5.2 Type level transformations
5.2.6 Data fields
All transformations discussed so far have focused on introducing different kind of types. In the following transformations, these types will be enriched with fields. In this transformation specifically, a field typed by a data type will be introduced.
Definition 5.2.58 (Type modelT mDataF ield)
LetT mDataF ieldbe the type model containing a regular class with identifierclasstype. ThenT mDataF ield defines a field named name with type f ieldtype, in which f ieldtype is either boolean, integer, real or string. T mDataF ieldis defined as:
Class={classtype}
Enum={}
U serDataT ype={}
F ield={(classtype, name)}
FieldSig = {︂(f,(f ieldtype,1..1)) if f ∈F ieldT mDataF ield EnumV alue={}
Inh={}
P rop={}
Constant={}
ConstType ={}
Also see tmod_data_fieldin Ecore-GROOVE-Mapping-Library.DataField
Theorem 5.2.59 (Correctness ofT mDataF ield)
T mDataF ield (Definition 5.2.58) is a consistent type model in the sense of Definition 3.2.11.
Also see tmod_data_field_correctin Ecore-GROOVE-Mapping-Library.DataField
A visual representation ofT mDataF ieldwith field namefieldon class.Examplecan be seen in Figure 5.6a.
In this example, the stringtype is chosen for the fieldtype, but any data type would have worked. The correctness proof ofT mDataF ieldis more involved, it is not included here for conciseness. It can be found
within the validated Isabelle proofs.
In order to make composing transformation functions possible, T mDataF ieldshould be compatible with
the type model it is combined with.
Theorem 5.2.60 (Correctness ofcombine(T m, T mDataF ield))
Assume a type model T m that is consistent in the sense of Definition 3.2.11. Then T m is compatible withT mDataF ield (in the sense of Definition 4.3.13) if:
• The class type on which the field is defined,classtype, is already an existing class inT m;
Also see tmod_data_field_combine_correctin Ecore-GROOVE-Mapping-Library.DataField
Proof. Use Lemma 4.3.12. It is possible to show that all assumptions hold. Now we have shown that
combine(T m, T mDataF ield)is consistent in the sense of Definition 3.2.11.
The definitions and theorems for defining a data field within Ecore are now complete.
Encoding as edge type
The most obvious encoding for an field in GROOVE would be using an edge type. The field is trans- formed into an edge type between an existing node type and the corresponding field type. The encoding corresponding to T mDataF ield can then be represented as T GDataF ield, defined in the following defini-
tion:
Definition 5.2.61 (Type graphT GDataF ield)
Let T GDataF ield be the type graph containing a node type which encodes the class type classtype. Fur- thermore, define an edge type from classtypenamed name. This edge type targets a node off ieldtype. T GDataF ieldis defined as:
N T ={ns_to_list(classtype), f ieldtype}
ET ={(ns_to_list(classtype),⟨name⟩, f ieldtype)}
⊑={(ns_to_list(classtype),ns_to_list(classtype)),(f ieldtype, f ieldtype)}
abs={}
mult(e) = {︂(0..∗,1..1) if e∈ {(ns_to_list(classtype),⟨name⟩, f ieldtype)}
contains={}
Also see tg_data_field_as_edge_typein Ecore-GROOVE-Mapping-Library.DataField
Theorem 5.2.62 (Correctness ofT GDataF ield)
T GDataF ield(Definition 5.2.61) is a valid type graph in the sense of Definition 3.3.5.
Also see tg_data_field_as_edge_type_correctin Ecore-GROOVE-Mapping-Library.DataField
A visual representation of T GDataF ield with edge name field on node type Example can be seen in
Figure 5.6b. Like the previous example, a string has been chosen to be consequent, but any primitive type could have been used. The correctness proof of T GDataF ield is more involved, it is not included
here for conciseness. It can be found within the validated Isabelle proofs.
In order to make composing transformation functions possible, T GDataF ield should be compatible with
the type graph it is combined with.
Theorem 5.2.63 (Correctness ofcombine(T G, T GDataF ield))
Assume a type graph T G that is valid in the sense of Definition 3.3.5. Then T G is compatible with T GDataF ield(in the sense of Definition 4.3.24) if:
• The node type of the encoded class type inT GDataF ield is already an node type inT G;
• The node type of the encoded class type inT GDataF ielddoes not already have an edge type with the same name as the field inT G.
Also see tg_data_field_as_edge_type_combine_correct in
Ecore-GROOVE-Mapping-Library.DataField
Proof. Use Lemma 4.3.23. It is possible to show that all assumptions hold. Now we have shown that
combine(T G, T GDataF ield)is valid in the sense of Definition 3.3.5.
Definition 5.2.64 (Transformation functionfDataF ield) The transformation functionfDataF ield(T m)is defined as:
N T ={ns_to_list(c)|c∈ClassT m} ∪ {f ieldtype} ET={(ns_to_list(c),⟨f⟩, f ieldtype)|(c, n)∈F ieldT m}
⊑={(ns_to_list(c),ns_to_list(c))|c∈ClassT m} ∪ {(f ieldtype, f ieldtype)} abs={}
mult = {︂(0..∗,1..1) if e∈ {(ns_to_list(c),⟨f⟩, f ieldtype)|(c, n)∈F ieldT m} contains={}
Also see tmod_data_field_to_tg_data_field_as_edge_typein
Ecore-GROOVE-Mapping-Library.DataField
Theorem 5.2.65 (Correctness offDataF ield)
fDataF ield(T m)(Definition 5.2.64) is a valid transformation function in the sense of Definition 4.3.25 transforming T mDataF ieldintoT GDataF ield.
Also see tmod_data_field_to_tg_data_field_as_edge_type_func in
Ecore-GROOVE-Mapping-Library.DataField
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 T GDataF ield into T mDataF ieldis defined:
Definition 5.2.66 (Transformation functionfDataF ield′ )
The transformation functionfDataF ield′ (T G) is defined as:
Class={list_to_ns(n)|n∈N TT G∩Labt} Enum={}
U serDataT ype={}
F ield={(list_to_ns(src(e)), l)|e∈ETT G∧ ⟨l⟩= lab(e)}
FieldSig = {︂(f,(f ieldtype,1..1)) if f ∈ {(list_to_ns(src(e)), l)|e∈ETT G∧ ⟨l⟩= lab(e)} EnumV alue={}
Inh={}
P rop={}
Constant={}
ConstType ={}
Also see tg_data_field_as_edge_type_to_tmod_data_fieldin
Ecore-GROOVE-Mapping-Library.DataField
Theorem 5.2.67 (Correctness offDataF ield′ )
fDataF ield′ (T G) (Definition 5.2.66) is a valid transformation function in the sense of Definition 4.3.30 transforming T GDataF ield intoT mDataF ield.
Also see tg_data_field_as_edge_type_to_tmod_data_field_func in
Ecore-GROOVE-Mapping-Library.DataField
Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.