In this section, the transformation of a containment field typed by a set of a proper class type is shown. This transformation defines a field which has a value a set of objects of a specified class type, that is not nullable. Furthermore, the objects referenced by the field are contained by the source class. First, the Ecore type model is defined.
Example TargetExample [0..7] field
(a)T mContainedClassSetF ieldto a class type.TargetExamplewithname=field
Example field TargetExample
(b)T GContainedClassSetF ieldto a class typeTargetExamplewithname=field
Figure 5.9: Visualisation of the transformation of a containment field typed by a set of a proper class type
Definition 5.2.95 (Type modelT mContainedClassSetF ield)
LetT mContainedClassSetF ield be the type model containing a regular class with identifierclasstype. Then T mContainedClassSetF ield defines a field named name with type containedtype, in whichcontainedtype is the identifier of another class type inT mContainedClassSetF ield. Furthermore, definemul to be a valid multiplicity for the fieldname. T mContainedClassSetF ield is defined as:
Class={classtype, containedtype}
Enum={}
U serDataT ype={}
F ield={(classtype, name)}
FieldSig = {︂(f,((setof,!containedtype), mul)) if f ∈F ieldT mContainedClassSetF ield EnumV alue={}
Inh={}
P rop={(containment,(classtype, name))}
Constant={}
ConstType ={}
Also see tmod_contained_class_set_field in
Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Theorem 5.2.96 (Correctness ofT mContainedClassSetF ield)
T mContainedClassSetF ield (Definition 5.2.95) is a consistent type model in the sense of Definition 3.2.11.
Also see tmod_contained_class_set_field_correctin
Ecore-GROOVE-Mapping-Library.ContainedClassSetField
A visual representation ofT mContainedClassSetF ield with field namefieldon class.Examplecan be seen in
Figure 5.9a. In this example,fieldreferences a class of.TargetExample. Please note that the multiplicity
0..7has been chosen here as an example, any valid multiplicity could have been used. Also notice that the field is in fact a containment relation. The correctness proof ofT mContainedClassSetF 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 mContainedClassSetF ield should be com-
patible with the type model it is combined with.
Theorem 5.2.97 (Correctness ofcombine(T m, T mContainedClassSetF ield))
Assume a type model T m that is consistent in the sense of Definition 3.2.11. Then T m is compatible withT mContainedClassSetF 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;
• The class type which the field targets, containedtype, is already an existing class in T m;
• The field namedname is not already a field onclasstype inT m;
• The multiplicity mulis valid.
Also see tmod_contained_class_set_field_combine_correctin
Proof. Use Lemma 4.3.12. It is possible to show that all assumptions hold. Now we have shown that
combine(T m, T mContainedClassSetF 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
Like the previous encodings of fields, an edge type in GROOVE will be used as encoding for the field. The field is transformed into an edge type from the encoded class type to the encoded target type. Furthermore, the edge type will be a containment edge, to support the fact that the target nodes are contained by the source nodes. The encoding corresponding to T mContainedClassSetF ield can then be
represented asT GContainedClassSetF ield, defined in the following definition: Definition 5.2.98 (Type graphT GContainedClassSetF ield)
Let T GContainedClassSetF ield be the type graph containing a node type which encodes the class type classtype. Furthermore, define an edge type from classtype named name. This edge type targets a node of containedtype. Finally, define multiplicity mul to beT GContainedClassSetF ield is defined as:
N T ={ns_to_list(classtype),ns_to_list(containedtype)}
ET ={(ns_to_list(classtype),⟨name⟩,ns_to_list(containedtype))} ⊑={(ns_to_list(classtype),ns_to_list(classtype)),
(ns_to_list(containedtype),ns_to_list(containedtype))}
abs={}
mult(e) = {︂(0..1, mul) if e∈ {(ns_to_list(classtype),⟨name⟩,ns_to_list(containedtype))}
contains={(ns_to_list(classtype),⟨name⟩,ns_to_list(containedtype))}
Also see tg_contained_class_set_field_as_edge_typein
Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Theorem 5.2.99 (Correctness ofT GContainedClassSetF ield)
T GContainedClassSetF ield (Definition 5.2.98) is a valid type graph in the sense of Definition 3.3.5.
Also see tg_contained_class_set_field_as_edge_type_correct in
Ecore-GROOVE-Mapping-Library.ContainedClassSetField
A visual representation of T GContainedClassSetF ield with edge name fieldon node type Examplecan be
seen in Figure 5.9b. Like the previous example,fieldreferences the.TargetExampleclass, but in this case the encoded node type ofTargetExample. Furthermore, it is visable that the introduced edge type for the field is indeed a containment edge. The correctness proof of T GContainedClassSetF 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 GContainedClassSetF ield should be com-
patible with the type graph it is combined with.
Theorem 5.2.100 (Correctness ofcombine(T G, T GContainedClassSetF 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 GContainedClassSetF ield (in the sense of Definition 4.3.24) if:
• The node types of the encoded class types inT GContainedClassSetF ieldare already node types inT G.
• The node type of the encoded class type in T GContainedClassSetF ield does not already have an edge type with the same name as the field in T G;
• The multiplicity mulis valid.
Also see tg_contained_class_set_field_as_edge_type_combine_correct in
Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Proof. Use Lemma 4.3.23. It is possible to show that all assumptions hold. Now we have shown that
combine(T G, T GContainedClassSetF ield)is valid in the sense of Definition 3.3.5.
Definition 5.2.101(Transformation functionfContainedClassSetF ield) The transformation functionfContainedClassSetF ield(T m)is defined as:
N T ={ns_to_list(c)|c∈ClassT m}
ET ={(ns_to_list(c),⟨f⟩,ns_to_list(containedtype))|(c, n)∈F ieldT m}
⊑={(ns_to_list(c),ns_to_list(c))|c∈ClassT m} abs={}
mult = {︂(0..1, mul) if e∈ {(ns_to_list(c),⟨f⟩,ns_to_list(containedtype))|(c, n)∈F ieldT m} contains={(ns_to_list(c),⟨f⟩,ns_to_list(containedtype))|(c, n)∈F ieldT m}
Also see tmod_contained_class_set_field_to_tg_contained_class_set_field_as_edge_type
in Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Theorem 5.2.102 (Correctness offContainedClassSetF ield)
fContainedClassSetF ield(T m)(Definition 5.2.101) is a valid transformation function in the sense of Defi- nition 4.3.25 transforming T mContainedClassSetF ield intoT GContainedClassSetF ield.
Also see tmod_contained_class_set_field_to_tg_contained_class_set_field_as_edge_type_func in Ecore-GROOVE-Mapping-Library.ContainedClassSetField
The proof of the correctness offContainedClassSetF ieldwill not be included here. Instead, it can be found
in the validated Isabelle theories.
Finally, to complete the transformation, the transformation function that transformsT GContainedClassSetF ield
intoT mContainedClassSetF ield is defined:
Definition 5.2.103(Transformation functionfContainedClassSetF ield′ )
The transformation functionfContainedClassSetF ield′ (T G)is defined as:
Class={list_to_ns(n)|n∈N TT G} Enum={}
U serDataT ype={}
F ield={(list_to_ns(src(e)), l)|e∈ETT G∧ ⟨l⟩= lab(e)}
FieldSig =
{︄
(f,((setof,!containedtype), mul)) if f ∈ {(list_to_ns(src(e)), l)|e∈ETT G ∧
⟨l⟩= lab(e)}
EnumV alue={}
Inh={}
P rop={(containment,(list_to_ns(src(e)), l))|e∈ETT G∧ ⟨l⟩= lab(e)} Constant={}
ConstType ={}
Also see tg_contained_class_set_field_as_edge_type_to_tmod_contained_class_set_field
in Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Theorem 5.2.104 (Correctness offContainedClassSetF ield′ )
fContainedClassSetF ield′ (T G)(Definition 5.2.103) is a valid transformation function in the sense of Defi- nition 4.3.30 transforming T GContainedClassSetF ield intoT mContainedClassSetF ield.
Also see tg_contained_class_set_field_as_edge_type_to_tmod_contained_class_set_field_func in Ecore-GROOVE-Mapping-Library.ContainedClassSetField
Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.