@@ -27,25 +27,16 @@ After reading the part "KerML," you
2727 - different kinds of classes in the abstract representation of KerML
2828
2929---
30- # KerML and SysML
30+ # KerML: Basis for SysML and More
3131The SysML v2 ecosystem builds on top of a basic and simple language:
32- KerML (Kernel Modeling language).
33- KerML is used as a kind of internal representation and starting point throughout the whole ecosystem.
34- In consequence, we start the tutorial with a description of the KerML.
35-
32+ KerML, the Kernel Modeling language.
3633KerML has several purposes:
3734
38- * Its classes specify the so-called _ Metamodel_ .
39- The Metamodel describes the means to specify models, and gives basic semantics.
40- * Instances represent concrete models are the basis for persistence and exchange of models; they can be given
41- * in an abstract way by elements and relationships between them in arbitrary representation ("abstract representation").
42- * in a concrete textual model ("textual representation").
43-
44- The abstract representation is the foundation, for example, for model exchange in formats like JSON or XML;
45- see part "API."
46- The textual representation allows users to specify models.
35+ * First, it serves as the so-called _ Metamodel_ .
36+ The Metamodel describes classes that are the means to specify models, and gives basic semantics and constraints.
37+ * Second, instances of the metamodel classes are used to represent concrete models.
4738
48- KerML and SysML are structured in different layers.
39+ KerML is structured in different layers.
4940The layers introduce, step by step and building on top of each other, more and more features.
5041The table below gives an overview of the KerML layers, including SysML v2.
5142Note that SysML v2 can be seen as a domain-specific library based on KerML.
@@ -58,11 +49,15 @@ Note that SysML v2 can be seen as a domain-specific library based on KerML.
5849| SysML v2 | Domain-specific library based on KerML | Definition & Usage of Attribute, Part, Port, Connection, Interface, Requirement, ... |
5950
6051KerML (and SysML) both distinguish two different representations:
61- The _ textual representation_ is written text, like a programming language.
62- It is translated by a compiler into an _ abstract representation_ that consists of elements that are part of the Metamodel description.
63- These elements can be serialized, analyzed, etc.
52+
53+ The ** textual representation** is written code, similar a programming language.
6454In SysMD, one edits the textual representation in a notebook cell (see figure below, left).
65- After compilation, the abstract representation is shown in the "has-a" tree view (see figure below, right).
55+
56+ The ** abstract representation** is generated by compilation, using production rules and related classes from the KerML metamodel.
57+ An example of the relationship between textual and abstract representation is shown below.
58+ It is visualized in the "has-a" tree view of SysMD (see figure below, right).
59+ The abstract representation is the foundation, for example, for model exchange and persistence.
60+ Then it is serialized into formats like JSON or XML; see part "API."
6661
6762![ img.png] ( Files/textual-versus-abstract-representation.png ) {width=1000 height=250}
6863
@@ -81,13 +76,13 @@ The _Root_ Layer of KerML deals with
8176> The Root Layer of SysML introduces no specific semantics;
8277> it just provides infrastructure for modeling.
8378
84- In the following, we introduce three main artifacts of the Root Layer
85- - Element
86- - Relationship
87- - Namespace
88- - Annotating Elements
79+ In the following, we introduce main artifacts of the Root Layer
80+
81+ - Element and Relationship as base elements for all KerML and SysML v2 constructs,
82+ - Annotating Elements, and
83+ - Namespace, Import
8984
90- ## Elements
85+ ## Elements and Relationships
9186
9287All artifacts in KerML and SysML are different kind of "Elements".
9388` Element ` is the base class for all kinds of Elements in KerML, and all other classes inherit its features.
@@ -113,12 +108,37 @@ Examples for unrestricted names are:
113108- ` 'This is a valid unrestricted name' `
114109- ` '1.2' `
115110
111+ The general pattern for elements the textual representation is shown below.
112+
113+ ![ img.png] ( Files/element-syntax.png ) {width=400 height=130}
114+
115+ Each element generally consists of
116+ - suitable prefixes, e.g., private, public, in, out, etc.,
117+ - a keyword (i.e., doc) from which the element kind in the abstract representation is derived,
118+ - a short name and the name as described above.
119+
116120Each element can own other elements respectively, be owned by an owner.
117121This is internally represented by an Element of kind ` OwningMembership ` , which is a kind of Relationship.
118122A fundamental principle of KerML and SysML is that all relationships, including ownership are represented
119123by reified kind of Relationship.
120124
121- ## Annotating Elements
125+
126+ A relationship is a kind of KerML element that models a relationship between elements.
127+ In addition to an element, a relationship has the properties
128+ - ` source ` , and
129+ - ` target ` .
130+
131+ Source and target are (ordered) collections of _ references_ to elements.
132+ Relationships are used as reified objects to model all kinds of relationships,
133+ in particular also the ownership between elements and its owning element.
134+ Often, but not always, its syntax follows the pattern shown below.
135+
136+ ![ img.png] ( Files/relationship-syntax.png ) {width=350 height=120}
137+
138+
139+
140+
141+ ## Annotating Elements and Annotation
122142
123143The most basic and simple elements are annotating elements.
124144Don't confuse them with annotations that are relationships as shown later.
@@ -129,7 +149,8 @@ Specific kind of AnnotatingElement are
129149- ` Documentation ` (starting keyword: ` doc ` ) with a property ` body ` that holds the comment resp. documenting text.
130150- ` TextualRepresentation ` (starting keyword: ` rep ` ) with a property ` body ` that holds source code,
131151 and a property ` language ` that holds a string that gives the language of the model, e.g., SysML, or
132- - ` Metadata `
152+ - ` Metadata ` .
153+ - ` Annotation ` is a Relationship that links an annotating element with an annotation (e.g. its owner).
133154
134155** Example**
135156
@@ -138,33 +159,29 @@ In the example below, we add a Documentation and two comments to the package tut
138159doc kermel /* The package tutorial::kerml is the top-level package that owns all artefacts of the tutorial. */
139160comment /* The owning package is specified in the header of each SysMD cell. */
140161comment c1 about tutorial /* Comments and Documents can have names! */
162+ rep code language C /* println("Hello"); */
141163```
142164
143- ## Namespace
165+ Note that the comment about the tutorial includes an annotation that refers from the comment (source) to the package ` tutorial ` (target).
166+ Also note that the syntax is "about" instead of "from .. to".
144167
145- A namespace provides the means to retrieve elements by its name or short name.
146- In this context, a ** qualified name** describes a path from an element to another element in a
147- hierarchy of elements.
148- In a qualified name, different names are called segments, and they are separated by "::".
168+ ## Namespace, Import
149169
150- Namespaces can ** import** single or all elements of other namespaces via "imports."
151- In KerML, an import is a relationship between an importing namespace and
152- - an imported namespace (all elements are imported), or
153- - a single element.
154- It makes imported elements visible directly in the importing namespace.
170+ A namespace provides the means to retrieve elements by its name, its short name,
171+ or by qualified names that give a kind of path (see below).
155172
156173> The process of searching an element by its name is called _ name resolution_ .
157174
158- ** Example**
175+ Name resolution searches locally, in supertypes, and in imported members.
176+
177+ ** Example: Namespace**
159178
160179Below, an example with two nested namespaces is given.
161180Note that the syntax schema throughout KerML and SysML is to start all elements by
162181- A keyword that gives its kind, that is the respective KerML, SysML class by convention in small letters.
163182- Optionally, a name and short name (in < .. >) and/or name
164183- Optionally, a body in curly braces where owned elements are modeled
165184
166- In the example, the qualified name ` namespaceExample::Bike ` refers to the Bike of the
167- namespace owning the namespaceExample.
168185``` KerML::tutorial::kerml
169186namespace NamespaceExample {
170187 namespace Car {
@@ -184,36 +201,46 @@ The figure below shows the abstract representation generated by the example:
184201![ ownership.png] ( Files/ownership.png ) {width=550 height=330}
185202
186203
204+ To refer to elements in other namespaces, one can use qualified names.
205+ A qualified name gives a path from the namespace where it is used to another element.
206+ IIn a qualified name, different names are called segments, and they are separated by "::".
207+ For example, the namespace Car has, starting with ` tutorial::kerml ` , the qualified name ` NamespaceExample::Car ` .
208+ However, the use of qualified names can lead to overly verbose models.
209+ Hence, namespaces can ** import** single or all elements of other namespaces via "import."
210+ In KerML, an import is a relationship between an importing namespace and
211+
212+ - an imported namespace (all elements are imported), or
213+ - a single element.
214+
215+ An import makes imported elements available as member in the importing namespace.
216+
187217> ** Warning** :
188218> SysMD permits executing code in cells in a given namespace (selected in the line above the cell).
189219> The whole tutorial is part of the namespace ` tutorial ` .
190220> The concrete example is executed in an isolated namespace ` tutorial::kerml ` , where `NamespaceExample' is added.
191221> This is not (yet?) part of the standard, where every cell would have to be in the root namespace.
192222
193- ## Relationship
194-
195- A relationship is a kind of KerML element that models a relationship between elements.
196- In addition to an element, a relationship has the properties
197- - ` source ` , and
198- - ` target ` .
199-
200- Source and target are (ordered) collections of _ references_ to elements.
201- Relationships are used as reified objects to model all kinds of relationships,
202- in particular also the ownership between elements and its owning element.
203-
204- From the user's perspective, ` Annotation ` is an important kind of elements in the Root layer of KerML.
205- An Annotation is a relationship between Annotating Element and an annotated element.
206-
207- > We come back to relationships later in the Kernel Layer.
208223
209- ## Annotating Elements
224+ ** Example: Import**
225+ The name resoluti
226+ ``` KerML::tutorial::kerml
227+ namespace Car {
228+ class Engine;
229+ }
230+
231+ package importExample {
232+ class Car {
233+ private import carParts::*; feature engine: Engine;
234+ }
235+ }
236+ ```
210237
211- # Core Layer
238+ # Core Layer: Classifiers and Features
212239
213240The core layer introduces _ types_ to describe and classify things that exist
214241in an imaginary or the existing universe.
215- For this purpose, a type introduces a relationship ` Specialization ` or a more specific kinds thereof.
216- This relationship relates each type to a more general type.
242+ For this purpose, a type uses a relationship ` Specialization ` ;
243+ more specific types use also more specific kinds of the relationship.
217244
218245The most general and predefined type is ` Base::Anything ` .
219246All types are subtypes of this type.
@@ -223,18 +250,20 @@ All types are subtypes of this type.
223250> (OMG, KerML)
224251
225252For example, we can introduce a type ` Vehicle ` with the extent of all vehicles.
226- An individual vehicle would then be an instance of this type.
253+ A feature ` vehicle ` typed by the type ` Vehicle ` is then an instance of this type.
254+ Note that SysML v2 further adds _ individuals_ that occur individually in the physical world.
227255
228- KerML introduces two different kind of types, each with different purpose:
256+ ## Classifiers and Features
229257
230- - Classifier, and
231- - Feature.
232- ## Classifiers
233258
234- SysML v2 has an ontological foundation.
235- Classifiers are types that classify single things in an imaginary or the real universe.
259+ ## Subtyping and
236260
261+ ##
237262
263+ ## Classifiers
264+
265+ SysML v2 has an ontological foundation.
266+ Classifiers are types that classify single things in an imaginary or the real universe.
238267
239268The Kernel layer (see below) further refines the ontological semantics of classifiers into:
240269
@@ -273,7 +302,8 @@ The Kernel layer introduces specific classes with more complex semantics, includ
273302- Behavior
274303- Functions and Expressions
275304- Associations and Connectors
276- ## DataType, Class
305+
306+ ## DataType
277307
278308The Kernel layer differentiates Classifiers into
279309- data types (keyword ` datatype ` , KerML class DataType), where occurrences are non-distinguishable individuals.
@@ -284,12 +314,11 @@ The Kernel layer differentiates Classifiers into
284314
285315The standard library ` ScalarValues ` introduces some basic data types, including
286316- Boolean; it can be referred by its qualified name: ` ScalarValues::Boolean ` .
287- Alternatively, you can import the namespace ` ScalarValues ` in the current namespace (` private import ScalarValues::* ` ).
317+ Alternatively, one can import the namespace ` ScalarValues ` into the current namespace (` private import ScalarValues::* ` ).
288318 Then, you can directly refer the type by ` Boolean `
289319- Integer (` ScalarValues::Integer ` )
290320- Real (` ScalarValues::Real ` )
291321
292-
293322Note that Reals have no accurate representation on computers;
294323they are, for example, represented by symbolic representations.
295324For execution or computations, approximations like floating point representations must be used.
0 commit comments