This section introduces the instance level transformation belonging to the transformation of a nullable class field. The type level transformation for nullable class fields can be found in Section 5.2.8. On the instance level, values for these fields are introduced.
Definition 5.3.85 (Instance modelImN ullableClassF ield)
Let ImN ullableClassF ield be an instance model typed by T mN ullableClassF ield (Definition 5.2.85). Define disjoint sets valobjects and nilobjects. The objects in valobjects will get a proper class value for the field introduced byT mN ullableClassF ield, while the objects innilobjects get anil value for the same field. Furthermore, define a function obids which maps each of these objects to their corresponding identifier and a function values, which maps the objects in valobjects to its value for the field introduced by
T mN ullableClassF ield. ImN ullableClassF ieldis defined as:
Object=nilobjects∪valobjects∪ {values(ob)|ob∈valobjects}
ObjectClass =
{︄
(ob, classtype) if ob∈nilobjects∪valobjects
(ob, f ieldtype) if ob∈ {values(ob)|ob∈valobjects}
ObjectId = {︂(ob, obids(ob)) if ob∈objects
FieldValue =
{︄
((ob,(classtype, name)),nil) if ob∈nilobjects
((ob,(classtype, name)),[obj, values(ob)]) if ob∈valobjects
DefaultValue ={}
Also see imod_nullable_class_field in
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Theorem 5.3.86 (Correctness ofImN ullableClassF ield)
ImN ullableClassF ield (Definition 5.3.85) is a valid instance model in the sense of Definition 3.2.19.
Also see imod_nullable_class_field_correctin
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
A visual representation of ImN ullableClassF ield with valobjects = {oba} and nilobjects = {obb} can
be seen in Figure 5.15a. In this visualisation, the field value for oba is defined as values(oba) = obx.
Furthermore, the value for obb is nil, because it occurs within the set nilobjects. Like the previous
transformations for field values, the value needs to be set for all objects that are typed by the class type corresponding to the field. Failing to do so would result in an invalid instance model after it is combined with another model, as the next definition will show. The correctness proof ofImN ullableClassF ieldonly is
already quite involved, but not be included here for conciseness. It can be found as part of the validated Isabelle proofs.
In order to make composing transformation functions possible,ImN ullableClassF ieldshould be compatible
with the instance model it is combined with.
Theorem 5.3.87 (Correctness ofcombine(Im, ImN ullableClassF ield))
Assume an instance model Im that is valid in the sense of Definition 3.2.19. Then Im is compatible withImN ullableClassF ield (in the sense of Definition 4.4.14) if:
• All requirements of Theorem 5.2.87 are met, to ensure the combination of the corresponding type models is valid;
• The class type on which the field is defined byT mN ullableClassF ield may not be extended by another class type in the type model corresponding to Im;
• All of the objects in the setsnilobjects andvalobjectsmust already be objects in Im;
• All of the objects referenced by the objects in the set valobjectsmust already be objects in Im;
• All objects typed by the class type on which the field is defined must occur in the set nilobjects∪
valobjects and thus have a value inImN ullableClassF ield;
• For all of the objects in the set objects, the identifier set by obids must be the same identifier as set by Imfor that object;
• The sets valobjectsandnilobjects must be disjoint, each object only gets a proper class value or a nil value, not both;
• For all objects in set valobjects, the value set by thevaluesfunction must be valid.
Also see imod_nullable_class_field_combine_correctin
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Proof. Use Lemma 4.4.13. It is possible to show that all assumptions hold. Now we have shown that
combine(Im, ImN ullableClassF ield)is consistent in the sense of Definition 3.2.19.
As explained earlier,ImN ullableClassF ieldneeds to introduce values for all objects that are typed by the
class type on which the field is defined. This is enforced by the requirements of Theorem 5.3.87. The proof is not included here for conciseness, but can be found as part of the validated proofs in Isabelle.
The definitions and theorems for introducing values for fields of data types within Ecore are now com- plete.
Encoding as edges and nodes
In the type level transformation of nullable class fields, nullable class fields were encoded in GROOVE as edge types to a corresponding encoded node type. On the instance level, this edge type will be used and edges will be created to give a value to each node type that has the field defined. The encoding corresponding to ImN ullableClassF ield can then be represented as IGN ullableClassF ield, defined in the
following definition:
Definition 5.3.88 (Instance graphIGN ullableClassF ield)
LetIGN ullableClassF ieldbe the instance graph typed by type graphT GN ullableClassF ield(Definition 5.2.88). Reuse the sets nilobjectsandvalobjects fromImN ullableClassF ield. Moreover, reuse the functionsobids andvaluesfrom ImN ullableClassF ield.
The objects in the sets nilobjects and valobjects are converted to nodes in ImN ullableClassF ield. For each of these objects, an edge of the encoded field is created. This edge targets a node that corresponds to the value set by values for the corresponding object in valobjects. The outgoing multiplicity of the edge type created by T GN ullableClassF ield is 0..1, such that the objects innilobjects do not need to have this edge, representing the absence of a value. Finally, the identity of the objects is defined using obids. IGN ullableClassF ield is defined as:
N =nilobjects∪valobjects∪ {values(ob)|ob∈valobjects}
E={︁(︁ob,(ns_to_list(classtype),⟨name⟩,ns_to_list(f ieldtype)), values(ob))︁|ob∈valobjects}︁
ident = {︂(obids(ob), ob) if ob∈objects with
typen =
{︄
(ob,ns_to_list(classtype)) if ob∈nilobjects∪valobjects
(ob,ns_to_list(f ieldtype)) if ob∈ {values(ob)|ob∈valobjects}
Also see ig_nullable_class_field_as_edge_type in
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Theorem 5.3.89 (Correctness ofIGN ullableClassF ield)
IGN ullableClassF ield (Definition 5.3.88) is a valid instance graph in the sense of Definition 3.3.10.
Also see ig_nullable_class_field_as_edge_type_correct in
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
A visual representation of IGN ullableClassF ield with valobjects ={oba} and nilobjects ={obb} can be
seen in Figure 5.15b. Like the previous visualisation, the field value forobais defined asvalues(oba) =obx.
Since obb was in the set nilobjects, no edge has been created for this node. Like the previous field
encodings, one needs to set the values for the field for all objects of the encoded class type at once. Failing to do so would result in an invalid instance graph after it is combined with another graph, as the next definition will show. The correctness proof of IGN ullableClassF ield only is already quite involved,
but not be included here for conciseness. It can be found as part of the validated Isabelle proofs. In order to make composing transformation functions possible,IGN ullableClassF ieldshould be compatible
with the instance graph it is combined with.
Theorem 5.3.90 (Correctness ofcombine(IG, IGN ullableClassF ield))
Assume an instance graphIG that is valid in the sense of Definition 3.3.10. ThenIG is compatible with IGN ullableClassF ield (in the sense of Definition 4.4.25) if:
• All requirements of Theorem 5.2.90 are met, to ensure the combination of the corresponding type graphs is valid;
• The node type on which the corresponding field is defined is not extended by other node types within the type graph corresponding toIG;
• All nodes inIG are also nodes in IGN ullableClassF ield;
• For all nodes shared betweenIG andIGN ullableClassF ield, each node must have the same identifier in bothIG andIGN ullableClassF ield;
• The setsvalobjectsandnilobjectsmust be disjoint, each node gets either one edge to another node, or no edge at all;
• For all nodes for which the field is set, thevalues function must define a valid value.
Also see ig_nullable_class_field_as_edge_type_combine_correctin
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Proof. Use Lemma 4.4.24. It is possible to show that all assumptions hold. Now we have shown that
combine(IG, IGN ullableClassF ield)is valid in the sense of Definition 3.3.10.
The next definitions define the transformation function fromImN ullableClassF ieldtoIGN ullableClassF ield: Definition 5.3.91 (Transformation functionfN ullableClassF ield)
The transformation functionfN ullableClassF ield(Im)is defined as:
N =ObjectIm E={︁(︁
ob,(ns_to_list(classtype),⟨name⟩,ns_to_list(f ieldtype)), values(ob))︁
|
ob∈ObjectIm∧ob∈valobjects
}︁
ident = {︂(obids(ob), ob) if ob∈ObjectIm with
typen=
{︄
(ob,ns_to_list(name)) if ob∈ObjectIm∧ob∈nilobjects∪valobjects
(ob,ns_to_list(name)) if ob∈ObjectIm∧ob∈ {values(ob)|ob∈valobjects}
Also see imod_nullable_class_field_to_ig_nullable_class_field_as_edge_typein
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Theorem 5.3.92 (Correctness offN ullableClassF ield)
fN ullableClassF ield(Im) (Definition 5.3.91) is a valid transformation function in the sense of Defini- tion 4.4.26 transforming ImN ullableClassF ield intoIGN ullableClassF ield.
Also see imod_nullable_class_field_to_ig_nullable_class_field_as_edge_type_funcin
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
The proof of the correctness offN ullableClassF ieldwill not be included here. Instead, it can be found in
the validated Isabelle theories.
Finally, to complete the transformation, the transformation function that transformsIGN ullableClassF ield
intoImN ullableClassF ield is defined:
Definition 5.3.93 (Transformation functionfN ullableClassF ield′ )
The transformation functionfN ullableClassF ield′ (IG)is defined as:
Object=NIG
ObjectClass =
{︄
(ob, classtype) if ob∈NIG∧ob∈nilobjects∪valobjects
(ob, f ieldtype) if ob∈NIG∧ob∈ {values(ob)|ob∈valobjects}
ObjectId = {︂(ob, obids(ob)) if ob∈NIG
FieldValue =
{︄
((ob,(classtype, name)),nil) if ob∈NIG∧ob∈nilobjects
((ob,(classtype, name)),[obj, values(ob)]) if ob∈NIG∧ob∈valobjects
DefaultValue ={}
Also see ig_nullable_class_field_as_edge_type_to_imod_nullable_class_fieldin
Ecore-GROOVE-Mapping-Library.NullableClassFieldValue
Theorem 5.3.94 (Correctness offN ullableClassF ield′ )
fN ullableClassF ield′ (IG) (Definition 5.3.93) is a valid transformation function in the sense of Defini- tion 4.4.31 transforming IGN ullableClassF ield intoImN ullableClassF ield.
Also see ig_nullable_class_field_as_edge_type_to_imod_nullable_class_field_funcin
a :Example b :Example c :Example x :TargetExample y :TargetExample z :TargetExample field field field
(a)ImContainedClassSetF ield with examples of different nodes with different values forfield
a:Example b: Example x: TargetExample y:TargetExample z: TargetExample c:Example field field field
(b)IGContainedClassSetF ieldwith examples of different nodes with different values forfield
Figure 5.16: Visualisation of the transformation of field values from containment fields typed by a set of a proper class type
Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.