• No results found

5.3 Instance level transformations

5.3.6 Data field values

The previous sections have shown the instance level transformations of the introduction of all kinds of types and their instances. From this section onward, these types and their instances will be enriched by introducing fields. In this section, the instance level transformation belonging to the transformation of a data field is discussed. The type level transformation for data fields can be found in Section 5.2.6. On the instance level, values for the data fields are introduced.

Definition 5.3.58 (Instance modelImDataF ield)

Let ImDataF ield be an instance model typed by T mDataF ield (Definition 5.2.58). Define a set objects, which represent the objects that will get a value for the field introduced by T mDataF ield. Furthermore, define a functionobidswhich maps each of these objects to their corresponding identifier and a function values, which maps each of these objects to its value for the field introduced byT mDataF ield. ImDataF ield

is defined as:

Object=objects

ObjectClass = {︂(ob, classtype) if ob∈objects

ObjectId = {︂(ob, obids(ob)) if ob∈objects

FieldValue = {︂((ob,(classtype, name)), values(ob)) if ob∈objects

DefaultValue ={}

Also see imod_data_fieldin Ecore-GROOVE-Mapping-Library.DataFieldValue

Theorem 5.3.59 (Correctness ofImDataF ield)

ImDataF ield (Definition 5.3.58) is a valid instance model in the sense of Definition 3.2.19.

Also see imod_data_field_correct in Ecore-GROOVE-Mapping-Library.DataFieldValue

A visual representation of ImDataF ield with objects = {ob} and obids(ob) = someId can be seen in

Figure 5.13a. In this visualisation, the field value forobis defined asvalues(ob) =“some value”. Although this visualisation only shows one object, it is required to define a value for all objects that contain 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 ofImDataF 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, ImDataF ieldshould be compatible with

the instance model it is combined with.

Theorem 5.3.60 (Correctness ofcombine(Im, ImDataF ield))

Assume an instance model Im that is valid in the sense of Definition 3.2.19. Then Im is compatible withImDataF ield (in the sense of Definition 4.4.14) if:

• All requirements of Theorem 5.2.60 are met, to ensure the combination of the corresponding type models is valid;

• The class type on which the field is defined by T mDataF ield may not be extended by another class type in the type model corresponding to Im;

• All of the objects in the set objects must already be objects in Im;

• All objects typed by the class type on which the field is defined must occur in the set objects and thus have a value in ImDataF 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;

• For all objects in set objects, the value set by thevaluesfunction must be valid.

Also see imod_data_field_combine_correct in

Ecore-GROOVE-Mapping-Library.DataFieldValue

Proof. Use Lemma 4.4.13. It is possible to show that all assumptions hold. Now we have shown that

combine(Im, ImDataF ield)is consistent in the sense of Definition 3.2.19.

As explained earlier, ImDataF ield needs 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.60. 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 data fields, data fields were encoded in GROOVE as edge types to an primitive 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 toImDataF ieldcan then

Definition 5.3.61 (Instance graphIGDataF ield)

Let IGDataF ield be the instance graph typed by type graph T GDataF ield (Definition 5.2.61). Reuse the set objects from ImDataF ield. Moreover, reuse the functions obidsand values from ImDataF ield. The objects in the set objects are converted to nodes in ImDataF 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 byvaluesfor the corresponding object. Finally, the identity of the objects is defined using obids. IGDataF ield is defined as:

N =objects∪ {values(ob)|ob∈objects}

E ={︁(︁

ob,(ns_to_list(classtype),⟨name⟩, f ieldtype), values(ob))︁

|ob∈objects}︁

ident = {︂(obids(ob), ob) if ob∈objects with

typen= {︂(ob,ns_to_list(classtype)) if ob∈objects

Also see ig_data_field_as_edge_typein Ecore-GROOVE-Mapping-Library.DataFieldValue

Theorem 5.3.62 (Correctness ofIGDataF ield)

IGDataF ield (Definition 5.3.61) is a valid instance graph in the sense of Definition 3.3.10.

Also see ig_data_field_as_edge_type_correctin

Ecore-GROOVE-Mapping-Library.DataFieldValue

A visual representation of IGDataF ield with objects = {ob} and obids(ob) = someId can be seen in

Figure 5.13b. Like the previous visualisation, the field value forobis defined asvalues(ob) =“some value”. Although this visualisation only shows one node, it is required to define a value for all nodes typed by the node type corresponding to the field. 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 ofIGDataF 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, IGDataF ield should be compatible with

the instance graph it is combined with.

Theorem 5.3.63 (Correctness ofcombine(IG, IGDataF ield))

Assume an instance graphIG that is valid in the sense of Definition 3.3.10. ThenIG is compatible with IGDataF ield (in the sense of Definition 4.4.25) if:

• All requirements of Theorem 5.2.63 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 in IG that are typed by the node type on which the field is defined are also nodes in IGDataF ield;

• For all nodes shared betweenIG andIGDataF ield, each node must have the same identifier in both IG andIGDataF ield;

• For all nodes for which the field is set, thevalues function must define a valid value;

• If an primitive type has incoming or outgoing edge types in the type graph corresponding to IG, then the lower multiplicity of these edge types must be 0.

Also see ig_data_field_as_edge_type_combine_correct in

Ecore-GROOVE-Mapping-Library.DataFieldValue

Proof. Use Lemma 4.4.24. It is possible to show that all assumptions hold. Now we have shown that

combine(IG, IGDataF ield)is valid in the sense of Definition 3.3.10.

Like the definition for the combination of instance models, the combination of instance graphs also requires the user to set a value for all nodes that are typed by the node type that corresponds to the field type. This is to keep the graph valid.

Definition 5.3.64 (Transformation functionfDataF ield) The transformation functionfDataF ield(Im)is defined as:

N =ObjectIm∪ {values(ob)|ob∈ObjectIm} E={︁(︁

ob,(ns_to_list(classtype),⟨name⟩, f ieldtype), values(ob))︁

|ob∈ObjectIm

}︁

ident = {︂(obids(ob), ob) if ob∈ObjectIm with

typen= {︂(ob,ns_to_list(name)) if ob∈ObjectIm

Also see imod_data_field_to_ig_data_field_as_edge_typein

Ecore-GROOVE-Mapping-Library.DataFieldValue

Theorem 5.3.65 (Correctness offDataF ield)

fDataF ield(Im) (Definition 5.3.64) is a valid transformation function in the sense of Definition 4.4.26 transforming ImDataF ield intoIGDataF ield.

Also see imod_data_field_to_ig_data_field_as_edge_type_func in

Ecore-GROOVE-Mapping-Library.DataFieldValue

The proof of the correctness of fDataF ield will not be included here. Instead, it can be found in the

validated Isabelle theories.

Finally, to complete the transformation, the transformation function that transforms IGDataF ield into ImDataF ieldis defined:

Definition 5.3.66 (Transformation functionfDataF ield′ )

The transformation functionfDataF ield′ (IG) is defined as:

Object={src(e)|e∈EIG}

ObjectClass = {︂(ob, classtype) if ob∈ {src(e)|e∈EIG}

ObjectId = {︂(ob, obids(ob)) if ob∈ {src(e)|e∈EIG}

FieldValue = {︂((ob,(classtype, name)), values(ob)) if ob∈ {src(e)|e∈EIG}

DefaultValue ={}

Also see ig_data_field_as_edge_type_to_imod_data_fieldin

Ecore-GROOVE-Mapping-Library.DataFieldValue

Theorem 5.3.67 (Correctness offDataF ield′ )

fDataF ield′ (IG) (Definition 5.3.66) is a valid transformation function in the sense of Definition 4.4.31 transforming IGDataF ield intoImDataF ield.

Also see ig_data_field_as_edge_type_to_imod_data_field_func in

Ecore-GROOVE-Mapping-Library.DataFieldValue

Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.