A Metamodeling Level Transformation from UML Sequence Diagrams to Coq
Total Page:16
File Type:pdf, Size:1020Kb
A metamodeling level transformation from UML sequence diagrams to Coq Chao Li, Liang Dou and Zongyuan Yang East China Normal University Shanghai, China email: [email protected], ldou,yzyuan @cs.ecnu.edu.cn { } Abstract. Modeling is an important aspect of UML formal verifica- tion that directly affects the quality and efficiency of the verification. Formal models are the foundation of formal verification. As UML dia- grams only have semi-formal semantics, they cannot be used for formal verification directly. Recent studies present model transformation from semi-formal UML models to formal models to solve the issues. In this paper, a metamodeling level transformation tool from UML sequence diagrams to formal Coq codes is presented. Using Kermeta (a metamod- eling language) and predefined transformation rules that directly added to the metamodel of UML sequence diagrams, models of UML sequence diagrams are transformed into XMI, an intermediate format, and finally to formal Coq codes. This paper is part of our formal verification work for UML sequence diagrams, and the automatically generated Coq codes can be used for further formal verification using the theorem proof assistant Coq in our related works. This paper perfects the whole verification work and provides useful support to improve the integration density of formal verification in the formalization process of UML sequence diagrams. Keywords: UML sequence diagrams, model transformation, formal verifica- tion, metamodeling, Kermeta, Coq. 1 Introduction Unified Modeling Language (UML) [1] is standardized by Object Management Group (OMG), and has a set of notations to specify and model target system at varying levels of abstraction. For its powerful modelling capability, UML is increasingly popular in the design stage of model-based software development. Despite the wide use of UML, a number of problems have been identified due to its semi-formal semantics. For example, a developer’s understanding of UML models may differ from the designer’s understanding, tools for analyzing UML models may be limited to syntactic analysis [2], and system flaws may fail to be revealed in the design phase. In order to provide UML correct foundation of formal semantics, formal methods are getting popular to analyze UML mod- els. Formal methods are the application of precise mathematical fundamentals and techniques to specify systems (formal specification) [3], and provide a sys- tematical way to check the soundness and correctness of system models (formal 147 C.Li et al. A metamodeling level transformation from UML sequence diagrams to Coq verification) [4]. Hence, UML formal verification (UFV) makes up for the defi- ciencies of UML itself and eliminates the inconsistency of different understanding to system design. UML sequence diagrams have been widely used in the early stage of software development process. Different objects or processes are represented by parallel vertical lines in a sequence diagram. Objects or processes communicate with each other via messages that are represented by horizontal arrows. UML sequence diagrams play an important role in helping developers understand the runtime behaviours of system. Thus, it is important to verify the models when using UML sequence diagrams in the design stage. A great deal of UFV works have been done, most of them focus on two as- pects: the transformation rules from models of UML diagrams to formal models, and the verification process based on the formal models. In previous work [5] [6], we presented formal semantics of UML sequence diagrams and implemented formal verification of the correctness of the semantics in Coq [7], but the transfor- mation for UML sequence diagrams to Coq presentations is implemented man- ually and transformation rules are not presented systematically. Manual trans- formation has low efficiency in dealing with large scale models. In this work, we present the systematic transformation rules, and implement the automatic meta- modeling level transformation from UML sequence diagrams models to formal Coq presentations, which is the foundation for further formal verification. We have developed a prototype transformation tool using metamodeling languages Kermeta [8]. Metamodeling is the process to define a modeling language completely and precisely. The abstract syntax of modeling language is described by a metamodel, which is also defined in a metamodeling language. A metamodeling language is a superior language to describe modeling languages and it is also defined with a metamodel. The metamodel of a metamodeling language is called meta- metamodel, which is self-descibing [9]. Model transformation is used to create new models based on existing models. In stead of creating models from scratch, model transformation enables the reuse of information that was once modeled. Metamodeling level transformation ensures that the target model confirms to the target metamodel specification, hence, the transformation is syntactically correct. In addition, metamodeling and model transformation are fully supported by Kermeta. Kermeta is an executable metamodeling language which supports metamodeling level transformation. Moreover, Kermeta stores data of model and metamodels in XML Metadata Interchage (XMI) files, which is widely used among different modeling tools. Hence, it is sufficient for Kermeta to transform UML sequence diagrams to Coq. The rest of the paper is structured as follows. Firstly, the related work is reviewed in Section 2. Section 3 recalls the model transformation in Kermeta and briefly introduces Coq. Transformation rules and a case study are showed in Section 4. Finally, we conclude in Section 5. 148 C.Li et al. A metamodeling level transformation from UML sequence diagrams to Coq 2 Related Work A variety of formalization work has been proposed for UML diagrams over the years. A formal framework is provided to support visual simulation of UML models that composed of class, object, state, sequence and collaboration dia- grams, and an integrated semantics of these models is presented in [11]. How- ever, it only focus on the semantics building and transformation rules of UML diagrams, but further verification of modeling process is not considered. In [12], some useful rules for transforming sequence diagram to petri net are presented, but the transformation process in that work is done manually. In [13], conven- tional programming language, Java, is used to navigate, create, read or delete models and model elements via specific libraries, all the transformations are at modeling level. However, we use the metamodeling language Kermeta to imple- ment a metamodeling transformation tool, which can transform models of UML sequence diagrams to formal presentations and ensure the syntactic correctness of the transformation at the same time. In [14] [15], UML state diagrams or activity diagrams are firstly formalized with operational semantics, and then translated into input code of formal verification, but they do not provide an automatic transformation tool. In contrast, an automatic translation of state charts and sequence diagrams into generalized stochastic nets is proposed in [16] [17], and their transformation are at metamodeling level. Our work not only presents transformation rules at metamodeling level, but also implement a transformation process from UML sequence diagrams to Coq codes automatically in Kermeta. The generated codes can be used for further formal verification. 3 Background 3.1 Metamodeling and Model Transformation in Kermeta Kermeta is an executable metamodeling language which supports describing both structures and behaviours of metamodels. Kermeta is integrated with Eclipse, and distributed as Eclipse plug-in. It is fully compatible with the OMG Essential Meta-Object Facility (EMOF) [18] and Ecore of Eclipse Modeling Framework (EMF) [19]. It provides an action language to specify the body of operations in metamodels. The action language of Kermeta is imperative and object-oriented. It also integrates aspect-oriented features, and supports some design-by-contract features. As Kermeta relies on EMF for model storage, regular EMF metamodels, Ecore files, can be used. These metamodels can be created and edited using the generic model editor provided with the EMF. Operations can be added to any class in metamodels using the action language provided by Kermeta. In addition, once the source metamodel is created, source model that confirms to the source metamodel can be generated manually using the model editor. Model transformation in Kermeta takes one source model as input, and pro- duces one target model as output. Both source model and target model should 149 C.Li et al. A metamodeling level transformation from UML sequence diagrams to Coq conform to specific metamodel or abstract syntax, and transformation rules should be defined to drive the transformation. That is, given the source model, source and target metamodel (or abstract syntax), and transformation rules, target model can be generated automatically. In order to write a model transformation in Kermeta, the source and target metamodels (or abstract syntax) should be defined at first. In our work, UML sequence diagrams is the source modeling language and Coq is the target mod- eling language. Metamodel of UML sequence diagrams and abstract syntax of Coq are explained in the following sections. 3.2 Metamodel of UML Sequence Diagrams Figure 1 displays the metamodel of UML sequence diagrams which has been defined in Ecore using the EMF editor. This metamodel has been simplified, but covers