ADVANCED MODEL CONSISTENCY RESTORATION WITH HIGHER-ORDER SHORT-CUT RULES

. Sequential model synchronisation is the task of propagating changes from one model to another correlated one to restore consistency. It is challenging to perform this propagation in a least-changing way that avoids unnecessary deletions (which might cause information loss). From a theoretical point of view, so-called short-cut (SC) rules have been developed that enable provably correct propagation of changes while avoiding information loss. However, to be able to react to every possible change, an infinite set of such rules might be necessary. Practically, only small sets of pre-computed basic SC rules have been used, severely restricting the kind of changes that can be propagated without loss of information. In this work, we close that gap by developing an approach to compute more complex required SC rules on-the-fly during synchronisation. These higher-order SC rules allow us to cope with more complex scenarios when multiple changes must be handled in one step. We implemented our approach in the model transformation tool eMoflon. An evaluation shows that the overhead of computing higher-order SC rules on-the-fly is tolerable and at times even improves the overall performance. Above that, completely new scenarios can be dealt with without the loss of information.


Introduction
Model-Driven Engineering (MDE) [BCW17] provides the necessary means to tackle the challenges of modern software systems, which become more and more complex and distributed.Using MDE, a system can be described by various models that describe different aspects and provide specific views onto the system itself, where each view may overlap to some degree with other views of the same system.Consequently, if one view changes, we have to propagate these changes to other views that share the same information.This is necessary To define a consistency relationship between source and target models, we employ Triple Graph Grammars (TGGs) [Sch94], which are a declarative and rule-based way to achieve this.As the name indicates, the rules of a TGG define the language of all consistent triple graphs, where our source, target and correspondence models are interpreted as graphs.Figure 2 shows the TGG rule set of our running example, consisting of the three rules on the left.Before a rule can be applied, its precondition must be met, meaning that all context elements in black must exist and all attribute conditions hold.When the rule is applied, all elements depicted in green and annotated with ++ are created.The first rule is Nook Rule, which can be applied without any precondition.It creates a Nook House together with a corresponding Construction on the target side and a connecting correspondence link.Since this will create the first House of a row, it also creates a Plan on the target side.Finally, each Nook House must have a Floor but no Cellar or Saddle Roof.The two rules Cube Rule and Villa Rule are very similar to each other in that they both require a House in the row that must already exist together with a corresponding Construction and Plan.Given that, they create a House with the Cube or Villa HouseType as the next House in line and a corresponding Construction, where a Cube has a Cellar and Floor, while a Villa will have a Floor and Saddle Roof.For better readability, we do not display edge types in the rules; they can be unambiguously inferred from the metamodels.
Using these rules, we can create consistent models from scratch.More interestingly, we can transform these rules to obtain forward translation rules as is depicted on the right in Figure 2. The main difference to our original rules is that their created source elements have now become part of the precondition.Assuming that we want to translate a source to a target model, this makes sense as a source model must already exist beforehand.To avoid translating elements more than once, we introduce the annotations □ → ✓ □ and ✓ □. 1 Source elements that were created in the original TGG rule are annotated with □ → ✓ □ in the derived forward rule.This indicates that they mark elements upon translation such that the rule is only applicable to elements that have not been marked yet.Other source elements that were already black are annotated with ✓ □, which means that these elements must have already been marked; different formalisations of such a marking mechanism are available [HEGO14, LAF + 17, Kos22].Also, attribute assignments now turn to attribute constraints.In our example this means that instead of setting the HouseType each forward rule can only be used to translate a specific HouseType.Backward rules that allow translating construction plans to the corresponding row of houses can be derived completely analogously.We want to incrementally synchronise changes from one model to another.Figure 3 depicts a small model, which was consistent w.r.t.our TGG but then was changed on the source side.On the left, we see a Nook House h 1 , followed by a Villa h 2 and a Cube h 3 , while on the right side there are the expected corresponding elements in the form of a Plan p 1 and three Constructions c 1 , c 2 and c 3 , each with its Construction Steps.As a change, we deleted the second House h 2 , which means that the third House h 3 now succeeds h 1 .Furthermore, we changed the type of h 3 from Cube to Villa.
On the right side of Figure 3, we can see a so-called precedence graph, which is of particular interest for the rest of this paper.Some of its nodes correspond to the rule applications that created the original triple graph; others represent rule applications that could have possibly been used to create the newly added elements on the source side.Edges denote sequential dependence between rule applications.Each precedence node contains the initials of the corresponding TGG rule together with a small index, which is the same as the one of the created elements of this rule application.Apart from that, each node has two boxes where the left and right depict the consistency state of the source and the target side, respectively.Blank boxes indicate that the elements on this side are still intact w.r.t. the corresponding TGG rule, which means that they have not been tampered with or that the changes had no consistency violating effect, e.g., by changing the architect.Green boxes containing a "+" indicate that new elements have been detected, which can be translated by a TGG rule, while "*" would mean that there are new elements but they cannot be   translated because some elements that would need to be marked together with them are already marked, i.e., they are still part of another (possibly inconsistent) rule application.In both cases, the right box for the target side is annotated with "u", expressing our lack of information on whether the corresponding target elements already exist.In contrast, red boxes containing a "-" indicate that all translatable elements on this side were deleted, meaning that created elements on the opposite side should be removed as well.A red box with "/" states that some but not all translatable elements were deleted, which means that the remaining elements must be translated differently than before.Finally, an orange box with "#" means that an attribute was changed such that a rule application has become invalid, e.g., the HouseType.A formalisation of precedence graphs via (partial) comatchs can be found in [Kos22].
Regarding our example, we have an intact Nook Rule application N 1 on top.The Villa Rule application V 2 depends on N 1 as this provides the previous House, Construction and Plan.V 2 itself is no longer intact as indicated by "-" on the source side due to the deletion of House h 2 .Cube Rule application C 3 , which depends on V 2 is also no longer intact due to an attribute change within House h 3 from HouseType Cube to Villa, which is denoted as "#".C 3 is also inconsistent due to the deletion of the edge between House h 2 and h 3 , which is a partial deletion meaning that not all created source elements of this rule application were removed.Partial deletions are denoted with "/".Due to this attribute change and the new edge between House h 1 and h 3 , we could retranslate h 3 using Villa Rule as represented via the precedence node V 3 .However, since h 3 is still part of the former rule application C 3 , we find an "*" annotation on the source side of V 3 ; C 3 has to be revoked before it becomes possible to retranslate h 3 .
Those annotations and the actual precedence graph are constructed using the results of an incremental graph pattern matcher (IGPM) that tracks all rules' pre-and postconditions.If a postcondition is violated, then the IGPM engine will notify us that the postcondition can no longer be matched and we can analyse which model change caused this.For preconditions, we also track whether the source (or target) side are matched for forward (or backward) rules, which we refer to as source (or target) matches.This gives us all possible translation steps even if the necessary context has not yet been created on the target side that would enable the translation to be executed.Note, however, that some steps may be mutually exclusive either because they would translate the same elements or because they rely on other rules to create necessary context on the opposite side.
2.3.Preserving Information using Short-Cut Rules.One sees that the above-described change of moving the third house and changing an attribute should only trigger a change of Construction Steps while the information about the architect should persist.To achieve this, we use so-called Short-Cut Rules [FKST21], which describe consistency-preserving operations, e.g., moving a house in the row without losing the target side information.Basically, a Short-Cut Rule revokes a rule application and applies another one instead, while preserving those elements that would be deleted just to be recreated.For our example, a Short-Cut Rule could exchange the HouseType while adding the missing and removing the now superfluous Construction Steps.A TGG Short-Cut Rule is created by overlapping an inversed TGG rule (the replaced rule that revokes a former rule application) with another TGG rule (the replacing rule).Deleted elements from the replaced rule that are overlapped with created elements from the replacing rule are preserved and become context as they would otherwise be unnecessarily deleted and then recreated.Consequently, deleted elements from the replaced rule that are not in the overlap must be removed and, analogously, created elements from the replacing rule that are not part of the overlap must be created.Finally, only the attribute conditions from the replacing rule must hold after applying the Short-Cut Rule as we want to revoke the former replaced rule application.
The precedence graph and the dependency links between precedence nodes tell us which TGG rules to overlap with each other.In our example (Figure 3), there is an invalid Villa Rule application, while there is a new Cube Rule application that could be applied instead to make the now necessary transformation steps for Cube h 3 .We, thus, overlap Villa Rule with Cube Rule such that the parent House is not overlapped as it has changed, while the created Houses are assumed to be the same as well as their corresponding Constructions, the Plans and Floors.Note that generally, there are many ways to overlap rules, which means that there may be many possible Short-Cut Rules.As discussed in Section 4, we use optimisation techniques to encode the space of all overlaps and calculate a replacing rule that matches the given situation.Note that this process is completely automated.Figure 4 depicts the resulting Short-Cut Rule on the left.It tells us that we can move a House and change its HouseType from Villa to Cube at the same time if, on the opposite side, we remove the superfluous Cellar and add a new Saddle Roof.
As with TGG rules, Short-Cut Rules can be transformed to yield forward and backward operationalised versions.On the right of Figure 4, we can see its forward operationalisation.Intuitively, we have to make sure that a user made the same changes as the Short-Cut Rule on the source side so that applying the forward operationalisation will propagate these changes correctly.Similar to before, formerly created elements on the source side must be marked because they are new, while black elements remain marked.Deleted elements on the source side must have been deleted by a user change.Hence, we must ensure that these elements do no longer exist, which is expressed as a negative application condition [EEPT06] depicted in blue and annotated with "nac".Also note that some context elements are omitted from the rule that would stem from the replaced rule, e.g., the context construction.We can leave some of them out, if they are not needed to perform the Short-Cut Rule.This is the case for the House h 1 , which is needed to check whether the edge to h 2 has been deleted.The "rel" annotation on the right side indicates that h 1 is relaxed.Relaxed means that this element does not necessarily need to exist, because if it was deleted together with its adjacent edges, then the "nac" is satisfied.Of course, this is only reasonable if h 1 is indeed the House that was used as context in the replacing rule application that we are going to replace.We ensure this by only applying Short-Cut Rules at locations with formerly valid replaced rule applications and using the information about these rule applications to construct those parts of our Short-Cut Rule match that overlap with the replaced rule.
Using Cube-To-Villa forward Short-Cut Rule, we can now resolve the situation from before by first processing the deleted second House and deleting its corresponding parts and then repairing the target side of the third House by using this rule.While the result looks very similar to the one of translating the whole source model from scratch, we still have the information about each Constructions' architect, which means that this information is no longer lost during synchronisation.Another advantage is that moving a House in a long row of terrace Houses can be very expensive as all succeeding rule applications would have to be revoked.In many cases, Short-Cut Rules can also help with this issue by preserving the consistency of subsequent steps and thereby boost the performance.

Higher-Order Short-Cut Rules
Formally, a short-cut rule is sequentially composed from a rule that only deletes structure and another one that only creates structure [FKST18].(We have generalised that kind of sequential composition to arbitrary rules in [KT23].)In practical applications so far, we made use of a static, finite set of short-cut rules; we composed each inverse of a rule from  .Intuitively, such a Short-Cut Rule replaces the action of the inverse rule by the one of its second input rule (while preserving common elements).Note that the Short-Cut Rule from Section 2 is created in that way and that such Short-Cut Rules enable repairs in many situations.But certain complex model changes are not supported yet, namely situations in which the common effect of several TGG rules should be replaced by the effect of another set of TGG rules.For this, one needs Short-Cut Rules that are not just computed from the TGG rules (and their inverses) but from (arbitrary long) concurrent rules [EEPT06], i.e., sequential compositions, of the TGG rules (and their inverses).Yet, in contrast to before, we cannot precalculate this set as there are usually infinitely many ways to concatenate an arbitrarily large set of TGG rules and, thus, infinitely many Short-Cut Rules.Hence, we must investigate each inconsistency and deduce what TGG rules to concatenate at runtime to create a helpful higher-order Short-Cut Rule that repairs multiple rule applications at once.In this chapter, we will explain the process of deriving these new rules using our running example and conclude with a discussion on its correctness.
3.1.Exemplifying the Need for Higher-Order Short-Cut Rules. Figure 5 shows another example model together with its precedence graph.We can see two Houses, where one was of HouseType Nook and the other of HouseType Cube together with their corresponding Constructions.Then, the first House's HouseType was changed from Nook to Cube and another House of HouseType Nook was added at the beginning of this row.Similar to Figure 3, this results in an inconsistency shown in the precedence graph on the right.There, we see that the Nook Rule application N 2 has become invalid due to an attribute constraint violation.Intuitively, we would expect that a new Construction is created for the new Nook House, which is then added to the already existing Plan.However, our consistency specification makes this rather hard to achieve as the Nook Rule creates this Plan together with the first House in a row.By handling one rule application at a time, we have to translate the new Nook House, create a corresponding Construction and another Plan.Then, we would either Since also the order of the two original Houses was changed, this repair step necessarily needs to involve reacting to that and performing the required repair for the former Cube House that now is a Villa.Hence, a higher-order Short-Cut Rule is needed.
3.2.Deriving Higher-Order Short-Cut Rules On-the-fly. Figure 6 shows our proposed process on how to obtain the necessary higher-order Short-Cut Rule using the information from an annotated precedence graph.Remember, to create a Short-Cut Rule, we need two ingredients: a higher-order replaced and higher-order replacing rule; i.e., one concurrent rule, built from inverses of the TGG rules, and one built from the TGG rules.The first is trivial to obtain as we can directly derive it from neighboured inconsistencies in our precedence graph ( 2 ) by forming sets of inconsistent precedence graph nodes that are connected ( 1 ).Such a set is found by picking an inconsistent precedence node and exploring its adjacent neighbours.Every neighbour that is also inconsistent is added to the set and we explore its neighbours recursively.Note that here, and also for the synthesis of the replacing rule, the order in which we compose more than two rules is irrelevant since sequential rule composition is associative [BK21].In contrast, nodes that are still intact or depict alternative rule applications are ignored and not explored further.We, thereby, identify all inconsistencies that should be repaired in one step.
In our case, we only have one set consisting of the precedence graph nodes N 2 and C 3 .These nodes represent formerly valid TGG rule applications for which we know what elements were created and which were used as precondition.We also know what changes invalidated them.Thus, we can use this information to concatenate Nook Rule and Cube Rule ( 3 ) because we know that the Plan, House and Construction required by C 3 were created by N 2 .In general, the resulting replaced rule can have context elements that stem from  The much more challenging task is to synthesise the replacing rule.While we used some inconsistencies to deduce our inverse replaced rule, we now need information that tells us how to restore consistency ( 5 ).We, thus, need to use the precedence graph nodes with "+" annotations, which indicate new translation options using entirely new elements, and those with "*" that describe translation alternatives for elements that are still part of an older rule application.Yet, not all of these nodes are relevant as some translations could just be carried out without using Short-Cut Rules or they might be needed for fixing another inconsistency.We can identify the relevant nodes as those that (partially) overlap with nodes from our set of connected inconsistencies.Intuitively, these overlapped nodes are the ones we would like to reuse and, thus, make part of a new rule application that is again consistent.Naturally, "+" annotated nodes cannot overlap with any inconsistencies as their source elements are entirely new.However, at times it is necessary to repair elements and, simultaneously, translate new elements as we have seen in Section 3.1.We, thus, also transitively add precedence nodes annotated with "+" if they are connected with a "*" or "+" annotated node that already belongs to the set of relevant nodes.
In general, we try to identify clusters of precedence nodes that are connected and only consist of nodes with a "*" or "+" annotation.The intuition behind this step is that all these nodes represent rule applications that are related and might have to be repaired in one step to yield a better result, where each cluster is used to create a specific replacing rule.Having a set of possible rule applications, we now have to construct our replacing rule ( 6 ).However, we only have a partial knowledge on how to concatenate the identified rules because these changes have not yet been propagated.Regarding our example, we know that we have to concatenate Nook Rule, Villa Rule and Cube Rule, but only on the source side we know exactly how.
In general, there are more challenges that we have to overcome.First, we have to make sure that after the repair, all elements on the source side are again part of an intact rule application.This is a hard task because we may find that there are multiple ways to translate a specific element, e.g., by different rules that compete with each other.Then, selection of an appropriate set of rule applications is required.In some cases, this choice can influence how much information on the target side is preserved.Furthermore, we must select a set of rule applications such that the precondition of every selected rule application holdsthrough other rules selected for this replacing rule or through original rule applications that are still intact.Note that for sake of brevity, our example is rather small and does not show such a scenario.However, we discuss this case in Section 4. Finally, we must ensure that the newly repaired rule applications will not introduce a cyclic dependency, i.e., a situation where rule applications would mutually guarantee their preconditions; in our example, for instance, a cyclic row of houses.
To guarantee these conditions, we automated the encoding of the selection of a suitable subset of to be concatenated rules and the calculation of their overlap as an ILP problem.A solution to such a problem will essentially describe an applicable sequence of rule applications that do not lead to a dead-end.We encode competing rule applications as mutually exclusive binary variables and define constraints ensuring that a rule is only chosen if (one or many in combination) other rules create the elements needed by its precondition.Hence, we have to ensure via constraints that context elements are mapped to created elements of compatible type (the same or a sub-type) and that edges can only be mapped if their corresponding source and target nodes are also mapped accordingly.We also make sure that all remaining source elements that are part of the inconsistency must be handled by the replacing rule application.This encoding is inspired by former approaches that present the finding of applicable TGG rule sequences as an ILP problem, e.g., [Leb18,WA20].Regarding our example, there are no competing rule applications but considering the precondition of Villa Rule and Cube Rule, we know that the Plan must be the one created by the Nook Rule application.The Construction could be taken from the Nook Rule or in case of Cube Rule from Villa Rule.Due to our knowledge that the needed House of Cube Rule stems from a Villa Rule application, the constraints will make it infeasible for Cube Rule to take the Nook Rule's Construction as there is no correspondence node between them.The identified rules are concatenated ( 6 ) and form the replacing rule as depicted on the right of Figure 7.
Using both the inverse replaced and replacing rule as well as the information of the actual inconsistency ( 7 ), we can now construct the Short-Cut Rule.As with the search for a replacing rule, we know what elements to overlap on the source side.This means that we only have to calculate the overlap for the correspondence and target side.While there are still many possible overlaps, e.g., between all Constructions of both rules, we usually want to find the one(s) that preserve more elements.To support least surprise, for target elements that have a corresponding source element we prefer solutions that only identify these target elements if their corresponding source elements are also identified.We also encode the overlapping as an ILP problem to find an optimal solution w.r.t.preserving elements.Currently, we do not differentiate between elements but the optimisation function can be customised to favour elements that, e.g., contain attributes, which have no representation  on the other side and should be prioritised.In our computation of overlaps, we also support node type inheritance.
The resulting higher-order Short-Cut Rule is depicted in Figure 8 on the left.It results from overlapping the Houses h 2 and h 3 from the replaced rule with h 3 and h 2 from the replacing rule.We also overlap p, c 2 , f 2 , c 3 and f 3 from the replaced rule's target side with p, c 3 , f 3 , c 2 and f 2 from the replacing rule.Finally, we also overlap correspondence links and edges if their corresponding source and target nodes are also mapped onto another.By applying this rule, we can preserve the two Houses on the left together with their corresponding Constructions and Floors.We also preserve the Plan and create a new Nook House with corresponding target structures.Since h 2 was a Nook House, we now assign the new HouseType Cube, which means that we have to add a new Cellar on the target side and make it the first Construction Step.Similarly, h 3 was a Cube House but is now transformed to a Villa House, which means that the former Cellar is now superfluous and thus removed.Instead, we add a new Saddle Roof as a final Construction Step.As before, we can operationalise this rule ( 8 ) to obtain a forward (and likewise backward) variant as depicted in Figure 8 on the right.Applying it to our example from Figure 5, we can now translate the new Nook, while simultaneously repairing the other two Houses and preserving the Plan with its content.
3.3.Discussion.From a technical point of view, there are some aspects worth mentioning.As a result of the construction process, we do not only get a higher-order Short-Cut Rule but also (implicitly) its match w.r.t. the analysed inconsistency.Hence, we can directly apply the rule and repair the inconsistencies it addresses.Besides that, however, we do not store the generated rule for applying it at other locations, which has two reasons.First, a higher-order Short-Cut Rule is quite specific to a certain inconsistency that is characterised by a set of related broken rule applications and how exactly each of them has been invalidated.To efficiently determine whether an existing rule can be applied to another set of inconsistencies can, thus, be very challenging and iterating and trying out all stored rules will probably become more expensive than simply constructing the rule from scratch.Second, as a higher-order Short-Cut Rule targets multiple inconsistencies at once, the space of related inconsistencies is generally very large.Hence, we argue that encountering the exact same constellation of inconsistencies is less likely.Yet, this has to be investigated further for real-world scenarios.
Regarding our choice to use ILP solving, by applying a Short-Cut Rule, we want to preserve as much information as possible that would otherwise be lost when unnecessarily deleting and recreating elements.Hence, we face an optimisation problem where we want to overlap as many created elements from both the replaced and replacing rule as these elements end up being preserved.For our current implementation, we use ILP solving separately for 5 and 7 .In 5 , we want to maximise the number of mappings between context and created elements, which are the locations where the rules are glued together.Selecting more such mappings means that less created elements must stem from outside of the computed Short-Cut Rule and, thus, it is more likely to be actually applicable.In 7 , we want to maximise the number of mappings between created elements in both rules, reducing the number of elements that must be deleted, potentially reducing information loss.In the future, we intend to combine both problems 5 and 7 into a single optimisation problem because the choice of how to construct the replaced and replacing rule may affect the resulting mapping and, thus, the final Short-Cut Rule.
In the following, we shortly discuss applicability and correctness of the individual process steps.In 1 , we identify clusters of related inconsistencies by analysing the precedence graph.This information is then used to create the replaced and replacing rule.Choosing the cluster too small, e.g., to save performance, might lead to a Short-Cut Rule that is not applicable if necessary context has been altered and this change was not considered.In that case, we can still fall back to restoring consistency by revoking the rule applications and applying alternative translation steps instead, although, this has the risk of losing some information.In contrast, if the set is chosen bigger than necessary, then the resulting ILP problems also tend to become harder to solve as the search space increases.In our implementation, these clusters contain all related inconsistencies that are (transitively) connected with each other without any consistent steps in between.We, thereby, ensure that the cluster is not chosen too small as inconsistencies that are (remotely) related are repaired together.However, at the moment, we cannot guarantee that our chosen clusters are minimal because some inconsistencies may be related but do not need to be handled together, i.e., could be repaired by standard Short-Cut Rules or smaller higher-order Short-Cut Rules.In the future, we would like to investigate ways to identify situations where these clusters could be broken up to yield less complex ones, which has the potential of improving the performance of our approach.All 2 , 3 and 4 are trivial as we use information about formerly valid rule applications for which we rely on a pattern matcher to identify these locations.
Regarding 5 , we may encounter multiple alternative translation options for one element, which may lead to an exponentially increasing number of possible translation sequences and, thus, performance issues.However, under certain technical (and not too ).Yet, as discussed for 1 , different choices may lead to different amounts of preserved model elements.Creating the inverse of the resulting rule in 6 is again trivial.Regarding the underlying theory of (higher-order ) Short-Cut Rules, we refer to the literature for details [FKST18,Kos22,KT23].Importantly, for our purposes in 7 and 8 , both replaced and replacing rule are composed from the rules of the given TGG, through our computation of Short-Cut Rules and the information provided by the IGPM, we ensure consistent matching of the replaced and the replacing rule, and we prevent the introduction of cyclic dependencies.This means that we meet criteria that guarantee language-preserving applications of Short-Cut Rules (cf.[Kos22, Theorem 4.16] or [KT23, Theorem 17]).The according application of their operationalised versions during synchronisation then incrementally improves consistency (compare [Kos22, Proposition 6.15]).

ILP-based Construction
This chapter extends our previous work [FKMS23], where we could only convey the abstract concept of how to obtain higher-order Short-Cut Rules.Our new contribution in this regard is a description on how to implement the concept using optimisation techniques and how to constrain the solution space to get desirable results.
As discussed in the previous chapter, we employ ILP solving for two subsequent tasks.First, we use it to find out how to concatenate a set of TGG rules to obtain the replacing rule.Second, we use it to overlap both the replaced and the replacing rule to obtain the final Short-Cut Rule.Note that the latter case was already presented in [Fri22], which is why we will focus on creating the replacing rule.For that purpose, we slightly extend our example from before so that creating the replacing rule is no longer straightforward and different solutions are possible from which the most promising one should be chosen.Also note that the entire ILP problem for this example can be found in Appendix A.
Figure 9 shows an additional TGG rule and its forward operationalised form that extend our rule sets from Figure 2. In contrast to Cube Rule, the new Double Cube Rule creates two Cubes on the source side that both correspond to one newly created Construction on the target side meaning that both Cubes are planned as a semi-detached House.The purpose of this new rule is to introduce a kind of variability during the translation and likewise synchronisation of a terrace house model because there may be multiple ways on how to restore consistency now.Translating two Cubes in a row, for example, we are now able to choose between applying Cube Forward Rule twice or Double Cube Forward Rule once.Ultimately, this is something a modeller would have to decide on their own for two reasons: First, there is no information on the source side on whether there should be one or two Constructions for both Cubes in the target model.Second, choosing either option will let us still translate all other Houses that come after both Cubes.This means that this is no scenario where the translation may lead to a dead-end for certain translation sequences and, thus, neither of the two possibilities is wrong.Of course, this means that for synchronisation scenarios, we also must account for this kind of variability when we create the replacing rule.Specifically, we may now encounter situations with alternative TGG rule concatenations forming different replacing rules that will lead to different (but equally valid) Short-Cut Rules in the end.For our example, this might present us with the choice between a Short-Cut Rule that uses a Double Cube Rule and another using two concatenated Cube Rules to repair translation steps for two former Villa Houses.Using the Short-Cut Rule based on the Double Cube Rule would remove one of the Constructions on the other side, which could mean an unintended loss of information.Hence, these rules mainly differ in what and how many elements are preserved and for that reason, it is important to choose the replacing rule that will be a better candidate for preserving information.
Figure 10 depicts a scenario in which we will encounter such a situation.As can be seen, we start with a row of three Houses beginning with a Nook followed by two Villa Houses.For each House, there is a corresponding Construction as well as a Plan containing them on the target side.As before, however, we change the source side and introduce an inconsistency.This time, we change the type of h 2 and h 3 from Nook and Villa to Cube.Additionally, we add a new Nook house h 1 before h 2 .As before, the most apparent inconsistency is that the Constructions c 2 and c 3 no longer contain the necessary building steps since a Cube has a Floor but no Saddle Roof and a Nook House has neither.Besides that, there are no corresponding elements for the newly added Nook as it has not yet been translated to the target side.To resolve this issue and restore consistency, we must investigate the precedence graph that is shown on the right side of Figure 10.We see that there is a new Nook Rule application as well as an invalidated one.The first N 1 is annotated with "+" meaning that its source elements are entirely new and thus free for translation and the latter is N 2 , which became inconsistent due to an attribute change ("#").Since the Nook is now a Cube, we find a new Cube Rule application C 2 as an alternative translation for the House h 2 .Besides that, we have an inconsistent Villa Rule application V 3 , which was also invalidated due to an attribute change and which caused the appearance of the new Cube Rule application C 3 .In combination, changing both h 2 and h 3 to being Cube Houses lead to a Double Cube Rule application DC 1,2 .Notably, the rule applications C 2 , C 3 and DC 1,2 can not be applied yet, as indicated by their "*"-annotation, because they would mark elements that are still marked by both N 2 and V 3 .Hence, our goal in the following is to create a replacing rule (followed by a Short-Cut Rule) that will let us translate the new Nook House and synchronise the attribute change, while trying to preserve elements on the target side.We, therefore, have to consider several aspects. 1 We know of all elements that were part of a replaced rule application, i.e., the rule applications that were once consistent and should now be repaired.Yet, the same does not hold for the candidates that will form the replacing rule.This is because we only know of elements from the source domain 2 but not the target domain, which in the precedence graph is expressed with a "u".This annotation stands for undefined and indicates that we do not know yet, whether there already are any elements on this side that we could reuse or whether we should create them all from scratch.Hence, we have to figure out whether context elements from one replacing rule candidate are created by another candidate or whether they come from yet another still consistent rule application.For example, we would have to figure out for C 3 what rule application created the Plan. 2 Some candidates may exclude each other.In our case, we know that C 2 and C 3 cannot coexist with DC 2,3 because they mark the same elements on the source side.Hence, we have to make sure that choosing a candidate means to exclude these other candidates from the solution.3 Several dependencies must be considered.There are, for example, dependencies between replacing rule candidates such as between C 2 and C 3 because the first has to be chosen (and applied) before the latter (if the latter is chosen at all).Similar dependencies exist between rule elements, e.g., by mapping a context node to the created node of another rule because we assume that this rule creates the necessary context.In our example, this could be the context Plan needed by C 3 and found created by N 1 .Edges and correspondence links are a special case in that regard as they are only allowed to be mapped when their source and target elements were also mapped onto each other, ensuring that this is indeed the same edge.4 While there may be multiple possible replacing rules, not all candidates are equal in how much information can be preserved in the end.Thus, we have to find a metric for assessing the value of a solution that indicates the usefulness of a specific replacing rule w.r.t. the final Short-Cut Rule.

Concatenation of rule candidates.
As mentioned before, we will use ILP to solve the above described problem.In general, when using ILP, we abstractly encode search spaces by means of optimisation variables that in combination with an objective function must adhere to certain constraints.In our case, we are only interested in 0-1 or pseudo-boolean ILP of the form: being a vector of weights and v being the vector of our boolean optimisation variables v 1 , ..., v m .The variables can represent entities such as rule application candidates and whether we consider them for our replacing rule or mappings between rule elements, e.g., whether we assume that a certain context element of one rule application will be created by a certain other one.In the following, we will write v[. ..] to reference a specific variable in our vector v, where the value between the brackets represents a unique index.Maximising the function should ultimately yield a valid concatenation of our replacing rule candidates, where weights can be used to favor the selection of specific variables.
In our example, all weights will usually be set to 1.By choosing to customise these weights, however, a user can encode restoration preferences, e.g., to give certain elements a higher priority to be preserved or even penalise others that should be avoided.Due to the various aspects that we have to consider, we will start with a small set of optimisation variables and constraints and extend them step-by-step solving the above-described sub-problems along the way.
Encoding rule applications and their dependencies.Constructing the replacing rule means to determine, which rule candidates to concatenate.Therefore, for each replacing rule candidate from our precedence graph, there is one variable in v that states whether this candidate is chosen for the replacing rule or not.For our example, we would have the following variables: ].Then, we encode their dependencies that we can read from the precedence graph, e.g., we can see that C 2 depends on N 1 , which means that v[C 2 ] may only be set to 1 if v[N 1 ] is 1 as well.This can be expressed . Consequently, we introduce the same constraint for the other candidates: . Some rule candidates are mutually exclusive because they would mark the same elements, which must be avoided because each element can only be translated once.Hence, we need to make sure that C 2 and C 3 cannot be chosen alongside DC 2,3 and vice versa because the latter marks the same elements as both Cube Rule applications.We, therefore, add the constraints Encoding possible dependencies of target context.In the next step, we need to figure out how to concatenate our replacing rule candidates.While we already know how rule application candidates can be concatenated on the source side of our example, it is not clear where target elements come from, i.e., which rule application would create them.Hence, we have to determine whether a context element from one rule candidate might be the created element of another candidate.For that purpose and for each candidates context (black) element, we search for created ('++', green) elements in candidates that the current candidate (transitively) depends on and that have the compatible type and no conflicting attribute assignments/conditions.We will call these pairs of context and created rule elements in the following context-create mappings.Figure 11 depicts the context-create mappings for our rule candidates in blue, e.g., the context Construction c r 2,3 of DC 2,3 could be created as nc r 1 from N 1 , which corresponds to the context-create mapping c r 2,3 − → nc r 1 .Note that the source side elements are model elements from Figure 10, while the correspondence and target side depict rule elements, which is why we draw the latter with dashed lines and added r as a superscript to emphasise the difference.In general, there may exist several possible mappings for each context element as is the case for the context Construction c r 3 of candidate C 3 that could stem from C 2 or N 1 .While it is impossible that N 1 would create it because ultimately Construction c r 2 will be the one that corresponds to the Cube House h 2 , we have no static analysis to determine this beforehand and rely on the optimiser to find a reasonable solution in compliance with all constraints.For that reason, it is possible that no context-create mapping is chosen, which means that we assume that the context comes from outside our current scope.In general, we cannot be sure whether our candidate set is actually able to create all necessary context or if the context stems from a still valid rule application.Yet, incorporating all rule applications would severely impact the applicability of this approach, which would scale with the size of the model rather than the size of the change.That being said, we also create context-create mappings between edges.In comparison with context-create mappings between nodes, however, edges can only be mapped if their respective source and target nodes are also mapped onto another.Hence, we constrain these edge context-create mapping variables to ensure that they are only 1 if the correct node mappings are 1, too.For mapping edge e r 2 from candidate C 2 to e r 1 from N 1 , we would need to make sure that p r 2 is mapped to p r 1 and likewise c r 2 to nc r 1 .This can be expressed as v . Finally, we also have to create context-create mappings between correspondence links.Note that these mappings were omitted from Figure 11 for readability reasons.These context-create mappings are handled in a similar way as edges with the slight difference that we already know whether their source side matches, e.g., mapping the context correspondence link from C 2 to the created one from N 1 , we can see that both are compatible on the source side because they both use the same model element h 1 .If this is not the case, we can directly drop the mapping and continue.
We must also add exclusions to circumvent that more than one context-create mapping is chosen for each context element.Choosing more than one would mean that the context element is created by more than one rule application, which cannot be the case.As before, we can achieve this by formulating an exclusion, which ensures that the sum of all contextcreate mapping variables associated with the context element is less or equal than 1, e.g., ≤ 1, which states that c r 3 must be the element created as nc r 1 , nc r 2 or neither.
Combining rule applications and context dependency.Beyond that, we combine our rule candidate variables from before with these new context-create mapping variables to make sure that using a context-create mapping also implies that the respective rule candidates are chosen as well.We can express this implication by stating that the variable of a context-create mapping must be less or equal than the variable of a rule candidate, which means that the first can only become 1 if the latter is 1 as well.In our example, this must hold when setting the mapping variable v[c r 3 − → nc r 2 ] to 1, which means that both v[C 3 ] and v[C 2 ] must be 1 as well because they use elements from these candidates.Hence, we add the constraints v where the context-create mapping can only be 1 if both v[C 2 ] and v[C 3 ] are 1, too.
Optimisation goal.Assuming that we would now maximise the number of chosen contextcreate mappings, we would get a valid replacing rule that overlaps context and created elements as much as possible.Our constraints ensure that no competing rule candidates may be chosen at the same time, while our constraints for edge and correspondence context-create mappings ensure that a solution is favored that does not blindly map each context node to any possible creating node.Instead, it should always give a higher reward when also considering how each node is connected.Thereby, the edge and correspondence constraints become the glue that pushes us towards a concatenation that is not only valid but also reasonable and applicable.4.2.Incorporating former target side elements.The result can still be improved by incorporating information about target side elements that were created by our formerly valid replaced rule applications.When being presented with different alternatives as in our example, incorporating knowledge about formerly created elements can help us making a better decision, e.g., to preserve more elements.For example, considering our example from above, it could be better to use a replacing rule that includes both Cube Rule candidates instead of the Double Cube Rule because we want to repair a Nook Rule and a Villa Rule application that both created a Construction.Choosing the Double Cube Rule would result in a Short-Cut Rule that removes one Construction.Even if this is what we wanted, we need the means to state that either solution should be preferred.We can achieve this by introducing rule-model mappings between created rule elements from our rule candidates and model elements that were created previously by rule applications that are no longer intact and which we are trying to repair with the final Short-Cut Rule.The intuition behind this step is that we try to find out whether we can reuse and, thus, preserve elements created by prior rule applications that would otherwise be deleted.Figure 12 depicts these rule-model mappings for our example, although, the rule candidate D 1,2 has been omitted for readability reasons.Similar to the context-create mappings, for each context element in our rule candidates, we search for compatible model elements.This time, however, they must have the same type (i.e., we exclude subtyping) or else the created rule element would not be the same as the one we already have.Again, correspondence mappings are omitted due to readability reasons but we discuss them in the following, too.Also note that, as explained previously, we do not need mappings to source side elements, because we already know these mappings.
Having a look at Figure 12, we can see that there is only one available rule application candidate on the right side that creates a Plan, which means that we can only map p r 1 to p 2 .In contrast, each of the three Constructions on the right side could be mapped to any of the two existing Constructions in our model, which results in six mappings.This also holds for the edges between the Plan and a Construction for which we know that there must be three in the end but for which there are only two candidates in our model.We also map created correspondence links for which there are also six possible mappings.Creating all these mappings is an important difference between context-create and rule-model mappings.For the first, we also considered dependencies between rule candidates and (implicitly) filtered some mappings, while for the latter, we are not sure which rule application would be a good candidate for preserving the information.This is because the order in which elements are translated may have changed as is the case for the example in Section 3. Hence, we create mappings from each created rule element to all matching model elements and let the optimiser find a solution that reuses these elements in a reasonable way.Comparing the former rule applications with the new rule application candidates and incorporating this knowledge to improve performance is left to future work.
Encoding dependencies between rule-context mappings.Since each model element can only be created by one rule element, we must ensure that mappings pointing to the same model element are mutually exclusive.Similar to Section 4.1, we enforce this by adding a constraint that ensures that only one mapping variable can be set to one, e.g., for mappings to Of course, these mappings may only be chosen if the rule application candidate on the right side is chosen as well.As with the rule concatenation constraints, we can express this by stating that the rule-model mapping variable may only be 1 if the rule application candidate variable is 1, e . Finally, we have to make sure that edges and correspondence links are not mapped if their sources and targets are not mapped onto each other as well since edges can not be the same if they point to different elements.In comparison to the Section 4.1, where we mapped context to created rule elements, we are now only interested in mapping created rule elements to formerly created model elements.However, most of our created rule edges have one context node as source, e.g., e r 3 .This means that we can only take such an edge if its context rule node is mapped to a created rule node of another rule application candidate, which is then mapped to the corresponding element in the model.For mapping e r 5 to e 2 , we would add the following constraint: 3v 5 − → e 2 ] can only be 1 if the three other variables are set to 1 and sum up to 3, which means that nc r 3 and p r 1 were mapped to c 3 and p 2 , respectively, while the context Plan from C 3 is assumed to be created by N 1 .Only then, we can be certain that e r 5 could indeed create e 2 if C 3 is chosen.As in Section 4.1, correspondence links are handled similarly as edges with the slight difference that we already know what element they point to on the source side.Hence, we only have to encode constraints for the target side elements of correspondence links.
Incorporating edges and correspondence links is crucial as this will ensure that nodes are not reused randomly.Instead, those solutions will be preferred where relations between model nodes are preserved.In our example, we could map the created Constructions of C 2 and C 3 freely but when mapping nc r 3 to c 2 , we won't be able to map the correspondence link and, thus, get a smaller reward.Another interesting case is that of N 1 .We could not only map its Plan p r 1 to p 2 in our model but also map nc r 1 to c 2 .Doing so, however, would leave us with no option but to remove the correspondence link between h 2 and c 3 because we cannot (and probably also do not want to) repurpose the edge to point to h 1 .This means that edges and likewise correspondence links are our means of reasoning on whether elements are assumed to be the same and, thus, should be preserved.Maximising the number of chosen mappings, finally, tells us how to concatenate some of the rule candidates in order to obtain our final replacing rule.For our example and without choosing specific weights, we would choose N 1 , C 2 and C 3 as our candidates, where the context Plan of the latter two stems from N 1 as well as the context Construction from C 2 , while C 2 creates the Construction that is needed by C 3 .This means that the Constructions from C 2 and C 3 were mapped to the model Constructions c 2 and c 3 , respectively.In contrast, when choosing DC 1,2 , we would only be able to map one Construction from our rule application candidate to our model and there are less context-create mappings from context to created elements, which in total gives a smaller reward.If we would like to prefer the DC 1,2 nonetheless, then we can choose specific weights to make it more rewarding to choose it.An obvious choice would be to add a large weight to v[DC 1,2 ] so that the reward of choosing a Double Cube Rule is always higher than choosing two Cube Rule candidates.As a rule of thumb, we must choose a weight that is greater than the difference between the number of mappings a Double Cube Rule and two Cube Rules may have.Another, more fine-granular, option is to add weightings to rule-model mappings such that choosing mappings between a Double Cube Rule candidate and a model is worth more than choosing similar mappings for two subsequent Cube Rules.The difference between the first and second option is that the latter lets us prioritise specific elements over others.Figure 13 shows the resulting replaced and replacing rule.Both are used to create the Short-Cut Rule shown in Figure 14 (cf.[FKST21]) by overlapping both rules and thereby identifying common elements.Here, the overlap would be between elements with the same name.Overlapped elements are preserved when from our formerly valid replaced rule application to the replacing rule application.Finally, applying this rule on our changed model from Figure 10 would create the missing Construction for House h1, while preserving the already existing Plan and changing the other Constructions to have a Cellar instead of a Saddle Roof.4.3.Discussion.We would like to highlight and discuss some details of our approach.First, we would like to point out that, in general, there are multiple possible Short-Cut Rules as there are often various possible overlaps between a replaced and a replacing rule.While we do not search for all possible Short-Cut Rules due to performance reasons and because many of them are not useful, we limit ourselves to finding useful ones, according to a custom (hand-crafted) metric, i.e., a specific choice of weightings (cf.[FKMS23]).This means two things.First, in order to preserve specific elements, we need to encode this via weights such that a solution that focuses on these elements is preferred.Second, since we do not search and try all Short-Cut Rules, our approach is an heuristic where in its basic form we choose all weights to be 1 due to our experience with examples from our repository of test scenarios 3 .Of course, since our approach is a heuristic, it can happen that we are not able to find a Short-Cut Rule that can be used in that particular scenario.As discussed in the previous chapter, however, we can guarantee that each created higher-order Short-Cut Rule is indeed correct, meaning that these rules cannot be used to perform synchronisation steps that inflict new inconsistencies.If no rule can be found, there is still the option to retranslate elements that were part in prior rule applications, which is guaranteed to restore consistency [Leb18].
With the current ILP formulation, mapping an element from a rule to a model gives some reward.In contrast, we do not penalise if not all elements from a rule have a matching counterpart in the model, which in some cases would be reasonable.A future extension could thus introduce such a penality term, e.g., adding another rule-model mapping variable for each rule element that has a negative weight and enforcing that for each node exactly one rule-model mapping variable has to be chosen.If there are not enough elements in the model to map all rule elements for a rule candidate, we would have to set variables with a negative weight to 1, which reduces the overall reward.Then, it would become more likely that another candidate is chosen that explains more model elements.
Another important aspect is that after finding the replacing rule, we create the Short-Cut Rule using ILP solving in a subsequent step with our former Short-Cut Rule framework presented in [FKST21].In fact, having found mappings from our replacing rule candidates to both the replaced rule and the model, we could already create the Short-Cut Rule.Currently, we rely on the former construction mechanism of Short-Cut Rules but we plan to replace it with one that creates replaced, replacing and Short-Cut Rules in one step in the future.

Evaluation
We implemented our approach and integrated it into the state-of-the-art graph transformation tool eMoflon4 .Our approach extends our previous work on Short-Cut Rules [FKST18,FKST21] and while the approach has the potential to preserve more information during synchronisation, we have to investigate how our original Short-Cut Rules perform in comparison.Also, since our approach analyses dependencies and creates Short-Cut Rules on-demand at runtime, we have to investigate whether it introduces a noteworthy offset.Thus, we pose the following research questions: • (RQ1) Does the new runtime analysis introduce any additional cost in comparison with using a precalculated set of Short-Cut Rules?• (RQ2) Does our new approach indeed preserve more information in certain cases?Evaluation scenarios.To answer our research questions, we investigate five different scenarios of our running example with three different resolution techniques: The legacy algorithm [Leb18] revokes invalid rule applications and retranslates parts of the model, while SC stands for the original Short-Cut Rule framework with precalculcated repair rules [FKST21] and HO SC stands for our new higher-order Short-Cut Rules.We compare both SC and HO SC with legacy to show the impact of repairing models instead of retranslating them (partially).Note that in both SC and HO SC our algorithm falls back to using the legacy algorithm in case no Short-Cut Rule was found.
In the first and second scenario, we have a fixed number of 2 000 rows of Houses with around 26 000 nodes on both source and target side and we increase the number of applied changes in steps of 50 from 50 to 250.Our primary goal for these scenarios is to investigate how our approach copes with linearly scaling a number of different kinds of changes.In contrast, the third and fourth scenario comprise two long rows of Houses that we grow iteratively by adding new Houses in steps of 20 from 20 to 200.This change is expected to become more expensive to resolve as the rows grow larger but should also be able to more information than the other two algorithms.The fifth scenario was not part of our previous work and extends our former evaluation.It features one long row of 1 000 Houses, where the first House is of type Nook and all following ones are of type Villa.Then, we change an increasing number of Houses in this row to become of type Cube starting from 10 to 60 subsequent Houses in steps of 10.Both the former Short-Cut Rule and the newer higher higher-order Short-Cut Rule framework should be able to preserve the same amount of information, the latter is expected to be more expensive due to the prior analysis needed to find a suitable rule.We, thus, want to measure the effect that subsequently dependent changes have when using our new approach.
The specific changes for each scenario and their expected outcomes are as follows: In the first and third scenario, we add new Nook Houses at the start of each row.HO SC can synthesise a higher-order Short-Cut Rule to react to this change, while legacy has to re-translate each affected row and SC has to separately translate the newly created Nook Houses and then move the affected Constructions to the newly translated Plan (using precalculated Short-Cut Rules).In the second and fourth scenario, we relocate subrows.This is a worst-case scenario for HO SC.In this case, every moved House's Construction must be repaired and moved to the new Plan.While legacy has to perform this via retranslation, both SC and HO SC can use the same repair rules -only SC does not have the offset of creating them on-the-fly.In the fifth scenario, we change an increasing number of Villa Houses to being Cube, starting from the front.As a result, HO SC will have to construct larger Short-Cut Rules, which constitutes another worst-case scenario, while legacy will simply retranslate the Houses and SC can repair them step-by-step.
Experimental setup.We measure the time it takes to resolve the inconsistencies as well as how many elements are deleted in the process.Every measurement was repeated five times and we show the average runtime while the number of deleted elements did not fluctuate.The evaluation was executed on a system with an AMD Ryzen 9 3900x with 64GB RAM.It can be replicated using our prepared VM5 , which comes with a detailed explanation on how to reproduce the results.The current version v1.1 of our VM needs a license of the Gurobi6 ILP solver to execute the evaluation but the former version is still available and implements the first four test scenarios without this dependency.
Results. Figure 15 shows the measured times of the all scenarios.For the first and third scenario, where legacy and SC have to transitively retranslate/repair, creating the needed higher-order Short-Cut Rules on-the-fly even has performance benefits.For the second and fourth case, the results indicate that for one of the worst-case scenarios where SC will have the same effect as HO SC, constructing higher-order Short-Cut Rules and applying them instead of performing many smaller repair steps only introduces a small cost.However, the fifth scenario shows there are cases where the construction of large Short-Cut Rules can be very expensive, at least when compared to applying smaller Short-Cut Rules instead.For  Figure 16 shows the largest number of deleted elements (nodes and edges) for all scenarios.As can be seen, using HO SC has the potential of preserving more information than SC and legacy in the right cases (RQ2).In the others, both SC and HO SC outperform the legacy algorithm; this cannot preserve any information at all.
In sum, the research questions can be answered as follows: RQ2 can be answered with a clear yes because there is no case where our new approach preserved less information than the former Short-Cut Rule framework and for two scenarios it even preserved more.Regarding (RQ1), we can state that there are cases where our new approach introduces a significant overhead compared to our previous Short-Cut Rule framework.Yet, at the same time, there are cases where using our new framework can even save time in situations where we cannot repair a model using smaller Short-Cut Rules and large parts have to be retranslated to restore consistency.For several cases, both our new and the old Short-Cut Rule framework even performed similarly w.r.t. the performance.Considering that using higher-order Short-Cut Rules can indeed preserve more information, one can argue that it is advisable to use higher-order Short-Cut Rules and switch to the former algorithm in case that a specific scenario only consists of worst-case scenarios such as the fifth scenario of our evaluation.
Discussion.There are several points worth mentioning.First, the current evaluation features only one example with synthetic data.Our approach, thus, has to be evaluated further on other (preferably real-world) scenarios with non-synthetic data and user changes.Yet, based on our experience with our test suite of 22 TGGs7 , we argue that the investigated scenarios are representative and similar results are to be expected there as well.Second, while using HO SC has the potential to preserve more information than the other two approaches, there are cases where calculating a Short-Cut Rule would take too much time.This issue could be resolved by not creating one large Short-Cut Rule to handle all changes at once but rather splitting them up.Therefore, we need to find some criteria to judge whether a split could cause information loss.Apart from that, we could also reduce the size of the ILP problem by filtering those mapping variables that cannot be part of the final solution.Currently, we encode most mappings and rely on our ILP constraints to filter these ones out.

Related Work
In this section, we relate our approach to other sequential model synchronisation approaches.We will first focus on TGG-based approaches and then discuss other related works with a different methodology.
TGG-based approaches.There have been several works that implement model synchronisation by transitively revoking invalid rule applications and retranslating possibly large parts of a model [GW09, LAVS12, LAF + 17].While these approaches come with proofs of termination, correctness and completeness, they may lead to an unnecessary information loss and at times a decrease in performance.
In contrast, Hermann et al. [HEO + 15] tried to solve this issue by calculating the maximal still-consistent sub-model, which is used as a starting point to propagate the model changes.Their approach is shown to be correct but cannot guarantee that all changes are carried out in a least-changing way.Above that, calculating the sub-model is computationally very expensive and their approach is limited to a deterministic TGG rule set only.
A very similar approach to ours is given by Giese and Hildebrandt [GHNW12] where they propose repairing rules that closely resemble Short-Cut Rules.These also save nodes instead of unnecessarily deleting them and are able to propagate relocations of model elements.However, neither a construction scheme to obtain these rules is provided nor is the preservation of information proven to be correct.Yet, using our approach from [FKST21], we are indeed able to construct the same rules as mentioned in their work.Similarly, Blouin et al. [BPD + 14] also propose to use custom repair rules.
Another approach was initially proposed by Greenyer et al. [GPR11] and later formalised by Orejas and Pino [OP14].They propose that elements are never directly deleted but rather marked.Thereby, these elements are still free to be re-used during synchronisation, e.g., by letting a forward rule transformation take elements from the set of these elements instead of creating new ones and, thus, prevent them from being deleted.Yet, to the best of our knowledge, their approach was never implemented.
Finally, Anjorin et al. [ALK + 15] discussed design guidelines for TGGs that lead to less transitive dependencies between rule applications and can, thus, be synchronised without triggering a large cascade of retranslation steps.Yet in many cases, remodelling a TGG to comply with these guidelines means to change the defined language and may for that reason not be desired.
In summary, there are several TGG-based approaches that acknowledge the limitations of propagating changes by retranslating possibly large parts of a model.Some approaches follow a similar approach as ours, yet without a formal foundation or construction concept.Others have, to the best of our knowledge, never been implemented.While we provide both, we extend our previous works [FKST18,FKST21] by broadening the practical applicability and preserving information in more complex scenarios than before.
Bidirectional transformations.Another popular formal framework for bidirectional transformations are lenses.While there are many works related to lenses and least-changing incremental synchronisation [DXC10, HB19, HPW12, HPC18, WGW11], most are only theoretical and were not implemented.Most closely related to our work are the works of Hofmann et al. [HPW12] and Wang et al. [WGW11].Hofmann et al. introduced so-called edit lenses that focus on the changes and how to propagate and preserve them instead of taking a state-based approach.This is similar to our approach that works incrementally based on the perceived change to the model.Wang et al. too derive functions to propagate changes between models.However, their approach is limited to tree-like structures only.
Another approach by Macedo and Cunha [MC16] was influenced by the lenses framework and is based on ATL and SAT solving via Alloy.In their work, they describe how to encode the search space of all feasible synchronisation solutions as an optimisation problem.Their approach rates changes based on one of two metrics, namely the graph edit distance and the operation-based distance.Using these ratings, a least-changing propagation is calculated, interpreting least-change either as the minimal set of (propagation) operations needed or the minimal set of atomic graph edit steps to be taken.In comparison to our work, they incorporate more advanced metamodel constraints, e.g., OCL, and, generally, their approach should yield good results.The major drawback is the scalability as it is applicable to rather small models only.
Finally, Anjorin et al. [ADJ + 17] compared three existing state-of-the art tools for bidirectional transformations of different methodologies against each other.Specifically, they compared the rule-and TGG-based tool eMoflon [WAF + 19], the constraint-based tool mediniQVT 8 and BiGUL [KZH16], which is a bidirectional programming language and related to lenses.Comparing these tools, they showed that eMoflon tends to perform better than the other two approaches w.r.t.performance.Additionally, eMoflon only failed on one scenario, while mediniQVT failed in four and BiGUL in two.Using our previous smaller Short-Cut Rules [FKST18], we were already able to solve the last case and as shown in our evaluation, the new approach is able to preserve information in even more cases.This benchmark was later extended [ABW + 20], featuring more scenarios and being implemented by a more diverse set of tools.There, eMoflons performance was showing a worse runtime performance than most other approaches and was not able to solve 6 out of 34 cases.However, an older version was used that did not incorporate Short-Cut Rules and worked with another incremental pattern matcher that has since been replaced by a more efficient one.
Model repair.Model repair [MTC17] is the task of restoring the consistency of a model with regard to some specification.Since modelling languages like UML [Obj17] can be used to describe a single system using a set of models of different types, e.g., class and sequence diagrams, there are several approaches to model repair that do not only restore intra-model but also inter-model consistency, i.e., that propagate changes on one kind of model to related models of other kinds.Recent such approaches, in particular, with support for synchronising class and sequence diagrams, include [OPK + 21, KKLE21, BHRI22, MKA + 23].In these cases, consistency is defined via a modelling language like UML or the requirements of a modelling framework like the Eclipse Modeling Framework [Ecl24], possibly complemented by constraints expressed in a language like OCL [OMG14].Generally, TGGs could also be applied for such repair tasks.For this, it would first be necessary to develop grammars that express the desired consistency relationships between the different kinds of models.However, not every consistency requirement expressible in OCL can be expressed using a TGG since for TGGs the language inclusion problem is decidable.Having their formal foundation in the theory of graph transformation, TGG-based approaches, including ours, often come with far more comprehensive formal guarantees than offered in approaches like [OPK + 21, KKLE21, BHRI22, MKA + 23].On the other hand, whereas TGG-based approaches usually use repair operations that are derived from the rules of the grammar, do not automatically repair a model but provide the user with a set of (relevant) repair options from which they can choose; in this way, it is guaranteed that user intent will be met.Our approach could be extended in this direction by not computing a single higher-order Short-Cut Rule but different interesting ones, letting the user select between the different outcomes.

Conclusion
In this paper, we presented a novel approach to construct non-trivial repair rules in the form of higher-order Short-Cut Rules from a given consistency specification.These repair rules are constructed on demand by analysing a precedence graph that is annotated based on user changes.Our approach was fully implemented into eMoflon, a state-of-the-art graph transformation tool, which forms the base of our evaluation.In the evaluation, we showed that higher-order Short-Cut Rules can preserve information in more complex cases, while introducing only a small overhead to the runtime and at times even outperforming other strategies in eMoflon.Next, we would like to investigate whether we can identify situations statically where a higher-order Short-Cut Rule is needed to improve performance when smaller Short-Cut Rules suffice.For concurrent synchronisation scenarios, these rules could also be used to check whether sequences of user changes to both models correspond to or contradict each other.

Figure 7 :
Figure 7: Inverse Higher-Order Replaced Rule & Higher-Order Replacing Rule

Figure 8 :
Figure 8: Higher-Order Short-Cut Rule and Forward Higher-Order Short-Cut Rule

Figure 12 :
Figure 12: Mapping Rule Candidate to Model Elements

Figure 13 :
Figure 13: Replaced and Replacing Rule

Figure 14 :
Figure 14: Higher-Order Short-Cut Rule and Forward Higher-Order Short-Cut Rule

Figure 16 :
Figure 16: Comparison of deleted elements repair are often more flexible.For instance,Barriga et  al. employ machine learning [BHRI22] and Ohrndorf et al. [OPK + 21] and Kretschmer et al. [KKLE21] use information on the edit history of a model.Furthermore, Ohrndorf et al. [OPK + 21] as well as Marchezan et al. [MKA + 23] Nook Rule application and retranslate the Cube House or use a Short-Cut Rule to transform a Nook Rule to a Cube Rule application.Since Cube Rule does not create a Plan but requires one, either way we would have to delete the old Plan and then try to connect the newly created or preserved Constructions with the new Plan.While this restores consistency, this procedure has two disadvantages.First, any information stored in the original Plan would be lost and, second, we would have to fix all succeeding rule applications to connect them with the new Plan.Hence, we want to create a Short-Cut Rule that preserves the original Plan by translating the new Nook House and repairing the Cube House in one step.