Girts Linde. Semantics and equivalence of UML class diagrams

advertisement
UNIVERSITY OF LATVIA
Institute of Mathematics and Computer Science
ĢIRTS LINDE
SEMANTICS AND EQUIVALENCE OF UML
CLASS DIAGRAMS
Summary of Doctoral Thesis
Advisor:
Professor, Dr. habil. sc. comp.
JĀNIS BĀRZDIŅŠ
R i g a - 2004
Advisor:
Professor, Dr. habil. sc. comp. Jānis Bārzdiņš
University of Latvia
Referees:
Professor, Dr. habil. sc. comp. Audris Kalniņš
University of Latvia
Professor, Dr. habil. sc. ing. Jānis Osis
Riga Technical University
Dr. sc. comp. Uģis Sarkans
European Institute of Bioinformatics (United Kingdom)
The defense of the thesis will take place in an open session of the Council for
Promotion in Computer Science, University of Latvia, on 10.09.2004 at 12:00
in the Institute of Mathematics and Computer Science, the University of Latvia
(Rīga, Raiņa bulv. 29, room 413).
The thesis (collection of works) and its summary are available at the Library of the
University of Latvia (Kalpaka bulv. 4, Rīga).
Head of the Council
Jānis Bārzdiņš
1 Introduction
The research on the thesis "Semantics and Equivalence of UML Class
Diagrams" is done from 1996 to 2003 in the Faculty of Physics and Mathematics and
in the Institute of Mathematics and Computer Science of the University of Latvia. The
scientific advisor of the thesis is professor J. Barzdins. The main results of the thesis
are reflected in 9 publications and presented in 5 international conferences.
The thesis is formed as a collection of 5 related papers about the problems of
semantics of UML class diagrams. Several methods for definition of semantics and
equivalence of class diagrams are presented in the thesis, as well as algorithms for
analysis of equivalence of class diagrams.
The goal of the thesis is to develop a mathematically precise framework for the
definition of semantics of UML class diagrams, and to formalize the "intuitive
equivalence" of class diagrams.
In the first chapter “Learning of Formulae from Finite Examples” a method
of semantics definition of UML class diagrams is proposed, which is based on manysorted first order logic with equality. It allows to prove nontrivial properties of class
diagrams. In the proposed formalization, class diagrams are converted to logic
formulas and instance diagrams are converted to interpretations, and according to this
transformation the semantics of class diagrams is defined on basis of semantics of
logic. Using this semantics, it is proved that simplified class diagrams are
synthesizable in limit from instance diagrams.
In chapter “The Cartoon Method of Semantics Definition for Modeling
Languages” a fundamentally new method of semantics definition for UML class
diagrams is proposed – the cartoon method. This method allows to define the
semantics of the basic concepts of object modeling – the object, the class, the
association, the link. This method formalizes the intuitive cognitive process that
builds an object model. A thesis is formulated, which states that every intuitive
cognitive process that builds an object model can be adequately represented with the
formally defined cognitive process. The formalized cognitive process is used in the
further work to define the "intuitive equivalence" of class diagrams.
In chapter “Equivalence Problem of Composite Class Diagrams” the
equivalence of composite class diagrams is studied. The canonical class diagram is
3
defined, in which the multiplicities of all associations and classes are consistent. An
algorithm is developed for transforming of a class diagram to the canonical form by
correcting multiplicities. Using the canonical class diagram an algorithm is developed,
which decides whether two given class diagrams are equivalent. These algorithms can
be used for the analysis of multiplicities in CASE tools. The results of this chapter
will also be needed for the algorithms in the following chapters.
In chapter “Reduction of UML Class Diagrams” a definition of the "intuitive
equivalence" of class diagrams is proposed. Using composite classes new concepts
are defined that are used to transform a class diagram into another class diagram
(reduction of diagrams). Two class diagrams are considered "intuitively equivalent" if
one of them can be reduced to the other one by such transformation. An algorithm is
developed, which determines whether two class diagrams are "intuitively equivalent"
by this definition. This algorithm can be used in CASE tools to analyze alternative
models of a system. It can be also used for "compression" of class diagrams, to
facilitate work with large class diagrams.
In chapter “Semantics and Equivalence of UML Class Diagrams” a new
definition of the "intuitive equivalence" of class diagrams is proposed. It is based on
the formalized cognitive process by comparing the detail level of cognition paths. If
two class diagrams satisfy the defined conditions, then we say that one of the class
diagrams semantically implies the other class diagram. It is proved that the reduction
of class diagrams is a special case of the semantical implication. The theoretical
results confirm that we are getting closer to the concept of "intuitive equivalence", the
formalization of which is one of the main goals of this work.
2 Definition of Precise Semantics for UML Class
Diagrams
In the recent years UML (Unified Modeling Language) has become a de facto
standard for system modeling in software development. Many tools are developed for
creating UML class diagrams. Class diagrams are convenient for modeling the
structure of complex systems, but the visual class diagram language is semi-formal. A
formal semantics of this language is not defined. This causes several problems:
-
without additional explanations different people can understand a class
diagram if different ways,
4
-
diagrams cannot be processed algorithmically, e.g., analysis of
alternative models of a system, algorithmical transformation, automated
testing is not possible.
The research in the field of semantics definition for UML class diagrams is
already being done. Various methods of semantics definition are developed that use
algebraic specifications [6], Object Calculus [4], specification language Z [8],
semantic networks [1,3]. In this thesis a fundamentally new approach to semantics
definition of class diagrams is developed, using the formalization of the cognitive
process. But first the possibilities for application of a more traditional method of
semantics definition are explored.
2.1 Definition of Semantics of Class Diagrams with First
Order Logic
In this chapter a method of semantics definition of UML class diagrams is
proposed, which is based on the many-sorted first order logic with equality. It is
known, that the semantics of this logic is mathematically defined and therefore
unambiguous. Definition of semantics of class diagrams with logic would enable us to
prove nontrivial properties of class diagrams and explore the possibilities to apply the
results of logic to class diagrams. One of such results developed in logic is [2], which
explores synthesis of logic formulas from examples – infinite models. But in object
modeling the examples are finite – those are instance diagrams. In this chapter it is
proved that simplified class diagrams are synthesizable in limit from instance
diagrams. The synthesis algorithm is developed in terms of logic and then applied to
class diagrams using the formally defined semantics.
Fig. 1 Formalization approach
5
The essence of the proposed method of semantics definition is represented in
Fig. 1. To define the semantics of class diagrams precisely (i.e., the correspondence
between instance diagrams and class diagrams), class diagrams are translated into
logic formulas and instance diagrams are translated into interpretations. The
correspondence of interpretations to formulas is already defined by the semantics of
logic.
This method of semantics definition is very natural and allows to solve practical
problems, but it is not able (like [1,3,4,6,8]) to define the semantics of the basic
concepts of class diagrams. This problem is explored in the next chapter.
2.2 Cartoon Method of Semantics Definition of Class
Diagrams
So far all the methods define semantics only for class diagrams – the class
diagram as a statement about instance diagrams. The semantics of the basic concepts
(object, class, association, link) remains unclear. The traditional methods of semantics
definition of formal languages don't work in this case. In this chapter a new method of
semantics definition is developed – the cartoon method, which looks deeper into the
semantics of the basic concepts. It is based on the formalization of the intuitive
cognitive process. The intuitive cognitive process that takes place in the modeler's
mind when he builds an object model is described with a mathematically precise
framework. The basic structure of the formalization is an oriented graph, which
describes the cognition state (Fig. 2). It contains the state of the real world and the
state of the abstract world. The state of the abstract world represents the concepts that
appear in the object modeling process – objects, links, classes and associations, and
connections between them.
Fig. 2 A cognition state
6
During the formal cognitive process a cognition path – a sequence of cognition
states – is built. The cognition path starts with the cognition start state, in which the
state of the abstract world is empty. Then every following cognition state is produced
from the previous state by making a cognition step – adding a new element to the state
of the abstract world. The method precisely defines all the possible cognition steps,
they are such as, add an object (Fig. 3), add a class e.t.c.
Fig. 3 A cognition step – add an object
The idea of the method of semantics definition is outlined in Fig. 4 – together
with the intuitive cognitive process we build a corresponding formal cognition path,
on which the semantics of the used concepts can be explained. The following thesis is
proposed:
Every intuitive cognitive process that builds an object model can be adequately
represented with the formally defined cognitive process.
The name "cartoon method" was chosen for this method of semantics definition,
because an analogy with cartoons can be observed here. In cartoons the real world is
represented with simplified cartoon objects on the screen, which nevertheless allow us
to adequately perceive the situation. In analogy with cartoons, the semantics
definition method represents the concepts of the real world with simplified, but
mathematically precise concepts. The most typical application of the cartoon method
to the semantics definition is the Church-Turing thesis. There the intuitive real world
objects – algorithms – are represented with mathematically precise "cartoon" objects
– Turing machines. The Church-Turing thesis states that the representation is
adequate.
7
Fig. 4 Formalization of the cognitive process
The cartoon method of semantics definition embodies several original aspects
that have not been used in semantics definition of object modeling before:
-
The mental cognitive process that creates object models is represented
formally.
-
A model of the real world is added, which allows to clearly show the
connections between the real world and the abstract world. All other methods
of semantics definition function only in the abstract world.
-
It is possible to clearly distinguish purely abstract objects (which in some
sense correspond to syntactical objects described in [5]) from the objects that
are derived from the real world.
A theorem is proved that confirms that with the formally defined cognitive
process it is possible to build any enumerable object model.
3 Equivalence Problem of UML Class Diagrams
When the semantics of class diagrams is precisely defined, we can start
researching the problem of the equivalence of class diagrams. Consider these three
class diagrams that model oriented graphs (Fig. 5).
8
Fig. 5 Three class diagrams modeling an oriented graph
Formally these are three different class diagrams. Each of them describes a
different set of instance diagrams. But intuitively we know that all these three
diagrams describe the same real world – oriented graphs. In this sense they are
"intuitively equivalent". The research goal of this part of the work is to formalize this
"intuitive equivalence" of UML class diagrams. But first the composite class diagrams
are explored and their equivalence in the usual sense, these results are used in the
further work.
3.1 Equivalence of Composite Class Diagrams
The equivalence problem is considered for simplified class diagrams, which are
the contents of a composite class. A composite class diagram can contain:
-
classes with multiplicity,
-
binary associations,
-
only the four most popular multiplicities (1..1, 0..1, 1..*, 0..*)
As it turns out, even for such a constrained language the equivalence problem is
not trivial. Fig. 6 shows 3 class diagrams that look quite different, but they describe
the same set of instance diagrams, hence they are equivalent.
Fig. 6 Three equivalent class diagrams
9
The class diagram (c) has the strongest multiplicities among these three
diagrams. Besides, it is also the most precise of all possible class diagrams describing
the same set of instance diagrams. To denote class diagrams with this property, a
special term is introduced – the canonical class diagram. The main results of this
chapter are algorithms for transformation and analysis of composite class diagrams:
-
An algorithm is developed, which transforms a given composite class diagram
into the canonical form. It is based on equivalence preserving transformations
of multiplicities. This algorithm can be applied in CASE tools to detect and
correct inconsistent multiplicities in class diagrams.
-
Using the transformation to the canonical form another algorithm is
developed, which determines if two composite class diagrams are equivalent.
3.2 Reduction of Class Diagrams
Consider the example in Fig. 7. It shows two class diagrams describing the same
situation – a person owns a car.
Fig. 7 Class diagrams with different detail levels
The diagram (a) is more detailed than the diagram (b), it describes more
practical details of owning a car. In this chapter a formal definition of such an
"intuitive equivalence" is developed. Its essence is the following: two class diagrams
are considered "intuitively equivalent", if the more detailed diagram can be reduced to
the less detailed diagram, using the method described here.
10
Fig. 8 Class diagram with new concepts
The foundation of the class diagram reduction is the definition of new concepts
from the elements of the existing class diagram. A set of new concepts is created, in
which every concept is described with a composite class. Fig. 8 shows a class diagram
with the new concepts added. The new concepts are defined so that the instances of
each concept are internally connected. If the set of new concepts is defined correctly,
then every instance diagram that corresponds to the class diagram can be split into
fragments corresponding to the new concepts. In this case a reduced class diagram
can be constructed, in which the new concepts are used as classes.
In this chapter algorithms are developed for solving the reduction problem:
-
an algorithm that decides if a set of concepts is correct for a given class
diagram,
-
an algorithm that for a given class diagram and a set of concepts constructs the
reduced class diagram,
-
an algorithm that for two given class diagrams determines if one of them can
be reduced to the other one, i.e., if they are "intuitively equivalent".
3.3 Semantical Implication of Class Diagrams
The reduction of class diagrams just described is based on the traditional
semantics, which relates instance diagrams to class diagrams. However, the new
cartoon method of semantics definition allows to go deeper into the research of the
equivalence of class diagrams. In this chapter a definition of the "intuitive
equivalence" is developed, which is based on the formalized cognitive process – the
semantical implication. The foundation of the definition is a method of comparing the
formal cognition paths – we define that one cognition path is more detailed than the
11
other, if from one path the other path can be constructed aggregating certain elements
and preserving some structural properties.
Consider two class diagrams A and B, and an arbitrary state of the real world R.
When comparing these two class diagrams, the following condition is important: if
from the state of the real world R an instance diagram for the class diagram A can be
constructed by some cognition path, then with a less detailed cognition path we can
construct an instance diagram also for the class diagram B. If this condition holds for
every state of the real world, then we say that the diagram A semantically implies the
diagram B.
It is proved that the reduction of class diagrams is a special case of the
semantical implication. The theoretical results show that the semantical implication is
now very close to the concept of the "intuitive equivalence", the formalization of
which is one of the main goals of the thesis.
4 Conclusion
The following are the main results achieved in this work:
1. Synthesizability in limit of simplified class diagrams is proved, using the
semantics of class diagrams based on the many-sorted first order logic with equality.
2. A new method of semantics definition for object modeling languages is
proposed, based on the formally defined cognitive process. It allows to define the
semantics of the basic concepts of object modeling – the class, the association, the
object, the link. A thesis is formulated that every intuitive cognitive process that
builds an object model can be adequately represented by the formally defined
cognitive process.
3. A definition of the "intuitive equivalence" of UML class diagrams is
developed, based on the reduction of class diagrams. The foundation of the class
diagram reduction is the idea of definition of new concepts using composite classes.
4. An algorithm is created that for two given simplified class diagrams decides if
one of them can be reduced to the other one. This algorithm can be used in CASE
tools to compare alternative models of a system, and for "compression" of large class
diagrams for easier understanding, e.g. for diagrams resulting from reverse
engineering of legacy software.
12
5. An improved definition of the "intuitive equivalence" of UML class diagrams
is developed, using the semantical implication of class diagrams. The semantical
implication is based on the formal cognitive process. A theorem is proved that the
reduction of class diagrams is a special case of the semantical implication.
These results allow to mark some directions for further research:
-
synthesizability for a richer class diagram language,
-
equivalence for a richer class diagram language,
-
reduction for a richer class diagram language,
-
possibility to use "composite associations" as new concepts in class diagram
reduction,
-
existence of the "maximally reduced" class diagram for a given class diagram,
-
using the ideas of reduction, define the "intuitive equivalence" between class
diagrams that cannot be directly reduced one to another (perhaps using a
common "maximally reduced" class diagram), verify the algorithmical
decidability of such "equivalence",
-
verify the algorithmical decidability of the semantical implication.
Presentations at International Conferences
1. Second International Workshop on Quantum Computation and Learning, Riga,
Latvia, 1999.
2. 12th Nordic Workshop on Programming Theory, Bergen, Norway, 2000.
3. 13th International Symposium on Fundamentals of Computation Theory, Jurmala,
Latvia, 2001.
4. Fifth International Baltic Conference on Databases and Information Systems,
Tallinn, Estonia, 2002.
5. 11th International Conference on Information Systems Development, Doctoral
Consortium, Riga, Latvia, 2002.
13
Related Publications
1. J. Barzdins, G. Linde, D. Kulis. Learning of Formulae from Finite Examples.
Proceedings of Second International Workshop on Quantum Computation and
Learning, 1999, Riga, Latvia, p. 200-208.
2. J. Barzdins, G. Linde. Towards Cartoon Semantics of Object Modeling. Extended
abstracts, 12th Nordic Workshop on Programming Theory, 2000, Bergen,
Norway, 3 pages.
3. G. Linde. Equivalence problem of UML Composites. Extended abstracts, 12th
Nordic Workshop on Programming Theory, 2000, Bergen, Norway, 3 pages.
4. G. Linde. Equivalence Problem of Composite Class Diagrams. Proceedings of
13th International Symposium on Fundamentals of Computation Theory, LNCS,
Vol. 2138, p. 264-274, Springer, 2001.
5. G. Linde. Reduction of UML Class Diagrams. Proceedings of the Fifth
International Baltic Conference on Databases and Information Systems, 2002,
Tallinn, Estonia, p. 39-48.
6. G. Linde. Reduction of UML Class Diagrams. H-M. Haav, A. Kalja (Eds),
Databases and Information Systems II, Selected Papers from the Fifth
International Baltic Conference, BalticDBIS'2002. p. 199-208, Kluwer Academic
Publishers, 2002.
7. G. Linde. Towards Semantics of Object Modeling. Proceedings of the 11th
International Conference on Information Systems Development, Doctoral
Consortium. Scientific proceedings of Riga Technical University: Computer
Science, Ser. 5, Vol. 9, p. 26-35. Riga, 2002.
8. G. Linde. The Cartoon Method of Semantics Definition for Modeling Languages.
Proceedings of the Latvian Academy of Sciences. Vol. 57, p. 138-143, Riga,
2003.
9. G. Linde. Semantics and Equivalence of UML Class Diagrams. Scientific Papers,
University of Latvia. Vol. 669. Computer Science and Information Technologies.
p. 107-116. Riga, 2004.
14
References
1. A. Analyti, N. Spyratos, P. Constantopoulos. On the Semantics of a Semantic
Network. Fundamenta Informaticae 36, 1998, pp.109-144
2. J. Barzdins, R. Freivalds, C. Smith. Learning Formulae from Elementary Facts.
LNCS, Vol. 1208, Springer, 1997, pp.272-285
3. J. Bezivin, R. Lemesle. Ontology-based Layered Semantics for Precise OA&D
Modeling. In: Proc. of ECOOP'97 Workshop on Precise Semantics for ObjectOriented Modeling Techniques, Jyvaskyla, Finland, June 1997, pp.31-38
4. J.C. Bicarregui, K.C. Lano, T.S.E. Maibaum. Formalising Object-Oriented
Models in the Object Calculus. In: Proc. of ECOOP'97 Workshop on Precise
Semantics for Object-Oriented Modeling Techniques, Jyvaskyla, Finland, June
1997, pp.45-52
5. M. Boman, J.A. Bubenko, P. Johannesson, B. Wangler. Conceptual Modelling,
Prentice Hall, 1997, 304 p.
6. R.H. Bourdeau, B.H.C. Cheng. A Formal Semantics for Object Model Diagrams.
IEEE Transactions on Software Engineering SE-21, 10, 1995, pp.799-821
7. B.J. Copeland. The Church-Turing Thesis. In: The Stanford Encyclopedia of
Philosophy (Fall 2002 Edition), Edward N. Zalta (ed.), http://plato.stanford.edu/
archives/fall2002/entries/church-turing/
8. J. Ebert, R. Suttenbach. Integration of Z-Based Semantics of OO-Notations. In:
Proc. of ECOOP'97 Workshop on Precise Semantics for Object-Oriented
Modeling Techniques, Jyvaskyla, Finland, June 1997, pp.75-82
9. A.S. Evans. Reasoning with UML class diagrams. WIFT'98. IEEE CS Press, 1998
10. A.S. Evans, R.B. France, K.C. Lano, B. Rumpe. The UML as a Formal Modelling
Notation. UML'98. LNCS, Vol. 1618, Springer, 1999
11. D. Kulis. Inductive Inference of Logic Formulas. Proceedings of Third
International Workshop on Quantum Computation and Learning, 2002, Riga,
Latvia, pp. 74-84
12. K.C. Lano, J.C. Bicarregui. Semantics and Transformations for UML Models.
UML'98. LNCS, Vol. 1618, Springer, 1999
15
13. K.C. Lano, A.S. Evans. Rigorous Development in UML. FASE'99, ETAPS'99.
LNCS, Vol. 1577, Springer, 1999
14. K. Periyasamy, W. Baluta. An Axiomatic Semantics for Object Modeling
Technique. In: Proc. of ECOOP'97 Workshop on Precise Semantics for ObjectOriented Modeling Techniques, Jyvaskyla, Finland, June 1997, pp.135-140
15. F. Racz, K. Koskimies. Tool-Supported Compressing of UML Class Diagrams.
UML'99. LNCS, Vol. 1723, Springer, 1999
16. J. Rumbaugh, M. Blaha, W. Premerlani, F. Eddy, W. Lorsen. Object-oriented
modeling and design. Englewood Cliffs, NJ: Prentice Hall 1991
17. J. Rumbaugh, G. Booch, I. Jacobson. The Unified Modeling Language Reference
Manual. Addison-Wesley, 1999
16
Download