Chapter 7. Semantics

In very general terms, the purpose of semantics is to provide a definition of meaning for a language. For having a precise definition of meaning, a formal semantics is needed. Such a semantics should allow checking the satisfiability/consistency of a system model and proving correctness properties for it. However, there are different kinds of formal semantics.

While Tarski's Model-Theoretic Semantics for (First-Order) Predicate Logic provides a widely accepted standard semantics for information modeling languages, which allow modeling the state structure of a system, such as Entity-Relationship Diagrams or UML Class Diagrams, there is no standard semantics for process modeling languages, such as BPMN or UML State Machines. Rather, there are many different operational semantics and denotational semantics for these languages.

The most general operational semantics are provided by mapping the elements of a language to an Abstract State Machine, see (Reisig 2008), which is a very expressive kind of state transition system. The most general denotational semantics is provided by mapping the elements of a language to Predicate Logic and using a Tarski-style model-theoretic semantics. The latter approach is taken in the KerML spec.

The Core Layer grounds KerML semantics by interpreting it using mathematical logic. However, additional semantics are then specified through the relationship of Kernel abstract syntax constructs to model elements in the Kernel Semantic Library, which is written in KerML itself. Models expressed in KerML thus essentially reuse elements of the Semantic Library to give them semantics. The Semantic Library models give the basic conditions for the conformance of modeled things to the model, which are then augmented in the user model as appropriate. [KerML 6.1]

A formal semantics, in the spirit of Tarski’s model-theoretic semantics for predicate logic, is only defined for the KerML Core layer. It refers to a vocabulary provided by the names of the classifiers and features defined as types in a KerML model. A feature is informally defined as “a Type that classifies relations between multiple things (in the universe)”. According to the specification, “KerML semantics are based on classification: a model has elements that classify things in the modeled system”.

While the classification-based approach of a model-theoretic semantics has been common for defining a semantics of information modeling languages, it is new for process modeling languages. In KerML, an action type (called "behavior") classifies action performances. Consequently, the universe (or semantic domain) of a model-theoretic interpretation does not only include individuals representing data values and objects, but also individuals representing events/actions.

According to one of the main authors of the KerML spec, Conrad Bock, the (main) purpose of KerML's semantics is allowing to check whether a completed behavior execution trace conforms to a system model without saying anything about how to execute the model (or how to create an execution trace). This is called semantic conformance testing.

Notice, however, that this view of the purpose of a semantics is quite narrow. A broader view of a semantics includes also checking the satisfiability/consistency of a system model and proving correctness properties for it.

The following paragraphs are taken from the conference paper An Analysis of the Semantic Foundation of KerML and SysML v2, Proceedings of The 43rd International Conference on Conceptual Modeling (ER 2024).

According to the KerML semantics, an interpretation of a KerML Core vocabulary is a quadruple ⟨ Δ, P, S, I ⟩ consisting of

  1. A universe Δ containing “all actual and potential things the vocabulary could possibly be about”, or, more specifically, data values, objects, and actions/performances.
  2. A strict partially ordered set P called marking set.
  3. A set of sequences S including all unary sequences (consisting of a single element of the universe) and all alternating sequences like (d1, p1, d2), (d1, p1, d2, p2, d3), . . ., where di ∈ Δ and piP.
  4. An interpretation function I that maps each classifier and feature name of the vocabulary to a subset of S.

Consider the following KerML model defining the classifiers Car and Person, as well as the features driver and mainEngine.

classifier Person;
classifier Engine;
classifier Car {
  feature driver[0..1] : Person;
  composite feature mainEngine : Engine;
}

Imagine a situation with two persons (John and Mary), two cars (car1 and car2) and two engines (e1 and e1) such that car1 is driven by John, car2 does not have a driver, Mary is not driving any car, car1 has e1 as its main engine, and car2 has e2. Then, sequences like (john), (mary), (car1), (car2), (e1), (e2), (car1, p1, john), (car1, p2, e1), (car2, p3, e2) would be required in the set of sequences for the interpretation of Car, Person, driver and mainEngine.

The marking elements p1, p2, p3, etc. separate elements of the universe in sequences like (car1, p1, john) and are used to account for features that are non-unique or ordered. For non-unique features, the same pair of elements is separated with different markings, and hence the collection of entities in the feature's range for a particular entity of the domain can be conceived as a bag (or multiset). For ordered features, the markings used form a total order, such that the collection of entities in the feature's range for a particular entity of the domain can be conceived as a sequence.

The semantics is defined in such a way that an interpretation function for our example would map Car to {(car1), (car2)}, driver to {(car1, p1, john)}, mainEngine to {(car1, p2, e1), (car2, p3, e2)} and Person to {(john), (mary), (car1, p1, john)} and Engine to {(e1), (e2), (car1, p2, e1), (car2, p3, e2)}. Note that all sequences in the interpretation of a feature are also included in the interpretation of its range (or co-domain), therefore, all sequences ending with a person, like (car1, p1, john), are included in the interpretation of Person, and all those ending with an engine, like {(car1, p2, e1), (car2, p3, e2)}, are included in the interpretation of Engine.

The core semantics provides rules to interpret: the predefined top-level classifier Anything, which is present in all models and subsumes all other classifiers in the model, and the predefined top-level feature things, also present in all models, subsuming all other features; specialization between types; disjoining between types, when the interpretation of two types has no intersection; feature typing, where a feature is given a ‘featuring type’ corresponding to its domain, and a ‘featured type’, corresponding to its range; feature redefinition, multiplicity, uniqueness, ordering, inverting and chaining.

7.1. A Standard Model-Theoretic Semantics of Simple KerML Models

KerML's official semantics departs from the standard model-theoretic semantics for logic-based modeling languages (such as OWL and Alloy), as well as from formalizations of UML class models and ER models in the following way:

  1. Since KerML allows features to have features, features cannot be interpreted (like classical properties or binary predicates) as binary relations over the universe U (or subsets of U × U).
  2. Due to KerML's peculiar Feature Typing concept, the interpretation/extent of a classifier C includes the interpretations/extents of all features having C as their range, implying that classifiers can no longer be interpreted as subsets of U.
  3. Since KerML allows features to have non-unique and ordered collections (multisets and sequences) as values, the interpretations of a KerML model also include a marking set and the set of all sequences formed with elements of U and of the marking set.

As a consequence, KerML's official semantics has lost much of the intuitive and philosophical appeal of standard model-theoretic semantics.

We present a standard model-theoretic semantics of a fragment of KerML, called Simple KerML Models, which do neither allow features to have features nor non-unique/ordered value collections.

For readability, we prefer using the terms object type instead of "structure", action type instead of "behavior", and action instead of "performance". We also call a structural feature a property, a data-valued property an attribute, and a behavioral feature an action step.

While the classical model-theoretic semantics of predicate logic does not make any ontological distinctions among the elements of the universe, the model-theoretic semantics of OWL partitions the universe into data values and objects, whereas the model-theoretic semantics of KerML partitions the universe into data values, objects and actions.

We define a Simple KerML model as a KerML model that only defines

  1. data types, object types and action types as classifiers;
  2. features for classifiers, but not for features;
  3. features with plain value sets.

The following is an example of a Simple KerML model defining the action types BookRoom, CheckIn, Charge, CheckOut and RentHotelRoom, as well as the object types Room and Hotel, such that the action type RentHotelRoom has four action steps, the object type Room has one attribute and the object type Hotel has two attributes and one action step:

behavior BookRoom;
behavior CheckIn;
behavior Charge;
behavior CheckOut;
behavior RentHotelRoom {
  step bookRoom[1] : BookRoom;
  step checkIn[0..1] : CheckIn;
  step charge[1] : Charge;
  step checkOut[0..1] : CheckOut;
}
struct Room {
  feature roomNumber: Natural;
}
struct Hotel {
  feature name: String;
  feature rooms[1..*]: Room;
  step rentHotelRoom[*] : RentHotelRoom;
}

An action step (as an action-valued feature) defined for an object type, such as Hotel::rentHotelRoom, may express the fact that objects of that type can perform actions of the type defined for the step, such as hotels performing rentHotelRoom actions.

In the following section, we define a more concise mathematical representation of Simple KerML models as 11-tuples.

Simple KerML Models

A Simple KerML model defines a vocabulary consisting of the names of classifiers (data types, object types or action types) and classifier features, corresponding to the vocabulary of a predicate logical language consisting of names of constants, functions and predicates. Data literals correspond to constants, classifiers correspond to unary predicates, and classifier features correspond to unary functions (or binary predicates).

For Simple KerML models, we simplify the representation of the start and end times of occurrences by including two corresponding attributes in the definition of the predefined classifier Occurrence. In KerML, all occurrences have a startShot and an endShot, which are special zero-duration suboccurrences, whose occurrence time can be obtained by invoking the library function TimeOf. Consequently, the start time of an occurrence o is TimeOf( o.startShot ), and its end time is TimeOf( o.endShot ).

According to the KerML spec, all occurrences have an endShot, which raises the question, if KerML does not support ongoing occurrences with a moving time horizon?

A Simple KerML model, based on a set of predefined classifiers, is a 11-tuple

DT, OT, AT, Cl, ownF, feat, rng, mul, sup, CInv, GInv

Figure 7-1. Predefined classifiers of Simple KerML Models
???

specifying:

  1. The pairwise disjoint finite sets of names of (predefined and user-defined) data types DT, object types OT and action types AT, which merged together form the set of classifier names Cl, such that, by definition, each of them contains the predefined name of a most general type/classifier: DataValueDT, ObjectOT, ActionAT and { Occurrence, Anything } ⊆ Cl.
  2. A function ownF for assigning a set of local names of its owned features to a classifier name C. The function feat is obtained by extending ownF such that subclassifiers inherit the (onwed and inherited) features of their superclassifiers. Full feature names have the form C::f where f ∈ feat(C).
  3. A function rng for assigning a range (or co-domain) to any feature C::f with rng(C::f) ∈ Cl.
  4. A function mul for assigning multiplicities to features.
  5. A function sup for assigning direct superclassifiers to classifiers CCl, such that

    1. Anything ∈ sup*(C), where sup* is the transitive closure of sup,
    2. if CDT, then sup(C) ⊆ DT and DataValue ∈ sup*(C),
    3. if COT, then sup(C) ⊆ OT and { Object, Occurrence } ⊆ sup*(C),
    4. if CAT, then sup(C) ⊆ AT and { Action, Occurrence } ⊆ sup*(C),
    5. if C' ∈ sup(C), then feat(C') ⊆ feat(C).
  6. A set of classifier invariants CInvar, which are ordered pairs of a classifier C and a logical formula F(x) with one free variable x, stating that F(i) holds for all instances i from the extent of C.
  7. A set of global invariants GInvar, which are logical sentences (formulas without free variables).

Interpretations

While data values are ahistoric (they exist independently of time), all occurrences (objects and actions) have either been existing for some time in the past and possibly still exist, or exist at present. Occurrences remain in the history (of a modeled system) once they have ceased to "exist". Local universes of discourse (at certain points in time) include not only the present occurrences but all past occurrences as well; they increase as time progresses and new occurrences come into being (see also the discussion of constant versus varying domain semantics in [1]).

An interpretation of a Simple KerML model is an octuple

I = ⟨ ⟨Time, <⟩, ct, DV, Obj, Act, Occ, U, It

such that

  1. Time, <⟩ is a linear order of time instants and ctTime is the current time. We write Timect for the set { tTime : tct }.
  2. DV is a time-independent (ahistoric) set of data values, which includes strings and numbers.
  3. Obj: Timect → 2Objct and Act: Timect → 2Actct are functions that assign finite sets of objects Objt and actions Actt to any time instant tct such that DV, Objt and Actt are pairwise disjoint. These sets are expanding in time: for all t, t'ct, if t < t', then ObjtObjt' and ActtActt'.
  4. Likewise, Occ: Timect → 2Occct and U: Timect → 2Uct are functions that assign a set of occurrences Occt and things Ut to any time instant tct such that Occt = ObjtActt and Ut = DVOcct.
  5. It is a time-indexed interpretation function such that for all time instants t, t'ct:

    1. It(Anything) = Ut and It(Occurrence) = Occt.
    2. It(D) = It'(D) ⊆ DV for all DDT, and It(DataValue) = DV.
    3. It(O) ⊆ Objt for all OOT, and It(Object) = Objt.
    4. It(A) ⊆ Actt for all AAT, and It(Action) = Actt.
    5. A feature C::f with mul(C::f) = ⟨ l, u ⟩ and rng(C::f) = R is interpreted as a function It(C::f) : It(C) → 2It(R) such that for any xIt(C) and its feature value set val = It(C::f)(x), card(val) ≥ l and, if u≠ ∗, card(val) ≤ u, and

      1. if C is a data type, the feature interpretation function It(C::f) is ahistoric: It(C::f) = It'(C::f),
      2. the predefined occurrence type features startTime and endTime are interpreted according to their intended semantics: for any occurrence o, st = It(startTime)(o) ≤ ct and if o has an end time et = It(endTime)(o), then stetct.
    6. The interpretation of classifiers respects their specialization hierarchy: for any classifier CCl and any of its supertypes C' ∈ sup(C), It(C)It(C').
    7. The interpretation satisfies all constraints of the model:
      1. for all classifier invariants ⟨C, F(x)⟩ ∈ CInvar, IF(a) for all aC,
      2. for all global invariants SGInvar, IS.

An interpretation I, together with a variable value assignment v : VarUct for a finite set of variables Var, allows to interpret expressions. For instance, for expressions of the form x.f where x is an occurrence variable and f is a feature name:

Itv(x.f) = It(C::f)(v(x)) where v(x) ∈ C and f ∈ feat(C)

Whenever the range of a feature C::f is an occurrence type C', we can interpret expressions of the form x.f1.f2 where f1 ∈ feat(C) and f2 ∈ feat(C'), which are called path expressions. The resulting value set Itv(x.f1.f2) is obtained by merging the value sets It(C::f2)(p) for all pIt(C::f1)(v(x)). In this way, we can interpret path expressions of any length greater than zero.

Satisfaction of Logical Formulas

Finally, we can define how a variable-assignment-enhanced interpretation Itv satisfies a logical formula F formed with atomic formulas that are composed with the help of the usual logical operators. The base case of atomic formulas includes the following three forms:

  1. Classification atoms have the form C(x) where C is a classifier. They are satisfied by Itv if and only if v(x) ∈ It(C). Symbolically,

    ItvC(x) iff v(x) ∈ It(C).

  2. Comparison atoms have the form expr1 # expr2 where each exprk is either a data literal (from one of the underlying data types), a variable, or a path expression, and # is one of the comparison predicates (=, ≠, <, ≤, >, ≥).

    Itvexpr1 # expr2 iff Itv(expr1) It(#) Itv(expr2),

    where It(#) is the interpretation of the comparison predicate #.

Complex logical formulas formed with the logical operators ¬, ∧, ∨, →, ∀, ∃ are satisfied by a variable-assignment-enhanced interpretation in the usual way.

When a logical sentence (variable-free formula) S is satisfied by an interpretation at a time instant tTime, we write ItS. When it is satisfied at all time instants tct, we write IS.

Entailment

A Simple KerML model M entails a logical sentence S if S is satisfied by all interpretations of M:

MS iff IS for all interpretations I of M.

Integrity Constraints

Integrity constraints, as elements of a KerML model, are logical sentences that have to be satisfied by the interpretations of the model. A KerML model may, for instance, define the following types of (integrity) constraints for a classifier:

Range Constraints

require that a feature must have a value from the value space of the type that has been defined as its range. For instance, a value of an attribute declared as feature age : Integer must be an integer. These (implicit) constraints are expressed in a model by specifying a range for the features concerned.

Mandatory Value Constraints

require that a feature must have a value. These constraints are expressed in a model with the help of a feature multiplicity that has a lower bound greater than 0. Notice that the default multiplicity of a feature is 1, implying that it is mandatory and single-valued.

Cardinality Constraints

apply to multi-valued features, only, and can require that the cardinality of a feature's value set is not less than a given minimum cardinality or not greater than a given maximum cardinality, as expressed by the feature's multiplicity.

In addition, there are further types of classifier constraints that only refer to a specific attribute and, therefore, could be expressed within the declaration of the attribute concerned:

Uniqueness Constraints (also called 'Key Constraints')

require that the value of an attribute C::a is unique among all instances of its domain: F(x) ≡ ∀y: C(y) → x.a ≠ y.a. Notice that this is different from declaring a feature to be unique, which requires its value collection to contain no duplicates.

Interval Constraints

require that the value of a numeric attribute a must be in a specific interval [min,max]: F(x) ≡ min ≤ x.ax.a ≤ max.

Pattern Constraints

require that a string attribute's value must match a certain pattern defined by a regular expression. They allow defining special string data types such as for URLs, email addresses or telephone numbers.

These classifier invariants could be expressed in the simplified way of an annotation appended to the attribute declaration. For instance, UML allows expressing uniqueness constraints with the help of the annotation (property modifier) keyword "key", while it also allows expressing standard identifier (or 'primary key') constraints with the help of the attribute annotation keyword "id" (implying that the attribute is unique and mandatory, and that its values are used as standard identifiers).

An interval constraint could be expressed with the attribute annotation keywords "min" and "max" together with corresponding numbers, while a pattern constraint could be expressed with the attribute annotation keyword "pattern" together with a regular expression.

References

[1] First-order temporal logics, a section of the article "Temporal Logic" by Valentin Goranko and Antje Rumberg, 2024, in Stanford Encyclopedia of Philosophy.