Constructing optimized constraint-preserving application conditions for model transformation rules

https://doi.org/10.1016/j.jlamp.2020.100564Get rights and content

Abstract

There is an increasing need for model transformations ensuring valid result models w.r.t. a given constraint. In model refactoring, for example, each performed refactoring should yield a valid model again. Given a constraint, if a model transformation rule always produces valid output, it is called constraint-guaranteeing; if only when applied to an already valid model, it is called constraint-preserving. In the literature, there is a formal construction for model transformation systems making them constraint-guaranteeing. This is ensured by adding application conditions to their transformation rules. These conditions can become quite large, though. As there are interesting application cases where transformations just need to be constraint-preserving (such as model refactoring), the construction of application conditions was also adapted to this case. Although logically weaker, the straightforward construction can lead to even larger application conditions. In this work, we develop simplifications of constraint-guaranteeing conditions by omitting certain parts of these conditions, namely of parts that check for antecedent validity. We prove that the resulting application conditions are constraint-preserving and characterize their logical strength. Our theory is developed for M-adhesive categories which encompass various graph-like model structures. In addition, the computation of constraint-guaranteeing application conditions and their simplifications was implemented in the Eclipse plug-in OCL2AC. Evaluations show that the complexity of the constructed simplified conditions is reduced by factor 7 on average. Moreover, this optimization yields a speedup of rule application by approximately 2.5 times.

Introduction

Model transformations are the heart and soul of Model-Driven Engineering (MDE). They are used for various MDE-activities including translation, optimization, and synchronization of models [1]. Usually, a transformation (that may consist of several transformation steps) should yield a valid result model, especially if it has been applied to an already valid model. Intermediate models may not be required to be valid; this has been argued generally for software systems [2] and has been approved for modeling in, e.g., [3]. But there are scenarios where even intermediate models have to show validity, at least a basic one, as the following example applications show: (1) Throughout a larger refactoring process, each performed refactoring should preserve the model’s validity [4]. (2) More generally, any in-place model change should preserve a basic validity, enough to view an edited model in its domain-specific model editor [5]. Model editors typically ensure the creation of models with basic validity right from the beginning. This is the application scenario we will use as running example and for our evaluation. A similar scenario is considered in projectional editing for textual editors [6]. (3) Modeling the behavior of concurrent and distributed systems with model transformations, each model represents a system state that should fulfill system invariants such as safety properties [7]. (4) When generating code from abstractly specified model transformations, the transformations should be constraint-preserving, especially for safety-critical systems [8].

State of the art. From the formal point of view, the theory of algebraic graph transformation constitutes a suitable framework to reason about model transformations [9], [10], in particular about rule-based transformation of EMF models [11]. Constraints are typically expressed as (nested) graph constraints [12], [13], into which a large and relevant part of OCL [14] can be translated [15]. Graph constraints can be integrated as application conditions into graph transformation rules as shown in [13]: Given a rule and a constraint, there are two variants of integration, namely computing a constraint-preserving or a constraint-guaranteeing rule. Both computations do not alter the actions of the rule but equip it with application conditions. Graph validity is preserved if, applying an equipped rule to a valid graph, the resulting graph is valid as well. Graph validity is guaranteed if, applying an equipped rule to any graph, the resulting graph is valid. Besides, very recently the notion of (direct) sustainment of consistency has been introduced. It formalizes the idea that the application of a rule does not increase the amount of “invalidity” of a graph with respect to a given constraint. Sustainment is shown to imply preservation of the constraint in question [16].

Whereas no construction for sustaining rules has been presented, the known ones for preservation and guarantee have certain complexity issues. Theoretically, the number of graphs in a constraint-guaranteeing application condition can grow exponentially [17]. As there are interesting application cases where transformations just need to be constraint-preserving (as pointed out above), it is worthwhile to investigate this case further. Although logically weaker, following the construction in the literature, constraint-preserving application conditions may contain even more elements than corresponding constraint-guaranteeing ones. This is due to the approach taken: The premise that the model was already valid before rule application is added to the computed constraint-guaranteeing application condition. The resulting condition can be inherently difficult to simplify because of the used material implication operator.

Contributions. In this paper, we develop optimizing-by-construction techniques in the general context of M-adhesive categories [18], [10] to construct application conditions that preserve validity and present tool support to compute constraint-guaranteeing application conditions as well as the optimized constraint-preserving ones. We formally show the correctness of our approach, discuss the architecture of our tool, and empirically show that the resulting application conditions are considerably less complex which also leads to a faster application of the equipped rules.

In more detail: We take a constraint and a rule as starting point and construct an application condition that preserves validity. This construction is based on the construction of the constraint-guaranteeing application condition but simplifies it by omitting parts that check for antecedent validity, while keeping parts that prevent the introduction of violations. A first class of such possible simplifications is introduced in the general framework of so-called M-adhesive categories, which encompass (typed attributed) graphs in particular. We show that the resulting application condition is not only preserving but a weakest constraint-preserving application condition in some and a weakest consistency-sustaining one in other cases (Theorem 1). In both cases, this means that they cannot be further simplified from the logical point of view without losing their distinguishing property. We formally compare this result to the construction of constraint-preserving application conditions by Habel and Pennemann [13]. It shows that, in the case of weakest constraint-preserving application conditions, the results of their construction are semantically equivalent to ours; however, theirs are generally far more complex with regard to the condition structure. A second class of simplifications is specific for EMF models and proven to not alter the semantics of the simplified application condition when evaluated on EMF model graphs (Theorem 2); in particular, the properties of being constraint-guaranteeing or -preserving or directly consistency-sustaining are not altered by those simplifications (Corollary 3). We will argue how some of these simplifications omit global checks that have to traverse the whole model while keeping local ones, i.e., checks being performed in the context of a rule match.

Practically, we have implemented the computation of constraint-guaranteeing application conditions in the tool OCL2AC. It is able to automatically translate OCL constraints into graph constraints and to integrate these as application conditions into transformation rules specified in Henshin [19]. This is the first ready-to-use tool implementing this technique and addressing EMF, i.e., a commonly accepted framework in MDE. On top of the computation of constraint-guaranteeing application conditions, OCL2AC implements the proposed simplifications which result in weakest constraint-preserving or weakest directly consistency-sustaining application conditions. The simplifications take place during the construction of the constraint-guaranteeing application condition. It turns out that the computation of the simplified application conditions is faster compared to the computation of the whole constraint-guaranteeing application condition. Comparing the structures of constraint-guaranteeing and -preserving application conditions with that of our simplified ones, empirical results show a considerable loss of structural complexity.

We provide an application case which shows that constraint-preserving transformations are useful in practice. In domain-specific model editing (presented as scenario (2) above), every state of the editing process has to ensure a basic model validity. Each editing step in such a process is specified as rule-based transformation step. The example comprises the MagicDraw Statechart meta-model with 11 OCL constraints and 84 editing rules. The optimizations do not only reduce the size of computed application conditions considerably but also improve the performance when applying the resulting rules.

In addition, we conducted several evaluations that test the overall approach. We compared the run times of validity checking after a transformation using existing OCL validators (a posteriori approach) with running a constraint-preserving transformation (being enriched with application conditions) with and without optimization (a priori approach). Results show that both approaches are fast in practice. To the best of our knowledge, this is the first time that the implemented approach (of guaranteeing or preserving validity by the use of application conditions) is empirically investigated.

This paper is an extended version of [20] and in particular of [21]. Beyond these papers, we present the following new contributions:

  • 1.

    We lift our formal results from graph transformation to M-adhesive categories and present all proofs. This means that our results also cover attributed graphs and further structures.

  • 2.

    We considerably improve Theorem 1 by not only showing preservation of a constraint but also that the resulting application condition is indeed a weakest constraint-preserving or weakest directly consistency-sustaining application condition.

  • 3.

    We formally compare to the work of Habel and Pennemann [13].

  • 4.

    We present more details of OCL2AC by giving an overview of its implementation. The integration of our optimizations is presented in particular.

  • 5.

    We discuss related work more comprehensively.

Structure. The paper starts with presenting a running example in Sect. 2 and recalling the formal background in Sect. 3. Section 4 presents the theory of all the simplifications of application conditions and compares the results with existing notions. Section 5 presents the tool support. Section 6 contains several evaluations that test our approach and tooling. The longer proofs and two technical lemmas are outsourced to Appendix A.

Section snippets

Running example

In this section, we illustrate the effect of our optimizations on application conditions computed by OCL2AC. A simple Statecharts language serves as an example. Its meta-model is displayed in Fig. 1. A StateMachine contains at least one Region and Pseudostates as connection points if they are of kind entryPoint or exitPoint. A Region contains Transitions and Vertices. Vertex is an abstract class with concrete subclasses State and Pseudostate. A State may contain Regions and Pseudostates to

Formal background

Our approach is based on the theory of algebraic graph transformation [9], [10]. EMF models and model transformations can be formalized as typed attributed graphs and graph transformations as presented in [11]. These graphs with adequate morphisms form, in turn, a so-called M-adhesive category [18], [10]. We state our results in this formal framework to also cover various graph-like and other model structures such as Petri nets. In the following, we recall (i) M-adhesive categories and the

Optimizing application conditions

The constructions Gua and Pres, as recalled in the last section, allow constructing a constraint-guaranteeing or -preserving rule without altering its actions. This raises further questions: First, from a logical point of view, the application conditions used for that should be as weak as possible to allow for as many applications of the equipped rule as possible. Application condition false, for example, trivially is constraint-guaranteeing and -preserving for any rule relative to any

Tooling

We developed a tool, called OCL2AC [20], as an Eclipse plug-in implementing the existing theory [13], [15] and our simplifications for constructing constraint-guaranteeing and -preserving application conditions from given transformation rules and constraints. OCL2AC consists of two main components:

  • OCL2GC takes a set of OCL constraints as an input and automatically returns a set of semantically equivalent graph constraints as an output. This component performs several steps which are shown in

Evaluation

In this section, we show the highlights of our evaluation; all details can be found in separate artifacts.4

Research questions (RQs)  Our evaluation aims to answer the following RQs regarding the complexity and performance:

  • (RQ 1)

    How complex are the resulting application conditions with and without optimizations? How does this compare to the complexity of the original graph constraints?

To perform

Related work

We first discuss work that is related to our suggested construction of application conditions, i.e., work that is related to our theoretical contribution (1). Works related to our application scenario and evaluation are discussed subsequently. In our evaluation, we compared the performances of a posteriori validity checks with that of a priori checks. Therefore, here we compare (2) to other approaches that ensure transformations to be constraint-preserving (a priori approach) and (3) to

Conclusion

Application scenarios where each graph transformation step has to preserve the validity of models w.r.t. given constraints are needed in practice. As the construction of application conditions by Habel and Pennemann in [13] yields constraint-guaranteeing ones and assuming that the preservation of graph validity is already sufficient, the resulting application conditions can be considerably optimized. We developed several techniques (in Theorem 1 and Theorem 2) to construct optimized

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Acknowledgement

We are grateful to Annegret Habel, Christian Sandmann, and Steffen Vaupel for their helpful comments on the conference version of this paper.

References (58)

  • F. Steimann et al.

    Robust projectional editing

  • C. Krause et al.

    Probabilistic graph transformation systems

  • H. Giese et al.

    Towards verified model transformations

  • H. Ehrig et al.

    Fundamentals of Algebraic Graph Transformation

    (2006)
  • H. Ehrig et al.

    Graph and Model Transformation – General Framework and Applications

    (2015)
  • E. Biermann et al.

    Formal foundation of consistent EMF model transformations by algebraic graph transformation

    Softw. Syst. Model.

    (2012)
  • A. Rensink

    Representing first-order logic using graphs

  • A. Habel et al.

    Correctness of high-level transformation systems relative to nested conditions

    Math. Struct. Comput. Sci.

    (2009)
  • OMG

    Object constraint language

  • J. Kosiol et al.

    Graph consistency as a graduated property. Consistency-sustaining and -improving graph transformations

  • K.-H. Pennemann

    Generalized Constraints and Application Conditions for Graph Transformation Systems

    (2004)
  • H. Ehrig et al.

    Categorical frameworks for graph transformation and HLR systems based on the DPO approach

    Bull. EATCS

    (2010)
  • T. Arendt et al.

    Henshin: advanced concepts and tools for in-place EMF model transformations

  • N. Nassar et al.

    OCL2AC. Automatic translation of OCL constraints to graph constraints and application conditions for transformation rules

  • N. Nassar et al.

    Constructing optimized validity-preserving application conditions for graph transformation rules

  • No Magic

    Magic draw

  • T. Kehrer et al.

    Consistency-preserving edit scripts in model versioning

  • S. Lack et al.

    Adhesive and quasiadhesive categories

    Theor. Inform. Appl.

    (2005)
  • N. Nassar et al.

    Rule-based repair of EMF models: an automated interactive approach

  • Cited by (10)

    • Preface to the special issue on the 12th International Conference on Graph Transformation

      2020, Journal of Logical and Algebraic Methods in Programming
    • Visual Smart Contracts for DAML

      2022, Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
    • Graph repair and its application to meta-modeling

      2020, Electronic Proceedings in Theoretical Computer Science, EPTCS
    • Encoding incremental nacs in safe graph grammars using complementation

      2020, Electronic Proceedings in Theoretical Computer Science, EPTCS
    View all citing articles on Scopus

    This work was partially funded by the German Research Foundation (DFG), projects “Meta-Modeling and Graph Grammars: Generating Development Environments for Modeling Languages” (grant no. TA 294/13-2) and “Triple Graph Grammars (TGG) 2.0” (grant no. TA 294/17-1).

    View full text