GRoundTram: An Integrated Framework for Developing Well-Behaved
Bidirectional Model Transformations
Soichiro Hidaka∗ , Zhenjiang Hu∗ , Kazuhiro Inaba∗ § ,Hiroyuki Kato∗ and Keisuke Nakano†∗ National Institute of Informatics, Japan
Email: {hidaka,hu,kinaba,kato}@nii.ac.jp† University of Electro-Communications, Japan
Email: ksk@cs.uec.ac.jp

Abstract— Bidirectional model transformation is useful for
maintaining consistency between two models, and has manypotential applications in software development including modelsynchronization, round-trip engineering, and software evolution. Despite these attractive uses, the lack of a practical
tool support for systematic development of well-behaved andefﬁcient bidirectional model transformation prevents it frombeing widely used. In this paper, we solve this problem
by proposing an integrated framework called GRoundTram,
which is carefully designed and implemented for compositional
development of well-behaved and efﬁcient bidirectional modeltransformations. GRoundTram is built upon a well-foundedbidirectional framework, and is equipped with a user-friendly
language for coding bidirectional model transformation, a
new tool for validating both models and bidirectional modeltransformations, an optimization mechanism for improving
efﬁciency, and a powerful debugging environment for testingbidirectional behavior. GRoundTram has been used by peopleof other groups and their results show its usefulness in practice.

I. I NTRODUCTION
Bidirectional model transformation [1–5], being anenhancement of model transformation with bidirectional capability, is an important requirement in OMG’sQueries/Views/Transformations (QVT) standard [6]. It describes not only a forward transformation from a source
model to a target model, but also a backward transformation
showing how to reﬂect the changes in the target model tothe source model so that consistency between two models
is maintained. Unlike (unidirectional) model transformation
where lots of tools have been developed for supporting
design, validation, and test of model transformation, bidirectional model transformation lacks such useful tools, which
prevents it from being widely used. In fact, new requirements
and challenges are introduced in the context of bidirectionalmodel transformation.
First and most important, we should be sure that thebidirectional model transformation behaves exactly as wewant. Unlike unidirectional model transformation, bidirectional model transformation has more complicated behavior§ Current afﬁliation is Google Inc. Email: kiki@kmonos.net

than unidirectional one. It should be well-behaved in thesense that both forward and backward transformations are
consistent with each other and satisfy the roundtrip property[1]. As argued in [2], there exist semantic issues in many
existing tools.
Next, bidirectional model transformations should be compositional to reuse existing transformations and constructbigger ones from smaller ones. As indicated in the conclusion in [7], most model transformation languages basedon graph transformations are rule-based, describing direct
relationship between the source and target models. They
are not compositional in the sense that we cannot introduce
intermediate models for gluing model transformations. This
makes them hard to support systematic development ofmodel transformations in the large [8]. However, composition comes at the cost of efﬁciency; many unnecessaryintermediate models might be produced. Therefore, an optimization method are required to automatically eliminate
unnecessary intermediate models during execution.
Furthermore, bidirectional model transformation shouldbe general enough as it is used at various stages of softwaredevelopment life cycle. It is applied to different models
such as UML diagrams, sequence diagrams, Petri-nets, andeven lower level control/data ﬂow graphs. While visualframeworks are useful in high level design, general textbased languages play an important role in developing largescale transformations, say, to deal with lower level mapping
or complex code refactoring. Besides, we would expect
to have a set of language-based tools for type checking(validating) both models and bidirectional model transformations to remove unnecessary errors before execution, anefﬁcient execution model, and a tool for testing/debugging
bidirectional behavior. We believe that such language-basedmodeling environments play important role in bidirectionalmodel transformation.
In this paper, we remedy this situation by proposing alanguage-based modeling framework called GRoundTram[9], which is carefully designed and implemented for compositional development of well-behaved and efﬁcient bidirectional model transformation at various stages of software

development. Our work is greatly inspired by recent researchon bidirectional languages and automatic bidirectionalizationin the programming language community [10–13]. In particular, it has been recently shown [14] that a graph query
algebra UnCAL can be fully bidirectionalized. Each graphtransformation in UnCAL has a clear bidirectional semantics
and is guaranteed to be well-behaved.
This paper is about a successful application of the resultof a bidirectional graph query algebra in the programming
community to the construction of a framework for developing bidirectional model transformation in the software
engineering community. Our main technical contributions
are summarized as follows.
Well-Behavedness. We propose a novel bidirectionalgraph contraction algorithm so that we can build wellbehaved bidirectional model transformations upon thewell-founded bidirectional UnCAL algebra. In fact,
there is a gap between the UnCAL graphs and themodels in model transformation: graphs in UnCAL areedge-labeled and their equality is deﬁned by bisimulation, while models in model transformation may havelabels on both edges and nodes and their equality isdeﬁned by unique identiﬁers. We close this gap so thatevery UnCAL graph has a bidirectional correspondencewith a model.
+• Compositional. We design a UnQL , a purely functional languages for developing large bidirectionalmodel transformations in a compositional way. UnQL+
is an extension of the graph query language UnQL [15]with new additional language constructs for graphtransformation. We show that any UnQL+ program
can be correctly translated to an UnCAL construct
and inefﬁciency due to intermediate models in thecomposition can be automatically eliminated.
• Languages-based IDE. We implement an integrated
development environment GRoundTram, which has anovel tool for validating both models and bidirectional model transformations, an automatic optimization mechanism for improving efﬁciency, and a powerful debugging environment for testing bidirectional
behavior. The system (including the sources, the documents, and many application examples) is available
online [9], and has been and is being used by peopleof other groups for developing some nontrivial applications. Their results indicate its usefulness in practice.

Source Model(DOT/UnCAL)

Source Schema
(KM3)

Model
Validation

Transformation(UnQL+)

Target Schema(KM3)

Model Transformation
Validation

Veriﬁed Transformation
Source Model(DOT)

ForwardTransformation

Target Model(DOT)

Graph Update

Bidirectional
Transformation

Graph Update

Updated Source Model(DOT)

Backward
Transformation

Updated Target Model(DOT)•II. OVERVIEW OF GROUND T RAM
Figure 1 shows the basic functions the GRoundTram
system provides.
A. Input
The input to the system is a source model together with its
schema, a transformation described in UnQL+ , and a target

Figure 1.

Overview of GRoundTram

Figure 2.

A Class Diagram

model schema. The target model is produced by the forward
transformation.
• Model. Models are represented by general edge-labeledgraphs, which form a general representation of various
models. As a concrete example, consider the classmodel diagram in Figure 2. It consists of three classes
and two directed associations, and each class has aprimary attribute. This model can be represented by
the graph where information is moved from nodes toedges.
• Model Schema (Metamodel). Each model has a structure. For instance, a class diagram has the following
structure. A class diagram consists of classes and directed associations between classes. A class is indicatedas persistent or non-persistent. It consists of one ormore attributes, at least one of which must be marked
as constituting the classes’ primary key. An attributetype is of a primitive data type (e.g. String, Integer).
An association speciﬁes an inheritance relation between
two classes. KM3 [16] is used to describe such a modelstructure, and its deﬁnition can be found in [9].

•Model Transformation. (Forward) Model transformation is described compositionally in UnQL+ , a SQLlike graph query/transformation language. As an example, consider extracting all persistent classes fromthe class model $db, and transforming them to tables by replacing Attributes by Columns. This canbe described compositionally as follows, where theintermediate model $persistentClass is used in thiscomposition.
select{tables : $table} where$persistentClass in(* select classes *)(select $class where{Association.(src|dest).Class : $class} in $db,
{is persistent : {Boolean : true}} in $class),$table in(* replace Attribute *)(replace attrs → $gby (select{Column : $a} where{attrs.Attribute : $a} in $persistentClass)in $persistentClass)

B. Validation
In order to detect errors during development as earlyas possible and help users to develop a correct models
and transformations, the GRoundTram system provides twotypes of validation mechanisms.
• Model Validation. Conformance of the source and thetarget model to their associated schemas can be veriﬁedby the system. In particular after editing the models, it
is important to check that they are in valid states.
• Model Transformation Validation. Correct modeltransformations should always generate a target model
conforming to the target schema from any source modelsatisfying the source schema.
While the model validation is quite standard, a generalmodel transformation validation is more challenging but
more useful in developing correct model transformation.
As an instance of simple erroneous transformation, suppose the user made an error writing select $a instead of
select {Column : $a} in the previous example. Its outputs
do not conform to the schema and hence reported by thesystem. The check is automatic and static. Users neither
have to provide any test cases by hand nor execute thetransformation for testing; the system automatically ﬁnds outand displays an example of a source model that reveals theproblem (in this case, a class model containing at least one
persistent class).
C. Bidirectional Transformation
The GRoundTram system is unique in its execution ofwell-behaved bidirectional transformation, as seen in thelower part of Figure 1.
• Forward Transformation. After the user speciﬁed thesource model and the UnQL+ model transformation,

Figure 3.

GUI of GRoundTram

by running the transformation with the model set to$db variable, the target model is computed. Like thesource model, the target model can also be exported in
the standard DOT format and be edited.
• Backward Transformation. The most distinct feature of GRoundTram is the automatic derivation ofbackward transformations that appropriately propagate
modiﬁcations on target models to source graphs. Thereis no need to maintain two separate transformations
and to worry about their consistency. Users just write
a forward transformation from one model to anotherin a compositional way, and a corresponding backward
transformation is automatically derived.
III. I MPLEMENTATION OF GROUND T RAM
A. Graphic User Interface
The GRoundTram system combines all the functions as anintegrated framework with a user-friendly GUI (Figure 3).
The user loads a source graph (displayed in the left pane)
and a bidirectional transformation written in UnQL+ . Oncethey are loaded, forward transformation can be conductedby pushing the “forward” button (right arrow icon). The
target graph appears on the right pane. User can graphically
edit the target graph and apply backward transformation bypushing the “backward” button (left arrow icon). Source
graph can be edited as well, of course. User can optionallyspecify the source schema and the target schema, and canrun validation by pushing the check button on both panes.
The transformation itself can also be checked.
For ease of debugging/understanding behavior of bidirectional computation between two models, trace information
is instantly displayed between source and target (red part inFigure 3). If subgraphs on either pane are selected, corresponding subgraphs on the other pane are also highlighted.
This helps users to understand how modiﬁcation on thetarget affects that on the source, and vice versa.
B. System Architecture
Figure 4 depicts the architecture of the system. We provide
a new model transformation language UnQL+ , and we ac-Figure 4. GRoundTram Implementation on Bidirectional UnCAL Engine

cept models that are described by edge-labeled graphs which
are general enough to capture various kinds of models. We
implement the GRoundTram system upon the powerful engine of bidirectional UnCAL, where a set of language-based
tools have been developed: a bidirectional interpreter [14], agraph and graph transformation veriﬁer [17], an optimizer toimprove efﬁciency [18], and a checker of valid updates in thebackward transformation [19]. The key contributions in thisimplementation are (1) a translation of UnQL+ to UnCAL
to enable use of the engine of bidirectional UnCAL, and (2)a bidirectional graph contraction algorithm for contracting
bisimilar UnCAL graphs so that a usual model can have abidirectional correspondence with an UnCAL graph.
IV. C ONCLUDING R EMARKSThe GRoundTram system has been fully implemented andis available online. The system website [9] provides a bunchof examples, big and small, including the known nontrivial(bidirectional) model transformation between UML class
diagrams and relational databases.
This work is our ﬁrst step towards bidirectional model
programming, a linguistic framework to support systematicdevelopment of model transformation programs. In the future, we wish to look more into relation between the rulebased approach and the algebraic and functional approach,and see how to integrate them to have a more powerfulframework for bidirectional model transformation.
R EFERENCES[1] K. Czarnecki, J. N. Foster, Z. Hu, R. Lämmel, A. Schürr, andJ. F. Terwilliger, “Bidirectional transformations: A cross-discipline
perspective,” in International Conference on Model Transformation(ICMT 2009). LNCS 5563, Springer, 2009, pp. 260–283.
[2] P. Stevens, “Bidirectional model transformations in QVT: Semantic
issues and open questions,” in Proc. 10th MoDELS, ser. Lecture Notes
in Computer Science, G. Engels, B. Opdyke, D. C. Schmidt, andF. Weil, Eds., vol. 4735. Springer, 2007, pp. 1–15.

[3] ——, “A landscape of bidirectional model transformations,” in Generative and Transformational Techniques in Software Engineering II,R. Lämmel, J. Visser, and J. a. Saraiva, Eds. Berlin, Heidelberg:
Springer-Verlag, 2008, pp. 408–424.
[4] H. Ehrig, K. Ehrig, C. Ermel, F. Hermann, and G. Taentzer, “Information preserving bidirectional model transformations,” in Proceedingsof the 10th international conference on Fundamental approaches tosoftware engineering, ser. FASE’07. Berlin, Heidelberg: SpringerVerlag, 2007, pp. 72–86.
[5] M. Antkiewicz and K. Czarnecki, “Design space of heterogeneoussynchronization,” in GTTSE ’07: Proceedings of the 2nd Summer
School on Generative and Transformational Techniques in Software
Engineering, 2007.
[6] OMG, “MOF QVT ﬁnal adopted speciﬁcation,” http://www.omg.org/docs/ptc/05-11-01.pdf, 2005.
[7] K. Ehrig, E. Guerra, J. de Lara, L. Lengyel, T. Levendovszky,
U. Prange, G. Taentzer, D. Varró, and S. Varró-Gyapay, “Modeltransformation by graph transformation: A comparative study,” inMTiP 2005, International Workshop on Model Transformations inPractice. Springer-Verlag, 2005.
[8] F. Klar, A. Königs, and A. Schürr, “Model transformation in thelarge,” in ESEC/SIGSOFT FSE, I. Crnkovic and A. Bertolino, Eds.
ACM, 2007, pp. 285–294.
[9] “The BiG project web site,” http://www.biglab.org/.
[10] J. N. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, andA. Schmitt, “Combinators for bi-directional tree transformations: alinguistic approach to the view update problem.” in POPL ’05:
ACM SIGPLAN–SIGACT Symposium on Principles of Programming
Languages, 2005, pp. 233–246.
[11] K. Matsuda, Z. Hu, K. Nakano, M. Hamana, and M. Takeichi,“Bidirectionalization transformation based on automatic derivation ofview complement functions,” in 12th ACM SIGPLAN International
Conference on Functional Programming (ICFP 2007). ACM Press,
Oct. 2007, pp. 47–58.
[12] A. Bohannon, J. N. Foster, B. C. Pierce, A. Pilkiewicz, andA. Schmitt, “Boomerang: resourceful lenses for string data,” inPOPL ’08: ACM SIGPLAN–SIGACT Symposium on Principles ofProgramming Languages, G. C. Necula and P. Wadler, Eds. ACM,
2008, pp. 407–419.
[13] Z. Hu, S.-C. Mu, and M. Takeichi, “A programmable editor for developing structured documents based on bidirectional transformations,”
Higher-Order and Symbolic Computation, vol. 21, no. 1-2, pp. 89–118, 2008.
[14] S. Hidaka, Z. Hu, K. Inaba, H. Kato, K. Matsuda, and K. Nakano,“Bidirectionalizing graph transformations,” in ACM SIGPLAN International Conference on Functional Programming. ACM, 2010, pp.
205–216.
[15] P. Buneman, M. F. Fernandez, and D. Suciu, “UnQL: a querylanguage and algebra for semistructured data based on structural
recursion,” VLDB Journal: Very Large Data Bases, vol. 9, no. 1,pp. 76–110, 2000.
[16] F. Jouault and J. Bézivin, “KM3: A DSL for metamodel speciﬁcation,” in Formal Methods for Open Object-Based Distributed Systems.
LNCS 4037, Springer, 2006, pp. 171–185.
[17] K. Inaba, S. Hidaka, Z. Hu, H. Kato, and K. Nakano, “Graphtransformation veriﬁcation using monadic second-order logic,” inProceedings of the 13th ACM SIGPLAN international conference onPrinciples and practice of declarative programming (PPDP 2011),
Odense, Denmark, 2011.
[18] S. Hidaka, Z. Hu, K. Inaba, H. Kato, K. Matsuda, K. Nakano,and I. Sasano, “Marker-directed Optimization of UnCAL GraphTransformations,” in Proceediings of 21st International Symposiumon Logic-Based Program Synthesis and Transformation (LOPSTR2011), Odense, Denmark, 2011.
[19] K. Nakano, S. Hidaka, Z. Hu, K. Inaba, and H. Kato, “Simulationbased graph schema for view updatability checking of graphqueries,” GRACE Center, National Institute of Informatics, Tech.
Rep. GRACE-TR11-01, May 2011.