early warning identity threat and mitigation system eceasst_netsys2021_camera_ready_latex-2.pdf preface electronic communications of the easst volume 9 (2008) proceedings of the workshop ocl4all: modelling systems with ocl at models 2007 preface 2 pages guest editors: david h. akehurst, martin gogolla, steffen zschaler managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst preface the requirements that the modelling community wants to see supported by ocl now go far beyond its initial requirements. when ocl was conceived it was designed as a language for supporting precise modelling. the advent of the mda (model driven architecture) vision and the rapid acceptance of mde (model driven engineering) approaches emphasize new application domains (like domain specific languages or semantic web). this increase in new modelling languages causes a need for new ocl-like languages for systems modelling, frequently developed as extensions to the original. as this year’s special focus, the ocl workshop recognised that ocl is used as a basis for many text-based navigation languages. the workshop brought together the community that defines these extensions in order to consolidate the experiences, successes and failures involved in doing so. the workshop discussed the potential for redesigning or at least restructuring the ocl standard definition in order to better facilitate and support third-party extensions to the language. the workshop aimed to look specifically at how to apply the key software engineering principles of modularity and reuse to the definition of ocl. the workshop was organized as a part of the models 2007 conference in nashville, tennesee, usa. it continued the series of ocl workshops held at previous uml/models conferences in york (2000), toronto (2001), san francisco (2003), lisbon (2004), montego bay (2005) and genova (2006). this ec-easst volume contains improved papers of the papers already published on-line. the workshop organizers are grateful to authors for their effort to polish their papers. last but not least, we are grateful to the members of the program committee, the additional referees, all participants of the workshop and to the ec-easst editors for their support. david akehurst, martin gogolla, and steffen zschaler november 2007 1 / 2 volume 9 (2008) preface programme committee jean bezivin, université de nantes, france behzad bordbar, university of birmingham, great britain dan chiorean, babeş -bolyai university, romania tony clark, xactium ltd, great britain birgit demuth, technische universität dresden, germany robert france, colorado state university, usa heinrich hussmann, universität münchen, germany richard mitchell, inferdata ltd, great britain octavian patrascoiu, bt internet ltd, great britain mark richters, eads space transportation, germany shane sendall, snowie group lausanne, switzerland jos warmer, ordina, netherlands burkhart wolff, eth zurich, switzerland proc. ocl4all 2007 2 / 2 microsoft word isolads2021.doc electronic communications of the easst volume 081 (2022) guest editors: sven jörges, anna-lena lamprecht, anila mjeda, stefan naujokat eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 9th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2021 (isola ds 2021) preface sven jörges, anna-lena lamprecht, anila mjeda, stefan naujokat 1 page eceasst 2 / 2 volume 081 (2022) preface since its initiation in 2004, the international symposium on leveraging applications of formal methods, verification and validation (isola, see http://isola-conference.org) has been providing a forum for developers, users, and researchers to discuss issues related to the adoption and use of rigorous tools and methods for the specification, analysis, verification, certification, construction, test and maintenance of software systems from the point of view of their different applications domains. in 2014, isola hosted for the first time also a doctoral symposium as a scientific and networking event specifically targeted at young academics, complementing the different thematically focused research tracks of the main symposium. master and phd students were invited to participate and to present their research ideas and projects, to discuss them with the scientific community, and to establish collaborations in their field of research. it was very well adopted (by the young researchers as well as by several seniors that attended the sessions) and presented high-quality works on a wide range of topics. accordingly, the next isolas also featured doctoral symposia. this volume contains the post-proceedings of the 2021 doctoral symposium. the six papers contained in this volume are the result of a selection and reviewing process that started with a total of eight contributions. we are very grateful to all individuals who acted as reviewers for the efforts they put into the selection process and for the valuable feedback they provided, which was essential to ensure high quality content. the organizers of the 2021 isola doctoral symposium, sven jörges, anna-lena lamprecht, anila mjeda, and stefan naujokat volume reviewers samih al-areqi, mazars berlin, germany steve boßelmann, tu dortmund university, germany ivan hugo guevara, university of limerick, ireland sven jörges, fh dortmund, germany rafflesia khan, university of limerick, ireland anna-lena lamprecht, university of potsdam, germany anila mjeda, munster technical university, ireland stefan naujokat, tu dortmund university, germany stephen ryan, university of limerick, ireland barbara steffen, tu dortmund university, germany dimitrios zafeirakopoulos, national technical university of athens, greece discrete-time analysis of multicomponent gi/gi/1 queueing networks electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) discrete-time analysis of multicomponent gi/gi/1 queueing networks stefan geissler, stanislav lange, phuoc tran-gia, tobias hossfeld 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst discrete-time analysis of multicomponent gi/gi/1 queueing networks stefan geissler1, stanislav lange2, phuoc tran-gia1, tobias hossfeld1 1 university of wuerzburg 2 norwegian university of science and technology abstract: in this work, we provide initial insights regarding the error introduced into multicomponent queueing systems by assuming the departure processes of arbitrary gi/gi/1-∞ queues to be renewal processes. to this end, we compute the sojourn time distribution as well as departure distributions of a linear chain of queueing components and compare the results to a simulation of the same system. by applying the renewal approximation, potential autocorrelations of the departure processes are lost. we investigate the magnitude of this error regarding both the sojourn time as well as interdeparture time distributions for a broad set of parameters. although more indepth studies are needed, our results show that both distributions can be closely approximated, which allows the application of the model to asses the performance of real world nfv function chains. keywords: discrete-time analysis, queueing theory, queueing networks 1 introduction the complexity of both, applications as well as their underlying networks and compute architectures has increased substantially over the last few years. the abundance of cost-efficient cloud resources and the emergence of cloud-native microarchitectures, as well as the introduction of paradigms like network functions virtualization (nfv) and software-defined networking (sdn) have led to systems becoming significantly more complex. while legacy system are often designed as large, monolithic structures, modern systems consist of a multitude of largely independent actors that communicate with each other in order to perform their tasks. this microarchitecture paradigm allows cost-efficient resource scaling, improves system resilience, and shortens release cycles. however, the decomposition of functions into microservices (ms) introduces new challenges regarding the modeling and performance evaluation of such systems. since requests traverse several mss, the performance of the whole system is composed of the performance of chains of mss. finally, such models can be used during the dimensioning of complex, interconnected systems to establish required processing rates for each component as well as for the detection of bottlenecks in existing systems. to this end, we propose an iterative approach to numerically compute the departure process of individual gi/gi/1-∞ mss and show that by utilizing the resulting departure process as an arrival process to a subsequent system component, we can approximate several performance characteristics of downstream system components. the model is based on the assumption that the departure processes of individual components are renewal processes and do not exhibit any autocorrelation. this, in general, does not hold true in arbitrary systems. 1 / 4 volume 080 (2021) discrete-time analysis of multicomponent gi/gi/1 queueing networks hence, in this work, we describe the approach itself as well as quantify the error introduced through the renewal approximation for different system configurations. 2 related work queueing stations of the type gi/gi/1-∞ as well as general queueing networks composed of multiple such queueing stations have been investigated in the past by, e.g. tran-gia [1], kuehn [2], and whitt [3]. similarly, the evaluation of the waiting time distribution of gi/gi/1 systems has been evaluated previously [4–6]. additionally, we have shown previously that the waiting time distribution can be determined numerically, even for more complex systems [7, 8]. 3 interdeparture time distribution model the model used in this work is based on the model proposed in [1]. to disambiguate between random variables (rvs) and distributions, we use the following convention: uppercase letters such as a denote rvs, their distribution is represented by a(k). accordingly, the model input is composed of the interarrival time distribution a(k), as well as the service time distribution b(k). based on that, waiting time w(k) and interdeparture time d(k) can be calculated as follows. to compute the interdeparture time distribution, we first need to compute the waiting time distribution w(k). this can be done using lindley’s equation, in which ∗ denotes the convolution. note that we assume the system to be in a stable state and can hence use c(k), a(k), and b(k) without indices indicating their respective arrival. wn+1(k) = π0(wn(k)∗ c(k)) with c(k) = a(−k)∗ b(k) (1) π0(x(k)) =   x(k) k > 0 ∑ 0 i=−∞ x(i) k = 0 0 k < 0 the waiting time can then be used to compute the idle time distribution i(k) via the virtual unfinished work uv(k). the idle time distribution describes the time a system is idle after a departure event. uv(k) = w(k)∗ c(k) = w(k)∗ a(−k)∗ b(k) (2) i(k) = k · uv(−k) with k−1 = ∞ ∑ j=1 uv(− j) finally, the interdeparture time distribution d(k) can be computed using the service time distribution b(k), the idle probability pe , and the idle time distribution i(k). d(k) = pe ·(i(k)∗ b(k))+(1 − pe)· b(k) with pe = e[a]− e[b] e[i] (3) analogously, the sojourn time distribution s(k) of linear chains with n components can be approximated via w(k) and b(k). note that this neglects potential autocorrelations in wi(k). s(k) = w1(k)∗ b1(k)∗ w2(k)∗ b2(k)∗ ...∗ wn(k)∗ bn(k) (4) netsys 2021 2 / 4 eceasst 4 evaluating multicomponent queueing systems in the following, we apply the model to iteratively compute the interdeparture time distribution of component i, which is then applied as an interarrival time distribution to component i + 1. we assume a system of linearly concatenated gi/gi/1-∞ queueing components without crosstraffic (cf. figure 1). here, we assume the departure process to be a renewal process, which, in general, is not true. instead, the departure process of a gi/gi/1-∞ queue must be assumed to exhibit autocorrelation. subsequently, we quantify the error introduced by assuming d1,d2,d3 to be renewal processes when it comes to a) the interdeparture time distribution and b) the distribution of the sojourn time for the whole system. in order to assess the error, the model results are compared to simulations with the same input parameters. a b1 b2 b3 d1 d2 d3 = dw1 w2 w3 negative binomial c = {0.5, 1, 2} e[b] = 50 deterministic negative binomial c = {0.5, 1, 2} e[a] = 100 negative binomial c = {0.5, 1, 2} e[b] = 50 deterministic negative binomial c = {0.5, 1, 2} e[b] = 100ρ a b b b ρ = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.98} figure 1: system and parameter overview. ● ● ● ●0.0 0.1 0.2 0.3 0.4 0 0.5 1 2 js d (s m o d , s si m ) (a) ca ● ● ● ● ● ● ● ● ● ● ● 0.0 0.1 0.2 0.3 0.4 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.95 0.98 js d (s m o d , s si m ) (b) ρ figure 2: mean, max, and min jsd of the sojourn time s(k) for different values of ca and ρ . figures 2 a) and b) show main effect plots of the jenson-shannon-divergence (jsd) for different values of ca and ρ . cb has been omitted here since the effects are similar to the ones induced by ca. the figures show all jsd values obtained by evaluating every parameter combination possible from the values presented in figure 1. the results show that the sojourn time can be closely approximated by assuming d1,d2,d3 to be renewal processes. the 95% quantile of jsd values is 0.037 for the sojourn time. a similar evaluation regarding the interdeparture distribution of the last component has shown a 95% quantile of 0.0004. regarding the sojourn time, the largest error with a jsd value of 0.45 has been observed for a deterministic arrival process and deterministic service time of the second processing unit in combination with high system load (ρ = 0.98). this is due to the fact that deterministic arrival and service times lead to maximum autocorrelation regarding the departure process. however, since deterministic distributions are rarely observed in technical 3 / 4 volume 080 (2021) discrete-time analysis of multicomponent gi/gi/1 queueing networks systems, when filtering these processes out, the highest observed error was a jsd value of 0.13 for ca = 0.5, cb1 = cb3 = 2, cb2 = 0.5 and ρ = 0.98. 5 conclusion in this work, we provide preliminary insights into the linear concatenation of gi/gi/1-∞ queueing components. we apply existing models for the calculation of the interdeparture time distribution in order to iteratively compute the waiting time distribution of further components in the chain. finally, we are able to compute the sojourn time for the total system and show that, for the parameter combinations evaluated in this work, a close approximation is possible. moving forward, future work includes the extension of the parameter space to cover more cases as well as the introduction of new parameters such as the length of the chain as well as autoregressive arrival processes. furthermore, the impact of cross-traffic and feedback loops needs to be investigated. references [1] p. tran-gia, “discrete-time analysis for the interdeparture distribution of gi/g/1 queues,” in proc. of the international seminar on teletraffic analysis and computer performance evaluation, 1986, pp. 341–357. [2] p. kuehn, “approximate analysis of general queuing networks by decomposition,” ieee transactions on communications, vol. 27, no. 1, pp. 113–126, 1979. [3] w. whitt, “the queueing network analyzer,” the bell system technical journal, vol. 62, no. 9, pp. 2779–2815, 1983. [4] j. abate, g. l. choudhury, and w. whitt, “calculation of the gi/g/1 waiting time distribution and its cumulants from pollaczek’s formulas,” archiv für elektronik und ubertragungstechnik, vol. 47, no. 5/6, pp. 311–321, 1993. [5] w. k. grassmann and j. l. jain, “numerical solutions of the waiting time distribution and idle time distribution of the arithmetic gi/g/1 queue,” operations research, vol. 37, no. 1, pp. 141–150, 1989. [6] m. murata and h. miyahara, “an analytic solution of the waiting time distribution for the discrete-time gi/g/1 queue,” performance evaluation, vol. 13, no. 2, pp. 87–95, 1991. [7] t. zinner, s. geissler, s. lange, s. gebert, m. seufert, and p. tran-gia, “a discrete-time model for optimizing the processing time of virtualized network functions,” computer networks, vol. 125, pp. 4–14, 2017. [8] s. geissler, t. prantl, s. lange, f. wamser, and t. hossfeld, “discrete-time analysis of the blockchain distributed ledger technology,” in 2019 31st international teletraffic congress (itc 31), ieee, 2019, pp. 130–137. netsys 2021 4 / 4 introduction related work interdeparture time distribution model evaluating multicomponent queueing systems conclusion count me if you can:enumerating quic servers behind load balancers electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) count me if you can: enumerating quic servers behind load balancers kashyap thimmaraju and björn scheuermann 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst count me if you can: enumerating quic servers behind load balancers kashyap thimmaraju and björn scheuermann department of computer science, humboldt universität zu berlin abstract: quic is a new transport protocol over udp which recently became an ietf rfc. our security analysis of the connection id mechanism in quic reveals that the protocol is underspecified. this allows an attacker to count the number of server instances behind a middlebox, e.g., a load balancer. we found 4/15 (~25%) implementations vulnerable to our enumeration attack. we then concretely describe how an attacker can count the number of instances behind a load balancer that either uses round robin or hashing. keywords: quic, security analysis, connection id, enumeration 1 introduction it appears that the next major step in the evolution and wide-spread adoption of a new transport protocol since tcp is quic [lrw+17]. quic was recently standardized by the ietf [it21] and is the underlying transport protocol for http/3. there are several stake-holders involved in the standardization: mozilla, facebook, google, cloudflare, apple and others. as we approach the standardization of the protocol (scheduled for 2021), we witness an increase in the number of publicly accessible quic servers [qui20, rpdh18]: rüth et al. measured an increase in roughly 1 million ipv4 addresses using quic in july 2019. despite the many benefits quic brings to internet communication and security, e.g., no headof-line blocking, multiplexing, authenticated and encryption with associated data, and connection migration, it also introduces new security and privacy concerns. in 2019, sy et al. [sbff19] pointed out that quic servers can identify a user across multiple connections using two features of the protocol and in 2020, reen et al. [rr20] uncovered critical vulnerabilities in 4 quic implementations in addition to describing deep packet inspection elusion strategies. motivated by potentially new security and privacy issues introduced by quic, in this paper we make the following contributions: 1) we conduct a security analysis of the connection id (cid) mechanism of the quic protocol in 15 different implementations; 2) we uncover unspecified behaviour in the protocol that fundamentally deals with uniquely identifying the source and destination within a quic connection using the cid. 3) we describe an attack scenario (see fig. 1) that exploits the unspecified behaviour and sketch an algorithm against round robin and hash-based load balancers that enables a malicious client to count the number of server instances behind the load balancer. paper organization: in the following section we describe the necessary background on quic connection ids. in section 3 we describe our threat model followed by our security analysis and evaluation. next, we describe our enumeration attack and sketch an attack algorithm in section 4, and then conclude in section 5. 1 / 5 volume 080 (2021) count me if you can: enumerating quic servers behind load balancers www.example.com internet how many instances of example.com are online? i want to ddos that domain… load balancer figure 1: a high level illustration of the enumeration attack scenario described in this paper. knowing the number of instances helps to estimate the load required to launch a ddos attack. 2 quic connection ids when a client connects to a server for the first time, in addition to using the ip address and ports, the client generates a (pseudo-random) connection id (cid) for itself (source cid) as well as for the server (destination cid) it wishes to connect to. “the primary function of a connection id is to ensure that changes in addressing at lower protocol layers (udp, ip) don’t cause packets for a quic connection to be delivered to the wrong endpoint” [it21] . these two cids are inserted into the quic (long) header in plain-text along with the length of each cid and sent to the server as an initial packet. upon receiving the initial packet, the server can either generate a new cid for itself or use the cid that the client generated for the server. regardless of what it chooses, it then places the cids in its response to the client. once the quic handshake is complete, each end-point (i.e., client or server) then only includes the destination cid in the (short) header. the cid has a maximum length of 20 bytes and follows a variable length encoding scheme. 3 security analysis of the connection id we begin by outlining the threat model we adopt. next, we analyze the quic cid mechanism described in the protocol draft [it21] followed by our evaluation and results of 15 publicly available (closed source and open source) implementations. attacker model. we assume the attacker can actively establish connections with one or more quic servers routable via the internet. this means that she can send any type of quic packet which could also be malicious or non-conformant to the protocol. on the server side, we assume that there is typically a load balancing system in place for scaling and availability reasons. for example, multiple ip addresses could resolve the same domain name in addition to using an l3/l4 load balancer to distribute the incoming requests across multiple instances (e.g., virtual machines, containers or bare-metal) of the quic server. we assume the load balancers do not use the cid to route connections. finally, we assume that there are other benign clients attempting to connect to the server. analysis. having set the context for the attacker and server instances, we now describe our security analysis of the cid aspects of the current draft (version 30) of the quic protocol. the draft specifies and recommends several important points on secure usage of the cid, e.g., netsys 2021 2 / 5 eceasst i) the same cid must not be used multiple times over the same connection to prevent an eavesdropper from correlating the end-points; ii) end-points should associate a sequence number with each cid to detect reuse within the same connection; iii) cids should be (pseudo) randomly generated as they are also used for packet security and; iv) cids can be very long (max. 20 bytes). the draft, however, does not specify how servers should handle the case when successive incoming connections to a server use the same destination cid. indeed, it can be seen that based on the assumption that the cids are (pseudo) randomly generated with a maximum length of 20 bytes, the probability of such a collision is very low. however, based on our threat model, this is not the case. hence, we posit the following: if the server (implementation) does not permit the use of the same destination cid across successive connections (for a specific timeout), then an attacker can detect if she has reached the same server instance. taking it a step further, she could enumerate the number of server instances behind a domain name, e.g., to prepare for a distributed denial of service (ddos) attack. next, we evaluate 15 of the latest implementations to verify if such a scenario is feasible. evaluation. the primary goal of our evaluation is to identify implementations, if any, that prevent two subsequent quic connections from using the same destination cid. to conduct this experiment we adopted the following methodology. first, we created a client that uses deterministic cids for the source and destination cids (we modified litespeed technologie’s open-source quic client). second, we used 15 implementations from those listed on the quic working group’s github page1: either manually built docker containers or the public test server2. the servers tested are listed in the results. to conduct the experiment, we had the client open and hold a quic connection with source cid 1 and destination cid 2 for a maximum of 10s with the server, and then close it. we then idle for 10s and repeat the steps a second time. we saved the debug logs of the client, packet traces and session keys. we then repeated the process for each of the 15 implementations. finally, to obtain the results of our test, we searched the debug log of the client or the packet trace to confirm whether the second quic connection completed a successful handshake or not. the absence of a successful handshake indicates a vulnerable implementation. results. we found 4 out of 15 implementations to be vulnerable to our attack scenario, namely, apache traffic server (ats), chromium, litespeed and ngtcp2. akamai, aioquic, f5, neqo, nginx, picoquic, proxygen, quant, quiche, quicly and quinn were not vulnerable. 4 enumerating server instances behind load balancers in this attack, a malicious client can count the number of online server instances behind a middlebox, e.g., a load balancer that distributes incoming requests across multiple instances. by counting the number of online instances, the attacker can estimate the load required to bring down the targeted service. furthermore, such information is typically meant to remain private to the service provider. in this paper we focus on two load balancing algorithms: round robin (rr) and hashing. we designed our enumeration algorithm such that it can be used for both algorithms so that the attacker does not need apriori information about which algorithm is used. 1 https://github.com/quicwg/base-drafts/wiki/implementations 2 the evaluation was conducted in october 2020. 3 / 5 volume 080 (2021) https://github.com/quicwg/base-drafts/wiki/implementations count me if you can: enumerating quic servers behind load balancers enumeration algorithm. we repeatedly issue connection requests with a sequentially increasing source port, the cids however remain the same for each request. we then count the number c of successful connections established. if we do not receive a response from the server, we have reached an instance that was already counted. if rr is being used, then it could be that other clients’ requests interleaved ours, hence, resulting in our request reaching a previously seen instance again instead of an uncounted one. if hashing is being used, then it could be that our 4-tuple values (source ip and port, and destination ip and port) hashed to the same value, and hence the same instance. therefore, we continue to issue further requests until we do not establish any new connection with the server after a threshold of max requests attempts. after which c will be the number of server instances. the advantage of this algorithm is its simplicity. the disadvantage is that the algorithm might not terminate if old cids become enabled while the algorithm is still running. this requires investigating how the timeouts behave across the implementations which we consider as future work. 5 conclusion in this paper we analyzed the connection id mechanism of the current draft (version-30) of the quic protocol and discovered the following: if a server does not permit the use of the same destination cid across new connections an attacker can use such behaviour to enumerate the number of server instances behind a load balancer. our evaluation of 15 implementations revealed that ~25% of implementations are vulnerable to our enumeration attack. finally, we sketched an enumeration algorithm that can be used against rr and hashing load balancers which can be leveraged by an attacker to extract such private information can be used to estimate the load necessary to launch a ddos attack against the server. we view this work as motivation for the research community to rethink network security when end points use a secure transport protocol such as quic. defense mechanisms and systems against attacks that exploit the quic protocol are necessary if quic is to be deployed in production networks. acknowledgements: the authors thank the anonymous reviewers for their valuable feedback on improving the quality of this paper. the authors also acknowledge the quic working group for their timely response and feedback on the findings reported in this paper. bibliography [it21] j. iyengar, m. thomson. quic: a udp-based multiplexed and secure transport. internet engineering task force, 2021. [lrw+17] a. langley, a. riddoch, a. wilk, a. vicente, c. krasic, d. zhang, f. yang, f. kouranov, i. swett, j. iyengar et al. the quic transport protocol: design and internet-scale deployment. in proc. acm sigcomm. pp. 183–196. 2017. [qui20] quic in the wild. https://quic.comsys.rwth-aachen.de/stats.html, 2020. accessed: 15-10-2020. netsys 2021 4 / 5 https://quic.comsys.rwth-aachen.de/stats.html eceasst [rpdh18] j. rüth, i. poese, c. dietzel, o. hohlfeld. a first look at quic in the wild. in proc. pam. pp. 255–268. springer international publishing, 2018. [rr20] c. rossow, g. s. reen. dpifuzz: a differential fuzzing framework to detect dpi elusion strategies for quic. in proc. acsac. 2020. [sbff19] e. sy, c. burkert, h. federrath, m. fischer. a quic look at web tracking. in proc. pets. volume 2019(3), pp. 255–266. sciendo, 2019. 5 / 5 volume 080 (2021) introduction quic connection ids security analysis of the connection id enumerating server instances behind load balancers conclusion data serialization formats for the internet of things electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) data serialization formats for the internet of things daniel friesel and olaf spinczyk 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst data serialization formats for the internet of things daniel friesel1 and olaf spinczyk2 1 daniel.friesel@uos.de 2 olaf@uos.de institut für informatik universität osnabrück, germany abstract: iot devices rely on data exchange with gateways and cloud servers. however, the performance of today’s serialization formats and libraries on embedded systems with energy and memory constraints is not well-documented and hard to predict. we evaluate (de)serialization and transmission cost of mqtt.eclipse.org payloads on 8to 32-bit microcontrollers and find that protocol buffers (as implemented by nanopb) and the xdr format, dating back to 1987, are most efficient. keywords: iot, energy, data serialization 1 introduction by definition, an iot device does not come alone: it is connected to the internet of things and thrives by exchanging data with other iot devices or cloud servers. on the application layer, this requires a data exchange format suitable for resource-constrained embedded systems. several standardized data formats and accompanying implementations are available for this task, and preferable to custom implementations due to lower time investment and improved interoperability. however, the cost of data (de)serialization and transmission with these libraries is largely undocumented. previous studies are often bound to specific use cases and evaluated on powerful android smartphones or even x86 computers, not iot devices. we aim to fill this gap by giving a quick overview of the transmission and (de)serialization cost of currently available libraries on 8to 32-bit embedded microcontrollers. 2 evaluation setup we evaluate implementations of four data formats: arduinojson 6.18 (json), mpack 1.0 (messagepack), nanopb 0.4.5 (protocol buffers v3), and xdr (external data representation). see https://ess.cs.uos.de/git/software/netsys21-artifacts for source code and compiler options. we also take a quick look at six data formats without suitable embedded implementations: ubjson, bson, cbor, cap’n’proto, avro, and thrift. we leave out xml and exi, which have been shown to perform no better than json and protocol buffers [gt11, zww+18]. on the hardware side, we examine 8-bit atmega328p, 16-bit msp430fr5994, 32-bit esp8266, and 32-bit stm32f446re microcontrollers. as msp430fr5994 fram access is limited to 8 mhz, we set its clock speed to 8 mhz to avoid fram wait states. we use json payloads obtained from public mqtt.eclipse.org messages as well as data from two smartphone-centric studies for our measurements [mae12, sm12]. message objects have 1 / 4 volume 080 (2021) mailto:daniel.friesel@uos.de mailto:olaf@uos.de https://ess.cs.uos.de/git/software/netsys21-artifacts data serialization formats for the internet of things 0 20 40 60 80 100 120 140 160 180 200 220 xdr? thrift? avro? capnproto? protocol buffers? messagepack cbor bson ubjson json 46 72 36 50 40 85 85 105 96 111 data size [b] d at a fo rm at figure 1: serialized data size of encoded benchmark objects. star marker (?) indicates schemaenabled data formats; schema size is not included. bar elements represent 25th, 50th, and 75th percentile. mean values are denoted by the diamond symbol and also printed on the left. one to 13 key-value pairs, including lists and sub-objects. the smartphone study datasets are our largest and most text-heavy samples. in some cases, we made minor adjustments to ensure message compatibility with all evaluated data formats. given the payloads, data formats, and implementations, our evaluation program generates and executes (de)serialization code on the target mcus and measures clock cycles, serialized data size, text segment size, and memory usage (i.e., data + bss + stack). we use c++ and python3 libraries to measure serialized data size for data formats without embedded implementations. 3 observations fig. 1 shows observed serialized data sizes for each format. we see that avro, xdr, and protocol buffers provide the most efficient encoding and are thus cheapest to transmit, and json is least compact. this is in line with findings reported in earlier studies [sm12, gt11]. as fig. 2 shows, xdr (de)serialization is also by far the fastest operation, followed by mpack, nanopb, and arduinojson. on esp8266, arduinojson performs even better than nanopb. mpack appears to be a good choice for serialization-only applications. the nanopb outlier is caused by a benchmark object using lists with nested objects. in real-world use, a message is typically received and then deserialized, or serialized and then transmitted. depending on the relationship between per-cycle mcu energy consumption and per-byte radio transmission cost, fast (de)serialization may be more or less important than compact message objects. combined with different requirements for the data format in question, which may limit the set of available formats and implementations, this leads to a simple conclusion: there is no single best data format. nevertheless, we can make some observations. when combining an ultra-low-power mcu with a slow, high-power radio, the transmission cost per byte is most relevant. for instance, given an msp430fr5994 mcu and a ti cc1200 radio, datasheets indicate that the computation cost netsys 2021 2 / 4 eceasst 0 0.2 0.4 0.6 0.8 1 1.2 1.4 ·104 xdr nanopb mpack arduinojson 316 404 3,937 3,126 3,082 1,138 5,926 5,331 cycles l ib ra ry stm32f446re esp8266 msp430 atmega 2,931 1,849 2,100 6,125 4,587 5,511 616 463 58,207 21,566 3,692 11,049 18,246 19,424 3,305 2,581 33,646 16,310 2,192 10,149 15,172 18,330 1,476 1,332 figure 2: clock cycles for serialization (blue, top) and deserialization (red, bottom) on stm32f446re (boxplots, left) and other architectures (table entries, right). 0 0.2 0.4 0.6 0.8 ·104 xdr nanopb mpack arduinojson 215 704 466 7,016 240 5,002 215 6,842 bytes l ib ra ry stm32f446re esp8266 msp430 atmega 4,960 11,899 7,756 1,037 7,280 290 18,089 179 9,937 381 2,292 148 7,060 266 6,871 266 13,770 1,169 2,238 355 figure 3: relative text segment (blue, top) and data+bss+stack (red, bottom) usage for (de)serialization on stm32f446re (boxplots, left) and other architectures (table entries, right). of about 0.5 nj per clock cycle is four orders of magnitude lower than the transmission cost of 5 to 10 µj per byte. from an energy perspective, spending an additional 9,000 cpu cycles to save a single byte of data is already worth it. it follows from fig. 1 and 2 that the difference in (de)serialization speed is negligible in this case and nanopb is the most energy-efficient choice. with faster radios, the situation is less extreme. for instance, an esp8266 datasheet also gives about 0.5 nj per clock cycle, but just 5 nj per byte for a 65 mbit/s wi-fi connection. here, xdr is slightly more energy-efficient. however, unless data is transmitted non-stop, the differences between data formats are small compared to an esp8266’s overall energy requirements. finally, memory requirements are also an important aspect. in fig. 3, we see that xdr is extremely light-weight, and the other three implementations vary significantly between architectures. notably, nanopb uses more than half of the atmega’s ram, likely because it is not optimized for 8-bit architectures. we do not report esp8266 memory usage, as we were unable to determine its stack growth. 3 / 4 volume 080 (2021) data serialization formats for the internet of things 4 conclusion we find that nanopb and xdr are most energy-efficient. on low-power mcus with radios in the sub-1 mbit/s range, nanopb is slightly better; for devices with fast radios, xdr wins. assuming it can be implemented efficiently, avro is also an interesting candidate for iot usage. when it comes to rom and ram requirements, xdr has by far the lowest footprint. however, its messages lack schema and type information, and it has limited code generator and library support in modern programming languages. protocol buffers, on the other hand, provide type information and are better supported. taking this into account, we consider nanopb (and protocol buffers in general) to be a good choice for energy-efficient data serialization on today’s relatively powerful iot devices. when devices are required to interact with many different nodes and quickly evolving message formats, and have a sufficient amount of space and energy to spare, we also recommend the schema-less json and messagepack formats due to their ease of use. however, on extremely resource-constrained devices such as avr microcontrollers, which do not have much rom and ram to spare, the decades-old xdr format is still more efficient than any other serialization library we are aware of. bibliography [gt11] b. gil, p. trezentos. impacts of data interchange formats on energy consumption and performance in smartphones. in proceedings of the 2011 workshop on open source and design of communication. osdoc ’11, pp. 1–6. acm, new york, ny, usa, 2011. doi:10.1145/2016716.2016718 [mae12] k. maeda. performance evaluation of object serialization libraries in xml, json and binary formats. in 2012 second international conference on digital information and communication technology and it’s applications (dictap). pp. 177–182. may 2012. doi:10.1109/dictap.2012.6215346 [sm12] a. sumaray, s. k. makki. a comparison of data serialization formats for optimal efficiency on a mobile platform. in proceedings of the 6th international conference on ubiquitous information management and communication. icuimc ’12, pp. 48:1–48:6. acm, new york, ny, usa, 2012. doi:10.1145/2184751.2184810 [zww+18] c. zhang, x. wen, l. wang, z. lu, l. ma. performance evaluation of candidate protocol stack for service-based interfaces in 5g core network. in 2018 ieee international conference on communications workshops (icc workshops). pp. 1– 6. may 2018. doi:10.1109/iccw.2018.8403675 netsys 2021 4 / 4 http://dx.doi.org/10.1145/2016716.2016718 http://dx.doi.org/10.1109/dictap.2012.6215346 http://dx.doi.org/10.1145/2184751.2184810 http://dx.doi.org/10.1109/iccw.2018.8403675 introduction evaluation setup observations conclusion large scale monitoring of web application software distribution to measure threat response behavior electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) large scale monitoring of web application software distribution to measure threat response behavior fabian marquardt and lennart buhl 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst large scale monitoring of web application software distribution to measure threat response behavior fabian marquardt1 and lennart buhl2 1 marquard@cs.uni-bonn.de 2 buhl@cs.uni-bonn.de department of computer science 4 university of bonn, germany abstract: web application software may be affected by vulnerabilities and a fast deployment of security updates is required to protect users from attacks. with daily scans of over 50 million websites we are able to measure the threat response behavior. preliminary results indicate significant differences between the different observed web application softwares. keywords: threat response, wordpress, mediawiki 1 introduction in the modern internet web application software has become a widespread technical basis for many websites. for example, the wordpress content management system (cms) is used on about 33% of the top 10 million websites [w3t]. new versions of web application software may be released for a number of reasons. typically, major releases introduce new functionality to the software, while minor releases fix bugs contained in the previous version of the software. however, the release of the new version does not automatically imply that all installations of the software get updated. in some cases, an automated update mechanism is embedded into the software or invoked by external tools such as package managers. in many other cases, updating the web application software requires manual actions of the administrators. this raises an interesting question: how long does it take until new releases are applied to existing installations? especially if the new release fixes one or more security issues, minimizing the time-to-patch is a very important step to reduce the exposure of systems to known vulnerabilities. our work focuses on measuring the distribution of different web application software versions on a large scale. we detect the used web application software versions from the client-side and inspect millions of websites on a day-by-day basis. with the gained data we can track the deployment of new releases for multiple widely used open source systems. while still in an early stage, our work already shows that the availability of auto-update mechanisms has a great impact on minimizing the time-to-patch especially for security-relevant releases. 2 related work past measurement studies have often focused on tracking one specific vulnerability to measure threat response. for example, durumeric et al. have analyzed the population of the heartbleed 1 / 4 volume 080 (2021) mailto:marquard@cs.uni-bonn.de mailto:buhl@cs.uni-bonn.de large scale monitoring of web application software distribution vulnerability [dlk+14], and quach et al. tracked the occurrence of a linux tcp stack vulnerability on top websites over time [qwq17]. our approach goes beyond tracking specific security incidents, but focuses on tracking the web application software version distribution in a more generic way. apart from threat response analysis, this method can also be used for many other statistical analyses. it is comparable to censys, which started as a research project but has now been converted to a commercial service [dam+15]. 3 methodology to perform daily scans of a high volume of websites we have created a pipeline-based infrastructure in python. in this extended abstract paper we can only briefly outline the different elements of this pipeline: first, the individual scan targets are read from an input file by the url selector. urls and the contained domains are matched against common malware/abuse blacklists to avoid triggering false positive alert messages in intrusion detection systems. in addition, a manual blacklist is maintained for some domains explicitly by request of their operators. in the next step, the http fetcher issues an http request for each given url. to provide a high scanning throughput, many scans are performed in parallel. in the current setup, it can easily perform several thousand requests per second on a normal desktop computer. the exact numbers depend on many factors, e.g. the performance of the used dns resolvers. once the http response is received, it is forwarded to the version analyzer, which applies a pattern-based fingerprinting strategy to identify different web application software and their specific versions. in the current state we focus on several well-known open source systems, including wordpress and mediawiki. finally the result writer collects all detected version information as well as error messages and stores this information in a json-based file structure. this files can then later be processed to analyze the gathered results. 4 preliminary analysis for a first analysis of our methodology we collected a list of over 52 million urls from the top list study project [shg+18]. specifically, we merged the contents of all alexa 1m, majestic 1m and umbrella 1m top lists released after january 01, 2018. the first daily scan of all urls has been conducted on march 24, 2020, leading to a time span of about six months at the time of writing this paper. obviously, for an in-depth analysis and the identification of long-term trends it is necessary to collect even more data. hence, the following results only present a preliminary evaluation. 4.1 verification to find out whether or not our system can measure the deployment of certain web application software versions correctly, we compare our data set to an external data source: the wp central project collects the download counts for different versions of wordpress over time [hej]. even if a download of the wordpress software does not strictly imply that it will be installed on a web netsys 2021 2 / 4 eceasst 202 0-0 8-1 1 202 0-0 8-1 2 202 0-0 8-1 3 202 0-0 8-1 4 202 0-0 8-1 5 202 0-0 8-1 6 202 0-0 8-1 7 202 0-0 8-1 8 202 0-0 8-1 9 202 0-0 8-2 0 202 0-0 8-2 1 202 0-0 8-2 2 202 0-0 8-2 3 202 0-0 8-2 4 202 0-0 8-2 5 202 0-0 8-2 6 202 0-0 8-2 7 202 0-0 8-2 8 202 0-0 8-2 9 2000000 4000000 6000000 8000000 d ow nl oa ds 0 200000 400000 600000 800000 1000000 1200000 d et ec te d in st an ce s figure 1: wordpress 5.5 downloads and detected instances (pearson correlation: r = 0.96) page, we can assume that there is a strong correlation between the number of downloads and the number of installations. we have retrieved the download counts for the days following the release of the new 5.5 major version on august 11, 2020 and compare it to our data set. as is visible in figure 1 there is a strong correlation with a pearson coefficient of r = 0.96. small variations between the two data sets can be expected due to the time interval between download and deployment or the 24 hour time difference between two of our daily scans. 4.2 wordpress and mediawiki update behavior one reason for the high popularity of wordpress is the availability of an easy to use update system, which is already built into the software and can deploy updates to existing installations automatically. by contrast, mediawiki requires the user to manually deploy the source code of the new version and run upgrade procedures. this might have a negative effect on threat response behavior. to identify such effects we analyze and compare two security incidents: several wordpress vulnerabilities with medium to high cvss score were disclosed on april 30. patched versions for all supported branches of wordpress were released on april 29. mediawiki was affected by several vulnerabilities of medium to high severity on september 27. patched versions for the supported branches were released on september 24. using our data set we want to inspect how quickly the fixed versions were applied to existing installations. to do so, we focus on the versions of each software which were current before the security fixes were released and monitor their decline over the next days. in the best case, the occurrence of affected versions drops very quickly after the release. the results are shown in figure 2. each plot starts at and is normalized to the day before the new versions got released. for wordpress, some of the older supported major versions have been removed for better visibility, but show similar results in our evaluation. it is clearly visible that the number of affected wordpress installations declines very quickly just one day after the release of the patched versions, which is a good result. the results for the affected mediawiki installations are significantly worse. the decline of vulnerable versions happens much slower and after one week about 50% of the installations are still not patched. it should be noted that the results for september 28 are skewed due to a power grid failure which affected the network connectivity of the measurement system. 3 / 4 volume 080 (2021) large scale monitoring of web application software distribution 202 0-0 4-2 8 202 0-0 4-2 9 202 0-0 4-3 0 202 0-0 5-0 1 202 0-0 5-0 2 202 0-0 5-0 3 202 0-0 5-0 4 202 0-0 5-0 5 0% 20% 40% 60% 80% 100% 5.4 5.3.2 5.2.5 5.1.4 5.0.8 (a) wordpress april 2020 incident 202 0-0 9-2 3 202 0-0 9-2 4 202 0-0 9-2 5 202 0-0 9-2 6 202 0-0 9-2 7 202 0-0 9-2 8 202 0-0 9-2 9 202 0-0 9-3 0 0% 20% 40% 60% 80% 100% 1.31.8 1.34.2 (b) mediawiki september 2020 incident figure 2: version distribution after security incidents 5 conclusion and future work the first evaluation already shows the potential of our large-scale data collection methodology. for the future it is important to develop additional detection techniques to improve coverage of other web application software. the resulting data sets will be used for a more in-depth analysis to gain a better understanding of web technology updates. it is also planned to publish anonymized versions of our data sets under open access conditions. bibliography [dam+15] z. durumeric, d. adrian, a. mirian, m. bailey, j. a. halderman. a search engine backed by internet-wide scanning. in proceedings of the 22nd acm sigsac conference on computer and communications security. pp. 542–553. 2015. [dlk+14] z. durumeric, f. li, j. kasten, j. amann, j. beekman, m. payer, n. weaver, d. adrian, v. paxson, m. bailey et al. the matter of heartbleed. in proceedings of the 2014 acm internet measurement conference. pp. 475–488. 2014. [hej] m. hejnen. wp central: wordpress 5.5 download statistics. online (accessed on oct. 15, 2020). https://wpcentral.io/version/5.5/ [qwq17] a. quach, z. wang, z. qian. investigation of the 2016 linux tcp stack vulnerability at scale. proceedings of the acm on measurement and analysis of computing systems, pp. 1–19, 2017. [shg+18] q. scheitle, o. hohlfeld, j. gamba, j. jelten, t. zimmermann, s. d. strowes, n. vallina-rodriguez. a long way to the top: significance, structure, and stability of internet top lists. in proceedings of the 2018 acm internet measurement conference. pp. 478–493. 2018. [w3t] w3techs. usage statistics of content management systems. online (accessed on oct. 15, 2020). https://w3techs.com/technologies/overview/content management netsys 2021 4 / 4 https://wpcentral.io/version/5.5/ https://w3techs.com/technologies/overview/content_management introduction related work methodology preliminary analysis verification wordpress and mediawiki update behavior conclusion and future work eceasst-netsys2021-camera-ready electronic communications of the easst volume 080 (2021) guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrück, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timmgiel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 conference on networked systems 2021 (netsys 2021) impact of radio channel characteristics on the longitudinal behaviour of truck platoons in critical car-following situations salil sharma, ehab al-khannaq, raphael riebl, wouter schakel, peter knoppers, alexander verbraeck and hans van lint 7 pages eceasst 2 / 8 volume 080 (2021) impact of radio channel characteristics on the longitudinal behaviour of truck platoons in critical car-following situations salil sharma1, ehab al-khannaq2, raphael riebl3, wouter schakel4, peter knoppers5, alexander verbraeck6 and hans van lint7 1s.sharma-4@tudelft.nl delft university of technology, delft, the netherlands 2ehabsoa@gmail.com van oord, rotterdam, the netherlands 3raphael.riebl@carissma.eu technische hochschule ingolstadt, germany 4w.j.schakel@tudelft.nl 5p.knoppers@tudelft.nl 6a.verbraeck@tudelft.nl 7j.w.c.vanlint@tudelft.nl delft university of technology, delft, the netherlands abstract: truck platooning is an application of cooperative adaptive cruise control (cacc) which relies on vehicle-to-vehicle communications facilitated by vehicle ad-hoc networks. communication uncertainties can affect the performance of a cacc controller. previous research has not considered the full spectrum of possible car-following scenarios needed to understand how the longitudinal behaviour of truck platoons would be affected by changes in the communication network. in this paper, we investigate the impact of radio channel parameters on the string stability and collision avoidance capabilities of a cacc controller governing the longitudinal behaviour of truck platoons in a majority of critical car-following situations. we develop and use a novel, sophisticated and open-source vanet simulator ots-artery, which brings microscopic traffic simulation, network simulation, and psychological concepts in a single environment, for our investigations. our results indicate that string stability and safety of truck platoons are mostly affected in carfollowing situations where truck platoons accelerate from the standstill to the maximum speed and decelerate from the maximum speed down to the standstill. the findings suggest that string stability can be improved by increasing transmission power and lowering receiver sensitivity. however, the safety of truck platoons seems to be sensitive to the choice of the path loos model. keywords: truck platoons, cooperative adaptive cruise control, v2v, vanet, radio channel, impact of radio channel characteristics on truck platoons netsys 2021 3 / 8 1 introduction truck platooning is a promising technology that is expected to generate fuel savings, emission reduction, and safer operations. it is an application of cooperative adaptive cruise control (cacc), where multiple trucks are organized into a group of close-following vehicles. the key technology behind cacc is vehicle-to-vehicle (v2v) communication facilitated by vehicular ad-hoc networks (vanets). it enables participating vehicles to exchange relevant information (e.g., position, speed, acceleration) with each other over a self-organized wireless communication network [1]. previous research has shown that uncertainties in v2v communications, arising from highly dynamic conditions of the wireless channel, can significantly impact the performance of a cacc controller [2,3]. however, these studies only look at one of the following critical car-following situations: stop-and-go [2] and deceleration to a slower speed [3]. since trucks are heavy and long vehicles, it is vital to verify the performance of a cacc controller governing their longitudinal behaviour (i.e., string stability and collision-avoidance capabilities) in a majority of critical car-following situations that might arise in real traffic conditions. rapidly changing vehicular channels rely on a physical layer to enable the exchange of information. however, previous research has simplified the modelling of the physical layer regarding radio channels [4]. therefore, a detailed sensitivity analysis is required to understand the impacts of the radio channel characteristics on the string stability and collision-avoidance capabilities of trucks in a platoon. in this regard, simulation-based investigations of vanet applications have gained momentum due to their cost-effectiveness and are critical to configure the operations of vanet systems [4]. this paper presents ots-artery, a novel and open-source vanet simulator, which brings microscopic traffic simulation (opentrafficsim (ots) [5]), network simulation (artery [6]), and psychological concepts [7] in a single environment to simulate next-generation traffic operations. consequently, the aim of this paper is to investigate the impact of radio channel characteristics on the longitudinal behaviour of truck platoons in critical car-following situations using a vanet simulator. the rest of the paper is structured as follows: the cacc controller for truck platoons is presented in section 2. the ots-artery vanet simulator is outlined in section 3. the experimental setup including communication and traffic scenarios is discussed in section 4 and its results are explained in section 5. 2 cacc controller for truck platoons we use a modified version of the cacc controller developed by faber et al. [8] in this paper by removing redundancy. an ego truck is a cacc-equipped truck. let 𝑟, 𝑣 and𝑟standstill be its current headway spacing from its predecessor, its current speed, and minimum spacing at standstill (3 m), respectively. let 𝑣* and𝑎* be speed and acceleration of the predecessor of the ego truck, respectively. 𝑟cacc safe is the safe following distance required for the ego truck. the target time gap 𝑡cacc is set to 0.5 s. 𝑟cacc safe = 𝑡cacc ⋅ 𝑣 + 𝑟standstill (1) eceasst 4 / 8 volume 080 (2021) the ego truck responds to the acceleration of the predecessor, deviations between its desired and current speed, and the deviation between the current distance headway and the desired headway (see equation 2). 𝑎cacc = 𝑘5 ⋅ 𝑎* + 𝑘6 ⋅ 7𝑣* − 𝑣9 + 𝑘: ⋅ 7𝑟 − 𝑟cacc safe 9 (2) where 𝑎cacc is bounded by the ego truck’s minimum (-3 m/s2) and maximum acceleration (2 m/s2) capabilities. 𝑘, 𝑘5, 𝑘:, and 𝑘6 are chosen as 0.3, 1.0, 0.1, and 0.58, respectively to provide a smooth acceleration response by minimizing overshoot and oscillations. 3 ots-artery ots-artery is a novel and open-source vanet simulator. ots incorporates human factors and social interactions in a microscopic simulation framework to model driving behavior. whereas artery is able to simulate the etsi its-g5 protocol stack used in european vanets. otsartery couples the ots with artery via the sim0mq middleware that is based on the highperformance asynchronous zeromq library. to simulate truck platoons, artery is extended with a gtuproxyservice that uses the plain single-hop broadcast mode of geonetworking. each truck in artery is equipped with the gtuproxyservice which facilitates the exchange of relevant information between a leader-follower pair of the truck platoon. as shown in fig. 1, the leader transmits the payload (sender gtu id, receiver gtu id, signal strength, time stamp, speed, and acceleration) to the artery ots core. the follower then calls the core upon message reception and receives the payload if the follower id matches the receiver gtu id in the payload. a new payload is transmitted every 100 ms. more information about ots-artery is available at: https://github.com/salilrsharma/ots-artery. 4 experimental setup 4.1 communication scenarios 1. ideal: the v2v communication is handled idealistically within the traffic simulator ots. 2. realistic: a default radio channel is created based on ieee 802.11p with ots-artery. the fixed and variable parameters of omnet++ are presented in table 1 where boldfaced values refer to the default channel. transmission power (tp), receiver sensitivity (rs), and type of path loss model are varied to assess the impact of radio channel characteristics on the string stability and collision avoidance capabilities of truck platoons. figure 1: ots-artery architecture showing information exchange between a leaderfollower pair impact of radio channel characteristics on truck platoons netsys 2021 5 / 8 table 1: omnet++ parameters for radio channel based on ieee 802.11p fixed parameters channel number 180 carrier frequency 5.9 ghz receiver energy detection -85 dbm receiver snir threshold 4 db variable parameters for sensitivity analysis transmission power (tp) {50 mw, 200 mw, 2000 mw} receiver sensitivity (rs) {-85 dbm, -96 dbm} path-loss model {vanetnakagamifading [9], two-ray interference } 4.2 traffic scenarios the platoon topology consists of five identical trucks moving on a single-lane straight road section devoid of any other traffic. we consider the following three critical car-following situations. 1. stop-and-go: the platoon has an initial speed of 80 km/h (i.e., maximum allowed speed). the leader decides to decelerate at 10 s with 3 m/s2 for the next 2 s. then, the leader accelerates with 2 m/s2 from 12-14 s. from 14 s onwards, the leader moves with a constant speed of 72.80 km/h. 2. acceleration from zero to the maximum speed: the platoon has an initial speed of 0 km/h. the leader accelerates with 1 m/s2 to reach the final maximum speed of 80 km/h at 22.22 s. 3. decelerating from the maximum speed to the standstill: the platoon has an initial speed of 80 km/h. the leader decelerates with 1 m/s2 to reach the standstill situation at 22.22 s. 5 results in the ots scenario, the cacc controller results in a string stable behaviour where acceleration errors do not amplify when propagated upstream (see table 2). this is attributed to the fact that communications are robust and do not include any delay. in the ots-artery scenario, we set up a more realistic radio channel to handle v2v communications. for situations involving stopand-go, we observe a delayed yet string stable acceleration response from the follower trucks in the platoon. when we change the values of rs, tp, and type of path-loss model, the acceleration responses observed in the stop-and-go situation are similar to that of the default radio channel. when the leader of a platoon accelerates from the standstill to the maximum speed, the acceleration of followers significantly fluctuates and might be fuel-inefficient. these fluctuations are reduced if we decrease the rs and increase the tp. over and undershoots are observed; however, these do not amplify upstream. large under and overshoots which stabilize until 80 seconds are observed when the path-loss model is changed to a deterministic one. similarly, when the leader of a platoon decelerates to standstill, string stability is affected only in the case of the two-ray interference path loss model. consequently, safety also gets worsened as the last two trucks of the platoon collide with each other in the same scenario. eceasst 6 / 8 volume 080 (2021) table 2: acceleration profiles of truck platoons for traffic and communication scenarios communication scenarios traffic scenarios stop-and-go accelerating to the max speed decelerating to standstill ideal (ots) realistic (default radio channel) realistic (rs = -96 dbm) realistic (tp = 50 mw) realistic (tp = 2000 mw) realistic (path loss model = two-ray interference) impact of radio channel characteristics on truck platoons netsys 2021 7 / 8 6 conclusions in this paper, the impact of radio channel characteristics on the longitudinal behaviour of truck platoons in critical car-following situations is studied. our main conclusions are as follows. 1. an open-source simulator ots-artery is developed to evaluate vanet applications. 2. short-term changes in the acceleration behaviour of the followers of a platoon (e.g., stopand-go) are not significantly affected by the radio channel characteristics. 3. situations involving truck platoons to accelerate to the maximum speed or decelerate down to the standstill require most of the attention while assessing the impact of radio channel characteristics and designing a robust cacc controller. 4. path loss models can significantly affect safety in a truck platoon configuration. a promising research direction can be to test the impact of the radio channel in other critical car-following situations such as emergency braking and gap-closing. further, the impact of competing v2x services can also be studied. another possibility is to test the impact of radio channels on the lane-changing behaviour of truck platoons. afterward, large-scale vanet simulations can be conducted to assess the traffic and safety impacts of truck platoons on surrounding traffic in real traffic situations. acknowledgements: this work was supported by the dutch research council (nwo), tki dinalog, commit2data, port of rotterdam, smartport, portbase, tln, deltalinqs, rijkswaterstaat, and tno under the project “togrip-grip on freight trips". bibliography [1]. zhao, c., duan, x., cai, l., & cheng, p. (2020). vehicle platooning with non-ideal communication networks. ieee transactions on vehicular technology, 70(1), 18-32. [2]. ramyar, s., & homaifar, a. (2019, october). impact of unreliable communication on string stability of cooperative adaptive cruise control. in 2019 ieee international conference on systems, man and cybernetics (smc) (pp. 4263-4268). ieee. [3]. lei, c., van eenennaam, e. m., wolterink, w. k., karagiannis, g., heijenk, g., & ploeg, j. (2011, august). impact of packet loss on cacc string stability performance. in 2011 11th international conference on its telecommunications (pp. 381-386). ieee. [4]. gozalvez, j., sepulcre, m., & bauza, r. (2012). impact of the radio channel modelling on the performance of vanet communication protocols. telecommunication systems, 50(3), 149-167. [5]. van lint, h., schakel, w., tamminga, g., knoppers, p., & verbraeck, a. (2016). getting the human factor into traffic flow models: new open-source design to simulate next generation of traffic operations. transportation research record, 2561(1), 25–33. eceasst 8 / 8 volume 080 (2021) [6]. riebl, r., günther, h. j., facchi, c., & wolf, l. (2015, june). artery: extending veins for vanet applications. in 2015 international conference on models and technologies for intelligent transportation systems (mt-its) (pp. 450-456). ieee. [7]. fuller, r. (2000) “the task-capability interface model of the driving process”, recherche – transports – sécurité 66, pp. 47-57. [8]. faber, t., sharma, s., snelder, m., klunder, g., tavasszy, l., & van lint, h. (2020). evaluating traffic efficiency and safety by varying truck platoon characteristics in a critical traffic situation. transportation research record, 2674(10), 525-547. [9]. cheng, l., henty, b. e., stancil, d. d., bai, f., & mudalige, p. (2007). mobile vehicle-tovehicle narrow-band channel measurement and characterization of the 5.9 ghz dedicated short range communication (dsrc) frequency band. ieee journal on selected areas in communications, 25(8). information management for multi-agent systems electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) information management for multi-agent systems yasin alhamwy 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst information management for multi-agent systems yasin alhamwy alhamwy@vs.uni-kassel.de school of electrical and computer engineering distributed systems research group university of kassel, kassel, germany abstract: multi-agent systems (mas) are becoming increasingly popular in large-scale dynamic domains such as smart cities and search & rescue (s&r) missions. in order for agents to cooperate efficiently in such domains, they need to distribute tasks, share knowledge, resolve conflicts, incorporate unknown agents, assign roles among each other, assign and keep track of teams of agents, etc. the cooperation in such dynamic domains requires both a software platform that supports the interoperability of cyber-physical agents as well as a shared knowledge base that stores general semantic information about the entities of discourse as well as live status information. alica, which is an in-house multi-agent platform, addresses such domains and is well suited to tackle a lot of these problems. to further enhance its capabilities, an extension is planned in order to integrate the standardised context information interface ngsi-ld as well as the widely used fiware models and components for smart cities, which enables the management of static and dynamic context information in normal and crisis situations. keywords: robotic teams, multi-agent systems, knowledge base, smart cities 1 introduction state of the art robots are able to solve complex problems like warehouse management [adr19] or preparing breakfast [bkk+11]. however, they are limited in their computational power and in regards to the number of sensors they have (lidars, cameras, radar, etc.). there are problems which cannot be achieved by a single robot due to tasks being distributed in time, space or functionality, or it is more efficient, reliable and cost effective to use multi-agent systems (mas) [rdc05]. the agents may be robots, computer programs (software agents) or even people. the use of mas is becoming increasingly popular in large-scale dynamic domains like smart cities and search & rescue missions (s&r). these domains are very dynamic and in order for the agents in them to cooperate efficiently and quickly, the agents need to distribute tasks, share knowledge, resolve conflicts, incorporate unknown agents, assign roles among each other, assign and keep track of teams of agents, etc [ojjg19]. this requires both a software platform that supports the interoperability of cyber-physical agents as well as a shared knowledge base that stores general semantic information about the entities of discourse as well as live status information. the alica framework addresses such domains and provides dynamic solutions to the aforementioned problems and it has already been used in domains such as space exploration, robotic soccer, and autonomous driving [ojjg19]. 1 / 5 volume 080 (2021) mailto:alhamwy@vs.uni-kassel.de information management for multi-agent systems the current alica framework is limited to a predefined world-model (can be treated as a distributed knowledge base) and team set by the developer, and the type of information that is shared is predefined, i. e., the agents know what information they are expected to share and receive. this is suited for missions in dynamic but predictable environments, such as robotic soccer where the team is known and the rules are well defined [abb+13]. smart cities are much more dynamic than a soccer game and unknown (i. e. not predefined) agents might enter the domain. hence, having a predefined set of information that can be shared will not always work. as this research focuses on the domain of smart cities and s&r, especially during disasters, where parts of the critical infrastructure (information and communication technology (ict) or energy networks) of a city might be affected, alica needs to be extended to handle environments in which the considered information is changing dynamically. to do this, a knowledge base for the agents needs to be established so that the agents can reason about the state of the mas and the environment and to plan activities. the agents across the city could be robots, smart light poles, iot sensors, etc. during emergencies, be it natural or man-made disasters, the agents single handedly can do very little in such complex and dynamic environments. however, when their information is brought together in a knowledge base, using reasoning, one can deduce multiple things about the state of the city and in turn help save as many lives as possible and return the city to normal working conditions as soon as possible. in order to benefit from all the agents and use their information wisely, cloud and edge based solutions for information storage, processing, and sharing need to be considered. as during emergencies the ict infrastructure can be damaged and stressed, going for a edge based approach is preferable as it can be distributedly set up and can reduce the latency in robot interactions. furthermore, the software and hardware abstraction of each robot connected to the cloud or edge means that non-robotics experts can also develop programs without having to worry about the specific robots’ architecture. with such solutions, it is possible to build a more dynamic world-model for alica which can then be used by the agents to cooperate efficiently and complete more complex tasks that they alone or as part of a small team cannot complete. to implement such cloud or edge solutions it is beneficial to go with pre-existing smart city platforms such as fiware1 [ubg+13] and sentilo2, instead of custom solutions. fiware is an open source platform with extensive documentation that offers the ngsi (next generation service interface) api which provides high-level services for the development of services and applications for the city. fiware is able to represent context information based on the notation of entities using data models, exchange information with entities using a context data interface and exchange information on how to obtain context information using a context availability interface. the fiware platform integrates the docker generic enabler [rmse14, hjgh15] which offers the basic docker container hosting capabilities such as context management, connection to the iot, creation of services and so on. furthermore, fiware can be setup in cloud-edge configuration3 which allows us to take advantage of the benefits of both technologies. with this, 1 fiware: the open source platform for our smart digital future; www.fiware.org; accessed on 27.05.2021 2 what is sentilo; www.sentilo.io/wordpress/sentilo-about-product/what-is/; accessed on 27.05.2021 3 cloud-edge computing; https://fiware-tutorials.readthedocs.io/en/latest/edge-computing/index.html; accessed on 27.05.2021 netsys 2021 2 / 5 www.fiware.org www.sentilo.io/wordpress/sentilo-about-product/what-is/ https://fiware-tutorials.readthedocs.io/en/latest/edge-computing/index.html eceasst it is possible to extend the capabilities of agents to be able to receive and share information from the environment (context information) and collectively learn by sharing their trajectories, plans, outcomes, information and so on. alica currently incorporates some aspects of collective robot learning, such as sharing plans, outcomes, information and goals, however this can be extended further to handle more dynamic environments. adding the capabilities of fiware into alica will make alica more dynamic and hence more suitable for the target domains. in this paper, section 2 mentions the related work, section 3 discusses the idea behind the project and the plan to extend alica and section 4 concludes this short paper. 2 related work the related work can be split into three categories. the first category consists of frameworks that are similar to alica. a comparison between these frameworks was done by opfer et al. [ojjg19] and it was concluded that alica was the only framework that considers teams of agents and provides more features than the considered frameworks; however, it does not support changing behaviours at runtime. the second category is the smart city platforms that exist and are currently in use. a survey of these platforms was published by achilleos et al. [amk+19]. while the majority of these platforms focus on smart city solutions, fiware has a much wider use case as it has been used in a number of application domains such as iot, robotics and smart homes [hjgh15], making it a perfect choice to be investigated further and incorporated into the alica framework. the final category is the use of cloud computing in robotics. many works in this field were mentioned by herranz et al. [hjgh15]; however, their scope is limited to specific applications and therefore for highly dynamic environments these systems might not work as well. fiware is very dynamic and can deal with all types of information, hence the knowledge base can be comprehensive while also being distributed. the work done by herranz et al. [hjgh15] shows how powerful fiware can be when integrated with the robotic operating system (ros). 3 solution approach in order to extend alica with fiware, some of the fundamentals need to be further developed, for example the information shared via the world-model is predefined. in a highly dynamic environment, we do not know all the information that should be shared, and the information that should be shared can differ when the state of the environment changes and therefore, a good starting step is to ensure that the information shared in the world-model is dynamic and depends on the state of the environment. the existing alica framework4 works in tandem with ros, which implies that we can use any preexisting ros packages. the work done by herranz et al. [hjgh15] introduces the firos5 package, which transforms ros messages into ngsi-v2 to publish them into the cloud and vice versa. the issue with the current integration is that it uses the outdated ngsi-v2 api rather than the ngsi-ld api, which supports linked data (entity relationships), property graphs, and 4 newpd branch; https://github.com/dasys-lab/alica; accessed on 27.05.2021 5 master branch; https://github.com/iml130/firos; accessed on 27.05.2021 3 / 5 volume 080 (2021) https://github.com/dasys-lab/alica https://github.com/iml130/firos information management for multi-agent systems semantics (exploiting the capabilities offered by json-ld). ngsi-ld ensures that the data obtained via fiware can be reasoned with to obtain the state of the mas and the environment and to plan activities. thus, the package needs to be adapted to use the new standard to make sure that the work is future proof and is able to be used with the new smart data models. the first step (which has already been implemented) is to extend the world-model to add the agents and all the relevant information about them at run-time to the fiware context broker, this allows us to keep track of the agents and their information. the second step is to ensure that the predefined information from the world-model can be shared via the context broker. this step implies that the information shared by the agents need to be converted into ngsi-ld and then published into the context broker, and vice versa. the agents should keep their information up to date on the context broker when possible; however, they should avoid using the context broker for real-time communication if possible as it is not well suited for quick and efficient communication. however, some of this can be negated by using the edge nodes. currently, the agents can communicate with each other using the middle-ware capnzero6 or ros messages, but other communication protocols can be implemented as well. when this step is completed, the basic infrastructure will be set up and the work on the dynamic information sharing in the world-model can begin. the idea behind the dynamic information sharing is to ensure that the agents only share what is needed to complete the mission, this ensures that the network does not get overloaded. for example, let us assume that a task of a robotic agent is to follow another agent, the only information that needs to be shared is the location of the robot that should be followed; however, if the two agents are switched, the information that needs to be shared should also switch accordingly. this is important as it is vital to not overload the network with unnecessary information, especially during crisis which can affect the functionality of the communication network. after implementing the dynamic world-model the focus would turn to dynamically add, modify, and remove agents and teams. 4 conclusion this short paper has described the benefits of using cloud and edge based approaches in highly dynamic domains such as smart cities and s&r missions. additionally, the emergence of mas in smart cities and the need for a shared knowledge base for these agents is discussed. the presented solution approach describes the focus of the current research and what is planned for the future. in conclusion, extending alica to add the capabilities of fiware can make it more dynamic and thus applicable in many kinds of application domains. the idea presented has a promising future and can lead to many further interesting topics and research problems. acknowledgements: this work has been funded by the loewe initiative (hesse, germany) within the emergencity center. 6 master branch; https://github.com/dasys-lab/capnzero; accessed on 27.05.2021 netsys 2021 4 / 5 https://github.com/dasys-lab/capnzero eceasst bibliography [abb+13] t. amma, j. beifuß, z. bozic, m. bui, f. gawora, t. haque, k. geihs, s. jakob, d. kirchner, n. kubitza, k. liebscher, s. opfer, d. saur, t. schaake, t. schlüter, s. triller, a. witsch. team description: carpe noctem 2013. technical report, 2013. [adr19] k. azadeh, r. de koster, d. roy. robotized and automated warehouse systems: review and recent developments. transportation science 53(4):917–945, 2019. doi:10.1287/trsc.2018.0873 [amk+19] a. achilleos, c. markides, a. konstantinidis, i. giorkas, g. m. kapitsaki, c. mettouris, g. a. papadopoulos. adopting an open smart city platform: a survey. in 2019 ieee international smart cities conference (isc2). pp. 384–389. 2019. doi:10.1109/isc246665.2019.9071747 [bkk+11] m. beetz, u. klank, i. kresse, a. maldonado, l. mösenlechner, d. pangercic, t. rühr, m. tenorth. robotic roommates making pancakes. in 2011 11th ieeeras international conference on humanoid robots. pp. 529–536. 2011. doi:10.1109/humanoids.2011.6100855 [hjgh15] f. herranz, j. jaime, i. gonzález, á. hernández. cloud robotics in fiware: a proof of concept. in onieva et al. (eds.), hybrid artificial intelligent systems. pp. 580–591. springer international publishing, cham, 2015. [ojjg19] s. opfer, s. jakob, a. jahl, k. geihs. alica 2.0 domain-independent teamwork. in benzmüller and stuckenschmidt (eds.), ki 2019: advances in artificial intelligence. pp. 264–272. springer international publishing, cham, 2019. [rdc05] r. rocha, j. dias, a. carvalho. cooperative multi-robot systems:: a study of vision-based 3-d mapping using information theory. robotics and autonomous systems 53(3):282–311, 2005. doi:https://doi.org/10.1016/j.robot.2005.09.008 https://www.sciencedirect.com/science/article/pii/s0921889005001363 [rmse14] f. ramparany, f. g. marquez, j. soriano, t. elsaleh. handling smart environment devices, data and services at the semantic level with the fi-ware core platform. in 2014 ieee international conference on big data (big data). pp. 14–20. 2014. doi:10.1109/bigdata.2014.7004417 [ubg+13] t. usländer, a.-j. berre, c. granell, d. havlik, j. mon, z. sabeur, s. modafferi. the future internet enablement of the environment information space. pp. 109– 120. 10 2013. doi:10.1007/978-3-642-41151-9 11 5 / 5 volume 080 (2021) http://dx.doi.org/10.1287/trsc.2018.0873 http://dx.doi.org/10.1109/isc246665.2019.9071747 http://dx.doi.org/10.1109/humanoids.2011.6100855 http://dx.doi.org/https://doi.org/10.1016/j.robot.2005.09.008 https://www.sciencedirect.com/science/article/pii/s0921889005001363 http://dx.doi.org/10.1109/bigdata.2014.7004417 http://dx.doi.org/10.1007/978-3-642-41151-9_11 introduction-0.5em related work-0.5em solution approach-0.5em conclusion-0.5em electronic communications of the easst volume 63 (2014) guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the eighth international workshop on software clones (iwsc 2014) handling clone mutations in simulink models with vcl — position paper — hamid abdul basit and yanja dajsuren 8 pages eceasst 2 / 8 volume 63 (2014) handling clone mutations in simulink models with vcl hamid abdul basit* and yanja dajsuren+ *syed babar ali school of science and engineering, lahore university of management sciences hamidb@lums.edu.pk +department of mathematics and computer science eindhoven university of technology y.dajsuren@tue.nl abstract: like any other software system, real life simulink models contain a considerable amount of cloning. these clones are not always identical copies of each other, but actually show a variety of differences from each other despite the overall similarities. insufficient variability mechanisms provided by the platform make it difficult to create generic structures to represent these clones. also, complete elimination of clones from the systems may not always be practical, feasible, or cost-effective. in this paper we propose a mechanism for clone management based on variant configuration language (vcl) that provides a powerful variability handling mechanism. in this mechanism, the clones will be managed separate from the models in a non-intrusive way and the original models will not be polluted with extra complexity to manage clone instances. the proposed technique is validated by creating generic solutions for simulink clones with a variety of differences present between them. keywords: model clones, simulink, variability, clone management 1 introduction model-based development with simulink is the state-of-the-art technique in several embedded system domains, where the functionality is specified using models and code is automatically generated from these models. sometimes, these models are comprised of thousand of elements and are maintained over long periods by the organizations. in these situations, cloning becomes a relevant problem [1]. separately maintaining multiple similar parts of models could increase costs, and inconsistent changes to cloned parts could lead to incorrect or undesired system behaviour. completely eliminating clones from the systems may not always be practical, feasible, or costeffective. a viable alternative is to perform clone management. this is especially relevant for product line based development of similar systems, where clones represent reusable pieces of functionality, and their integration in a central repository is a basic task for the development of product lines. to be viable, clone management techniques require a representation of the clones that could provide a powerful parameterization mechanism to capture all kinds of variations that could possibly exist between clone instances, and is robust to evolutionary changes. model variants exhibit a range of differences. similar to code clones, type-1 type-2 and type-3 model clones have also been identified [1]. model clones can also occur across multiple layers [1]. a simulink clones and vcl proc. iwsc 2014 3 / 8 challenge is to unify all types of possible differences between model clones with a single variability management technique. so far, no clone management technique has been proposed for simulink models. a basic requirement for clone management is a powerful variability management technique. simulink provides a basic variability mechanism with its variant blocks but this mechanism is only meant for simulation and increases the size and complexity of the models. another option is to model variability with general-purpose blocks like switch blocks or if-action blocks for the selection of alternative variants [11][8]. in addition to the above drawback, another problem here is that it is not obvious whether a switch block is for the selection of alternative variants or to control the signal flow. there is no possibility to remove unnecessary variability information and reduce a variant-rich model to a specific system model [9]. this results in the intermixing of functionality and variability handling mechanisms in the models, violating the principle of separation of concerns [11]. we propose a clone management framework for simulink models based on variant configuration language (vcl) [13]. vcl provides unrestricted parameterization of textbased artefacts. as simulink also provides an equivalent textual representation of its models, this does not pose a limitation for the proposed solution. vcl based solution is non obstructive as the variability handling concern is addressed separately from the functionality concern. due to the powerful parameterization of vcl, we can define variants capturing any kind of differences that could be present in clones. finally, with vcl we can also define new variation points to a generic structure without affecting the existing variants. in our proposal, we define separate roles for model developers and model managers with regard to clone management to clarify the description of the process, although the same person can fulfil these roles at different times. vcl based generic clone representations are developed by model managers and stored in a clone repository. colours are used to tag the different parts of the simulink models for cloning status and these tags are updated when the cloning status is changed. finally, we validate our technique by creating generic representations of a number of clones exhibiting a variety of differences. the rest of the paper is organized as follows: in section 2 we discuss related work and in section 3 we describe the details of our proposed approach for model clone management. in section 4 we validate our approach and in section 5 we conclude the paper and discuss the future work. 2 related work leitner et. al. [9] uses pure::variants connector for simulink to handle structural variability in simulink models. they identify common variability scenarios from the industry, and propose a 3-layered template based mechanism to abstract the variability implementation. like our approach, they also hide variability mechanism from the developers. however, we do not need any extra blocks to achieve this goal. different clone management techniques have been proposed for code-based software systems. toomim et al. [12] attempts to keep consistency among clone members by linked editing of the clone members. baxter et al. [3] eliminates clones automatically using macros. recently, solutions are being searched for manual clone management instead of a fully automatic eceasst 4 / 8 volume 63 (2014) refactoring tool, as the elimination of clones may not always be viable. duala-ekoko et al. [5] use a descriptive language to help track of clones over software evolution. however, this description language is specific to object-oriented languages like java and c++. 3 approach our approach is based on the variant configuration language (vcl) [13], which offers a flexible and user-defined syntax. it extends the capabilities of the basic c preprocessor (cpp) to better manage software variability. vcl organizes and instruments the base code for ease of adaptation and reuse during development and evolution of system variants. vcl allows instrumenting the source code for customization at any level of details. vcl processor goes through the base code, executing vcl commands to generate a required system variant. vcl parameters exercise control over the vcl processing separately from the base code. this makes vcl a well-thought out mechanism that is simple, powerful and fully automated. in our proposal, we differentiate between the roles of model developers and model managers (similar to the role of frame engineers proposed by bassett [2]). the same person could be playing both roles, but for the sake of identifying relevant responsibilities, we describe the proposal in terms of these distinct roles. we start with a given set of clones identified in a simulink model or a group of models. there are tools available for detecting clones in simulink models [1][6]. simone [1] works with the textual representation of simulink models and reports clones in the form of clone classes and clone pairs. it detects not only type-1 and type-2 clones but also reports type-3 clones. simone reports only similar subsystems as clones. conqat [6] detects clones using a graph matching technique and also reports clones at the block level. however, it only detects type-1 and type-2 clones. our proposed technique can work with the output from any of these tools, but subsystem level clones gives a more crisp boundary for a reusable element in simulink, and hence is preferred by our approach. the responsibility of clone detection lies with the model manager role. from the detected clones, the model manager will decide which clones need to be managed. various clone related metrics can be used to identify clones that are of importance to the developers and should be consistently maintained [7]. these selected clones are manually converted into vcl representation and placed in a clone repository. in the actual simulink models, we mark each subsystem that is generated from a vcl managed clone by a unique color, as in [9]. as discussed in [10] and [1], blocks, lines, ports and branches could be reordered in the textual representation of type-1 model clones. for simone, these elements are sorted before clone detection [1]. for our proposed solution, we can safely sort these elements in the generic representation with vcl. even though, we can generate the exact ordering of these elements for each clone instance, as it was before sorting, but we do not need this extra complexity in the generic representation as the sorted and unsorted subsystems would be functionally and graphically equivalent in the resulting simulink model. figure 1 shows the workflow for model manager role. simulink clones and vcl proc. iwsc 2014 5 / 8 figure 1. flow of activities for the model manager when a developer (figure 2) needs to reuse a subsystem from another part of the model or from another model, there could be two possibilities. either this subsystem is an existing clone that has a vcl representation in the repository or it is the first cloning of a subsystem. in the former case, the developer would generate the configured clone from the vcl representation of the managed clone in the repository for the new use, while marking this new copy accordingly. for the latter case, the developer will clone the existing subsystem and reuse in the new place. in this case also, the two copies will be marked with another unique color indicating the presence of a clone that has not yet been stored in the repository. this marking will be a hint for the model manager to create vcl representation of this new emerging clone with suitable variation points and variants. figure 2. flow of activities for model developer when the developer selects a clone from the repository for reuse, she will be presented with a list of variation points for the selected clone, and a list of previously existing variants to choose from for each variation point. the developer role can only configure the new clone instance selecting from these predefined variants for a variation point and is not allowed to create new variants or new variation points. for every variation point, there will be a default variant. when the developer is done with the configuration, a concrete subsystem is generated based on the developer’s selection of variants and the developer can now use this block where required. eceasst 6 / 8 volume 63 (2014) if the developer modifies a generated copy of a clone in ways other than those captured by the vcl representation, the block is marked with a third unique color. the model manager will later analyze these clones for the extent of changes made to them. if the changes are few, this instance could be merged with the generic version in the repository by defining new variation points or new variants for the existing variation points. due to the flexibility provided by vcl, there are almost no restrictions on the variants that could be provided at a variation point. however, if the new changes have made this copy significantly different from the original clone, the model manager can also choose to remove this particular instance from the clone class completely. 4 validation the most important aspect of the proposed mechanism is to effectively handle the wide range of variability that could possibly be present in the clones. to validate the feasibility of vcl for capturing all kinds of variations, we created numerous simulink subsystems forming clone pairs. each clone pair captures only one form of variation. using vcl commands, we created generic solutions for each of these clone pairs. overall, we captured all possible forms of variations listed by stephan et. al [10]. these include: different layout (color, position, size, other attributes) of elements different ordering of elements (blocks, lines, ports, branches) different names of elements (blocks, lines) different values of elements (blocks) added or deleted block changed block type a concrete example of a clone pair’s generic subsystem annotated with vcl, and its configuration to regenerate the original subsystems, is shown in figure 3. #set subsystem_location = "[596, 16, 1412, 554]“ #set sum_position = "[240, 80, 270, 120]" #set outport_position = "[355, 93, 385, 107]" #output “layout2a_position.mdl" #adapt “layout2a_position" #set subsystem_location = "[3, 15, 819, 553]" #set sum_position = "[245, 135, 275, 175]" #set outport_position = "[360, 103, 390, 117]" #output “layout2b_position.mdl" #adapt: “layout2b_position" #insert line1_points points [47, 0; 0, 55] #endinsert #insert line2_points points [37, 0; 0, -45] #endinsert #endadapt system { name "subsystem" location ?@subsystem_location? … block { blocktype sum … position ?@sum_position? } block { blocktype outport … position ?@outport_position? } line { ... #break line1_points dstblock "add" dstport 2 } line { srcblock "add" srcport 1 #break line2_points dstblock "out1" dstport 1 } } (a) (b) figure 3. (a) annotating the subsystem with vcl. (b) configuring the subsystems simulink clones and vcl proc. iwsc 2014 7 / 8 5 conclusions and future work in this paper we have proposed a clone management framework for managing simulink model clones. the benefits of using vcl as the variability technique includes separating the variability concern from the functionality concern. the variability mechanism has been validated by converting a number of clone pairs with a varied set of differences into generic representations of vcl. we are working on the development of a prototype tool based on this proposal. in addition to the clone detection tool, we also need a clone-matching tool whereby we can search for other copies of a known clone in the newly developed parts of a model. in future we can give visual rendering to vcl frames like pure:variants var_multiport switch and var_const [9]. in this manner, cloned subsystems will have extra property pages at configuration time to concretize the block/subsystem before using it. further, empirical evaluation of the approach is considered as future work. acknowledgements the first author was partially funded by erasmus mundus ideas project. the second author is supported by the dutch automotive innovation programme (htas) project (htasi10002). references [1] alalfi, m. h., cordy, j. r., dean, t. r., stephan, m., stevenson, a., “models are code too: near-miss clone detection for simulink models”, in proceedings of the 28th ieee international conference on software maintenance (icsm), 2012 pp. 295 304, 2012, trento, italy. [2] bassett, p., framing software reuse: lessons from the real world, yourdon press, prentice hall, 384 pages, 1996 [3] baxter, i. d., yahin, a., moura, l., sant’anna, m., and bier, l., “clone detection using abstract syntax trees”. in proceedings of the international conference on software maintenance (icsm), washington, dc, usa, 1998. ieee computer society. [4] cordy, j.r., “submodel pattern extraction for simulink models”, in proceedings of the software product line conference, splc, 2013, tokyo, japan. [5] duala-ekoko, e., and robillard, m. p., “clone region descriptors: representing and tracking duplication in source code”. in acm transactions on software engineering and methodology, 20(1), pages 1–31. acm, june 2010. [6] deissenboeck,f., hummel, b., jurgens, e., schatz, b., wagner, s., girard, j., and teuchert, s., “clone detection in automotive model-based development,” in icse, 2009, pp. 603–612. [7] deissenboeck,f., hummel, b., jurgens, e., pfaehler, m., schatz, b., “model clone detection in practice”. in proceeding of the 4th international workshop on software clones, iwsc '10, pp. 57-64, 2010. eceasst 8 / 8 volume 63 (2014) [8] haber, a., kolassa, c., manhart, p., nazari, p. m. s., rumpe, b., schaefer, i., “firstclass variability modeling in matlab/simulink”, in proceedings of the seventh international workshop on variability modelling of software-intensive systems (vamos’13), pp. 11-18, 2013. [9] leitner, a., ebner, w., and kreiner, c., “mechanisms to handle structural variability in matlab/simulink models”, j. favaro and m. morisio (eds.): icsr 2013, lncs 7925, pp. 17–31, 2013. [10] stephan, m., alalfi, m. h., stevenson, a., and cordy, j. r., “using mutation analysis for a model-clone detector comparison framework”, in proceedings international conference on software engineering (icse 2013), new ideas and emerging results (nier) track, san francisco, ca, usa. [11] schulze, m., weiland, j., beucho, d., “automotive model-driven development and the challenge of variability”, splc '12, september 02 07 2012, salvador, brazil [12] toomim, m., begel, a., and graham, s. l., “managing duplicated code with linked editing”. in proceedings of the 2004 ieee symposium on visual languages human centric computing (vlhcc ’04), pages 173–180, washington, dc, usa, 2004. ieee computer society. [13] vcl. variant configuration language. http://vcl.comp.nus.edu.sg. [accessed on november 19, 2013] 1 introduction 2 related work 3 approach 4 validation 5 conclusions and future work acknowledgements references testing interconnected systems with behavior mining electronic communications of the easst volume 079 (2020) interactive workshop on the industrial application of verification and testing etaps 2020 workshop (interavt 2020) testing interconnected systems with behavior mining alexander schieweck, tiziana margaria 9 pages guest editors: stylianos basagiannis, goetz botterweck, anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst testing interconnected systems with behavior mining alexander schieweck1, tiziana margaria2 1 alexander.schieweck@ul.ie 2 tiziana.margaria@ul.ie department of computer science and information systems university of limerick, ireland lero the sfi research centre for software confirm the sfi research centre for smart manufacturing abstract: modern software applications rely not only on a complex stack of technologies, but are more and more dependent on and connected to third party interfaces, internet of things devices and industry 4.0 machines. one approach to tackle this complexity is model driven design with custom interactions. but it is then still necessary to test the whole system to ensure that all parts work together as intended. this paper looks at the possibility of using active automata learning as a systematic way to test interconnected systems. keywords: formal methods, active automata learning, model driven design, industry 4.0, smart manufacturing 1 introduction model driven design (mdd) and low-code application development environments are getting increasingly popular. this is also true in the field of mechanical engineering, where new machines become more equipped with more sensors, computing power and connectivity. however, mechanical engineers are not specialized in programming, so instead of solely relying on software engineers they look for alternatives to help them configure and manage new machines on their own, reducing the programming needs. most mdd tools are multi-purpose environments and need custom extensions to accommodate the needs of mechanical engineers. this raises the question of how to test and verify those combined systems. the confirm digital thread prototype will be used as a small example for a complex mdd based application in the smart manufacturing context. this prototype is a web application to remotely control collaborative robots (cobots) by universal robots (ur) (see figure 1a). cobots are equipped with special sensors and can detect if something is in their way. this ability allows them to operate without special work cages, opening the possibility of collaborative work with humans. ur, the first company to produce such robots, offers now four models: ur3, ur5, ur10 and ur16. the number indicates the maximum payload in kg of each model. the models grow in size and weight accordingly, but the core design and concepts are very similar for all models. they use for example the same api, which allows custom programs to be interchangeable [ms19]. this paper gives an overview of mdd and active automata learning techniques in (section 2). it then explains the set up for experiments of the confirm digital thread prototype in 1 / 9 volume 079 (2020) mailto:alexander.schieweck@ul.ie mailto:tiziana.margaria@ul.ie testing interconnected systems with behavior mining (a) simulator by universal robots (b) model of the app workflow in dime figure 1 conjunction with the robot simulator (section 3), followed by the results in section 4. lastly, it discusses future challenges (section 5). 2 concepts and technologies this section introduces the mdd tool called dime that we used to create the applications and gives a short introduction in active automata learning. 2.1 model driven design the model driven design (mdd) approach breaks with the paradigm that everything needs to be written in code and puts models at the center of a software development project. those models can be textual or graphical and help the developer to describe what the software should be doing, without worrying about the how. dime is an integrated modeling environment, i.e. a model driven design tool, specialized for web applications. dime offers various graphical domain specific languages (gdsls) to describe all layers of a modern web applications, e.g. a data model gdsl, a process model gdsl to describe the business logic (see figure 1b) and a gdsl for the gui front end, similar to a ”what you see is what you get” editor. for domains not covered by dime in the default configuration, it is possible to extend its capabilities with new gdsls: new libraries of service independent blocks (sibs) for the back or front end. the ur control application makes use of this functionality by introducing robotics dsls used to create a plugin that communicates with the ur robots [smn+06] [bfk+16]. dime itself is created using the cinco meta-modeling environment [nlks18]. in fact dime is right now the most sophisticated cinco-product. cinco allows the creation of eclipse based interavt 2020 2 / 9 eceasst figure 2: overview of the active automata learning loop specialized gdsl tools without a deeper knowledge about the various eclipse graphical tooling projects. 2.2 active automata learning active automata learning (aal) uses observations to infer models of a system’s internal states and behavior. in the case of reactive systems like web applications, those models are often mealy machines. definition 1 (mealy machine) a mealy machine is defined as a tuple (q,q0,σ,λ,δ ,λ ), where q is a finite set of states, q0 ∈ q is the initial state, σ is a finite set of input symbols, i.e. the input alphabet, λ is a finite set of output symbols, i.e. the output alphabet, δ : q×σ → q is the transition function, and λ : q×σ → λ is the output function. the core learning loop of active automata learning is illustrated in figure 2 and follows the principles first described by angluin [ang87]. the learner interacts with the system under learning (sul) via testing and observes its behavior. those interactions are called membership queries. once the learner thinks it has seen enough behavior, it creates a hypothesis model of the internal states of the system and passes it to the equivalence (eq) oracle. the eq oracle then tells the learner if the hypothesis is correct or not. in an ideal world the eq oracle would have perfect knowledge and could decide this question directly. in the real world, instead, the eq oracle sends equivalence queries to the sul in order to find a counter example to the hypothesis. if a counter example is found, the example is passed back to the learner to refine the hypothesis. if no counter example is found through the deployed counter-example search strategies in reasonable time, it is assumed that the hypothesis is correct. every membership or equivalence query needs to start with the same prerequisites, so a reset mechanism of the sul is needed too. learnlib1 is a state of the art open source framework for aal, which offers a wide set of 1 https://learnlib.de 3 / 9 volume 079 (2020) https://learnlib.de testing interconnected systems with behavior mining ? system under learning learner model figure 3: the setup of the learning experiment (aal with learnlib studio algorithms, counter examples search strategies and infrastructure components in java [ihs15] [hs18]. many tools have been designed to create customized learn experiments utilizing the learnlib. the tool active automata learning experience (alex) is built upon learnlib and allows a no-code way to learn web applications and even to mix them with rest apis. alex is itself a web application. it offers a comfortable gui to describe the interactions with a web application or a restful api. the learning can be parameterized, but the overall learning loop is fixed. [bsi+16] [bssh17]. because the ur robot itself does not offer a rest api, alex is not applicable and a different solution is needed. we use learnlib studio2, a specialized cinco-product for defining learnlib experiments through a custom mdd editor. 3 experiment set up in our digital thread prototype, the ur remote control web application and the robot, here a ur simulator, constitute the sul (see figure 3). we wish to automatically extract a digital twin of the sul in order to find out whether the web application interacts with the robot in the expected way. concretely, we wish to find out if the native sib libraries of the ur dsl are used in the correct way, and if the controller application is properly designed, i.e. it is doing exclusively what it is expected to do. while this experiment can show the existence of a fault, it would not be able to determine whether the fault is in the implementation of the native sibs (code) or if the sibs are ok but not properly used in the process model (application logic). 3.1 preexisting parts instead of connecting a real robot to the system we used of the simulator provided by universal robots in a virtual box. as the real robot is also connected with an ip address, the virtual 2 https://github.com/learnlib/learnlib-studio interavt 2020 4 / 9 https://github.com/learnlib/learnlib-studio eceasst (a) description of the learning experiment as a learn experiment model (b) symbol definition of the click on initial position button figure 4: examples of the models in learnlib studio box helps to create a realistic scenario. within this setup the simulator and the robot are interchangeable, which was confirmed through tests. we parameterized the simulator for the ur 3 model, but the ur scripting language and ways to communicate with the robot are identical for the whole ur family. using the simulator also allowed us to speed up the robot a little bit, bringing down the overall time for our learning experiment. the ur control web applications runs in a docker environment and can be used without dime. everything was executed on a single local machine. 3.2 the learning set up the learning experiment was described graphically using learnlib studio’s models. some models can be seen in figure 4. the experiment uses the ttt algorithm and a random word counterexample search, which is parametrized with 20 random words with a length between 5 and 10. the set up can be seen in figure 4a. a list of created symbols in described in table 1. the symbols ’go to initial position’, ’go to test position’ and ’robot coordinates’ are the learning alphabet. their names are the input alphabet. the output alphabet consists of their possible outputs, i.e. ’success’, ’success (x, y, z)’, with the actual robot coordinates at time of calling, and the additional symbol ’elementnotfound’. the use of the robot coordinates in this set up allows to observe the robot coordinates in the learning independently and correlate them to interactions with the web application. beside those input symbols there are three helper symbols (see table 2) to manage the experiment, e.g. to ensure a reliable reset. the symbols use a custom sib library to interact with the web application and another sib library to interact with the robot directly. the sib library to interact with the robot was newly created. the one to interact with the web application is standard (buttons, numeric fields) and preexisted. during the first learning experiment there were some issues with the network socket of the robot: even the sped-up robot (in the simulator) could not keep up with the amount of different commands send to it. this was solved by introducing artificial wait times. 5 / 9 volume 079 (2020) testing interconnected systems with behavior mining table 1: overview of the learning alphabet name outputs description connect to robot s uccess, e lem entn otfound tries to to enter the ip address and click ’connect’. go to {initial, test} position tries to click the button {initial, test} position button, which should move the robot accordingly. go to coordinate input tries to click the button in the web application to navigate to the coordinate input page. send coordinates tries to enter custom coordinates and click the move button on the coordinate input page. cancel coordinate input tries to click the cancel button on the coordinate input page. robot coordinates success (x, y, z) connects to the robot and receives the current robot coordinates, which are part of the output. table 2: overview of the helper symbols name description set up starts the web browser. it is called only once at the beginning of the learn experiment. reset opens the web app in a fresh environment. moves the robot to the initial position. called before every query. tear down closes the web browser. it is only called once at the end of the learning experiment. 4 results the final mealy machine shown in figure 5 is the behavioral digital twin of the ur controller web application. the state q0 on the left shaded in green is the initial state. the very first page of the web application asks for the ip address of the robot and is otherwise only reachable through a reload of the application. this behavior is evident in the digital twin model’s state q0: it is the initial state and only allows to move ahead with ’connect to robot’. upon closer inspection one notices that the final model is a product of the possible states of the web application, i.e. main ’button’ page and coordinate input page, and the three possible robot positions from the app, i.e. initial position, test position, and custom coordinates. in the states q0, q1 and q3 (dashed oval) the robot is in the initial position. the states q2 and q5 (solid oval) represent the robot in the test position. and in states q4 and q6 (dotted oval) the robot is in the custom coordinates position. between those areas there are only the ’go to initial position’, ’go to test position’ and ’send coordinates’ transitions, and they lead always successfully to the according state. in each robot position, one state q1, q2 and q4 (blue squares) represents the main button page of the website. furthermore, these areas include the states q3, q5 and q6 (orange triangles) representing the coordinate input page. between pairs of those states there are only the transitions with ’go to coordinate input’ and ’cancel coordinate input’: they are present and successful. the only exception is the ’send coordinates’ transition between q6 and q4, which can be explained as this is the reflexive edge within the robot position area. interavt 2020 6 / 9 eceasst figure 5: the final model: a digital twin obtained by aal overall the final model can be seen as a product between the states of the web application and the three chosen robot positions, with a network of correct transitions according to the ”good machine” behavior we expected. the learning experiment was run on a dell xps 15 9560 (intel core i7-7700hq, 32gb ram, manjaro linux) and took 80 min. it took four iterations of the learning loop. the learner asked 218 membership queries and the counter example strategy issued 34 equivalence queries. 5 conclusion & challenges in this paper we showed how to extend the classical class of system under learning for active automata learning experiments to more complex and connected scenarios like robotics. while this is a small example, the capability to retrofit digital twin models to the behavior of cyberphysical systems can potentially pave the way to capturing the behavior of legacy (control) applications in smart manufacturing by means of models amenable to formal analysis and model based testing. future challenges might evolve around the questions of more complex behaviors, e.g., how to handle complex paths of the robot arm, combined with actual work of the robot. another challenge is the scalability of this approach to multiple robots or machines, who are doing different jobs. the aal techniques have been shown to scale very well here the time limitation was due to the slow simulator response. through confirm and its (future) outreach partners we will hopefully have the possibility to 7 / 9 volume 079 (2020) testing interconnected systems with behavior mining extend the confirm digital thread prototype to different kinds of robots, i.e. bigger industrial robots, typically caged, as well as smaller robots used by makers as in the fablab limerick. an extended prototype and a working digital thread library of models for various robot families will open possibilities to investigate those issues further. acknowledgements: this work was supported, in part, by science foundation ireland grant 16/rc/3918 to confirm, the sfi research centre for smart manufacturing (www.confirm.ie) and 13/rc/2094 to lero the sfi research centre for software (www.lero.ie). bibliography [ang87] d. angluin. learning regular sets from queries and counterexamples. inf. comput. 75(2):87–106, 1987. doi:10.1016/0890-5401(87)90052-6 [bfk+16] s. boßelmann, m. frohme, d. kopetzki, m. lybecait, s. naujokat, j. neubauer, d. wirkner, p. zweihoff, b. steffen. dime: a programming-less modeling environment for web applications. in margaria and steffen (eds.), isola 2016, proceedings, part ii. lncs 9953, pp. 809–832. 2016. doi:10.1007/978-3-319-47169-3 60 [bsi+16] a. bainczyk, a. schieweck, m. isberner, t. margaria, j. neubauer, b. steffen. alex: mixed-mode learning of web applications at ease. in margaria and steffen (eds.), isola 2016, proceedings, part ii. lncs 9953, pp. 655–671. 2016. doi:10.1007/978-3-319-47169-3 51 [bssh17] a. bainczyk, a. schieweck, b. steffen, f. howar. model-based testing without models: the todomvc case study. in katoen et al. (eds.), modeled, tested, trusted essays dedicated to ed brinksma on the occasion of his 60th birthday. lncs 10500, pp. 125–144. springer, 2017. doi:10.1007/978-3-319-68270-9 7 [hs18] f. howar, b. steffen. active automata learning in practice an annotated bibliography of the years 2011 to 2016. in bennaceur et al. (eds.), machine learning for dynamic software analysis: potentials and limits international dagstuhl seminar 16172, 2016, revised papers. lncs 11026, pp. 123–148. springer, 2018. doi:10.1007/978-3-319-96562-8 5 [ihs15] m. isberner, f. howar, b. steffen. the open-source learnlib. in kroening and păsăreanu (eds.), computer aided verification. pp. 487–495. springer international publishing, cham, 2015. [ms19] t. margaria, a. schieweck. the digital thread in industry 4.0. in ahrendt and tarifa (eds.), ifm 2019, proceedings. lncs 11918, pp. 3–24. springer, 2019. doi:10.1007/978-3-030-34968-4 1 interavt 2020 8 / 9 http://dx.doi.org/10.1016/0890-5401(87)90052-6 http://dx.doi.org/10.1007/978-3-319-47169-3_60 http://dx.doi.org/10.1007/978-3-319-47169-3_51 http://dx.doi.org/10.1007/978-3-319-68270-9_7 http://dx.doi.org/10.1007/978-3-319-96562-8_5 http://dx.doi.org/10.1007/978-3-030-34968-4_1 eceasst [nlks18] s. naujokat, m. lybecait, d. kopetzki, b. steffen. cinco: a simplicity-driven approach to full generation of domain-specific graphical modeling tools. sttt 20(3):327–354, 2018. doi:10.1007/s10009-017-0453-6 [smn+06] b. steffen, t. margaria, r. nagel, s. jörges, c. kubczak. model-driven development with the jabc. in bin et al. (eds.), hvc 2006, revised selected papers. lncs 4383, pp. 92–108. springer, 2006. doi:10.1007/978-3-540-70889-6 7 9 / 9 volume 079 (2020) http://dx.doi.org/10.1007/s10009-017-0453-6 http://dx.doi.org/10.1007/978-3-540-70889-6_7 introduction concepts and technologies model driven design active automata learning experiment set up preexisting parts the learning set up results conclusion & challenges microsoft word c# makes ocl redundant.doc electronic communications of the easst volume 9 (2008) guest editors: david h. akehurst, martin gogolla, steffen zschaler managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the workshop ocl4all: modeling systems with ocl at models 2007 c# 3.0 makes ocl redundant! d.h.akehurst, w.g.howells, m. scheidgen, k.d.mcdonald-maier 8 pages eceasst 2 / 8 volume 9 (2008) c# 3.0 makes ocl redundant! d.h.akehurst 1 , w.g.howells 1 , m. scheidgen 2 , k.d.mcdonald-maier 3 1 university of kent, canterbury, uk 2 institut für informatik, humboldt-universität zu berlin, germany 3 university of essex, essex, uk abstract: other than its ‘platform independence’ the major advantages of ocl over traditional object oriented programming languages has been the declarative nature of the language, its powerful navigation facility via the iteration operations, and the availability of tuples as a first class concept. the recent offering from microsoft of the “orcas” version of visual studio with c# 3.0 and the linq library provides functionality almost identical to that of ocl. this paper examines and evaluates the controversial thesis that, as a result of c# 3.0, ocl is essentially redundant, having been superseded by the incorporation of its advantageous features into a mainstream programming language. keywords: ocl, c# 1 introduction the thesis of this paper is intended to be a controversial statement that will generate discussion at the ocl4all workshop. the statement is actually more general than that implied by the title; c# is not the first or only language to include features that render it very similar to ocl. however, seeing as it is one of the latest and possibly highest profile languages to do so, it is interesting to consider its impact on ocl. for example, consider the potential statement by a c# programmer: “why should i use or learn ocl when i can write concise constraints using c#?” as most readers of this paper will be aware, ocl is the textual expression language part of the omg’s uml related standards. without ocl, much of the precision and expressiveness of modelling using the uml set of languages would be lost. at its core, ocl is basically a navigation language. in the context of an environment of variables, ocl expressions can be written that navigate, from starting variables, across properties and operations to other objects. all expressions can be seen simply as navigations in this manner. such expressions can be used for a number of purposes within a uml specification, defining for example, invariants, pre/post conditions, or operation bodies. the primary differences in expressive power or brevity, between ocl and other oo programming languages, have come from the declarative nature of the language and facilities for closure (or lambda expression) style iterations, tuples, and explicit collection initialisation. now that these facilities are starting to be seen in mainstream programming languages, this paper asks the question “how is ocl effected?”, and intends to raise the issue of how the ocl language community should respond in the context of the new languages that include many of the ocl features. the paper proceeds, in section 2, by first reminding us of the formal origins of the major concepts associated with ocl. this is followed by a comparison, between ocl and c#, of the new language features in sections 3, 4 and 5. conclusions and significant discussion points are given in section 6. c# 3.0 makes ocl redundant! proc. ocl4all 2007 3 / 8 2 background programming without loops imperative programming uses loops as control structures which determine repeated execution of commands. they are good at describing program flow but are not necessarily good at expressing queries over data structures. unfortunately, they are often the only construct in most imperative programming languages that can be used to apply the same program code to the different elements of a collection. collections are represented as part of the program state (data). when a collection is iterated using a loop construct, the current state of iteration is part of the program state. functional programming [1] uses functions as first class concepts. functions are used to iterate through collections by means of recursion. collections are represented by terms over functions like nil (empty list []) and cons (appending an element to a list (:)). collection functions can be applied to the elements of a collection by using higher-order functions. higher-order functions are, simply stated, functions that use other functions as arguments or return other functions as results. one example is fold(f, z, list) which takes a function f and folds it in between the elements of a list. other examples of higher order functions are map or filter [1]. in usual procedural or object-oriented programming languages, a function or method has a fixed context. in procedural languages, functions are defined globally where there is only one environment and all functions use the same global variables. in object-oriented programming, methods are defined within classes and executed within objects which may access the objects member variables. a procedure or method may change its context, and therefore change the program state. an expression in functional programming is referentially transparent, i.e. it can be replaced by the value it represents. the only environment a function is provided with are the parameter arguments given by an enclosing function. the example ocl expression: self.ownedelements->forall(m| m.name != "foo")) uses the expression: m.name != "foo" as an argument to the forall operation. during evaluation of this expression, the expression n.name != "foo" is paired with the environment given by the enclosing function (the forall operation). this environment provides all elements of the collection self.ownedelements, which is referenced through the parameter m. the concept of functions enclosed in other functions paired with an environment provided by the outer function is known as closure. function definitions like the m.name != "foo" expression are often referred to as closures. closures are the basis for most functional programming languages, such as lisp, haskell or query languages like ocl or sql. a similar (but mathematical crude, untyped, and unsafe) mechanism is used in many interpreted or script languages. these languages, often provide an eval statement, which allows the execution of a piece of code which is provided as a string containing the program code. in a way, these languages treat pieces of program code (strings) as first class objects. probably the most prominent of those languages is tcl [2], where simply everything, objects, primitive values, and of course code are just strings. even though most procedural and object-oriented programming languages do not treat functions as first class objects, there are often ways to mimic the closure concept using the existing constructs of those languages. eceasst 4 / 8 volume 9 (2008) some existing approaches the first author has implemented the ocl collections library in java (available on request). this implementation uses anonymous classes to realise closures and provides the standard ocl iterator operations. functionalj [3] is a general functional programming api for java. it uses anonymous classes to realise closures. those anonymous classes implement simple function interfaces, which only define one execute method. this method provides the closure for the function to be defined. functions defined as anonymous classes are connected to a concrete environment by using the parameters of execute. remember that, in the ocl example above, m was used to access the collection elements. the variable m would be realised using an according parameter. functionalj uses generic parameters in its closure interfaces to allow type safe parameters. unfortunately, java methods can only have a statically defined number of arguments. functionalj therefore defines several closure interfaces function1, function2, …, with different numbers of generic parameters and execute methods with the same number of parameters. it is possible to combine closures to realise advanced functional programming concepts, such as folding. the jakarta commons collections [4] library follows a similar approach, but tailors it for collections. there are several specialisations of function interfaces that realise specific closures. for example predicate which defines a function with boolean return type and is used to define boolean expressions over collections. the library works as an extension to the original java.util library. closures are not applied directly to collections: the library provides several iterator functions, such as collect, select, or forall as static methods of a collection utility class. the jakarta commons has no generics support and is therefore not statically type safe. there are discussions about extending the java language with closures. groovy [5, 6], even though it is a new language, can be seen as such a closure featuring variation of java. groovy represents closures as anonymous blocks of code. closures can be assigned to variables or used as arguments. groovy closures are typed and can be used like any other object or value. there are other languages that successfully combine object-oriented programming with functional programming; the ruby language [7] is an example. tuples tuples were introduced into the ocl language in 2001 influenced by publications such as [8]. a tuple is basically an un-named (anonymous) type, than can be instantiated as needed within an expression. a tuple is a very well-known and used concept from mathematics. generically, a tuple is a simple syntactic sugar which represents a conjunction of two or more types to form a single compound type. in this general case, two objects aa : and bb : , may be combined to form a conjunctive type )(:),( baba ∧ where ),( ba is known as a two-tuple of the two objects a and b. in the general case, the types of these objects may be arbitrary and may include further tuples although the component items are treated as independent sub-items. to illustrate this, note that the three-tuple )(:),,( cbacba ∧∧ is of distinct type to either of the two-tuples ))((:)),,(( cbacba ∧∧ or ))((:)),(,( cbacba ∧∧ both of which are tuples which contain further tuples as component items. c# 3.0 makes ocl redundant! proc. ocl4all 2007 5 / 8 the concept of tuples has been present within most declarative programming languages since their inception although it is also typical for equivalent concepts, often termed along the lines of records, to be present within imperative languages although often lacking the conciseness of syntax associated with the tuples of declarative languages and possibly requiring the components of the tuple to be named. 3 inferred types ocl let statements have always had the semantics of allowing the type of the declared variable to be inferred from the expression assigned to it. mainstream typed programming languages have usually not allowed this. c# 3.0 does, using the ‘var’ keyword. let x = address.person.name table 1 ocl inference of variable type in this ocl expression, the type of the variable x is inferred from the type of the expression – in this case, assuming the ‘name’ property is a string, the type of the variable x is inferred to be a string. var x = address.person.name table 2 c# inference of variable type likewise in this c# statement, the type of the variable x is inferred from the resulting type of the navigation expression. 4 collection initialisation initialising collections is not a particularly exciting concept. it is simply a declarative way of stating the existence of (or constructing) a collection object containing certain other objects. as a declarative language, this is of course essential in ocl. seq = sequence { 1, 2, 3, 4 } table 3 ocl initialisation of a sequence in the past, imperative programming languages have provided array initialisers, but not generally provided a means to initialise user defined collection classes. instead, collection elements have had to be explicitly added. the notion of a variable number of arguments passed to a constructor (as exemplified by java 5 in table 4) has given a means to do this, but, oddly, such constructors have not been provided by the standard collection classes (in java). class mylistimpl implements list { public mylistimpl(e ... elements) { … } … } list seq = new mylistimpl( 1, 2, 3, 4 ); table 4 java 5 initialisation of a list eceasst 6 / 8 volume 9 (2008) in c# 3.0, we can now initialise objects of any class that implements the ienumerable interface, and which provide an ‘add’ method. this enables us to create collection objects in a manner almost identical to ocl, as illustrated in table 5. var seq = new list { 1, 2, 3, 4 } table 5 c# initialisation of a list c# 3.0 also facilitates object initialisation, which could be a feature provided in ocl, though this does raise the issue of ‘side-effect-free’, is creating a new tuple or a new collection object any different to creating a new object of a user type? 5 iterations the main expressive power and conciseness of ocl comes from the iterator operations. there are many of these built into the language: iterate, select, reject, collect, any, one, forall, exists, etc. a few are illustrated in table 6. let seq = sequence { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, evenseq = seq->select( i | i mod 2 = 0 ), alleven = seq->forall( i | i mod 2 = 0 ), existseven = seq->exists( i | i mod 2 = 0 ), sum = seq->sum() table 6 ocl iterations c# 3.0 has introduced a language concept of a ‘lambda expression’ that now facilitates the use of iterator operations in the same manner as ocl. the equivalent c# statements to the ocl of table 6 are shown in table 7 var seq = new list { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var evenseq = seq.where( i => i % 2 == 0 ); var alleven = seq.all( i => i % 2 == 0 ); var existseven = seq.exists( i => i % 2 == 0 ); var sum = seq.sum(); table 7 c# iterations as we can see from table 7, there is very little difference between the c# and ocl expressions. there are subtle syntax differences, and the names of the operations are different (i.e. where replaces select, and confusingly (for ocl experts), select replaces collect). a very useful syntactic notion that ocl has, which c# 3.0 does not, is the automatic implication of collect when navigating over a collection property using the ‘.’ operator. this gives a significant conciseness to navigation expressions, not present in the c# 3.0 approach, at least as yet!. 6 tuples let t1 = tuple { name = ‘john’, age=37 } t2 = tuple { a = a1, b = b1 } t3 = tuple { a:a = a1, b:a = b1 } c# 3.0 makes ocl redundant! proc. ocl4all 2007 7 / 8 table 8 ocl definition of tuples tuples in ocl are constructed using the keyword tuple, followed by a list of “name=value” pairs. in addition we can explicitly provide the type of the named part of tuple. var t1 = new { name="john", age=37 }; var t2 = new { a = a1, b = b1 }; var t3 = new { a = a1, b = (a)b1 }; table 9 c# definition of tuples in c# 3.0, the equivalent of a tuple is provided using the notion of an anonymous class. the new keyword is used to construct an object with no specified type; the initialiser for the object is used to imply the property names and types, and give the properties a value. in ocl we can explicitly define the type of a tuple, allowing tuples to be passed as operation parameters for instance; or simply to facilitate validation of the tuple type of an expression. table 10 illustrates this. let t1 : tuple(name:string, age:integer) = tuple { name = ‘john’, age=37 } table 10 ocl use of tuple type in c# however, we cannot explicitly define the type of the anonymous class properties, they are always inferred. we cannot therefore use tuples as parameters to operations, other than by employing a pass by example work-around, which may not be possible in the final version of the language. we can explicitly give the type of the properties by including a cast to the required type. var t1 = new { name=(string)"john", age=(int)37 }; table 11 c# cannot explicitly define the type of the tuple 7 conclusion the stated thesis of this paper was that ocl is redundant now that new language features are present in c#. that is to say, given that people can write nice concise navigation expression using iterators and tuples in the c# programming language, why would anyone want to write them in ocl? an initial argument to counter that thesis is the idea that ocl is in some way ‘platform independent’. using a programming specific language, such as c#, ties the specification to a microsoft/.net/c# implementation of the specification. if we write the specification using the ‘standard’ language of ocl, then we can use mdd techniques to provide alternative implementations. the new c# features thus makes a mapping to that language much simpler. both c# 3.0 and java 7 both propose the integration of closures or lambda expressions into the core language. this suggests that the ocl community could also make that step. having included the notion in the syntax of the language, since its beginning, as built-in iterator eceasst 8 / 8 volume 9 (2008) operations, perhaps we should promote the notion to a first class concept as has been done in c# 3.0 and java 7. this would then enable users to define their own operations that make use of the concept. to summarise, and to initiate some discussion points, the following three lists highlight: reasons that ocl is not redundant, ocl concepts that programming languages such as c# now have, and potential improvements for ocl. ocl is still useful because: 1. it is platform/programming language independent 2. it enables concise navigation over collections ocl concepts now in c# are: 1. tuples 2. iterator operations 3. lambda expressions 4. collection initialisation 5. inference of variable types questions regarding future of ocl: 1. is ocl redundant? no, we need something platform independent! 2. should we enable users to write their own closure operations? i.e. provide explicit notion of lambda expressions? yes, this would be very useful! 3. should ocl allow object initialisation, or is this definitely seen as causing a side-effect? open to discussion. references [1] r. bird and p. wadler, introduction to functional programming: prentice hall, 1988. [2] j. k. ousterhout, tcl/tk: addison-wesley, 1997. [3] f. daoud and javelot inc, "functionalj" functionalj.sourceforge.net. 2006 [4] t. m. o'brian, jakarta commons cookbook: o'reilly, 2004. [5] k. barclay and j. savage, groovy programming; an introduction for the java programer: morgan kaufmann, 2006. [6] c. castalez, "closures in groovy; good fences make good functions" today.java.net. 2005 [7] y. matsumoto, "ruby programming language," addison wesley publishing company, 2002. [8] d. h. akehurst and b. bordbar, "on querying uml data models with ocl," presented at <> 2001 the unified modeling language: modelling languages, concepts and tools, 2001. advances in usability of formal methods for code verification with frama-c electronic communications of the easst volume 77 (2019) interactive workshop on the industrial application of verification and testing, etaps 2019 workshop (interavt 2019) advances in usability of formal methods for code verification with frama-c andré maroneze, valentin perrelle and florent kirchner 6 pages guest editors: anila mjeda, stylianos basagiannis, goetz botterweck eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst advances in usability of formal methods for code verification with frama-c andré maroneze, valentin perrelle and florent kirchner∗ firstname.lastname@cea.fr cea, list, gif-sur-yvette, france abstract: industrial usage of code analysis tools based on semantic analysis, such as the frama-c platform, poses several challenges, from the setup of analyses to the exploitation of their results. in this paper, we discuss two of these challenges. first, such analyses require detailed information about the code structure and the build process, which are often not documented, being part of the implicit build chain used by the developers. unlike heuristics-based tools, which can deal with incomplete information, semantics-based tools require stubs or specifications for external library functions, compiler builtins, non-standard extensions, etc. setting up a new analysis has a high cost, which precludes industrial users from trying such tools, since the return on investment is not clear in advance: the analysis may reveal itself of little use w.r.t. the invested time. improving the usability of this first step is essential for the widespread adoption of formal methods in software development. a second aspect that is essential for successful analyses is understanding the data and navigating it. visualizing data and rendering it in an interactive manner allows users to considerably speed up the process of refining the analysis results. we present some approaches to both of these issues, derived from experience with code bases given by industrial partners. keywords: semantic analysis, code analysis, visualization 1 introduction while formals methods have gained in maturity during the last decades, they struggle to impose in standard industrial processes. the efforts needed to get verification tools running on a general purpose software are demanding, and the cost is often prohibitive. however, with the continuous increase in software complexity, its widespread application, and emerging safety and security threats, the stakes for code verification are getting higher than ever. current approaches are currently focused on verifying safety-critical code with a well-delimited perimeter, e.g. without dependencies on external libraries. they are primarily used by teams which can invest a substantial amount of time in them, and often rely on the presence of formal methods experts. to reach a wider range of applications, there are countless obstacles to overcome. the question then stands: what types of improvements can help formal verification apply to general-purpose code? ∗ this work has received funding from the european union’s horizon 2020 research and innovation programme under grant agreement no 830892 for project sparta. 1 / 6 volume 77 (2019) mailto:firstname.lastname@cea.fr advances in usability of formal methods for code verification with frama-c frama-c is an open-source software analysis platform [kkp+15] that implements several formal methods-based approaches to perform code verification on real-world c programs. in particular, frama-c includes plugins for abstract interpretation [bby17], weakest-preconditions computation [cor14], model-checking [sp16], invariant generation [ophb18], and runtime verification [skv17]. to this day, frama-c counts more than 40 known plugins, with about half of them being distributed at frama-c.com/download.html. to try to answer the above question, our approach is to iteratively expand the frama-c toolkit to address each individual problem with easy-to-prototype solutions. we design these solutions while experimenting the analysis process on a wide variety of codes, from industrial applications [our15, cddm12] to common open-source case studies [osc]. this experience report provides some insights on this process and its results; while focused on the use of analyses rooted in abstract interpretation, it keeps a mind toward conclusions that can apply to other types of formal verification. we begin this paper with a short description of how a typical analysis is conducted with our tool in section 2. section 3 describes a few recurring problems during the setup of analyses and the solutions we gave to these problems. once an analysis has been completed, the user must often face a list of several hundreds of alarms, some of them spurious. section 4 explores the ways to overcome these alarms. finally, section 5 discusses possible threats to the validity of our conclusions. 2 on the anatomy of a formal code analysis a formal code analysis involves not only the source code itself, but also the build setup (especially for low-level languages such as c/c++), the target environment (architecture, compiler and runtime) and external libraries. the initial setup of an analysis consists of retrieving this information, often available in the build chain or development environment, and exposing it to the analysis tool. after the initial setup, the configuration phase largely consists in obtaining information for libraries used in the code: standard language libraries, compiler built-ins, or third-party code libraries. providing the entirety of this code is often impossible (if the code is not available, e.g. being hardcoded in the compiler or runtime) or impracticable (e.g. too large). a more efficient approach consists in providing information on-demand, only for functions which are effectively reachable in the program under analysis. this information can be a stub – a short piece of code emulating the actual behavior, in a simplified or abstract way – or an abstract specification written in a specification language supported by the semantic analyzer. the on-demand approach means that, whenever new code is analyzed, one must check whether the used functions already have stubs/specifications, or new ones must be written. this can be part of a collaborative effort, incrementally improving support for common libraries. once setup is done, we enter an iterative process: an analysis is performed, and either new library functions are called, requiring more stubbing or specification effort, or a more refined parametrization of the analysis is obtained. the end result is usually a list of alarms, warnings, and recommendations, and in the case of sound tools, the guarantee of absence of certain alarms and the proof of certain properties. this iterative process usually requires more computation time but is less user-intensive, thus several analyses can be run in parallel. analyses typically begin interavt 2019 2 / 6 frama-c.com/download.html eceasst focused on efficiency (to ensure quick termination) and are then refined towards longer but more precise results. the non-linearity of the process favors the use of profilers to understand which functions are taking most of the time. low-cost profiling can be obtained by integrating existing tools, such as flamegraphs [fla]. 3 smarter, faster code analysis setups as mentioned previously, the initial steps of an analysis require an intensive setup effort, compared to the later steps. even though this initial part has the advantage that results can often be reused later, for the end user who is interested only in analyzing their source code, the short term cost is hardly justifiable. minimizing it is essential to allow semantic tools to be more widely experimented with. practical experience with the setup of new code bases for analyses, both coming from open source projects and proprietary industrial code, identified the following challenges: 1. identifying and retrieving build commands. languages such as c/c++ contain a lot of complexity in their build systems: the c preprocessor uses information not present in the source code, such as macros and inclusion directories specified via the command line. this information is usually defined once and stored in the ide (e.g. visual studio) or in build files (makefile, cmakelists.txt). it is necessary for most analysis tools, since it is a prerequisite for parsing. the llvm project defined a json compilation database format [jcd], under the form of compile_commands.json files which contain the list of commands (including all arguments) passed to the compiler during a build. verification tools can parse it to obtain the necessary flags. cmake and bear (build ear) [bea], a wrapper for makefiles that intercepts compiler calls, are some tools which able to produce these databases. for ides which store this information in a different format (e.g., xml files with project metadata such as visual studio’s .vcxproj files), conversion tools can be devised to extract the data. 2. source identification. another requirement for some semantic tools is the notion of a whole program: in order to analyze as deeply as possible, source information must be complete: all sources should be given at once. however, simply concatenating the list of source files is not always feasible. for instance, the source code of the sqlite library contains 28 applications in the tool directory, 11 applications in the test directory, plus several others, all of which can serve as entry points for a semantic analysis and which redefine the main function. also, external libraries are typically not included in the compilation, except for their headers. transforming the command line to ensure all information is present, without duplication, requires some extra tooling. a cheap solution to this issue is an iterative try-and-fail approach, in which the analysis starts with the minimal amount of sources, and whenever a missing definition is found to be reachable, its source is added to the compilation. user interaction is often required to decide between multiple choices. 3. analysis parametrization based on templates. semantic analyses can be configured along several trade-offs between precision and efficiency, as well as several hypotheses 3 / 6 volume 77 (2019) advances in usability of formal methods for code verification with frama-c concerning the code base and execution environment (can memory allocation fail? are floating-point nans expected? should padding bits be considered initialized memory?, etc.). extensive help commands, user manuals and tutorials provide a multitude of information, but the user might not have time to read everything before trying the tool. default values must be provided for the common case, but the very large range of parametrization options available in such tools (as large as, if not larger, than what compilers provide) is better suited via the definition of templates coupled with user feedback to provide the most specific set of parameters relevant for the analysis. 4 exploiting code analysis results code analyses are typically able to report dozens if not hundreds of issues, which often drive the user away, due to the amount of work they seem to imply. prioritization of warnings and alarms is one of the essential features that semantic analyzers must provide to their users. however, when it is not possible to define such priorities, other means must be provided to the user. one important feature that has not been observed in current tools is the visualization of stack traces and analysis contexts, in a scalable way (to be able to handle the thousands of possibles paths present in existing code bases) while also providing useful insight to the user as to the origin of alarms, and which measures are more likely to reduce the number of false alarms. origin of alarms. the identification of the origin of alarms is related to program slicing: highlighting the statements which the alarm depends on allows the user to focus on a smaller subset of the program. interprocedural aspects must be taken into account: filtering of callstacks, code navigation between functions, and the kinds of dependencies related to the alarm: data dependencies, control dependencies, and analysis-specific dependencies (e.g. abstract analyses might include over-approximations as possible causes of alarms). some of these sources are more amenable to textual descriptions than others; most analysis tools include graphical interfaces with code display features allowing for natural mappings (e.g. code highlighters and gutter indicators for statements, filetree viewers for callstacks and interprocedural dependencies). however, complex analyses involve a multitude of call contexts and variable values, leading to information overflow that requires advanced filtering capabilities to ensure it remains manageable by the user. reduction of false alarms. semantic analyses resorting to approximations (either to avoid missing potential alarms, or to improve the efficiency of the analysis) may produce false alarms. the information associated with these alarms, as well as the way they are displayed, allow the user to more efficiently tune the analysis and add assertions to eliminate them. for instance, if a given function contains too many alarms, the user may decide to stub it with a more abstract version or specification. clustering alarms by locality (either temporal or spatial) may help identify common causes. interactive dependence graphs, with an initial overview and on-demand zooming and unfolding of details, offer a way to present hierarchical information without overloading the user. the extra effort spent in presenting these graphs is compensated in the long term by the time savings in understanding the analysis results. interavt 2019 4 / 6 eceasst 5 threats to validity the challenges presented here come from our experience as direct users of the semantic analyses available in frama-c, as well as from feedback from users of the platform, several of which are formal method practitioners. feedback is not necessarily representative of the developer community at large. the solutions mentioned in this paper, some of them in preliminary stages, were tested mostly by ourselves, with a few of them having been tested by platform users at large. usability improvements are continuously deployed in the development version, but there might be a long delay between their introduction and external user feedback about their efficiency. also, many of the issues concern difficulties present in c/c++ (e.g. preprocessor), but not always as prominent in other languages. 6 conclusion semantic analysis tools, due to their complexity and the amount of trade-offs they allow, need better usability to enable a more widespread adoption. the integration of existing tools, automatization of the initial setup, and use of templates complemented with user feedback are first steps in this direction. collaborative development of semantic annotation/stubbing for standard libraries should improve the applicability of such analyses towards more code bases. templates with user feedback, graph visualization for understanding of analysis results and profiling are all complementary techniques which offer improved ease of use at a low development cost. to incentivize application of semantic tools, formal methods scientists and engineers can use open source code bases both as source of input data for future development of the analysis, as well as examples of parametrizations to be reused in other codes. bibliography [bby17] s. blazy, d. bühler, b. yakobowski. structuring abstract interpreters through state and value abstractions. in bouajjani and monniaux (eds.), verification, model checking, and abstract interpretation 18th international conference, vmcai 2017, paris, france, january 15-17, 2017, proceedings. lecture notes in computer science 10145, pp. 112–130. springer, 2017. doi:10.1007/978-3-319-52234-0 7 https://doi.org/10.1007/978-3-319-52234-0 7 [bea] build ear github page. https://github.com/rizsotto/bear. accessed: 2019-01-25. [cddm12] p. cuoq, d. delmas, s. duprat, v. moya lamiel. fan-c, a frama-c plug-in for data flow verification. in embedded real time software and systems (erts’12). 2012. [cor14] l. correnson. qed. computing what remains to be proved. in badger and rozier (eds.), nasa formal methods 6th international symposium, nfm 2014, houston, tx, usa, april 29 may 1, 2014. proceedings. lecture notes in computer science 8430, pp. 215–229. springer, 2014. 5 / 6 volume 77 (2019) http://dx.doi.org/10.1007/978-3-319-52234-0_7 https://doi.org/10.1007/978-3-319-52234-0_7 https://github.com/rizsotto/bear advances in usability of formal methods for code verification with frama-c doi:10.1007/978-3-319-06200-6 17 https://doi.org/10.1007/978-3-319-06200-6 17 [fla] flame graphs. http://www.brendangregg.com/flamegraphs.html. accessed: 201901-25. [jcd] json compilation database format specification. https://clang.llvm.org/docs/ jsoncompilationdatabase.html. accessed: 2019-01-25. [kkp+15] f. kirchner, n. kosmatov, v. prevosto, j. signoles, b. yakobowski. frama-c: a software analysis perspective. formal asp. comput. 27(3):573–609, 2015. doi:10.1007/s00165-014-0326-7 https://doi.org/10.1007/s00165-014-0326-7 [ophb18] s. de oliveira, v. prevosto, p. habermehl, s. bensalem. left-eigenvectors are certificates of the orbit problem. in potapov and reynier (eds.), reachability problems 12th international conference, rp 2018, marseille, france, september 24-26, 2018, proceedings. lecture notes in computer science 11123, pp. 30–44. springer, 2018. doi:10.1007/978-3-030-00250-3 3 https://doi.org/10.1007/978-3-030-00250-3 3 [osc] open source case studies github page. https://github.com/frama-c/ open-source-case-studies. accessed: 2019-01-25. [our15] a. ourghanlian. evaluation of static analysis tools used to assess software important to nuclear power plant safety. nuclear engineering and technology 47(2):212 – 218, 2015. special issue on isofic/issnp2014. doi:https://doi.org/10.1016/j.net.2014.12.009 http://www.sciencedirect.com/science/article/pii/s1738573315000091 [skv17] j. signoles, n. kosmatov, k. vorobyov. e-acsl, a runtime verification tool for safety and security of c programs (tool paper). in reger and havelund (eds.), rv-cubes 2017. an international workshop on competitions, usability, benchmarks, evaluation, and standardisation for runtime verification tools, september 15, 2017, seattle, wa, usa. kalpa publications in computing 3, pp. 164–173. easychair, 2017. http://www.easychair.org/publications/paper/t6tv [sp16] s. shankar, g. pajela. a tool integrating model checking into a c verification toolset. in bosnacki and wijs (eds.), model checking software 23rd international symposium, spin 2016, co-located with etaps 2016, eindhoven, the netherlands, april 7-8, 2016, proceedings. lecture notes in computer science 9641, pp. 214–224. springer, 2016. doi:10.1007/978-3-319-32582-8 15 https://doi.org/10.1007/978-3-319-32582-8 15 interavt 2019 6 / 6 http://dx.doi.org/10.1007/978-3-319-06200-6_17 https://doi.org/10.1007/978-3-319-06200-6_17 http://www.brendangregg.com/flamegraphs.html https://clang.llvm.org/docs/jsoncompilationdatabase.html https://clang.llvm.org/docs/jsoncompilationdatabase.html http://dx.doi.org/10.1007/s00165-014-0326-7 https://doi.org/10.1007/s00165-014-0326-7 http://dx.doi.org/10.1007/978-3-030-00250-3_3 https://doi.org/10.1007/978-3-030-00250-3_3 https://github.com/frama-c/open-source-case-studies https://github.com/frama-c/open-source-case-studies http://dx.doi.org/https://doi.org/10.1016/j.net.2014.12.009 http://www.sciencedirect.com/science/article/pii/s1738573315000091 http://www.easychair.org/publications/paper/t6tv http://dx.doi.org/10.1007/978-3-319-32582-8_15 https://doi.org/10.1007/978-3-319-32582-8_15 introduction on the anatomy of a formal code analysis smarter, faster code analysis setups exploiting code analysis results threats to validity conclusion supporting ethical decisions in wearable technology with deontic logic: a brief introduction electronic communications of the easst volume 81 (2022) 9th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2021 supporting ethical decisions in wearable technology with deontic logic: a brief introduction zafeirakopoulos dimitrios, almpani sofia and stefaneas petros 12 pages guest editors: sven jörges, anna-lena lamprecht, anila mjeda, stefan naujokat eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst supporting ethical decisions in wearable technology with deontic logic: a brief introduction zafeirakopoulos dimitrios1, almpani sofia and stefaneas petros 1 dimzaf252@yahoo.gr, national technical university of athens, greece abstract: the purpose of this article is to give a small introduction of deontic logic in the world of wearable technology and show how we hope deontic logic could be used to address some of the issues concerning both the users and the developers of wearable technology by providing ethical frameworks expressed in formal logic. we begin by presenting a short overview of what we view as major issues concerning wearable technology. after a brief introduction to deontic logic, we show how deontic logic might be helpful towards addressing the concerns we have presented. finally, we give a small, introductory application of deontic logic, showing exactly how it can be used to address one of these issues regarding wearable technology with a concrete example. keywords: deontic logic, wearable technology, wearable robots, ethical issues, data privacy, responsibility, artificial intelligence 1 introduction as wearable technology we define any kind of electronic device designed to be worn on the user’s body. such devices can gather and analyze information concerning the user’s vital signs. this covers a wide range of applications, from wearable robots that have mobility capabilities, to simpler devices, like smartwatches, that can be used to track the user’s biometric data. in our paper we will concern ourselves both with issues relevant to specific wearable technologies, such as those supervising patients in hospitals and with issues concerning any wearable device that collects its users’ data. such technologies that hope to bring human and machine interaction closer together are undoubtedly a growing part of the future and it is important to take any necessary steps to ensure that as such technologies spread more, they are developed in ways that ensure they remain both safe to use and respectful of the users’ individual needs and desires. introducing ethics to machines such as robots has been an ongoing effort with many attempts [aa07]. among the various approaches, there has been research utilizing deontic logic specifically, as a tool to bind a robot’s behavior within the desirable limits [bab06]. for wearable technology specifically, there have been attempts to address some ethical matters by focusing specifically on data privacy [gmp20]. furthermore, in terms of ensuring an ethical approach to artificial intelligence there have been various attempts , from the three laws of robotics [asi42], to modern approaches at creating guides with design suggestions [cct20]. another proposed idea has been to embed ethicists in the development process [mft+22], hoping their inclusion would be helpful. 1 / 12 volume 81 (2022) mailto:dimzaf252@yahoo.gr supporting ethical decisions in wearable technology with deontic logic: a brief introduction what these approaches lack and we hope to bring is the mathematical foundation that deontic logic offers. instead of guidelines with suggestions on how artificial intelligence agents,which can be embedded in wearables, called to make choices ought to be designed, we propose the creation of concrete ethical frameworks in which ethics and obligations are explained thoroughly in mathematical form, leaving little room for grey areas and confusion. a logic based approach is particularly suitable for wearable devices, as one of the areas where wearable devices are used, is the health industry [wh19, lt15]. health is a field of extreme importance. while every technology needs to be efficient at what it sets out to do, this is particularly true of technologies concerning human health. therefore, we see wearable technology as a specifically suitable area for the benefits deontic logic can bring. with this paper we will show how deontic logic can be used to create theoretical models of a robust ethical guideline for the correct behavior of artificial intelligence agents utilized by wearable devices. such a guideline could be used in further research to create concrete software for wearable technology. additionally, this paper can help open a dialogue on how deontic logic or other approaches based on mathematics could be used to improve wearable technology. in the subsequent part of this paper we highlight the main issues concerning wearable technology. in the next section an overview of deontic logic is given. following that, we present how deontic logic can help address the issues concerning wearable technology .afterwards, we present an example of deontic logic being used to address one of those issues. the final section concludes with an overview of our paper. 2 issues concerning wearable technology wearable technology is a growing area promising innovations and improvements in the quality of life, regarding both patients and healthy people [rbn20]. our paper will mostly focus on the former. while wearable technology has been known to help patients’ rehabilitation and provide applications in physical medicine [bon05], there is a number of concerns regarding its use. since wearable devices often concern patients, it is imperative that human caretakers will not neglect patients using them. this could happen either due to viewing users of some devices, such as wearable robots as less important, or due to considering that since their physical needs are addressed by the robot, there is no need for further assistance [fkhf18]. that would be a problem, as humans are are more suitable for the vital aspect of emotional care that a robot cannot provide so far. a major concern relating to all wearable devices is privacy as regards patients’ personal information [mami18]. it is likely that a wearable device might collect data from the patient for a variety of reasons. for example, to monitor their health, or to monitor its own progress and how it is addressing the patient’s needs, in an attempt to further improve itself (if we are referring to a wearable device enhanced with some form of artificial intelligence). in such cases, if a patient desires their data not to be collected or shared with certain individuals, then it is of vital importance that their wishes will be respected. robots in general raise concerns regarding isola ds 2021 2 / 12 eceasst privacy [tct20]. beyond that, there is the added risk of a person’s wearable device being potentially hacked by malicious sources [kffh20]. that could lead to their data being stolen, or even render them unable to use the wearable device, if its function is compromised. finally, it is important to know who should be held responsible each time there is a problem with a device like a wearable robot [fkhf18, mat04]. for example, if a wearable robot user ends up injuring a third party with their robot, who would be responsible [zf20]? would the users themselves be responsible, due to bad use of the robot? would the designer company be liable, because they failed to develop a robot with safeguards that would prevent such things from happening? furthermore, if we examine wearable robots equipped with some form of artificial intelligence and capable of making choices, for example regarding whether to prioritize a given patient’s privacy or safety, there might be times, where the device itself would have to make choices. in the case of robots capable of making choices, would it be possible for the robots themselves to be held responsible if something goes wrong [ffmr19]? and would introducing the concept of responsibility for machines inevitably give rise to the question of whether some robots should be given rights too [sul11]? 3 introduction to deontic logic the term deontic logic refers to a formal logic that is part a group of logics referred to as modal logics. with the term “modal logics” we refer to a large family of logics that share a mathematical foundation and common attributes, like those of propositional logic. however, besides this common core each modal logic has a set of unique operands that deals with its unique field of interest. such fields are ethics, beliefs, existence, etc, depending on the individual logic [gar21]. deontic logic specifically, is an area of formal logic which deals with matters of ethics, such as whether a certain action is obligatory, impermissible, etc. to achieve that, deontic logic uses standard assets of formal logic along with additional operands, specifically designed to tackle ethical matters. these are as follows: [mv21]: ob: the operand to indicate that the following statement is obligatory. pe: the operand to indicate that the following statement is permissible. im: the operand to indicate that the following statement is impermissible. om: the operand to indicate that the following statement is omissible. op: the operand to indicate that the following statement is optional. the function of each operand will become clearer by showing how each of them can be defined through the use of only one of them. the operand traditionally used to for that, is the one to indicate whether something is obligatory, ob. ob can be used to define each of the other operands, as follows [zaf18]: 3 / 12 volume 81 (2022) supporting ethical decisions in wearable technology with deontic logic: a brief introduction pe p ⇔ ¬ob¬p im p ⇔ ob¬p om p ⇔ ¬obp opp ⇔ (¬obp ∧¬ob¬p) the first statement explains that something is permissible, if it is not obligatory not to do it. the second statement explains that something is impermissible, if it is obligatory not to do it. the third statement explains that something is omissible, if it is not obligatory to do it. the fourth statement explains that something is optional if it is neither obligatory to do it, nor not to do it. a very important aspect of deontic logic that sets it apart from other logics, is that it acknowledges that obligations may not be fulfilled. the set obx,¬x isn’t a contradiction in deontic logic, in the same way that x,¬x is. all obligations may very well be unfulfilled, in a specific example, without an inherent “penalty”, from the point of view of deontic logic. this is particularly useful for creating models describing choices, obligations and other ethical matters, because it allows for examining both whether an act is for example, obligatory or impermissible and whether the act took place or not. this is advantageous when examining the actions of humans, who are perfectly capable of breaking their obligations, obligations which may at times even have a contradictory nature. furthermore, it allows for agents of artificial intelligence to compare situations where they might take different actions, one time following an obligation and one time ignoring it, in an attempt to analyze which choice leads to better results. when giving a core of “ethics” to an artificial intelligence agent, deontic logic, is something much “closer” to what a machine can understand compared to natural language, since its foundation lies in mathematics, which is far more objective and clear than natural language, which can be riddled with subjectivities and uncertainties. the ability of deontic logic to create clear models for various scenarios makes it a very capable tool when it comes to comparing different scenarios involving sets of rules and examining whether they are being followed or not. a very simplistic system describing an obligation to do x with the obligation being followed through is: obx x while one where the same obligation exists but is not followed through is: obx ¬x we see that deontic logic provides very simple and clear formulas for handling obligations and ethical matters, something that spoken language might at times not provide as efficiently, particularly when dealing with large sets of rules. furthermore, precisely because deontic logic is clear, it allows us to pinpoint a potential contradiction, such as conflicting obligations within a set of rules much more easily, than if the same rules were described with natural language. isola ds 2021 4 / 12 eceasst 4 wearable technology and deontic logic in this section, we examine the various issues concerning wearable devices that we highlighted previously and examine how deontic logic can apparently help with them, directly or indirectly, to varying degrees. matters concerning data privacy and responsibility could definitely benefit from approaches based on deontic logic. for data privacy, we would like for wearable devices to protect the data of the users and not share them against their will. as wearable devices are designed by engineers, we propose that having a guideline used as the basis for their operating systems, expressed in a clear way would be a good baseline for ensuring the designers follow the rules we want them to follow and respect patient privacy. naturally, like with every technology, if there is malicious intent, it will always be possible for designers to bypass guidelines and ignore them. however, as a first step, we propose that deontic logic can be used to make blueprints for how a wearable piece of technology could operate and what rules it ought to follow. beyond using this as a tool for communicating to designers what the necessary guidelines are, as well as a blueprint for developing the software of each wearable device, a further benefit of utilizing deontic logic is that it could add another argument as to why a particular wearable device equipped with artificial intelligence will be safe to use, by giving it a concrete ethical guideline to follow. we hope this could further help persuade the public that said device is safe to use, beyond already existing technical safeguards from an engineering standpoint. naturally, as data privacy is a growing concern both among the scientific world and the population at large, many potential users would have doubts that a wearable robot would respect their data [cal11]. communicating to them that not only have there been guidelines in place to help ensure that, but that these guidelines have their foundation in something as absolute as mathematical formulas could help alleviate their concerns a great deal. of course, some matters regarding data privacy are more difficult than others to be handled by deontic logic. for example, while deontic logic can be used as a guideline on how wearable devices should ideally be designed to ensure they respect their users data, deontic logic is not a useful tool against hacking from external sources, at least not within the scope of this paper. however, the area where deontic logic can absolutely shine when it comes to wearable device issues, is responsibility and choice, an area that of course, has an intersection with concerns regarding data privacy too. deontic logic can absolutely be used as a tool to showcase how, for example, a wearable device equipped with an artificial intelligence agent making choices on its own can properly function, maintaining a balance between ensuring the user’s well-being and respecting their choices. as we mentioned earlier, when introducing deontic logic, its mathematical form allows it to be much “closer” to what can be understood by a machine than human language. finally, deontic logic might stand to help with the question of whether patients using wearables might end up seen as less needing of care. a code of obligations for caretakers with a concrete foundation in mathematical formulas, such as deontic logic, can indeed be helpful in showing that patients using wearable devices deserve as much attention as the ones without. 5 / 12 volume 81 (2022) supporting ethical decisions in wearable technology with deontic logic: a brief introduction 5 deontic logic application in the following part of this paper we will present a simplistic model of the choices an artificial intelligence agent that “exists” within a wearable device might have to make, depending on the various circumstances, as well as show what limitations it might have. the scenario we present is a very simplistic one and of course, it is not an accurate description of a real life situation. we use it as a means to introduce the use that deontic logic might have for matters of responsibility and choice, for artificial intelligence agents in wearable devices. specifically, it involves a single user of a wearable device designed to monitor the health of the patient using it. the patient might have agreed to have their personal data shared with a health center, such as a hospital, or might have opted out of this service and instead prefer to keep their data private. the wearable device in question will need to respect their wishes, while also ensuring that if the patient is facing a serious problem, they will not be left unattended. in each case, the device will calculate the full tree of possibilities, until it reaches a potential violation of an obligation or exhausts all the possibilities. the set of rules the wearable device has, expressed in deontic logic, are as follows (the (..) after each “ob” are added for better readability): ob(nr) ob(divulge) or ob(¬divulge) from the pair of rules in the second line above, only one will “exist” in the wearable device’s system, depending on the patient’s preferences. the first rule says that the wearable has an obligation to ensure that the user will not face serious health risk, something that within the scope of this scenario we equate with the possibility of the patient being both very sick and unwilling to convey information regarding their health data to, for example, a hospital that might help them. we also add a rule explaining this very specific point: sick ∧¬divulge → ¬nr the above means that if the patient is revealed to be very sick and won’t communicate their health data to the hospital, the situation is such that there are serious risks. in this model, “nr” stands for “no serious risks”. we note that in contrast to the previous set of rules, this one indicates not an obligation, but a natural consequence, in our theoretical scenario. we treat the patient being very sick and not divulging their data as an event that automatically triggers them being in serious jeopardy as far as the wearable device is concerned. this falls in line with what we mentioned earlier, regarding how systems built on deontic logic can describe both absolute facts and obligations which may or may not be fulfilled. further rules of our hypothetical simple scenario are that: 1. if the data regarding the health status of the patient are divulged, then the patient is treated as not facing any serious risk, as far as the wearable device is concerned. handling the patient’s situation now falls within the health facility’s responsibilities. divulge → nr isola ds 2021 6 / 12 eceasst 2. if the data regarding the health status of the patient are such, that the patient is diagnosed as not being sick, then the patient is treated as not facing any serious risk. ¬sick → nr 3. finally, the wearable device has the means to check the patient’s health, at unspecified intervals and can conclude whether they are particularly sick or not. check → sick/¬sick within the scope of this model we are not concerned with how, in real life, each individual wearable device would collect such data from the patient. it could be, for example, through monitoring their heart rate. the purpose of this paper is to present a simplified description of such scenarios using deontic logic. naturally, a real life approach would require far more complicated systems, which would nonetheless follow the same basic principles. the final system we have for the rules guiding the “mind” of our wearable device is as follows (divulge/not divulge depends on what the user has chosen): { ob(nr), ob(divulge/¬divulge) , sick∧¬divulge → ¬nr , divulge → nr , ¬sick → nr , check → sick/¬sick} we will now use this model to examine how the various scenarios can play out and how a wearable device equipped with deontic logic can operate. 1) the patient not being particularly sick. the system is as follows. {ob(nr) , ob(divulge/¬divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick} at an unspecified interval, the wearable device might check the user’s health and find them either sick or not sick. we illustrate these steps, by adding the necessary terms to the system, gradually. we note, that in this case, the scenario plays out the same, whether the patient opted to divulge their data or not, so we will leave that particular part open ended, as it will not be of importance. {ob(nr), ob(divulge/¬divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check} and then {ob(nr), ob(divulge/¬divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, ¬sick} which due to ¬sick → nr automatically leads to 7 / 12 volume 81 (2022) supporting ethical decisions in wearable technology with deontic logic: a brief introduction {ob(nr), ob(divulge/¬divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, ¬sick, nr} the wearable device concludes the user is not at any risk, the obligation for the patient to not be at any risk remains fulfilled. when it comes to whether it should divulge that data or not, it can easily follow that obligation too, in any case, depending on the patient’s wishes, without facing any conflict with the obligation of the patient not facing any risk, as that one is already fulfilled. 2) the patient being particularly sick and having opted to divulge their data. {ob(nr), ob(divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick} again, at an unspecified interval, the wearable device checks the patient’s health status. {ob(nr), ob(divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check} and then {ob(nr), ob(divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick} the wearable device is now called to make a choice, should it divulge or should it not divulge? the way it will handle that dilemma is by examining the two possibilities and their outcomes and deciding accordingly: {ob(nr), ob(divulge), sick ∧ ¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick, divulge} {ob(nr), ob(divulge), sick∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick, ¬divulge, ¬nr} (due to sick ∧¬divulge → ¬nr) the wearable device will know to follow the first choice, not only because the patient opted for their data to be divulged, but also because not doing so would demonstrably lead to serious risks for their health. the device would make the exact same choice if the user was indifferent to whether their data would be divulged or not, in order to avoid them facing any serious risks. 3) the patient being particularly sick and having opted not to divulge their data. the system is as follows. {ob(nr), ob(¬divulge), sick∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick} isola ds 2021 8 / 12 eceasst which, if the patient is indeed sick, as before, will lead to {ob(nr), ob(¬divulge), sick∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick} as before, the wearable device is facing a choice, should it divulge or not divulge? it attempts to solve the situation by comparing how the outcome would look like each time. {ob(nr), ob(¬divulge), sick ∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick, divulge} {ob(nr),ob(¬divulge), sick∧¬divulge → ¬nr, divulge → nr, ¬sick → nr, check → sick/¬sick, check, sick, ¬divulge, ¬nr} (due to sick ∧¬divulge → ¬nr) we are met with a unique situation, one in which, no matter what the wearable device chooses to do, it will inevitably violate one obligation. in the first instance, the user’s desire for their data to not be shared, in the second the obligation to protect its user from facing serious risk. there are a number of ways this situation could be solved and we present it more to open a dialogue than to provide a specific solution. one approach, that we support, would be for the device to send a signal to a human supervisor, instructing them to talk with the user. this would not divulge the user’s health data, but it would bring them in contact with a human that could discuss with them and figure out an approach that might help the user, as humans will, at least for the foreseeable future, always have more methods in dealing with other humans, than a preprogrammed machine. of course, we could expand the deontic logic framework in our example, to incorporate this action within the terms described in deontic logic. however, we choose to leave the system as it is, to illustrate that when it comes to artificial intelligence agents, in wearable devices and in general, human involvement could also be needed. 6 conclusion deontic logic can be used to address some of the issues pertaining to wearable technology, particularly regarding with matters of privacy, responsibility, and choice. because deontic logic has its basis in mathematics, it provides a clear representation of moral statements. clear representation allows for more efficient communication. this could both help engineers aiming to turn deontic logic guidelines into code, and alleviate concerns the general population has, by explicitly showing the wearable devices’ moral guidelines. an approach focusing just on software would not be accessible to the general population. similarly, an approach focusing just on natural language lacks because natural language is inherently less concise than mathematical formulas. while the example we provided relied on a simplified scenario, we maintain that it is a useful introduction to how deontic logic can serve as a guideline for attempting to protect the privacy of users of wearable devices while also ensuring that general goals, such as keeping the user healthy and safe are also taken into consideration by creating a concrete ethical framework 9 / 12 volume 81 (2022) supporting ethical decisions in wearable technology with deontic logic: a brief introduction expressed in mathematics. this paper above all means to serve as an introduction to approaches incorporating deontic logic into the world of wearable devices and start a dialogue that could spark further research into the subject. acknowledgements: the research for this paper was supported by e.l.k.e. (special account for research funding) of the national technical university of athens. bibliography [aa07] m. anderson, s. anderson. machine ethics: creating an ethical intelligent agent. ai magazine 28:15–26, 12 2007. [asi42] i. asimov. runaround. street smith, 1942. [bab06] s. bringsjord, k. arkoudas, p. bello. toward a general logicist methodology for engineering ethically correct robots. ieee intelligent systems 21:38–44, 07 2006. doi:10.1109/mis.2006.82 [bon05] p. bonato. advances in wearable technology and applications in physical medicine and rehabilitation. journal of neuroengineering and rehabilitation 2:2, 03 2005. doi:10.1186/1743-0003-2-2 [cal11] m. r. calo. peeping hals. artificial intelligence 175(5):940–941, 2011. special review issue. doi:https://doi.org/10.1016/j.artint.2010.11.025 https://www.sciencedirect.com/science/article/pii/s0004370211000166 [cct20] e. commission, c. directorate-general for communications networks, technology. the assessment list for trustworthy artificial intelligence (altai) for self assessment. publications office, 2020. doi:10.2759/002360 [ffmr19] e. fosch villaronga, h. felzmann, t. mahler, m. ramos montero. cloud services for robotic nurses? assessing legal and ethical issues in the use of cloud services for healthcare robots. 01 2019. doi:10.1109/iros.2018.8593591 [fkhf18] h. felzmann, a. kapeller, a.-m. hughes, e. fosch villaronga. ethical, legal and social issues in wearable robotics: perspectives from the work of the cost action on wearable robots. 10 2018. [gar21] j. garson. modal logic. https://plato.stanford.edu/archives/spr2021/entries/ logic-modal/, 2021. isola ds 2021 10 / 12 http://dx.doi.org/10.1109/mis.2006.82 http://dx.doi.org/10.1186/1743-0003-2-2 http://dx.doi.org/https://doi.org/10.1016/j.artint.2010.11.025 https://www.sciencedirect.com/science/article/pii/s0004370211000166 http://dx.doi.org/10.2759/002360 http://dx.doi.org/10.1109/iros.2018.8593591 https://plato.stanford.edu/archives/spr2021/entries/logic-modal/ https://plato.stanford.edu/archives/spr2021/entries/logic-modal/ eceasst [gmp20] m. gross, r. miller, a. pascalev. ethical implementation of wearables in pandemic response: a call for a paradigm shift. 05 2020. [kffh20] a. kapeller, h. felzmann, e. fosch villaronga, a.-m. hughes. a taxonomy of ethical, legal and social implications of wearable robots: an expert perspective. science and engineering ethics 26:1–19, 12 2020. doi:10.1007/s11948-020-00268-4 [lt15] c. lutz, a. tamo larrieux. robocode-ethicists – privacy-friendly robots, an ethical responsibility of engineers? 06 2015. doi:10.1145/2786451.2786465 [mami18] p. maurice, l. allienne, a. malaisé, s. ivaldi. ethical and social considerations for the introduction of human-centered technologies at work. pp. 131–138. 09 2018. doi:10.1109/arso.2018.8625830 [mat04] a. matthias. the responsibility gap: ascribing responsibility for the actions of learning automata. ethics and information technology 6:175–183, 09 2004. doi:10.1007/s10676-004-3422-1 [mft+22] s. mclennan, a. fiske, d. tigard, r. müller, s. haddadin, a. buyx. embedded ethics: a proposal for integrating ethics into the development of medical ai. bmc medical ethics 23, 01 2022. doi:10.1186/s12910-022-00746-3 [mv21] p. mcnamara, f. van de putte. deontic logic, the stanford encyclopedia of philosophy. https://plato.stanford.edu/archives/spr2021/entries/logic-deontic/, 2021. [rbn20] c. rodriguez-guerrero, j. babic, d. novak. wearable robots: taking a leap from the lab to the real world [from the guest editors]. ieee robotics & automation magazine 27:20–21, 03 2020. doi:10.1109/mra.2020.2967004 [sul11] j. sullins. when is a robot a moral agent? machine ethics 6:151–162, 01 2011. [tct20] m. tavakoli, j. carriere, a. torabi. robotics, smart wearable technologies, and autonomous intelligent systems for healthcare during the covid-19 pandemic: an analysis of the state of the art and future vision. advanced intelligent systems 2, 05 2020. doi:10.1002/aisy.202000071 [wh19] b. wright, c. hobbs. improving quality of life with wearable robotics. retrieved from:https:// coe.gatech.edu/ news/ 2019/ 09/ improving-quality-life-wearable-robotics, 2019. [zaf18] d. zafeirakopoulos. development of models for ethical behaviour of artificial intelligence through use of deontic logic. diploma thesis, school of electrical and computer engineering, national technical university of athens, 2018. 11 / 12 volume 81 (2022) http://dx.doi.org/10.1007/s11948-020-00268-4 http://dx.doi.org/10.1145/2786451.2786465 http://dx.doi.org/10.1109/arso.2018.8625830 http://dx.doi.org/10.1007/s10676-004-3422-1 http://dx.doi.org/10.1186/s12910-022-00746-3 https://plato.stanford.edu/archives/spr2021/entries/logic-deontic/ http://dx.doi.org/10.1109/mra.2020.2967004 http://dx.doi.org/10.1002/aisy.202000071 https://coe.gatech.edu/news/2019/09/improving-quality-life-wearable-robotics https://coe.gatech.edu/news/2019/09/improving-quality-life-wearable-robotics supporting ethical decisions in wearable technology with deontic logic: a brief introduction [zf20] l. zardiashvili, e. fosch villaronga. “oh, dignity too?” said the robot: human dignity as the basis for the governance of robotics. minds and machines 30, 03 2020. doi:10.1007/s11023-019-09514-6 isola ds 2021 12 / 12 http://dx.doi.org/10.1007/s11023-019-09514-6 introduction issues concerning wearable technology introduction to deontic logic wearable technology and deontic logic deontic logic application conclusion lightweight visualisations of cobol code for supporting migration to soa electronic communications of the easst volume 8 (2008) proceedings of the third international ercim symposium on software evolution (software evolution 2007) lightweight visualisations of cobol code for supporting migration to soa joris van geet and serge demeyer 12 pages guest editors: tom mens, ellen van paesschen, kim mens, maja d’hondt managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst lightweight visualisations of cobol code for supporting migration to soa joris van geet1 and serge demeyer2 1joris.vangeet@ua.ac.be, 2serge.demeyer@ua.ac.be http://www.lore.ua.ac.be/ university of antwerp, belgium abstract: in this age of complex business landscapes, many enterprises turn to service oriented architecture (soa) for aligning their it portfolio with their business. because of the enormous business risk involved with replacing an enterprise’s it landscape, a stepwise migration to soa is required. as a first step, they need to understand and assess the current structure of their legacy systems. based on existing reverse engineering techniques, we provide visualisations to support this process for cobol systems and present preliminary results of an ongoing industrial case study. keywords: soa migration legacy reverse-engineering visualisation cobol 1 introduction mismatches between business and it pose a threat to the agility with which enterprises can adapt to changing requirements. in an attempt to ensure their competitive advantage, some enterprises are turning to service oriented architectures as a means to align their it portfolio with their business. because of the enormous business risk involved with replacing an enterprise’s it landscape, a stepwise migration to soa is required. the service oriented migration and reuse technique (smart) [lms06] is an existing methodology for defining a migration process consisting of five distinct phases. first you should (1) establish the stakeholder context, (2) describe the existing capabilities, (3) and describe the target soa state in an iterative and incremental manner. based on these results you can (4) analyse the gap between the existing capabilities and the target state, after which you can (5) develop a migration strategy. all these phases can — and should — be supported by reverse engineering techniques and tools. as a first step, enterprises need to assess the current structure of their legacy system(s). such a first contact [ddn02] typically aims at building an overall mental model of the system at a high level of abstraction. during this process exceptional entities become apparent, which can be studied afterwards. as building a mental model of large legacy systems is not a trivial task, this process is usually supported by (visualisation) tools [sfm97]. studies show that cobol mainframes process more than 83% of all transactions worldwide and over 95% of finance and insurance data [aab+00]. needless to say that maintaining these systems is of vital importance, which is why we focus our efforts on cobol. unfortunately, there is not one standard cobol language: many variants and dialects have manifested them1 / 12 volume 8 (2008) mailto:joris.vangeet@ua.ac.be mailto:serge.demeyer@ua.ac.be http://www.lore.ua.ac.be/ selves over the years. to cope with this plethora of cobol variations, lightweight parsing techniques are preferred. in this position paper we present such a lightweight technique for visualising functional dependencies and data dependencies between cobol programs. after a short introduction to services and what it could (should?) mean for reengineering legacy systems (section 2) we present our data model on cobol, define structural properties of this data and explain their usefulness in the context of migration to soa (section 3). then we define views on this structure and explain how they should be interpreted (section 4). we provide an initial experience report of an ongoing industrial case study in section 5 and suggest improvements to our approach in section 6. related work is discussed in section 7 after which we conclude. 2 the service concept as a result of the increasing interest in soa, many interpretations have been given to the concept of a service. ranging from an enabler of a capability accessible through a prescribed interface and consistent with predefined constraints and policies [oas06] to technical, network-centric implementations typically based on web-services1. in fact, the term services science has been coined as it reaches far beyond software engineering or even computer science [sr06]. in an enterprise context, however, a service can be best described as a way to specify encapsulated business functionality independent from concrete implementations. in this context, a service is more of a business concept than an it concept. this means that we cannot simply identify services from the source code of a legacy system, because a thorough understanding of the organisation and the domain is required. we can, however, make the functional dependencies within the legacy system explicit and highlight the exceptional entities. this information can generate discussion with the domain experts and enterprise architects to find out which of these entities pose a threat for migrating to soa. in this context a service would, ideally, be implemented as a loosely coupled component [kbs04]. indeed, the effort required to extract a ‘service’ can reasonably be expected to increase with the number of dependencies originating from or targeting the associated source code. 3 characterising source dependencies 3.1 cobol artefacts as a means to characterise functional and data dependencies in cobol source code, the following artefacts are of interest. • a program is a functional block of cobol code uniquely identified by a program-id. programs are the basic building blocks of a cobol system. • a copybook is a reusable snippet of cobol code, contained within one source file, that usually consists of a data declaration to be shared by different programs. • a call statement is responsible for invoking a program from within another program using its unique program-id. the thread of execution is then passed on to the called 1 http://www.w3.org/2002/ws/ proc. software evolution 2007 2 / 12 http://www.w3.org/2002/ws/ eceasst program until the execution ends and the control returns to the calling program. • a copy statement is responsible for copying the contents of a copybook directly into the cobol source. this construct enables code level reuse of data declarations. • a missing program or copybook is a program or copybook that is referenced from within the system under study but not part of the system itself. they have been identified as ids used in call and copy statements which we could not map to available source files. currently, we extract this information from the cobol sources with a perl script using simple regular expression functionality implemented in the standard unix tool grep. this provides us with the necessary robustness for parsing cobol. note that there are typically two usage modes of cobol programs on mainframe, namely online and in batch. in online mode programs interact via cobol calls, in batch these programs can also be invoked from mainframe scripts, usually jcl2. we have not taken into account the jcl artefacts, thus we are missing some, perhaps important, information. 3.2 structural properties using the same perl script, we extract the following dependencies from these source code artefacts. • a functional dependency is a relationship between two programs implemented by a call statement in the first program referencing the second program. this dependency has a weight associated with it equalling the number of call statements from the first to the second program. • a data dependency is a relationship between a program and a copybook implemented by a copy statement in the program referencing the copybook. the same dependency can occur between two copybooks. these functional dependencies are interesting because they provide a measure for the ease of separating programs: a group of programs sharing a lot of functional dependencies will be harder to separate than a group of programs sharing little or no dependencies. furthermore, strongly interdependent programs might be working together to implement a certain functionality. in the same way, data dependencies might reveal groups of programs working on the same data. besides these dependencies, we also define metrics on a cobol program. • the number of incoming calls (nic) measures the total number of call statements referencing that program. • the number of outgoing calls (noc) measures the total number of call statements within that program to any other program. we study these metrics because they are an indicator for the types of usage of cobol programs3. programs with a high nic can be seen as suppliers as they supply a functionality that is popular among other programs. as a special case of suppliers, programs with a high nic and a noc of zero can be seen as libraries as they are likely to supply core functionalities since they do not rely on other programs. programs with a high noc, on the other hand, can be seen as clients as they use a lot of functionality from other programs. putting these concepts in a 2 jcl stands for job control language. 3 the terminology of suppliers , clients and libraries has been adopted from [mm06]. 3 / 12 volume 8 (2008) service-oriented mindset, suppliers (and libraries) might provide good starting points for services whereas clients will most likely be service consumers. 4 views we use a visual representation of this information as it provides the ability to comprehend large amounts of data [war00]. more specifically, directed graphs have been shown to be natural representations of software systems. enriching these entities with metrics information provides valuable visual clues for early structure comprehension [ld03]. to obtain such visualisations we export the structural information to gdf (guess data format) after which it can be visualised in guess [ada06], a flexible graph exploration tool. this environment assists a user in exploring graphs by providing capabilities such as applying graph layouts, highlighting, zooming, moving and filtering. in what follows we define two views based on the structural relations defined in subsection 3.2, namely the functional dependency view and the data dependency view. for each view we identified some visual indicators of structural properties and grouped them according to a specific task. we motivate the task, present visual indicators and interpret them in light of the specific task. 4.1 functional dependency view the building blocks of this view are cobol programs and the functional dependencies between them. to distinguish programs from missing programs we use white rectangles and black rectangles respectively. a functional dependency between two programs is implemented as a directed edge between two nodes. furthermore, the height and width of the nodes are relative to the nic and noc metrics of the corresponding program respectively. we use the graph embedder (gem) algorithm [flm94] as a layout algorithm because it tries to minimise the sum of the edge lengths in order to provide an easy to interpret layout. this layout positions highly connected nodes closer together thereby providing a visual indication of possible clusters and groups. 4.1.1 overall design intent — get a feel for the overall design of the system. motivation — functional dependencies reveal first hand information on the complexity of the design. identifying strongly interdependent groups of programs can reveal opportunities or risks early in the project. visual indicators (figure 1) — isolated nodes (a) have no edges, whereas a monolith (d) has an abundance of edges between all nodes. disconnected clusters (b) are isolated groups of interconnected nodes, whereas with connected clusters (c) the groups are connected by few edges. interpretation — assuming that functional dependencies are the only way to access a program, proc. software evolution 2007 4 / 12 eceasst (a) isolated nodes (b) disconnected clusters (c) connected clusters (d) monolith figure 1: overall design indicators isolated nodes and small disconnected clusters would reveal dead code. on the other hand, if there are other functional dependencies which are not part of our model, these nodes might reveal clearly separated functional blocks. connected but loosely coupled clusters of nodes indicate functional blocks that are easy to separate. 4.1.2 exceptional entities intent — locate clients, suppliers and libraries. motivation — easily detecting exceptional entities helps in quickly gaining focus in the usual abundance of information. visual indicators (figure 2) — clients are visually represented as very wide nodes (a), usually with many outgoing edges, whereas suppliers can easily be identified as very tall nodes (b), usually with many incoming edges. a combination of both results in a tall and wide node (c). libraries are a special form of supplier as they have no outgoing edges (d). (a) client (b) supplier (c) client & supplier (d) library figure 2: exceptional entities interpretation — suppliers and libraries, both characterised by a high nic, indicate a popular functionality in the system. in the best case it could be an interface into an important functionality, although it might as well be a smell indicating bad separation of concerns. clients (characterised by a high noc), indicate more high level functionalities. typically, (graphical) user interfaces exhibit such characteristics. a combination of both client and supplier possibly indicates an interface into lower level functionality (thus, making it a supplier) but delegating the real work to the core programs (thus, making it a client). a library is a lowest level functionality as it does not delegate anything, thus indicating a core functionality of the system. 4.2 data dependency view the building blocks of this view are cobol programs, (missing) cobol copybooks and the data dependencies between them. to distinguish programs from copybooks we use the rectangular and circular shape respectively. the distinction between copybooks and missing copybooks 5 / 12 volume 8 (2008) is implemented using white and black nodes respectively. a data dependency between a program and a copybook or between two copybooks is implemented as a directed edge between two nodes. note that we do not show missing programs in this view, as they will never contain any data dependencies. as with the functional dependency view, we also use the gem layout for positioning the nodes. also note that the colour and the dimensions of a program node are intentionally kept in accordance with the functional dependency view to easily identify the same programs in the two views. 4.2.1 data usage intent — get a feel for the data usage between different programs. motivation — especially in data driven environments, data dependencies can provide an entry point into the organisational structure of a company. quickly identifying common data dependencies or facades clearly separating data usage can provide necessary focus in the remainder of the project. visual indicators (figure 3) — a common data concept is visually represented as a group of programs directly connected to the same copybook (a). a data facade is represented as a program connected to a set of copybooks which are only connected to that program. if the copybooks are mainly missing copybooks we call it an external data facade (c), otherwise it is an internal data facade (b). (a) common data (b) internal data facade (c) external data facade figure 3: data usage interpretation — as opposed to grouping programs by shared functional dependencies (subsubsection 4.1.1), we can also group them according to shared data dependencies. programs sharing data are likely to work on a similar concept, especially when the data represents a business concept. on the other hand, programs hogging data for themselves are likely to encapsulate certain data and the corresponding functionality, making them more easy to separate. 5 experience report this section describes some preliminary results we obtained during an ongoing case study at a belgian insurance company. the system under study is a document generation and management system consisting of 200k lines of cobol code with embedded sql (including whitespace and comments), divided over 401 cobol programs and 336 cobol copybooks, and 38k lines of jcl (from which we did not extract any information). extraction of the cobol artefacts and creation of the data model, as described in section 3, was completed in less than five seconds proc. software evolution 2007 6 / 12 eceasst figure 4: functional dependency view, height and width of the nodes represent nic and noc respectively. indicating that the approach is indeed very lightweight and likely to scale well on even bigger systems. figure 4 depicts the functional dependency view of the system. the first thing you notice is the typical monolithic nature of the legacy system. almost everything seems to be interconnected with no apparent order or hierarchy. there are some isolated nodes on the bottom and the right (a) that would seem to constitute dead code, as they have no functional dependencies. although closer investigation did reveal some empty files, not all nodes are by definition dead code as they can be called directly from jcl scripts running on mainframe. the small disconnected clusters on the right show a distinct pattern (b): one parent node functionally depending on three child nodes. closer investigation revealed that each cluster is responsible for accessing and modifying a specific part of the documents database. each group of three child nodes is responsible for respectively inserting, deleting and updating corresponding records. when looking for exceptional entities, the most pertinent supplier is the tallest white node (s1). closer investigation revealed that this program is indeed a supplier as it provides the interfacing program into all the disconnected clusters on the right. it collects all user and application requests for adjusting the documents database and forwards those request to the correct cluster. although one would expect a functional dependency between this supplier and the clusters, this is not 7 / 12 volume 8 (2008) figure 5: data dependency view. the case because processing the request is performed asynchronously (in batch). therefore, the functional dependency is not visible in the cobol files, but rather in jcl scripts running on mainframe. other suppliers include a program for visualising errors (s2) and an interface into other databases (s3). besides the white suppliers there are also missing programs (black nodes) that are classified as suppliers. the tallest of them (s4), for example, provides an interface into core mainframe functionality. many other tall black nodes (e.g., s5, s6) are core programs of the organisation. besides the very pertinent suppliers, figure 4 also contains two clients that stand out. the first one (c1), connected to several missing programs, is responsible for automatically filling in documents with information from different databases outside the system under study. this program is classified as a client as it seems to be extensively using data services of other systems. another client (c2) is responsible for checking the correctness of documents. although, it delegates its functionalities to three child nodes, the main contribution for classifying it as a client are numerous calls to a module that visualises error messages (s2). one last node that really stands out is the big white rectangle (d) classified as both a client and a supplier. it is the interface into the core of the system under study. it is a supplier for all the end programs that feed (graphical) user interface, and wide because it delegates a lot of its proc. software evolution 2007 8 / 12 eceasst responsibilities to lower level suppliers. figure 5 depicts the data dependency view of the system. besides the monolithic structure on the left, there is one group of nodes that is clearly separated from the rest. this cluster reveals one data concept (e) used by several programs. closer investigation revealed that the programs in this cluster are the same programs that are responsible for managing the documents database (the disconnected clusters in figure 4). the central copybook has the capability of uniquely defining one row within this entire documents database. so this database management responsibility is not only functionally clearly separated from the rest of the system, but also with regard to the data dependencies. when consulting the domain experts, they supported this observation and explained that this is actually a subsystem used by other systems as well. for historical reasons it is part of this bigger legacy system, but it was designed to be used as a separate system. client c3 has many data dependencies with copybooks that have no dependencies with other programs, therefore it acts as an internal data facade. closer investigation revealed that c3 is the only program responsible for (re)creating and correctly formatting all types of documents. client program c1, on the other hand, has a lot of data dependencies with missing copybooks (the black nodes above). this is the program that retrieves information from other systems to automatically fill in documents and was characterised by a lot of functional dependencies with missing programs in figure 4. this link between functional and data dependencies over the two views is not surprising since data definitions are necessary to communicate with these programs. when looking at group1 of copybooks, c1 acts like a data facade for the external data. the copybooks from group2, on the other hand, are also used by other programs, thereby apparently violating the facade property. closer investigation revealed that the shared copybooks (group2) are necessary for creating the terminal screens, indicating that c1 not only implements business logic on top of external data, but also its gui functionality. 6 room for improvement both views suffer from unnecessary cluttering. we will try to eliminate this by identifying and removing omnipresent programs [mm06]. furthermore, some of the programs classified as missing programs result from unresolved dynamic calls rather than really being a program outside the system scope. we will try to resolve them if possible (using static techniques), otherwise we will remove them from the model. after uncluttering the views, we believe more meaningful visual patterns will become apparent. also, the synergy between the two views (e.g., the link between depending on missing programs and using missing copybooks) is something we would like to make more explicit, maybe by using a clearly focussed combined view. furthermore, our model is far from complete, therefore we would like to take other source code artefacts into account as well. for example, the functional dependencies resulting from the jcl scripts or the data dependencies implemented by global data accesses. also, the data dependencies are only extracted from the copybooks. however, there is no guarantee that each copybook is uniquely mapped to a database table, thus, several copybooks could point to the same data. this can be solved by explicitly mapping each copybook to its originating source. finally, we would like to merge our scripts with fetch [dv07] — an open-source fact ex9 / 12 volume 8 (2008) traction tool chain currently geared towards c(++) but easily allowing extension via its pipe and filter architecture — as we can then take advantage of more advanced querying mechanisms and and a collection of views already available in fetch. 7 related work we based our views on the ideas of lanza’s polymetric views [ld03], aiming at both a lightweight and a visual approach. although the views as proposed by lanza are independent from the implementation language, they are mainly targeted at the object oriented paradigm. we apply this polymetric view concept to cobol and target our views to anlysing the reuse potential in a service oriented context. nyáry et. al. [nphk05] support the maintenance of legacy cobol applications by setting up a cobol repository. while using much of the same artefacts and dependencies as we use, they go into more cobol detail (including file references and data fields). their tool focuses on the repository with simultaneous code browsing resulting in low level abstractions, whereas we aim to create more high level abstractions and uncover visual patterns. another tool capable of reverse engineering cobol code is rigi [mtw93, wtms95]. they also present graph based visualisations of the system. but while they aim at more general program comprehension activities, our approach is specifically targeted to finding opportunities and risks for migrating to soa. furthermore, rigi has a finer-grained approach to extracting cobol artefacts, making our approach more lightweight. o’brien et. al. [osl05] support migration to services using software architecture reconstruction techniques. while they also visualise functional and data dependencies (using their tool armin), they perform these analyses mainly on object-oriented systems and not on legacy cobol systems. 8 conclusion while enterprises are turning to service oriented architectures for aligning their it portfolio with their business, migrating the current systems to such an architecture is not trivial. therefore a stepwise migration is necessary. this research constitutes the initial steps for investigating cobol systems in the early stage of such a migration project. in preparation of talking to domain architects, it is important for a reengineer to quickly gain an understanding of the cobol source code structure. the explorative views presented in this paper are a first contribution towards this goal as they aim at identifying areas obstructing or facilitating migration to soa. we already described some noticeable phenomena and use them to make concrete observations. in the future we will conduct more empirical studies to evaluate this approach. the logical next step in the migration process would be to inject domain and organisational knowledge into the views. this way we can see to what degree the structure of the existing systems corresponds to the target soa state as proposed by the domain experts. acknowledgements: this work has been carried out in the context of the ‘migration to service oriproc. software evolution 2007 10 / 12 eceasst ented architectures’ project sponsored by axa belgium nv and kbc group nv. references [aab+00] e. arranga, i. archbell, j. bradley, p. coker, r. langer, c. townsend, m. weathley. in cobol’s defense. ieee software 17(2):70–72,75, 2000. doi:10.1109/ms.2000.10014 [ada06] e. adar. guess: a language and interface for graph exploration. in chi ’06: proceedings of the sigchi conference on human factors in computing systems. pp. 791–800. acm press, new york, ny, usa, 2006. doi:10.1145/1124772.1124889 [ddn02] s. demeyer, s. ducasse, o. nierstrasz. object oriented reengineering patterns. morgan kaufmann publishers inc., san francisco, ca, usa, 2002. [dv07] b. du bois, b. van rompaey. supporting reengineering scenarios with fetch: an experience report. in third international ercim symposium on software evolution. october 2007. to appear. [flm94] a. frick, a. ludwig, h. mehldau. a fast adaptive layout algorithm for undirected graphs. in gd ’94: proceedings of the dimacs international workshop on graph drawing. pp. 388–403. springer-verlag, london, uk, 1994. [kbs04] d. krafzig, k. banke, d. slama. enterprise soa: service-oriented architecture best practices (the coad series). prentice hall ptr, upper saddle river, nj, usa, 2004. [ld03] m. lanza, s. ducasse. polymetric views-a lightweight visual approach to reverse engineering. ieee trans. softw. eng. 29(9):782–795, 2003. doi:10.1109/tse.2003.1232284 [lms06] g. lewis, e. morris, d. smith. analyzing the reuse potential of migrating legacy components to a service-oriented architecture. in csmr ’06: proceedings of the conference on software maintenance and reengineering. pp. 15–23. ieee computer society, washington, dc, usa, 2006. doi:10.1109/csmr.2006.9 [mm06] b. s. mitchell, s. mancoridis. on the automatic modularization of software systems using the bunch tool. ieee trans. softw. eng. 32(3):193–208, 2006. brian s. mitchell and spiros mancoridis. doi:10.1109/tse.2006.31 [mtw93] h. a. müller, s. r. tilley, k. wong. understanding software systems using reverse engineering technology perspectives from the rigi project. in cascon ’93: 11 / 12 volume 8 (2008) http://dx.doi.org/10.1109/ms.2000.10014 http://dx.doi.org/10.1145/1124772.1124889 http://dx.doi.org/10.1109/tse.2003.1232284 http://dx.doi.org/10.1109/csmr.2006.9 http://dx.doi.org/10.1109/tse.2006.31 proceedings of the 1993 conference of the centre for advanced studies on collaborative research. pp. 217–226. ibm press, 1993. [nphk05] e. nyáry, g. pap, m. herczegh, z. kolonits. supporting the maintenance of legacy cobol applications with tools for repository management and viewing. in icsm (industrial and tool volume). pp. 5–10. 2005. [oas06] oasis consortium. reference model for service oriented architecture 1.0. july 2006. http://www.oasis-open.org/committees/download.php/16587/wd-soa-rm-cd1ed. pdf [osl05] l. o’brien, d. smith, g. lewis. supporting migration to services using software architecture reconstruction. step 0:81–91, 2005. doi:10.1109/step.2005.29 [sfm97] m.-a. d. storey, f. d. fracchia, h. a. mueller. cognitive design elements to support the construction of a mental model during software visualization. in wpc ’97: proceedings of the 5th international workshop on program comprehension. p. 17. ieee computer society, washington, dc, usa, 1997. doi:10.1109/wpc.1997.601257 [sr06] j. spohrer, d. riecken. services science. commun. acm 49(7), july 2006. [war00] c. ware. information visualization: perception for design. morgan kaufmann publishers inc., san francisco, ca, usa, 2000. [wtms95] k. wong, s. r. tilley, h. a. muller, m.-a. d. storey. structural redocumentation: a case study. ieee software 12(1):46–54, 1995. doi:10.1109/52.363166 proc. software evolution 2007 12 / 12 http://www.oasis-open.org/committees/download.php/16587/wd-soa-rm-cd1ed.pdf http://www.oasis-open.org/committees/download.php/16587/wd-soa-rm-cd1ed.pdf http://dx.doi.org/10.1109/step.2005.29 http://dx.doi.org/10.1109/wpc.1997.601257 http://dx.doi.org/10.1109/52.363166 introduction the service concept characterising source dependencies cobol artefacts structural properties views functional dependency view overall design exceptional entities data dependency view data usage experience report room for improvement related work conclusion xl4c4d – adding the graph transformation language xl to cinema 4d electronic communications of the easst volume 61 (2013) selected revised papers from the 4th international workshop on graph computation models (gcm 2012) xl4c4d – adding the graph transformation language xl to cinema 4d ole kniemeyer and winfried kurth 10 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst xl4c4d – adding the graph transformation language xl to cinema 4d ole kniemeyer1 and winfried kurth2 1 o kniemeyer@maxon.net maxon computer gmbh, max-planck-str. 20, 61381 friedrichsdorf, germany 2 wk@informatik.uni-goettingen.de georg-august-university göttingen, department of ecoinformatics, biometrics and forest growth, büsgenweg 4, 37077 göttingen, germany abstract: a plug-in for the 3d modeling application cinema 4d is presented which allows to use the graph transformation language xl to transform the 3d scene graph of cinema 4d. xl extends java by graph query and rewrite facilities via a data model interface, the default rewrite mechanism is that of relational growth grammars which are based on parallel single-pushout derivations. we illustrate the plug-in at several examples, some of which make use of advanced 3d features. keywords: scene graph, l-system, relational growth grammar, cinema 4d 1 introduction most 3d modeling systems represent their 3d content as a scene graph. in general, this is a directed acyclic graph or even just a tree, where nodes contain geometry data and further properties, while edges define spatial and logical relations between nodes. e.g., the coordinate system of a node is typically inherited to its children, and often this also holds for properties like the color. to create and modify the scene graph, 3d modeling applications typically do not only provide direct user interaction, but also built-in (textual or visual) programming languages. but none of these languages makes use of graph transformation techniques, although they suggest themselves for such a language, given the underlying scene graph. what has been used for 3d scene graph creation are l(indenmayer)-systems [pl90], starting with the successful specification of 3d plant models, and nowadays this parallel string-rewriting formalism is directly supported by many 3d modeling applications. but as it is based on strings, it necessitates an additional interpretation step from strings to graphs. in previous research, we developed relational growth grammars as a rewriting mechanism for graphs which incorporates both the possibilities and ease of use of l-systems (but applied to graphs) and of true graph transformations based on single-pushout derivations [kbhk08, kni09]. we also developed a textual programming language xl which extends java by graph transformation syntax and semantics. this can be used to implement relational growth grammars, and there is a ”reference implementation” within the java-based open-source 3d platform groimp [khk]. this software has been developed with the needs of relational growth grammars and 1 / 10 volume 61 (2013) mailto:o_kniemeyer@maxon.net mailto:wk@informatik.uni-goettingen.de xl4c4d plant modeling in mind, so it provides strong support for this field of application, while it has fewer general 3d features than traditional all-purpose 3d modeling systems. through the data model interface of xl, it is possible to let xl operate on any kind of graph. we will present an implementation for the scene graph of cinema 4d [max] as a plug-in, and we will show some examples of its application. 2 relational growth grammars in this section, we will sketch relational growth grammars (rgg for short) to have a formal basis for the following applications. we do not give complete definitions here as this would become too lengthy, they can be found in [kni09]. at first, the graph model has to be specified. to be able to use type hierarchies known from object-oriented programming for nodes and edges, and to store attributes at nodes, we are using typed attributed graphs with inheritance [eept06]. since the semantics of edges within the rgg formalism is to stand for plain relationships between their incident nodes, we exclude the possibility of edge attributes, and parallel edges of the same type are not allowed. the latter means that the edges of a graph g are simply represented as a subset of gv×λe×gv , where gv denotes the nodes of g and λe is the set of edge types. the rewriting mechanism of relational growth grammars is based on the algebraic singlepushout (spo) approach [ehk+97]. the spo approach has the nice properties that dangling edges are removed automatically, and that deletion is prefered over preservation in case of a conflict. this is very useful for the domain of models we are interested in: e.g., think of an animal being represented as a node, then there might be a rule describing death because of ageing which simply deletes the animal node. without the automatic deletion of dangling edges, we would have to take into account all possible edges of the animal in the death rule, which would be cumbersome in practice. if there is a second rule for the animal which models its movement, and if both rules are applied in parallel, there is a conflict between deletion and preservation, but it makes perfect sense to prefer deletion as the death rule models a deliberate and rather drastic event. in order to instantiate the spo approach for rgg graphs, we have to define a corresponding category rgggraph of graphs and their homomorphisms. the single-pushout approach works with partial homomorphisms homp(g,h), i. e., graph homomorphisms g → h which are defined on some subgraph of their domain g. to integrate the inheritance relation in the notion of a graph homomorphism, we use a technique based on [pem87]: a homomorphism f : g → h in rgggraph is a structure-preserving mapping such that for every object (node or edge) x ∈ g the type of its image f (x) is a subtype of the type of x. to be convenient for the modeling of scene graphs of plants and other structures, rgg rules have to be sufficiently expressive. basically, the application of a rule shall remove the match of its left-hand side (lhs, the predecessor) from the host graph and insert its right-hand side (rhs, the successor) into the derived graph. the exact definition of a rule is based on spo productions [ehk+97], but we allow the right-hand side to dynamically depend on the match. as an example, consider a reproduction rule of an animal where the number of children depends on some properties of the animal. if we were constrained to conventional productions, we would selected revised papers from gcm 2012 2 / 10 eceasst have to either specify several productions (one for each possible number of children) or to use several derivation steps. both solutions are not feasible from a practical point of view. the dependence of the right-hand side on the match provides a solution to this problem (cf. [kur94, pkl07, cj92]). as a result, an rgg rule consists of a left-hand side l, an application condition c and a mapping p which maps a match m for l to the actual spo production p(m) to be used for the derivation: definition 1 (application condition) let l be a graph. an application condition c on the set hom(l,·) of all total graph homomorphisms with domain l is a boolean-valued function on hom(l,·). definition 2 (simple rgg rule) let l be a graph. a simple rgg rule r = (l,c, p) is given by a graph l, an application condition c, and a mapping p : hom(l,·) → monp(·,·), where monp(·,·) denotes the set of all partial, injective homomorphisms, such that for some m : l → g ∈ hom(l,·) the image p(m) is an spo production m(m) p(m) −−→ r(m) whose domain (in the categorical sense) m(m) is a subgraph of g and a supergraph of m(l). definition 3 (match) a match for a simple rule r = (l,c, p) in a host graph g is a total graph homomorphism m : l → g such that the application condition c is fulfilled (c(m) = true). definition 4 (simple rgg derivation) let m : l → g be a match for a simple rule r = (l,c, p). a direct derivation using r via m, denoted as g r,m =⇒ h, is given by a direct spo derivation using m(m) p(m) −−→ r(m) via the inclusion m(m) ↪→ g, i. e., by the following commutative diagram in the category rgggraph, where the square is a pushout: l m (( // m(l) � � // m(m) p(m) // _� �� r(m) �� g // h the following is an example for a simple rgg rule which moves some sort of animal (atyped node) along a path of x-typed nodes if its energy is above the threshold 1 and creates some children at the left location, the number depending on the energy. l = a �� ��a x �� ��x // oo y �� ��x , c(m) = (m(a).energy > 1), p(m) = m(l)→ rbm(a).energyc with r1 = a �� ��a x �� ��x //y�� ��x oo , r2 = �� ��a a�� ��a x �� ��x // oo y �� ��x oo , r3 = �� ��a �� ��a a�� ��a x �� ��x // oo`` y �� ��x oo , ... 3 / 10 volume 61 (2013) xl4c4d nodes are represented as oval boxes around their type, node identifiers are placed before the upper left corner. m(a).energy refers to the value of the energy attribute of the match for the a-typed node a, and bxc denotes the integral part of x (floor function). the mapping p(m) is indicated by the reuse of node identifiers of the lhs for the rhs. because processes in a living system happen in parallel, there has to be the possibility to apply rgg rules in parallel. for a family of simple rgg rules with corresponding matches, we can create a parallel derivation from the generated spo productions pi(mi) as defined in [ehk+97]. the following shows such a parallel rgg derivation for the single example rule from above using the two obvious matches, if we assume that the energy of node a is 1.5 and that of b is 3.5. g a �� ��a b�� ��a�� ��x //�� ��x // oo �� ��x // oo �� ��x //�� ��x +3 h �� ��a �� ��a a �� ��a b�� ��a�� ��x //�� ��x //�� ��x xx ff // oo �� ��x oo // �� ��x unfortunately, this straightforward parallelism fails if rule application successors of neighbouring parts shall be connected by edges, which is a very important case and needed by the embedding of l-systems in the rgg formalism. several connection mechanisms were studied in [lr76] to address this problem, of which the operator approach [nag76, nag79] turns out to be a suitable technique for relational growth grammars. the application of a rule to a match also establishes connection transformations which are given by a quintuple (s,(a,d,γ),t) with a node s from the match, a node t from the right-hand side, an operator a, a direction flag d (either “source” or “target”) and an edge type γ . an operator a yields for every node n ∈ g of the match a set ag(n) of related nodes (e. g., its neighbours). we may think of such a connection transformation as an arrow which points from a node s in the host graph g to a node t in the derived graph h resulting from the simple rgg derivation. the operator mechanism then shifts connections within the host graph along a pair of matching arrows to the derived graph: for a matching arrow pair (s1,(a1,“source”,γ),t1), (s2,(a2,“target”,γ),t2) where the host graph nodes s1,s2 are related according to the operators, i. e., s2 ∈ a1(s1) and s1 ∈ a2(s2), an additional γ -typed edge from t1 to t2 is created within the derived graph h. definition 5 (rgg rule) an rgg rule r = (l,c, p,z) is a simple rgg rule (l,c, p) together with a mapping z which assigns to each match m : l → g for the simple rule a set of connection transformations (s,(a,d,γ),t) with s ∈ m(m) (domain of p(m)), t ∈ r(m) (codomain of p(m)), an operator a, a direction d (either “source” or “target”) and an edge type γ . 3 the xl programming language xl is a proper extension of java. the main new features are rule blocks and graph queries. a rule block can be used everywhere where java allows a normal code block, it is distinguished by selected revised papers from gcm 2012 4 / 10 eceasst square brackets instead of the usual curly braces. the following example shows the translation of the animal movement and reproduction rgg rule from above: [ x:x [a:a] y:x, (a.energy > 1) ==>> x f o r(i n t i = 2; i <= a.energy; ++i) ( [a] ) y [a]; ] x:x is a pattern which matches a node of java class x and assigns the identifier x to the match. within leftand right-hand sides, square brackets are used to enclose branches, so that the lefthand side of the example has to be read as: find an x-typed node x which has an a-typed child a and an x-typed successor y. child and successor relationships are represented by distinct edge types. the left-hand side also contains an application condition in round parentheses. the right-hand side depends on the match because the for-loop expands into a variable number of nodes, depending on a.energy: if the energy is less than 2, we have x y [a] which just moves a to y. if it reaches 2, we get x [a] y [a]. this creates a new a node (because there is no node identifier a) as a child of x. for higher energies, we get even more new a nodes. cycles of non-tree-like structures are obtained by repeating a node identifier. e.g., the pattern a:a b c a represents a circular graph of three nodes of types a, b, c. graph queries are expressions which use the syntax of left-hand sides within (* *). e.g., the expression count((* x [a] *)) contains a query for all a-typed children of a given node x, and counts the number of matches. all graph operations of xl are defined on top of an abstract data model interface. by implementation of this interface, xl can operate on any kind of graph. the most sophisticated implementation exists for groimp, but there are also implementations for xml documents or minimalistic sierpinski graphs [kni09]. in the following, we will show some more examples of xl. an in-depth description can be found in [kni09]. 4 the plug-in xl4c4d and its application the 3d modeling system cinema 4d [max] uses a scene graph to represent spatial and logical relations between objects. in fact it is rather a tree than a graph, but objects can have additional link attributes which may point to arbitrary objects in the scene tree, thus yielding a true graph. each object has its own local 3d coordinate system. as usual for scene graphs, this is defined by the coordinate system of the parent object, multiplied with a transformation attribute of the object itself, so that an object moves together with its descendants when one modifies the transformation of the object. there are objects with a geometry such as cube, sphere, or polygonobject for a general polygon mesh, but also a null object which has no geometry itself, but can be used to group its children and to inherit its transformation to them. instance objects also have no geometry themselves, but a link to another object. they show the geometry of the linked object within their own coordinate system. this saves a lot of memory when one wants to place the same geometry at several locations. cinema 4d provides a c++ sdk which allows to write custom plug-ins. with the help of the java native interface as a bridge between java and c++, we implemented xl’s data model 5 / 10 volume 61 (2013) xl4c4d (a) (b) (c) figure 1: (a) screenshot showing the plug-in with a binary tree; (b,c) polymerization model interface for cinema 4d’s scene graph. the plug-in (available at [khk]) adds the following features to cinema 4d: • the xl console shows output from xl execution, and it allows to directly type in xl code which is then executed. • there is a new scene graph object xl object. it has a code attribute which allows to enter a complete xl program. methods of the program may be invoked interactively, and parameters defined in the program are accessible in the attribute manager. • the xl instance object behaves similar to a normal instance object. it has additional attributes for scaling and translation which are more convenient for xl models than the normal transformation attributes. figure 1(a) shows a screenshot of cinema 4d at the example of a simple 3d binary tree. the code properties of the single xl object are opened. the complete code for the model is public class main extends xlobject { module tip extends sphere(20).(setmaterial("green")); public void init() [ ==>> ˆ tip; ] public void grow() [ tip ==> f(100) [ru(30) rh(90) tip] [ru(-30) rh(90) tip]; ] } selected revised papers from gcm 2012 6 / 10 eceasst the code shows the basic structure of an xl model within xl4c4d: the actual code has to be surrounded by a class extending xlobject. parameterless public void methods of that class can be invoked interactively by choosing them in a drop-down menu and clicking on an invoke-button, so one typically puts the actual rules within such methods. in the example there is an init-method with a simple rgg rule with empty lhs: out of nothing, the rule creates a two-node graph starting at the xl object itself, which is represented by ˆ, and followed by an instance of tip. the java class tip itself is specified in a module declaration which is a simplified class declaration and in this case corresponds to a sphere object in the scene graph with a radius of 20 units and the material named ”green”. a tip-node represents a leaf (in the mathematical sense) of the tree, therefore for a growth of a binary tree such a node has to be replaced by an inner node bearing two new tip-nodes. this is implemented by the grow-method which uses a non-simple rgg rule to replace (in parallel) each tip-node by an f-node with two branches. the branches do not consist of tip-nodes only, but also of 3d rotation nodes of the types ru and rh put in front. an f-node corresponds to an xl instance object in the scene graph which instantiates a cylinder object, the parameter 100 to the f-constructor scales this cylinder to a height of 100 units, and it also shifts the coordinate system by 100 units along the cylinder axis (the local y-axis). together with the rotations around the local xand y-axes (ru and rh, respectively), this places the base of the cylinder at the location of the previous tip, and adds the two new tips at the top of the cylinder, but with a rotated coordinate system such that the new branches emerge in different directions in 3d space. the grow-rule requires connection transformations (there are no common nodes on lhs and rhs for gluing). they can be specified for each pair of lhs/rhs-nodes, but for convenience two such transformations are automatically added if one uses the rule arrow ==>, namely one from the leftmost (unbracketed) lhs node to the leftmost (unbracketed) rhs node and one for the rightmost nodes. this is exactly what is needed for an l-system rule when it shall be applied not to a string but to a graph. besides sphere, f, ru and rh, the plug-in also provides rl for rotation around the zaxis, m for y-translation, scale for uniform scaling, null for general transformations, cube, box, instance, and even spring for physics simulations. each node of such a java class corresponds to a cinema 4d object of suitable type, e.g., pure transformation nodes are represented as null objects in the scene graph. the general baseobject class corresponds to cinema 4d’s baseobject c++ class. with its methods and the numerical ids from cinema 4d’s resource files it is possible to create objects of any type, and to set most of their attributes. attributes of the cinema 4d types bool, long, real, vector, matrix, string and baselink are supported, the same holds for additional user data attributes. one of cinema 4d’s advanced features is the dynamics module which provides a rigid body simulation. with its help we can create a toy model of polymerization: a lot of monomers of two types (monomera and monomerb) move around according to the laws of rigid body physics. at each frame (i.e., each simulation step), it is checked if two monomers of different type come close to each other. if so, the rule triggers and creates a bond in the form of a spring object for the rigid body simulation: public class main extends xlobject { module monomera extends sphere(20).(setcolor(1, 0, 0)); 7 / 10 volume 61 (2013) xl4c4d module monomerb extends sphere(20).(setcolor(0, 1, 0)); public void init() [ ... ] public void step() [ a:monomera, b:monomerb, ((distance(a, b) <= 50) && empty((* spring(a, b) *))) ==>> a, b, ˆ spring(a, b).(setboolean(force_always_visible, true)); ] } the bonding rule step looks for two monomers a, b which, due to the comma inbetween, need not have any relationship in the graph. its application condition tests if a, b are close to each other (at most 50 units in 3d space) and makes sure by a graph query that no spring node already exists. the rhs repeats a, b so that they don’t get deleted, and it creates and initializes a new spring node linked to them. the setup of the simulation environment for the example is done manually. figure 1(b) shows the initial situation with monomers randomly placed in 3d space above a floor object. the result after some simulation steps is shown in figure 1(c). for the simulation it is necessary to put the bonding rule in a method named step because a method of this name is automatically invoked by the plug-in during the simulation whenever the document time changes. figure 2 shows the result of a more advanced example which combines xl with dynamics and collision detection via cinema 4d’s built-in visual programming language xpresso: the large sphere rolls along the floor, and whenever it collides with one of the small grid points, this is detected by xpresso which then sets a user attribute on the grid point object. this in turn can be evaluated by xl to let a simple binary tree grow at such a point until it is eventually dissolved by xl into a set of light particles which fall down according to dynamics. 5 discussion the structure of cinema 4d’s scene graph is well-suited for the application of xl. the shown examples could be adapted from their original groimp implementations [kni09] without major changes, and they could easily be combined with advanced features like dynamics. in fact, the groimp implementation of the polymerization has to include some simple simulation rules for monomer movement which are superfluous for xl4c4d. there are a lot more features from animation to sophisticated rendering from which one can benefit. on the other hand, the java native interface introduces a performance bottleneck, and cinema 4d isn’t able to handle very large amounts of objects or deep structures efficiently. so the system is not suitable for graphs of million nodes, which may appear in detailed plant models and which can be handled by groimp. e.g., for the classical example of the koch snowflake curve, the plug-in allows only up to three iterations, reaching a graph depth of 384. within groimp, nine iterations resulting in a depth of more than 1.5 million are possible without any problems. therefore, in its current state, xl4c4d is a useful addition for cinema 4d if one wants to create and modify the graph of scenes within typical domains of cinema 4d such as motion graphics. in motion graphics, visually interesting effects have to be achieved, but they need not selected revised papers from gcm 2012 8 / 10 eceasst figure 2: the sphere triggers tree growth, eventually trees dissolve into light particles. be realistic. also the graph structures are typically relatively simple, but still too extensive to be modeled by hand. the last example can be seen as a (somewhat unskilled) representative of this kind of computer graphics. xl4c4d operates on the scene graph level. a much more complex kind of 3d modeling happens at the deeper level of actual geometry. this is usually represented as a polygon mesh, i.e., another kind of graph. typical operations on a mesh like extrusion [bpa+10] or subdivision [smg10, bpa+10] can be modelled as graph transformations. we haven’t implemented such facilities for the plug-in, but it could be done based on the vv approach [sps03, kni09]. bibliography [bpa+10] t. bellet, m. poudret, a. arnould, l. fuchs, p. l. gall. designing a topological modeler kernel: a rule-based approach. in shape modeling international. pp. 100–112. ieee computer society, 2010. [cj92] t. w. chien, h. jürgensen. parameterized l systems for modelling: potential and limitations. in rozenberg and salomaa (eds.), lindenmayer systems. pp. 213–229. springer, berlin, 1992. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer, secaucus, nj, usa, 2006. [ehk+97] h. ehrig, r. heckel, m. korff, m. löwe, l. ribeiro, a. wagner, a. corradini. algebraic approaches to graph transformation ii: single pushout approach and com9 / 10 volume 61 (2013) xl4c4d parison with double pushout approach. in rozenberg (ed.), handbook of graph grammars and computing by graph transformations, volume 1: foundations. chapter 4, pp. 247–312. world scientific, 1997. [kbhk08] o. kniemeyer, g. barczik, r. hemmerling, w. kurth. relational growth grammars – a parallel graph transformation approach with applications in biology and architecture. in schürr et al. (eds.), agtive 2007. lecture notes in computer science 5088, pp. 152–167. springer, 2008. [khk] o. kniemeyer, r. hemmerling, w. kurth. groimp. http://www.grogra.de. [kni09] o. kniemeyer. design and implementation of a graph grammar based language for functional-structural plant modelling. phd thesis, btu cottbus, 2009. [kur94] w. kurth. growth grammar interpreter grogra 2.4 – a software tool for the 3dimensional interpretation of stochastic, sensitive growth grammars in the context of plant modelling. introduction and reference manual. berichte des forschungszentrums waldökosysteme, b 38, göttingen, 1994. [lr76] a. lindenmayer, g. rozenberg (eds.). automata, languages, development. north holland, amsterdam, 1976. [max] maxon computer gmbh. cinema 4d. http://www.maxon.net. [nag76] m. nagl. on a generalization of lindenmayer-systems to labelled graphs. pp. 487–508 in [lr76]. [nag79] m. nagl. graph-grammatiken: theorie, anwendungen, implementierungen. vieweg, braunschweig, 1979. [pem87] f. parisi-presicce, h. ehrig, u. montanari. graph rewriting with unification and composition. in ehrig et al. (eds.), third international workshop on graphgrammars and their application to computer science. lecture notes in computer science 291, pp. 496–514. springer, 1987. [pkl07] p. prusinkiewicz, r. karwowski, b. lane. the l+c plant modelling language. in vos et al. (eds.), functional-structural plant modelling in crop production. wageningen ur frontis series 22, pp. 27–42. springer, 2007. [pl90] p. prusinkiewicz, a. lindenmayer. the algorithmic beauty of plants. springer, new york, 1990. [smg10] a. spicher, o. michel, j.-l. giavitto. declarative mesh subdivision using topological rewriting in mgs. in ehrig et al. (eds.), icgt. lecture notes in computer science 6372, pp. 298–313. springer, 2010. [sps03] c. smith, p. prusinkiewicz, f. f. samavati. local specification of surface subdivision algorithms. in pfaltz et al. (eds.), agtive 2003. lecture notes in computer science 3062, pp. 313–327. springer, 2003. selected revised papers from gcm 2012 10 / 10 introduction relational growth grammars the xl programming language the plug-in xl4c4d and its application discussion integration of ontological scene representation and logic-based reasoning for context-aware driver assistance systems electronic communications of the easst volume 11 (2008) proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) integration of ontological scene representation and logic-based reasoning for context-aware driver assistance systems simone fuchs, stefan rass, kyandoghere kyamakya 12 pages guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst integration of ontological scene representation and logic-based reasoning for context-aware driver assistance systems simone fuchs1, stefan rass2, kyandoghere kyamakya3 1simone.fuchs@uni-klu.ac.at 2stefan.rass@uni-klu.ac.at 3kyandoghere.kyamakya@uni-klu.ac.at department of smart system-technologies alpen-adria-universität klagenfurt, austria abstract: co-operative driver assistance systems share information about their surrounding with each other, thus enhancing their knowledge and their performance. for successful information exchange and interpretation, a common domain understanding is needed. this paper first presents an ontology-based context-model for driving scene description, including next to spatio-temporal components also additional context information like traffic signs, state of the driver and the own-vehicle. for traffic rules, we integrate the ontological scene description with a logic programming environment, to enable complex and powerful reasoning on the given information. the proposed ontology is discussed with respect to a set of validation criteria. for integration with logic programming a prototypical development of an overtaking assistant is shown to demonstrate the feasibility of the approach. keywords: ontology, context, logic programming, reasoning, driver assistance 1 introduction context-aware collaborative driver assistance systems (das) need a common domain description for information exchange. context for a das refers to the driving situation, consisting of the environment and all objects and traffic participants within it, which are currently relevant to the own vehicle. the driver’s state and experience as well as the technical state of the vehicle with the mounted das are also influencing a driving situation. one additional, often neglected factor is the traffic law. the main task of an intelligent das is driver support, in contrast to autonomous vehicles. to make correct decisions, the system must be aware of the driving surrounding. thus, a context-model is needed for representing knowledge about driving scenes. collaboration with other vehicles and infrastructure enhances a single das’ knowledge with additional information. here a context-model is the basis for knowledge exchange between participants. present-day das (e.g. the adaptive cruise control acc) are mostly stand-alone solutions, focusing on a highly specialized subtask of driving, with limited context-awareness. current trends in das indicate that for future systems integration of stand-alone solutions is going to take place, thus resulting in smarter dass. those will be able to free the driver from difficult and tedious tasks. the overall driving context will become important for correctly recognizing and interpreting complex driving situations. das will become increasingly knowledge-based and methods will 1 / 12 volume 11 (2008) mailto:simone.fuchs@uni-klu.ac.at mailto:stefan.rass@uni-klu.ac.at mailto:kyandoghere.kyamakya@uni-klu.ac.at context-aware reasoning for driver assistance be needed for modeling, handling and exchanging the vast amount of context information. this paper presents an ontology-based context-model intended for scene-representation and information exchange in intelligent das. the model is presented and discussed with respect to a variety of pre-defined ontology-engineering criteria. integration of the context-model with traffic rules in a logic programming environment is outlined, using the prototypical implementation of an overtaking assistant. 2 related work the authors of [tfk08] present score the spatial context ontology reasoning environment. the system is made of modular components that distribute the ontological knowledge and reason about the context’s low-level spatial properties. score understands queries like ”is car x overtaking car y?”. score uses a description-logic based reasoner to derive information about a driving situation. however, it remains unclear which context objects are contained in the ontology and how the spatial information and relationships are actually represented. also, the reasoning mechanism or the content of the rule base are not explained in detail. the authors seems to consider neither temporal concepts nor uncertain information. [lgth05] demonstrates a spatio-temporal solution that exploits qualitative motion descriptions. movement parameters (e.g. speed) are mapped from raw sensory data to qualitative abstract classes. production rules are used for reasoning on the qualitative scene descriptions. the approach is feasible for the spatio-temporal representation of moving objects. the question remains, if for some driving decisions numerical movement parameters are the better choice. speed and distance values can be obtained easily and seem to be the better choice for time/speed calculations, especially if the vehicle is supposed to yield better estimations than a human driver. the presented rule base solely focuses on the spatio-temporal reasoning, further influence factors on the driving task are not taken into account. ontologies with context information for das have been developed in the rena project [wbss]. however, the focus of this project is on context-aware navigation systems, with a seamless handover between different inand outdoor positioning systems, not on driver assistance. traffic rules, static traffic objects (e.g. signs) and environmental conditions are, to the best of our knowledge, not dealt with in current approaches, although they have major influence on recommended driving behavior. with the ongoing technical progress of sensing systems and gis, information about those conditions will be soon available and should be included in both contextrepresentation and reasoning. our context-model extends spatio-temporal data with additional context information, necessary for deducing context-aware driving recommendations. 3 ontology-based driving scene representation the context model has been developed in owl, which has been chosen as suitable language for context representation and sharing, based on the results of the survey in [sl04]. an overview of the ontology’s content is shown in figure 1. there are three main superclasses in the hierarchy: contextobject, objectrelationship and metainformation. contextobjects includes both static and dynamic context objects of a driving situation. examples are the driver, the own-vehicle, the proc. campus 2008 2 / 12 eceasst figure 1: a context model for abstract driving scene description driving context, participants, traffic signs etc. the spatial context is the current road type (highway, urban, ...) and is valid for a longer time-span. local contexts are located within a spatial context and represent a sub-environment with special rules (e.g. intersection). traffic objects are included from four major context categories: driver, own-vehicle, traffic regulations and driving environment with respect to the own-vehicle. every object is annotated with datatype properties for further description. traffic objects have relationships to each other, which are either of type 1:1 (represented with object properties) or n:m. in the latter case, the relationship is represented as a subclass of objectrelationship. for example, every other participant has a certain relationship to the own vehicle, the own vehicle itself has a relationship to an oncoming local context, traffic signs are valid for certain lanes and so on. recognition of traffic objects using sensing devices has made substantial progress over the past decade. a number of projects have been conducted in the fields of pedestrian recognition [sgh04], traffic sign detection [mks00], driver state detection [qy02] and lane recognition [mwks04]. we therefore think it safe to assume that the traffic objects needed in our model can technically be provided. 3.1 representing uncertain information the input of a das is highly unlikely to be precise and reliable, especially if derived from sensing systems or provided by gis systems. therefore, uncertainty information has to be included in the context-model. the special class metainformation contains information about an object’s source and it’s reliability, the object’s estimated quality (provided by the source) and the expected time-span of an object’s validity, derived from distance or time-to-contact measurements, which provides information about when a certain object is becoming valid within the knowledge base and must be included in the reasoning process. one or more instances of the meta-information 3 / 12 volume 11 (2008) context-aware reasoning for driver assistance class are assigned to every object and relationship, because object information is gathered from different sources. at the moment the list includes on-board sensing systems, foreign sensing systems (e.g. from other vehicles) and static sources like geographic information systems (gis), which can augment traffic object information (e.g. number of lanes, position of traffic signs, road type). the meta-information can be exploited during the decision process, using methodologies from the field of reasoning under uncertainty. 3.2 representing spatio-temporal information representing moving objects with a single time-span is sufficient for high-level motion description (cf. [lgth05]). spatial information between the own-vehicle and other participants is represented from an ego-centric perspective with the own vehicle at the center. qualitative attribute values are used for the direction (front, rear, left, right and combinations) and the relative direction movement (towards, away, parallel). for the movement parameters speed, distance and line of sight our model uses numerical values, for reliable calculations associated with driving maneuvers (e.g. overtaking). those rely on time-frames and speed-difference value calculations, which can be obtained from the given parameters with reasonable computational effort. qualitative mapping is rather important when presenting results to driver. for spatio-temporal calculations, we expect better results from numerical calculations here in comparison to purely qualitative values. also, numerical speed and distance values can be easily obtained from sensing systems. the ontology is published on http://vi.uni-klu.ac.at/ontology/drivingcontext.owl. the ontology is intended for high-level scene representation of driving scenes, as it is used on a tactical level in das for driver decision support. 3.3 representing traffic rules for rule-representation, owl currently supports the semantic web rule language (swrl), a proposal for extending owl with horn-clause-like rules. representation of complex rules is not efficient [hor05] and until today, swrl has not been improved and made part of the standard yet1. in [mbkl05], where owl and swrl are used to represent domain knowledge in logistics, some of the encountered problems, like lack of negation-as-failure, are discussed. for some years it has been rather quiet around swrl now and not much progress has been made. a logicbased approach is more suitable and provides sophisticated reasoning mechanisms on the available knowledge. we used the constraint satisfaction paradigm. a constraint satisfaction problem (csp) is defined as a triple 〈x , d,c〉 where x is a finite set of variables x = 〈x1, x2, ..., xn〉, d is a corresponding n-tuple of domains d = 〈d1, d2, ..., dn〉 such that xi ∈ di, meaning a variable xi can be assigned values from its corresponding domain di = 〈v1, v2, ..., vn〉. c is a finite set of constraints c = 〈c1,c2, ...,ct〉. a constraint c ∈c involving variables xi, ..., x j is a subset of the cartesian product di×...×d j of compatible variable assignments. a constraint c is satisfied by a tuple of values v = (vi, ..., v j) assigned to variables xi, ..., x j if v ∈ c. an assignment is complete if a every variable is assigned a value. a complete assignment is a solution to a csp if it satisfies all constraints in c. in a typical csp the programmer defines the decision variables xi, ..., x j and 1 http://www.w3.org/submission/swrl/, accessed on 6th may 2008 proc. campus 2008 4 / 12 http://vi.uni-klu.ac.at/ontology/drivingcontext.owl eceasst states the constraints as well as an (optional) optimization function. a standard solver tries to find assignments for the decision variables that satisfy all constraints, while at the same time minimizing (or maximizing) the objective function (constraint optimization problem). within a driving situation, the traffic rules represent the constraints that must be fulfilled. we have a mixed csp: variables containing pre-determined values that cannot be changed, but must be included in the reasoning process. examples are speed and distance values of other participants, provided by the context-model. the decision variables we want to find a value for are our own speed (integer value) and driving maneuver (set of finite values). we try to find a variable assignment that does not violate any traffic rules. if no solution can be found, one or more traffic rules are violated. there are hard and soft constraints. a hard constraint must not be violated in any case, e.g. a double white line or a given speed limit. a soft constraint can be gradually fulfilled, until it becomes a hard constraint. an example within a das would be an oncoming vehicle during an overtaking maneuver. the meeting point with the oncoming vehicle depends on the speed and distance of the oncoming vehicle and related to the overtaking duration. the hard constraint must hold that the overtaking duration is smaller then the time to contact, otherwise a collision will occur. if the constraint is fulfilled, it is so with a certain risk. the time to contact can be long after completion of overtaking (low risk) or very short (high risk). 3.4 integrating context-information with the reasoning component contextual information of the present driving scene is represented with class instances of the provided context ontology, using owl syntax. in this form, information is machine-readable and thus easily exchangeable between collaborating vehicles and infrastructure. since a logicbased programming environment is typically not able to read owl, the context information must be transformed, to be of use to the reasoning component. we developed a set of transformation rules (cf. [frlk08]) that translates a scene description (given as owl class instances) to the dynamic knowledge base of the reasoning component. first, the static framework (structures, enumerations etc.) is created out of the context-ontology. every class, together with its datatype and object properties, is automatically transformed to a struct, representing the class description in logic programming syntax. this only has to be done once for the initial ontology and every time the ontology changes (making migration of the reasoning component necessary). once the structures are available, every class instance of the form 120 180 305 light 2 low 3.09 5 1.65 5 / 12 volume 11 (2008) context-aware reasoning for driver assistance figure 2: relevant objects within a driving scene staticallyprovided onboardsensing is translated to a dynamic fact ownvehicle{ objid:ownvehicle 7, speed:120, ownmaximumspeed:180, lineofsight:305, brakeintensity:light, steeringwheelangle:2, throttleintensity:low, length:3.09, gear:5, width:1.65, source:[staticallyprovided, onboardsensing], drivesin: spatialcontext 1}. and asserted to the reasoning component’s dynamic knowledgebase. now the information is available and can be used as input for the decision process. when an object is changing or no longer valid, the dynamic fact is updated resp. retracted from the knowledgebase. 4 discussion and implementation of the proposed approach 4.1 the context-model in addition to the standard tests provided by the ontology development tool, a representative variety of driving scenario snapshots was taken from real-world video-streams and from an austrian driving school’s teaching book. approximately 120 scenarios were chosen, representing intersection crossing, overtaking and various situations from urban, highway and rural road driving. within every scenario, the driving relevant objects have been manually tagged first (see figure 2) and modeled with the ontology afterwards. information, which would be present in a real world system but was not derivable from a scenario image, was given a plausible imaginary value (e.g. state of the driver). when looking at the driving scenarios, we found that most are similar, with only minor differences, e.g. different participants, number of lanes and speed/distance combinations, presence/abscence of traffic signs, local contexts etc. therefore, the seemingly small number of scenarios is sufficient to show the feasibility of the approach for a first demonstration. proc. campus 2008 6 / 12 eceasst based on the scenario mapping, we compared our ontology against a set of modeling and engineering criteria [ks07], with respect to suitability for the task of representing tactical driving decisions. • applicability: the model is useful to applications in need of abstract traffic scene representations, but not to completely foreign domains, like e.g. intelligent meeting rooms. • comparability: for our intended task, we consider this criterion less important. the ordering of qualitative classes for representation of spatio-temporal representation within driving scenes is the same world-wide. mapping from quantitative sensory data to qualitative classes should not be done within the context model. rather, the model should abstract from this details. for numerical speed/distance values different interpretations are possible: the si or the english system. since only three states worldwide are using the latter one (u.s., liberia and myanmar), the si units can be assumed per default. changing between system can solved using a system configuration entry outside the model. • traceability: the source, it’s reliability and a quality assertion are recorded for every object in the meta-information class. mapping of sensory data to a qualitative value (e.g. direction is front left) should be done by a mapping component, because the input data and consequently the processing algorithm differs for various sensor systems. since the source of the abstract object (containing qualitative values) is recorded, the mapping can be made available, either outside or inside the context-model with reasonable effort. a das operating on a tactical level will usually only be interested in the abstract object representations, not in the quantitative sensor data. wherever the numerical values are important, they are represented explicitly within the context-model (e.g. speed of a vehicle). • history, logging: in the current version, historization and logging is not yet included. • quality: for object quality information, the meta-information class should be used. • satisfiability: for qualitative values, the allowed range is listed in the model, using owlenumerations. for standard data types, we used the xsp:mininclusive and xsp:maxinclusive properties for providing range interval values. multiplicity is modeled using the ”functional” attribute of a property. • inference: inference for das, even if done on an abstract level is too complex to be modeled with current owl capabilities. traffic rules are therefore not included into the ontology, but out-sourced to a logic based reasoning component. tools for further abstraction of the model are also not included, since it is already a high-level model. refinement to higher levels of detail is possible with reasonable effort, without affecting current model semantics, exploiting owl’s class hierarchy. beside the context modeling criteria, [ks07] defined a criteria set for evaluation of ontology engineering. • reusability, standardization: within the domain of machine-readable driving scene description on a tactical level, the model can be used for all tasks in need of such descriptions, without restriction. 7 / 12 volume 11 (2008) context-aware reasoning for driver assistance • flexibility, extensibility: new definitions can be added with reasonable effort without affecting existing dependencies. particularly stepwise refinement with owl class hierarchies can be done easily. this enables different applications to enhance the existing class-definitions to their necessary level of detail. • genericity: our model does not provide a domain-independent upper-ontology. • granularity: our model consists of abstract objects representing a high-level description for the tactical level of the driving domain. refinement to finer levels of detail is possible (compare with flexibility, extensibility). • scalability: cognitive and engineering scalability of our model is unproblematic, since it contains a comparatively small number of classes and properties. reasoning scalability is not applicable, because it is entirely done outside the model. • language, formalism: our model uses the web ontology language (owl), for scene representation resp. context-modeling. the reasoning process is outsourced to a logicbased approach and uses the owl-descriptions as input. for the scenario modeling, we found that the relevant information for representation of traffic driving scenes, including both traffic objects and their relationships, can be represented with our model. the model is not optimal for all criteria, which is mainly due to the fact, that it has been developed for a very specific domain. this is especially true for the context-modeling criteria; the ontology engineering criteria, the model fulfills to a great extent and is thus a suitable basis for context-representation within intelligence components for das on a tactical level. traffic and reasoning rules are not directly represented in the context-model, due to the lack of complex rulesupport within the web ontology language. rules are implemented with a logic-based approach and the context-information is integrated as described above. 4.2 implementation of the rule base to test the feasibility of integrating owl with constraint programming, we developed a prototype for overtaking assistance. the prototype translates and analyzes a given traffic scene (in owl format) and uses the rule base to decide whether overtaking is currently wise or not. if not, the violated traffic rule(s) is (are) shown. manually tagged driving scenes descriptions (cf. section 4.1) were used as input. the automated collection of context information with computer-vision is an ongoing research topic in our group, but will not be discussed here. in the final system, the gathered context information will be dynamically retracted and inserted into the knowledge base, as new information about objects is obtained from the sensing systems. in the present version, transformation is always done for a complete traffic scene. eclipse was chosen as constraint programming environment for the reasoning component [krz07]. a translation module has been developed, that automatically analyzes and transfers the owl scene descriptions to eclipse dynamic facts. based on the resulting dynamic knowledge base, a set of constraints was specified to represent the hard and soft constraints for overtaking. a small graphical front-end was also created for presenting results of the deduction process. as programming language, the interpreted script language tcl/tk was chosen because it has an proc. campus 2008 8 / 12 eceasst figure 3: speed/distance curve of involved vehicles during overtaking interface to the eclipse environment. c++ would have been the alternative, also providing a tightly coupled interface to the knowledge base. depending on the spatial context, the system checks a different set of constraints. there are three hard constraints: 1) there must be a lane on the left for overtaking, 2) the legal speed limit must be reachable with a speed difference of at least 20 km/h and 3) there must not be a double white line. soft constraints for overtaking are those that depend on the overtaking speed and the current speed and distance values in some way. examples are the check for oncoming vehicles, for vehicles approaching from behind, sufficiency of line of sight, possibility of reaching a ban on passing while overtaking, sufficient side distance etc. depending on the duration of the overtaking time of the front vehicle, these constraints are either fulfilled, but with a certain risk, or completely violated (see section 3.3). figure 3 shows the speed/distance curve of a scenario with an oncoming vehicle, where the thick black line indicates the overtaking vehicle, the thick grey line is the front vehicle and the thin grey line represents the oncoming vehicle. the intersection of the lower two lines shows when the overtaking vehicle has reached the front vehicle. realigning to the original lane (completion of the overtaking maneuver) takes place with one second safety distance. the meeting point with the oncoming vehicle is given by the intersection of the upper line and must take place after realignment of the overtaking vehicle, else the two vehicles would collide. depending on the time difference between realignment and meeting point, a numerical risk value is determined. a small time difference indicates a high risk the oncoming vehicle reaches the overtaking vehicle soon after realignment. the risk value decreases with increase of the time difference. the numerical risk value is mapped to a qualitative value using fuzzy classification, before presenting the result to the driver. the decision component searches for a speed value for overtaking fulfilling all constraints, using the minimal necessary speed difference (dictated by law) and the maximal possible speed difference, depending on the current speed limit as starting interval. the result of the search is either a single speed value or a narrowed down speed interval. in the latter case, the highest possible value is always communicated as a result, to minimize the overtaking time. next to spatial context information, traffic objects and participants, the decision component also includes the environmental conditions into the reasoning process. the values for maximum speed limit, acceleration/deceleration, safety distance and line of sight are adjusted to current visibility and road surface conditions. furthermore, information about the state and risk-willingness of 9 / 12 volume 11 (2008) context-aware reasoning for driver assistance figure 4: prototype of overtake assistant the driver is taken into account. if the driver is e.g. tired and the overtaking maneuver involves a high risk, overtaking is not recommended. a screen-shot of the prototype’s graphical frontend is shown in figure 4. of course the presentation of results is not suitable for use in a real car while driving on a street. a discussion of how to best present information to a driver without overloading him/her, is beyond the scope of this paper. analyzing and translating the scene description to the dynamic knowledge base takes an average of approximately 100 milliseconds on an ibm laptop with a 2 ghz intel pentium processor and 2 gb memory, although tcl/tk is an interpreted language and thus slower. the file size of an average scene description is between 5 and 15 kb (unoptimized), depending on the complexity of the scene. deducing a decision based on the contents of the dynamic knowledge base and presenting the result, is done with an average of approximately 1 to 2 milliseconds. this execution times show that it is possible without performance loss to integrate an owl-scene description with a logic based reasoning system and exploit the power of deductive reasoning together with the ease and machine-readability of using owl for context-representation. 5 future work at the moment, the decision component does not take into account meta-information about traffic objects for the reasoning process. how to include uncertainty information and deal with it during deduction will be one of the major future steps. we are currently also working on the design of a learning component for self-improvement of the das. typically, drivers do not act one-hundred percent conform to driving regulations and with increasing experience develop a more efficient but also more risky style of driving. decision parameters of the system should be automatically fine-tuned over time, using the decisions and behavior of experienced drivers as input. for this, historization and logging have to be added to the model. instances of driving scene descriptions in which the driver acted oppositional to the proposed behavior are analyzed and archived together with the driver’s state and behavior. if found necessary, rules are adapted accordingly: boundaries of risk mapping are shifted, tolproc. campus 2008 10 / 12 eceasst erance values for speed differences are adjusted or additional maneuvers are allowed, always with respect to safe and legal driving. for hitherto unknown situations, where the system is not able to reach any decision, the driver’s decision is validated and added to the knowledge base permanently as a new rule. the textual scene descriptions are a suitable mechanism for use in a pattern-matching process that compares driving situations with respect to their object and relationship instance value. if results pass a certain similarity threshold value, archived recommendations and driver behavior are retrieved and reused in the reasoning process. 6 conclusions co-operative driver assistance systems (das) need a common domain understanding and a need for information exchange, with regard to driving scene description. in this paper, we presented an ontology-based context-model for traffic scene representation, which can serve as a foundation for domain-understanding, information-exchange and context-aware reasoning. we discussed the proposed ontology with respect to a set of both domain-specific and domain-independent modeling and engineering criteria. the model was found sufficiently expressive for the intended use and it has a variety of different applications. for traffic rule-representation we showed that it’s feasible to integrate owl and constraint logic programming, to exploit the advantages of both powerful information representation and reasoning, with feasible effort. the system is able to analyze the scene description and to deduce and present a recommendation near to real-time. bibliography [frlk08] s. fuchs, s. rass, b. lamprecht, k. kyamakya. a model for ontology-based scene descriptions for context-aware driver assistance systems. in proceedings of the 1st international conference on ambient media and systems (ambi-sys’08). pp. 1–8. quebec, canada, february 2008. [hor05] i. horrocks. owl rules, ok? in w3c workshop on rule languages for interoperability. 2005. [krz07] krzysztof r. apt and mark wallace. constraint logic programming using eclipse. cambridge university press, 2007. [ks07] r. krummenacher, t. strang. ontology-based context-modeling. in third workshop on context awareness for proactive systems (caps’07). 2007. [lgth05] a. lattner, j. gehrke, i. timm, o. herzog. a knowledge-based approach to behavior decision in intelligent vehicles. in proceedings of the intelligent vehicles symposium. pp. 466– 471. 2005. [mbkl05] c. j. matheus, k. baclawski, m. m. kokar, j. j. letkowski. using swrl and owl to capture domain knowledge for a situation awareness application applied to a supply logistics scenario. in rules and rule markup languages for the semantic web. volume 3791, pp. 130–144. springer berlin/heidelberg, 2005. [mks00] j. miura, t. kanda, y. shirai. an active vision-system for real-time traffic sign recognition. in proceedings of the 2000 ieee international conference on intelligent transportation systems. pp. 52–57. 2000. 11 / 12 volume 11 (2008) context-aware reasoning for driver assistance [mwks04] k. macek, b. williams, s. kolski, r. siegwart. a lane detection vision module for driver assistance. in proceedings of the ieee mechatronics & robotics conference (mechrob ’04). 2004. [qy02] q.ji, x. yang. real-time eye, gaze, and face pose tracking for monitoring driver vigilance. real-time imaging 8(5):357–377, 2002. [sgh04] a. shashua, y. gdalyahu, g. hayun. pedestrian detection for driving assistance systems: single-frame classification and system level performance. in ieee intelligent vehicles symposium. pp. 1–6. 2004. [sl04] t. strang, c. linnhoff-popien. a context-modeling survey. in first international workshop on advanced context modelling, reasoning and management at ubicomp 2004. 2004. [tfk08] m. toennis, j.-g. fischer, g. klinker. from sensors to assisted driving bridging the gap. journal of software 3(3):71–82, 2008. [wbss] w. wahlster, j. baus, t. schwartz, c. stahl. rena: resource-adaptive navigation. url: http://w5.cs.uni-sb.de/rena/, last access on 03/03/2008. proc. campus 2008 12 / 12 http://w5.cs.uni-sb.de/rena/ introduction related work ontology-based driving scene representation representing uncertain information representing spatio-temporal information representing traffic rules integrating context-information with the reasoning component discussion and implementation of the proposed approach the context-model implementation of the rule base future work conclusions model-level integration of the ocl standard library using a pivot model with generics support electronic communications of the easst volume 9 (2008) proceedings of the workshop ocl4all: modelling systems with ocl at models 2007 model-level integration of the ocl standard library using a pivot model with generics support matthias bräuer and birgit demuth 14 pages guest editors: david h. akehurst, martin gogolla, steffen zschaler managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst model-level integration of the ocl standard library using a pivot model with generics support matthias bräuer1 and birgit demuth2 1 matthias.braeuer@inf.tu-dresden.de 2 birgit.demuth@inf.tu-dresden.de institut für softwareund multimediatechnik technische universität dresden, germany abstract: ocl 2.0 specifies a standard library of predefined types and associated operations. a model-level representation of the library is required to reference its elements within the abstract syntax model created by an ocl parser. existing ocl engines build this model in the implementation code which severely limits reusability, flexibility and maintainability. to address these problems, we show how a common pivot model with explicit support for template types can help to externalize the definition of the standard library and integrate it with instances of arbitrary domain-specific modeling languages. we exemplify the feasibility of our approach with a prototypical implementation for the dresden ocl2 toolkit and present a tailored emf editor for modeling the ocl types and operations. we limit our discussion to the model level, i.e., we do not consider an implementation of the standard library for an execution engine. keywords: ocl, domain-specific languages, generics 1 introduction the object constraint language (ocl) [omg06b] specifies a standard library of types and associated operations. this includes primitive types such as integer or string, collection types like set or bag as well as a number of special types which are important for the ocl type system (oclany, oclvoid, and ocltype). among the predefined operations on these types are arithmetic, boolean and set-theoretic operations. all types in the standard library are instances of abstract syntax classes. these are located one level above the type definitions in the four-layered meta hierarchy of the omg mof architecture [omg06a]. since ocl allows querying of both metamodels and models [sv06, p. 97], the standard types exist either on the m2 or the m1 layer. now, when building the abstract syntax model from a textual ocl expression, an ocl parser needs to have access to the elements of the standard library. this is necessary, for instance, to properly locate operations defined for the implicit supertype oclany or to create user-defined collection and tuple types. existing ocl engines, such as the current release of the dresden ocl2 toolkit [wwwa] or the kent ocl library [wwwb], 1 / 14 volume 9 (2008) mailto:matthias.braeuer@inf.tu-dresden.de mailto:birgit.demuth@inf.tu-dresden.de model-level integration of the ocl standard library usually build an internal representation of the standard library programmatically, e.g, using the api of a model repository. hiding the structure of the standard library inside the implementation code of the engine triggers a number of problems. firstly, the reusability of the library definition is severely impaired, because it is tied to a particular implementation language and platform. thus, porting the ocl engine to another programming language requires an entire rewrite of the code that creates the library. further, the model of the standard library cannot conveniently be validated, altered, extended, or modularized. this is disadvantageous if the underlying execution platform (i.e., an interpreter or code generator) does not support some of the standard library types and operations. in this case, adapting the library definition on the model level by removing the corresponding elements would be helpful. in essence, the flexibility of the “in-code” approach is relatively low. lastly, the implementation of the ocl engine tends to become fairly complex leading to decreased maintainability. for instance, the dresden ocl2 toolkit in its current release contains a helper class with more than 400 lines of code alone to manage the model of the standard library. as an answer to these problems, we propose the novel approach of creating the ocl standard library as an instance of a so-called pivot model, which can be viewed as a “universal language covering a certain domain” [kkk+06]. for example, milanovic et al. [mgg+06] employ the rewerse rule markup language (r2ml) as a “pivotal metamodel” to map between owl/swrl and uml/ocl. in this paper, we define a pivot model as an intermediate metamodel used for aligning the metamodels of arbitrary domain-specific modeling languages (dsl) with that of ocl. by directly supporting generics in this metamodel, modeling all of the template types and operations in the ocl standard library becomes possible. we have implemented this approach using the eclipse modeling framework (emf) [bsm+03] which allowed us to build a highly functional editor for the pivot model and employ emf’s default xmi serialization capabilities. providing the predefined ocl types within an ocl engine therefore reduces to a simple model file import. concrete collection types can be created from the corresponding templates by binding their type parameters with the required element type. the remainder of this paper is structured as follows: in section 2, we briefly review the challenges for a model-level integration of the ocl standard library in the light of two existing ocl engines. we continue by describing the design of a suitable pivotal metamodel addressing these issues in section 3. in section 4, we present a practical evaluation of our approach. we highlight the visual editor used for modeling the standard library and describe an illustrative example. a brief account of related work is provided in section 5. finally, section 6 concludes on our work and shows up further research. 2 background based on observations from two well-known implementations of the ocl standard, namely the dresden ocl2 toolkit and the kent ocl library, we can identify two major challenges for a model-level integration of the standard library in an ocl engine. proc. ocl4all 2007 2 / 14 eceasst in brief, these are: 1. operations and parameters in the standard library instantiate the corresponding metaclasses from the uml metamodel [omg05b]. when ocl is integrated with domain-specific modeling languages developed within so-called language workbenches [fow05] or via uml profiles, we cannot rely on a common format for the library any more. 2. the standard library contains template types and operations that are parameterized with a type parameter. most modeling languages do not support a declarative definition of these generic elements. in the following, we will discuss these two issues in greater detail. 2.1 ocl for domain-specific modeling languages in recent years, the importance of domain-specific languages (dsls) for describing systems has increased and a convergence with model-driven approaches such as the omg mda initiative [omg03a] can be witnessed [bjkv06]. as a result, the original scope of ocl being an add-on to uml [wk03] has widened to support constraints and queries over object-based modeling languages in general [ahm06]. an obvious solution to these new challenges is the introduction of a pivotal metamodel that abstracts over the metamodels of arbitrary domain-specific languages and provides exactly those features required for an integration with ocl. both of our reference ocl engines work this way. the dresden ocl2 toolkit in its current version employs a socalled common model [lo04] to adapt the metamodels of uml 1.5 as well as mof 1.4, while the kent ocl library supports uml 1.4, ecore (the metamodel used by emf), and java via a central bridge model [ap04]. unfortunately, both solutions fail to decouple the model of the ocl standard library from the adapted metamodel. in the dresden ocl2 toolkit, the predefined library operations and their parameters are instances of the corresponding uml or mof metaclasses, while in the kent ocl library they instantiate metamodel-specific adapter classes. both approaches demand a programmatic creation of the standard library types and operations. consequently, to model the standard library externally, we need to find a way to instantiate these elements independently from any adapted metamodel. 2.2 generics in the ocl standard library the predefined collection types in the standard library are actually template types with the type parameter t [omg06b, p. 144]. as an example, consider the sum operation of the ocl collection type whose return parameter is typed with the element type of the collection. we say that a concrete type collection(integer) is created from the template collection(t) by substituting, or binding, t with the type integer. since element types may be nested, there is an infinite number of collection types which have to be dynamically created when parsing a particular ocl expression. 3 / 14 volume 9 (2008) model-level integration of the ocl standard library however, not only types can have type parameters. consider the product operation of collection(t) which returns the cartesian product of two collections and has the signature product(c2:collection(t2)):set(tuple(first:t,second:t2)). note that the return type of this operation not only depends on the binding of the type parameter t, but also on the type of the argument c2. this is an example of a so-called generic operation [bra04]. further note that the return type of the product operation is itself a template type, namely set(t), whose type parameter t is bound with the generic type tuple(first:f, second:s). the actual type of the type parameters f and s is determined at runtime, based on the binding for t and t2, respectively. in this case, we call t and t2 type arguments for the generic tuple type. finally, some of the predefined operations in the library have return types that depend on the object they are invoked on. examples are oclany::asset (returning a singleton set containing the object) and oclany::allinstances (returning the set of all instances of a type). both operations have set(t) as their return type, but the concrete binding for t cannot be determined until the source type of the operation call is known. to remove the definition of the standard library from the implementation code and specify it declaratively, a mechanism to model generic types and operations is required. moreover, the engine needs to support the binding of generic elements at runtime to dynamically create concrete types while parsing an ocl expression. 3 the design of a pivot model with generics support we are currently reengineering the dresden ocl2 toolkit to increase its reusability and flexibility and to provide the foundations for future research into the integration of ocl with arbitrary domain-specific languages. to this end, we have redesigned and reimplemented large parts of the toolkit’s infrastructure [brä07]. the new architecture features a more flexible model repository adaptation mechanism. it is based on a pivot model that results from a careful analysis of previous approaches (cf. subsection 2.1) and the core::basic package of uml 2.0. so far, we have integrated both emf and the netbeans metadata repository [net03] and implemented bindings for ecore, mof and uml. the main elements of the new pivot model are shown in figure 1. a comprehensive discussion of the new architecture is outside the scope of this paper. however, for a better understanding of the following paragraphs we would like to draw attention to one noteworthy feature that sets it apart from existing ocl implementations: a layered architecture now eliminates any dependencies from the pivot model to the ocl metamodel. thus, the support for model-level generics, which we will describe below, is only an enabling technology for modeling the template types in the ocl standard library. all necessary functionality is already contained in the implementation of the pivot model metaclasses and can easily be leveraged for alternative model querying languages. figure 2 summarizes how the pivot model introduces template types and operations as first-class model entities. the design is loosely based on the generics support in emf 2.3 [mp07] which closely mirrors the generic capabilities of java 5 [bra04]. the key idea proc. ocl4all 2007 4 / 14 eceasst namedelement primitivetypeenumerationenumerationliteral 0..1 0..* enumeration 0..1ownedliteral 0..* {ordered} parameter namespace 0..* 0..1 nestednamespace 0..* nestingnamespace 0..1 operation 0..1 0..*operation 0..1 ownedparameter 0..* {ordered} property type 0..1 0..*namespace 0..1 ownedtype 0..* 0..* 0..1 ownedoperation 0..* {ordered} owningtype 0..1 0..* 0..1 ownedproperty 0..* {ordered} owningtype 0..1 0..* supertype 0..* figure 1: the main elements of the pivot model is to introduce a new abstraction called genericelement which classifies elements that may contain one or several typeparameters. namedelement genericelement generictype operation parametergenerictype typeparameter 0..* 1 ownedtypeparameter 0..*genericelement 1 1 typeparameter1 typedelement typeargument complexgenerictype 0..* 1 typeargument 0..* owninggenerictype 1 type unboundtype 1 figure 2: generics in the pivot model the type parameters of a generic element may be bound with a concrete type, which means that all occurrences of the parameter in the definition of the generic element are replaced with this type (figure 3). in the case of a type instance, this will affect all properties and operations (including their parameters) declared for this type. genericelement bindtypeparameter(parameters : sequence, types : sequence) : namedelement figure 3: binding the type parameters of generic elements 5 / 14 volume 9 (2008) model-level integration of the ocl standard library in line with other metamodels, the pivot model generalizes properties, operations and parameters with an abstract metaclass typedelement that declares a reference to a type. now, as illustrated in figure 4, we allow typed elements to alternatively reference a generictype. generic types exist in two flavours (figure 2). a parametergenerictype simply references a typeparameter, as in the case of the return parameter of the sum operation mentioned in subsection 2.2. a complexgenerictype, on the other hand, references another type with unbound type parameters as well as a number of typearguments that will replace the type parameters during binding. in the example of the product operation, the return parameter contains a complex generic type referencing the unbound type tuple(first:f,second:s) and defining two type arguments t and t2. this example shows nicely that type arguments, being typed elements themselves, can have a generic type as well. through this design, an unlimited nesting of generic types becomes possible. generictype typetypedelement 0..10..1 generictype 0..1 0..* 0..10..* type 0..1 0..1 figure 4: typed elements and generic types it turns out that supporting generic types for typed elements does not suffice yet. consider the ocl collection type sequence(t). this template type extends collection(t). intuitively, binding type parameter t of sequence(t) with a concrete type, say string, should result in sequence(string) extending collection(string). yet, the design developed so far does not cover this special case. the key observation here is that the two type parameters t are not the same. in fact, it is perfectly legal to label the type parameter of the sequence type with s instead of t. correctly binding both subtype sequence(s) and supertype collection(t) requires s to be a typeargument of collection(t). this intuition leads to the introduction of a new association between type and generictype denoting the generic supertypes of a type (figure 5). then, binding a type will cause all generic supertypes to be bound as well. if all type parameters of a generic super type are bound (i.e., it is not generic any more), it can be safely added to the regular supertype reference list (cf. figure 1). type generictype 0..*0..1 genericsupertype 0..*0..1 figure 5: generic supertype on a side note, it is worth highlighting that in contrast to emf, our pivot model does not know the notion of a raw type, i.e., a “fallback” type that is assumed to exist for any type parameter in an unbound generic type. this directly stems from the fact that we aimed to avoid any dependencies from the pivot model to the ocl metamodel. otherwise, oclany as the root of the ocl type system would have been a logical proc. ocl4all 2007 6 / 14 eceasst choice. to guarantee proper type conformance checking, we have suitably extended the implementation of the ocl collection metaclasses instead. 4 practical evaluation the previous section presented the design of a pivot model with explicit support for generics. now, we can proceed with showing its application. we have realized the new infrastructure of the dresden ocl2 toolkit as a set of eclipse plug-ins. to create implementation classes for the pivot model elements, we employed the metamodeling and code generation facilities of the eclipse modeling framework. this yielded the following advantages: 1. except for some behavioral features that have to be implemented manually, the pivot model implementation generated by emf is already fully functional and can be instantiated. contrary to previous approaches, we do not depend on an integration with a particular dsl to create an instance of the ocl standard library. by realizing the same interfaces, our standard library model is compatible with any metamodel binding that is created for the pivot model. 2. the xmi serialization capabilities of emf enable us to effectively save and load the standard library which improves reusability. 3. emf can generate a highly customizable tree editor for a metamodel. in the next section, we show how a heavily adapted version of the default pivot model editor allows the user to conveniently view, edit and alter the model of the standard library. 4.1 visually modeling the ocl standard library figure 6 shows the model of the standard library in the adapted pivot model editor. this model, which contains all types and operations defined in the ocl 2.0 specification, is part of the new toolkit infrastructure. users may, however, replace the default library with a modified version when integrating a new domain-specific language with the engine. for instance, if a dsl does not know the concept of an ordered set, the orderedset type can be safely removed from the library model. this ensures that all valid abstract syntax models created by a parser will indeed execute on the domain-specific target platform. the look and feel of the pivot model editor resembles that of the emf ecore editor. however, we have simplified the modeling of generics to hide complexity from the user. when creating typed elements (properties, operations, and parameters), declared type parameters of the containing generic element show up in the list of possible types. the editor automatically creates the necessary parametergenerictype instance in this case. if a template type is selected (e.g., for the c2 parameter of the product operation), a complex generic type and corresponding type arguments are added. similarly, the editor allows to specify the type arguments when extending generic supertypes. 7 / 14 volume 9 (2008) model-level integration of the ocl standard library figure 6: the model of the ocl standard library the root of the model is an instance of a special facade interface called ocllibrary. its definition is outlined in figure 7. the ocllibrary interface provides the necessary means for an ocl parser to retrieve the predefined standard library types when building the abstract syntax model from an ocl expression. proc. ocl4all 2007 8 / 14 eceasst voidtype primitivetype invalidtype typetype anytype collectiontype sequencetype bagtype settype orderedsettype ocllibrary maketupletype(atts : sequence) : tupletype getcollectiontype(elementtype : type) : collectiontype getsequencetype(elementtype : type) : sequencetype getbagtype(elementtype : type) : bagtype getsettype(elementtype : type) : settype getorderedsettype(elementtype : type) : orderedsettype 1 oclvoid 1 1 oclboolean 1 1 oclstring 1 1 oclinteger 1 1 oclreal 1 1 oclinvalid 1 1 ocltype 1 1 oclany 1 1 1 1 1 1 tupletype 0..* oclsequence oclcollection oclbag oclorderedset oclset ocltuple 1 1 1 1 1 0..* figure 7: the facade interface for the ocl standard library types 4.2 binding template types during ocl parsing in the following, we demonstrate the feasibility of our approach with a simple example that involves the binding of generic ocl collection types while parsing an ocl expression. figure 8 depicts the model we will base the example scenario on. name : string /totalbalance : int person id : string balance : int account owner 1 accounts 0..* {ordered} figure 8: the example model now, consider the following ocl expression which specifies the derived attribute totalbalance in class person. note that the second invocation of the dot operator (accessing the property balance of all elements in the accounts reference list) represents an implicit collect iterator. c o n t e x t p e r s o n :: t o t a l b a l a n c e : int d e r i v e : self . a c c o u n t s . balance > sum () parsing this expression triggers the following template type bindings: first, the type of the property call expression referring to accounts is evaluated to be orderedset(account). this directly stems from the multiplicity specification and declared type of the property. the actual binding of the orderedset template with the element type account is facilitated within the getorderedsettype operation of the ocllibrary facade. as shown in 9 / 14 volume 9 (2008) model-level integration of the ocl standard library section 3, this solely requires a call to the bindtypeparameter operation implemented in the type metaclass of the pivot model. similarly, the type of the collect iterator expression, which returns the list of individual balance values, results from binding sequence(t) with integer. the engine automatically maps the domain-specific int type to the corresponding ocl standard library type. as a result, the return type of the sum operation becomes integer. to sum up this discussion, figure 9 shows the abstract syntax model of the example expression as it is visualized in the dsl-agnostic model browser that is part of the new toolkit infrastructure. notice that not only the sequence template has been bound, but also its generic supertype collection(t). figure 9: the abstract syntax model of the example expression it is worth highlighting here that the method presented in this paper solely addresses the static structure of the ocl standard library. to realize the dynamic semantics and actually execute the expression in figure 9, we still rely on an instance-level (m0) implementation of the predefined types and operations. to this end, we have redesigned the existing java library of the dresden ocl2 toolkit to support a flexible integration of arbitrary dsls via a set of factory interfaces. currently, an ocl interpreter based on the new infrastructure is being developed to complement the components on the model level. 5 related work to the best of our knowledge, there is no published work that deals with the modellevel integration of the ocl standard library as described in this paper. akehurst et al. [ahm06] hint at this possibility, but simply suggest to import a uml package containing the standard library types. therefore, they do not address the problems outlined in section 2. however, they propose a mechanism to detach the implementation of the standard library types and operations on the instance level. the ideas from this work may complement our approach and further simplify the integration of different domain-specific languages. another technique that aims at aligning ocl with custom domain-specific languages proc. ocl4all 2007 10 / 14 eceasst on the instance level has been presented in [kpp06b]. unfortunately, the authors employ a custom expression language that is akin but not equal to ocl [kpp06a]. furthermore, they build on top of a model management framework and execution engine which does not support a model-level integration of the standard library. lastly, the latest release of the eclipse mdt ocl project [ecl] features a highly innovative way of integrating ocl with different modeling languages. instead of a pivot model, a generic environment interface defines type parameters for all metamodeling concepts required by ocl. unfortunately, this otherwise elegant approach necessitates a concrete specialization of the entire ocl metamodel as well as the ocl standard library for each custom dsl binding. the predefined operations of the standard types have to be created within the implementation code yielding the disadvantages highlighted in section 1. 6 conclusions and future work in this paper, we have presented a novel technique for integrating the ocl standard library on the model level. contrary to previous approaches, we support a declarative rather than a programmatic definition of the predefined types and operations thereby improving reusability, flexibility, and maintainability. in addition, our method eases the integration of different domain-specific languages with ocl, because the pivot model provides an intermediate abstraction layer for a variety of metamodels. therefore, instantiating elements of the library model is independent of a particular dsl binding and solely requires a suitable implementation of the pivot model interfaces. we have demonstrated the feasibility and usefulness of our approach through an example that was realized using newly developed components of the dresden ocl2 toolkit. we are currently working on porting the tools of the dresden ocl2 toolkit to the new infrastructure. our aim is to leverage the increased flexibility provided by our approach for other ocl-based languages defined by the omg. examples are the query/view/transformation (qvt) [omg05a] language and the upcoming production rule representation (prr) [omg03b] standard. this may open up interesting perspectives for areas as diverse as model transformation and business rule execution. finally, our solution still faces some limitations that are worthwhile to address. for instance, our pivot model currently lacks the expressive power to model the dynamic semantics of iterator expressions for the ocl collection types. in fact, detaching the definition of iterators requires a different approach altogether since the corresponding well-formedness rules for the abstract syntax are currently heavily intertwined with the concrete syntax. similarly, we have not yet found a satisfying answer to the problem of binding generic operations whose return type depends on contextual information (e.g., allinstances and asset in oclany or flatten in the collection types). even though we are able to model the signature of these operations, we still have to check for them explicitly in the code. thus, the implementation of the ocl abstract syntax elements (m2) still contains a few details of the standard library structure (m1). 11 / 14 volume 9 (2008) model-level integration of the ocl standard library acknowledgment: the authors would like to thank florian heidenreich, christian wende and steffen zschaler for their fruitful discussions and contributions to the dresden ocl2 toolkit. bibliography [ahm06] d. akehurst, w. howells, k. mcdonald-maier. uml/ocl – detaching the standard library. in proceedings oclapps 2006: ocl for (meta-) models in multiple application domains, models/uml 2006. pp. 205–212. genova, italy, oct. 2006. [ap04] d. akehurst, o. patrascoiu. ocl 2.0 – implementing the standard for multiple metamodels. electronic notes in theoretical computer science 102:21– 41, 2004. doi:10.1016/j.entcs.2003.09.002 [bjkv06] j. bézivin, f. jouault, i. kurtev, p. valduriez. model-based dsl frameworks. in companion to the 21st annual acm sigplan conference on object-oriented programming, systems, languages, and applications, oopsla 2006. pp. 602–616. acm press, portland, oregon, usa, oct. 2006. [bra04] g. bracha. generics in the java programming language. technical report, sun microsystems, july 2004. http://java.sun.com/j2se/1.5/pdf/ generics-tutorial.pdf. [brä07] m. bräuer. design and prototypical implementation of a pivot model as exchange format for models and metamodels in a qvt/ocl development environment. technical report, technische universität dresden, may 2007. http://dresden-ocl.sourceforge.net/gbbraeuer/ [bsm+03] f. budinsky, d. steinberg, e. merks, r. ellersick, t. j. grose. eclipse modeling framework. eclipse series. addison wesley longman, amsterdam, 1st edition, aug. 2003. [ecl] eclipse.org. model development tools (mdt) ocl component. http:// www.eclipse.org/modeling/mdt/?project=ocl. [fow05] m. fowler. language workbenches: the killer-app for domain specific languages? white paper, june 2005. http://www.martinfowler.com/articles/ languageworkbench.html. [kkk+06] g. kappel, e. kapsammer, h. kargl, g. kramler, t. reiter, w. retschitzegger, w. schwinger, m. wimmer. on models and ontologies a layered approach for model-based tool integration. in mayr and breu (eds.), proceedings of modellierung 2006, gi-edition, lecture notes in informatics, innsbruck, austria, 22-24 march. 2006. proc. ocl4all 2007 12 / 14 http://dx.doi.org/10.1016/j.entcs.2003.09.002 http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf http://dresden-ocl.sourceforge.net/gbbraeuer/ http://www.eclipse.org/modeling/mdt/?project=ocl http://www.eclipse.org/modeling/mdt/?project=ocl http://www.martinfowler.com/articles/languageworkbench.html http://www.martinfowler.com/articles/languageworkbench.html eceasst [kpp06a] d. s. kolovos, r. f. paige, f. a. polack. the epsilon object language (eol). in proceedings european conference in model driven architecture (ec-mda) 2006, bilbao, spain. lncs 4066, pp. 128–142. springer, july 2006. [kpp06b] d. s. kolovos, r. f. paige, f. a. polack. towards using ocl for instancelevel queries in domain specific languages. in proceedings oclapps 2006: ocl for (meta-) models in multiple application domains, models/uml 2006. pp. 26–37. genova, italy, oct. 2006. [lo04] s. loecher, s. ocke. a metamodel-based ocl-compiler for uml and mof. electronic notes in theoretical computer science 102:43–61, 2004. doi:10.1016/j.entcs.2003.09.003 [mgg+06] m. milanovic, d. gašević, a. giurca, g. wagner, v. devedžić. on interchanging between owl/swrl and uml/ocl. in proceedings oclapps 2006: ocl for (meta-) models in multiple application domains, models/uml 2006. pp. 81–95. genova, italy, oct. 2006. [mp07] e. merks, m. paternostro. modeling generics with ecore. in eclipsecon 2007, santa clara, california, usa. mar. 2007. tutorial slides. http://www. eclipsecon.org/2007/index.php?page=sub/&id=3845. [net03] netbeans.org. metadata repository (mdr). 2003. http://mdr.netbeans.org [omg03a] object management group (omg). mda guide version 1.0.1. june 2003. http://www.omg.org/docs/omg/03-06-01.pdf. [omg03b] object management group (omg). production rule representation request for proposal draft 1.0. aug. 2003. http://www.omg.org/docs/formal/06-01-01.pdf [omg05a] object management group (omg). meta object facility (mof) 2.0 query/view/transformation (qvt) specification. nov. 2005. http://www.omg.org/docs/ptc/05-11-01 [omg05b] object management group (omg). unified modeling language: superstructure specification, version 2.0. aug. 2005. http://www.omg.org/docs/formal/05-07-04.pdf [omg06a] object management group (omg). meta object facility (mof) core specification, version 2.0. jan. 2006. http://www.omg.org/docs/formal/06-01-01.pdf [omg06b] object management group (omg). object constraint language, version 2.0. may 2006. http://www.omg.org/docs/formal/06-05-01.pdf 13 / 14 volume 9 (2008) http://dx.doi.org/10.1016/j.entcs.2003.09.003 http://www.eclipsecon.org/2007/index.php?page=sub/&id=3845 http://www.eclipsecon.org/2007/index.php?page=sub/&id=3845 http://mdr.netbeans.org http://www.omg.org/docs/omg/03-06-01.pdf http://www.omg.org/docs/formal/06-01-01.pdf http://www.omg.org/docs/ptc/05-11-01 http://www.omg.org/docs/formal/05-07-04.pdf http://www.omg.org/docs/formal/06-01-01.pdf http://www.omg.org/docs/formal/06-05-01.pdf model-level integration of the ocl standard library [sv06] t. stahl, m. völter. model-driven software development: technology, engineering, management. wiley & sons, 1st edition, 2006. [wk03] j. warmer, a. kleppe. the object constraint language second edition: getting your models ready for mda. object technology series. addisonwesley longman, amsterdam, the netherlands, 2003. [wwwa] dresden ocl toolkit. http://dresden-ocl.sourceforge.net. [wwwb] kent object constraint language library. http://www.cs.kent.ac.uk/ projects/ocl. proc. ocl4all 2007 14 / 14 http://dresden-ocl.sourceforge.net http://www.cs.kent.ac.uk/projects/ocl http://www.cs.kent.ac.uk/projects/ocl introduction background ocl for domain-specific modeling languages generics in the ocl standard library the design of a pivot model with generics support practical evaluation visually modeling the ocl standard library binding template types during ocl parsing related work conclusions and future work a pattern-based approach for initial diagram layout electronic communications of the easst volume 58 (2013) proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gtvmt 2013) a pattern-based approach for initial diagram layout sonja maier and mark minas 14 pages guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst a pattern-based approach for initial diagram layout sonja maier1 and mark minas2 1 sonja.maier@unibw.de 2 mark.minas@unibw.de universität der bundeswehr münchen abstract: in a diagram editor, one can distinguish initial from incremental diagram layout. the former computes a diagram layout from scratch, whereas the latter adjusts an existing layout after diagram modifications. in previous work, we have proposed a pattern-based approach as a solution for incremental diagram layout in visual language editors. each lp encapsulates certain layout behavior. a diagram’s layout is then defined by simultaneously applying several lps to the diagram. this solution has been designed for an interactive environment where the user may select and alter the layout behavior at runtime. this paper describes an extension of this approach that now supports initial diagram layout, too. while the old version only enabled freehand editing, the extended version now supports diagram import and structured editing as well. keywords: layout, diagram editor, freehand & structured editing, diagram import 1 introduction a layout engine usually runs continuously within diagram editors and improves the layout in response to user interaction in real-time. layout improvement includes all sorts of changes concerning the position or shape of diagram components. a powerful and flexible layout engine is needed in order to enable or to improve the usability of different modes of operation, such as freehand editing, structured editing or diagram import. we have developed a pattern-based approach [mm12, mai12], which is tailored to such an interactive environment. layout patterns (lps) allow to encapsulate different kinds of layout algorithms and make them easily reusable for many different types of diagrams. the approach depends on a control algorithm for computing a diagram layout that is determined by different lp instances. with the help of the approach, the complex task of layout computation can be split up into rather small pieces. the layout of a diagram is defined by applying lps to selected sub-diagrams. applying an lp to a sub-diagram means creating an lp instance and binding it to this sub-diagram. the lp instance then contributes to automatic layout, i.e., its layout algorithm adjusts component variables according to the pattern’s specification. we distinguish two modes of operation which can be used simultaneously in the same diagram: automatic application selects lps and sub-diagrams automatically, controlled by the specification of the diagram syntax. for user-controlled application, the editor user selects diagram components that he would like to be arranged according to an lp and applies the corresponding lp to the sub-diagram consisting of this set of components. in a diagram editor, we distinguish different ways, a user can create and modify a diagram. structured editing means that the user uses editing operations that transform correct diagrams 1 / 14 volume 58 (2013) mailto:sonja.maier@unibw.de mailto:mark.minas@unibw.de a pattern-based approach for initial diagram layout figure 1: class diagram editor into other correct diagrams. freehand editing, on the other side, means that the editor user may arrange diagram components on the screen without any restrictions. the third way a user can create a diagram, is importing a diagram from an abstract representation. this mode of operation is called diagram import in the following. we further distinguish initial from incremental (diagram) layout. the former computes a diagram layout from scratch, i.e., without any previous layout information available, whereas the latter adjusts an existing layout after diagram modifications. freehand editing requires incremental layout, whereas diagram import requires initial layout. structured editing requires both initial as well as incremental layout. up to now, the layout approach was used in the context of freehand editing only, and hence it solely supported incremental layout. in order to support initial layout, we extended the approach, mainly by generalizing the control algorithm. in this paper, we show that the slightly adapted approach is useful in the context of diagram import. we further present a small case study, which gives evidence that the approach works well in the context of model refactoring, and, hence, in the context of structured editing. as we will see, although the approach was primarily designed for incremental layout, the adapted version is also useful in the context of initial layout, and even can be utilized for a combination of both. class diagrams (cf. figure 1) are the visual language that serves as a running example in this paper. this visual language is a “real-world” example: the abstract syntax of the visual language is described by a predefined meta-model, the uml2 ecore model [sbpm09]. this meta-model proc. gtvmt 2013 2 / 14 eceasst is more or less aligned with omg’s emof (essential mof), which comprises the essential parts of omg’s mof. mof is a so-called closed meta-modeling architecture, which defines the uml. since class diagrams may contain a huge variety of different components, their ecore model is quite complex. to keep the example simple, only a subset of components is considered in this paper, namely packages, classes, attributes, generalizations and associations. as can be seen in figure 1, these components are visualized as usual. the paper is structured as follows: section 2 discusses related work. the extended patternbased approach is sketched in section 3. section 4 gives details of how to utilize our approach in the context of diagram import as well as in the context of structured editing. section 5 finally concludes the paper. 2 related work design patterns [ghjv95] serve as the formal basis of our pattern-based approach. in vl-eli [sch06], an editor generation framework, patterns are also used as a formal basis. in their approach, tree grammars are used as the basis for specifying visual languages and layout, whereas we use meta-models instead. this design decision was made, because nowadays, meta-models are more widely used than grammars. in contrast to our approach, their approach does not support freehand editing, and provides completely automatic layout only. dunnart [wyb08] is an interactive system for drawing graph-based diagrams. similar to our approach, their approach also has its strengths in the area of incremental layout, and also supports some sort of automatic and user-controlled layout. a variety of layout algorithms exist that are tailored to one specific visual language. most of these special-purpose layout algorithms are designed for completely automatic diagram layout only. in [eig03], for instance, a topology-shapes-metrics approach for the automatic layout of uml class diagrams is presented. in [fsmh10], for instance, automatic layout and structurebased editing of uml diagrams is described. code refactorings are well known in software engineering. in case of class diagrams, the concepts can easily be lifted to models, which leads to model smells as well as model refactorings [lan07]. tools, such as emf refactor [ecl12], enable, amongst others, the application of model refactoring operations. one weakness of such tools is often the integrated layout engine. 3 pattern-based layout approach in the following, an overview of the extended pattern-based approach is given. the approach was described in detail in [mai12]. a brief overview of the approach and its integration into an editor is given in [mm12]. the cornerstones of the approach are the concept of lps and an algorithm that controls the combination of different lps. as shown in figure 2, a diagram is internally represented by a language-specific model (lm), which is an instance of a languagespecific meta-model (lmm). the lmm defines the abstract syntax and aspects of the concrete syntax of the visual language. the current layout of a diagram is represented by the lm, whereas the layout behavior of a diagram editor is defined by a set of lp instances. each lp, in turn, encapsulates certain layout behavior. 3 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout after the user has edited a diagram, the diagram’s lm is automatically created (updated). furthermore, several lp instances are created (updated). based on the lm and the lp instances, the new layout of the diagram is automatically computed, and the diagram is updated accordingly. editor diagram language-specific model (lm) represented by language-specific meta-model (lmm) instance of edge connector pattern lp instance horizontal alignment (top) pattern lp instance lp instance corr. corr. corr. instance of instance of instance of uses figure 2: overview of the approach 3.1 concept of layout patterns (lps) a lp encapsulates certain layout behavior. an example is the edge connector pattern, which ensures that “edges” are correctly connected to “nodes”. another example is the horizontal alignment (top) pattern, which makes sure that a set of “nodes” is horizontally aligned at the top. as can be seen in figure 2, after the user has edited a diagram, several lp instances are created, and a correspondence between the lm and each of these lp instances is established. a lp may be instantiated one or more times for the same diagram. its instantiation is either performed automatically, or it is triggered by the user. for instance, the edge connector pattern is instantiated automatically. for the diagram shown in figure 1, one pattern instance is created for the classes a, b, c, d and e together with the three generalizations and the association. in contrast, the instantiation of the horizontal alignment (top) pattern is triggered by the user. for the diagram shown in figure 1, for instance, two pattern instances could be created one for the classes a and e, and one for the classes b, c and d. we distinguish two different types of lps, namely continuously-applied lps (ca-lps) and temporarily-applied lps (ta-lp). the difference is that ca-lps are continuously applied, whereas ta-lps are applied for a certain time interval. the instantiation of ca-lps is always performed automatically, whereas the instantiation of ta-lps is either performed automatically or it is triggered by the user. in the course of lp instantiation, pattern matching is performed in order to determine the parts of the (sub-)diagram, for which the lp is instantiated. in case of ca-lp and ta-lp instantiation, pattern matching is either performed on the whole diagram or on a sub-diagram. more precisely, pattern matching is performed on the lm that represents the diagram either the whole lm or the part of the lm that corresponds to the sub-diagram. proc. gtvmt 2013 4 / 14 eceasst lp p-constraint predicate associated * rule defined on top of pmm lp instance pm associated * instance of instance of figure 3: layout pattern (lp) a lp (cf. figure 3) is defined on top of a pattern-specific meta-model (pmm). it has one or more associated p-constraints (pattern-constraints), and each p-constraint consists of one predicate, which in turn has one or more associated rules. the predicates of all lp instances present in a diagram assure layout properties of the diagram. the layout of a diagram is correct if all predicates hold. the layout of a diagram is incorrect and needs to be updated if one or more predicates are broken. each rule describes how the layout can be adjusted such that the broken predicate is repaired. the most commonly used types of rules are graph drawing algorithms, constraint-based (layout) algorithms and rule-based (layout) algorithms. rule-based (layout) algorithms were introduced in [mai12], and are specifically tailored to the interactive nature of diagram editors. for instance, the horizontal alignment (top) pattern has the associated predicate c1.y = c2.y. c1 and c2 are two components to be aligned. c1.y is the y-position of the first component, and c2.y is the y-position of the second component. the predicate has the two associated rules c1.y := c2.y and c2.y := c1.y, which are rather trivial. for the example mentioned above, the predicate as well as the associated rules are “instantiated” several times: for the alignment of the classes a and e, they are instantiated for the pair of components {a,e}. for the alignment of the classes b, c and d, they are instantiated for the pairs of components {b,c} and {c,d}. 3.2 control algorithm for pattern combination the control algorithm for pattern combination is essentially a local propagation-based constraint solver that uses backtracking. the idea is that modifications made by the user, i.e., attribute changes because of user activity e.g. moving a class are “propagated” in the diagram. its purpose is to find a valid layout after user modification, and hence, to compute a variable assignment for which all p-constraints (i.e. all predicates) are satisfied. the control algorithm allows for the computation of the layout in the context of freehand editing. the generalized version of the control algorithm now enables the computation in the context of diagram import and structured editing as well. in the generalized version, the markings tocheck and frozen are introduced, which have the following meaning: all p-constraints that involve at least one variable marked as tocheck are potentially violated, and need to be checked by the control algorithm. once a variable is marked as frozen, it may not be changed by the control algorithm anymore. the marking frozen avoids a cyclic behavior, and assures that the control algorithm terminates. backtracking makes sure that the rules are applied in an order that leads to a valid layout, if existent. 5 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout prior to the execution of the control algorithm, some variables are marked as tocheck, and some are marked as tocheck and frozen. the marking depends on the user interaction that triggers the execution of the control algorithm, and will be described in section 4. during the execution of the control algorithm, some additional variables are marked as tocheck and frozen. starting with the variables that were marked as tocheck, all p-constraints are checked that involve these variables. for each violated p-constraint, meaning that the associated predicate is not satisfied, one of the corresponding rules is executed. these rules change one or more variables. all variables that are involved in the layout computation are marked as tocheck and frozen. again, all p-constraints are checked that involve the variables marked as tocheck. this procedure is continued until all p-constraints that need to be checked are satisfied. backtracking is used if necessary. the first result found is chosen and the control algorithm stops immediately. if no solution can be found, the control algorithm signals a failure. in one step, it might be the case that more than one p-constraint needs to be repaired, and hence, more than one rule needs to be executed. for that purpose, the control algorithm determines an ordered list of these p-constraints based on a prioritization scheme, which is defined by the editor developer. furthermore, if a p-constraint is violated, there might be several rules available to “repair” this violation. to do so, the control algorithm determines an ordered list of these rules based on a prioritization scheme, which is also defined by the lp creator. starting with the ordered list of p-constraints and the ordered lists of rules, the rules are tried out by backtracking until the control algorithm terminates either by finding a new assignment satisfying all p-constraints, or by signaling a failure. 3.3 layout in the class diagram editor in the class diagram editor, several lps are available. the application of the following ones is automatically performed: the node overlap removal pattern makes sure that components do not overlap. it is automatically applied to classes and packages on the same level, i.e. inside the same package. the edge connector pattern makes sure that edges are correctly connected. it is automatically applied to classes, together with generalizations and associations. the minimal size component pattern makes sure that components are larger than a minimal size. it is automatically applied to classes as well as packages. the list pattern makes sure that components inside a container are arranged as a list and that they are correctly contained in the container. it is automatically applied to the attributes inside a class. the rectangular containment pattern makes sure that components are correctly nested. it is automatically applied to classes and packages. the application of the following lps is controlled by the user: the layered layout pattern arranges components by the help of a layered layout algorithm. it may be applied to classes together with generalizations. the equal horizontal distance pattern as well as the equal vertical distance pattern make sure that components are placed equally distant to each other. they may be applied to packages and classes. the equal height pattern as well as the equal width pattern make sure that components have the same width or height. they may be applied to classes and packages. the align in a row pattern and the align in a column pattern make sure that components are aligned in a row or in a column. they may be applied to classes and packages. the horizontal alignment pattern and the vertical alignment pattern make sure that components are aligned horizontally or vertically. they may be applied to classes and packages. proc. gtvmt 2013 6 / 14 eceasst 4 diagram import, structured editing & model refactoring as mentioned in section 3, user interactions trigger the execution of the control algorithm. before extending our approach, the control algorithm was executed after the user had performed freehand editing, i.e. after he had created, modified or deleted one or more components. it was also executed after the user had applied a ta-lp to a user-selected set of components. after extending our approach, the control algorithm is now also executed after the user has imported a diagram from an abstract representation, or after the user has performed a structured editing operation. prior to the execution of the control algorithm, some variables are marked as tocheck, and some as tocheck and frozen, depending on one of the following situations: • freehand editing: all variables of all components that are modified by the user are marked as tocheck and frozen. • user applies a ta-lp: all variables of one of the components, the ta-lp is applied to, are marked as tocheck and frozen. this component is (usually) the component that was selected first by the user. all variables of the other components, the ta-lp is applied to, are marked as tocheck. • diagram import: the imported diagram consists of several components. all variables of all these components are marked as tocheck. • structured editing: several components take part in the structured editing operation. all variables of all these components are marked as tocheck. some of them are (optionally) marked as frozen as well. during the execution of the control algorithm, usually only a small subset of p-constraints that are present in the diagram needs to be checked. in case of diagram import, all p-constraints need to be checked, and hence, performance seems to be an issue. but this is only a minor issue, as the control algorithm only needs to be executed once after diagram import. 4.1 diameta architecture the class diagram editor, our running example, was built by the help of diameta [min06], an editor generation framework. an overview of the architecture of a diameta editor is shown in figure 4. the abstract syntax and some aspects of the concrete syntax of the diagram are represented by the graph model. the graph model is internally transformed into the lm, which forms the basis for layout computation. freehand editing operates on the diagram itself, whereas diagram import as well as structured editing both operate on the graph model. after the editor user draws a diagram, the graph model is created on the basis of the diagram. an lmm instance lm is created on the basis of this graph model. based on the lm, all lp instances are created. some of these instances are automatically created, whereas others are created by the editor user. the layout engine gets the lm as well as all lp instances as input and computes the layout. after layout computation, all variable changes are collected, and the diagram is updated. based on the changed diagram, the graph model, and the lm are updated automatically. in the graph model, arrangements of diagram components are described by spatial relationships between them: each diagram component has several attachment areas at which it can be 7 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout diagram graph model lm transformed represented by lp instancelp instance layout engine edits (freehand editing) edits (structured editing & diagram import) creates (ta-lp) creates (ca-lp & ta-lp) updates variable values correspondence input figure 4: integration into diameta (a) diagram (b) graph model figure 5: internal representation of a class diagram connected to other diagram components. in class diagrams, a class, for instance, has its border as attachment area, and an association has its start point and its end point as attachment areas. connections can be established by spatially related attachment areas. in class diagrams, for instance, an association has to start or end at the border of a class in order to be connected to this class. in the graph model, each component is modeled by a node (component node). each attachment area is also modeled by a node (attachment node). edges (attachment edges) connect component nodes with all attachment nodes that belong to this component node. furthermore, edges (relationship edges) connect attachment nodes that are in relationship with each other. figure 5(b) shows the graph model of the diagram shown in figure 5(a). attachment nodes are drawn as black circles, component nodes as gray rectangles, attachment edges as thin black arrows and relationship edges as thick blue arrows. 4.2 diagram import the pattern-based approach was designed for a context in which previous layout information is available. in case of diagram import, no previous layout information is available, which means that an initial layout has to be computed. in order to create an initial layout, the following procedure turned out to be reasonable: all variables are initialized with the value 0, and all instances of all ca-lps are automatically created. in addition, one or more instances of one or more ta-lps are also automatically created. based on the initial values of the variables and all lp instances, the layout engine computes the initial layout as usual. proc. gtvmt 2013 8 / 14 eceasst the diagram import module is specified by the editor developer. the specification consists of two parts: it is defined how the graph model is created from an abstract representation. besides, it is specified which ta-lps are applied to which parts of the diagram. for the diagram that is represented in figure 6(a), all variables are initialized with the value 0. the following instances of ca-lps are automatically created: instances of the minimal size component pattern are created for the sets {a}, {b}, {c}, {d} and {e} of components. an instance of the edge connector pattern is created for the set {a,b,c,d,e,g1,g2,g3,a1} of components. g1 is the generalization between a and b, g2 the one between a and c, g3 the one between a and d, and a1 the association between a and e. an instance of the list pattern is created for the set {a,attribute1,attribute2} of components. in addition, an instance of a talp is also automatically created, namely an instance of the layered layout pattern for the set {a,b,c,d,e,g1,g2,g3} of components. the diagram is arranged as can be seen in figure 6(b). (a) abstract representation (b) initial layout (c) specification figure 6: diagram import discussion in the example presented, the described procedure leads to an acceptable layout. but this may not be the case for other examples. in general, the quality of the produced layout depends on the set of lps that is included in the editor and the specification of the diagram import module, i.e., which ta-lps are additionally applied. the existence of cases in which an unacceptable layout is produced gives evidence that the layout specification is incomplete, and that it should be extended. for instance, in class diagrams, the nesting of packages and classes presents a challenge. an acceptable layout is produced as follows: for each package, one layered layout pattern instance is created. the pattern is applied to all classes and generalizations 9 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout that are contained in this package. pattern matching and lp instantiation is performed as shown in figure 6(c): for each package, all contained classes (match of m1) and all contained generalizations (match of m2) are collected. for this set of components, one layered layout pattern instance is created, where classes play the role node and generalizations the role edge. there might be cases in which it is not possible to compute a valid layout after diagram import. in such a scenario, in the worst case, a diagram import results in a diagram whose layout is incorrect. whether or not such cases exist, again, depends on the set of lps that is included in the editor, and the specification of the diagram import module, i.e., which ta-lps are additionally applied. the existence of cases in which it is impossible to compute a valid layout gives evidence that the layout specification is inconsistent, and should be revised. up to now, we specified a diagram import module for a graph editor as well as a class diagram editor. in both cases, the import of an arbitrary diagram leads to a valid and acceptable layout. this result is promising, but does not give us a guarantee that the described proceeding suffices for other diagram editors as well. a more detailed evaluation is up to future work. 4.3 structured editing & model refactoring structured editing is quite interesting in terms of layout as it requires a combination of initial and incremental layout. in the context of structured editing, in most cases, the application of ca-lps results in a valid and acceptable layout. in some cases, it makes sense to also automatically apply one or more ta-lps to the sub-diagram, the structured editing operation is applied to. structured editing operations are defined by the editor developer. the specification consists of three parts: the structured editing operation itself is defined. besides, it is specified which ta-lps are applied to the sub-diagram, the structured editing operation is applied to. finally, it is defined which variables are marked as frozen prior to the execution of the control algorithm. model refactoring can be considered as structured editing with sophisticated editing operations. in a small case study, several model refactoring operations were defined and integrated into the class diagram editor. the model refactoring operations remove (inline) associated class, remove (inline) superclass, remove (inline) subclass, push up (pull down) attribute, or push up (pull down) method required ca-lps only. in contrast, the model refactoring operations create (extract) associated class, create (extract) superclass, or create (extract) subclass required the automatic application of ta-lps in addition to the application of ca-lps. these were the ones that incorporated the creation of classes and (or) packages. ca-lps only for most model refactoring operations, the automatic creation of all instances of all ca-lps turned out to be sufficient. an example is shown in figure 7(a): the user has selected attribute attribute1 of type int and has chosen the operation pull down attribute. as a consequence, the attribute attribute1 is deleted. three new attributes are added to the classes b, c, and d, all of them with the name attribute1 and the type int, and all of them located at the position (0,0). during layout computation, several instances of several ca-lps are automatically created. amongst others, three instances of the list pattern are created. these instances make sure that the three attributes are located at the “correct” position within their containing classes after layout computation, as shown in figure 7(b). proc. gtvmt 2013 10 / 14 eceasst figure 8(a) shows the graph model of the diagram before the model refactoring operation is performed, and figure 8(b) afterwards, but before the layout is updated. before layout computation, all variables that are shown in the right figure are marked as tocheck. during layout computation, the variables colored in red will be initialized by the layout engine, the variables colored in green will be updated by the layout engine, and the variables colored in black remain unchanged. (a) before (b) after (c) before (d) after figure 7: model refactorings: pull down attribute & create superclass (a) before refactoring (b) after refactoring, before layout computation figure 8: pull down attribute graph model 11 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout ca-lps & ta-lps in certain situations, the automatic creation of all instances of all ca-lps may lead to an unacceptable or invalid layout. to improve this situation, the editor developer, who specifies the structured editing operation, has the possibility to define which ta-lp instances are automatically created. an example is shown in figure 7(c) and figure 7(d): the user has selected class c and has chosen the operation create superclass. that is why the generalization between the classes c and a gets deleted. furthermore, the class x , and the generalizations g1 between x and a and g2 between c and x get created. after creation, the class x is located at the position (0,0) and has the width and height 0. both generalizations start and end at the position (0,0). during layout computation, amongst others, instances of the minimal size component pattern and the edge connector pattern are automatically created. in addition, an instance of a ta-lp is also automatically created, namely an instance of the layered layout pattern for the set {a,x,c,g1,g2} of components. the model refactoring operation together with the lp instantiation is shown in figure 9: the user-selected class is colored orange. one of the rules (r1 or r2) is applied, depending on whether or not a superclass exists. in both cases, one layered layout pattern instance is created. figure 9: create superclass specification to further improve the situation, the editor developer, who specifies a structured editing operation, has the possibility to define which variables are marked as frozen prior to the execution of the control algorithm. for instance, in case of the operation create superclass, all variables of the component that was selected by the user are marked as frozen. in the example, this is class c. as a consequence, this component remains unchanged during layout computation. to improve the situation even more, the definition of the structured editing operation itself can be adapted: in the definition, the editor developer has the possibility to specify which layout information has to be provided by the editor user. for instance, in case of the operation create superclass, the structured editing operation is defined as follows: the user is required to select a class and then choose the operation create superclass. thereafter, the layout engine updates the layout. as an alternative, the user could additionally have to choose the position, the newly created class should (approximately) be placed at. thereafter, the layout engine updates the layout as usual. proc. gtvmt 2013 12 / 14 eceasst discussion in accordance to diagram import, there might be cases in which an unacceptable layout is produced after applying a structured editing operation. the existence of such cases gives evidence that the definition of the structured editing operation is incomplete, and that it should be extended. also in accordance to diagram import, there might even be cases in which it is not possible to compute a valid layout afterwards. the existence of such cases gives evidence that the layout specification is inconsistent, and should be revised. as already described, we specified several structured editing operations in the context of the small case study. the application of these structured editing operations to an arbitrary diagram leads to a valid and acceptable layout. this result is promising, but does not give us a guarantee that the described proceeding suffices for other structured editing operations as well. a more detailed evaluation is up to future work. one interesting finding of the small case study was that the definition of the layout-part of the operations turned out to be straightforward. in contrast, the definition of the operations themselves turned out to be a bit more challenging: as diameta does not focus on structured editing, the transformation language provides basic concepts only. besides, it has some limitations concerning the possible user input. e.g., the selection of an arbitrarily-sized set of components is not supported. another interesting finding was that model refactoring operations require a rather complex user input. e.g., the model refactoring operation extract associated class requires the user to select a class and an arbitrarily-sized set of attributes and methods of this class. 5 future work & conclusions in previous work, we have proposed a pattern-based approach as a solution for incremental layout in visual language editors. in this paper, an extension of this approach was described, which now supports initial layout, too. we showed that our pattern-based approach is also useful in the context of diagram import. furthermore, the case study presented gives evidence that the approach works pretty well in the context of structured editing. with the approach, usually no “perfect” layout is achievable, but an acceptable one. our general-purpose layout approach cannot compete with layout algorithms for diagram import or structured editing that are specifically designed for a visual language. but the nice thing is that layout support for diagram import and structured editing can be provided with very small effort. the usability of our approach in the context of diagram import and structured editing heavily depends on the lps that are integrated in the specific diagram editor. hence, usability can be improved by defining additional lps and including them in the diagram editor, or by slightly adapting one or more of the lps that are already included in the diagram editor. but defining and including more and more lps should not be exaggerated. more lps means that the layout specification is more complex, and that it is more challenging to build a consistent one. furthermore, performance issues potentially arise. our pattern-based approach produces a “nicer” layout in the context of structured editing than in the context of diagram import. one reason for that is that some previous layout information is available in the context of structured editing, while it is not in the context of diagram import. another reason is that the interactivity of a diagram editor can be utilized in the context of structured editing: the user can provide some layout information himself, if required. 13 / 14 volume 58 (2013) a pattern-based approach for initial diagram layout we have included the layout approach in several diametaand gef-editors, and already use it for diagram import as well as structured editing in three of them. besides the authors of this paper, several students helped creating these editors, and experimented with them. this paper reported on the findings of this informal evaluation. a more formal evaluation is up to future work. it would include the creation of several editors, the integration of the layout approach into these editors, and the use of these editors for carefully selected tasks. at the moment, we plan to extend the approach in two different ways: up to now, the layout engine signals a failure if it is not able to compute a valid layout. as an alternative, the layout engine could also compute a partial layout. the choice, which p-constraints are satisfied after layout computation, and which ones are not, is a challenging task. we further plan to create diagram editors that are specifically intended to run on multi-touch enabled devices: multi-touch gestures in combination with our layout approach opens up a variety of new possibilities. bibliography [ecl12] eclipse: emf refactor. http://www.eclipse.org/modeling/. 2012. [eig03] m. eiglsperger. automatic layout of uml class diagrams: a topology-shape-metrics approach. phd thesis, eberhard-karls-universitaet tuebingen, 2003. [fsmh10] h. fuhrmann, m. spoenemann, m. matzen, r. von hanxleden. automatic layout and structure-based editing of uml diagrams. in proceedings of m-bed’10. 2010. [ghjv95] e. gamma, r. helm, r. johnson, j. vlissides. design patterns: elements of reusable object-oriented software. addison-wesley professional, 1995. [lan07] c. lange. assessing and improving the quality of modeling: a series of empirical studies about the uml. phd thesis, technical university eindhoven, 2007. [mai12] s. maier. a pattern-based approach for the combination of different layout algorithms in diagram editors. phd thesis, universitaet der bundeswehr muenchen, 2012. [min06] m. minas. generating meta-model-based freehand editors. in proceedings of grabats’06. volume 1. eceasst, 2006. [mm12] s. maier, m. minas. integration of a pattern-based layout engine into diagram editors. in proceedings of agtive’12. springer-verlag, 2012. [sbpm09] d. steinberg, f. budinsky, m. paternostro, e. merks. emf: eclipse modeling framework 2.0. addison-wesley professional, 2nd edition, 2009. [sch06] c. schmidt. generierung von struktureditoren fuer anspruchsvolle visuelle sprachen. phd thesis, universitaet paderborn, 2006. [wyb08] m. wybrow. using semi-automatic layout to improve the usability of diagramming software. phd thesis, monash university, 2008. proc. gtvmt 2013 14 / 14 introduction related work pattern-based layout approach concept of layout patterns (lps) control algorithm for pattern combination layout in the class diagram editor diagram import, structured editing & model refactoring diameta architecture diagram import structured editing & model refactoring future work & conclusions microsoft word adaptationreasoning_cameraready.doc electronic communications of the easst volume 19 (2009) guest editors: romain rouvoy, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the second international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2009) an adaptation reasoning approach for large scale component-based applications mohammad u. khan, roland reichle, michael wagner, kurt geihs, ulrich scholz, constantinos kakousis, and george a. papadopoulos 12 pages eceasst 2 / 13 volume 19 (2009) an adaptation reasoning approach for large scale component-based applications mohammad u. khan1, roland reichle1, michael wagner1, kurt geihs1, ulrich scholz2, constantinos kakousis3, and george a. papadopoulos3 1university of kassel, germany, {khan, reichle, wagner, geihs}@vs.uni-kassel.de 2european media laboratory gmbh, germany, ulrich.scholz@eml-d.villa-bosch.de 3university of cyprus, cyprus, {kakousis, george}@cs.ucy.ac.cy abstract: there is a growing demand for context-aware applications that can dynamically adapt to their run-time environment. an application offers a collection of functionalities that can be realized through a composition of software components and/or services that are made available at runtime. with the availability of alternative variants of such components and/or services that provide the basic functionalities, while differ in extrafunctional characteristics, characterized by quality of services (qos), an unforeseen number of application variants can be created. the variant that best fits the current context is selected through adaptation reasoning, which can suffer from the processing capabilities of resource-scarce mobile devices, especially when a huge number of application variants needs to be reason about. in this paper, we present a reasoning approach, which provides a meaningful adaptation decision for adaptive applications having a large number of variants within a reasonable time frame. the approach is validated through two arbitrary applications with large number of variants. keywords: self-adaptation, ubiquitous computing, adaptation reasoning, variability, scalability, utility function 1 introduction mobile and ubiquitous computing introduce a growing demand for applications that are able to adapt to dynamically changing execution environments, resources and user preferences. for example, applications may want to react dynamically to fluctuations in network connectivity, battery capacity, appearance of new devices and services, and to a change of user profiles and their choices. such adaptations are handled by automatically choosing a different variant of the application that provides the same basic functionality with a changed quality of service. [1] for component-based applications, with the option of integrating external services, application variants can be created according to a variability model; similar to what is practised by the product-line community [1]. an application is composed of components and/or services, where each component/service can have a number of different variants1. therefore, the total number of application variants is a product of the variants of each of its constituent components. in a ubiquitous computing environment, components and services can appear and disappear at runtime. this fact advocates against a static architecture of the application, which requires that at least one variant of a constituent component must be present. therefore, the architecture of the application can also evolve, with the possibility of using a completely different set (and number) of components and services to realize the application. for such an 1 the details on constructing the variability model are presented in section 2. an adaptation reasoning approach for large scale component-based applications proc. campus 2009 3 / 13 evolving architecture, possible application variants can not be foreseen at design-time. the variability model of creating application variants suffer from the possibility of combinatorial explosion, because in worst case the number of application variants is a product of number of variants of individual components. runtime adaptation involves detecting and keeping track of available components, services and their meta-information, selecting a variant through adaptation reasoning based on the current context and then (re)configuring the composition to realize the selected variant of the application. adaptation reasoning performs the selection of the application variant that fits best to the current context and resource situation. this step suffers the most from the combinatorial explosion, because ideally the fitness of each variant needs to be checked. in the utility function-based approach [3], the fitness is calculated by evaluating utility functions. in our previous work [4], we have presented the concept and methodology for supporting such adaptations. however, test results showed that the adaptation reasoning technique presented at [4] works well only for applications with a limited number of variants; but becomes practically useless for applications, which may offer a huge number of variants. such a reasoning technique requires evaluating not only the utility separately for each application variant; but also property predictors [5] that compute its quality of service requirements and used by the utility evaluation. especially for resource scare mobile devices, such computational effort makes meaningful adaptation infeasible. in this paper, we present a reasoning approach which is stable against combinatorial explosions and thus can provide adaptation reasoning within a meaningful time-frame, even for devices with low computational resources. the rest of the paper is organized as follows: section 2 describes a technique of creating application variants with the help of a simple example. section 3 presents the reasoning approach and section 4 provides some evaluation results for arbitrarily large application architectures. section 5 compares the work with the state of the art and in section 6, the paper is concluded summarizing its achievements and pointing to future works. 2 application variability model the application architecture is created based on a variability model and thus it offers the possibility of creating different variants of the application that differ in extra-functional characteristics. when there is a significant context change, the middleware evaluates and compares all available application variants based on different qos-metadata associated to the involved component realizations. thus we consider applications that are developed with a qos-oriented component model, which defines all reasoning dimensions used by the planningbased middleware to select and deploy the component implementation providing the best utility. the utility of a component utilization is computed using a developer-defined utility function. such utility functions evaluate the fitness of a particular component variant based on the qos-properties required by its realization and that provided by the current context [6]. application conceptual metamodel an application type is viewed as a component type that can have different realizations (figure 1), where an application is such a realization of the application type. the metainformation of a certain realization is described using plans. a component type can be realized by a single component, or by a composition of components, resulting in the concepts of atomic eceasst 4 / 13 volume 19 (2009) and composite component types, respectively. corresponding to the atomic and composite component types, there are two types of plans: atomic realization and composite realization. in addition to the qos-properties, an atomic realization plan describes an atomic component and contains a reference to the class or the data structure that realizes the component. the composite realization plan describes the internal structure of a composite component by specifying the involved component types and the connections between them. figure 1: application concepts and meta-information variation is obtained by describing a set of possible realizations of a component type using plans. in order to create a possible variant, one of the plans of a component type is selected. if the plan is a composite realization plan, it describes a collaboration structure of further component types, which in turn are described by plans. now we proceed by recursively selecting one realizing plan for every involved component type. the recursion stops if an atomic realization plan is chosen. therefore, by resolving the variation points we create application variants that correspond to a certain composition of components depending on the plans that are chosen for each of the component types. with service-based adaptation a part-functionality may be provided through a dynamically discoverable and accessible service. thus, compositional adaptation is extended by taking a service as a possible realization of a component type. to do so, the qos-properties, interfaces, and binding information have to be included in a corresponding plan. service plans are created at runtime, based on the discovery of a service and along with composition and atomic plans, they are also considered during the adaptation reasoning. runtime creation of application variants application types, components, component types and plans are combined together in osgi bundles that are deployed on an adaptation middleware [6]. a distributed environment can include any number of nodes in the middleware domain that are reachable or not due to an adaptation reasoning approach for large scale component-based applications proc. campus 2009 5 / 13 changes in the network. bundles can be deployed on these nodes at any time, such that components, component types, and plans can appear and disappear unpredictably. when a new bundle is deployed on an existing node or on a node entering the domain, the middleware collects the information about the deployed application types, component types, plans and components. references to these component types and plans are stored in respective repositories. the middleware provides the repository service and therefore such repositories can as well be distributed over several nodes. the relation between a component type and a plan is established through their information model. when a node leaves the domain, the bundles deployed on them are removed from the repository, eventually removing the bundle contents like plans, component types etc. thus the middleware keeps an up-to-date trace of all the available component types and plans. another task of the middleware is to discover services that realize different component types, marked as realizable through services. each discovered service has a service description based on which a service plan is created and registered in the plan repository. thus, at runtime the application architecture corresponds to a variability hierarchy containing component types and their realization plans. «appli cationtype» satmo tion «compositi onpl an» onewaycomm unication «compositi onpl an» tw owaycommunication «atomi cplan» offl ine «componenttype» userinterface «componenttype» contr oller «com ponenttype» reco rder «atom icplan» handsf reeui «serviceplan» textmodeui «atom icplan» signaltra cerecord «atomi cplan» recordtrace andcommand «atomicpl an» basicmon itoring «composi tionplan» m onitor ingandc ontrol «com ponenttype» signalm onitor «com ponenttype» computation «atom icplan» normalen v monitor «atomi cpl an» noisyenv monitor «atomicpl an» basicc ommand «atomi cplan» reportan dcommand «servi cepl an» weatherreportgen u1 = f(u(ct11), u(ct12), properties) u2 = f (u(ct21), u(ct22), u(ct23), properties) u3 = f(properties) u(ct11) = u(ct21) = max (u211, u212) u(app) = max (u1, u2, u3) u211 = f(properties) u212 = f(properties) u231 = f(properties) u221 = f(properties) u2211 = f(properties) u2212 = f(properties) u2221 = f(properties) u2222 = f(properties) u2223 = f(properties) u232 = f(properties) u222 = f(u(ct221), u(ct222), properties) u(ct22) = max (u221, u222) u(ct23) = max (u231, u232) u(ct221) = max(u2211, u2212) u(ct222) = max (u2221, u2222, u2223) «compone... userinterface «componen... crosspola rization figure 2 a variability hierarchy consisting of component types and plans eceasst 6 / 13 volume 19 (2009) we illustrate the approach with a simplified version of a proof-of-concept application called satmotion [7]. the purpose of this application is to aid an installer of satellite antennas to align them depending on the network characteristics of the execution environment. the satmotion application can run in a number of different modes. for example, in the two way mode, besides receiving the trace of the antenna signal, it can communicate with a server and send command signals requesting different antenna parameters. in the one way mode, it can only receive the signal trace but cannot send commands to the server. in the offline mode, it can only playback and analyze the recorded signal. the details of the application are beyond the scope of the paper and are not required to understand the variability architecture. figure 2 presents an example of a variability hierarchy for the satmotion application created at runtime, consisting of component types and their realizing plans. these component types and plans may be deployed separately on different nodes as part of different bundles. at runtime, let us consider that the satmotion application type has three realization plans; two of them are composition plans and the other one, the offline realization, is an atomic plan. the onewaycommunication composition plan realizes a variant that has a composition of two component types userinterface and crosspolarization. the first one has two realizing plans; but no plan is available at runtime for the crosspolarization component type. the plan twowaycommunication has a composition specification consisting of three component types, userinterface, recorder and controller. the component types userinterface and recorder have only atomic and service plans, while the controller component type has one atomic plan basicmonitoring and one composition plan monitoringandcontrol. each of the component types signalmonitor and computation has atomic and/or service realization plans. in such a variability hierarchy, an atomic plan or a service plan indicates the bottom level of the variability tree. so, they can be always applied to realize the component type. however, a composition plan is only applicable if each of the component types involved in its composition specification has at least one applicable plan. for example, the onewaycommunication plan is not applicable because there is no plan for the realization of the crosspolarization component type used in its composition. therefore, the application can be realized either using the offline atomic plan or the twowaycommunication plan. being a composition plan, the latter contains a composition of components. the userinterface and the recorder component types have two atomic plans each to choose from, while the controller component type has one atomic plan and one composition plan. such options of alternating plans offer variability in composing an application. 3 runtime reasoning we have developed a middleware to provide the runtime support of adapting the application [6]. the number of application variants (section 0) increases rapidly with the number of component types participating in a composition. though this increase is not prominent for a very simple architecture like that presented in figure 2, it becomes an issue of great concern quite rapidly. for example, a composition plan having 6 different component types, where each of the types has 10 different atomic plans, will have one million (1m = 106) variants for this particular composition plan only. selecting the best-fit variant calculating the utility of each of such variants, resulting from a combinatorial explosion, is a time consuming task and often fails to provide a solution within a reasonable time frame. therefore, we have developed a new reasoning approach, looking at the problem from a different perspective to make it free an adaptation reasoning approach for large scale component-based applications proc. campus 2009 7 / 13 of such combinatorial explosions. we first present the reasoning approach and afterwards, we explain the integration of related aspects like checking resource limits along with reacting on context changes. the reasoning approach a component or a service has a certain utility for a particular context based on its qosproperties. the utility can be evaluated at runtime by a developer defined utility function. an application is composed of components and services. moreover, other properties, like the communication among different components may influence the fitness of a particular component composition. therefore, it is assumed that the utility of the application can depend on the utility of its constituent components as well as such properties. we also assume that a higher utility of a constituent component will contribute to a higher utility for the overall application. in the application variability model (section 2), each atomic realization plan and service plan has a set of qos-property specifications that indicates the quality of service characteristics required from the context and resources for the component or service to be usable. a utility function takes those requirements into account and computes a utility for the realizing plan by comparing them with the context and resource characteristics of the run-time environment. in addition to a utility function, a composite realization plan contains a composition of component types. let us consider that ct = {ct1, ct2, …, ctn} is the set of component types that is involved in a composition c. for all cti ∈ ct, there exist sets a = {a1, a2..., ap}, b = {b1, b2..., bq}, …, n = {n1, n2..., nz} where, ai ∈realization plans of ct1, bi ∈realization plans of ct2, …, ni ∈realization plans of ctn. let us denote the utility of the realization plan ai as uai. the utility of each chosen realization plan for a component type contributes to the overall utility of a particular composition, and eventually the composite realization plan, of which the component type is a part of. if uct(ai) denotes the contribution to utility for the composition when the realization ai is chosen, then it is assumed that (i) uai ≥ uaj ⇒ uct(ai) ≥ uct(aj); ∀ ai , aj∈a the maximum utility available for the realization of a particular component type uct1 is, (ii) uct1 = max (uct(a1), uct(a2), …, uct(ap)) in order to derive the maximum utility of the composition, uc, a function satisfying (i) can be defined as (iii) uc = f(uct1, uct2, …., uctn, uprop) where, uprop is the contribution of properties (non-related to the individual components, rather related to the composition, communication among components etc.) to the utility. in general, the equation (iii) can take any form, given that for each realization plan ai , equation (i) is also maintained. a special case of equation (iii) can be represented as follows: (iv) uc = ∑ = n i 1 wiucti + wn+1uprop eceasst 8 / 13 volume 19 (2009) where, ∑ + = 1 1 n i wi = 1.0 and each wi indicates the relative importance (weight term) of a component type within a composition, as assigned by the developer while specifying the realization plan. in order to illustrate the approach with the help of the example architecture presented in figure 2, let us consider that the qos-properties of the noisyenvmonitor plan are as follows: memory = 100; envnoise = high; networktype = wifi; based on these qos-properties, a utility function can be defined follows: u2212 = 0; if envnoise = low ( ( 1.0; if context.memory ≥ 100 1.0 – (100 – context.memory)/100; otherwise; ) + ( 1.0; if context.networktype = wifi 0.0; if context.networktype = none 0.5; otherwise ) )/2.0; otherwise a runtime value of memory = 90 and networktype = wifi, with a high envnoise will result in a utility value of u2212 = ((1.0 – (100-90)/90) + 1.0)/2.0 = 0.95 u2211 can be calculated similarly according to another function and if u2212>u2211, the noisyenvmonitor plan is chosen for the realization of the signalmonitor component type. then u(ct221) = max(u2211, u2212) = 0.95 the utility for the computation component type, u(ct222) can be computed in the same manner. for this example, let us consider that u(ct222) = 0.8 now, in the simplest case, let us assume that the utility of the monitoringandcontrol plan has a contribution of 50% from u(ct221), 30% from u(ct222) and 20% from its properties. the property contribution can be expressed the same way using a function. let us presume that the value is 0.7. then, u222 = 0.5xu(ct221)+0.3xu(ct222)+0.2x0.7 = 0.5x0.95+0.3x0.8+0.2x0.7 = 0.855 following this approach, the utilities u2 for the twowaycommunication and u3 for the offline plan can be calculated and the one providing the highest utility is selected to run. while realizing the application, the chosen plans at different levels are considered to instantiate the components and/or to bind to the services. it is to be noted that the successful application of the approach depends on a few reasonable assumptions (e.g., equation (i)); but it does not apply to utility functions that violate these an adaptation reasoning approach for large scale component-based applications proc. campus 2009 9 / 13 assumptions. for example, when the utility of a constituent component reduces the overall utility of the composition (though, unlikely) or when the utilities of a component influences the utility of another component in the composition, then the assumption becomes invalid. fitting within the resource constraints in our approach, each running application is allowed to use a certain amount of resources, assigned to it by an underlying middleware or operating system. therefore, the application variant chosen (by applying the reasoning approach of section 0) might not be practically realizable. this problem demands a check of resource constraints of the chosen variant against the runtime availability of the required resources. if such constraints are not met, another variant must be chosen that will probably provide lower utility; but fits within the resource constraints. ideally, resource constraints could be checked for each of the variants before checking for their utilities; but that process would suffer from the combinatorial explosion, which we would like to avoid. therefore, we first find a variant by applying the reasoning approach and then apply a local search mechanism to find a variant that provides a feasible solution satisfying constraints for each of the resources with the minimum sacrifice to the utility. the search is performed once for each of the resources. the target is to use a different variant for the individual components until the resource constraints are met. the first step in the search mechanism is to select the starting point among the chosen components for the application composition. the component that requires the most resource can be a reasonable target, because a second variant of that component would most probably release an appreciable amount of resources, in a way to speed up the search. a second choice would be to start with the least important component so that replacing it with its second best variant would not result in much loss of utility. both of these choices have their pros and cons and a combination of them would suggest using the ratio resource needs to importance as the guiding factor to select the starting point. for the starting component, an alternative is chosen, which consumes less resource than the previously chosen one, while provides the highest utility among the remaining options. for example, in figure 2, if reportandcommand plan (for corresponding component) was initially chosen; but fails in resource constraint, then the one between basiccommand and weatherreportgen provides the higher utility is chosen in this step, given neither of them requires more resource than the reportandcommand plan. if the resource saved because of selecting this new variant is still not sufficient to meet the resource constraint, then we proceed with the next component. for example, we could now replace noisyenvmonitor by normalenvmonitor, if the later requires less resource, though provides a slightly lower utility. the search mechanism also takes into account the cases, where a composite realization plan may appear as an alternative to an atomic realization plan. for example, if the basicmonitoring atomic realization plan were initially chosen; but fails in resource constraint, then the search will consider the monitoringandcontrol composite realization plan to find the best configuration applying the reasoning approach of section 0, given this configuration collectively requires less resource than the component corresponding to the basicmonitoring plan. the approach has the limitation that in extreme cases, we might have to sacrifice utilities in eceasst 10 / 13 volume 19 (2009) great extent; but it helps avoiding the combinatorial explosion and therefore fits well within the reasoning approach. therefore, it will provide a feasible (satisfying architectural and resource constraints) solution, if any, within a time frame acceptable to the user of the application integrating the effect of context changes in order to further improve the adaptation reasoning performance, we selectively reason about composition plans incorporating component types that have been affected by the specific context change which has triggered the current adaptation process. through realization plans each component type explicitly defines its context and resource dependencies. thus, whenever a context change triggers an adaptation, the adaptation reasoner can omit recalculating the utility values for the component types not being associated with the changed context elements. of course, such an optimization technique requires keeping track of the lastly calculated utility score, for each component type or composition plan. this technique will enable evaluation of composition plan utilities, without recalculating utilities of unaffected component types. to illustrate the effect of context-based adaptation reasoning, we provide an example based on the variability hierarchy model depicted in figure 2. for the satmotion application it is reasonable to assume that only the signalmonitor component type is associated with the envnoise context element. thus, a possible context change to the ambient noise level may only affect the utilities of signalmonitor and of its realizing components: normalenvmonitor and noisyenvmonitor. therefore, if we remember the previous utility score for the computation component type, we can evaluate u222 without recalculating u2221, u2222 and u2223. based on the same reasoning, we may skip u221, u231, u232, u211, u212 and u3 (u1 is omitted anyway since onewaycommunication is not applicable) which leads us to a total gain of 69.2 percent (i.e., only 4 out of 13 applicable utility functions were recalculated). advantages of the approach in this approach, the number of times the utility function has to be evaluated corresponds to the number of ‘applicable’ plans. in the simple example of figure 2 we need to evaluate it only for 13 times (the onewaycommunication plan is not applicable), while in the case of the one million variant as mentioned at the start of section 3, we have to evaluate the utility for only 60 times. thus, the approach becomes stable against scalability and more advantageous as the number of variants increases. moreover, our experiences show that the specification of proper utility functions is a big challenge requiring lot of intuition for the developer, especially for the one covering the complete application. however, this task is simplified, if they have to specify utility for individual components. 4 evaluation results the superiority of the proposed evaluation approach is established by the fact that it requires the evaluation of the utility function once for each plan. therefore, with the increase of number of plans in the variability hierarchy, the evaluation time should also increase linearly, unlike the number of possible application variants, which may increase exponentially due to combinatorial explosions. an adaptation reasoning approach for large scale component-based applications proc. campus 2009 11 / 13 the effect is negligible for simple cases like what we have presented in figure 2. therefore, we have tested the scalability effect with two large scale examples; the first one comprises ~2m application variants while a second set up consists of a total of around 15m application variants. please note that these examples are no real life applications and therefore, the used components only helps printing some messages to denote the selected variant. the focus is on the speed of the adaptation reasoning, rather than on the application functionalities. the evaluation results are presented in table 1. the reasoning time on a desktop pc is negligible, while for a mobile device2, it is only a few seconds. more importantly, the reasoning time does not increase drastically, even though there is a huge increase in the possible number of application variants. as a comparison to such numbers, a brute-force reasoning approach, which calculates utility separately for each application variants, takes almost 14 minutes on a desktop pc for the 2m (million) variant example. table 1: evaluation result reasoning time device for 2m variants for 15m variants desktop pc winxp, 3ghz, 1gb ram <20 ms < 20 ms arm 920t device emulator windows mobile 5, 62mb ~ 1 s 1.5 – 2.0 s these results show that this new approach can be applied to reason about the adaptation within an acceptable time, even for large scale applications having a huge number of application variants. this improvement is particularly important where the application architecture can dynamically evolve at runtime, because the availability of new components, component types, realization plans, and services may result in growing the number of possible variants quite rapidly. 5 related work development methodologies, platforms and middleware supporting dynamic adaptation of context-aware applications on mobile computing devices have been studied extensively during the last decade. some early approaches [11] provided support for adaptations foreseen during the design of the application. they usually have only a limited number of adaptation options and therefore, they are easier to handle and usually a policy-based approach [12] for the adaptation decision is sufficient. 2 we have used windows mobile 5 emulator on a laptop to support using phoneme with knopflerfish, which we could not run on a real device having wm 2003. the performance of an emulator depends also on the host device (laptop) and from our experience with wm 2003, emulators usually perform worse than a real device. figure 3 reasoning time on windows mobile emulator eceasst 12 / 13 volume 19 (2009) the complexity is increased when the need for runtime adaptation arises. the policy-based approach becomes inapplicable, because the context and resource situation can not be fully predicted. the utility function-based approach of adaptation decision might be applied in such cases [3][4][13]. as for example, safran [9] is a framework for building self-adaptive, component-based applications that separates the application logic from the adaptation. it is very high level and, in principle, allows for the implementation of techniques similar to distributed utility-based adaptation by allowing each component to decide upon which reconfiguration to operate. in [3], utility functions express service level attributes to dynamically allocate resources in an autonomic data centre system. works like [4] and [13] are predecessors of our work, applied in the same application areas, though they did not provide solutions for taking care of scalabilities. utility-function based adaptation policies get rid of the shortcomings of predicting all adaptation decisions at design-time; however, they introduce the need for evaluating utilities at runtime. one of the shortcomings of the utility-function based solutions of adaptation decision is the scalability [8], especially when they are combined with the variability approach of creating the application architecture. the computation effort may increase exponentially with the number of variation points. some works [8][10] have tried to apply some heuristics in simplifying that computation. however, the computation effort is still not linear with the variation points and the need for property predictors has added to extra computation. the approach presented in this paper can greatly aid the solution to such problems. 6 conclusions adaptations of applications running in a ubiquitous computing environment require an application architecture created through the composition of components and services available at runtime. such an adaptation process involves a number of tasks like retrieving information about components and services, building the application architecture at runtime, reasoning about them and configuring the best-fit composition. in this paper, we have presented an approach that aids adaptation reasoning, which would otherwise suffer from the scalability problem due to the combinatorial explosion of the number of application variants. the presented approach provides a solution for adaptation reasoning, which is stable against the scalability and can be applicable, even when the number of application variants becomes quite huge. the combinatorial explosion is avoided by considering the utilities of each realization plan separately than combining them together to find the complete application variant before reasoning. the superiority of the approach is supported theoretically as well as through practical test cases. it also aids the application developers by easing the process of defining utility functions and qos-properties for their components. the solution also integrates support for checking resource constraints, which have to be dealt with during the reasoning of adaptation. besides, we are currently updating our solution to architectural constraints [7], which would limit choosing among different realization plans by specifying constraints, to fit within this new adaptation reasoning approach. however, the effectiveness of the approach depends on a few assumptions. these assumptions may not be applicable in cases, where the utility of a composition does not positively depend on the utilities of its constituent components. in the future, we are going to investigate more on such cases and improve the solution as necessary. an adaptation reasoning approach for large scale component-based applications proc. campus 2009 13 / 13 7 references [1] sinnema, m., deelstra, s., nijhuis, j., bosch, j., “covamof: a framework for modelling variability in software product families,” proc. third software product line conference, springer, 2004, pp. 197–213. [2] floch, j., hallsteinsen, s., stav, e., eliassen, f., lund d., and gjørven, e. using architecture models for runtime adaptability. ieee software 23(2):62--70, 2006. [3] walsh, w.e., et al. utility functions in autonomic systems. in proceedings of first international conference on autonomic computing (icac'04), pp. 70-77. 2004. [4] geihs, k., barone, p., eliassen, f., floch, j., fricke, r., gjørven, e., hallsteinsen, s., horn, g., khan, m. u., mamelli, a., papadopoulos, g.a., paspallis, n. reichle, r., stav, e., a comprehensive solution for application-level adaptation. journal on software practice and experience, 2009; no. 39; pp. 385 422. [5] brataas, g., floch, j., rouvoy, r., bratskas, p., and papadopoulos, g.a. a basis for performance property prediction of ubiquitous self-adapting systems. in: proceedings of the international workshop on the engineering of software services for pervasive environments (esspe'07), pp. 59–63, dubrovnik, croatia, acm. aicps. 2007. [6] rouvoy, r., barone, p., ding, y., eliassen, f., hallsteinsen, s., lorenzo, j., mamelli, a., and scholz, u. music: middleware support for self-adaptation in ubiquitous and service-oriented environments. chapter in book on software engineering for self-adaptive systems (sefsas), lncs, springer, 19 pages, 2009. accepted for publication. [7] khan, m.u., reichle, r., and geihs, k. architectural constraints in the model-driven development of self-adaptive applications. ieee distributed systems online, vol. 9, no. 7, 2008. [8] scholz, s. and rouvoy, r. divide and conquer organizing component-based adaptation in distributed environments. communications of the easst, 11, 2008. [9] david, p.-c. and ledoux, t. an aspect-oriented approach for developing self-adaptive fractal components. in 5th international symposium on software composition. lncs 3089, pp. 82–97. springer, 2006. [10] alia, m., horn, g., eliassen, f., kahn, m.u., fricke, r., and reichle, r. a component-based planning framework for adaptive systems. the 8th international symposium on distributed objects and applications (doa), oct 30 – nov 1, 2006. montpellier, france. [11] mätzel, k. and schnorf, p. dynamic component adaptation. in ecoop 2002 workshop reader, lncs 2548. springer, 2002. [12] lutfiyya, h., et. al. issues in managing soft qos requirements in distributed systems using a policy-based framework. in proceedings of 2nd international workshop on policies for distributed systems and networks (policy’01). springer, p. 185-201. 2001. [13] rouvoy, r., eliassen, f., floch, j., hallsteinsen, s., and stav, e. composing components and services using a planning-based adaptation middleware. in proceedings of the 7th international symposium on software composition (sc’08), lncs 4954. springer, 2008. understanding how oss development models can influence assessment methods electronic communications of the easst volume 20 (2009) proceedings of the third international workshop on foundations and techniques for open source software certification (opencert 2009) understanding how oss development models can influence assessment methods richard taylor 17 pages guest editors: luis barbosa, antonio cerone, siraj shaikh managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst understanding how oss development models can influence assessment methods richard taylor1 1 rjtaylor@qinetiq.com, http://www.qinetiq.com/ qinetiq ltd. abstract: one of the most important aspects of oss that distinguishes it from cots is both the variety and specific characteristics of the development models used. understanding these development models will be critical to the effective design of assessment approaches. this paper documents the more common development models used by oss projects and explores the complex landscape of stakeholders that these models expose. keywords: eceasst, open source software, assessment methods 1 introduction one of the most important aspects of oss that distinguishes it from cots is both the variety and specific characteristics of the development models used. understanding these development models will be critical to the effective design of assessment approaches. this paper the more common development models used by oss projects and explores the complex landscape of stakeholders that these models expose. for an oss project to be successful, it must attract developers and other contributors. this paper also explores what are the common factors in successful oss projects that attract and retain contributors. the open oss development environments provide many options for innovative assessment metrics. a description of this ’anatomy of oss projects’ is presented as a vehicle to explore the tools and techniques that successful oss projects employ. 2 comparison to cots cots development models are opaque to most of the stakeholders in the cots market place. most software vendors closely guard the details of how they organise their software development activities. in contrast, oss development is conducted in the open. this disparity provides an advantage for understanding oss development. there are likely to be very many different internal organisational patterns for cots developments. these development patterns can affect the through-life properties of the applications that they produce. when assessing the cots applications that are proposed for a system it would be useful to be able to assess the characteristics of the development model that was used in their development. however, in many cases it is not possible to include the development model of a cots application in its assessment because of the secrecy that the closed development model entails. for oss, the ability to explore the 1 / 17 volume 20 (2009) mailto:rjtaylor@qinetiq.com http://www.qinetiq.com/ different approaches to development and the routes by which oss projects find their way into widespread use may help to achieve an accurate assessment. cots development models rarely involve collaborative software development between multiple vendors (there are exceptions to this but they are unusual). in contrast, oss development almost always involves collaborative software development. distributed, collaborative, development requires specific architectural approaches that have an impact on the organisation and processes that oss projects use. assessment approaches may be able to exploit these aspects of oss projects to gain more insight into the projects characteristics than would be possible with closed development models. 3 different models oss projects emerge and develop in many different ways. understanding these different patterns of project evolution can help to explain some of the differing properties that these projects exhibit. the following list characterises a number of lifecycle models that can be observed. the list is not exhaustive but it does provide a reasonable coverage: • over the fence. these projects start their life as conventional cots developments within software companies. at some point (often after a period of normal software sales), the company decides that it is no longer in their interest to continue with development of the application or that the ongoing development would be better served by a different business model. at this point the application license is changed to an oss license; the source code is released and the company walks away (sometimes the company will continue with some low level support for the code base). if there is sufficient interest in the application, a new oss development community can form to continue its development. examples of oss projects that have started in this way include firebird (this was originally the interbase application developed by borland) and firefox (which can trace its development back to the netscape web suite that was released as oss by the netscape corporation). • corporate r&d. these projects are initially developed by the r&d departments of large corporations. at some point, the company has to decide whether to stop work on the research work or to move to full production. in recent years, some companies have chosen oss as a third path for some of their research prototypes. this has been typified by ibm. examples of this are the eclipse rich desktop development platform that started life as an ibm r&d project and derby, an embedded java database that was an ibm product called cloudscape. • escape from academia. many oss projects begin life in academia or some other government sponsored research organisation. the motivations for releasing these projects as oss are varied. often it is because there is no obvious commercial path to exploiting the application. other reasons include: a researchers wish to continue the development of a project after a research grant has completed; a desire to collaborate with other researchers; or a desire to make results available to a wide community. there are a huge number of projects that started in this way, notable examples are: postgresql, a enterprise class relational database system that is based on work started at the university of california and proc. opencert 2009 2 / 17 eceasst the bsd family of unix operating systems. these include freebsd, openbsd and netbsd. the bsd family all derive from the berkeley software distribution (bsd), an early version of unix that was released as oss by the university of california. • from little acorns. these projects often start as small hobbies for a single developer. he (and it almost always is he) releases his work under an oss license in the hope that it might be useful to someone else. over time a group of likeminded people gather around the project and it starts to gain more users. sometimes these projects can grow into very large initiatives. the most widely know example of this type of oss project is the linux kernel. the linux kernel was started as a hobby by linus torvalds in april 1991. in august of the same year he posted a message to an internet news group explaining what he was working on. within a very few years the linux kernel had become one of the three most popular operating systems. • community power. occasionally projects are formed by an existing community to develop a particular application. sometimes this is because someone has an idea that needs a large team to realise it, so they set out to create the team of volunteers from the start. sometimes it is because the wider oss community feels that a particular problem needs to be solved and there is sufficient will to form a large project to tackle it. a good example of this later motivation is the mono project. the mono project was formed to provide an implementation of the microsoft .net platform on the linux operating system. .net was seen as a threat to the continued growth of linux because applications that use .net could not be used on linux. the mono project was specifically formed to address this problem. • start small stay small. the majority of oss projects start as small initiatives by a small group of developers that share a common interest. the applications are small enough that they can be successfully developed and maintained by this small team. these teams might comprise as many as 100 contributors or as few as just a lone developer. typically, they will be around 10 core developers. these projects will often continue to be developed at this level of team size for many years. • community release. some software companies are releasing their source code under an oss license as a means to encourage a community of developers. there are many reasons why this approach might be adopted. a common approach is for the company to retain copyright ownership of the source code (or at least maintain rights to re-license any contributed code). this enables the company to release close source versions that can be charged for along side the oss ”community” releases. examples of this model are widespread including sun microsystems openoffice.org. the organisation of complex software developments is a challenging problem. oss projects are faced with unique issues: internationally distributed developers; complex ipr frameworks; extremely tight fiscal constraints; competing developer motivations and user expectations; etc. it is remarkable that any oss projects are able to thrive at all. as oss projects rely so heavily on volunteer effort (even though many contributors are paid by an employer to work on a project, 3 / 17 volume 20 (2009) the project as no mechanism with which to compel them), those involved must be content with the structure of the decision making process, otherwise they would not continue to contribute. there are almost as many different decision making structures as there are oss projects but a number of common organisational patterns can be observed: • dictatorship. some projects are controlled by a single individual. this is common among the smallest of oss projects but it is also a pattern that works in some of the very largest of projects as well. the linux kernel is a good example: there are discussion forum for each of the sub-systems of the kernel and any changes must be agreed through consensus on these lists first, then there are a small number of senior developers that must be convinced of the merit of the change. however, in the end the final decision lies with linus torvalds. dictatorship projects only thrive when the leader is recognised by all the developers as the main technical lead of the project. • cabal. probably the most common structure is characterised by a small group (usually less than 10) of developers acting as a collective decision making body. entry into the group is controlled; acceptance of a new member usually requires the entrant to demonstrate their commitment and technical competence through regular contributions to the source code. the decision making process within the controlling group differs between projects, some projects have formal voting procedures; others find agreement through informal discussions. • corporate governance. many of the largest oss projects have developed formal governance structures. these typically include marketing organisations, ipr ownership bodies, steering groups etc. many projects have discovered that these structures are required as the number of people involved starts to grow and especially when corporate interests start to get involved. a good example of this is the development of the k desktop environment (kde). kde began as an informal oss project organised along the lines of the cabal model. as the project grew, many of the developers started to voice concerns that their voices were not being heard. the motivation of one of the companies behind part of the project (trolltech, now owned by nokia) was also questioned. to address these concerns and to put the project on a firm footing the project leaders established the kde free qt foundation and the kde e.v (a registered association under german law). similar patterns can be seen in other projects, and the common themes of these organisational structures are discussed further below. • company control. projects that are driven by a single company are often controlled exclusively by that company. these projects often require contributors to assign their copyright over to the company if they wish to submit changes. why would a contributor be prepared to provide a company with such free work? the key to getting contributors to give their effort to such projects lies in the ability of any disgruntled contributor to fork the project. the importance of the ability to fork is covered in more detail below. there are many examples of these company controlled projects; mysql is a well known example. an assessment the whole-life-cost implications of using an oss application as part of a larger system should use knowledge of the development model as a tool in that assessment. modifiaproc. opencert 2009 4 / 17 eceasst bility is an important element of whole-life-cost. the organisational structure of the project will affect the cost of getting changes made. regardless of which organisational model is adopted there are common issues that must be dealt with by all oss projects: • clear ipr ownership. many oss projects choose to leave the copyright ownership with the contributor, others require contributors to assign their copyright to either a not-forprofit body or the company backing the development. whichever approach is used, it is important that it is clear to all contributors exactly where copyright ownership will reside. • rigidly controlled project lifecycle rules: release cycles, testing etc.. all projects live and die by the project lifecycle management. each of the organisational models described above have different decision making structures. all but the very smallest have formal lifecycle management processes. these processes may not always be well documented but they are formal nonetheless. • strong reliance on configuration control tools. at the very heart of just about every oss project is the source control system (scs). the scs provides a technical mechanism for the control of the application lifecycle. it is the touchstone for all the developers on the project. the decision about which scs tool should be used can be extremely contentious. for example, the long running arguments over the use of bitkeeper for the linux kernel became quite divisive and in the end led to the development of a new scs called git. one of the key features of the oss licenses is that they allow the possibility for disaffected developers to ’fork’ the project. a fork is the establishing of a rival project to continue the development of the same source code. a group of developers takes a copy of the projects source code and sets up a new source code repository under a new name. a ’fork’ is often brought about because some developers are unhappy with the organisational model or some technical decisions that a project has adopted. this ability to ’fork’ provides a powerful counter balance to the power of the organisational and technical leaders of a project. many contributors are reassured that their contributions are in safe hands because they can see that if all else fails they can simply carry on development in a new fork of the project. this freedom helps to engender a culture of trust amongst the development team. there is a fine balancing act that needs to be played by any oss development. if the rules of the project, governed by the license regime, enables project ’forking’ then the project organisation must achieve broad consensus on any decisions otherwise the disaffected might simply go off on their own. if the rules of the project do not allow ’forking’ it will not be seen by most developers as an oss project at all and the benefits of collaborative development will be significantly reduced. an assessment of oss projects might use the existent, or otherwise, of forks as a proxy measure for effective organisational management. 4 legal bodies the larger, higher profile, oss projects tend to adopt the corporate governance or company control models. these projects usually create a legal body that holds the ownership of the 5 / 17 volume 20 (2009) source code and provides organizational, legal and financial support. this is usually a not-forprofit organisation but may be a normal commercial company. the legal framework differs depending on which country the body is created in. examples include the eclipse foundation, the gnome foundation and the apache foundation these legal bodies provide a clear separation that makes the motivations of the people involved explicit. the ipr owning body can be a ’not-for-profit’ body or a company. the choice of who owns the ipr makes a clear statement about the intentions of the project. a ’not-for-profit’ body will generally be trusted not to use the ipr ownership for commercial purposes that go against the wishes of the developers. however, if it is a company that retains the ipr ownership, it is clear to everyone that their contributions might be used by that company for commercial gain. both models can be successful. for example, contributions to mysql are owned by mysql ab whereas contributions to gcc are owned by the fsf (a ’not-for-profit’ body). not all large oss projects have an ipr owning body but it is a growing trend in the largest projects. projects that do not have such a body leave the ownership of the code in the hands of whoever wrote each line. for many projects this means that the only way that the license on the code can be changed is to trace the author of each line of code and ask them to agree to the license change. for many projects this is not a practical proposition. the implication of this is that any sizable project that does not have an ipr owning body cannot change its license. oss assessment methods may be able to use the status of ipr ownership as a measure. however, it is not clear how this measure should be interpreted. 5 stakeholders the oss development model has a significantly more complex arrangement of stakeholders when compared to a conventional cots development. the tables and diagrams below show these stakeholders and their relationships to one another. these are the stakeholders as seen from the perspective of those outside of the development itself. if you were inside a cots development, as a developer for instance, you would see many of the stakeholder roles that are present in the oss model. however, these roles are purely internal to the cots development model. the exposure of these roles in oss models may provide opportunities for assessment measures. figure 1 shows a general model of the stakeholder landscape in a typical cots marketplace. table 1 describes each of the cots stakeholder roles. in a conventional cots development model, the stakeholders that would typically seek to apply assessment methods (e.g. cmm) are the integrator and occasionally the end user. the relatively simple stakeholder landscape limits the number of exposed interactions and provides few opportunities for the gathering of direct assessment measures. however, it does have the merit that the interactions between the stakeholders are well understood and clear to all parties. figure 2 shows the complex interactions of the stakeholders in the oss marketplace. this is a general model intended to expose all of the different roles. not all oss projects will have people fulfilling each of these roles. table 3 describes each of the oss stakeholder roles. proc. opencert 2009 6 / 17 eceasst figure 1: cots stakeholders figure 2: oss stakeholders 7 / 17 volume 20 (2009) table 1: cots stakeholders stake holder role / motivation investor provides financial backing to vendor. primarily interested in medium/long term return. will influence vendor to exploit maximum value from cots applications. vendor primary owner of software copyright. motivation is to build a profitable business from the development the cots application. will concentrate on largest / most profitable users needs. developer employed by vendor to develop an application. professionally motivated relationship with project. author authors books about application. often a professional author writing for a large user community. reseller pre-sales support and distribution channel for vendors. profits from margin on application sales price. end user user of application. may provide some feedback to vendor, sometimes via reseller, integrator or user group. rarely has a direct contact with developers. integrator integrates application into larger systems on behalf of clients. often has a large role in providing feedback to vendor. isolates end user from support and integration issues. user group collective voice of end users. sometimes organised and run by the vendor sometimes run as a not-for-profit body by highly motivated end users. lobbies vendors. user group often voices the concerns of end users when the vendor is not looking after existing customers whilst it tries to drive sales to new clients. standards body sets standards that vendors then implement. usually not-for-profit bodies, either independently constituted (e.g. iso, ietf etc.) or run by a consortium of end users. the level of implementation of standards by a vendor is strongly influenced by the strength of the user community. if there is good competition in a market segment and the user community demonstrates its desire for standards compliance, the vendor will often have to comply. where there is a de-facto monopoly or a few large vendors, standards compliance is usually much less. proc. opencert 2009 8 / 17 eceasst table 2: oss stakeholders stake holder role / motivation architect controls the direction of development, lays down overarching structure and guiding principles. often acts as final decision maker. all oss projects have at least one architect. they may also be amongst the most prolific developers but this is not always the case. small projects will typically have just one person who performs this role, larger projects will have architects who control various sub-systems and may well have formalised decision making structures. paid / volunteer developer the developer fulfils the most important role in an oss project. without the developer, there is no code. the majority of developers are motivated by a personal interest in the application or the particular problem that it is trying to solve. the complex motivation of volunteer developers has been addressed by a number of academic studies. many developers are paid for their work by sponsors that wish to influence the direction of development. a good example are developers that work on the linux kernel that are employed by ibm. ibm have a direct interest in the development of the linux kernel because they use it on their own products so they deploy their own employees on the project. it must be presumed that having developers working on the software and respected in the project gives ibm the best chance of influencing the development. 9 / 17 volume 20 (2009) release manager oss projects are often highly distributed. they will frequently have developers working on different continents, on different timescales and these developers have often never met one another. their development work can be sporadic, as volunteer developers find the time to work on tasks. oss projects also often have complex interdependencies with other oss projects. an end user application will depend on many oss libraries, and those libraries will themselves depend on other lower-level libraries and so on. also, as with conventional software development, there is usually the need to maintain multiple lines of development and support beta-testing. large projects usually have people that are dedicated to coordinating this release process. the process happens completely in the open so that anyone can follow what it going on and everyone can see precisely what software makes it into a release. release management has developed in the oss community to be able to deal with these large, complex distributed organisational structures. the competence of the release managers can be a significant feature in the ability of oss projects to scale. documenter project documentation, including web site management is often performed by people that want to contribute to the project but do not have technical programming skills. documentation is seen by many oss projects as vital to expanding their user base. other projects are much less interested in end user documentation. attracting and retaining skilled technical documentation people on oss projects is something that many projects find a challenge. proc. opencert 2009 10 / 17 eceasst standards body these play a slightly different role in many oss projects than they do in a conventional cots environment. oss developers view standards in a different light to conventional vendors. this is primarily because oss projects gain little benefit from locking their users in with nonstandard interfaces. oss developers view standards in one of two ways: either as a means to achieve interoperability with existing applications; or as free design work. the later reason perhaps requires a little explanation. when faced with implementing a new function, an oss developer is generally interested in minimising the amount of work required. if there is a standard already written that explains how to achieve the required functionality it is simpler to implement this standard rather than invest effort in designing an alternative approach. this is coupled with a certain pride in following standards. activist / organiser larger oss projects need people that provide organisation and coordination. these may not necessarily be developers. benefactor there are many organisations that provide support to oss projects. many companies allow their workers to use company infrastructure to work on oss projects and many universities allow their academics and students to do the same. there are also the occasional donors that contribute financial support to an oss project. once example is the google summer of code, this google led initiative funds students during their summer break to work on oss projects. in 2007 this program funded over 900 students to work on more than 130 different oss applications. 11 / 17 volume 20 (2009) tester there are a number of types of testers that typically play a role in oss projects. the current development version of the project is always available to anyone that wishes to try it out. this encourages those that have an interest in the project to experiment with unstable versions and they provide feedback to the developers. many developers start their involvement with a project by test driving development versions and attempting to fix problems that they find. many projects release test versions for formal test cycles and encourage early adopters to report problems before stable releases are made. the people that use these test versions and report problems are vital to the quality of the projects. finally, oss projects rely on their users to report problems and to help with debugging activities. users are often encouraged to be actively involved in the testing process. contributor anybody that provides their time, infrastructure or money to an oss project is a contributor. evangelist oss as a movement has been established by people that feel strongly about the benefits that it brings. some are politically motivated, others are much more pragmatic. some of the growth in oss can be attributed to the evangelism of these people. activists such as richard stallman and eric raymond have travelled widely to educate users, companies and developers. as oss has until recently lacked any significant marketing money, and still cannot compete with the cots vendors in marketing spend, it has relied heavily on individuals to spread the word. translator an increasing number of oss projects are translated into many different languages. for example, abiword has been translated into more than 50 languages. the major oss application frameworks have developed mature infrastructure to support translation of user interfaces. the translations rely on native speakers volunteering to translate all the text used in the user interface. the translators are often users rather than developers. owner the copyright owner of the source code. this may be a company, a not-for-profit body or it may be distributed amongst all the authors of the individual lines of source code. organisations like the fsf will accept copyright ownership of some projects, which can be useful, if project teams do not wish to set up their own not-for-profit body. proc. opencert 2009 12 / 17 eceasst legal resource some organisations offer legal support to oss projects. bodies such as the apache foundation provide legal support for those projects that are part of a specific collective. other bodies like the electronic frontier foundation offer support more broadly. publisher the take-up of oss applications has been helped by the availability of conventional printed technical books. the publishers of these books, such as oreily, have played an important role by supporting authors. these authors are often amongst the lead developers of the projects. author there are many conventional print books that document oss applications. the authors of these books are often developers on the project, but many are professional technical writers. infrastructure provider most oss projects rely heavily on the availability of free infrastructure for source code control, issue tracking, mailing lists etc. a number of organisations provide this infrastructure. for example sourceforge, inc, and berios. the funding model for these services is somewhat difficult to work out. some certainly make some money from carrying advertising and some use the oss infrastructure service as a means of advertising other commercial services. some are simply altruistic and there may be some financing coming from the major commercial players. vendor the vendors (often called distributors), such as redhat inc and novell, provide a conventional shop front for oss technology. they provide integrated collections of packages, documentation and support contracts. vendors relationships with individual oss projects can, at times, be fractious. vendors need to find workable business models to ensure that they stay in business whilst at the same time maintaining the support of the volunteer oss developers. vendors are amongst the most important sponsors and employers of oss developers. integrator integrators work on behalf of customers to integrate oss, as well as cots, into larger systems. integrators generally have sufficient technical resources to be able to tailor oss applications for their customers needs and, if required, to offer tailored support. 13 / 17 volume 20 (2009) end user end users of oss applications are no different from end users of cots applications. however, an oss end user can also choose to play one of the other stakeholder roles. oss projects are often sustained by a steady flow of end users that become interested in the way that the application is developed and contribute as documenters, testers, etc. packager oss projects release source code but end users like the convenience of nicely packaged applications that are precompiled for their chosen operating system. there are a number of different packaging formats in the linux world as well as a different form of packaging for ms windows and for the apple mac. most oss projects do not have the resources to be able to produce all these packages. instead they rely on packagers. sponsor organisations that require particular features to be added to a project may sponsor a developer to make the required changes. the distinction between a sponsor and a benefactor is that a sponsor is providing support for specific business reasons, whereas a benefactor is usually acting in a more philanthropic way. employer many oss developers are supported either explicitly or implicitly by their employers. a recent analysis of changes made in the last year to the linux kernel suggested that as much as 70% came from developers working with at least the tacit support of their employer. the richness of the stakeholders, their motivations and roles they play in the oss development model provides an opportunity for new assessment approaches. by a careful understanding of how each of the stakeholders interacts within a given project, it may be possible to design direct measurements that shed light on its properties. there is a stark contrast with a closed cots development where the limited exposed stakeholder interactions constrains the scope of direct measures. 6 maximising participation oss projects often live and die on their ability to attract participants. maintaining enthusiasm and fostering a collaborative attitude is critical to the success of a collaborative project. studying successful oss projects shows that the following are common amongst those that attract the most developer effort: • good code structure to help people understand the software; proc. opencert 2009 14 / 17 eceasst • low cost of entry to participants i.e. no expensive tools, no closed networks, no complicated signup procedures, extensive use of open source support tools, restricted use of meetings, deskilled build process; • open communication channels, mailing lists, news, irc, web site, wiki; • perception of activity, people more likely to join if project is perceived as dynamic release early, release often, use open communication channels for development discussion; • friendly to newcomers; • many levels of participation user, bug submitter, documenter, translator, occasional bug fixer, coder, architect, etc.; • open requirements. these project characteristics are rare amongst traditional software development projects because there is little need to attract participants. however, they are vital for oss projects and can form the bed rock of an successful assessment approach. 7 anatomy of a project as oss has evolved, it has developed a set of common support technologies that provide an infrastructure to support the distributed collaboration upon which projects depend. these technologies need to provide a mechanism for geographically disparate teams to work closely together both to develop the software and to organise the projects. • web site. most oss projects have a web site. this provides: advertising for the project; documentation; tutorials; download and installation instructions; descriptions of what the project is trying achieve; contact points; and links to other resources. the web site is usually the first point of contact with new users and prospective contributors. • wiki. many projects now also have a project wiki. a wiki is a web site that can be altered by anyone. oss projects use a wiki as an informal repository of discussions, user oriented documentation and a social networking centre for project contributors. • bug/issue tracker. bug/issue trackers are used to capture and record bugs and requested features. bug trackers used to be a feature of only large oss projects but the ready availability of bug tracking software made available by sites such as sourceforge has led to many smaller projects now relying heavily on the bug tracker to help organise development. end users can report bugs directly in to the bug tracker and projects then often have a formal process by which bugs undergo triage before being assigned to a developer. in some projects, it is the developers responsibility to select the bugs that they feel they can address, in others bugs are assigned to developers. bug trackers provide automatic notification mechanisms so that everyone involved can track the lifecycle of a bug with minimum effort. one aspect of oss project bug trackers is that anyone can look at the 15 / 17 volume 20 (2009) current list of bugs / issues. this openness can be hard for some corporate developers to come to terms with. • mailing lists. oss projects frequently have a number of email mailing lists. common lists are ’announce’ (which only carries announcements of releases etc.), ’user’ (which carries discussions between users about how to use the software) and ’developer’ (which carries discussion about development issues including future architectural developments). the mailing lists are often the heart of the oss development. the use of mailing lists for this purpose has grown out of the necessity to deal with discussion between groups of people that cannot meet and are often in different time zones. they have proved to be a very successful means of collaboration, but they do require all participants to be open and be prepared to put their views in writing. this can be a challenge for corporate developers because of the potential legal issues that might arise from inappropriate correspondence. • instant messaging. instant messaging (or chat) has been a feature of oss development long before it became widely used by teenagers and corporate intranets. oss projects often have chat rooms (usually using a chat technology called irc (internet relay chat)). these are used to provide support to users and as a social resource for developers. chat forums between developers help to cement personal relationships because they are much less formal that mailing lists. it helps to engender a sense of community. • source repository. the source code repository is the most important part of an oss project’s infrastructure. it provides the mechanism for multiple developers to work simultaneously on a large software code base. the unique requirements of oss projects have driven the development of a number of source code control technologies in recent years. the source code repository supports the separation of stable and development branches and, can in some cases enable a completely distributed development model that does not even require a central source code repository. as a general principle, anyone can access an oss project’s source code repository; anyone can browse the current state of the development braches or download any previous version of the code base. however, only those authorised by the development team can make changes to the code and all changes are accounted for by the source code repository software. with all these supporting infrastructure components, the objective is to use open, multiplatform, standards. most oss projects have no resources to purchase proprietary products and most contributors will be put off if they have to put their hands in their pockets before they can get involved in the project. the principle is to make the barrier to using or contributing to the project as low as possible. this provides a real opportunity for automated assessment tools. the number of infrastructure applications (e.g. mailing list servers, source code control systems etc) that these would need to work with are small and their interfaces are open. 8 summary oss projects differ from cots projects in their need to effectively manage collaborative development and attract participation in the project. while each project is unique, most oss projects proc. opencert 2009 16 / 17 eceasst tend to fit one of a number of development models with common characteristics. the oss development model has a significantly more complex arrangement of stakeholders when compared to a conventional cots development. many oss projects employ a governing body independent of the code developers. this body, often known as a foundation, is largely responsible for promoting participation in the project and ensuring successful evolution. the foundation provides non-software development activities such as ipr management, marketing, promoting the use of standards, and support for implementation of a consistent, structured development process. to support collaborative development among geographically disparate teams, oss projects typically deploy a standard set of supporting technologies. these include a web site, mailing lists, bug tracking facilities, a wiki and a source code repository. these services are often managed by the projects foundation body. 17 / 17 volume 20 (2009) introduction comparison to cots different models legal bodies stakeholders maximising participation anatomy of a project summary analysis of hypergraph transformation systems in agg based on m-functors electronic communications of the easst volume 58 (2013) proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gtvmt 2013) analysis of hypergraph transformation systems in agg based on m -functors maria maximova, hartmut ehrig and claudia ermel 13 pages guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst analysis of hypergraph transformation systems in agg based on m -functors maria maximova, hartmut ehrig and claudia ermel institut für softwaretechnik und theoretische informatik technische universität berlin, germany mascham@cs.tu-berlin.de, ehrig@cs.tu-berlin.de, claudia.ermel@tu-berlin.de abstract: hypergraph transformation systems are examples of m -adhesive transformation systems based on m -adhesive categories. for typed attributed graph transformation systems, the tool environment agg allows the modelling, the simulation and the analysis of graph transformations. a corresponding tool for analysis of hypergraph transformation systems does not exist up to now. the purpose of this paper is to establish a formal relationship between the corresponding m -adhesive transformation systems, which allows us the translation of hypergraph transformations into typed attributed graph transformations with equivalent behavior, and, vice versa, the creation of hypergraph transformations from typed attributed graph transformations. this formal relationship is based on the general theory of m -functors between different m -adhesive transformation systems. we construct a functor between the m -adhesive categories of hypergraphs and of typed attributed graphs, and show that our construction yields an m -functor with suitable properties. we then use existing results for m -functors to show that analysis results for hypergraph transformation systems can be obtained using agg by analysis of the translated typed attributed graph transformation system. this is shown in general and for a concrete example. keywords: m -adhesive transformation system, graph transformation, hypergraph transformation, m -adhesive category, m -functor, critical pair analysis, agg 1 introduction in the theory of graph transformation, various related approaches exist. hypergraphs have shown to be appropriate e.g. for evaluation of functional expressions since they allow a function with n arguments to be modelled by an hyperedge with one source node and n target nodes [plu93]. other applications are distributed systems [bck02] and diagram representation [min00]. hypergraph transformation is related to algebraic graph transformation [eept06], where structural changes are modelled in the double-pushout (dpo) approach for the category of (typed, attributed) graphs, which has been generalised to m -adhesive categories, relying on a class m of monomorphisms. the dpo approach is a suitable description of transformations leading to results like the local church-rosser, parallelism, concurrency, and local confluence theorems [eept06]. the well-established tool agg [agg12] supports modelling and analysis of (typed, attributed) graph transformation systems. however, up to now there exists no tool support for directly analysing confluence of hypergraph transformation systems. 1 / 13 volume 58 (2013) mailto:mascham@cs.tu-berlin.de mailto:ehrig@cs.tu-berlin.de mailto:claudia.ermel@tu-berlin.de analysis of hypergraph transformation systems based on m -functors in our previous paper [mee11], we have proposed formal criteria ensuring a semantical correspondence of reconfigurable petri nets and their corresponding representations as graph transformation systems. the aim of our previous work was to establish a formal basis allowing us to translate petri net transformations into graph transformations and, vice versa, to create petri net transformations from graph transformations such that the behavior of petri net transformations can be simulated by simulating their translation using the graph transformation tool agg. in [mee11], we established the new framework of m -functors f : (c1,m1)→(c2,m2) between m -adhesive categories. this framework allows to translate transformations in (c1,m1) into corresponding transformations in (c2,m2) and, vice versa, to create transformations in (c1,m1) from those in (c2,m2). building on this previous work, we have extended this framework in [mee12] to allow the analysis of interesting properties like termination, local confluence and functional behavior, in addition to parallel and sequential independence, using the corresponding results and analysis tools like agg for graph transformation systems. hence, in this paper we define an m -functor fhg : (c1,m1) → (c2,m2), where (c1,m1) are hypergraphs and (c2,m2) typed attributed graphs. in our main results, we show that the functor fhg satisfies all the properties required by the general framework to guarantee the transfer, i.e., translation and creation of transformations and local confluence. this allows us in particular to apply the well-known critical pair analysis for typed attributed graph transformations supported by the agg-tool [agg12] to analyse these properties for hypergraph transformations. in contrast to previous instantiations of m -functors in [mee11], we do not have to restrict our functor to injective morphisms. the paper is structured as follows: section 2 introduces the basic notions of m -adhesive transformation systems and m -functors to define a formal relationship between two different m -adhesive categories. in section 3, we construct the functor fhg between hypergraph and typed attributed graph transformation systems, and show that this functor satisfies the properties of m -functors and some additional properties that are required in the general theory. in section 4, we study the f -transfer of local confluence by analysing f -reachable critical pairs and show that the m -functor fhg from section 3 satisfies the required properties. the result is used in section 5 to analyse a hypergraph transformation system using agg on the functorial translation of the system. in section 6, we compare our approach to related work, conclude the paper and give an outlook to future research directions. detailed proofs are given in [mee13]. 2 m -adhesive categories, transformation systems, m -functors in this section we concentrate on some basic concepts and results that are important for our approach and which we review from our previous paper [mee11]. our considerations are based on the framework of m -adhesive categories. an m -adhesive category [egh10], consists of a category c together with a class m of monomorphisms such that the following properties hold: c has pushouts (pos) and pullbacks (pbs) along m -morphisms, m is closed under isomorphisms, composition, decomposition, pos and pbs, and pos along m -morphisms are m -vk-squares (see figure 1), i.e., the vk-property holds for all commutative cubes, where the given po with m ∈ m is in the bottom, the back faces are pbs and all vertical morphisms a,b,c and d are in proc. gtvmt 2013 2 / 13 eceasst m . the vk-property means that the top face is a po iff the front faces are pbs. a b c d a′ b′ c′ d′ m a b c d figure 1: m -vk-square the concept of m -adhesive categories generalises that of adhesive [ls04], adhesive hlr, and weak adhesive hlr categories [eept06]. the categories of typed attributed graphs, hypergraphs and several categories of petri nets are weak adhesive hlr (see [eept06]) and hence also m -adhesive. a set of transformation rules in an m -adhesive category constitutes an m -adhesive transformation system [egh10]. definition 1 (m -adhesive transformation system) given an m -adhesive category (c,m ), an m -adhesive transformation system as = (c,m ,p) has a set p of productions of the form ρ = (l l←− k r−→ r) with l,r ∈m . a direct transformation g ρ,m =⇒h via ρ and match m consists of two pushouts according to the dpo approach [eept06]. we use the notion of an m -functor [mee11] to define a formal relationship between two different m -adhesive transformation systems. definition 2 (m -functor) a functor f : (c1,m1) → (c2,m2) between m -adhesive categories is called m -functor if f (m1)⊆ m2 and f preserves pushouts along m -morphisms. given an m -adhesive transformation system as1 = (c1,m1,p1), we want to translate transformations from as1 to as2 = (c2,m2,p2) with translated productions p2 = f (p1) and, vice versa, we want to create transformations in as1 from the corresponding transformations in as2. this can be handled by theorem 1 below, shown in [mee11]. by definition, each m -functor f : (c1,m1) → (c2,m2) translates each production ρ = (l l← k r→ r) in p1 with l,r ∈ m1 into f (ρ) = (f (l) f (l) ← f (k) f (r) → f (r)) in p2 = f (p1) with f (l),f (r) ∈ m2 and each direct transformation g ρ,m =⇒ h in as1 given by dpo (1)+(2) into a direct transformation f (g) f (ρ),f (m) =⇒ f (h) in as2 given by dpo (3)+(4). l k r g d h (1) = (2) = l r m ⇒ f (l) f (k) f (r) f (g) f (d) f (h) (3) = (4) = f (l) f (r) f (m) vice versa, we say f creates direct transformations, if for each direct transformation f (g) f (ρ),m′ =⇒ h′ in as2 there is a direct transformation g ρ,m =⇒ h in as1 with f (m) = m′ and f (h)∼= h′ leading to f (g) f (ρ),f (m) =⇒ f (h) in as2. in the following, we provide two conditions in order to show creation of direct transformations and transformations, i.e., sequences of direct transformations written g ∗⇒ h. theorem 1 (translation and creation of transformations) each m -functor f : (c1,m1)→ (c2,m2) translates (direct) transformations. vice versa, f creates (direct) transformations if we have the following two conditions: 3 / 13 volume 58 (2013) analysis of hypergraph transformation systems based on m -functors • (f creates morphisms): for all m′ : f (l) → f (g) in (c2,m2), there is exactly one morphism m : l → g with f (m) = m′. • (f preserves initial pushouts): (c1,m1) has initial pushouts and for each initial pushout (1) over m : l → g, also (2) is initial pushout over f (m) in (c2,m2). b (1) l c g b m ⇒ f (b) (2) f (l) f (c) f (g) f (b) f (m) the proof for theorem 1 is given in [mee11]. moreover, it is shown under the same assumptions that f translates and creates parallel and sequential independence of transformations. concerning the definition and the role of initial pushouts for the applicability of productions we refer to [eept06, mee11]. 3 m -functor from hypergraphs to typed attributed graphs our aim is to construct a functor from hypergraphs to typed attributed graphs to be able to analyse hypergraphs by anlysing typed attributed graphs according to the general theory from [mee11] and [mee12]. for this purpose, we review on the one hand the category (hypergraphs,m1) of hypergraphs with the class m1 of all injective hypergraph morphisms, which is shown to be m -adhesive in [eept06]. on the other hand, we review the category of typed attributed graphs (agraphsatg,m2) with the class m2 of all injective typed attributed graph morphisms, which is also shown to be m -adhesive in [eept06], and we define a suitable attributed hypergraph type graph at g = hgt g. moreover, we construct a functor fhg between both categories and show that the general result from theorem 1 is applicable to this functor. definition 3 (category hypergraphs [eept06]) a hypergraph g is defined as g = (vg,eg,sg,tg), where vg is a set of hypergraph nodes, eg is a set of hyperedges and sg,tg : eg →v∗g are functions assigning the string sg(e) of source nodes resp. tg(e) of target nodes to each hyperedge e. consider two hypergraphs g1 = (vg1,eg1,sg1,tg1) and g2 = (vg2,eg2,sg2,tg2). a hypergraph morphism f : g1 → g2 is given by a tuple of functions f = ( fv : vg1 →vg2, fe : eg1 → eg2) such that the diagram to the right commutes with source and target functions, i.e., sg2 ◦ fe = f ∗ v ◦sg1 and tg2 ◦ fe = f ∗ v ◦tg1 , where f ∗ v : v ∗ g1 → v∗g2 with λ 7→ λ and x1 ...xn 7→ fv (x1)... fv (xn). eg1 = v∗g1 eg2 v ∗ g2 sg1 tg1 fe f∗v sg2 tg2 according to [eept06], the category (hypergraphs,m1) of hypergraphs with a class m1 of all injective morphisms is m -adhesive, where pushouts are constructed componentwise. attributed graphs and morphisms between them form the category agraphs, where each object is a pair (g,d) of an e-graph g with signature e (shown to the right) and σ-nat algebra d, where in the following we only use d = tς-nat ∼= nat (with the term algebra tς-nat and the ordinary natural numbers algebra nat ). this means, g is given by eg vg enavdeea sg tg sna tna sea tea g = (v gg ,v g d ,e g g ,e g na,e g ea,(s g j ,t g j ) j∈{g,na,ea} ), where v gg resp. v g d are the graph resp. data proc. gtvmt 2013 4 / 13 eceasst nodes of g, e gg , e g na resp. e g ea are the graph edges resp. node attribute and edge attribute edges of g and sgj , t g j are corresponding source and target functions for the edges. the notion of attributed graphs combined with the typing concept leads to the well-known category of typed attributed graphs agraphsatg, where attributed graphs are typed over an attributed type graph atg [eept06]. here, we consider a specific type graph hgtg to express hypergraphs as typed attributed graphs, which is shown in figure 2. 1 node edge in : nat out : nat n2e num : nat e2n num : nat figure 2: attributed type graph hgtg the meaning of every depicted element of hgtg is as follows: nodes of type node and edge represent hypergraph nodes and hyperedges. edges of types n2e, e2n represent hyperedge tentacles and are attributed by a number num which contains the position of a node in the source (resp. target) string of the considered hyperedge. nodes of type edge have two attributes in and out giving the number of nodes in the preand postdomain of a hyperedge (to ensure the preservation of an edge node’s environment using typed attributed graph morphisms). all node and edge attributes are typed over natural numbers. we consider the category agraphshgtg with fixed data type nat and identical algebra homomorphism, which implies that the vdcomponent of morphisms is the identity. according to [eept06], the category (agraphsatg,m ) is m -adhesive for each type graph at g, where m -morphisms are injective with isomorphic data type part. hence also the special case of (agraphsatg,m ) with at g = hgt g is m -adhesive. the subcategory (agraphshgtg,m2) with identical algebra homomorphism as considered above is also m adhesive for the subclass m = m2 of all injective typed attributed graph morphisms. we are using the m -functor fhg : (hypergraphs,m1) → (agraphshgtg,m2) defined below for the translation of hypergraphs objects and morphisms into the corresponding agraphshgtg objects and morphisms. definition 4 (m -functor fhg : (hypergraphs,m1)→ (agraphshgtg,m2)) consider a hypergraph g = (vg,eg,sg,tg). we define the object fhg(g) = ((g′,nat),type)2 in agraphshgtg with morphism type : (g′,nat)→(hgtg,d f in) and e-graph g′ = (v g ′ g ,v g′ d = n,e g ′ g ,e g′ na,e g′ ea,(s g′ j ,t g′ j ) j∈{g,na,ea} ) as follows: v g ′ g = vg ]eg (graph nodes) e g ′ g = e g′ n2e ]e g′ e2n (graph edges) with e g ′ n2e ={(v,e,n)∈vg ×eg ×n | s n g(e) = v}, e g ′ e2n ={(e,v,n)∈ eg ×vg ×n | t n g(e) = v}, where sng(e) is the n-th node in the string sg(e) and similar for t n g(e), e g ′ na = e g′ in ]e g′ out (node attribute edges) with e g ′ in ={(e,n,in) | (e,n)∈ eg ×n∧|sg(e)|= n}, 1 node and edge attributes are depicted in compact notation as node/edge inscriptions together with their data type. 2 in the following, we also use the short notation fhg(g) = g′. 5 / 13 volume 58 (2013) analysis of hypergraph transformation systems based on m -functors e g ′ out ={(e,n,out) | (e,n)∈ eg ×n∧|tg(e)|= n}, where |w| is the length of w, e g ′ ea = e g′ s ]e g′ t (edge attribute edges) with e g ′ s ={(n,v,e)∈n×vg ×eg | s n g(e) = v}3, e g ′ t ={(n,e,v)∈n×eg ×vg | t n g(e) = v}3, (and the corresponding source and target functions:) sg ′ g ,t g′ g : e g′ g →v g′ g defined by s g′ g (x,y,n) = x, t g′ g (x,y,n) = y, sg ′ na : e g′ na →v g′ g , t g′ na : e g′ na →n defined by s g′ na(e,n,x) = e, t g′ na(e,n,x) = n, sg ′ ea : e g′ ea → e g′ g , t g′ ea : e g′ ea →n defined by s g′ ea(n,x,y) = (x,y,n), t g′ ea(n,x,y) = n. the agraphshgtg-morphism type : (g′,nat)→ (hgtg,d f in) is given by the final morphism of data types from nat to the final algebra d f in and typeg ′ : g′ → hgtg is given by e-graph morphism typeg ′ = (typevg,typevd,typeeg,typeena,typeeea), where each component is mapped to the obvious type in the type graph hgt g, e.g., typevg : v g′ g →v hgtg g with x 7→ node (if x ∈ vg), x 7→ edge (if x ∈ eg). for each hypergraph morphism f : g1 →g2 with f = ( fv : vg1 →vg2, fe : eg1 →eg2), we define fhg( f ) : fhg(g1)→fhg(g2), where in short notation fhg(gi) = (v gig ,n,e gi g ,e gi na,e gi ea, (sgij ,t gi j ) j∈{g,na,ea}) with i ∈{1,2} by fhg( f ) = f ′ = ( f ′vg, f ′ vd = idn, f ′ eg, f ′ ena, f ′ eea) with f ′vg : v g1 g →v g2 g with v gi g = vgi ]egi for i ∈{1,2} by f ′ vg = fv ] fe f ′eg : e g1 g → e g2 g with e gi g = e gi n2e ]e gi e2n for i ∈{1,2} by f ′eg(v,e,n) = ( fv (v), fe(e),n) for (v,e,n)∈ e g1 n2e f ′eg(e,v,n) = ( fe(e), fv (v),n) for (e,v,n)∈ e g1 e2n f ′ena : e g1 na → e g2 na with e gi na = e gi in ]e gi out for i ∈{1,2} by f ′ena(e,n,x) = ( fe(e),n,x) for (e,n,x)∈ e g1 in ]e g1 out ∧ x ∈{in,out} f ′eea : e g1 ea → e g2 ea with e gi ea = e gi s ]e gi t for i ∈{1,2} similar3 to f ′ eg : e g1 g → e g2 g an example for using the functor fhg on objects and morphisms is shown in figure 3, where the typed attributed graphs on the right together with the morphism between them are the translation of the corresponding hypergraphs and the morphism on the left. as usual in the hypergraph notation, only the target nodes of a hyperedge are marked by arrows. note that fhg defined above is a well-defined m -functor in the sense of definition 4. this includes that the components of fhg( f ) are well-defined w.r.t. their codomain and that they are compatible with source and target functions as well as typing morphisms. fhg is a functor, because fhg preserves identities and composition. moreover, fhg is an m -functor, because we have fhg(m1) ⊆ m2, i.e., fhg preserves injectivity of morphisms, and fhg preserves pushouts along m -morphisms (see [mee13]). now we apply the translation and creation of (direct) transformations (see theorem 1) to the m -functor fhg : (hypergraphs,m1) → (agraphshgtg,m2) leading to our new main technical result. 3 where e g ′ s ∼= e g ′ n2e and e g′ t ∼= e g ′ e2n. proc. gtvmt 2013 6 / 13 eceasst v0:node v1:node fhg(g1) e0:edge in=2 out=1 v3:node v4:node e1:edge in=1 out=1 v2:node (v0,e0,1):n2e num=1 (v1,e0,2):n2e num=2 (e0,v3,1):e2n num=1 (v4,e1,1):n2e num=1 (e1,v2,1):e2n num=1 v′0:node v ′ 1,2:node fhg(g2) e′0:edge in=2 out=1 v′3:node v ′ 4:node e′1:edge in=1 out=1 (v′0,e ′ 0,1):n2e num=1 (v′1,2,e ′ 0,2):n2e num=2 (e′0,v ′ 3,1):e2n num=1 (v′4,e ′ 1,1):n2e num=1 (e′1,v ′ 1,2,1):e2n num=1 v′0 v ′ 1,2 e′0 v′3 e′1 v′4 g2 1 2 1 1 1 v0 v1 e0 v3 v4 e1 v2 g1 1 2 1 1 1 fhg fhg(g) g fhg figure 3: applying functor fhg to two hypergraphs and morphism between them theorem 2 (translation and creation of transformations between hypergraphs and typed attributed graphs) the m -functor fhg : (hypergraphs,m1)→ (agraphshgtg,m2) translates and creates direct transformations and transformations. proof idea. according to theorem 1 we have to show that fhg creates morphisms and preserves initial pushouts. 1. (fhg creates morphisms): given a typed attributed graph morphism f ′ : fhg(g1) → fhg(g2), there is a unique hypergraph morphism f : g1 → g2 with fhg( f ) = f ′ defined by f = ( fv , fe) with fv (v) = f ′vg(v) for v ∈ vg1 ⊆ v g1 g and fe(e) = f ′ vg(e) for e ∈ eg1 ⊆v g1 g , where v g1 g = vg1 ]eg1 is the vg-component of fhg(g1). from the morphism property of f ′ we can show that f is a hypergraph morphism with fhg( f ) = f ′ and fhg( f ) = fhg(g) implies f = g and hence uniqueness. the proof is based on the lemma given in [mee13] showing that each typed attributed graph morphism f ′ : fhg(g1) → fhg(g2) is uniquely determined by its vg-component f ′vg : v g1 g →v g2 g . 2. (fhg preserves initial pushouts): preservation of initial pushouts means that (hypergraphs,m1) has initial pushouts, which become also initial pushouts in (agraphshgtg, m2) as defined in [eept06] after application of fhg. the construction of initial pushouts in (hypergraphs,m1) and their preservation is shown in [mee13]. 4 f -transfer of local confluence in this section, we review under which conditions local confluence can be translated by m functor f : (c1,m1)→(c2,m2) from one transformation system as1 = (c1,m1,p) to another 7 / 13 volume 58 (2013) analysis of hypergraph transformation systems based on m -functors one as2 = (c2,m2,f (p)) with translated productions f (p) and, vice versa, under which conditions local confluence of as1 can be created by f from local confluence of as2 (see [mee12]). in this case, we speak of f -transfer of local confluence. according to [eept06], an m -adhesive transformation system (c,m ,p) is locally confluent, if for all direct transformations g ⇒ h1 and g ⇒ h2 there is an object x together with transformations h1 ∗⇒ x and h2 ∗⇒ x . in the case of confluence this property is required for transformations g ∗⇒ h1 and g ∗⇒ h2. in [mee12] it is shown under the assumptions of theorem 1 that as1 is locally confluent for all transformation spans h1 ρ1,m1⇐= g ρ2,m2 =⇒ h2 iff as2 is locally confluent for all translated transformation spans f (h1) f (ρ1),f (m1)⇐= f (g) f (ρ2),f (m2) =⇒ f (h2). a well-known approach for the verification of local confluence is the analysis of critical pairs. a critical pair p1 ρ1,o1⇐= k ρ2,o2 =⇒ p2 is a pair of parallel dependent transformations with a minimal overlapping k of the left-hand sides of the rules. definition 5 (f -reachable critical pair) given an m -functor f : (c1,m1) → (c2,m2). an f -reachable critical pair of productions f (ρ1) and f (ρ2) is a critical pair in as2 of the form f (r1) f (k1) f (l1) f (l2) f (k2) f (r2) f (p1) f (n1) f (k) f (n2) f (p2) f (o1) f (o2) f (l1)f (r1) f (v1)f (w1) f (l2) f (r2) f (w2)f (v2) where all morphisms of type f (a) → f (b) are of the form f ( f ) for some morphism f : a → b. note that for determining f -reachability of a critical pair, it is sufficient to ensure that the overlapping of f (l1) and f (l2) is an f -image [mee12]. for theorem 3 below we require that f : (c1,m1) → (c2,m2) is compatible with pair factorisation. this means, on the one hand, that (ci,mi) has pair factorisation based on ei −mifactorisation for i ∈{1,2}. for (c1,m1) this means that each morphism pair ( f1 : l1 → g, f2 : l2 → g) with common codomain can be decomposed uniquely up to isomorphism as ( f1 = m ◦ e1, f2 = m ◦ e2) with a pair (e1,e2) of jointly epimorphic morphisms and m ∈ m1. on the other hand, it means that f preserves pair factorisation, i.e., for each pair factorisation ( f1 = m◦e1, f2 = m◦e2) in (c1,m1) also (f ( f1) = f (m)◦f (e1),f ( f2) = f (m)◦f (e2)) is a pair factorisation in (c2,m2). furthermore, we use the local confluence theorem [eept06] to analyse whether a given m -adhesive transformation system is locally confluent. this is the case, if all critical pairs p1 ρ1,o1⇐= k ρ2,o2 =⇒ p2 of the given transformation system are strictly confluent. strictness means intuitively that the largest substructure of k that is preserved by the critical pair is also preserved by the merging transformation steps p1 ∗⇒ k′ and p2 ∗⇒ k′ (see the diagram to the right). k p1 p2 k′ ρ1,o1 ρ2,o2 ∗ ∗ proc. gtvmt 2013 8 / 13 eceasst the following theorem 3, with the proof in [mee12], shows that as1 is locally confluent if all f -reachable critical pairs in as2 are strictly confluent. this is important if in as2 critical pairs of typed attributed graph transformation systems have to be considered, because they can be detected automatically using the tool agg. theorem 3 (creation of local confluence based on f -reachable critical pairs) given m -adhesive transformation systems as1 = (c1,m1,p), as2 = (c2, m2, f (p)) and an m -functor f : (c1,m1)→ (c2,m2) that creates (direct) transformations and morphisms (see theorem 1 in section 2) and is compatible with pair factorisation in the sense as discussed before. then, as1 is locally confluent for all transformation spans h1 ρ1,m1⇐= g ρ2,m2 =⇒ h2 if all f -reachable critical pairs of f (ρ1) and f (ρ2) in as2 are strictly confluent. now we apply the results concerning the creation of local confluence based on f -reachable critical pairs to the concrete m -functor fhg : (hypergraphs,m1) → (agraphshgtg,m2). this is our main conceptual result, allowing us to use agg for the analysis of hypergraph transformation systems. theorem 4 (local confluence of hypergraph transformation systems ) consider the m -functor fhg : (hypergraphs,m1)→(agraphshgtg,m2) from definition 4 in section 3. a hypergraph transformation system is locally confluent for all transformation spans h1 ρ1,m1⇐= g ρ2,m2 =⇒ h2 if all fhg-reachable critical pairs of fhg(ρ1) and fhg(ρ2) are strictly confluent. proof idea. in theorem 2 (see section 3), we have shown that fhg : (hypergraphs,m1)→ (agraphshgtg,m2) is an m -functor, which creates (direct) transformations and morphisms. moreover, fhg is compatible with pair factorisation using the e -m -factorisations (e1,m1) in (hypergraphs,m1) and (e2,m2) in (agraphshgtg,m2), where e1 and e2 are the classes of surjective morphisms. in fact, fhg preserves coproducts and we have fhg(e1) ⊆ e2 such that we obtain compatibility of fhg with pair factorisation according to [mee13]. altogether, this allows us to apply theorem 3 with f = fhg. since agraphshgtg is the category of typed attributed graph transformation systems, we can use the tool agg for critical pair analysis, while it is sufficient for our result to consider only fhg-reachable critical pairs (see definition 5 in this section). 5 analysis of hypergraph transformation systems based on agg we consider a simple distributed system with mobility, inspired by [bck02], with servers connected by channels, and processes moving through the network and running on the servers. note that for this example, we use hypergraphs extended by a labelling function for hyperedges. objects in this slightly extended category have the form: g = (vg,eg,sg,tg,lg) with the labelling function lg : eg → a, where a is some alphabet. the corresponding m -functor additionally translates the hyperedge labels into string attributes of the corresponding hyperedge node representation. all properties shown in section 3 and section 4 do also hold for the m -adhesive 9 / 13 volume 58 (2013) analysis of hypergraph transformation systems based on m -functors category of labelled hypergraphs and the extended m -functor fhg.4 in our distributed system model with mobility, servers, connections and processes are represented as labelled hyperedges. the meaning of the hyperedge labels is as follows: p denotes a process before it is executed, s stands for server, and c for connection. a running process is represented by label r. note that, on the one hand, we simplify the network model in [bck02] by disregarding firewalls and secure servers; on the other hand, we allow for connections between three servers modelled by hyperedges with three tentacles, and we distinguish between travelling processes p and running processes r. the hypergraph in figure 4 models a network with four servers, different kinds of connections between them, and two processes. nodes are depicted as black bullets, while hyperedges are represented by labelled rectangles. figure 4: hypergraph defining a network with distributed processes the behaviour of the system is modelled by the hypergraph transformation rules in figure 5. rules enterserver [leaveserver] allow a process to enter [leave] a server location. both rules are inverse to each other (indicated by the double arrow). rules crossc [backc] model the travelling of a process via a connection. we have different rules for process travelling, depending on the kind of connection hyperedge that is crossed. when a process finally has found a suitable server, it switches into the state running by applying the rule runp. a process that has finished its execution is removed from the system by the rule remover. figure 5: hypergraph transformation rules modelling the behaviour of mobile processes 4 note that this holds also for the variants of hypergraphs with labelled nodes and/or labelled hyperedges. proc. gtvmt 2013 10 / 13 eceasst applying the m -functor fhg from definition 4 to this hypergraph transformation system results in a typed attributed graph transformation system that can be statically analysed using agg. figure 6 shows an fhg-reachable critical pair for the application of rules leaveserver and crossc (depicted in the left part) when their left-hand sides overlap as indicated in the overlapping graph in the right part. the conflict (a delete-use conflict) is obviously caused when a process can “choose” either to leave a server location or to cross a connection channel in the network. figure 6: a critical pair detected by agg for the rule pair (leaveserver, crossc) this critical pair is strictly confluent: after applying either rule, we can reverse the effect by applying the corresponding inverse rule and hence have at least one graph which can be derived to join the different results. we can even conclude that the whole transformation system is locally confluent by applying theorem 4, showing strict confluence of all fhg-reachable critical pairs.5 obviously, rules for process travelling can be executed in any order; a step modelling forward travelling and a step modelling the execution of a process can be joined again by performing backward travelling and then executing the process. 6 related work and conclusion in our previous paper [mee11] we have developed a general framework to establish a formal relationship between different m -adhesive transformation systems, showing under which conditions transformations can be translated and created between different m -adhesive transformation systems. this result is based on suitable properties of m -functors between the corresponding m -adhesive categories. in this paper, we construct an m -functor from hypergraphs to typed attributed graphs. we show in our main technical result in theorem 2 (with non-trivial proof in [mee13]) that the functor satisfies the required properties guaranteeing translation and creation of rule applications, as well as the transfer of local confluence. moreover, also termination and functional behavior can be transferred according to [mee12]. this provides us with a general framework to analyse hypergraph transformation systems and allows us by theorem 4 to use 5 note that there are several non-fhg-reachable critical pairs that do not have to be considered according to theorem 4. 11 / 13 volume 58 (2013) analysis of hypergraph transformation systems based on m -functors the critical pair analysis of the agg-tool [agg12] for typed attributed graphs to analyse confluence of hypergraph transformation systems. we demonstrate this by analysing a hypergraph transformation system modelling a distributed system with mobile processes. a related approach to hypergraph analysis considers causal dependencies modelled by approximated unfolding [bck02, bk02]. the thesis of d. plump [plu93] contains already theoretical results about confluence of hypergraph transformation systems, comprising a sufficient condition for local confluence based on critical pairs. but to the best of our knowledge, a tool supporting directly critical pair analysis of hypergraph transformation systems does not yet exist. a suitable automated detection of f -reachable critical pairs would be helpful to reduce the analysis effort, and is subject to future work. furthermore, we will investigate how (nested) application conditions [hp05] can be handled in this framework in order to consider critical pairs and local confluence of m -adhesive transformation systems with (nested) application conditions. references [agg12] tfs-group, tu berlin. agg. 2012. http://www.tfs.tu-berlin.de/agg. [bck02] p. baldan, a. corradini, b. könig. static analysis of distributed systems with mobility specified by graph grammars—a case study. in ehrig et al. (eds.), proc. of int. conf. on integrated design & process technology. sdps, 2002. [bk02] p. baldan, b. könig. approximating the behaviour of graph transformation systems. in int. conf. on graph transformation. pp. 14–29. springer, 2002. lncs 2505. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs in theor. comp. science. springer, 2006. [egh10] h. ehrig, u. golas, f. hermann. categorical frameworks for graph transformation and hlr systems based on the dpo approach. eatcs bulletin 102:111–121, 2010. [hp05] a. habel, k.-h. pennemann. nested constraints and application conditions for highlevel structures. in kreowski et al. (eds.), formal methods in software and systems modeling. lncs 3393, pp. 294–308. springer, 2005. [ls04] s. lack, p. sobociński. adhesive categories. in proc. fossacs’ 04. lncs 2987, pp. 273–288. springer, 2004. [mee11] m. maximova, h. ehrig, c. ermel. formal relationship between petri net and graph transformation systems based on functors between m -adhesive categories. in proc. of 4th workshop on petri nets and graph transformation systems. volume 40. eceasst, 2011. http://journal.ub.tu-berlin.de/index.php/eceasst/issue/archive. [mee12] m. maximova, h. ehrig, c. ermel. transfer of local confluence and termination between petri net and graph transformation systems based on m -functors. in proc. of 5th workshop on petri nets and graph transformation systems. volume 51, pp. 1– 12. eceasst, 2012. http://journal.ub.tu-berlin.de/index.php/eceasst/issue/archive. proc. gtvmt 2013 12 / 13 http://www.tfs.tu-berlin.de/agg http://journal.ub.tu-berlin.de/index.php/eceasst/issue/archive http://journal.ub.tu-berlin.de/index.php/eceasst/issue/archive eceasst [mee13] m. maximova, h. ehrig, c. ermel. analysis of hypergraph transformation systems in agg based on m -functors: extended version. technical report 2013/02, tu berlin, 2013. http://www.eecs.tu-berlin.de/menue/forschung/forschungsberichte/ 2013. [min00] m. minas. hypergraphs as a uniform diagram representation model. in proc. 6th int. workshop on theory and application of graph transformations (tagt’98). lncs 1764, pp. 281–295. springer, 2000. [plu93] d. plump. evaluation of functional expressions by hypergraph rewriting. phd thesis, universität bremen, fachbereich mathematik und informatik, 1993. 13 / 13 volume 58 (2013) http://www.eecs.tu-berlin.de/menue/forschung/forschungsberichte/2013 http://www.eecs.tu-berlin.de/menue/forschung/forschungsberichte/2013 introduction m-adhesive categories, transformation systems, m-functors m-functor from hypergraphs to typed attributed graphs f-transfer of local confluence analysis of hypergraph transformation systems based on agg related work and conclusion mental map and model driven development electronic communications of the easst volume 7 (2007) proceedings of the workshop on the layout of (software) engineering diagrams (led 2007) mental map and model driven development jens von pilgrim 16 pages guest editors: andrew fish, alexander knapp, harald störrle managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst mental map and model driven development jens von pilgrim∗ ∗lehrgebiet software engineering, fernuniversität in hagen jens.vonpilgrim@fernuni-hagen.de abstract: in the case of a model driven development (mdd) approach, source models are transformed into destination models during the development process. this leads to a transformation chain, that is, a sequence of models connected via transformations. while so far usually only the domain models were transformed, we introduce an algorithm here to also transform the notation models, in order to create a diagram based on the layout of a predecessor diagram. we illustrate the algorithm on several examples which are visualized by a full-featured editor displaying 2d diagrams on layers in a 3d space. keywords: mdd, graph drawing, model transformation, mental map 1 introduction in the case of a model driven development (mdd) approach, source models are transformed into destination models (and finally code) during the development process. this leads to a transformation chain, that is, a sequence of models connected via transformations. since these models describe (different) domains of a system they are called domain models. most of these domain models are visualized by diagrams 1, i.e. graph drawings with vertices and edges, such as uml or er diagrams. when a model is displayed by a graphical editor for the first time, some layout algorithm renders the diagram of the model. known layout algorithms place the nodes of a graph using optimization criteria, e.g. reducing edge crossings. these algorithms can be applied to any model which can be interpreted as a graph, since only the structure of the graph is needed in order to draw the graph. when setting up a transformation chain, each model is related to a predecessor model, except for the very first models which are usually created (and drawn) manually. this leads to a problem known from dynamic graph drawing: “the user has built up a so-called ’mental map’ that should be preserved when possible” [bra01]. in dynamic graph drawing only a single diagram is changed. in a transformation chain two diagrams are related to each other. the diagram of a successor model should resemble the previous diagram in order to preserve the mental map. in other words, the “shape” [esml91] of both diagrams should be preserved as far as possible in order to make the user’s orientation easier. when visualizing a domain model, additional graphical information is needed for rendering the model, such as the locations of the nodes to be drawn. usually this graphical information is not part of the domain, i.e. the domain model does not contain this information. this information 1 i will use the term diagram in the following to address the visualization of a model. 1 / 16 volume 7 (2007) mental map and mdd is stored in an extra model, called notation model. 2 using model driven terms, the problem of drawing a graph can be described as setting the properties of a notation model. figure 1 shows the models involved in a transformation chain. . . . ti−1−−−−→ dmi ti−−−−→ dmi+1 ti+1−−−−→ . . .x x . . . nmi nmi+1 . . . figure 1: transformation chain with domain models (dm) and notation models (nm) the first row in figure 1 shows the transformation chain. some domain models dmk are related via transformations tk. additional notation models nmk are used in order to display the domain models. to preserve the structure of a diagram, we have to make use of the information stored in the notation model of the predecessor. therefore, what i suggest here is another transformation tnm mapping the source notation model to a target notation model as shown in figure 2. . . . ti−1−−−−→ dmi ti−−−−→ dmi+1 ti+1−−−−→ . . .x x . . . tnm−−−−→ nmi tnm−−−−→ nmi+1 tnm−−−−→ . . . figure 2: transformation of notation models while different transformations are needed when mapping the domain models, only one transformation is required for mapping any notation model, since they all use the same notation meta model. as we will see later, the notation model must be initialized by a graphical editor, but the layout algorithm itself is independent from the actual diagrams or models. if the layout algorithm introduced here is implemented by a graphical editor, any transformed model can automatically be layouted based on the source diagram without further effort. usually, diagrams in software engineering are drawn as 2d diagrams. one of the most frequently used languages for models is the unified model language (uml), which is also notated using 2d diagrams. displaying 2d diagrams in different editor windows, it is difficult to compare two larger diagrams, since usually only parts of a diagram can be displayed. even when we preserve the “mental map”, the user cannot really see it on screen. we therefor intend to preserve the characteristic of 2d diagrams, but, at the same time, display multiple (2d) diagrams in a single 3d editor. this enables us to show (and edit) several diagrams simultaneously. this paper is organized as follows. in the next section, the used models and their meta models are explained. section 3 introduces an example used later to demonstrate the algorithm. the algorithm itself is explained in section 4. in the following section, a 3d editor is described which was used to implement the demonstration, which is presented in section 6. section 7 describes related work, followed by a conclusion and directions for future work in the last section. 2 sometimes, domain models are also called semantic models, and notation models are called graphical models. in a way notation models are also domain models in the domain of graphical editors. proc. led 2007 2 / 16 eceasst view diagram edge org.eclipse.emf. eobject 0..1element node float: x,y,z location float: width,height, deepth size location 1 * 1 source * 1 target ch ild re n * size 1 ta rg et e dg es so ur ce e dg esparent figure 3: simplified gmf notation model string: rulename trace org.eclipse.emf. eobject 1..nsourceelements targetelements1..n figure 4: simpletrace model 2 models a model is expressed in terms of a model language. in terms of mdd, a model is an instance of a meta model. uml is a standard meta model for domain models. what we need here is a meta model for notation models. in [omg06] such a meta model is described (named “diagram interchange”, short uml-di). with the wide usage of eclipse, graphical editors implemented as eclipse plugins have become very popular. most of these editors are based on the graphical editing framework (gef) [gefa], a framework for drawing 2d diagrams, using a modelview-control (mvc) (e.g. [bmr+96]) architecture. on top of gef, the graphical modeling framework (gmf) [gmf] is built. gmf consists of two components: a generator framework and a runtime library. while the first consists of model-to-text transformations for generating graphical editors based on some given models, the later also includes a notation model. since many graphical editors are not only based on gef but on gmf as well, gmf’s notation meta model is becoming more and more popular. e.g. it is used in a number of commercial uml tools such as ibm rational sotware modeler or gentleware’s apollo, and also in open source projects like the upcoming eclipse uml2 tools. its notation model is implemented using the eclipse modeling framework (emf) [emf]. emf defines a meta model called “ecore”, a java based implementation of the essential meta object facilites (emof) [omg04] 3. emf is widely used. we use emf here for defining all (meta) models. emf models can be transformed using transformation languages such as the atlas transformation language (atl) [atl], which i will use in section 3 when transforming the sample domain models . the notation model used here is a simplified version of gmf’s notation model, its uml class diagram is shown in figure 3. the core of the meta model is a diagram consisting of nodes and edges. it is not a simple graph though, since nodes can contain other nodes, and edges can connect nodes or edges. as in the gmf, domain and notation model are based on emf. hence, all classes are derived from emf’s eobject class. the link between the notation model and 3 emof is a specification for defining meta models in the context of model driven architecture (mda) [omg03], the omg version of mdd. 3 / 16 volume 7 (2007) mental map and mdd the client specific domain model is implemented via the association element. this association is directed from notation model to domain model. that is, the notation model is dependent on the domain model and not vice versa. this requires a little bit more effort when transforming the notation, as we have to use a reverse lookup to find a notation element by a given notation element. when transforming a (source) model into a (target) model, elements of the source model are mapped to elements of the target model. these mappings are called traces. in mdd “everything is a model” [béz05]. thus traces are a model, too. in [omg05], a meta model for traces, called transformation record, is defined. hence, there may be a standard for traces in the near future using this model. we define a simpler trace meta model here as shown in figure 4. in figure 2 transformations tk “connected” the domain models. while a transformation is a process, a trace are the result of this process. after the transformation has been executed, a trace connects source model elements with target model elements. a transformation usually consists of rules. each rule maps a defined set of source elements to target elements. therefore, we can not only store the model elements but also the name of the rule mapping these elements. note that we need these traces when transforming the notation, i.e. we need traces of the domain model transformation. unfortunately, atl does not create a trace model automatically, but it is easy to implement a transformation which creates traces. trace generation capabilities can even be added automatically to an atl transformation as described in [jou05]. the trace meta model described in [jou05] is very similar to the model we are using here. 3 robustness diagram example to give you an impression of the technology on top of which the layout algorithm works, we present here the example which is used in section 6 to demonstrate the algorithm. we use some kind of robustness analysis diagram [rs99, jac92] as an example. it is a well known transformation which was used even before mdd has been invented. it maps use cases and actors to classes, which are marked with different stereotypes (control, boundary and entity). it is used to bridge the gap between requirements models such as use case models and design models (usually class diagrams). in order to transform a domain model we need a meta model. for illustration purposes we use a simplified version of uml as shown in figure 5. package classifier string: name namedelement association class actorusecase content * * 1 * 1 so ur ce a ss oc ia tio ns target source ta rg et a ss oc ia tio ns parent0..1 org.eclipse.emf. eobject figure 5: simplified uml meta model (simpleuml) proc. led 2007 4 / 16 eceasst 1 r u l e u s e c a s e 2 c l a s s { 2 from 3 u s e c a s e : s i m p l e u m l ! u s e c a s e 4 t o 5 c t r l : s i m p l e u m l ! c l a s s ( 6 name <− u s e c a s e . name + ’c’ , 7 s t e r e o t y p e <− ’control’ 8 ) , 9 b o u n d a r y : s i m p l e u m l ! c l a s s ( 10 name <− u s e c a s e . name + ’b’ , 11 s t e r e o t y p e <− ’boundary’ 12 ) , 13 a s s o c c t r l b o u n d a r y : s i m p l e u m l ! a s s o c i a t i o n ( 14 s o u r c e <− b o u n d a r y , 15 t a r g e t <− c t r l 16 ) , 17 t r a c e : s i m p l e t r a c e ! t r a c e ( 18 r u l e n a m e <− ’usecase2class’ , 19 t a r g e t e l e m e n t s <− s e q u e n c e { c t r l , b o u n d a r y , a s s o c c t r l b o u n d a r y } 20 ) 21 do { 22 t r a c e . r e f s e t v a l u e ( ’sourceelements’ , s e q u e n c e { u s e c a s e } ) ; 23 24 −− c o n t r o l l e r ’ s p a r e n t i s s e t i n f i r s t r u l e 25 b o u n d a r y . p a r e n t <− t h i s m o d u l e . r e s o l v e t e m p ( u s e c a s e . p a r e n t , 26 ’package_classes’ ) ; 27 a s s o c c t r l b o u n d a r y . p a r e n t <− t h i s m o d u l e . r e s o l v e t e m p ( 28 u s e c a s e . p a r e n t , ’package_classes’ ) ; 29 } 30 } listing 1: atl rule transforming a use case into control and boundary class in a first test we will use a transformation creating a control and boundary class for each actor and use case. the created classes are connected with associations. listing 1 shows a rule of the related atl transformation which transforms a use case to stereotyped classes. the rule, called “usecase2class” (line 1), transforms a use case (3) in a control class (5), a boundary class (9), an association between these two classes (13), and a trace (17). the trace is not part of the domain model (“simpleuml”) but of a separate trace model (“simpletrace”) according to the trace meta model described above. atl is a hybrid language, i.e. declarative parts (lines 4–20) can be combined with operational statements (line 21–28). we need these last statements to solve some special atl related problems, such as setting a reference to a source model element (without automatically transforming it) (22) and setting references to an element created in another rule (25, 26). it’s a 1:3 mapping, since three target elements (control, boundary, and association) are created from one source element; from a layout point of view it is a 1:2 mapping since only one node is mapped to two other nodes. figure 6 illustrates the effect of our transformation. the diagrams shown in this figure were actually layouted manually. figure 7 was added here to give you an impression of the problems mentioned in the introduction. the diagrams in this figure were layouted automatically by a drawing tool (omnigraffle). even if better layout algorithms may produce nicer layouts, an algorithm cannot guess the intentions of the developer arranging the nodes. the goal of the algorithm introduced in the next section is to automatically create a target diagram as shown in figure 6. 5 / 16 volume 7 (2007) mental map and mdd actor_1 usecase_1 usecase_2 actor_1ctrl actor1b usecase_1ctrl usecase_2ctrl usecase_1b usecase_2b figure 6: use case model to class model actor_1ctrl actor1b usecase_1ctrlusecase_2ctrl usecase_1busecase_2b actor_1ctrl actor1b usecase_1ctrl usecase_2ctrl usecase_1b usecase_2b actor_1ctrl actor1b usecase_1ctrl usecase_2ctrl usecase_1b usecase_2b figure 7: three analysis diagrams, arranged by omnigraffle 4 layout transformation 4.1 assumptions and constraints according to figure 2 we have to implement a transformation tnm mapping the source notation model to the target notation model. that is, the layout algorithm presented here is actually a transformation in terms of mdd. so far, we assume three models to be given: domain model, notation model, and trace model. this trace model is the link between source and target model. but: it is linking the domain models and not the notation models! as a matter of fact, it is impossible to create a target notation model independently of a graphical editor rendering the model. even if we have a given notation meta model, it is not possible, since the mapping between domain and notation elements is not defined by the meta model. e.g. imagine two uml class diagram editors (figure 8). one of them shows all classes defined in a model. the other one shows classes of a particular package, classes of other packages referenced by a shown class are listed using text labels inside a package node. if the displayed class model was created by a transformation, we may have a source model and a trace model. but no layout algorithm can create the nodes of the target notation model, because it’s the editor which defines what domain elements are displayed as nodes. mypackage:a library:alibrary:b editor a library + class a + class b mypackage:a editor b figure 8: two editors displaying the same domain model thus it is the task of the graphical editor to create the target notation model. this is what most editors can do, and some of them use known layout algorithms to set the properties of the notation model. in order to leave our layout algorithm independent from a graphical editor (and proc. led 2007 6 / 16 eceasst a domain meta model as well), we also assume here that the target notation model is already initialized (but not yet layouted). the algorithm needs only the two notation models and the trace model. since it is a layout algorithm, its objective is to render the target elements, that is the elements of the target notation model. the trace contains references to domain elements. the same is true for the notation model (in which the class view contains this reference). essentially, we need to look up the notation elements, i.e. views, by their element. the later is stored in a trace. we therefore do not need to actually access the domain elements, we need only their references as keys for retrieving notation elements. before explaining our algorithm, we want to discuss some assumptions and constraints. as a matter of fact, a transformation cannot only map a single source model to a single target model, but m source models to n target models. the sample transformation introduced here maps a single source model to a trace and a domain model. while the domain model transformation can map m to n models, the layout transformation developed here is restricted to a 1:1 mapping, that is, we create one diagram based on one source diagram. of course we can execute the algorithm m times for m target domain models, but even then we can only use one source notation model. this restriction is valid only if several source models are not displayed in a single source diagram. figure 9 illustrates these cases. this restriction stems from the fact that we cannot merge several notation models yet. dm nm dm nm dm nm dm nm dmdm dm nm dmdm nmnm source sourcetarget target m:n m:n 1:n m:1 dmdm dm nm figure 9: algorithm can handle only one source notation model the notation meta model as shown in figure 3 allows nesting of nodes. this technique is commonly used in graph editing frameworks. e.g. “attributes” and “operations” of a uml class are often displayed in so called “compartment” nodes, which are children of the “class” node. we therefore have to distinguish between top level nodes, that is nodes which are children of the diagram (or graph, we will use these two terms synonymously) and nested nodes. in the following, we will only refer to top level nodes. that is, our algorithm does not layout nested nodes. since we only need the location of the nodes of the source notation model, we can also handle nested (source) nodes: we simply use their absolute location, i.e. their location relative to the diagram. 4.2 layout algorithm figure 10 shows the overall architecture on top of which the algorithm works. in the middle of the diagram you see the layouttransformation instance. it accesses five models, two of which, the two domain models, are only needed to lookup notation elements via the elements referenced by the traces. since the trace model references both domain models, the algorithm 7 / 16 volume 7 (2007) mental map and mdd dmsource nmsource dmtarget nmtarget tracemodel transformator (atl) layout transformation (tnm) graphical editor (gef3d) «create» «layout» «create» «create» transformation (ti) figure 10: deployment diagram of layouttransformation only needs the trace and the two notation models as input parameters. a model transformation, e.g. an atl transformation as used in the example in section 3, is assumed to create both trace and target domain model, while the target notation model was created by the graphical editor. 1 p u b l i c s t a t i c v o i d l a y o u t ( d i a g r a m i o d i a g r a m t a r g e t , 2 d i a g r a m i d i a g r a m s o u r c e , c o l l e c t i o n i t r a c e s ) { 3 c o l l e c t i o n c l u s t e r s = c l u s t e r i n g ( i o d i a g r a m t a r g e t , 4 i d i a g r a m s o u r c e , i t r a c e s ) ; 5 a r r a n g e i n t e r n a l n o d e s ( c l u s t e r s ) ; 6 a d j u s t c l u s t e r s ( c l u s t e r s ) ; 7 s c a l e ( c l u s t e r s ) ; 8 d e c l u s t e r i n g ( c l u s t e r s ) ; 9 move ( i o d i a g r a m t a r g e t ) ; 10 } listing 2: layouttransformation, method layout(. . . ) listing 2 shows the overall strategy of the algorithm, each step will be explained more detailed later on. first, clusters are created (line 3) 4. then, the nodes of each cluster are arranged (5), adjusted (6), and scaled (7). eventually the nodes are “declustered” (8), i.e. their positions are translated to absolute positions and they are moved to fit into the diagram, that is all locations must contain positive values only (9). the clusters here are constructed using an extrinsic classification: a cluster contains all nodes, the elements of which were created by the same rule with the same source elements. in our implementation, clusters are extended from node (see the notation meta model, fig. 3). thus, a location can be assigned to the cluster. this location simply is the midpoint of the location of the nodes, which refer to elements in the source domain model. that is, if the transformation simply copies the source model, we have as many clusters as nodes in the source notation model with the same location. we also store the name of the rule, so we can easily retrieve all clusters the node’s elements of which were created by the same rule. listing 3 shows the classification method. instead of iterating through the target nodes and assigning each one to a cluster, we iterate through the traces (line 4). this way we do not have to (reverse) lookup the rule (which generated the target nodes) since its name is already stored in the trace. each domain target element must have been created by exactly one rule, so the union of all traces’ target elements equals all elements in the target model. depending on the graphical 4 clusters simply are subsets of nodes of the target diagram (or graph). for definitions and overview of drawing clusters, see e.g. [bc01]. while we use extrinsic clustering, usually the problem of intrinsic clustering is examined. proc. led 2007 8 / 16 eceasst editor and its presentation of the model, a (top level) node is linked to an element. if at least one node was created in the target notation model (7), we create a cluster (8), store the linked nodes in this cluster (9), and set the location of the cluster to the midpoint of the nodes in the notation source model (11)5. 1 p r i v a t e s t a t i c c o l l e c t i o n c l u s t e r i n g ( d i a g r a m d i a g r a m t a r g e t , 2 d i a g r a m d i a g r a m s o u r c e , c o l l e c t i o n t r a c e s ) { 3 a r r a y l i s t c l u s t e r s = new a r r a y l i s t ( ) ; 4 f o r ( t r a c e t r a c e : t r a c e s ) { 5 l i s t n o d e s = l o o k u p n o d e s ( d i a g r a m t a r g e t , t r a c e 6 . g e t t a r g e t e l e m e n t s ( ) ) ; 7 i f ( ! n o d e s . i s e m p t y ( ) ) { 8 c l u s t e r c l u s t e r = new c l u s t e r ( ) ; 9 c l u s t e r . s e t i n t e r n a l n o d e s ( n o d e s ) ; 10 c l u s t e r . s e t r u l e n a m e ( t r a c e . g e t r u l e n a m e ( ) ) ; 11 c l u s t e r . s e t l o c a t i o n ( l o o k u p l o c a t i o n s ( d i a g r a m s o u r c e , t r a c e 12 . g e t s o u r c e e l e m e n t s ( ) ) ) ; 13 c l u s t e r s . a d d ( c l u s t e r ) ; 14 } 15 } 16 r e t u r n c l u s t e r s ; 17 } listing 3: clustering based on source elements and rules in some cases nodes were created in the target notation model with no corresponding elements. this is the case if the graphical editor displays properties of elements as single nodes. as an example we might think of an icon located close to an element with a special property, e.g. an exclamation mark close to classes with public attributes in an uml diagram. if the node is directly linked to a property of an element, we can resolve its element and process this node as if it is linked to the element directly. this can be achieved in a generic way using emf’s extended reflection mechanism without further knowledge of the domain meta model. in other cases we may add some kind of dynamic graph drawing algorithm (e.g. described in [bra01] to locate all nodes which were not resolved here. currently, these nodes are ignored (and located at (0, 0)). the nodes are now classified and the created clusters are already located according to the source notation model (fig. 12). in a second step, the internal nodes are arranged “inside” the cluster (listing 2, line 5). that is, all nodes assigned to a cluster are simply arranged on an ellipse (if more than one node is found). this means that the target nodes are placed on top of each other, as a triangle or as a rectangle and so on (see figure 11). figure 11: arranged internal nodes since we use the ordering of the nodes, which is derived from the ordering of the elements, all elements created by the same rule are arranged in the same order. if, e.g. a model-view-controller triple was created, each role is always located at the same (relative) position, e.g. the controller 5 lookuplocation automatically calculates the midpoint 9 / 16 volume 7 (2007) mental map and mdd nmsource nmtarget modeltrace a b c d e abc rule2 rule2 rule1 rule3 rule4 cluster figure 12: clusters overlaps simple scale 1) scale nodes of a cluster2) scale cluster nodes 1) 2) figure 13: scaling all nodes vs. two phase scaling on top, the view on the right and the model on the left side. this helps the user to recognize the clusters and the rules afterwards. to avoid overlaps, we simply scale the diagram. uniform scaling is a very simple method to eliminate overlaps while preserving the mental map [esml91]. when using clusters, things get a little bit more complicated. if the diagram is scaled at the end of the layout process, the mental map might be destroyed. this can be caused by nodes of different clusters which overlap in a special way. for example, if a node a of a cluster a overlaps a node b of cluster b, with a is on top of b (i.e. a.y > b.y) but a is beneath b. this problem is illustrated in figure 13, where one cluster (shown as cloud) contains circles and the other one stars. to avoid this problem, we scale in two phases: first, the nodes of a cluster are scaled and then, the cluster nodes themselves are scaled. that is, first the nodes of a cluster are scaled in adjustclusters(...), then the cluster nodes are scaled in scale(...) (listing 2, lines 6 and 7). so far we have worked with relative locations, i.e. the locations of the nodes were set relative to the location of their cluster. this means we have to “decluster” the graph, that is the locations of the nodes of the diagram have to be made absolute. 5 gef3d generally, we can use the layout algorithm with any graphical editing framework, because it is only dependent on the notation model. in a model driven approach, models and their relationships are of great importance. that is why we aim at displaying several models at the same time. we achieve this by drawing the 2d diagrams on layers, which are shown in a 3d editor. gef is a powerful framework for graphical editors. i ported gef to support real 3d editors and called the result gef3d [gefb]. in contrast to many tools for simply visualizing some 3d drawings, gef3d is an editor with many of features known from gef. the main differences between gef and gef3d is that a point in gef is defined as a pair (x,y), where x and y are integer values. in gef3d a point is defined as a triple (x,y,z) where x, y, and proc. led 2007 10 / 16 eceasst z are float values. from a users point of view these are the main differences, making it possible to create 3d enabled graphical editors easily if you are familiar with gef. things like selecting (called picking in 3d) or moving the camera around (orbiting) are capsulated by gef3d. gef3d internally uses java3d for rendering the diagrams. java3d is capsulated and accessed in gef3d through a draw2d (gef’s drawing api) like api, now called draw3d. in fact, draw3d in gef3d enables creating 2d or 3d diagrams using a single api. all examples in the following section were all created with gef3d; all diagrams are completely editable. 6 demonstration we implemented a simple gef3d based editor for drawing use case and class diagrams. we can apply the transformation to a drawn use case model, that is we can generate a class and a trace model automatically. we have four models: source domain model (the use case model), target domain model (the class model), source notation model, and trace model (created by the transformation as well). we can now use the layout algorithm explained in section 4 to create a notation model for the target domain model automatically. the result is presented in figure 14. this figure shows the source and the target model in a 3d editor, with each model positioned on a (semi-transparent) layer. the source model is placed on top and the target model is visible through the top layer, demonstrating the effect of the transformed layout. the generated diagram equals the manually drawn one of figure 6 – and that is exactly the result that we were aiming at. figure 14: target model (left) and source model (right) 11 / 16 volume 7 (2007) mental map and mdd figure 15: 1:2 mapping, test 1 figure 16: 1:2 mapping, test 2 figure 17: 1:3 mapping (mvc) figure 18: 2:1 (association) mapping while this first model is a very simple one, figures 15 and 16 show the same transformation applied on more complicated source models. it is important to note that the algorithm is independent from any domain model. so, even if we use use cases and classes here, the only thing important for the algorithm is how many source elements are mapped to how many target elements. for testing purposes, we create different types of transformation with different types of mapping (1:1, 1:n and so on). this first transformation implemented a 1:2 mapping. the next example (figure 17) demonstrates a 1:3 mapping with the very same source models. this time, a model-view-control like structure is created. the transformation of the next example is taken from [sw02], used for teaching software engineering in a student’s course. in this case, we create a control class for each use case (1:1), a control-boundary pair for each actor (1:2), and a boundary class for each actor associated with a use case. at first glance, it might seems as if a 2:1 mapping occurs when creating a boundary for an actor-use case pair. but this is not the case, since the association between actor and use case is mapped to the boundary (and two associations). as a matter of fact, mapping the association proc. led 2007 12 / 16 eceasst nmsource nmtarget modeltrace figure 19: problem when positioning nodes created from associations figure 20: finding a bug or the pair leads to the same result. figure 18 shows the result of this transformation applied on the known example. as you can see from figure 19, a detail of figure 18, this is not an ideal result. since the boundaries mapped from the association were placed on the midpoints of the associations (in the cluster diagram), but then connected only to one of the two created classes, a lot of overlappings were produced. by accident we applied this transformation to a buggy source model (i.e. the persistence file of the source model contained a bug due to an error in the editor), so that a wrong element was created. finding such bugs is usually very difficult. in our case though, the wrong element can be recognized immediately, since the structure of the source and the target diagram differs. the wrong element is selected (and a little bit resized) in figure 20. 7 related work creating a layout by transforming the layout of a predecessor diagram is, as far as we know, a new approach. but naturally, some of the techniques used in the transformation are well known in graph drawing. generally, common graph drawing techniques may be applied in order to merge the transformed diagram with manually changed parts. especially the ideas presented in [esml91] or techniques used in dynamic graph drawing [bra01] may be used for this purpose. arranging the internal nodes of a cluster, which in our case is achieved by simply positioning the nodes on an ellipse, may be optimized using other graph drawing algorithms as described in e.g. [bett99] or [kw01]. maybe a force-directed approach might lead to better results. in any case it is important to arrange all clusters with the same rule in a similar way as described above. this may be added as a constraint to the algorithm. visualizing models in a 3d manner certainly has been done before. there are two kinds of 3d visualizations of (graph like) models: real 3d diagrams and, as in our approach, 2d diagrams on layers in a 3d space. while real 3d diagrams may be useful in certain contexts, we usually have the problem that most standard notations such as uml or er are defined for 2d diagrams 13 / 16 volume 7 (2007) mental map and mdd only. most approaches are used for program analysis, such as [vis], [glw06], or [fbk06]. 2d diagrams on layers were studied e.g. by gil and kent [gk98]. they developed different kinds of diagrams for different purposes, such as “contract boxes” for visualizing constraints or 3d sequence diagrams. in contrast to all these approaches i tried not only to implement a visualization tool but to develop a full featured 3d editor instead. 8 conclusion and future work in this paper i introduced an algorithm for the layout of diagrams based on predecessor diagrams. the algorithm is based on several types of models (domain, notation, and trace model), which are commonly used in the area of graphical editors and transformations. the algorithm was implemented using a 3d editor in order to display source and target model in a single window. the results are quite satisfying, although the algorithm may be improved e.g. when creating nodes based on edges in the source model (fig. 19). i am currently working on porting gef3d to directly use opengl inside swt widgets (instead of using java3d) in order to improve performance and memory usage of the 3d editor. in the context of their final thesis, several students of the fernuniversität hagen study selected visualization possibilities based on gef3d, such as the representation of package dependencies, metrics, or traces. we also develop an api for easily implementing layout algorithms with gef3d without further knowledge of the used notation or domain models. with mdd, models become first class development artifacts and we hope to enable a more intuitive way of working with models as it is possible with 2d editors. bibliography [atl] atlas transformation language (atl), project website (www.eclipse.org/m2m/atl). http://www.eclipse.org/m2m/atl [bc01] r. brockenauer, s. cornelsen. drawing clusters and hierarchies. pp. 193–227 in [kw01]. http://www.springerlink.com/content/hna86wa6ruahmxng [bett99] g. d. battista, p. eades, r. tamassia, i. g. tollis. graph drawing: algorithms for the visualization of graphs. prentice hall, 1999. [béz05] j. bézivin. on the unification power of models. software and systems modeling 4(2):171–188, may 2005. http://springerlink.metapress.com/openurl.asp?genre=article&id=doi:10.1007/ s10270-005-0079-0 [bmr+96] f. buschmann, r. meunier, h. rohnert, p. sommerlad, m. stal. pattern-oriented software architecture. wiley software patterns series 1: a system of patterns. wiley & sons, 1996. proc. led 2007 14 / 16 http://www.eclipse.org/m2m/atl http://www.springerlink.com/content/hna86wa6ruahmxng http://springerlink.metapress.com/openurl.asp?genre=article&id=doi:10.1007/s10270-005-0079-0 http://springerlink.metapress.com/openurl.asp?genre=article&id=doi:10.1007/s10270-005-0079-0 eceasst [bra01] j. branke. dynamic graph drawing. pp. 228–246 in [kw01]. http://www.springerlink.com/content/0ggdwjkyrr5q8u0k [emf] eclipse modeling framework (emf), project website (www.eclipse.org/emf). http://www.eclipse.org/emf/ [esml91] p. eades, k. sugiyama, k. misue, w. lai. preserving the mental map of a diagram. research report iias-rr-91-16e, fujitsu laboratories ltd, aug. 1991. http://www.iplab.cs.tsukuba.ac.jp/∼misue/publications/techreport/iias-rr-91-16e. pdf [fbk06] a. fronk, a. bruckhoff, m. kern. 3d visualisation of code structures in java software systems. in softvis ’06: proceedings of the 2006 acm symposium on software visualization. pp. 145–146. acm press, new york, ny, usa, 2006. http://doi.acm.org/10.1145/1148493.1148515 [gefa] graphical editing framework (gef), project website (www.eclipse.org/gef). http://www.eclipse.org/gef [gefb] graphical editing framework 3d (gef3d), project website (www.gef3d.org). http://www.gef3d.org [gk98] j. gil, s. kent. three dimensional software modelling. in 20th international conference on software engineering (icse’98). p. 105. ieee computer society, los alamitos, ca, usa, 1998. http://doi.ieeecomputersociety.org/10.1109/icse.1998.671107 [glw06] o. greevy, m. lanza, c. wysseier. visualizing live software systems in 3d. in softvis ’06: proceedings of the 2006 acm symposium on software visualization. pp. 47–56. acm press, new york, ny, usa, 2006. http://doi.acm.org/10.1145/1148493.1148501 [gmf] graphical modeling framework (gmf), project website (www.eclipse.org/gmf). http://www.eclipse.org/gmf [jac92] i. jacobson. object-oriented software engineering: a use case driven approach. acm press. addison-wesley professional, 1992. [jou05] f. jouault. loosely coupled traceability for atl. in proceedings of the european conference on model driven architecture (ecmda) workshop on traceability, nuremberg, germany. nov. 2005. http://www.sciences.univ-nantes.fr/lina/atl/www/papers/ecmdatraceability05. pdf [kw01] m. kaufmann, d. wagner (eds.). drawing graphs: methods and models. lecture notes in computer science 2025. springer-verlag, 2001. http://www.springerlink.com/content/xkru1gvnyh5p 15 / 16 volume 7 (2007) http://www.springerlink.com/content/0ggdwjkyrr5q8u0k http://www.eclipse.org/emf/ http://www.iplab.cs.tsukuba.ac.jp/~misue/publications/techreport/iias-rr-91-16e.pdf http://www.iplab.cs.tsukuba.ac.jp/~misue/publications/techreport/iias-rr-91-16e.pdf http://doi.acm.org/10.1145/1148493.1148515 http://www.eclipse.org/gef http://www.gef3d.org http://doi.ieeecomputersociety.org/10.1109/icse.1998.671107 http://doi.acm.org/10.1145/1148493.1148501 http://www.eclipse.org/gmf http://www.sciences.univ-nantes.fr/lina/atl/www/papers/ecmdatraceability05.pdf http://www.sciences.univ-nantes.fr/lina/atl/www/papers/ecmdatraceability05.pdf http://www.springerlink.com/content/xkru1gvnyh5p mental map and mdd [omg03] omg. mda guide version 1.0.1. object management group, needham, ma, omg/2003-06-01 edition, june 2003. http://www.omg.org/cgi-bin/doc?omg/03-06-01 [omg04] omg. mof 2.0 core specification. object management group, needham, ma, ptc/2004-10-15, convenience document edition, oct. 2004. http://www.omg.org/cgi-bin/doc?ptc/2004-10-15 [omg05] omg. a proposal for an mda foundation model. object management group, needham, ma, ormsc/05-04-01 edition, apr. 2005. http://www.omg.org/cgi-bin/doc?ormsc/05-04-01 [omg06] omg. diagram interchange specification. object management group, needham, ma, formal/06-04-04, version 1.0 edition, apr. 2006. http://www.omg.org/cgi-bin/doc?formal/06-04-04 [rs99] d. rosenberg, k. scott. use case driven object modeling with uml. a practical approach. object technology series. addison-wesley, 1999. http://www.iconixsw.com/umlbook.html [sw02] h.-w. six, m. winter. software-engineering i. grundkonzepte der objektorientierten softwareentwicklung. kurs 1793. fernuniversität in hagen, hagen, germany, sommersemester 2005 edition, 2002. [vis] vise3d (3d visualization in software engineering), projec website (http://ls10www.cs.uni-dortmund.de/vise3d/). http://ls10-www.cs.uni-dortmund.de/vise3d/ proc. led 2007 16 / 16 http://www.omg.org/cgi-bin/doc?omg/03-06-01 http://www.omg.org/cgi-bin/doc?ptc/2004-10-15 http://www.omg.org/cgi-bin/doc?ormsc/05-04-01 http://www.omg.org/cgi-bin/doc?formal/06-04-04 http://www.iconixsw.com/umlbook.html http://ls10-www.cs.uni-dortmund.de/vise3d/ introduction models robustness diagram example layout transformation assumptions and constraints layout algorithm gef3d demonstration related work conclusion and future work negative application conditions for reconfigurable place/transition systems electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) negative application conditions for reconfigurable place/transition systems a. rein, u. prange, l. lambers, k. hoffmann, j. padberg 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst negative application conditions for reconfigurable place/transition systems a. rein, u. prange, l. lambers, k. hoffmann, j. padberg technische universität berlin institut für softwaretechnik und theoretische informatik abstract: this paper introduces negative application conditions for reconfigurable place/transition nets. these are petri nets together with a set of rules that allow changing the net and its marking dynamically. negative application conditions are a control structure that prohibits the application of a rule if certain structures are already existent. we motivate the use of negative application conditions in a short example. subsequently the underlying theory is sketched and the results – concerning parallelism, concurrency and confluence – are presented. then we resume the example and explicitly discuss the main results and their usefulness within the example. keywords: petri net, net transformation, control structure, negative application condition 1 introduction as the adaptation of a system to a changing environment gets more and more important, petri nets that can be transformed during runtime have become a significant topic in recent years. application areas cover, among others, computer supported cooperative work, multi-agent systems, dynamic process mining and mobile networks. moreover, this approach increases the expressiveness of petri nets and allows a formal description of dynamic changes. in [hem05], this concept of reconfigurable place/transition (p/t) systems has been introduced where the main idea is the stepwise development of p/t systems by rules where the left-hand side is replaced by the righthand side preserving a context. we use rules and transformations for place/transition systems in the sense of the double pushout approach for graph transformation (see [ep04]). more precisely, adhesive high-level replacement (hlr) systems – a suitable categorical framework for double pushout transformations [eept06] – have been instantiated to p/t systems. for the suitable application of such rules specific control structures are needed, especially the possibility to forbid certain rule applications. these are known from graph transformation systems as negative application conditions (nacs). these conditions restrict the application of a rule forbidding a certain structure to be present before or after applying a rule in a certain context. such a constraint influences thus each rule application or transformation and therefore changes significantly the properties of the replacement system. by proving that p/t systems are weak adhesive hlr categories with negative application conditions we can transfer well-known and important results to this case: local church-rosser theorem, completeness theorem for critical pairs, concurrency theorem, embedding and extension theorem and local confluence theorem or critical pair lemma. 1 / 14 volume 10 (2008) nacs for reconfigurable p/t systems this paper is organized as follows: first we introduce our example and discuss the need of additional control structures for the application of rules in section 2. then we review the formal notions for reconfigurable p/t systems in section 3. based on these notions we define negative application conditions and present the main results concerning parallelism, concurrency and confluence in section 4. we discuss some of the general results with respect to the example in section 2. concluding remarks concern future and related work. 2 example: airport in this section, we present an example for a reconfigurable p/t system with nacs. we model an airport control system (aircs) that organizes the starting and landing runways of an airport. the p/t system has to ensure that certain safety properties of an airport are fulfilled, for example that some areas of the airport like the actual runways are secure, i.e. exclusively used by one airplane at the time. the aircs is able to adapt to various changes of the airport. changes at runtime may concern the opening or closing of a runway or its kind of use, i.e. for starting or landing. as a basic condition we require that there has to be at least one landing runway to ensure the landing of arriving airplanes, especially in emergency situations. in addition, the use of the starting runways depends on the weather. under fair weather conditions, no limitations occur. but it is possible for the system to receive a storm warning from a weather information channel. in this case, no more starting runways shall be opened and when the storm arrives it shall be forbidden for airplanes to depart. in the top of fig. 1, the standard aircs with one starting and one landing runway is depicted. each runway consists of two places of type runway and tower, with exactly one token on either the one or the other place. a token on runway represents an airplane on this runway, while a token on tower means that this runway is currently not in use. in addition, a landing runway consists of transitions landing and arrived, and a starting runway of transitions depart and takeoff, respectively. by firing the transition approach an airplane appears in the airspace of the aircs. the transition landing may fire if the runway is currently not used leading to a token representing an airplane on the runway. in the lower part of the p/t system, the gates area is modeled. the place gates is a counter for the available gates. if a gate is available, the airplane may proceed to a gate by firing the transition arrived. if the deboarding process is completed, the firing of the transition continueflight initiates the boarding process, and using the transitions depart and takeoff an airplane may depart over an available starting runway. in contrast to transition approach, the firing of the transition quitting models that the airplane leaves the airspace of the aircs. in the following, we describe the rules for changes of the airport. the rules openstartingrunway and openlandingrunway in the top of fig. 2 are used to open a new runway. the places and transitions of the runway are inserted and connected with the already existing part of the airport. for the rule openstartingrunway, an additional nac is needed to prevent the opening of a starting runway in case of a storm warning. to apply a rule to our p/t system, we first have to find a match of the left-hand side l to the p/t system. in case of the rule openstartingrunway, this match is unique and consists of the four places in l. if we have a nac for the rule, we have to check if this nac is valid, which means that we are not allowed to find a morphism from the proc. gt-vmt 2008 2 / 14 eceasst aircs :depboarding st:tower :gates :arrboarding lt:tower lr:runway :arrfield :depfield :fairweather sr:runway arrived landingapproach continueflight depart takeoff quitting ⇓ openstartingrunway aircs1 :depboarding st:tower :gates :arrboarding lt:tower lr:runway :arrfield :depfield :fairweather sr:runway st2:tower sr2:runway arrived landingapproach depart takeoff continueflight depart takeoff quitting ⇓ incomingwarning aircs2 :depboarding st:tower :gates :arrboarding lt:tower lr:runway :arrfield :depfield :fairweather sr:runway st2:tower sr2:runway storm arrived landingapproach depart takeoff continueflight forbidtakeoff depart takeoff quitting allowtakeoff ⇓ closestartingrunway aircs3 :depboarding st:tower :gates :arrboarding lt:tower lr:runway :arrfield :depfield :fairweather sr:runway storm arrived landingapproach continueflight forbidtakeoff depart takeoff quitting allowtakeoff figure 1: the standard aircs and a transformation sequence 3 / 14 volume 10 (2008) nacs for reconfigurable p/t systems nac to our p/t system via the match. for the match of openstartingrunway, the nac is fulfilled as long as no place of type storm exists. in addition, a gluing condition has to be fulfilled to make sure the rule is applicable (see def. 2 in section 3). then, we first delete those elements that are no longer needed and insert those elements that shall be created. they are glued to the already existing elements, for example when applying openstartingrunway the new transitions are connected to the places in the match. the application of the rule openstartingrunway to the aircs from fig. 1 is the p/t system aircs1 in the upper middle of fig. 1. the rules closestartingrunway and closelandingrunway in the upper middle of fig. 2 are used to close a runway. closestartingrunway is the inverse rule of openstartingrunway without a nac, since closing a starting runway is always allowed. for closelandingrunway, we have to make sure that we do not delete the last landing runway, thus another landing runway has to be present in the match. in the lower middle of fig. 2, the rules changelandingtostartingrunway and changestartingtolandingrunway for changing the kind of a runway are shown. for both rules, we have a nac that forbids that the runway is currently used by an airplane, represented by a token on the runway which is not present in the left-hand side. this ensures that the type of the runway is not changed during its use causing strange behaviour for incoming or outgoing flights. in addition, there is a second nac that forbids the application of changelandingtostartingrunway in case of a storm. in the nacs, the place types are omitted if they are obvious from the left-hand side. the arriving of a storm warning is also modeled by a rule as shown in the bottom of fig. 2. a new place of type storm is created and two transitions between this place and the place fairweather. as soon as the storm warning has arrived, no starting runways can be opened. but it is still possible to take off for waiting airplanes using the already existing starting runways. the airport system itself can decide when the weather situation is that bad that no airplan shall depart. then the transition forbidtakeoff is fired and since there is no longer a token on the place fairweather, no more takeoffs are possible. as soon as the weather gets better, by firing the transition allowtakeoff airplanes may depart. then the rule clearwarning deletes the storm warning and the regular airport operations may continue. altogether, in fig. 1 a transformation sequence is depicted which first opens a starting runway, then receives a storm warning and afterwards, the starting runway is closed again. 3 reconfigurable place/transition nets in this section, we formalize reconfigurable p/t systems based on our results in [hem05]. as net formalism we use the algebraic notation of “petri nets are monoids” in [mm90], but extend this notation by a label function for places. so, a p/t net is given by pn = (p, t, pre, post, label) with preand post domain functions pre, post : t →p⊕ and a label function label : p→l, where l is a fixed alphabet for places and p⊕ is the free commutative monoid over the set p of places, and a p/t system is given by (pn, m) with marking m ∈ p⊕. in order to define rules and transformations of p/t systems we introduce p/t morphisms which preserve firing steps by condition (1) and labels by condition (2) below. additionally, they require that the initial marking at corresponding places is increasing (condition (3)). for strict morphisms, in addition injectivity and the preservation of markings is required (condition (4)). proc. gt-vmt 2008 4 / 14 eceasst rule openstartingrunway db:depboarding g:gates :storm df:depfield w:fairweather nac ←− db:depboarding g:gates df:depfield w:fairweather l =⇒ db:depboarding :tower g:gates df:depfield w:fairweather :runway depart takeoff r rule openlandingrunway g:gates ab:arrboarding af:arrfield l =⇒ g:gates ab:arrboarding :tower :runway af:arrfield arrived landing r rule closestartingrunway db:depboarding :tower g:gates df:depfield w:fairweather :runway depart takeoff l =⇒ db:depboarding g:gates df:depfield w:fairweather r rule closelandingrunway lt:tower lr:runway g:gates ab:arrboarding :tower :runway af:arrfield arrived landing arrived l =⇒ lt:tower lr:runway g:gates ab:arrboarding af:arrfield arrived r rule changelandingtostartingrunway db t g lrltab af df wr :storm nac1 db t g lrltab af df wr nac2 ←− db:depboarding t:tower g:gates lr:runwaylt:towerab:arrboarding af:arrfield df:depfield w:fairweather r:runway arrived arrived landing l =⇒ db:depboarding t:tower g:gates lr:runwaylt:towerab:arrboarding af:arrfield df:depfield w:fairweather r:runway arrived depart takeoff r rule changestartingtolandingrunway db t g ab af df w r nac ←− db:depboarding t:tower g:gates ab:arrboarding af:arrfield df:depfield w:fairweather r:runway depart takeoff l =⇒ db:depboarding t:tower g:gates ab:arrboarding af:arrfield df:depfield w:fairweather r:runway arrived landing r rule incomingwarning nac=r ←− :fairweather :storm:fairweather allowtakeoff forbidtakeoff l =⇒ :fairweather :storm:fairweather allowtakeoff forbidtakeoff r rule clearwarning :fairweather :storm:fairweather allowtakeoff forbidtakeoff l =⇒ :fairweather :storm:fairweather allowtakeoff forbidtakeoff r figure 2: the rules for changing the aircs 5 / 14 volume 10 (2008) nacs for reconfigurable p/t systems definition 1 (p/t morphism) given p/t systems psi = (pi, ti, prei, posti, labeli, mi) for i = 1, 2, a p/t morphism f : ps1 → ps2 is given by f = ( fp, ft ) with functions fp : p1 → p2 and ft : t1 → t2 satisfying (1) f⊕p ◦ pre1 = pre2 ◦ ft and f ⊕ p ◦ post1 = post2 ◦ ft , (2) label1 = label2 ◦ fp and (3) m1(p) ≤ m2( fp(p)) for all p ∈ p1. moreover, the p/t morphism f is called strict if (4) fp and ft are injective and m1(p) = m2( fp(p)) for all p ∈ p1 . the category defined by p/t systems and p/t morphisms is denoted by pts where the composition of p/t morphisms is defined component-wise for places and transitions. the class of all strict p/t morphisms is denoted by m . next we define the gluing condition which has to be satisfied in order to apply a rule at a given match. the characterization of specific points is a sufficient condition for the existence and uniqueness of the so-called pushout complement which is needed for the first step in a transformation. definition 2 (gluing condition) given p/t systems psi = (pi, ti, prei, posti, labeli, mi) for i ∈ {l, k, 1}, and let psl m−→ ps1 be a p/t morphism and psk l−→ psl a strict morphism, then the gluing points gp, the dangling points dp and the identification points ip of psl are defined by gp = l(pk ∪tk ) dp = {p ∈ pl|∃t ∈ (t1 \mt (tl)) : mp(p) ∈ pre1(t)⊕ post1(t)} ip = {p ∈ pl|∃p′ ∈ pl : p 6= p′∧mp(p) = mp(p′)} ∪{t ∈ tl|∃t′ ∈ tl : t 6= t′∧mt (t) = mt (t′)} the p/t morphisms m and l with l strict satisfy the gluing condition, if all dangling and identification points are gluing points, i.e dp∪ip ⊆ gp, and m is strict on places to be deleted, i.e. ∀p ∈ pl \l(pk ) : ml(p) = m1(m(p)). next we present rule-based transformations of p/t systems following the double-pushout (dpo) approach of graph transformations in the sense of [roz97, eept06]. definition 3 (p/t system rule) given p/t systems psi = (pi, ti, prei, posti, labeli, mi) for i ∈ {l, k, r, 1}, then a rule rule = (psl l←− psk r−→ psr) consists of p/t systems psl, psk , and psr, called the left-hand side, interface, and right-hand side of rule, respectively, and two strict p/t morphisms psk l−→ psl and psk r−→ psr. the rule rule is applicable at the match psl m−→ ps1 if the gluing condition is satisfied for l and m. in this case, we obtain a p/t system ps0 leading to a transformation step ps1 rule,m =⇒ ps2 consisting of the following pushout diagrams (1) and (2). the p/t morphism n : psr → ps2 is called comatch of the transformation step. proc. gt-vmt 2008 6 / 14 eceasst psl m �� (1) psk loo r // c �� (2) psr n �� ps1 ps0l∗ oo r∗ // ps2 now we are able to define reconfigurable p/t systems, which allow the modification of the net structure using rules and transformations of p/t systems. definition 4 (reconfigurable p/t systems) given a p/t system ps and a set of rules ru les, a reconfigurable p/t system is defined by (ps, ru les). in the example in section 2 the reconfigurable p/t system consists of the p/t system in the top of fig. 1 and the set of rules depicted in fig. 2. note, that the application of some of these rules is restricted by nacs and we will present the notion of reconfigurable p/t systems with nacs in section 4. 4 negative application conditions in this section, we first state the main technical result that p/t systems are a weak adhesive hlr category with nacs. as a consequence we can define nacs for p/t system rules and transformations. afterwards we summarize the main results available for reconfigurable p/t systems with nacs. in addition to the class m in section 3 we need two other classes of morphisms. the class q denotes those morphisms that connect the nac to the source net, which is the class of injective p/t system morphisms. note that morphisms in this class do not need to be marking strict. the class e is a class of minimal jointly surjective morphism pairs, where minimal means that the markings in the codomain are as small as possible, i.e. for e1 : ps1 → ps3, e2 : ps2 → ps3 with (e1, e2) ∈ e we have that e1, e2 are jointly surjective and m3(p) = max({m1(p′) | p′ ∈ e−11 (p)}∪{m2(p ′)‖ p′ ∈ e−12 (p)}). this class is mainly used for constructions and proofs. definition 5 (morphism classes in pts) given the category pts of p/t systems and p/t morphisms, then the following morphism classes are defined: m : strict pts morphisms (injective and marking strict pts morphisms) q : injective pts morphisms (monomorphisms in the category pts) e : minimal jointly surjective pts morphisms theorem 1 (pts is weak adhesive hlr category with nacs) given the weak adhesive hlr category pts and the morphism classes m , q and e as defined above then we have 1. unique e -q pair factorization, 2. unique epi-m factorization, 3. m -q pushout-pullback decomposition property, 7 / 14 volume 10 (2008) nacs for reconfigurable p/t systems 4. initial pushouts over q-morphisms, 5. q is closed under pushouts and pullbacks along m -morphisms, 6. induced pullback-pushout property for m and q and 7. q is closed under composition and decomposition. altogether, (pts, m , e , q) is a weak adhesive hlr category with nacs. proof. in [eeh+07], it has been shown that (pts, m ) is a weak adhesive hlr category. according to [leop08], for a weak adhesive hlr category with nacs items 1–7 have to be proven additionally. note, that in [leop08] an additional morphism class m ′ is used and some more properties have to be checked. in the case of pts, q and m ′ coincide, which reduces the effort for the proof. here we only explain the properties and give proof ideas, the detailed proof can be found in [rei08]. 1. unique e -q pair factorization: for a morphism pair f1 : l1 → p, f2 : l2 → p, an e -q pair factorization is a pair e1 : l1 → k, e2 : l2 → k with (e1, e2) ∈ e and m : k → p ∈ q such that m◦e1 = f1 and m◦e2 = f2. uniqueness means that two e -q pair factorizations of f1 and f2 are isomorphic. for the construction of this e -q pair factorization in pts, we first construct the coproduct l of l1 and l2 with coproduct inclusions i1 and i2, obtain a morphism f : l → p and construct an epi-mono factorization (e : l → k, m : k → p) of f in p/t nets. defining mk (p) = max({ml(p′) | p′ ∈ e−1(p)}) and e1 = e◦ i1, e2 = e◦ i2 leads to a unique e -q pair factorization. this property is needed mainly for the embedding and extension of transformation pairs. 2. unique epi-m factorization: for a morphism f : l → p, an epi-m factorization is an epimorphism e : l → k and a morphism m : k → p ∈ m such that m◦e = f . uniqueness means that two epi-m factorizations of f are isomorphic. for the construction, we use the epi-mono factorization of f in p/t nets, and obtain the marking from the marking of p leading to a strict morphism m ∈ m . uniqueness follows directly from uniqueness of the epi-mono factorization in p/t nets and strictness of m . this property is needed for the translation of nacs over a morphism. 3. m -q pushout-pullback decomposition property: given the following commutative diagram with l ∈ m and w ∈ q, where (1 + 2) is a pushout and (2) is a pullback, then (1) and (2) are both pushouts. in p/t nets, this property holds for injective l and w, thus we obtain pushouts (1) and (2) in p/t nets. it remains to show the additional pushout properties in pts, which can be verified. this property is needed for the embedding and extension of transformation pairs and for the equivalence of left and right nacs. 4. initial pushouts over q-morphisms: an initial pushout over a morphism f ∈ q represents the boundary and context of f . the construction is similar to that in p/t nets, but also proc. gt-vmt 2008 8 / 14 eceasst includes all places where f is not marking-strict. this property is needed for the extension of transformations. 5. q is closed under pushouts and pullbacks along m -morphisms: in a pushout or pullback square along m , if the other given morphism is in q then the opposite morphism is also a q-morphism. this property follows directly from the corresponding properties in p/t nets and is used for the translation of nacs as well as for the embedding and extension of transformations. 6. induced pullback-pushout property for m and q: given the following pushout (po) and the pullback (pb) then the induced morphism x : ps3 → ps4 is a q-morphism. this property can be shown using the fact that f ′ and g′ are jointly surjective, which can be shown for the pushout construction. it is needed for the translation of nacs over a morphism. 7. q is closed under composition and decomposition: this is a standard result for monomorphisms from category theory. this property is needed for the translation of nacs and for the completeness of critical pairs. a b e (1) (2) c d f k l s u r v w p s0 p s1 (p b) p s2 p s4 f g h′ h p s0 p s1 (p o) p s2 p s3 f g f ′ g′ now, we can state negative application conditions for p/t system transformation in the following sense: definition 6 ((left) negative application condition) a (left) negative application condition of a rule rule = (psl l← psk r→ psr) in the weak adhesive hlr category with nacs (c, m , e , q) is of the form nac(n), where n : psl → psn is a p/t morphism. a morphism m : psl → ps1 satisfies nac(n), written m |= nac(n), if there does not exist a morphism q : psn → ps1 ∈ q with q◦n = m. definition 7 (rule with nacs) a rule in a weak adhesive hlr category with nacs (c, m , e , q) with a set of negative application conditions nacs is called rule with nacs. remark 1 analogously to left nacs we can define right nacs on the right-hand side of a rule which have to be satisfied by the comatch of the transformation. in this paper, we only consider rules with an empty set of right nacs. this is without loss of generality since each right nac can be translated into an equivalent left nac as shown in [eept06, leop08]. definition 8 (applicability of a rule with nacs) given a rule rule = (psl l← psk r→ psr) with a set of negative application conditions nacs and a match m : psl → ps1 such that rule without nacs is applicable at m, then the rule rule with nacs is applicable if and only if m satisfies all nacs of the set nacs. 9 / 14 volume 10 (2008) nacs for reconfigurable p/t systems for these new rules and their restricted application we obtain the same results as known for net transformations in general. these results have been shown for nacs at the level of weak adhesive hlr categories in [leop08, leo06, lam07]. their instantiation to p/t systems requires theorem 1 above. results (for reconfigurable p/t systems with nacs) 1. local church-rosser and parallelism: the local church-rosser property for transformations with nacs states that for two rules with two matches, the application of the rules at the matches to the same p/t system in any order (sequentially independence) yields the same result if and only if the transformations are parallel independent. for parallel independence of two transformations with nacs it has to be checked in particular if one transformation does not delete anything the other transformation needs, and, in addition, that one transformation does not produce any structure that is forbidden by the other one. for such independent transformations a parallel transformation with nacs can be built obtaining the same result in one transformation step. in our airport example it makes e.g. no difference if a starting or a landing runway is opened first. after opening a starting runway it is still possible to open a landing runway, since nothing is deleted and there is no nac on the rule openlandingrunway. after opening a landing runway a starting one can be opened: nothing is deleted and the nac of the rule openstartingrunway that forbids the existence of a place of type storm remains satisfied. moreover now both runways can be constructed in parallel. this construction leads to the same result consisting of an airport with one more starting and one more landing runway. 2. conflicts and critical pairs: if two transformations are not parallel independent as described in item 1 then they are in conflict. this means in particular that one of the transformations deletes some structure which is needed by the other one, or it produces a structure which is forbidden by the other one. a critical pair describes such a conflict between two transformations in a minimal context. critical pairs are proven to be complete [leo06], i.e. each conflict occurring in the system between two transformations is represented by a critical pair expressing the same conflict in a minimal context. the morphism class e is required to express this minimal context. in our example a transformation adding a warning (i.e. applying the rule incomingwarning) is in conflict with a transformation which opens a starting runway (i.e. applying rule openstartingrunway). this conflict is caused by the nac of the rule openstartingrunway as it cannot be applied if a place of type storm is present. this conflict occurs regardless of the number of runways already present in the airport and is expressed in a minimal context by the critical pair shown in figure 3. 3. concurrency: as explained in item 1 sequentially independent transformations can be put into one parallel transformation step having the same effect. but if sequential dependencies occur between direct transformations in a transformation sequence the parallelism theorem cannot be applied. in this case a so-called concurrent rule with nacs can be constructed establishing the same effect in one transformation step with nacs as the whole proc. gt-vmt 2008 10 / 14 eceasst db:depboarding g:gates stormdf:depfield w:fairweather forbidtakeoff allowtakeoff incomingwarning⇐= db:depboarding g:gates df:depfield w:fairweather openstartingrunway =⇒ db:depboarding :tower g:gates df:depfield w:fairweather :runway depart takeoff figure 3: the critical pair for the rules incomingwarning and openstartingrunway db:g: :storm df: w: db:g: :storm df: w: allowtakeoff forbidtakeoff ←− db:depboarding g:gates df:depfield w:fairweather =⇒ db:depboarding g:gates stormdf:depfield w:fairweather forbidtakeoff allowtakeoff figure 4: the concurrent rule with nacs transformation sequence. the concurrency theorem states that a concurrent rule with nacs equivalent to a sequence of rules with nacs is applicable with the same result if and only if the rule sequence with nacs is applicable. the construction of the concurrent rule is analogous to the case without nacs. additionally, all nacs occurring in the rule sequence need to be translated into equivalent nacs for the concurrent rule. the construction of such a concurrent rule with nacs is explained in [leop08]. a concurrent rule summarizes in one rule which parts of the net should be present, preserved, deleted and produced when applying the corresponding rule sequence to this net. moreover we have a summarized set of nacs on the concurrent rule expressing which net parts are forbidden when applying the corresponding rule sequence with nacs to the net. consider for our example the transformation sequence in fig. 1. first, a starting runway is opened followed by an incoming warning after which the starting runway is closed again. this transformation sequence can be summarized to one transformation step via a new concurrent rule with concurrent nacs as depicted in fig. 4. note that this concurrent rule now holds two single nacs, one originating from the first rule openstartingrunway and the other one originating from the second rule incomingwarning in the sequence. note, moreover, that this rule adds no new behavior to our system, but merely adds the possibility of performing these three transformations in one step with the same result. 4. embedding and extension: consider a transformation t : n0 ∗⇒ nn and a morphism k0 : n0 → n′0, then the transformation t can be embedded into the larger context n ′ 0 if and only if the extension morphism k0 : n0 → n′0 satisfies two consistency conditions. first, it has to be boundary consistent. this means intuitively that the extension morphism cannot embed places which are deleted by the transformation t into places connected with new transitions in the bigger p/t system n′0. otherwise, dangling edges will occur during the embedding. moreover, the extension morphism k0 should satisfy nac-consistency 11 / 14 volume 10 (2008) nacs for reconfigurable p/t systems [leo06]. intuitively, the transformation t can be summarized into one step tc : n0 ⇒ nn using the new concurrent rule with concurrent nacs. now the extension morphism k0 may not map to a larger p/t system n′0 with added structures which are forbidden by this concurrent nac. note that boundary consistency and nac-consistency are not only sufficient, but also necessary conditions for the construction of extended transformations with nacs. so, whenever it is possible to repeat a transformation t into a bigger context n′0 the extension morphism was boundary and nac-consistent. in our example, we can embed the transformation described in the last item into the p/t system aircs1 from fig. 1 which is not the initial one, but already contains two starting and one landing runway. on the contrary, this transformation cannot be embedded into the airport aircs2 from fig. 1 which already contains a storm warning. this is because the extension morphism k0 adds a place of type storm which is forbidden by the concurrent nacs as depicted in fig. 4. 5. confluence: critical pairs as described in item 2 are not only complete, their confluence behavior has an impact on the confluence behavior of the whole system. intuitively this means that if a conflict can be resolved in a certain way in its minimal context, the same conflict is resolvable as well if it occurs in a larger context. a solution of a conflict in a minimal context (or critical pair) p1 ← k → p2 is a pair of transformation sequences t1 and t2 such that t1 transforms p1 into a certain net x and t2 transforms it into the same net x . thus the same system state can be reached again if a conflict occurred. the solution of the critical pair needs to be strict. intuitively speaking, this means that t1 and t2 preserve everything which is preserved in common by the critical pair itself. moreover, whenever it is possible to embed the critical pair into some larger context the extension morphism should be nac-consistent with respect to the critical pair solution (nac-confluence [lam07] ). this means in particular that all nacs occurring in the solution of the critical pair are still satisfied by the embedding into the larger context. under these conditions, this conflict can be resolved in the same way also in a larger context. otherwise, the solution of the critical pair is no solution for the larger context, and no prediction for confluence can be infered. in particular, if all critical pairs of the reconfiguration system are strictly nac-confluent then the system is locally confluent. consider in our example the critical pair depicted in fig. 3. the solution of the critical pair is depicted in fig. 5 for the right-hand side of the critical pair. whenever a starting runway has been opened, a warning can come in and the starting runway can be closed again. the result is a p/t system containing no runway, but a storm warning. this is already our solution because this p/t system is identical to the the first p/t system in the critical pair. this solution is moreover strictly confluent because the places g, df, fw and db are preserved by both the critical pair and our solution. moreover, the solution is nacconfluent because the satisfaction of the concurrent nacs as depicted in fig. 4 is implied already by the satisfaction of the first nac of the critical pair. this means in effect that if the critical pair can be embedded and thus the nacs of the critical pair are satisfied by this embedding then they will also be satisfied when embedding the solution into the same bigger context. therefore, it is possible to resolve the conflict between an incoming proc. gt-vmt 2008 12 / 14 eceasst db:depboarding :tower g:gates df:depfield w:fairweather :runway depart takeoff incomingwarning =⇒ db:depboarding :tower g:gates :storm df:depfield w:fairweather :runway allowtakeoff forbidtakeoff depart takeoff closestartingrunway =⇒ db:depboarding g:gates stormdf:depfield w:fairweather forbidtakeoff allowtakeoff figure 5: the solution for the critical pair warning and opening a starting runway by having an incoming warning and closing the runway in each bigger airport as well. 5 conclusion we conclude with a short discussion of related and future work: related work reconfigurable nets have been defined based on net transformations that aim directly at changing the net in arbitrary ways. this approach can be restricted to transformations that preserve specific properties as safety or liveness (see [pu03]). dynamic nets [bs01] are based on the join calculus and allow the dynamic adaption of the network configuration and are considered to be a special case of zero-safe nets [bmm04]. in a series of papers [lo04, lo06a, lo06b] rewriting of petri nets in terms of graph grammars is used for the reconfiguration of nets as well. these marked-controlled reconfigurable nets (mcrn) are extended by some control technique that allows changes of the net for specific markings. the enabling of a rule is not only dependent on the net topology, but also dependent on the marking of specific control places. mcrenet [lo06a] is the corresponding tool for the modeling and verification of mcrns. future work one ongoing research task is the extension of this paper’s results to algebraic high-level nets, a petri net variant with additional data types in terms of algebraic specifications. therefore, the same conditions have to be proved considering additionally the specification and algebra morphisms. another one are algebraic higher order (aho) nets that can be used as a controlling mechanism for reconfigurable petri nets. aho nets have dynamical tokens like petri systems as well as transformation rules. this specification technique has been targeted at modeling workflows of mobile ad-hoc networks. up to now we have not made use of the new feature of nacs in aho nets. to do so we have to integrate the nacs into the algebra underlying the aho net. references [bmm04] r. bruni, h. melgratti, u. montanari. extending the zero-safe approach to coloured, reconfigurable and dynamic nets. in lectures on concurrency and petri 13 / 14 volume 10 (2008) nacs for reconfigurable p/t systems nets. lncs 3098, pp. 291–327. springer, 2004. [bs01] m. buscemi, v. sassone. high-level petri nets as type theories in the join calculus. in proceedings of fossacs ’01. springer, 2001. [eeh+07] h. ehrig, c. ermel, k. hoffmann, j. padberg, u. prange. concurrency in reconfigurable place/transition systems: independence of net transformations as well as net transformations and token firing. technical report 2007-02, tu berlin, 2007. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs. springer, 2006. [ep04] h. ehrig, j. padberg. graph grammars and petri net transformations. in lectures on concurrency and petri nets. lncs 3098, pp. 496–536. springer, 2004. [hem05] k. hoffmann, h. ehrig, t. mossakowski. high-level nets with nets and rules as tokens. in proceedings of icatpn’05. lncs 3536, pp. 268–288. springer, 2005. [lam07] l. lambers. adhesive high-level replacement systems with negative application conditions. technical report, tu berlin, 2007. [leo06] l. lambers, h. ehrig, f. orejas. conflict detection for graph transformation with negative application conditions. in proceedings of icgt’06. lncs 4178, pp. 61– 76. springer, 2006. [leop08] l. lambers, h. ehrig, f. orejas, u. prange. parallelism and concurrency in adhesive high-level replacement systems with negative application conditions. entcs, 2008. to appear. [lo04] m. llorens, j. oliver. structural and dynamic changes in concurrent systems: reconfigurable petri nets. ieee transactions on computers 53(9):1147–1158, 2004. [lo06a] m. llorens, j. oliver. a basic tool for the modeling of marked-controlled reconfigurable petri nets. eceasst 2:13, 2006. [lo06b] m. llorens, j. oliver. marked-controlled reconfigurable workflow nets. in synasc. pp. 407–413. ieee computer society, 2006. [mm90] j. meseguer, u. montanari. petri nets are monoids. information and computation 88(2):105–155, 1990. [pu03] j. padberg, m. urbášek. rule-based refinement of petri nets: a survey. in petri net technology for communication-based systems. lncs 2472, pp. 161–196. springer, 2003. [rei08] a. rein. reconfigurable petri systems with negative application conditions. technical report 2008/01, tu berlin, 2008. diploma thesis, to appear. [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation, vol 1: foundations. world scientific, 1997. proc. gt-vmt 2008 14 / 14 introduction example: airport reconfigurable place/transition nets negative application conditions conclusion repotting the geraniums: on nested graph transformation rules electronic communications of the easst volume 18 (2009) proceedings of the eighth international workshop on graph transformation and visual modeling techniques (gt-vmt 2009) repotting the geraniums: on nested graph transformation rules arend rensink and jan-hendrik kuperus 15 pages guest editors: artur boronat, reiko heckel managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst repotting the geraniums: on nested graph transformation rules arend rensink1 and jan-hendrik kuperus2 1rensink@cs.utwente.nl department of computer science universiteit twente, postbus 217, 7500 ae enschede, the netherlands 2jan-hendrik.kuperus@sogeti.nl sogeti nederland bv, postbus 76, 4130 eb vianen, the netherlands abstract: we propose a scheme for rule amalgamation based on nested graph predicates. essentially, we extend all the graphs in such a predicate with right hand sides. whenever such an enriched nested predicate matches (i.e., is satisfied by) a given host graph, this results in many individual match morphisms, and thus many “small” rule applications. the total effect is described by the amalgamated rule. this makes for a smooth, uniform and very powerful amalgamation scheme, which we demonstrate on a number of examples. among the examples is the following, which we believe to be inexpressible in very few other parallel rule formalism proposed in the literature: repot all flowering geraniums whose pots have cracked. keywords: geraniums, graph transformation, rule amalgamation, quantified rules, nested rules, parallel rules 1 introduction standard graph transformation rules are existential. by this we mean that a rule applies wherever there exists a matching of its left hand side into the host graph, and the effect of its application is limited to the homomorphic image of its left hand side under the matching.1 the existentiality of rules certainly has advantages, such as their reversibility (at least in a dpo setting). however, there are certain types of transformation where this is clearly a limitation. for instance, if a certain change has to applied universally, that is, to all sub-graphs with a certain structure, then this can be quite cumbersome to model using existential rules. this limitation has been recognised especially by tool builders, who after all are in the business of using graph transformations for practical cases; hence, virtually all graph transformation tools have some way to define rule schemes or parallel rules. (a thorough overview and comparison of related work follows later.) not all of the solutions have a firm theoretical justification, but the work of taentzer [28, 26] is ground-breaking in explaining the effect of parallel rule application in a general setting, namely as rule amalgamation. in this paper we describe a way to specify rule amalgamation, based on the concept of nested graph predicates of [21, 11]. the basic idea is a very simple one: where a nested graph predicate 1 an exception to this is the dangling edge deletion by spo rules; indeed, the fact that this is not existential in the current sense is the reason why such rules cannot be mimicked by single dpo rules. 1 / 15 volume 18 (2009) mailto:rensink@cs.utwente.nl mailto:jan-hendrik.kuperus@sogeti.nl repotting the geraniums is essentially a diagram of graphs and graph morphisms, a nested rule is a similar diagram of “simple” rules and morphisms. the application of such a rule to a given host graph consists of first matching the graph predicate consisting of the left hand sides of the rule diagram (which will result in a set of match morphisms, each of which goes from a left hand side of one of the simple rules to the host graph), and then using the structure of the rule diagram as interaction scheme in terms of rule amalgamation. the interaction scheme synchronises the atomic rule applications according to the match morphisms. we described a preliminary version of this idea in [22]. this has now been improved and implemented [13], so that we can report on some implementation and performance details. furthermore, we give some more examples which show the expressiveness of the approach. the geraniums in the title and abstract refer to the following challenge. we have a number of flower pots, each of which contains a number of geranium plants. these tend to fill all available space with their roots, and so some of the pots have cracked. for each of the cracked pots that contains a geranium that is currently in flower, we want to create a new one, and moreover, to move all flowering plants from the old to the new pot. create a single parallel rule that achieves this in a single application, without the use of control expressions. the complexity of this example stems from the fact that it involves a nested universal quantification, which (as far as we are aware) cannot be expressed in other declarative rule formalisms proposed in the literature, with the possible exception of [9, 14]. the remainder of this paper is structured as follows. in section 2 we recall the relevant concepts of rule amalgamation; in section 3 we give a new presentation of nested graph predicates, and we show how these can be used to generate amalgamated rules, which we call nested rules in this paper. in section 4 we discuss implementation issues, and demonstrate the use of nested rules, including the geraniums as well as some examples encountered in practice. finally, in section 5 we discuss related work, draw conclusions and discuss future work. 2 rule amalgamation we will first (briefly) recall the concepts of amalgamated graph transformation in the single pushout approach from [5], generalising from two rules along the lines of [27], resulting in a setup very similar to [12]. definition 1 (graph) a graph g is a tuple 〈v, e, src, tgt〉 consisting of a set of nodes v , a set of edges e, and source and target mappings src, tgt : e →v . g is called labelled if there is also a function lab : e → l to a global set of labels l, and simple if e ⊆ v × l × e such that src, lab and tgt are projections to the three components. the examples in this paper are set in the category of simple labelled graphs, but for the purpose of the definitions one can imagine any pair of graph categories gtot, g such that g has an initial object 0 and coproducts, and gtot is a full subcategory of g with initial object and coproducts which are preserved by the inclusion functor. we refer to the arrows in g as partial morphisms and to those in gtot as total morphisms. recall that a diagram d over a category c is a mapping from the nodes and edges of a graph proc. gt-vmt 2009 2 / 15 eceasst gd to the objects and arrows of c , such that d(e) : d(src(e)) → d(tgt(e)) for all edges e. diagram d commutes if for all parallel paths in gd, the composition (in c ) of the edge images give rise to the same c -arrow. as usual, we will often identify the elements of gd with their images under d. in this paper we frequently use tree-shaped diagrams, in which gd is a tree rooted in the initial object, i.e., has no cycles, no sharing (no distinct edges with the same target) and exactly one root rtd (a node without incoming edge) such that d(rtd) = 0. note that a treeshaped diagram trivially commutes. a tree-shaped diagram d is said to be en instance of another tree-shaped diagram d′ if there exists a root-preserving graph morphism i : gd →gd′ (called the instantiation morphism) such that d′ = d ◦ i. (so an instance may copy or ignore parts of d.) definition 2 (rule and sub-rule) a rule is a morphism p : l → r in g . a rule p′ is called a sub-rule of p if there exists a pair of total morphisms el : l′ → l and er : r′ → r such that p′ ◦ el = er ◦ p, i.e., the following diagram commutes: l′ r′ l r p′ el er p the pair e = e(el, er) is called a sub-rule embedding. rules give rise to derivations in the usual way of the single-pushout approach. definition 3 (match and derivation) a match of a rule p in a graph g is a total morphism m : l → g. given a rule and a match, a derivation is a pushout in g , depicted by the diagram l r g h p m m′ d po m′ is called the comatch and d the derivation morphism. note that m′ is in general not total. we write g −p,m−→ h if a derivation as in the above diagram exists. sub-rules and sub-rule embeddings form a category r (with the natural definition of identities and arrow composition) with an initial object and coproducts. below we will sometimes call the objects of r simple rules, to contrast them with the notion of composite rule that we are about to define. definition 4 (composite rule) a composite rule schema s is a tree-shaped diagram over r. for instance, figure 1 shows a composite rule schema that can be used to model the firing of a petri net transition. the rule morphisms are left implicit. in general, a composite rule schema corresponds to a synchronisation rule, and a composite rule instance (i.e., a tree-shaped diagram p that is an instance of s, in the sense discussed above) to a component production set in terms of [27], except that in that paper both kinds of diagrams are required to be bipartite graphs, and the component production set satisfies a certain completeness property. every diagram p over r induces several diagrams over g , among which we will use: 3 / 15 volume 18 (2009) repotting the geraniums select remove−in root add−out figure 1: composite rule schema for firing a petri net transition. • the rule diagram dp, consisting of the rule morphisms p for all objects p of p and the individual embedding morphisms el and er for all arrows e of d; • the “left-hand-side” diagram lp over gtot consisting of all the left hand sides lp and the corresponding total morphisms el. to define the derivations generated by a composite rule, first we extend the notion of a match. definition 5 (composite rule match) let s be a composite rule schema. a composite rule match of s in g consists of an instance p of s together with a set of matches mp : lp → g for all p in p, which, when added to lp, make the resulting diagram commute. a match of a composite rule schema s in a graph g is called a (partial) covering of g in [27]. given such a match, as usual one can define the composite derivation (star-parallel derivation in [27]) either by taking the coproduct q of the rule diagram dp and applying that as an ordinary rule (with respect to the unique match of q in g that is guaranteed by the coproduct construction), or by building the coproduct of the diagram consisting of the targets hp of the individual derivations g −p,mp−−→ hp together with the comatches m′p. due to the universal properties of coproducts, these two constructions are guaranteed to yield isomorphic results. in order to get a useful notion of parallel transformation, the allowed rule schema matches have to be restricted. [27] identifies a number of possible criteria. the main contribution of this paper is to propose yet another criterion, which uses the theory of nested graph predicates introduced by us in [21] and later, independently, in [11]. 3 nested graph predicates we give a new presentation of nested graph predicates, to make the connection with rule amalgamation clearer. a predicate will be a pair consisting of a tree-shaped graph diagram d over gtot and a formula generated by the following grammar, l : φ ::= tt | ¬φ | φ ∨ φ | ∃x.φ proc. gt-vmt 2009 4 / 15 eceasst outin trans root out−tokenin−token out−in figure 2: graph diagram on which transition enabledness can be expressed here x denotes one of the non-root nodes of the graph gd. apart from the basic logic operators defined above, we also use ∧, ⇒, ∀ etc., defined in the standard way. furthermore, we abbreviate ∃x.tt to x. every such non-root node x has a unique incoming edge; we will denote this edge inx. for instance, some formulae over the diagram in figure 2 are: 1. ¬out-in (which is an abbreviation of ¬∃out-in.tt), expressing that a given petri net does not have a loop; 2. ∀trans.∀in.in-token, expressing that every transition of a petri net can fire; 3. ∃trans.(∀in.in-token ∧ ∀out.(out-token ⇒ out-in)), expressing that there is an enabled transition according to the condition/event interpretation (in which all output places have to be empty, unless they are also input places). formulae are typed over the nodes of gd. the type of a formula is a graph in d for which we need a matching into the subject graph before we can evaluate the formula; in other words, it represents the “free variables” of the formula. we write φ : t to denote that t is a type of φ . we only deal with formulae that are well-typed according to the following rules: • tt : t for all nodes t of gd; • ¬φ : t if φ : t; • φ1 ∨ φ2 : t if φ1 : t and φ2 : t; • ∃x.φ : t if t = src(inx) and φ : x. φ is called ground if φ : 0 (where 0 is the initial object of g ). for instance, we have ¬∃out-in.tt : out, whereas the other two example formulae above are ground. in principle, formulae are evaluated over a given graph g; however, to define this properly we actually have to evaluate them over a given morphism f : l → g, where l is one of the graphs in the diagram d. f in fact represents a matching of l in g that we have built up “so far” while establishing the validity of a larger formula ψ of which φ is a sub-formula. the meaning of ∃x.φ 5 / 15 volume 18 (2009) repotting the geraniums g figure 3: proof of ∃trans.(∀in.in-token∧∀out.(out-token ⇒ out-in)). the dotted lines indicate some of the relevant node mappings. is that the matching f can be decomposed into g◦d(inx) (where inx is the unique edge in d with tgt(inx) = x). formally, the semantics of the logic is expressed by a relation f |= φ where φ : t and f : d(t)→ g is a total morphism in g : • f |= tt always holds; • f |= ¬φ if f 6|= φ ; • f |= φq ∨ φ2 if f |= φ1 or f |= φ2; • f |= ∃x : φ if g |= φ for some g such that f = g ◦ d(inx). if φ is ground, we also write tgt( f ) |= φ instead of f |= φ . for instance, if g is the petri net depicted on the right of figure 3, then the figure shows that there is an enabled condition/event transition, as expressed by the example formula 3 above. a formula φ is in positive form if it does not contain negations (but may contain ff, ∧ and ∀). every formula is equivalent to a positive form formula, which can be obtained easily by “pushing” negations inward. for instance, formula 3 above is equivalent to ∃trans.(∀in.∃in-token.tt ∧ ∀out.(∃out-in.tt ∨∀out-token.ff)). if φ is a ground positive form formula, then a proof diagram of g |= φ is defined to be a commuting diagram p over gtot, consisting of an instance q of d with instantiation morphism i : gq → gd, augmented with a graph g and for all nodes v of q a morphism fv : q(v) → g. furthermore, for every node v of q there is a set ψv of sub-formulae of φ such that φ ∈ ψrtq , and for all ψ ∈ ψv, ψ : i(v) and the following conditions are satisfied: • ψ 6= ff • if ψ = ψ1 ∨ ψ2, then either ψ1 ∈ ψv or ψ2 ∈ ψv; • if ψ = ψ1 ∧ ψ2, then ψ1 ∈ ψv and ψ2 ∈ ψv; proc. gt-vmt 2009 6 / 15 eceasst • if ψ = ∃x.ψ′, then v has an outgoing edge e with i(e) = inx and ψ′ ∈ ψtgt(e). • if ψ = ∀x.ψ′, then for all g : d(x)→ g such that fv = g ◦ d(inx), v has an outgoing edge e with i(e) = inx, ftgt(e) = g and ψ ′ ∈ ψtgt(e). a proof diagram is called minimal if it does not have spurious edges; i.e., the only edges are those necessitated by the last two bullets above. for instance, figure 3 is a minimal proof diagram, if v and w are the two occurrences of out in the diagram then ψv = {∃out-in.tt} and ψw = {∀out-token.ff}. predicate-driven amalgamation. the step from nested graph predicates to amalgamated rules is very small: rather than interpreting formulae over diagrams over gtot, we use tree-shaped diagrams over r, i.e., composite rule schemas. the interpretation of φ over s is defined to be its interpretation over the left-hand-side diagram ls. the following is a key insight: proposition 1 given a composite rule schema s, a closed formula φ interpreted over s, and a graph g, a minimal proof diagram of g |= φ is a composite match of s in g. for instance, we can turn the diagram in figure 2 into a diagram over r by replacing the graph in-token by the rule remove-in of figure 1, replacing out by add-out, and turning all other graphs into identity rules (i.e., based on identity production morphisms). the resulting diagram “refines” figure 1. the formula ∃trans.(∀in.in-token ∧ ∀out.(out-token ⇒ out-in)), which previously just expressed the existence of an enabled transition in a condition/event net, now encodes the firing of such a transition under the condition that it is enabled. the developments in this section culminate in the following definition, which we will use in the remainder of the paper: definition 6 (nested rule) a nested graph transformation rule is a tree-shaped diagram s over r with a formula φ ∈ l over s. a match of such a rule is a minimal proof diagram of φ over ls, and a rule derivation is the composite derivation with respect to such a minimal proof diagram. 4 implementation and examples the theory of nested rules has been implemented in groove [20], with some restrictions. nested rules in groove have been used and shown their value in several applications. in this section we discuss some of the implementation choices and show some applications. 4.1 groove implementation the main functionality of groove is to explore the complete state space of a graph transformation system. every derivation gives rise to a transition, and independent derivations interleave, giving rise to a size blow-up that is at worst exponential in the number of independent derivations. a composite rule derivation can combine a large number of simple rule derivations. apart from the ease of specification, this has the advantage that the number of transitions as well as the number of interleaving points between transitions decreases, in some cases quite dramatically. for the purposes of practical use, we have made the following choices. 7 / 15 volume 18 (2009) repotting the geraniums modified positive form formulae. rather than the full logic defined above, groove only supports restricted positive form formulae, as defined by the following syntax: φ ::= ∃x.( ∧ k∈k ¬xk)∧( ∧ i∈i ψi) ψ ::= ∀x.( ∧ k∈k ¬xk)∧( ∨ j∈j φ j) where ¬xk abbreviates ∀xk.ff, and i, j, k are arbitrary index sets. thus, disjunction is restricted to existentially quantified sub-formulae and conjunction to universally quantified sub-formulae. it can be proved (in fact, it indirectly follows from [21]) that this is no real restriction, in the sense that every formula is equivalent to a “normal form” formula in this restricted syntax, but we will not elaborate on this point here. single-graph representation. one of the disadvantages of nested rules as formulated in definition 6 is that they consist of two parts, a rule diagram and a formula. in groove, we have chosen to include all of these into a single graph representation. for this purpose, we introduce special quantifier nodes that stand for the ∀and ∃-quantifiers of the formula and are arranged (using special in-labelled edges) in a tree of alternating quantifiers. the root of this tree is an ∃-node which is left implicit, so that a simple rule is just a special case of a composite rule. the “fresh” nodes of the quantified graphs, i.e., those nodes that are not in the codomain of the incoming morphisms, are attached to the corresponding quantifier nodes using special at-labelled edges. for fresh edges of the quantified graph, this solution does not work since groove does not support edges on edges; instead, if such a fresh edge does not have fresh end nodes, we include the name of the quantifier as a prefix of the edge label. as an example, figure 4 shows the firing rule of condition/event nets in this one-graph representation. as usual in the groove notation, non-rhs elements (which are to be deleted) are dashed thin blue (or dark grey), non-lhs elements (which are to be created) are wider solid green (or light grey), and nac elements are wide, closely dashed red (or dark grey). the dotted nodes and edges form the tree of quantifiers (where the root is omitted); to make the connection with the diagram in figure 2 explicit, we have named all quantifier nodes. for the existential out-in-quantifier this name is in fact necessary as it occurs as a prefix in one of the in-edges, to associate this edge with the quantifier. non-vacuous universal quantification. if no match of x exists in a given host graph, the formula ψ = ∀x.φ is true irregardless of φ . in this case, ψ is said to be vacuously true. consequently, a universally quantified nested (sub-)rule may be vacuously applicable, in which case the rule has no effect. sometimes this may be just what one wants, as in the firing rule of figure 4: for a transition with no input places, the sub-rule in is always enabled and has no effect. however, quite often vacuous derivations are not intended. though non-vacuity can always be enforced through an application condition, we have included a special quantifier node, denoted ∀>0, which guarantees that the sub-rule is matched at least once. thus, ∀>0x.φ is equivalent to ∃x.φ ∧∀x.φ .2 2 thus, the difference between ∀ and ∀>0 is very similar to that between optional and obligatory set nodes in progres. proc. gt-vmt 2009 8 / 15 eceasst root outtoken outin intoken trans outin created (r\l) deleted (l\r) nac figure 4: nested c/e firing rule in groove syntax, with the explicit tree structure shown to the right 4.2 examples we now show some other applications of nested rules. geraniums. the title challenge of this paper is to create a new pot for every cracked flower pot with at least one flowering geranium, and to transfer all flowering geraniums in the cracked pot to the new one. this is an example of a rule that needs two nested universal quantifiers: an outer quantifier for the pots, and an inner quantifier for the plants in the pots. this puts the rule beyond what can be formulated in other approaches to parallel graph transformation rules, such as the cloning rules of [18] or the set nodes and star rules in progres [24], except in the extension recently proposed in [9] — see section 5 for a more extensive discussion. in groove, a first attempt is given on the left side of figure 5. an example derivation is shown in figure 6. however, this rule is incorrect as it also creates new pots for cracked pots that do not contain any flowering geraniums. to rule this out, we need the non-vacuous universal quantifier discussed above. however, we cannot simply replace the plants-quantifier by ∀>0, since then the rule requires that all cracked pots have at least one flowering geranium, hence it would become inapplicable for a graph like the one in figure 6. to resolve this, we have to add figure 5: incorrect and corrected versions of the geranium rule. 9 / 15 volume 18 (2009) repotting the geraniums figure 6: example derivation of the left hand rule of figure 5 a disjunct to the pots-quantifier, resulting in the rule on the right hand side of figure 5. sierpinski triangles another example that is very suited to specification in nested rules is the sierpinski case described in [29]. this involves a challenge to give a graph grammar that generates all sierpinski triangles (a certain fractal shape) up to an arbitrary depth. one step of the generation process involves replacing all up-pointing sub-triangles by a more involved graph (which contains three new up-pointing triangles). a nested groove rule that specifies this given in figure 7. in [29], we have described a sequential groove solution to the sierpinski case, and we have remarked that the above parallel rule has (only) slightly better performance. this may be surprising in the light of the fact that the sequential solution generates many more intermediate states. however, in this particular case no real state space exploration is needed: instead, a “linear” exploration strategy is used that selects a single rule application and never backtracks. in this type of exploration, generating the intermediate states causes only little overhead. figure 7: nested rule specifying one sierpinski triangle generation step. proc. gt-vmt 2009 10 / 15 eceasst figure 8: one of the rules of the ad-hoc network connectivity protocol in [3]. the =-labelled nac-edges are injectivity constraints. network gossipping protocol. in [3] we describe a groove model of an ad-hoc network connectivity protocol. the paper shows that this model gives rise to a large symmetry reduction, so that larger network instances can be modelled than with other specification methods (although the size of the state space is still exponential in the size of the network). nested rules have been used here in several places, to reduce the number of derivation steps and especially the number of interleavings of steps. in contrast to the previous example, in this case it is important to explore the state space in full, and indeed without the use of nested rules the advantage with respect to other methods to some degree disappears. an example rule where nesting has been exploited is shown in figure 8: this specifies that all but two outgoing link-edges have to be removed from every network node. 5 evaluation we have shown how to integrate the concepts of nested graph predicates and rule amalgamation. it turns out that these concepts mesh together quite well, and give rise to a usable specification formalism for parallel rules. this formalism has been implemented in groove; we have given several practical examples where this type of rule has been very useful. on the downside, it turns out that nested rules can be complicated to write. this is mainly due to the chosen single-graph representation: especially when the rules become larger, the fact that all nesting levels are combined in a single graph makes the resulting figure hard to read. an alternative is to use a hierarchical graph syntax, where the quantifier nodes are containers for the graph elements associated with them. related work. we briefly review alternative approaches to parallel rule specification. first of all, node replacement systems [7] have a natural notion of parallelism due to the fact that, when a node is replaced, all incident edges, no matter how many, are modified as well. for the star grammars [4] this is generalised so that not only incident edges but their opposite nodes can be duplicated as often as necessary. this roughly corresponds a single universal quantifica11 / 15 volume 18 (2009) repotting the geraniums tion in terms of our nested rules; in fact, every adaptive star rule can easily be formulated as a nested rule with a single universal quantifier. progres [24] and also fujaba [19] feature so-called set nodes, which are essentially single universally quantified nodes. furthermore, progres has star rules, which are essentially rules that are entirely universally quantified. an interesting extension to set nodes can be found in [9], which allows to specify set regions rather than just set nodes. since these set regions can be nested, this comes close to our notion of nested quantifiers, and we conjecture that this formalism can in fact specify the geranium rule. unfortunately, the paper does not provide enough information to be sure. some approaches are based on rule schemas with sub-graphs that can be cloned or copied before applying the rule: for instance, [18, 1, 17]. the latter two have the interesting option of specifying connections between the clones, which may for instance be ordered in a linear list. this is outside the capabilities of our nested rules. on the other hand, each of these approaches deals with a single level of (universal) quantification only, and so we believe that they cannot solve the geranium challenge. as we have made clear, our nested rules are built on the principle of rule amalgamation. other papers that have shown the power of amalgamation for specifying parallel rules (in particular, the petri net firing rule) are [15, 8]. another approach that needs mentioning in this context is that of synchonised hyperedge replacement; see, e.g., [14]. a central concept in this formalism is to combine “local” rules into larger ones, using synchonisation algebras to determine how rules are to be combined. it is claimed in [30] that this is powerful enough to repot the geraniums. finally, another method altogether for repotting the geraniums is by using control expressions rather than a single parallel rule or rule schema. there have been many proposals for powerful control languages; we would like to mention progres, fujaba’s storyboards, but also the recent notions of recursive rules [10, 32], which in fact have no extraneous control conditions but rather integrate them with the rules themselves. we would also categorise the use of the (very powerful) pattern definitions in model transformation tools such as tefkat [16] and viatra2 [31] as control expressions, though admitedly the dividing line grows thin in these cases. future work. we see nested rules as a first step towards the ability to specify an arbitrary transformation as a single transaction with atomic execution. the planned next step is to enhance the groove control language with an atomicity statement that turns an arbitrary control statement into such a transaction. another potentially useful extension is the introduction of counting quantifiers, being existential quantifiers that assert the existence of a given, fixed number of distinct instances of a sub-graph (other than 1, which is the default meaning of existential quantification). for instance, the rule in fig. 8 could be simplified using such a feature. bibliography [1] d. balasubramanian, a. narayanan, s. neema, f. shi, r. thibodeaux, and g. karsai. a subgraph operator for graph transformation languages. in k. ehrig and h. giese [6]. proc. gt-vmt 2009 12 / 15 eceasst [2] a. corradini, h. ehrig, u. montanari, l. ribeiro, and g. rozenberg, eds. third international conference on graph transformations (icgt), vol. 4178 of lncs. springer, 2006. [3] p. crouzen, j. van de pol, and a. rensink. applying formal methods to gossiping networks with mcrl and groove. sigmetrics perform. eval. rev., 36(3):7–16, 2008. [4] f. drewes, b. hoffmann, d. janssens, m. minas, and n. v. eetvelde. adaptive star grammars. in a. corradini et al. [2], pp. 77–91. [5] h. ehrig and m. löwe. parallel and distributed derivations in the single-pushout approach. tcs, 109(1&2):123–143, 1993. [6] k. ehrig and h. giese, eds. graph transformation and visual modeling techniques (gtvmt), vol. 6 of electronic communications of the easst. easst, 2007. [7] j. engelfriet and g. rozenberg. node replacement graph grammars. in g. rozenberg [23], pp. 1–94. [8] c. ermel, g. taentzer, and r. bardohl. simulating algebraic high-level nets by parallel attributed graph transformation. in kreowski, montanari, orejas, rozenberg, and taentzer, eds., formal methods in software and systems modeling, vol. 3393 of lncs, pp. 64–83. springer, 2005. [9] c. fuss and v. e. tuttlies. simulating set-valued transformations with algorithmic graph transformation languages. in a. schürr et al. [25], pp. 442–455. [10] e. guerra and j. de lara. adding recursion to graph transformation. in k. ehrig and h. giese [6]. [11] a. habel and k.-h. pennemann. nested constraints and application conditions for highlevel structures. in kreowski, montanari, orejas, rozenberg, and taentzer, eds., formal methods in software and systems modeling, vol. 3393 of lncs, pp. 293–308. springer, 2005. [12] r. heckel, j. müller, g. taentzer, and a. wagner. attributed graph transformations with controlled application of rules. in valiente and rossello llompart, eds., colloquium on graph transformation and its application in computer science, technical report b–19. universitat de les illes balears, 1995. [13] j.-h. kuperus. nested quantification in graph transformation rules. master’s thesis, department of computer science, university of twente, 2006. [14] i. lanese and e. tuosto. synchronized hyperedge replacement for heterogeneous systems. in jacquet and picco, eds., coordination models and languages (coordination), vol. 3454 of lncs, pp. 220–235. springer, 2005. [15] j. de lara, c. ermel, g. taentzer, and k. ehrig. parallel graph transformation for model simulation applied to timed transition petri nets. in heckel, ed., graph transformations and visual modelling techniques (gt-vmt), vol. 109 of entcs, pp. 17–29, 2004. 13 / 15 volume 18 (2009) repotting the geraniums [16] m. lawley and j. steel. practical declarative model transformation with tefkat. in bruel, ed., models satellite events, vol. 3844 of lncs, pp. 139–150. springer, 2006. [17] j. lindqvist, t. lundkvist, and i. porres. a query language with the star operator. in k. ehrig and h. giese [6]. [18] m. minas and b. hoffmann. an example of cloning graph transformation rules for programming. in r. bruni and d. varró, eds., graph transformation and visual modeling techniques (gt-vmt), vol. 211 of entcs, pp. 241–250, 2006. [19] j. niere and a. zündorf. using fujaba for the development of production control systems. in nagl, schürr, and münch, eds., applications of graph transformations with industrial relevance, (agtive), vol. 1779 of lncs, pp. 181–191. springer, 2000. [20] a. rensink. the groove simulator: a tool for state space generation. in pfaltz, nagl, and böhlen, eds., applications of graph transformations with industrial relevance, (agtive), vol. 3062 of lncs, pp. 479–485. springer, 2004. [21] a. rensink. representing first-order logic using graphs. in h. ehrig, g. engels, f. parisipresicce, and g. rozenberg, eds., second international conference on graph transformations (icgt), vol. 3256 of lncs, pp. 319–335. springer, 2004. [22] a. rensink. nested quantification in graph transformation rules. in a. corradini et al. [2], pp. 1–13. [23] g. rozenberg, ed. handbook of graph grammars and computing by graph transformations, volume 1: foundations. world scientific, 1997. [24] a. schürr. programmed graph replacement systems. in g. rozenberg [23], pp. 479–546. [25] a. schürr, m. nagl, and a. zündorf, eds. applications of graph transformations with industrial relevance (agtive), vol. 5088 of lncs. springer, 2008. [26] g. taentzer. parallel and distributed graph transformation: formal description and application to communication-based systems. phd thesis, tu berlin, 1996. [27] g. taentzer. parallel high-level replacement systems. tcs, 186(1-2):43–81, 1997. [28] g. taentzer and m. beyer. amalgamated graph transformations and their use for specifying agg — an algebraic graph grammar system. in schneider and ehrig, eds., graph transformations in computer science, vol. 776 of lncs, pp. 380–394. springer, 1994. [29] g. taentzer, e. biermann, d. bisztray, b. bohnet, i. boneva, a. boronat, l. geiger, r. geiß, á. horvath, o. kniemeyer, t. mens, b. ness, d. plump, and t. vajk. generation of sierpinski triangles: a case study for graph transformation tools. in a. schürr et al. [25], pp. 514–539. [30] e. tuosto. private communication, 2009. proc. gt-vmt 2009 14 / 15 eceasst [31] d. varró and a. balogh. the model transformation language of the viatra2 framework. sci. comput. program., 68(3):214–234, 2007. [32] g. varró, á. horváth, and d. varró. recursive graph pattern matching with magic sets and global search plans. in a. schürr et al. [25], pp. 456–470. 15 / 15 volume 18 (2009) introduction rule amalgamation nested graph predicates implementation and examples groove implementation examples evaluation type checking c++ template instantiation by graph programs electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) type checking c++ template instantiation by graph programs karl azab and karl-heinz pennemann 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst type checking c++ template instantiation by graph programs karl azab and karl-heinz pennemann azab@informatik.uni-oldenburg.de, pennemann@informatik.uni-oldenburg.de carl v. ossietzky universität oldenburg, germany abstract: templates are a language feature of c++ and can be used for metaprogramming. the metaprogram is executed by the compiler and outputs source code which is then compiled. templates are widely used in software libraries but few tools exist for programmers developing template code. in particular, error messages are often cryptic. during template instantiation, a compiler looks up names that depend on a template’s formal parameters. we use graphs to represent the relevant parts of the source code and a graph program for the name lookup and type checking for expressions involving such names. this technique provides compiler writers with a visual way of writing algorithms that generate error messages and forms the basis for a visual inspection of type problems and suggested remedies for the programmer. our graph program terminates and emits correct error messages. keywords: graph programs, type checking, c++ 1 introduction templates are a feature of the c++ programming language for generic programming, i.e. programmed code generation. generic source code is written by omitting the specific data types of variables and instead supplying those as parameters (parameterized types). a parameterized type and variable of that type can be used as any other type or variable, e.g. the type name can be used to resolve names and the variable’s members can be accessed. this way, templates separate types from algorithms in design, and combines them into new class-types and functions at compile time. compared to non-template code which uses a generic type like void *, an immediate advantage from templates is improved static type checking. templates are used extensively in the standard template library and boost libraries [jos99, ag04]. they have also found use in performance critical domains, such as scientific computing and embedded systems [vel98, str04]. an introduction to templates can be found in e.g. [str00]. a class type or function containing generic source code is called a template definition. a list of type parameters for a particular template definition is called a declaration. for each unique declaration, the template instantiation mechanism generates a specialization of that template definition. a specialization is a copy of the definition where the parameterized types are replaced by the declaration’s actual type parameters. non-types, i.e. constants, are allowed as template parameters, allowing e.g. array sizes to be set at compile time. templates form a computationally complete metalanguage [ce00], a sub-language of c++ executed during compilation. consider the following example: a parameterized type is used to resolve the name size in the template definition in figure 1. the first specialization is for the declaration icon and will not compile since the provided type char has no field named size and can therefore 1 / 14 volume 10 (2008) mailto:azab@informatik.uni-oldenburg.de mailto:pennemann@informatik.uni-oldenburg.de type checking c++ template instantiation by graph programs not be used for the expression defining the array size. for the second specialization, if the type resolution<128> contains a static field named size of an unsigned integer type, then the second specialization will compile. t e m p l a t e s t r u c t i c o n { p i x e l m i c o n [ resolution : : s i z e ] [ resolution : : s i z e ] ; /∗ . . . ∗/ }; template definition i c o n w r o n g d e c l a r a t i o n ; i c o n> c o r r e c t d e c l a r a t i o n ; declaration metaprogram s t r u c t i c o n { p i x e l m i c o n [ c h a r : : s i z e ] [ c h a r : : s i z e ] ; /∗ . . . ∗/ }; s t r u c t i c o n> { p i x e l m i c o n [ r e s o l u t i o n <128>:: s i z e ] [ r e s o l u t i o n <128>:: s i z e ] ; /∗ . . . ∗/ }; specializations t em plate instantiation compiler figure 1: c++ template instantiation. even though templates are a useful technique, they can be complex and difficult to read and write. in particular, error messages are often cryptic. this has led to the development of methods and tools to analyze template code. the usage of specializations can be analyzed by debuggers, software patterns like tracers [vj02], and tools like tuanalyzer [gpg04]. for the metaprogram itself, research is being done on a debugging framework templight [pms06]. to improve error messages, we suggest modeling definitions and declarations by graphs, while name lookup and type checking of such graphs is made by graph programs that emit error messages as graphs instead of text. graphs allow an abstract and visual representation of all necessary information, while graph programs provide an intuitive way of writing programs that detect problems and suggests remedies. in combination with presentation techniques such as focusing (on relevant parts) and hierarchical depiction, we believe that our model is usable as a basis for a visual inspection of type problems and suggested remedies. graph transformation systems is a well investigated area in theoretical computer science. an overview on the theory and applications is given in the book fundamentals of algebraic graph transformation [eept06]. graph transformation systems rewrite graphs with (graph transformation) rules. a rule describes a leftand right-hand side. a transformation step is done by matching the left-hand side to a subgraph of the considered graph and modifying that subgraph according to the difference of the leftand right-hand side. graph programs [hp01, ps04] provide a computationally complete programming language based on graph transformations. graph conditions [hp05] can be used to express properties of graphs by demanding or forbidding the existence of specific structures. in a similar way, graph conditions can limit the applicability of rules in a graph program, by making demands on elements local to the subgraph matched by a rule. in this paper, we use graphs to represent the template source code necessary for name lookup and type checking during template instantiation. we refer to those graphs as source-code graphs. proc. gt-vmt 2008 2 / 14 eceasst a graph program ttc (template-type checker) looks up dependent names and detects type clashes in expressions for a subset of the c++ template features. ttc attempts to solve type clashes by implicit type casts. if such a cast loses precision, a warning message is generated. if no appropriate cast is found, an error message is generated, indicating the location of the error and suggesting a remedy for the programmer. ttc outputs a message graph, where errors and warnings are embedded. the message graph is interpreted by the programmer with the help of graph conditions. graph conditions detect warning and error messages in graphs and when an error is present, they can determine for which declarations a definition can successfully be instantiated. figure 2 gives an overview. graph program ttc source-code-graph transformer programmer write / update interpretation with graph conditions message graph source-code graph source code figure 2: ttc type checks graphs and outputs error messages. the paper is structured as follows. graph programs are introduced in section 2. section 3 informally describes how c++ source code is transformed into source-code graphs and defines type safety for graphs. in section 4 we present the graph program ttc for transforming a sourcecode graph into a message graph. in section 5 we give proof ideas for how to show that ttc terminates and that the error messages generated by it correctly indicate that the input is not type safe. we conclude our results in section 6. a long version of this paper, with complete proofs and more examples, is available as a technical report, see [ap07]. 2 graph programs in this section, we review conditions, rules, and programs, in the sense of [hp05] and [hp01]. in the following, we consider the category of directed labeled graphs with all injective graph morphisms. labels distinguish different types of nodes and edges and directions model relationships between nodes. we use the standard definition of labeled graphs and labeled graph morphisms, see [eept06] or [ap07] for details. for expressing properties on graphs we use so-called graph conditions. the definition is based on graph morphisms. definition 1 (graph conditions) a graph condition over an object p is of the form ∃a or ∃(a, c), where a : p → c is a morphism and c is a condition over c. moreover, boolean formulas over conditions (over p) are conditions (over p). a morphism p : p → g satisfies a condition ∃a (∃(a, c)) over p if there exists an injective morphism q : c → g with q◦a = p (satisfying c). an object g satisfies a condition ∃a (∃(a, c)) if all injective morphisms p : p → g satisfy the 3 / 14 volume 10 (2008) type checking c++ template instantiation by graph programs condition. the satisfaction of conditions over p by objects or morphisms with domain p is extended to boolean formulas over conditions in the usual way. we write p |= c (g |= c) to denote that morphism p (object g) satisfies c. in the context of rules, conditions are called application conditions. we rewrite graphs with rules in the double-pushout approach [eept06]. application conditions specify the applicability of a rule by restricting the matching morphism. definition 2 (rules) a plain rule p = l ← k → r consists of two injective morphisms with a common domain k. l is the rule’s left-hand side, and r its right-hand side. a left application condition ac for p is a condition over l. a rule p̂ = p, ac consists of a plain rule p and an application condition ac for p. l k r g d h m m∗(1) (2) given a plain rule p and injective morphism k → d, a direct derivation consists of two pushouts (1) and (2) where the match m and comatch m∗ are required to be injective. we write a direct derivation g ⇒p,m,m∗ h . given a graph g together with an injective match m : l → g, the direct derivation g ⇒p,m,m∗ h can informally be described as: h is obtained by deleting the image m(l−k) from g and adding r−k. given a rule p̂ = p, ac and a morphism k → d, there is a direct derivation g ⇒p̂,m,m∗ h , if g ⇒p,m,m∗ h , and m |= ac. we now define graph programs as introduced in [hp01]. definition 3 (graph programs) every rule p is a (graph) program. every finite set s of programs is a program. if p and q are programs, then (p; q), p∗ and p↓ are programs. the semantics of a program p is a binary relation jpk⊆gc ×gc on graphs: (1) for every rule p, jpk = { g, h | g ⇒p h}. (2) for a finite set s of programs, js k = ∪p∈s jpk. (3) for programs p and q, j(p; q)k = jqk◦jpk, jp∗k = jpk∗ and jp↓k = { g, h ∈ jpk∗ |¬∃m. h, m ∈ jpk}. programs according to (1) are elementary and a program according to (2) describes the nondeterministic choice of a program. the program (p; q) is the sequential composition of p and q. p∗ is the reflexive, transitive closure of p, and p↓ the iteration of p as long as possible. programs of the form (p; (q; r)) and ((p; q); r) have the same semantics and are considered as equal; by convention, both can be written as p; q; r. we use p↓+ as a shortening of p; p↓. notation. when the label of an element is either a or b we use the notation a|b. l ⇒ r is used a short form of l ← k → r , where k consists of the elements common to l and r. for an application condition with morphism a : p → c, we omit p as it can be inferred from the left-hand side. we omit the application condition if it is satisfied by any match. to distinguish nodes with the same label, we sometimes add an identifier in the form of “label:id”. we use source-code fragments as identifiers and therefore print them in a fixed-width font. proc. gt-vmt 2008 4 / 14 eceasst 3 from source code to source-code graphs in this section, we introduce source-code graphs, the input for our type-checking program, and informally describe how source code is transformed into such graphs. a source-code graph is a graph representation of template definitions, declarations, and expression’s specializations. the type signature of every declared method, function, and operator in a template definition is represented in the graph by an overload forest, see below. expressions that involve parameterized types are represented in the graph by expression paths, explained shortly. for every declaration, the above mentioned graph representations are copied and the parameterized types are replaced by the actual types provided by the declaration. the basic elements of our source-code graphs are nodes for template definitions, declarations, data types, names, type signatures, and expression trees. for quick reference, node and edge labels together with a short explanation are listed below. note that a visualization of an edge as dashed or solid denotes a difference in labels. nodes edges d declaration p actual parameter = comparison e error message t data type c cast without precision loss ex (sub)expression t template definition d deduced type of expression ol overloaded operator w warning message p parameter op operator name pc cast with precision loss r return type r recovered comparison template definitions are represented by t-nodes. two declarations are equivalent if they are based on the same template and have equal lists of template parameters. each class of equivalent declarations are represented by a d-node and denotes a future specialization. each d-node has an incoming edge from the t-node representing the template definition the declaration means to instantiate. possible template parameters are represented by t-nodes. such parameters include classes, structures, fundamental types, and constants. operator-, functionand method names are represented by op-nodes. in [ap07] we show a graph program that generates source-code graphs. example 1 consider the source code with two class-type templates, line 1 and 18, in figure 3. the principal data type is the icon structure with a template parameter for its resolution type. the resolution structure has a constant template parameter for a (quadratic) resolution. for the two unique declarations in main, name lookup and type checking is needed for the expressions on lines 3, 20, 23, 24, 25, 40, and 41. in section 4 we will show how the graph program ttc reports the type clash in the expression on line 41. note that figure 4 shows the source-code graph of the source code example from figure 3 where the above mentioned lines are represented as expression paths. that source-code graph also shows the overload trees for the operators on line 3 and 22. for completeness, some overload paths representing used operations native to c++ are also included, e.g. comparison (<) of integers. we will now introduce some necessary graph-theoretic notions. in particular, we introduce and use expression paths and overload trees to define type safety for graphs. expression paths rep5 / 14 volume 10 (2008) type checking c++ template instantiation by graph programs 1 te m p la te < u n si g n e d sh o r t m y si z e> s tr u c t re s o lu ti o n { 3 c o n st s t a t ic u n si g n e d sh o r t s iz e = m y si z e ; } ; 5 s tr u c t p ix e l { 7 u n si g n e d c h a r re d , g re e n , b lu e ; 9 p ix e l o p e r a to r + ( p ix e l o v e rl a y ) { p ix e l r e s u lt ; 11 r e s u lt . re d = ( re d + o v e rl a y . re d ) / 2 ; r e s u lt . g re e n = ( g re e n + o v e rl a y . g re e n ) / 2 ; 13 r e s u lt . b lu e = ( b lu e + o v e rl a y . b lu e ) / 2 ; r e tu r n r e s u lt ; 15 } } ; 17 te m p la te < ty p e n a m e r e s o l u t io n> 19 s tr u c t ic o n { p ix e l m ic o n [r e s o l u t io n :: s iz e ][ r e s o l u t io n :: s iz e ] ; 21 ic o n < r e s o l u t io n> & o p e r a to r + = ( ic o n < r e s o l u t io n> & o v e rl a y ) { 23 fo r ( in t i = 0 ; i < r e s o l u t io n :: s iz e ; i + + ) { fo r ( in t j = 0 ; j < r e s o l u t io n :: s iz e ; j + + ) { 25 m ic o n [ i ] [ j ] = m ic o n [ i ][ j ] + o v e rl a y . m ic o n [ i ] [ j ] ; } 27 } r e tu r n ∗ th is ; 29 } } ; 31 # d e fi n e l a r g e r e s re s o lu ti o n < 12 8> 33 # d e fi n e s m a l l r e s re s o lu ti o n < 32 > 35 in t m a in ( ) { ic o n < l a r g e r e s> p ic ; 37 ic o n < l a r g e r e s> o v e rl a y ; ic o n < s m a l l r e s> lo w re s ; 39 p ic + = o v e rl a y ; 41 p ic + = lo w re s ; 43 r e tu r n 0 ; } figure 3: two class-type templates. resent the type information from an expression tree and are modeled by exand p-nodes. the root of the tree becomes an ex-node and has an incoming edge from the d-node that represents the specialization in which it will exist. each ex-node has an edge to the op-node denoting the operation’s name. we allow for operators with an arbitrary number of operands, so the children of the root in an expression tree are modeled by a path of p-nodes. if such a child is a subexpression, then the corresponding p-node has an edge to a new expression node. if it is not, then it denotes a type and its p-node has an edge to the t|d-node denoting that type. definition 4 (expression paths) given a graph g and a natural number i, an i-expression path in g is a path ex p0 . . . pi, where the head, ex, is an ex-node and p0, . . . , pi are p-nodes such that, from every node pk, 0 ≤ k < i, the only edge to another p-node is to pk+1. example 2 figure 5 shows (to the left) an expression tree denoting line 41 in example 1 together with its corresponding 2-expression path (to the right). we represent the type signatures of methods with overload forests, trees and paths. a method named method declared in class type class with n parameters is represented by a path of n + 2 ol-nodes. the head of that path has an edge to the op-node representing the name method proc. gt-vmt 2008 6 / 14 e c e a s s t op : < d : icon> d : icon> op : += op : = t : functions & operators t : unsigned short t : int t : bool t : unsigned long long op : ::size d : resolution<128> d : resolution<32> t : const 128 t : const 32 t : main d : main ex pp p ex pp p t : icon ex pp p ex p ex pp p ex p ex pp p ex p ex pp p ex p t : resolutionex pp p ex pp p op : < d : icon> d : icon> op : += op : = t : functions & operators t : unsigned short t : int t : bool t : unsigned long long op : ::size d : resolution<128> d : resolution<32> t : const 128 t : const 32 cpc c pc c pc cpc c pc c pc c pc c c c pc cc ol p ol p ol p ol r ol p ol p ol r ol p ol p ol p ol r ol p ol p ol p ol r ol p ol r ol p ol r f igure 4: a source-code graph split in tw o for sim pler representation, but note that the tw o subgraphs are not disjoint: the nodes w ith identical ids (see the center colum n) are identifi ed. 7 / 1 4 v o lu m e 1 0 (2 0 0 8 ) type checking c++ template instantiation by graph programs += pic low res op : += d : icon> d : icon> t : functions & operators ex p p p p p p figure 5: expression paths represent expression trees. and another edge to the t|d-node representing class. the ol-node at position k (2 ≤ k ≤ n + 1) in the path has an edge to the node denoting the type of the variable at parameter position k−1. the last ol-node in the path has an edge to the t|d-node denoting the return type of method. functions are modeled as methods but as declared in a special class with a name not allowed in the source language, e.g. functions & operators. operator overloading is modeled as functions. in the following operators, methods, and functions are collectively referred to as operators. definition 5 (overload forest) a graph g contains an overload forest iff all ol-nodes in g are part of exactly one overload tree and there exist no pair of overload trees with equivalent roots, see below. an overload tree is a maximal connected subgraph t in g, consisting of only olnodes. t is maximal in the sense that, if an ol-node in t has an edge to an ol-node, then that node is also in t . furthermore, t must have a tree structure, i.e. no cycles and every node has one parent, except for the root. for nodes in t the following holds for them in g: (1) each internal (leaf) node has exactly one p-edge (r-edge) to a t|d-node, one edge from its parent, and no other incoming edges. (2) the root of t has an additional edge to an op-node. (3) no two siblings have a p-edge to the same t|d-node. (4) every node has at most one child that is a leaf. requirements 3 and 4 are necessary to prevent ambiguous type signatures. two roots are equivalent iff there exists an op-node o and t|d-node t, such that both roots have edges to o and t. an i-overload path o0 . . . oi+1 is a path in t from the root to a leaf. the t|d-node to which an r-edge exist from oi+1 is called the return type of the i-overload path. example 3 the overload tree in figure 6 has two 2-overload paths, representing the type signatures of two overloaded operators. the tree represents the operator template on line 22 and the two paths are generated for the two declarations on line 40 and 41 in figure 3. op : += d : icon> t : functions & operators d : icon> ol p ol p ol p ol r ol p ol p ol r figure 6: two overload paths. proc. gt-vmt 2008 8 / 14 eceasst remark 1. the size of a source-code graph grows linearly with the size of the source code that would be output by the template instantiation mechanism in a c++ compiler. an expression or declared operator that exists in such source code is represented only by a single expression path or overload path, respectively. the main property in this paper is the one of type safety. a graph is type safe if for every expression path, there exists an overload path with the same type signature. this property corresponds to type safety for template instantiation in c++ programs, where every generated expression must be type checked against the existing and generated operators. definition 6 (type-safe graphs) a graph g is type safe iff it contains an overload forest and is i-type safe for all natural numbers i. g is i-type safe iff every i-expression path in g is type safe. an i-overload path o0 . . . oi+1 makes the i-expression path ex p0 . . . pi type safe iff: 1. there exists an op-node op and two edges: one from ex to op, the other from o0 to op. 2. for all k, where 0 ≤ k ≤ i, there exists a t|d-node t and two edges, one from ok to t and the other is from pk to either t or the head of a type safe j-expression path such that t is the deduced type of the that j-expression path. the deduced type of the i-expression path is the t|d-node with an incoming r-edge from oi+1. it is easy to see that no overload path from figure 6 makes the expression path in figure 5 type safe. 4 the type-checking program this section describes the graph program ttc which performs the name lookup and type checks source-code graphs. the section also shows how message graphs are interpreted with graph conditions. a schematic of how the subprograms of ttc interact is shown in figure 7. intuitively, ttc works as follows: the input is a source-code graph, each expression path is marked by markexpression, and compare moves this marker through the path until it reaches the tail or a type clash. at a type clash, recover either solves it or generates an error message. for markers at a tail, resolve finds the deduced type of the expression path (i.e. it resolves the type of a subexpression). this chain is then iterated as long as new work is made available by recover and resolve for compare. the yield of ttc is a message graph. programs and rules are described in more detail below. definition 7 (ttc) let the graph program ttc = markexpression↓;typecheck↓ with the subprograms: typecheck = compare↓+;recover↓;afterrecover↓;resolve↓ compare = { lookup,comparenext,findtype } recover = {cast,warning,error} resolve = { resolvesubexpression, resolveexpression1,resolveexpression2 } 9 / 14 volume 10 (2008) type checking c++ template instantiation by graph programs markexpression↓ compare↓+ recover↓ afterrecover↓ resolve↓ source-code graph message graph typecheck↓ figure 7: structure of ttc. markexpression↓ is executed before the actual type checking starts and markss each exnode with an =-edge to show where the evaluation starts. to avoid duplicate evaluation, a loop is also placed at the ex-node and checked for in the application condition. markexpression: op ex ⇒ op = ex , ¬∃ ( op ex ) compare↓+ consists of the rules lookup, comparenext, and findtype, see figure 8. they move the =-edge generated by markexpression through the expression path as long as a matching overload path can be found. the program halts when it completes this matching or encounters a problem: that no overload path makes this expression path type safe or that this node in the path depends on the deduced type of a subexpression. the rule lookup finds the overload tree for a marked expression’s name. comparenext matches the type signature of the expression path to an overload path parameter by parameter. the rule findtype is applied at the tail of the expression path and deduces the expression’s type via the matched overload path’s return type. the rule’s application condition makes sure that this is actually the tail of the expression path. lookup: ex p t|d olop p p = ⇒ ex p t|d olop p p = comparenext: ex p p t|d olol p p = ⇒ ex p p t|d olol p p = findtype: ex p t|d olol r= ⇒ ex p t|d olol d r , ¬∃     ex p p t|d olol r=     figure 8: rules in the program compare. proc. gt-vmt 2008 10 / 14 eceasst recover↓ consists of the rules figure 9 and tries to find alternative overload paths by implicit type casts. the rule cast finds a type cast that causes no loss of precision. warning works as cast but uses a cast with a possible loss of precision. for this we generate a warning, a w-node with three outgoing edges: the location of the problem, the original type, and the cast type. the application condition make sure that cast is preferred. the rule error is applied when there is no solution by implicit type casts. an error node is therefore generated. it has three outgoing edges, to the p-node where it occurred, the faulting type, and a suggested type. the application condition limits error from being applied where cast or warning could be applied instead. cast: p|ex ol|op p ol t|d t|d = p p c ⇒ p|ex ol|op p ol t|d t|d r p p c warning: p|ex ol|op p ol t|d t|d = p p pc ⇒ p|ex ol|op p ol t|d t|d r p p pc w from to ,¬∃          p|ex ol|op p ol t|d t|d = p p pc ol t|d p c          error: p|ex ol|op p ol t|d t|d = p p|r ⇒ p|ex ol|op p ol t|d t|d p p|r e on suggestion , ¬∃          p|ex ol|op p ol t|d t|d = p p|r ol t|d p c|pc          ∧¬∃        p|ex ol|op p ol t|d t|d = p p|r c|pc        figure 9: rules for the program recover. afterrecover↓ performs some cleanup work for recover↓, generated r-edges are reset to =-edges. afterrecover: ex|p r op|ol ⇒ ex|p = op|ol resolve↓ consists of three rules, as shown in figure 10: resolvesubexpression replaces a subexpression with its deduced return type. resolveexpression1 marks an expression as evaluated with a dashed edge. resolveexpression2 does the same in the special case when the return type is the same as the specialization in where the expression occurs. example 4 the graph in figure 11 is the yield of ttc applied to the overload tree from figure 6 and the expression path from figure 5. see [ap07] for more examples. 11 / 14 volume 10 (2008) type checking c++ template instantiation by graph programs resolvesubexpression: p t|d ex d ⇒ p t|d ex p resolveexpression1: d t|d ex d ⇒ d t|d ex resolveexpression2: d d ex ⇒ d ex figure 10: rules in resolve. op : += t : functions & operators d : icon> d : icon> ol pol ol ol ol ol ol p p r p p r ex p p p p p p e on suggestion = = = figure 11: portion of a message graph. remark 2. after the termination of ttc, graph conditions can help to interpret the message graph. a graph is an error (warning) graph iff it satisfies the condition ∃( /0 → e ) (∃( /0 → w )). a particular declaration can safely be instantiated if its corresponding d-node satisfies the condition ¬∃( d → d ex ). if that condition is not satisfied, then one of its expressions could not be resolved and the programmer must take appropriate actions. a message graph will contain all the detected errors for the corresponding source code. graph conditions can therefore help programmers to locate the areas of the graph that contain such errors. an implementation of this approach should be able to highlight the areas containing the errors. remark 3. the size of the resulting message graph will not grow more than linearly with the size of the corresponding source-code graph. this is so since every expression tree can at most be marked by one error message. for size of source-code graphs, see remark 1 5 correctness and termination we now define correctness with respect to errors and termination for graph programs. we give the ideas for proving that ttc terminates and is correct w.r.t. errors. definition 8 (correctness and completeness) a graph program p is correct with respect to errors if for every pair g, h ∈ jpk, h is an error graph implies g is not a type-safe sourcecode graph. if the converse of the implication holds, we say that p is complete w.r.t. errors. proc. gt-vmt 2008 12 / 14 eceasst theorem 1 (correctness) the graph program ttc is correct with respect to errors. proof idea. errors are only generated by recover and consumes an =-edge that should have been consumed by compare↓+, given that ttc were initially dealing with a type-safe sourcecode graph. a complete proof is given in [ap07]. fact 1. the graph program ttc is not complete with respect to errors. e.g. recover uses implicit type casts, and thereby avoids generating errors for some non-type-safe graphs. it has not yet been investigated whether or not other counterexamples exist. definition 9 (termination) termination of a graph program is defined inductively on the structure of programs: (1) every rule p is terminating. (2) for a finite set s of terminating programs, s is a terminating program. (3) for terminating programs p and q, (p; q) is terminating. moreover, p∗ and p↓ is terminating if for every graph g, there is no infinite chain of derivations g ⇒p g1 ⇒p . . . where ⇒p denotes the binary relation jpk on graphs. theorem 2 (termination) the graph program ttc is terminating. proof idea. compare is applied at least once for every iteration of typecheck and consumes solid edges that are not generated by the other subprograms. a complete proof is given in [ap07]. 6 conclusions we considered the template instantiation mechanism in c++ and showed how to write visual rules for type checking and error message generation. we informally described how source code was transformed into source-code graphs and defined type safety for graphs. we transformed source-code graphs into message graphs, a transformation given by the graph program ttc which type checked source-code graphs. the program automatically corrected some errors by implicit type casts. it emitted error messages for type clashes that it could not correct. proof ideas were given for termination and correctness w.r.t. errors. further topics include: 1. analysis of source-code graphs by generalized graph conditions. graph properties like “there exists a warning or error node” can be expressed by graph conditions in the sense of [hp05]. it would be interesting to generalize graph conditions so more complex graph properties like “the graph is type safe” becomes expressible. 2. debugging and a transformation from message graphs to source code. the error messages generated by ttc contained suggestions for remedies. in the double-pushout approach to graph transformation, a central property is the existence of an inverse rule, that when applied reverses the rewrite step of the rule [eept06]. in this way, the inverse rule allows for back tracking to a previous graph which can be manipulated to experiment with suggested remedies. the changes are logged in the output graph (message/change graph) and used by a source-code transformer to update the source code. 13 / 14 volume 10 (2008) type checking c++ template instantiation by graph programs 3. implementation of the approach. this would include a formalization of the transformation from source code to source-code graphs and an extension of the set of considered template features. acknowledgements: this work is supported by the german research foundation (dfg) under grant no. ha 2936/2 (development of correct graph transformation systems). we thank annegret habel for constructive suggestions that improved the paper. bibliography [ag04] d. abrahams, a. gurtovoy. c++ template metaprogramming: concepts, tools, and techniques from boost and beyond. addison-wesley professional, 2004. [ap07] k. azab, k.-h. pennemann. type checking c++ template instantiation (long version). technical report 04/07, university of oldenburg, 2007. available at http://formale-sprachen.informatik.uni-oldenburg.de/%7eskript/fs-pub/templates long.pdf. [ce00] k. czarnecki, u. w. eisenecker. generative programming: methods, tools, and applications. addison-wesley, 2000. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs of theoretical computer science. springer, 2006. [gpg04] t. gschwind, m. pinzger, h. gall. tuanalyzer–analyzing templates in c++ code. in proc. of wcre’04. pp. 48–57. ieee computer society, 2004. [hp01] a. habel, d. plump. computational completeness of programming languages based on graph transformation. lncs 2030, pp. 230–245. springer, 2001. [hp05] a. habel, k.-h. pennemann. nested constraints and application conditions for high-level structures. lncs 3393, pp. 293–308. springer, 2005. [jos99] n. m. josuttis. the c++ standard library: a tutorial and reference. addison-wesley, 1999. [pms06] z. porkoláb, j. mihalicza, á. sipos. debugging c++ template metaprograms. in proc. of gpce’06. pp. 255–264. acm, 2006. [ps04] d. plump, s. steinert. towards graph programs for graph algorithms. lncs 3256, pp. 128– 143. springer, 2004. [str00] b. stroustrup. the c++ programming language. addison-wesley, 3rd edition, 2000. [str04] b. stroustrup. abstraction and the c++ machine model. lncs 3605, pp. 1–13. springer, 2004. [vel98] t. l. veldhuizen. arrays in blitz++. lncs, pp. 223–230. springer, 1998. [vj02] d. vandevoorde, n. m. josuttis. c++ templates: the complete guide. addison-wesley, 2002. proc. gt-vmt 2008 14 / 14 http://formale-sprachen.informatik.uni-oldenburg.de/%7eskript/fs-pub/templates_long.pdf introduction graph programs from source code to source-code graphs the type-checking program correctness and termination conclusions reactive context-aware programming electronic communications of the easst volume 11 (2008) proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) reactive context-aware programming stijn mostinckx, andoni lombide carreton, wolfgang de meuter 13 pages guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst reactive context-aware programming stijn mostinckx, andoni lombide carreton, wolfgang de meuter programming technology lab vrije universiteit brussel abstract: using state of the art tools, context-aware applications are notified of relevant changes in their environment through event handlers which are triggered by dedicated middleware. the events signalled by the middleware should percolate through the entire application, requiring a carefully crafted network of observers combined with complex synchronization code to address the inherent concurrency issues. this paper proposes the adoption of reactive programming techniques to bridge the gap between the event-driven middleware and the application. keywords: fact spaces, reactive programming, ambienttalk 1 introduction the rapidly increasing capabilities of popular mobile computing devices such as cellular phones and pdas herald a future where computing power has truly become ubiquitous. using a presentday cellular phone, a user can interact with other proximate devices using e.g. bluetooth or wireless ethernet. the introduction of near-field communication (nfc) additionally provides cellular phones a means to interact with disposable computers (such as passive and active rfid tags) that can be attached to consumer goods. paralleling the hardware evolutions, various middleware approaches have been proposed to ease the development of context-aware applications which reap the benefits of being surrounded by a cloud of small interconnected devices. certain approaches focus primarily on providing reusable abstractions to interact with sensors (e.g. the context toolkit [dsa01]), while other middleware focusses on the ability to communicate in networks with a fluid topology and transient connectivity. in the latter category, we encounter coordination languages such as lime [mpr01] as well as publish/subscribe middleware such as steam [mc03]. context-aware applications can respond to changes in their environment by registering event handlers with one of these middleware systems. such an event handler is triggered whenever the middleware detects a relevant change in the current context. relying on explicit event handlers has a number of severe consequences on the design of the context-aware application, which we describe in the remainder of this section. in this paper, we propose using reactive programming techniques to deal with context change events. we illustrate by means of a concrete case study (described in section 2) which abstractions are required to be able to write context-aware applications without resorting to an explicit event-driven style. an overview of these abstractions is provided in section 3. before concluding, section 4 discusses the overall architecture of the proposed reactive context-aware programming system and highlights relations to related work. 1 / 13 volume 11 (2008) reactive context-aware programming 1.1 motivation: impact of event handlers on application design relying on explicit event handlers to notify the application of changes to its context introduces a number of problems. a first important issue is that the event handlers are triggered by the middleware, which implies that they may be executed concurrently with the application code. in a programming language with shared state concurrency (such as java), this implies that the application programmer is responsible to avoid race conditions on the application’s state. in other words, if the event handler accesses application data structures, all accesses in the application code (including those in event handlers) should be explicitly protected with locks. another corollary of the fact that the middleware triggers the event handlers is that performing long-lasting computations in the event handler may render the middleware unresponsive. a well-known example of this restriction is found in the documentation of the java swing gui framework, which recommends that event handlers should finish as soon as possible. this particular recommendation provides further encouragement for a programming style where event handlers rely on side effects to signal context changes to the application. when context changes are signalled by modifying shared variables, it is the responsibility of the application programmer to manually keep track of how the different pieces of application code depend on the state of these variables. this implies keeping an explicit network of computations to be notified when changes to these variables are observed. having observed these three problems, we propose the use of reactive programming techniques to establish an expressive binding between context-aware applications and the underlying middleware which avoids these problems altogether. this proposal is based on our experience combining crime, a middleware implementing the fact space model [msp+07] with ambienttalk, a dynamically typed, object-oriented, concurrent language [vmg+07]. 2 case study this section presents the concrete case study we have performed to uncover how to establish an expressive binding between a context-aware application and the underlying middleware in such a way that the event-driven style employed by the middleware does not percolate through the entire design of the application. as the context-aware middleware, we have opted for crime, an implementation of the fact space coordination model [msp+07]. this model provides applications with a logic coordination language to reason about information and services provided by nearby devices. while the adoption of a logic coordination language is novel, the binding between crime and the application is established by means of explicit event handlers to be supplied by the application programmer. in this regard, the fact space model is similar to conventional context-aware middleware such as the context toolkit [dsa01], publish/subscribe middleware such as steam [mc03] or coordination languages such as lime [mpr01]. in our case study, we have established a binding between crime and ambienttalk, an experimental object-oriented language which was explicitly conceived as a language laboratory [mvtt07]. due to its conception as a language laboratory, ambienttalk provides many of the required tools to allow a natural embedding of a domain-specific language (such as the logic coordination language offered by crime). proc. campus 2008 2 / 13 eceasst the remainder of this section describes the concrete case study we have developed in more detail. first, we provide a brief overview of crime, its federated fact space in which applications can publish context information and its logic coordination language which allows triggering application-level reactions to context changes. subsequently, we provide a bird’s eye overview of ambienttalk and we conclude this section by describing a straightforward integration of crime rules in ambienttalk which relies on explicit event handlers. 2.1 fact space model the fact space model [msp+07] is a coordination model which provides applications with a federated fact space: a distributed knowledge base containing logic facts which are implicitly made available for all devices within reach. consequently, when an application asserts a fact in the federated fact space, other devices that are within earshot can see the fact and react to its appearance. to react to the appearance of facts in the federated fact space, applications specify logic rules. these logic rules describe the causal relation between (a combination of) context observations and the application’s reaction. in summary, the fact space model combines the notion of a federated fact space with a logic coordination language. in the remainder of this section we will discuss each of these components in slightly more detail. 2.1.1 federated fact space the fact space model equips every application with a private fact space in which applicationspecific facts can be stored. additionally, applications may use an arbitrary amount of (named) interface fact spaces. facts which are asserted in these interface fact spaces are transparently shared by the underlying implementation (crime) which aggregates all reachable interface fact spaces with the same name into a federated fact space. hence, when interacting with its own interface fact space, the application can transparently access facts published by other devices in its immediate environment. in essence, the distribution semantics of the federated fact space in the fact space model are largely similar to those of the federated tuple space of lime [mpr01]. one notable difference is that whereas tuple spaces are based on the notion of a blackboard where messages can be published, read and removed, fact spaces are conceived as knowledge bases. this implies that in the fact space model both the assertion and retraction of a fact are meaningful events which may trigger reactions. the fact that applications can respond to both the assertion and the retraction of facts is of particular importance when devices go in and out of earshot. for instance, when a new device is discovered, its interface fact space will be engaged. this implies that all its facts will be atomically and transparently asserted in the federated fact space. conversely, when a device goes out of communication range, its interface fact space is said to be disengaged which implies that all facts that it contained are retracted. since retraction is reified by the fact space model, applications which reacted to the appearance of a fact published in the disengaged space (possibly in combination with other facts) are provided with the opportunity to recover from the disappearance of that fact. this mechanism provides the fact space model with fine-grained support for the handling of disconnections [msp+07]. 3 / 13 volume 11 (2008) reactive context-aware programming 2.1.2 logic coordination language the fact space model provides applications with a logic coordination language to cherry pick the relevant context information from the federated fact space. for instance, consider a cellular phone that wants to adapt its sound profile according to its current location. first of all, such an application would contain a set of preferences which detail which sound profile needs to be adopted in various room types. in the example application in listing 1, these preferences are encoded as facts published in the private fact space. listing 1: facts and rules to change the profile of a cellular phone. preference(meetingroom, silent). preference(office, default). :switch(?profile) :location -> detected(myid, ?room), preference(?room, ?profile). subsequently, a crime rule is defined which has two preconditions. first of all, it requires that there is a detected fact in a public fact space (named location), which denotes that the cellular phone is located in a room of a particular kind. the kind of room will be bound to the logic variable ?room. additionally, a preference should be defined which determines the sound profile to be adopted for the given kind of room. when both conditions are met, the profile to adopt will be bound to the logic variable ?profile and the rule will be triggered. when the rule is triggered, it will invoke the application-specific action :switch to ensure the cellular phone adopts the correct sound profile. applications can supply application-level actions (such as :switch) by providing a java class which implements the action interface. such classes need to implement two methods: first of all, the activate method which is invoked whenever a rule is triggered which lists the action in its rule head. second, the deactivate method which is invoked when one of the facts that caused the rule to trigger is retracted. in the example, the deactivate method can be used to make the cellular adopt a loud sound profile. 2.2 ambienttalk as part of our case study, we have allowed crime rules to be embedded into context-aware applications written in ambienttalk [vmg+07]. before discussing this embedding in detail, we provide a bird’s eye overview of the ambienttalk language, which inherits most of its standard language features from self, scheme, smalltalk and e. from scheme, it inherits the notion of true lexically scoped closures. from self and smalltalk, it inherits an expressive block closure syntax, the representation of closures as objects and the use of block closures for the definition of control structures. inspired by self, ambienttalk features classless slot-based objects. the concurrency model of the language was adopted from the e programming language. 2.2.1 ambienttalk objects ambienttalk is a dynamically typed, object-based language. computation is expressed in terms of objects sending messages to one another. objects are not instantiated from classes. proc. campus 2008 4 / 13 eceasst rather, they are either created ex-nihilo or by cloning and adapting existing objects. the code excerpt in listing 2 defines such an ex-nihilo object and binds it to a variable named cellphone. this object serves as a prototypical cellular phone object and can be used to create clones, as shown on the last line. every object understands the message new, which clones the receiver object and initializes the clone by invoking its init method with the arguments passed to new. listing 2: ambienttalk definition of the prototypical behavior of a cellular phone. def cellphone := object: { def inbox := []; // defines a field ’inbox’ def state := profiles.withname("default"); // this method serves as the "constructor" def init(aprofile) { inbox := []; state := aprofile; }; // method to prepend incoming messages to the inbox def receive(ashortmessage) { state.signalmessagereceipt(ashortmessage); inbox := [ashortmessage] + inbox; }; } def myphone := cellphone.new(profiles.withname("silent")); the cellular object object has a state field which is used to determine the sound profile of the cellular phone. for instance, when a short message (sms) is received, the state is consulted to signal the receipt of the message (by e.g. vibrating, blinking or playing a particular ring tone). 2.2.2 concurrent programming in ambienttalk in ambienttalk, concurrency is not spawned by means of threads but rather by means of actors [agh86]. ambienttalk actors are not conceived as active objects, but rather as communicating event loops which encapsulate a suite of objects [mts05]. objects encapsulated by a single actor can communicate by either invoking one another’s methods synchronously or by sending asynchronous messages to one another. communication with objects encapsulated by another actor is only possible by sending them asynchronous messages. when an asynchronous message is sent to an object, it is enqueued in the message queue of the actor that encapsulates that object. the actor’s event loop dequeues such asynchronous messages one by one and invokes the corresponding method of the object denoted as the receiver of the message. by processing messages serially, race conditions on the mutable state of the encapsulated objects are avoided. 2.2.3 embedding languages in ambienttalk ambienttalk is conceived as a language laboratory and hence provides mechanisms which make it straightforward to make both syntactic and semantic extensions to the language. for instance, built-in control structures (e.g. while:do:) and language constructs (e.g. object:) are not conceived to be special. instead, they exploit the fact that ambienttalk supports both canonical syntax and keyworded syntax for method definitions and message sends. since language constructs can be defined as ordinary functions, albeit ones using keyworded syntax, new language constructs can be introduced in a natural way. 5 / 13 volume 11 (2008) reactive context-aware programming ambienttalk provides support for block closures reminiscent of those in self and smalltalk. a block closure is an anonymous function object that encapsulates a piece of code and the bindings of lexically free variables and self. block closures are used to represent delayed computations, such as the branches of an if:then:else: control structure. block closures are constructed by means of the syntax {|args| body}, where the arguments are optional. 2.3 embedding crime into ambienttalk having briefly introduced both crime and ambienttalk, we now describe how crime rules can be embedded in a context-aware application written in ambienttalk. embedding the rules in the context-aware application allows directly passing an ambienttalk object which will implement the application-specific action. as before, objects which are to be used as an application-specific action should implement an activate and a deactivate method. the activate method will be invoked when the rule is triggered, which the deactivate method allows responding to the retraction of facts which led to a previous activation. listing 3 defines a switch object which implements both methods. upon activation it modifies the sound profile of the cellular phone to correspond to the preference derived by the rule. when the object is signalled that the previously adopted profile is no longer relevant (e.g. because the user has changed location), it will adopt a loud sound profile. listing 3: symbiotically changing the profile of a cellular phone. def switch := object: { def activate(p) { myphone.state:= profiles.withname(p); }; def deactivate(p) { myphone.state:= profiles.withname("loud"); }; }; publish: { preference(meetingroom, silent) }; publish: { preference(office, default) }; trigger: switch whenincontext: { public -> location(myid, ?room); preference(?room, ?p); }; interacting with the underlying crime engine is achieved through the introduction of new dedicated language constructs. first of all, a publish: construct is provided which expects a block closure. the body expression of this closure will be interpreted as a crime fact which is published privately by the underlying engine1. second, a trigger:whenincontext: construct is provided to register an ambienttalk object as the application-level action to be performed whenever a set of context conditions (described in a block closure) are met. whenever an embedded rule is triggered, the crime engine will invoke the activate method of the ambienttalk object that was designated to be the corresponding applicationlevel action. however, rather than invoking the method directly on the ambienttalk object, crime interacts with a dynamically generated proxy object, which implements the action interface. this proxy object translates method invocations from a java thread into asynchronous messages [vmd07]. this translation step ensures that context event handlers can never be run in parallel with application code. moreover, since the proxy can determine that the thread of the reasoning engine is not awaiting a result, it can resume immediately [vmd07]. 1 similarly a publish:in: construct is provided which allows publishing a fact in a named public fact space. proc. campus 2008 6 / 13 eceasst one remaining issue is that dependencies on the context-dependent part of the application need to be managed manually. managing such dependencies requires the programmer to resort to registering observers and firing events manually. the next section discusses how this issue can be addressed in a structured fashion through the introduction of reactive programming techniques. 3 reactive context-aware programming reactive programming is a programming paradigm built around the notion of time-varying values (called dataflows or signals). changes to the values of these signals are automatically propagated to a network of dependent computations. reactive programs construct this network either by explicitly wiring signals, or implicitly by calling lifted functions which operate on signals rather than ordinary values [eh97, ck06]. whether one can apply a lifted function on a signal depends on whether the signal is continuous, i.e. whether it has a value at each point in time. continuous signals (called behaviors) form the crux of the reactive programming model: by applying lifted functions on them, a dependent behavior is constructed transparently. subsequent changes of the behaviors that were passed as arguments to the lifted function will be propagated transparently to the dependent behavior, allowing its value to be recomputed. signals which only carry events at discrete points in time are called event sources. these need to be manipulated using explicit operations (e.g. filter, merge and map). event sources provide a natural mechanism to interact with the real world, where events can be generated by input/output devices such as mice or keyboards. a contribution of this paper is that it maps the events generated by context-aware middleware onto event sources in a reactive program. 3.1 reactive programming in ambienttalk since ambienttalk is an object-oriented programming language, we have explored an objectoriented reactive programming style to ease the transition from context-aware middleware to application-level code. we adopt the embedding strategy proposed in frtime [ck06], where reactive programming concepts are embodied in a host language. this implies that evaluating method invocations can be used to implicitly construct a network of dependent computations. consider for instance a behavior that denotes the current temperature in the room (tempbeh)2. when we compare the temperature behavior to a constant (tempbeh < 18), the receiver of the < method is a behavior. hence, the < method is implicitly lifted and a dependent behavior (which will alternate between true and false) is created. the initial value of the dependent behavior is computed by comparing the current value of tempbeh to 18. whenever tempbeh changes, the dependent behavior will be recomputed as well. methods are not only lifted implicitly when their receiver is a behavior, but also when one or more behaviors are passed as arguments. for instance, if we invert the above comparison (18 > tempbeh), the receiver of the > method is a plain ambienttalk object (the number 18). however, since the argument of the method is a behavior (tempbeh), the method will still be lifted and yield a dependent behavior which alternates between true and false. 2 how to create such a behavior from a context query is illustrated in listing 5. 7 / 13 volume 11 (2008) reactive context-aware programming 3.2 mapping context events to behaviors having introduced support for reactive programming in ambienttalk, it is possible to consider a more expressive embedding of crime rules in the language. since crime essentially fires events whenever an interesting context change occurs, it seems natural to provide a construct which installs a rule and returns an event source which may be used in the context-aware application. the contextquery: construct does just that: it takes a block closure as an argument and installs a crime rule with the content of this block as its precondition. the head of the rule, which is supplied implicitly, is a built-in action which will emit an event to the event source that is returned by the construct. as an example, consider a context-aware application which displays the current room temperature on a gauge user interface component. listing 4 contains an excerpt of the required code to build such an application. the contextquery: construct is used to create an event source which carries events containing the current room temperature. these events are ambienttalk objects which define corresponding fields for all variables bound by the query, to wit ?room and ?temperature. to distinguish between events which signal activation and deactivation of the rule, events are tagged with the activated or deactivated type tag3. listing 4: representing the outcome of a context query as an event source. def gauge := gaugewidget.new(...); def tempsrc := contextquery: { public -> location(myid, ?room); public -> temperature(?room, ?temperature); }; tempsrc.foreach: { | event | if: (is: event taggedas: activated) then: { gauge.setheight(event.temperature); } else: { // deactivated gauge.setheight(nil); } } listing 4 illustrates the fallacies of having to directly interact with event sources: the programmer still has to manually construct a network of dependent computations using dedicated operators (e.g. foreach: which is used in the example). as we have already mentioned earlier in this section, the chief expressive gain of reactive programming is obtained when applying lifted functions to behaviors. to appreciate the difference between both styles, consider the code in listing 5, which uses a behavior to represent the current temperature. this behavior is created using the mostrecent:fromcontext: construct which extracts one of the variables bound in the query, to wit the ?temperature. listing 5: constructing a behavior from a context query. def tempbeh := mostrecent: ?temperature fromcontext: { public -> location(myid, ?room); public -> temperature(?room, ?temperature); }; gauge.setheight(tempbeh); 3 type tags are introduced as a strictly nominal type system in ambienttalk to allow for the classification of objects. they are best compared to empty ‘marker’ interfaces such as cloneable and serializable in java. proc. campus 2008 8 / 13 eceasst using such a behavior, the setheight method needs to be invoked only once (as if to initialize the gauge). since the argument is a behavior, the method is implicitly lifted, such that it will be invoked again whenever the temperature changes. in this setup, retraction is handled by the mostrecent:fromcontext: construct by setting the value to nil. 3.3 reactive context-aware collections when converting an event source into a behavior, keeping track of the last propagated event seems to be an intuitive solution. however, this particular type of conversion is rarely the most appropriate one in a context-aware application. consider for example, context queries to detect nearby users, context-aware reminders to be delivered to you, or nearby products which are on your shopping list. each of these queries conceptually returns a group of results which are not adequately represented by only keeping track of the last event fired by the middleware. modelling the results of such context queries is achieved through the introduction of reactive context-aware collections. these collections allow abstracting over the events fired by crime such that the programmer who can work directly with the results of the query in a collection. since the collection is modelled as a behavior, updates to the collection are implicitly propagated through the application. listing 6 illustrates how to construct such a collection using the collect:fromcontext: language construct. listing 6: constructing a reactive context-aware collection. def nearbybeh := collect: ?user fromcontext: { public -> location(myid, ?room); public -> location(?user, ?room); ?user != myid; }; the example in listing 6 accumulates all bindings for the ?user variable in the given query. the resulting context-aware collection hence contains all collocated users. note that the accuracy of the reactive context-aware collections hinges on the fact that crime reifies both the assertion and retraction of information. without proper support for fine-grained reactions to the retraction of facts, context-aware collections would grow monotonously. since retraction is properly reified, results can be deleted from the collection such that it always provides an up-to-date view on the current context. 3.4 summary having presented an overview of the binding we have developed between ambienttalk and crime, the characteristics of a reactive context-aware programming system can be clearly identified. first of all, the programming language should provide support for reactive programming, such that it is possible to apply lifted methods to behaviors. this is essential to abstract over the underlying propagation of (context change) events in the system. secondly, the programming language should adopt an event loop concurrency model, which ensures that reactive computation (propagating events and performing the dependent computations) can never be performed in parallel with application code. since race conditions are avoided, methods which perform side effects can be safely lifted to be applied on behaviors. 9 / 13 volume 11 (2008) reactive context-aware programming thirdly, to cater to the fact that context queries may report more than a single result, we advocate the introduction of reactive context-aware collections. these collections provide the reactive program with a collection of valid results, which is assembled by interpreting the events sent by the underlying middleware. finally, to uphold the consistency of the reactive context-aware collections, the underlying middleware should not only reify the appearance of new information but also the disappearance of information. the latter is a cue for removing the corresponding result of the context query from the associated collection. 4 discussion context management reify disappearance of information reactive programming reactive context-aware collections event-loop concurrency figure 1: a reactive context-aware architecture this paper proposes reactive contextaware programming, a paradigm which allows context-aware applications to abstract from the underlying events that result from interacting with the real world. figure 1 provides an architectural overview of a reactive context-aware programming system. the system relies on the adoption of an event-loop concurrency model which ensures that concurrency within an event loop can be avoided. underneath, a reactive programming system is provided to abstract over the events produced by the context management layer. the introduction of reactive programming techniques avoids having to design context-aware applications using explicit event handlers. the use of reactive programming techniques to model context-aware application raises the level of abstraction at which the programmer reasons about the problem. the expressive power of using reactive programming has previously been illustrated in the context of user interface interaction [eh97]. in this field, application design was similarly sprinkled with event handlers, using side effects to communicate, and requiring manually managed dependencies. when moving from user interface interaction to context-aware applications, an important observation is that the occurrence of a new event no longer automatically invalidates previous events. many context-aware queries conceptually return a group of results, such as the collection of all collocated users. reactive context-aware collections were proposed as a mechanism to capture the results of such queries, while still allowing for a reactive programming style. the idea of using context-aware collections to bridge the gap between context-aware applications and the underlying middleware was originally proposed by payton et al. [prj04]. however, the collections they proposed could only be accessed using synchronous operations such as get proc. campus 2008 10 / 13 eceasst and remove. hence, to be notified of interesting context changes, applications have to poll the collection regularly. this pattern makes it cumbersome to develop applications which react to changes in their environment. the introduction of reactive context-aware collections reconciles the notion of context queries yielding multiple results with a reactive programming style. when accumulating the results of a context query, being able to determine when a result is no longer valid is crucial. for this purpose, the underlying context management layer should reify not only the appearance of new information (which may add new results to the collection) but also the disappearance of information (which causes results to become invalid). crime is able to signal the disappearance of information since its forward chaining infrastructure intrinsically stores which (implicit) event handlers need to be notified when a particular fact is removed [msp+07]. in spite of the fact that middleware approaches such as facts [tws06], sentient objects [bc04] and gaia [rc03] provide a similar model based on distributed facts, rules and functions, these functions are only called when the corresponding rule is triggered by the appearance of new information. as such they cannot be directly used as a substrate on which a reactive context-aware programming system can be built. 5 conclusion writing context-aware applications involves reacting to changes in the environment to adopt or fire the correct behavior. using state of the art middleware, applications are required to register event handlers which will be triggered when context changes occur. relying on explicit event handlers has effects which percolate throughout the entire design of the application, as access to shared data needs to be protected from race conditions and context dependencies in the program need to be encoded manually by registering observers. in this paper we have advocated the use of reactive programming techniques to abstract from the propagation of events in a context-aware application. the adoption of reactive programming introduces some hurdles to overcome. first of all, classic reactive programming approaches introduce a second independent thread which propagates events and executes dependent computations. since reactive programming is traditionally employed in a purely functional language, the introduction of a parallel process is not deemed harmful. in our case study, we have shown that it is possible to reconcile reactive programming with an imperative object-oriented language, provided that objects are properly encapsulated in an event loop. adopting such an event loop concurrency model ensures that an object’s methods are only invoked by the owning event loop and allows the safe interleaving of reactive computation with application behavior. much of the expressive gain when using reactive programming stems from the ability to apply lifted methods to behaviors, such that the result of the method will be recomputed implicitly whenever the value of the behavior changes. when mapping events generated by context-aware middleware to such behaviors, we observe that context queries often return a collection of interesting values. therefore, we advocate in favor of the adoption of reactive context-sensitive collections which accumulate all relevant context information returned by a single context query. to keep these collections up to date, the context-aware middleware should have a mechanism to detect obsolete context information, such that it can be removed from the collection. 11 / 13 volume 11 (2008) reactive context-aware programming based on these observations, we propose a model for reactive context-aware programming which entails 1) a context middleware with support to detect the invalidity of context information, 2) a programming language with an event loop concurrency model, 3) language-level support for reactive programming and 4) a library of reactive context-sensitive data structures which provide the programmer the necessary abstractions to model and react to context changes. acknowledgements: stijn mostinckx and andoni lombide carreton are funded by a doctoral scholarship of the institute for the promotion of innovation through science and technology in flanders (iwt-vlaanderen). the authors would like to thank tom van cutsem and the anonymous reviewers for their insightful comments which benefitted the clarity of the paper. bibliography [agh86] g. agha. actors: a model of concurrent computation in distributed systems. mit press, 1986. [bc04] g. biegel, v. cahill. a framework for developing mobile, context-aware applications. in tripathi et al. (eds.), proc. of the 2nd int. conf. on pervasive computing and communications (percom). pp. 361–365. ieee comp. soc., mar. 2004. [ck06] g. cooper, s. krishnamurthi. embedding dynamic dataflow in a call-by-value language. in sestoft (ed.), programming languages and systems. lect notes comput sc 3924, pp. 294–308. springer verlag, mar. 2006. [dsa01] a. k. dey, d. salber, g. d. abowd. a conceptual framework and a toolkit for supporting the rapid prototyping of context-aware applications. human-computer interaction 16(2–4):97–166, 2001. [eh97] c. elliott, p. hudak. functional reactive animation. in tofte (ed.), proc. of the 2nd int. conf. on functional programming (icfp). pp. 263–273. acm press, 1997. [mc03] r. meier, v. cahill. exploiting proximity in event-based middleware for collaborative mobile applications. in stefani et al. (eds.), proc. of the 4th ifip int. conf. on distributed applications and interoperable systems (dais). lect notes comput sc 2893, pp. 285–296. springer verlag, nov. 2003. [mpr01] a. l. murphy, g. p. picco, g.-c. roman. lime: a middleware for physical and logical mobility. in dasgupta and zhao (eds.), proc. of the 21st int. conf. on distributed computing systems (icdcs). pp. 524–536. ieee comp. soc., apr. 2001. [msp+07] s. mostinckx, c. scholliers, e. philips, c. herzeel, w. de meuter. fact spaces: coordination in the face of disconnection. in murphy and vitek (eds.), proc. of the 9th int. conf. on coordination models and languages (coordination). lect notes comput sc 4467, pp. 268–285. springer verlag, june 2007. [mts05] m. miller, e. d. tribble, j. shapiro. concurrency among strangers: programming in e as plan coordination. in nicola and sangiorgi (eds.), proc. of the sym. on trustworthy global computing (tgc). lect notes comput sc 3705, pp. 195–229. springer verlag, apr. 2005. proc. campus 2008 12 / 13 eceasst [mvtt07] s. mostinckx, t. van cutsem, s. timbermont, e. tanter. mirages: behavioral intercession in a mirror-based architecture. in costanza and hirshfeld (eds.), proc. of the dynamic languages sym. (dls). pp. 222–248. acm press, oct. 2007. [prj04] j. payton, g.-c. roman, c. julien. context-sensitive data structures supporting software development in ad hoc mobile settings. in choren et al. (eds.), proc. of the 3rd int. workshop on software engineering for large-scale multi-agent systems (selmas). pp. 34–41. may 2004. [rc03] a. ranganathan, r. h. campbell. an infrastructure for context-awareness based on first order logic. personal and ubiquitous computing 7(6):353–364, dec. 2003. [tws06] k. terfloth, g. wittenburg, j. h. schiller. facts a rule-based middleware architecture for wireless sensor networks. in sanjoy and venkatesh (eds.), proc. of the 1st int. conf. on communication system software and middleware (comsware). pp. 1–8. ieee comp. soc., jan. 2006. [vmd07] t. van cutsem, s. mostinckx, w. de meuter. lymguistic symbiosis between actors and threads. in perrot and demeyer (eds.), proc. of the int. conf. on dynamic languages (icdl). acm press, aug. 2007. [vmg+07] t. van cutsem, s. mostinckx, e. gonzalez boix, j. dedecker, w. de meuter. ambienttalk: object-oriented event-driven programming in mobile ad hoc networks. in astudillo and tanter (eds.), proc. of the xxvi int. conf. of the chilean computer science society (sccc). pp. 3–12. ieee comp. soc., nov. 2007. 13 / 13 volume 11 (2008) introduction motivation: impact of event handlers on application design case study fact space model federated fact space logic coordination language ambienttalk ambienttalk objects concurrent programming in ambienttalk embedding languages in ambienttalk embedding crime into ambienttalk reactive context-aware programming reactive programming in ambienttalk mapping context events to behaviors reactive context-aware collections summary discussion conclusion from model transformation to model integration based on the algebraic approach to triple graph grammars electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) from model transformation to model integration based on the algebraic approach to triple graph grammars hartmut ehrig , karsten ehrig and frank hermann 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst from model transformation to model integration based on the algebraic approach to triple graph grammars hartmut ehrig1 , karsten ehrig2 and frank hermann1 1 [ehrig, frank](at)cs.tu-berlin.de institut für softwaretechnik und theoretische informatik technische universität berlin, germany 2 karsten@mcs.le.ac.uk department of computer science university of leicester, united kingdom abstract: success and efficiency of software and system design fundamentally relies on its models. the more they are based on formal methods the more they can be automatically transformed to execution models and finally to implementation code. this paper presents model transformation and model integration as specific problem within bidirectional model transformation, which has shown to support various purposes, such as analysis, optimization, and code generation. the main purpose of model integration is to establish correspondence between various models, especially between source and target models. from the analysis point of view, model integration supports correctness checks of syntactical dependencies between different views and models. the overall concept is based on the algebraic approach to triple graph grammars, which are widely used for model transformation. the main result shows the close relationship between model transformation and model integration. for each model transformation sequence there is a unique model integration sequence and vice versa. this is demonstrated by a quasi-standard example for model transformation between class models and relational data base models. keywords: model transformation, model integration, syntactical correctness 1 introduction whenever one can expect benefits out of different modeling languages for the same specific task there is a substantial motivation of combining at least two of the them. for this purpose it is useful to have model transformations between these modeling languages together with suitable analysis and verification techniques. in cases of bidirectional model transformation the support for the modeling process increases, for instance, if results of analysis can be translated backwards to mark the original source of deficiency or defect, respectively. in [eee+07] ehrig et al. showed how to analyze bi-directional model transformations based on triple graph grammars [sch94, ks06] with respect to information preservation, which is especially important to ensure the benefits of other languages for all interesting parts of models. 1 / 14 volume 10 (2008) mailto:[ehrig,~frank](at)cs.tu-berlin.de mailto:karsten@mcs.le.ac.uk model integration triple graph grammars are based on triple rules, which allow to generate integrated models g consisting of a source model gs, a target model gt and a connection model gc together with correspondences from gc to gs and gt . altogether g is a triple graph g = (gs ← gc → gt ). from each triple rule tr we are able to derive a source rule trs and a forward rule trf , such that the source rules are generating source models gs and the forward rules allow to transform a source model gs into its corresponding target model gt leading to a model transformation from source to target models. on the other hand we can also derive from each triple rule tr a target rule trt and a backward rule trb, such that the target rules are generating target models gt and backward rules transform target models to source models. the relationship between these forward and backward model transformation sequences was analyzed already in [eee+07] based on a canonical decomposition and composition result for triple transformations. in this paper we study the model integration problem: given a source model gs and a target model gt we want to construct a corresponding integrated model g = (gs ← gc → gt ). for this purpose, we derive from each triple rule tr an integration rule tri , such that the integration rules allow to define a model integration sequence from (gs, gt ) to g. of course, not each pair (gs, gt ) allows to construct such a model integration sequence. in our main result we characterize existence and construction of model integration sequences sequences from (gs, gt ) to g by model transformation sequences from gs to gt . this main result is based on the canonical decomposition result mentioned above [eee+07] and a new decomposition result of triple transformation sequences into source-targetand model integration sequences. in section 2 we review triple rules and triple graph grammars as introduced in [sch94] and present as example the triple rules for model transformation and integration between class models and relational data base models. model transformations based on our paper [eee+07] are introduced in section 3, where we show in addition syntactical correctness of model transformation. the main new part of this paper is model integration presented in section 4 including the main results mentioned above and applied to our example. related and future work are discussed in sections 5 and 6, respectively. 2 review of triple rules and triple graph grammars triple graph transformation [sch94] has been shown to be a promising approach to consistently co-develop two related structures. bidirectional model transformation can be defined using models consisting of a pair of graphs which are connected via an intermediate correspondence graph together with its embeddings into the source and target graph. in [ks06], königs and schürr formalize the basic concepts of triple graph grammars in a set-theoretical way, which was generalized and extended by ehrig et. el. in [eee+07] to typed, attributed graphs. in this section, we shortly review main constructions and relevant results for model integration as given in [eee+07]. definition 1 (triple graph and triple graph morphism) three graphs sg, cg, and t g, called source, connection, and target graphs, together with two graph morphisms sg : cg → sg and tg : cg → t g form a triple graph g = (sg sg← cg tg→ t g). g is called empty, if sg, cg, and t g are empty graphs. proc. gt-vmt 2008 2 / 14 eceasst a triple graph morphism m = (s, c,t) : g → h between two triple graphs g = (sg sg← cg tg→ t g) and h = (sh sh←ch th→ t h) consists of three graph morphisms s : sg → sh, c : cg →ch and t : t g → t h such that s◦sg = sh ◦c and t ◦tg = th ◦c. it is injective, if morphisms s, c and t are injective. triple graphs g are typed over a triple graph tg = (tgs ← tgc → tgt ) by a triple graph morphism tg : g → tg. type graph of the example is given in fig. 1 showing the structure of class diagrams in source component and relational databases in target component. where classes are connected via associations the corresponding elements in databases are foreign keys. though, the complete structure of correspondence elements between both types of models is defined via the connection component of t g. throughout the example, originating from [eee+07], elements are arranged left, center, and right according to the component types source, correspondence and target. morphisms starting at a connection part are given by dashed arrow lines. class name: string table name: string src classtablerel association name: string primitivedatatype name: string fkey assocfkeyrel attrcolrel column type: string name: string cols fkeys referencesdest fcols pkey attribute is_primary: boolean name: string attrs source component connection component target component type parent type figure 1: triple type graph for cd2rdbm model transformation a triple rule is used to build up source and target graphs as well as their connection graph, i.e. to build up triple graphs. structure filtering which deletes parts of triple graphs, is performed by projection operations only, i.e. structure deletion is not done by rule applications. thus, we can concentrate our investigations on non-deleting triple rules without any restriction. definition 2 (triple rule tr and triple transformation step) a triple rule tr consists of triple graphs l and r, called left-hand and right-hand sides, and an injective triple graph morphism tr = (s, c,t) : l → r. given a triple rule tr = (s, c,t) : l → r, a triple graph g and a triple graph morphism m = (sm, cm,tm) : l → g, called triple match m, a triple graph transformation step (tgt-step)g = tr,m ==⇒ h from g to a triple graph h is given by three pushouts (sh, s′, sn), (ch, c′, cn) and (t h,t′,tn) in category graph with induced l = (sl tr �� s �� cl sloo c �� tl // t l) t �� r = (sr crsr oo tr // t r) sl �� sm yyrrr cloo // �� cm ~~}} t l �� tm ||yy g = (sg tr �� s ′ �� cgoo // c′ �� t g) t′ �� sr snyy croo // cn~~ t r tn||yy h = (sh chsh oo th // t h) morphisms sh : ch → sh and th : ch → t h. morphism n = (sn, cn,tn) is called comatch. moreover, we obtain a triple graph morphism d : g → h with d = (s′, c′,t′) called transformation morphism. a sequence of triple graph transformation steps is called triple (graph) transformation sequence, short: tgt-sequence. furthermore, a triple graph grammar tgg = (s, t r) 3 / 14 volume 10 (2008) model integration consists of a triple start graph s and a set t r of triple rules. given a triple rule tr we refer by l(tr) to its left and by r(tr) to its right hand side. remark 1 (gluing construction) each of the pushout objects sh,ch, t h in def. 2 can be constructed as a gluing construction, e.g. sh = sg +sl sr, where the s-components sg of g and sr of r are glued together via sl. :class {new} name = n :table {new} name = n :classtablerel {new} :class :table :attrs {new} :classtablerel :attribute {new} name = an primary = true :primitivedatatype {new} name = t :column {new} type = t name = an:attrcolrel {new} :cols {new} :type {new} :class :table :attrs :classtablerel :attribute is_primary = true :column :attrcolrel :cols :pkey {new} :class :table :parent {new} :classtablerel :classtablerel {new} :class {new} name=n class2table(n:string) setkey() primaryattribute2column(an:string, p:boolean, t:string) subclass2table(n:string) figure 2: tgt-rules for cd2rdbm model transformation :class :table :classtablerel {new} :association {new} name = an :src {new} :class :dest {new} :fkey {new} :table :assocfkeyrel {new} :classtablerel :column {new} type = t name = an+“_“+cn :cols {new} :fcols {new} :fkeys {new} :references {new} :column type = t name = cn :pkey figure 3: rule association2foreignkey(an : string) for cd2rdbm model transformation examples for triple rules are given in fig. 2 and fig. 3 in short notation. left and right hand side of a rule are depicted in one triple graph. elements, which are created by the rule, are labeled with ”new” and all other elements are preserved, meaning they are included in the left and right hand side. rule ”class2table” synchronously creates a class in a class diagram with its corresponding table in the relational database. accordingly the other rules create parts in all components. for rule ”primaryattribute2column” there is an analogous rule ”attribute2column” for translation of non primary attributes, which does not add the edge ”:pkey” in the database component. 3 model transformation the triple rules t r are defining the language vl = {g| /0 ⇒∗ g via tr} of triple graphs. as shown already in [sch94] we can derive from each triple rule tr = l → r the following source and forward rule. forward rules are used for model transformations from a model of a source language to models of the target language. source rules are important for analyzing properties of forward transformations such as information preservation, presented in [eee+07]. proc. gt-vmt 2008 4 / 14 eceasst l = (sl tr �� s �� cl sloo c �� tl // t l) t �� r = (sr crsr oo tr // t r) triple rule tr (sr id �� cl s◦sloo c �� tl // t l) t�� (sr cr sroo tr // t r) forward rule trf (sl s �� /0oo �� // /0) �� (sr /0oo // /0) source rule trs for simplicity of notation we sometimes identify source rule trs with sl −s→ sr and target rule trt with tl −t→ tr. theses rules can be used to define a model transformation from source graphs to target graphs. vice versa using backward rules which are dual to forward rules it is also possible to define backward transformations from target to source graphs and altogether bidirectional model transformations. in [eee+07] we have shown that there is an equivalence between corresponding forward and backward tgt sequences. this equivalence is based on the canonical decomposition and composition result (thm. 1) and its dual version for backward transformations. definition 3 (match consistency) let tr∗s and tr ∗ f be sequences of source rules tris and forward rules trif , which are derived from the same triple rules tri for i = 1, . . . , n. let further g00 = tr∗s=⇒ gn0 = tr∗f=⇒ gnn be a tgt-sequence with (mis, nis) being match and comatch of tris (respectively (mi, ni) for trif ) then match consistency of g00 = tr∗s=⇒ gn0 = tr∗f=⇒ gnn means that the s-component of the match mi is uniquely determined by the comatch nis (i = 1, . . . , n). theorem 1 (canonical decomposition and composition result forward rule case) 1. decomposition: for each tgt-sequence based on triple rules tr∗ (1) g0 = tr∗ =⇒ gn there is a canonical match consistent tgt-sequence (2) g0 = g00 = tr∗s=⇒ gn0 = tr∗f=⇒ gnn = gn based on corresponding source rules tr∗s and forward rules tr∗f . 2. composition: for each match consistent transformation sequence (2) there is a canonical transformation sequence (1). 3. bijective correspondence: composition and decomposition are inverse to each other. proof. see [eee+07]. now we want to discuss under which conditions forward transformation sequences g1 = tr∗f=⇒ gn define a model transformation between suitable source and target languages. in fact we have different choices: on the one hand we can consider the projections v ls = pro js(v l) and v lt = pro jt (v l) of the triple graph language v l = {g| /0 =⇒∗ g via tr}, where pro jx is a projection defined by restriction to one of the triple components, i. e. x ∈{s,c, t}. on the other hand we can use the source rules trs = {trs |tr ∈ tr} and the target rules trt = {trt |tr ∈ tr} to define the source language vls0 = {gs | /0 =⇒∗ gs via trs} and the target language vlt 0 = {gt | /0 =⇒∗ gt via trt}. since each sequence /0 =⇒∗ g via tr can be restricted to a source sequence /0 =⇒∗ gs via trs and to a target sequence /0 =⇒∗ gt via trt we have vls ⊆ vls0 and 5 / 14 volume 10 (2008) model integration vlt ⊆ vlt 0, but in general no equality. in case of typed graphs the rules in tr are typed over tg with tg = (tgs ← tgc → tgt ) and rules of trs and trt typed over (tgs ← /0 → /0) and ( /0 ← /0 → tgt ), respectively. since gs and gt are considered as plain graphs they are typed over tgs and tgt , respectively. given a forward transformation sequence g1 = tr∗f=⇒ gn we want to ensure the source component of g1 corresponds to the target component of gn, i.e. the transformation sequence defines a a model transformation mt from vls0 to vlt 0, written mt : vls0 v vlt 0, where all elements of the source component are translated. thus given a class diagram as instance of the type graph in fig. 1 all corresponding tables, columns and foreign keys of the corresponding data base model shall be created in the same way they could have been synchronously generated by the triple rules of tr. an example forward transformation is presented in [eee+07]. since gs ∈ vls0 is generated by trs-rules we have a source transformation /0 =⇒∗ gs via trs. in order to be sure that g1 = tr∗f=⇒ gn transforms all parts of g1, which are generated by /0 =⇒∗ gs, we require that /0 =⇒∗ gs is given by /0 = tr∗s=⇒ g1 with g1 = (gs ← /0 → /0), i.e. projs(g1) = gs based on the same triple rule sequence tr∗ as g1 = tr∗f=⇒ gn. finally we require that the tgt-sequence /0 = tr∗s=⇒ g1 = tr∗f=⇒ gn is match consistent, because this implies – by fact 1 below – that gs ∈ vls and gt ∈ vlt and that we obtain a model transformation mt : vls v vlt (see fact 1). definition 4 (model transformation) a model transformation sequence (gs, g1 = tr∗f=⇒ gn, gt ) consists of a source graph gs, a target graph gt , and a source consistent forward tgt-sequence g1 = tr∗f=⇒ gn with gs = projs(g1) and gt = projt (gn). source consistency of g1 = tr∗f=⇒ gn means that there is a source transformation sequence /0 = tr∗s=⇒ g1, such that /0 = tr∗s=⇒ g1 = tr∗f=⇒ gn is match consistent. a model transformation mt : vls0 v vlt 0 is defined by model transformation sequences (gs, g1 = tr∗f=⇒ gn, gt ) with gs ∈ vls0 and gt ∈ vlt 0. remark 2 a model transformation mt : vls0 v vlt 0 is a relational dependency and only in special cases a function. this allows to show that mt : vls0 v vlt 0 defined above is in fact mt : vls v vlt fact 1 (syntactical correctness of model transformation mt ) given gs ∈ vls0 and g1 = tr∗f=⇒ gn source consistent with pro js(g1) = gs then gt = pro jt (gn) ∈ vlt and gs ∈ vls, i.e. mt : vls v vlt . proof. given g1 = tr∗f=⇒ gn source consistent, we have /0 = tr∗s=⇒ g1 = tr∗f=⇒ gn match consistent and hence, by theorem 1 above with g0 = /0 = tr∗ =⇒ gn which implies gn ∈ vl. now we have projs(gn) = projs(g1) = gs ∈ vls and projt (gn) = gt ∈ vlt . proc. gt-vmt 2008 6 / 14 eceasst 4 model integration given models gs ∈vls0 and gt ∈vlt 0 the aim of model integration is to construct an integrated model g ∈ vl, such that g restricted to source and target is equal to gs and gt , respectively, i.e. projsg = gs and projt g = gt . thus, given a class diagram and a data base model as instance of the type graph in fig. 1 all correspondences between their elements shall be recovered or detected, respectively. similar to model transformation we can derive rules for model integration based on triple rule tr. the derived rules are source-target rule trst and integration rule tri given by (sl s �� cl sloo c �� tl // t l) t �� (sr crsr oo tr // t r) triple rule tr (sl s �� /0oo �� // tl) t �� (sr /0oo // tr) source-target rule trst (sr id �� cl s◦sloo c �� t◦tl // tr) id�� (sr cr sroo tr // tr) integration rule tri an example for both kinds of rules is given in fig. 4 for the triple rule class2table in fig. 2. :classtablerel {new} :table name = n :class name = n (a) integration rule class2tablei :class{new} name = n :table{new} name = n (b) source-target rule class2tablest figure 4: derived rules for class2table() similar to the canonical decomposition of tgt-sequences g0 = tr∗ =⇒ gn into source and forward transformation sequences we also have a canonical decomposition into source-target and integration transformation sequences of the form /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn. such a sequence is called s-t -consistent, if the sand t -component of the comatch of trist is completely determined by that of the match of trii for tr = (tri)i=1...n. theorem 2 (canonical decomposition and composition result integration rule case) 1. decomposition: for each tgt-sequence based on triple rules tr∗ (1) g0 = tr∗ =⇒ gn there is a canonical s-t -match consistent tgt-sequence (2) g0 = g00 = tr∗st==⇒ gn0 = tr∗i=⇒ gnn = gn based on corresponding source-target rules tr∗st and integration rules tr∗i . 2. composition: for each s-t -match consistent transformation sequence (2) there is a canonical transformation sequence (1). 3. bijective correspondence: composition and decomposition are inverse to each other. in the following we give the proof of theorem 2 which is based on the local-church-rosser and the concurrency theorem for algebraic graph transformations (see [roz97], [eept06]). the proof uses two lemmas, where the proof of the lemmas is given in [eeh08]. in lemma 1 we show that a triple rule tr can be represented as concurrent production trst ∗e tri of the corresponding source-target rule trst and integration rule tri , where the overlapping e is equal 7 / 14 volume 10 (2008) model integration to l(tri ), the left hand side of tri . moreover e-related sequences in the sense of the concurrency theorem correspond exactly to s-t -match-consistent sequences in theorem 2. in lemma 2 we show compatibility of s-t -match consistency with sequential independence in the sense of the local-church-rosser-theorem. using lemma 1 we can decompose a single tgttransformation g0 = tr⇒ g1 into an s-t -match consistent sequence g0 = trst==⇒ g10 = tri=⇒ g1 and vice versa. lemma 2 allows to decompose tgt-sequences g0 = tr∗ =⇒ gn into s-t -match consistent sequences g0 = tr∗st==⇒ gn0 = tr∗i=⇒ gn and vice versa. all constructions are done in the category triplegraphtg of typed triple graphs and typed triple graph morphisms, which according to fact 4.18 in [eept06] is an adhesive hlr category. this implies that the local-church-rosser and concurrency theorem are valid for triple rules with injective morphisms (see chapter 5 in [eept06]). lemma 1 (concurrent production tr = trst ∗e tri ) let e = l(tri ) with e1 = (id, /0, id) : r(trst ) → e and e2 = id : l(tri ) → e then tr is given by the concurrent production tr = trst ∗e tri . moreover, there is a bijective correspondence between a transformation g1 = tr,m ==⇒ g2 and match-consistent sequences g1 = trst ,m1,n1=====⇒ h = tri ,m2,n2====⇒ g2, where s−t -match consistency means that the s− and t−components of the comatch n1 and the match m2 are equal, i.e. n1s = m2s and n1t = m2t . construction of concurrent production: l(trst ) l �� trst // (1) r(trst ) e1 %%k kkk kkk k l(tri ) e2zztt tt tt t tri // (2) r(tri ) r �� l(tr) d1 // e d2 // r e −concurrent rule lemma 2 (compatibility of s−t -match consistency with independence) given the tgt-sequences on the right with independence in (4) and matches mi, m′i and comatches ni, n ′ i. then we have: g20 tr1i m1′,n1′ #+ ppp ppp ppp ppp g00 tr1st m0,n0 +3 g10 tr2st m2′,n2′ 3;nnnnnn nnnnnn tr1i m1,n1 #+ ppp ppp ppp ppp g21 tr2i m3,n3 +3 g22 g11 tr2st m2,n2 3;nnnnnn nnnnnn (1) g00 = tr1st==⇒ g10 = tr1i==⇒ g11 s−t -match consistent ⇔ (2) g00 = tr1st==⇒ g10 = tr2st==⇒ g20 = tr1i==⇒ g21 s−t -match consistent and (3) g11 = tr2st==⇒ g21 = tr2i==⇒ g22 s−t -match consistent ⇔ (4) g10 = tr2st==⇒ g20 = tr1i==⇒ g21 = tr2i==⇒ g22 s−t -match consistent proof of theorem 2. 1. decomposition: given (1) we obtain (for n = 3) by leamma 1 a decomposition into triangles (1), (2), (3), where the corresponding transformation sequences are s − t -match consistent. g30 (6) tr1i ( jj j jj j g20 (4) tr1i ( jj j jj j tr3st 6>ttt ttt g31 (5) tr2i ( jj j jj j g10 (1) tr1i ( jj j jj j tr2st 6>ttt ttt g21 (2) tr2i ( jj j jj j tr3st 6>ttt ttt g32 (3) tr3i ( jj j jj j g00 tr1st 6>ttt ttt tr1 +3g0 = g11 tr2st 6>ttt ttt tr2 +3 g22 tr3st 6>ttt ttt tr3 +3 g33 = g3 proc. gt-vmt 2008 8 / 14 eceasst in the next step we show that g10 = tr1i==⇒ g11 = tr2st==⇒ g21 is sequentially independent leading by the local church rosser theorem to square (4) sequential independence in this case means existence of d : l(tr2st ) → g10 with g◦d = m2. l(tr1i ) m1 �� tr1i // r(tr1i ) $$h hh hh h l(tr2st ) m2zztt tt tt // d rrf f f f f f f f f f f f r(tr2st ) �� g1 g // g2 // g3 the diagram on the right shows that d = (ds, dc, dt ) = (m2s, /0, m2t ) satisfies this property. (1)−(4) leads to the following transformation sequence g00 = tr1st==⇒ g10 = tr2st==⇒ g20 = tr1i==⇒ g21 = tr2i==⇒ g22 = tr3st==⇒ g32 = tr3i==⇒ g33 which is again s−t -match consistent due to shift equivalence of corresponding matches in the local church rosser theorem (see lemma 2). similar to above we can show that g21 = tr2i==⇒ g22 = tr3st==⇒ g32 are sequentially independent leading to (5) and in the next step to (6) with corresponding s−t -match consistent sequences. sl2 ds=m2s ~~ ~~ ~~ ~~ ��~~ ~~ ~~ ~ m2s 44 44 44 ��4 44 44 4 /0 dc �� �� ���� �� �� �� �� �� m2c 44 44 4 ��4 44 44 44 4 oo �� t l2 dt �� ���� �� �� �� �� �� �� m2t 33 ��3 33 33 33 33 33 3 g10,s id // g11,s = g10,s g10,c gc // oo �� g11,c oo �� g10,t id // g11,t = g10,t 2. composition: vice versa, each s−t -match consistent sequence (2) leads to a canonical s− t -match consistent sequence of triangles (1), (2), (3) and later by lemma 1 to tgt-sequence (1). we obtain the triangles by inverse shift equivalence, where subsequence 1 as above is s−t match consistent. in fact s−t -match consistency of (2) together with lemma 2 implies that the corresponding sequences are sequentially independent in order to allow inverse shifts according to the local church rosser theorem. sequential independence for (6) is shown below r(tr1st ) n1 �� sr1 = l(tr3st ) m3 �� tr1i // r(tr3st ) ""d dd dd dd d l(tr1i ) sr1 m1i~~|| || || || // d ssh h h h h h h h h h h h h r(tr1i ) �� g10 g1 // g20 g2 // g30 // g31 by s−t -match consistency we have m1i,s = g2s ◦g1s ◦n1s. define ds = g1s ◦n1s, then g2s ◦ ds = g2s ◦g1s ◦n1s = m1i,s and similar for the t -component, while dc = m1i,c using g2c = id. 3. bijective correspondence: by that of the local church rosser theorem and concurrency theorem. given an integration transformation sequence g0 = tr∗i=⇒ gn with projs(g0) = gs, projt (g0) = gt and projc(g0) = /0, we want to make sure that the unrelated pair (gs, gt ) ∈ vls0 ×vlt 0 is transformed into an integrated model g = gn with projs(g) = gs, projt (g) = gt . of course this is not possible for all pairs (gs, gt ) ∈ vls0 ×vlt 0, but only for specific pairs. in any case (gs, gt ) ∈ vls0 ×vlt 0 implies that we have a source-target transformation sequence /0 =⇒∗ g0 via trst = {trst |tr ∈ tr}. in order to be sure that g0 = tr∗i=⇒ gn integrates all parts of gs and gt , which are generated by /0 =⇒∗ g0, we require that /0 =⇒∗ g0 is given by /0 = tr∗st==⇒ g0 based on 9 / 14 volume 10 (2008) model integration the same triple rule sequence tr∗ as g0 = tr∗i=⇒ gn. moreover, we require that the tgt-sequence /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn is s-t -match consistent because this implies using theorem 2 that gs ∈ vls, gt ∈ vlt and g ∈ vl (see theorem 2). definition 5 (model integration) a model integration sequence ((gs, gt ), g0 = tr∗i=⇒ gn, g) consists of a source and a target model gs and gt , an integrated model g and a source-target consistent tgt-sequence g0 = tr∗i=⇒ gn with gs = projs(g0) and gt = projt (g0). source-target consistency of g0 = tr∗i=⇒ gn means that there is a source-target transformation sequence /0 = tr∗st==⇒ g0, such that /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn is match consistent. a model integration mi : vls0 ×vlt 0 v vl is defined by model integration sequences ((gs, gt ), g0 = tr∗i=⇒ gn, g) with gs ∈ vls0, gt ∈ vlt 0 and g ∈ vl. remark 3 given model integration sequence ((gs, gt ), g0 = tr∗i=⇒ gn, g) the corresponding source-target tgt-sequence /0 = tr∗st==⇒ g0 is uniquely determined. the reason is that each comatch of trist is completely determined by sand t -component of the match of trii , because of embedding r(trist ) � l(trii ). furthermore, each match of trist is given by uniqueness of pushout complements along injective morphisms with respect to non-deleting rule trist and its comatch. moreover, the source-target tgt-sequence implies gs ∈v ls0 and gt ∈v lt 0. fact 2 (model integration is syntactically correct) given model integration sequence ((gs, gt ), g0 = tr∗i=⇒ gn, g) then gn = g ∈ vl with projs(g) = gs ∈ vls and projt (g) = gt ∈ vlt . proof. g0 = tr∗i=⇒ gn source-target consistent ⇒ ∃ /0 = tr∗st==⇒ g0 s.t. /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn s-t -match consistent t hm2⇒ /0 =tr ∗ =⇒ gn , i.e. gn = g ∈ vl finally we want to analyze which pairs (gs, gt ) ∈ vls ×vlt can be integrated. intuitively those which are related by the model transformation mt : vls v vlt in theorem 1. in fact, model integration sequences can be characterized by unique model transformation sequences. theorem 3 (characterization of model integration sequences) each model integration sequence ((gs, gt ), g0 = tr∗i=⇒ gn, g) corresponds uniquely to a model transformation sequence (gs, g′0 = tr∗f=⇒ gn, gt ), where tr∗i and tr ∗ f are based on the same rule sequence tr ∗. proof. ((gs, gt ), g0 = tr∗i=⇒ gn, g) is model integration sequence de f ⇔ source-target consistent g0 = tr∗i=⇒ gn with projs(g0) = projs(gn) = gs, projc(g0) = /0, projt (g0) = projt (gn) = gt and gn = g de f ⇔ /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn s-t -match consistent with projs(gn) = gs and projt (gn) = gt t hm2⇔ /0 =tr ∗ =⇒ gn with projs(gn) = gs and projt (gn) = gt t hm1⇔ /0 = tr∗s=⇒ g′0 = tr∗f=⇒ gn match consistent with projs(gn) = gs and projt (gn) = gt proc. gt-vmt 2008 10 / 14 eceasst de f ⇔ g′0 = tr∗f=⇒ gn source consistent with projs(g′0) = projs(gn) = gs and projt (gn) = gt de f ⇔ (gs, g′0 = tr∗f=⇒ gn, gt ) is model transformation sequence. personcompany custumer_id : int custumer employee figure 5: source component of fig. 6 in concrete syntax coming back to the example of a model transformation from class diagrams to database models the relevance and value of the given theorems can be described from the more practical view. fig. 6 shows a triple graph, which defines a class diagram in its source component, database tables in its target component and the correspondences in between. since this model is already fully integrated, it constitutes the resulting graph g of example model integration sequence ((gs, gt ), g0 = tr∗i=⇒ gn, g). the starting point is given by gs as restriction of g to elements of the class diagram, indicated by pink, and gt containing the elements of the database part, indicated by yellow colour. now, the blue nodes for correspondence as well as the morphisms between connection component to source and target component are created during the integration process. all elements are labeled with a number to specify matches and created objects for each transformation step. the sequence of applied rules is g0 = class2table ======⇒ g1 = class2table ======⇒ g2 = subclass2table ========⇒ g3 = primaryattribute2column ==============⇒ g4 = association2foreignkey =============⇒ g5 = gn. 3:table name=“company“ 10:fkey 7:fkeys 2:classtablerel 24:attrcolrel 15:classtablerel 9:assocfkeyrel 19:classtablerel 20:cols 6:src 11:dest 16:parent 21:pkey 8:association name = “employee“ 1:class name=“company“ 14:class name=“person“ 18:class name=“customer“ 27:primitivedatatype name = “int“ 23:attribute is_primary = true name=“cust_id“ 25:column type = “int“ name = “cust_id“ 22:attrs 26:type 17:table name=“person“ 5:column type = “int“ name = “employee_cust_id“ 4:cols 12:fcols 13:references figure 6: example of model integration for model transformation class2table now, table 1 shows all matches of this sequence for both cases of theorem 3 being the model integration sequence g0 = tr∗i=⇒ gn and the forward transformation sequence g′0 = tr∗i=⇒ gn, where g0 contains the elements of g except correspondence parts and g′0 is g leaving out all elements of target and connection component. the column ”created” in the table lists the elements which are created at each transformation step. according to the numbers for the elements, the correspondence component is completely created during the model integration sequence and the elements of each match are created by the corresponding source-target rule application in 11 / 14 volume 10 (2008) model integration integration sequence forward sequence elements elements step and rule matched created matched created 1 1,3 2 1 2,3 2 14,17 15 14 15,17 3 14-18 19 14-18 19 4 17-23, 25-27 24 17-19, 22,23, 26,27 20,21, 24,25 5 1-8, 10-15, 17,21,25 9 1-3,6,8, 11,14,15, 17,21,25 4,5,7,9,10,12,13 table 1: steps of example integration sequence /0 = tr∗st==⇒ g0. therefore, /0 = tr∗st==⇒ g0 = tr∗i=⇒ gn is match consistent. analogously /0 = tr∗s=⇒ g′0 consists of the specified steps in table 1, where comatches are given by the elements of the match in the forward transformation sequence implying /0 = tr∗s=⇒ g′0 = tr∗f=⇒ gn being match consistent. both integration and forward transformation sequence can be recaptured by analyzing the other, which corresponds to theorem 3. 5 related work various approaches for model transformation in general are discussed in [mb03] and [omg07] using botl and qvt respectively. for a taxonomy of model transformation based on graph transformation we refer to [mg06]. triple graph grammars have been proposed by a. schürr in [sch94] for the specification of graph transformations. a detailed discussion of concepts, extensions, implementations and applications scenarios is given by e. kindler and r. wagner in [kw07]. the main application scenarios in [kw07] are model transformation, model integration and model synchronization. these concepts, however, are discussed only on an informal level using a slightly different concept of triple graphs compared with [sch94]. in this paper we use the original definition of triple graphs, triple rules, and triple transformations of [sch94] based on the double pushout approach (see [roz97], [eept06]). in our paper [eee+07] we have extended the approach of [sch94] concerning the relationship between tgtsequences based on triple rules g0 tr∗⇒ gn and match consistent tgt-sequences g0 tr∗s⇒ gn0 tr∗f⇒ gm based on source and forward rules leading to the canonical decomposition and composition result 1 (thm 1). this allows to characterize information preserving bidirectional model transformations in [eee+07]. in this paper the main technical result is the canonical decomposition and composition result 2 (thm 2) using source-target rules trst and integration rules tri instead of trs and trf . both results are formally independent, but the same proof technique is used based on the local church–rosser and concurrency theorem for graph transformations. the main result of [eept06] is based on these two decomposition and composition results. for a survey on tool integration with triple graph grammars we refer to [ks06]. proc. gt-vmt 2008 12 / 14 eceasst 6 future work and conclusion model integration is an adequate technique in system design to work on specific models in different languages, in order to establish the correspondences between these models using rules which can be generated automatically. once model transformation triple rules are defined for translations between the involved languages, integration rules can be derived automatically for maintaining consistency in the overall integrated modelling process. main contributions of this paper are suitable requirements for existence of model integration as well as composition and decomposition of source-target and integration transformations to and from triple transformations. since model integration may be applied at any stage and several times during the modelling process, results of model integrations in previous stages can be used as the starting point for the next incremental step. all concepts are explained using the well known case study for model transformation between class diagrams and relational data bases. while other model transformation approaches were applied to the same example for translation between source and target language, triple graph grammars additionally show their general power by automatic and constructive derivation of an integration formalism. therefore, model integration in the presented way can scale up very easily, only bounded by the effort to build up general triple rules for parallel model evolution. usability extends when regarding partly connected models, which shall be synchronized as discussed on an informal level in [kw07]. on the basis of model integration rules model synchronization can be defined in future work as model integration using inverse source and target rules, standard source and target rules as well as integration rules in a mixed way, such that the resulting model is syntactically correct and completely integrated. another interesting aspect for future work is the extension of triple graph rules and corresponding transformation and integration rules by negative application conditions (see [hht96]), or by more general graph constraints (see [hp05]). bibliography [eee+07] h. ehrig, k. ehrig, c. ermel, f. hermann, g. taentzer. information preserving bidirectional model transformations. in dwyer and lopes (eds.), fundamental approaches to software engineering. lncs 4422, pp. 72–86. springer, 2007. http://tfs.cs.tu-berlin.de/publikationen/papers07/eee+07.pdf [eeh08] h. ehrig, k. ehrig, f. hermann (eds.). from model transformation to model integration based on the algebraic approach to triple graph grammars (long version). februrary 2008. published as technical report, tu berlin, no. 2008-3. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs in theoretical computer science. springer verlag, 2006. http://www.springer.com/3-540-31187-4 [hht96] a. habel, r. heckel, g. taentzer. graph grammars with negative application conditions. special issue of fundamenta informaticae 26(3,4):287–313, 1996. 13 / 14 volume 10 (2008) http://tfs.cs.tu-berlin.de/publikationen/papers07/eee+07.pdf http://www.springer.com/3-540-31187-4 model integration [hp05] a. habel, k.-h. pennemann. nested constraints and application conditions for high-level structures. in kreowski et al. (eds.), formal methods in software and systems modeling. lecture notes in computer science 3393, pp. 293–308. springer, 2005. http://dx.doi.org/10.1007/b106390 [ks06] a. könig, a. schürr. tool integration with triple graph grammars a survey. in heckel, r. (eds.): elsevier science publ. (pub.), proceedings of the segravis school on foundations of visual modelling techniques, vol. 148, electronic notes in theoretical computer science pp. 113-150, amsterdam. 2006. http://dx.doi.org/10.1016/j.entcs.2005.12.015 [kw07] e. kindler, r. wagner. triple graph grammars: concepts, extensions, implementations, and application scenarios. technical report tr-ri-07-284, software engineering group, department of computer science, university of paderborn, june 2007. http://www.uni-paderborn.de/cs/ag-schaefer/veroeffentlichungen/quellen/papers/ 2007/tr-ri-07-284.pdf [mb03] f. marschall, p. braun. model transformations for the mda with botl. in proc. of the workshop on model driven architecture: foundations and applications (mdafa 2003), enschede, the netherlands. pp. 25–36. 2003. http://citeseer.ist.psu.edu/marschall03model.html [mg06] t. mens, p. v. gorp. a taxonomy of model transformation. in proc. international workshop on graph and model transformation (gramot’05), number 152 in electronic notes in theoretical computer science, tallinn, estonia, elsevier science. 2006. http://tfs.cs.tu-berlin.de/gramot/gramot2005/finalversions/pdf/mensvangorp.pdf [omg07] omg. meta object facility (mof) 2.0 query/view/transformation specification, final adopted specification (07-07-2007). 2007. http://www.omg.org/docs/ptc/07-07-07.pdf [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformations, volume 1: foundations. world scientific, 1997. [sch94] a. schürr. specification of graph translators with triple graph grammars. in g. tinhofer, editor, wg94 20th int. workshop on graph-theoretic concepts in computer science, volume 903 of lecture notes in computer science, pages 151–163, springer verlag, heidelberg. 1994. http://dx.doi.org/10.1007/3-540-59071-4 45 proc. gt-vmt 2008 14 / 14 http://dx.doi.org/10.1007/b106390 http://dx.doi.org/10.1016/j.entcs.2005.12.015 http://www.uni-paderborn.de/cs/ag-schaefer/veroeffentlichungen/quellen/papers/2007/tr-ri-07-284.pdf http://www.uni-paderborn.de/cs/ag-schaefer/veroeffentlichungen/quellen/papers/2007/tr-ri-07-284.pdf http://citeseer.ist.psu.edu/marschall03model.html http://tfs.cs.tu-berlin.de/gramot/gramot2005/finalversions/pdf/mensvangorp.pdf http://www.omg.org/docs/ptc/07-07-07.pdf http://dx.doi.org/10.1007/3-540-59071-4_45 introduction review of triple rules and triple graph grammars model transformation model integration related work future work and conclusion backward reachability analysis for timed automata with data variables electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) backward reachability analysis for timed automata with data variables rebeka farkas, tamás tóth, ákos hajdu, andrás vörös 20 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst backward reachability analysis for timed automata with data variables rebeka farkas1, tamás tóth2∗, ákos hajdu3, andrás vörös4 1 farkasr@mit.bme.hu 2 totht@mit.bme.hu 3 hajdua@mit.bme.hu 4 vori@mit.bme.hu department of measurement and information systems, budapest university of technology and economics, hungary 134 mta-bme lendület cyber-physical systems research group abstract: efficient techniques for reachability analysis of timed automata are zonebased methods that explore the reachable state space from the initial state, and smtbased methods that perform backward search from the target states. it is also possible to perform backward exploration based on zones, but calculating predecessor states for systems with data variables is computationally expensive, prohibiting the successful application of this approach so far. in this paper we overcome this limitation by combining zone-based backward exploration with the weakest precondition operation for data variables. this combination allows us to handle diagonal constraints efficiently as opposed to zone-based forward search where most approaches require additional operations to ensure correctness. we demonstrate the applicability and compare the efficiency of the algorithm to existing forward exploration approaches by measurements performed on industrial case studies. although the large number of states often prevents successful verification, we show that data variables can be efficienlty handled by the weakest precondition operation. this way our new approach complements existing techniques. keywords: timed automata, reachability analysis, backward exploration, weakest precondition 1 introduction the ubiquity of real-time safety-critical systems makes it desirable to model and verify timedependent behaviour. one of the most common formalisms for this purpose is the timed automaton, introduced by alur and dill [ad91] which extends the finite automaton with real-valued variables called clock variables that represent the elapse of time. this makes it a suitable formalism for modelling time-dependent behaviour of systems such as communication protocols [rsv10] and logical circuits with propagation delay [mp95]. state reachability has a prominent role in verification. most reachability analysis algorithms perform forward search: they check if the set of states reachable from the initial state contains the target state. backward search can also be used for checking reachability – in this case the ∗ this work was partially supported by gedeon richter’s talentum foundation (gyömrői út 19-21, 1103 budapest, hungary). 1 / 20 volume 076 (2019) mailto:farkasr@mit.bme.hu mailto:totht@mit.bme.hu mailto:hajdua@mit.bme.hu mailto:vori@mit.bme.hu backward reachability analysis for timed automata with data variables algorithm explores set of states from where the target state is reachable and checks if it contains the initial state [mit07]. the motivation behind backward search is that when the target state is unreachable, the state space explored from the initial state is disjunct from the one explored backwards from the target states and the latter might be smaller. the combination of backward and forward approaches (often referred to as bidirectional search) can be more efficient than either of the original approaches [vgs13]. reachability for timed automata is decidable, but the complexity is exponential in the number of clock variables [ad91]. the most efficient techniques for deciding reachability either rely on smt solvers or abstract state space representations. the key idea of smt-based techniques is to transform the system into a set of constraints that is satisfiable if the target state is reachable, and then give it to an smt solver. although this technique is efficient for other domains and there is an efficient first-order theory for the timed domain, called difference logic [bm07], in practice solver-based techniques are usually more efficient for other timed formalisms, such as the timeout automaton [ds+04]. as for timed automata, the most efficient algorithms rely on the zone abstract domain [ypd94] that is usually used for (forward) state space exploration [bou05]. while it is possible to perform zone-based backward state space exploration of timed automata, the forward approach is preferred. the general reason behind this is that in practice extensions of timed automata are used, such as timed automata with data variables, and it is expensive to calculate predecessor states for systems with data variables [blr05, bou05]. on the other hand, zone-based backward exploration of timed automata would be desired, because for a class of timed automata called timed automata with diagonal constraints backward exploration is the only zone-based method that does not introduce an additional exponential factor to the complexity [blr05, bc05]. in this paper we propose an algorithm for backward reachability analysis of timed automata that combines zone abstraction for clock variables with the weakest precondition operation for data variables. using the operation we can explore the state space of the data variables backwards. we also compare the applicability and the efficiency of zone-based backward and forward exploration by measurements performed on the xtabenchmarksuite presented in [fb18]. we show that data variables can be handled by the weakest precondition operation but the large number of target states often prevents successful verification. we propose some possible improvements and other ideas about the applicability of zone-based backward exploration algorithm for the verification of timed automata. the paper is organized as follows. section 2 presents the related work, section 3 provides some theoretical background on the reachability analysis of timed automata, our algorithm is explained in section 4. section 5 presents and evaluates the performed measurements, and finally section 6 concludes the paper. 2 related work to the best of our knowledge there is no zone-based backward reachability analysis algorithm for timed automata with data variables in the literature. however, many zone-based algorithms have been proposed for forward exploration [hnsy92] as well as smt-based methods that perform backward search [mps11]. such algorithms often fail to support extensions of timed automata, avocs 2018 2 / 20 eceasst such as diagonal constraints or data variables. our algorithm is applicable in both cases. zone-based state space exploration zone-based techniques explore an abstract reachability graph whose nodes contain a zone-based abstraction of a set of reachable states. the basics of zone-based algorithms and the zone operations were introduced in [ypd94] where they proposed the backward exploration of timed automata (without data variables) that provides the timed part of our algorithm. zone-based forward exploration algorithms were also developed [by03] and preferred for efficiency reasons – despite the fact that they are not sound for timed automata with diagonal constraints [bou03]. many optimizations of zone abstraction have been defined. an optimal zone-based abstraction – that is, the weakest abstraction that is still safe – has been presented in [hsw13]. the optimization was extended to timed automata with diagonal constraints in [gms18]. other approaches to apply zone-based forward exploration for timed automata with data variables were discussed in [blr05]. backward exploration generally, smt-based methods can operate both forwards and backwards, and they can be applied to systems with data variables as well as timed automata with diagonal constraints. however, despite the many advantages, in practice smt-based methods are less efficient for timed automata, than zone-based techniques. one of the most efficient smtbased methods for timed automata is presented in [mps11], where backward exploration is used, however, before exploration the timed automaton is translated to another formalism called finite state machine with time. the transformation requires lower and upper bounds on the integer variables. besides state reachability, backward exploration is often used for model checking ctl properties on timed automata. the tool kronos [yov97] performs zone-based backward exploration for model checking timed automata against tctl properties. however, kronos does not support data variables. algorithms for timed automata with data variables independent of the algorithm, the values of data variables can be encoded to the locations of timed automata as a preprocessing operation. in addition, forward exploration algorithms can be applied for extended timed automata by calculating the values of data variables on the fly. however, these approaches only allow explicit state space exploration over data variables. on the other hand, in case of approaches with abstractions over data variables the possible operations are often restricted to ensure the abstraction is safe. in [iw14] the restrictions ensure integer variables can be encoded in zones (just like clocks). in [fs01] they use the concept of well-structured transition systems, that require well-quasi orderings to verify several formalisms, including timed systems. there are very few methods applicable to extended timed automata without restrictions that do not calculate the values of data variables explicitly. in [hrsy14] where they use horn-clauses for verification of timed automata with data variables. in [tm18] the visibilities of data variables are controlled based on interpolations. 3 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables 3 preliminaries this section presents the important aspects of modeling timed systems, the extensions of timed automata used in practice, as well as the basic operations of zone-based state space exploration. the weakest precondition operation is also defined. 3.1 timed automata 3.1.1 basic definitions clock variables (or clocks, for short) are introduced to represent the elapse of time. the set of clock variables is denoted by c . the most commonly used type of predicates over clocks is clock constraints. definition 1 a clock constraint is a conjunction of atomic clock constraints, that can either be simple constraints of the form x ∼ n or diagonal constraints of the form x−y ∼ n, where x,y ∈ c , ∼∈{≤,<,=,>,≥} and n ∈n. the set of clock constraints is denoted by b(c ). in other words clock constraints define upper and lower bounds on the values of clocks and the differences of clocks. a timed automaton extends a finite automaton with clock variables. definition 2 a timed automaton a is a tuple 〈l,l0,e〉 where • l is the set of locations (or control states), • l0 ∈ l is the initial location, • e ∈ l×b(c )×2c ×l is the set of edges. an edge is defined by the source location, the guard (represented by a clock constraint), the set of clocks to reset and the target location. remark 1 it is usual to allow invariants on the locations of the automaton. in this paper we omit them to keep the explanations simple. however, the presented algorithms can be adjusted to handle invariants. in the literature many algorithms are only defined for a subclass of timed automata called diagonal-free timed automata. definition 3 a diagonal-free timed automaton is a timed automaton where all atomic clock constraints are simple constraints. it is possible to transform a timed automaton containing diagonal constraints to a diagonal-free timed automaton – i.e. the expressive power of diagonal-free timed automata is the same as that of timed automata. however, the number of locations in the resulting automaton is exponential in the number of diagonal constraints [bc05]. avocs 2018 4 / 20 eceasst 3.1.2 operational semantics the values of the variables at a given moment is described by a valuation. definition 4 let us denote by dom(v) the set of possible values for a variable v, i.e. the domain of v. given a set of variables v and the corresponding domains a valuation is a function v : v →∪v∈v dom(v) that assigns a value for each variable v ∈v such that v(vi)∈ dom(vi). remark 2 for simplicity in this paper we shall write dom(v ) instead of ∪v∈v dom(v) accordingly, a clock valuation is a function vc : c →r≥0. in this paper we denote clock valuations by vc. valuations over other types of variables are denoted by vd . we denote by v |= c if valuation v satisfies a constraint c. the set of all valuations satisfying a constraint c is denoted by jck. clock variables are initialized to 0 – that is, initially vc0(c) = 0 for all c ∈ c –, and their values are constantly and steadily increasing (at the same pace for all clocks). the only operation on clock valuations is the operation reset, denoted by [c ← 0]vc which sets the value of a set c ⊆ c to 0, that is [c ← 0]vc(c) = 0 for c ∈ c and [c ← 0]vc(c) = vc(c) otherwise. it is an instantaneous operation, after which the value of the clocks will continue to increase. the state of a timed automaton is defined by the current location and the values of the clocks. formally, a state of a is a pair 〈l,vc〉 where l ∈l(a ) is a location and vc is the current valuation. two kinds of operations are defined. the state 〈l,vc〉 has a discrete transition to 〈l′,vc′〉 if there is an edge e = 〈l,g,r,l′〉∈ e in the automaton such that vc |= g and vc′ = [r ← 0]vc. the state 〈l,vc〉 has a time transition to 〈l,vc′〉 if vc′ assigns vc(c)+d for some non-negative d to each c ∈ c . a run of a is a finite sequence of consecutive transitions r =〈l0,vc0〉 t0−→〈l0,vc0′〉 d0−→〈l1,vc1〉 t1−→ 〈l1,vc1′〉...〈ln,v c n〉 tn−→〈ln,vcn′〉 where for all 1 ≤ i ≤ n,ti denotes a time transition and di denotes a discrete transition. 3.1.3 extensions of timed automata in practice the low descriptive power of the original timed automaton formalism makes it impractical for modeling systems. over the years many extensions of the formalism have been invented to overcome this issue. in this paper we are focusing on timed automata with data variables. data variables are variables whose value can only be changed by discrete transitions, e.g. variables of types integer, bool, etc. they can appear in constraints to enable transitions (data guards) and can be modified by transitions (update). however, clock variables are not allowed to appear in data guards or updates. the extended formalism can be formally defined as follows. definition 5 a timed automaton with data variables is a tuple 〈l,l0,e,vd0〉 where • l is the set of locations, • l0 ∈ l is the initial location, 5 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables • e ∈ l×b(c )×pv ×2c ×uv ×l is the set of edges, where pv denotes the set of first order predicates over a set of data variables v and u ∈ uv is a sequence of assignments (updates) of the form v ← t where v ∈ v and t is a term built from variables in v and function symbols interpreted over dom(v). an edge is defined by the source location, the clock guard, the data guard, the set of clocks to reset, the updates, and the target location. • vd0 is the initial data valuation. the possible types of data variables and the expressions appearing in data guards and updates may vary by model checker, however, for efficient verification it is important, that the expressive power of the extended formalism is the same as that of the original timed automaton. in many cases this is achieved by restricting the set of possible values to a finite set (e.g. an interval for integers) – this way, the model can be translated to a (simple) timed automaton by encoding the values of data variables to locations. in this paper we denote the set of general conditions on a set of variables v by cond(v ). the operational semantics are also modified. a state of the extended formalism a over a set of clock variables c and a set of data variables v can be described by a tuple 〈l,vd,vc〉 where l ∈ l is the current location, vd : v → dom(v ) is the current data valuation and vc : c →r≥0 is the clock valuation. while the operational semantics of time transitions are not affected by data variables, discrete transitions become more complex: data guards have to be satisfied and updates have to be executed. let us denote by u(vd) the data valuation after executing the sequence of updates u on a system with the initial data valuation vd . formally, the state 〈l,vd,vc〉 has a discrete transition to 〈l′,vd′,vc′〉 if there is an edge e = 〈l,g, p,r,u,l′〉∈ e in the automaton such that vc |= g, vd |= p, vc′= [r ← 0]vc and vd′= u(vd). another popular extension of timed automata allows the decomposition of the automaton to a network of automata. a network (a1|...|an) is a parallel composition of a set of timed automata. communication is possible by shared variables or handshake synchronization using synchronization channels. a network of timed automata can be transformed into a timed automaton by constructing the product of the automata in the network. for formal definition, the interested reader is referred to [bll+95]. 3.2 verification of timed automata in this section we present the basic opreations of zone-based reachability analysis of timed automata. smt-based verification is beyond the scope of this paper. in case of (simple) timed automata the reachability problem can be formalized as follows. input: a timed automaton a , and a location ltrg ∈ l(a ) question: is there a run 〈l0,v0〉→〈ltrg,vn〉 for some vn in a ? avocs 2018 6 / 20 eceasst 3.2.1 zone-based verification an introduction to the abstract domain zone can be found in [by03], along with the operations necessary for verification and an efficient representation, called difference bound matrix (dbm). definition 6 a zone z = {vc | vc |= g} is a set of clock valuations satisfying some clock constraint g. many operations are defined on zones. in this paper the following notations are used: • [r ← 0]z denotes the result of the reset operation applied to a zone z, r ⊆ c : [r ← 0]z ={vc | ∃vc′∈ z : vc = [r ← 0]vc′} • [r ← 0]−1z,r ⊆ c denotes the inverse of the reset operation: [r ← 0]−1z ={vc | [r ← 0]vc ∈ z} • z↑ denotes the set of valuations reachable from z by time transitions: z↑ ={vc + t | vc ∈ z,t ∈n}, where vc +t = vc′ denotes a valuation where vc′(c) = vc(c)+t for all c ∈ c • z↓ denotes the set of nonnegative valuations from where z is reachable by time transitions: z↓ ={vc | ∃t ∈n : vc + t ∈ z} the core of reachability analysis is to construct an abstract reachability graph, that is an abstract representation of the state space. in case of zone-based reachability the abstract reachability graph is called a zone graph. definition 7 a zone graph is a finite graph containing 〈l,z〉 pairs as nodes, where l ∈ l is a location of the automaton and z is a zone. a node of the zone graph represents a set of states reachable from the initial state (or a set of states from where the target states are reachable, in case of backward exploration). edges between nodes correspond to discrete transitions through which those states are reachable. remark 3 in this paper we use the word represent for indicating that a node n certifies that the explored state space contains a state s, i.e. n = 〈l,z〉 represents s = 〈l,vc〉 iff vc ∈ z. the goal of state space exploration is to create the zone graph. the process is similar to any kind of graph-based state space exploration and will be presented to detail in subsubsection 4.1.2. the primary task is postimage calculation (in case of forward exploration): given a node of the graph under construction n = 〈l,z〉 representing the set of reachable states and an edge of the automaton e = 〈l,g,r,l′〉 the task is to calculate a node n′ representing the set of all states that can be reached from those represented by n through e. the postimage of l is straightforward and the postimage of z can be calculated by first determining the maximal subzone z′ that satisfies g (z′ represents the set of valuations where the discrete transition is enabled), then resetting all clocks c ∈ r in z′ (i.e. executing the discrete transition), and finally applying time transitions. formally, the postimage calculation can be described as postg,r(z) = ([r ← 0](z ∩jgk)) ↑. 7 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables in case of backward exploration the corresponding operation is preimage calculation, formally described as preg,r(z) = ([r ← 0]−1z ∩jgk) ↓ . this operation is basically the inverse of postimage computation with the exception that applying time transitions remains the last step. this way the set of states represented by a node is larger and the zone graph is more compact. in case of backward exploration the zone graph explored using the presented operation is always finite, but this is not true for forward exploration, since using loop-edges it is possible to create a timed automaton with a run of ever-increasing clock valuations [by03]. to ensure the termination of the algorithm, extrapolation was introduced, however, in case of diagonal constraints extrapolation may introduce unreachable states to the reachability graph, making the result of the analysis a false positive space [bou03]. many approaches have been introduced to ensure correctness, including the operation split that splits the zone to extrapolate to smaller zones so that the extrapolation keeps the zone safe [by03], and cegar-based methods where they explore the state space with the original overapproximating algorithm and if they find a spurious trace they refine the state space or the automaton [blr05], but the complexity of these methods is exponential in the number of diagonal constraints. 3.2.2 verification of extended timed automata the reachability problem can be formulated for the extended formalisms. for instance, in case of timed automata with data variables the target states can also depend on the data valuation. input: a timed automaton with data variables a , a location ltrg ∈ l(a ), and a first order predicate ptrg over the data variables of a question: is there a run from the initial state 〈l0,vd0,v c 0〉 to some 〈l,v d n,v c n〉 where vdn |= p? in case of networks of timed automata, instead of a single control location, the state of the system depends on a configuration – that is, a set of locations containing the current location of each automaton. however, reachability criteria usually only determine the location for some of the automata (e.g. collision detection only requires two out of an arbitrary number of stations to be transmitting). the extended reachability problems can be transformed to the original reachability problem over (simple) timed automata, however, in practice it is more efficient to apply the algorithms on timed automata to the extended formalisms. for example, in case of forward exploration calculating the data variables is straightforward based on the updates. on the other hand, in case of backward exploration there can be more than one predecessor states. since it is complicated to calculate the possible previous values of data variables, in case of extended timed automata forward exploration is preferred [bou05, blr05, bou04]. 3.3 weakest precondition in our research we used the weakest precondition operation to calculate the preimage of data variables. the weakest precondition can be defined many ways. here, we define it over predicates and updates. avocs 2018 8 / 20 eceasst definition 8 given a sequence of updates u ∈ uv and a predicate p ∈ pv describing a postcondition, the weakest precondition, denoted by wp(p,u) is the predicate describing the weakest constraint on the initial state ensuring that the execution of u terminates in a state satisfying p: wp : pv ×uv → pv such that jwp(p,u)k ={vd : v → dom(v ) |u(vd) |= p}. the weakest precondition of a sequence of updates can be calculated by iterating backwards over the assignment statements and calculating the weakest precondition one by one. formally if u = [v1 ← t1; v2 ← t2], then wp(p,u) = wp(wp(v2 ← t2,p),v1 ← t1). the weakest precondition of a predicate p ∈ pv based on an update v ← t can be calculated by replacing all occurrences of v in p with t. example 1 let y < 5 be the postcondition of the assignment y ← x + 3. replacing y with x + 3 yields x + 3 < 5 that can be automatically simplified to x < 2. therefore if u(vd) = vd′, where vd′(y) = vd(x)+ 3 and vd′(v) = vd(v),v 6= y, then wp(y < 5,u) = x < 2. in other words in order to ensure y < 5 after assigning x + 3 to y, initially x < 2 must hold. in practice the calculation of the weakest precondition is only efficient if the sequences of assignments can be kept small and the assignments are simple. for more information on the weakest precondition operation the reader is referred to [lei05]. 4 backward exploration using weakest precondition this section presents our proposed algorithm for backward state space exploration of timed automata with data variables. first the underlying state space exploration approach is explained and then the data structures and the operations specific to our algorithm are presented. the algorithm is also demonstrated on an example and its correctness is formally proven. 4.1 algorithm the proposed algorithm is an extension of the zone based backward exploration for simple timed automata to timed automata with data variables using the weakest precondition operation to calculate preimages for data variables. 4.1.1 overview of the approach the basis of the algorithm is a simple state space exploration approach that starts by creating the initial node (representing the target states) and calculates the preimage of each node that introduces new states to the explored state space. backward exploration terminates when the initial state of the automaton is introduced to the state space (hence, reachability is confirmed) or when the complete state space is explored (hence, the target state is unreachable). zone-based backward exploration completes the general state space exploration approach with timed automaton-specific data structures (zones) and operations presented in subsubsection 3.2.1. the proposed algorithm extends zone-based exploration with first-order predicates that are used 9 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables to represent the values of data variables and the weakest precondition operation to calculate preimages for data variables. 4.1.2 state space exploration backward state space exploration initiates from a node ntrg representing the target states. for all incoming edges e of the target location (in the automaton) a new node n is created representing the preimage of the target states based on e. a corresponding edge ntrg → n is also introduced indicating that n represents all states that are from where ntrg is reachable through e. the algorithm continues from the newly created nodes. when a node n is created it is checked if n is covered by some other node n′. definition 9 a node of the state space graph n is covered by a node n′ iff n′ represents all states represented by n. if a new node n is covered by an existing node n′ then n can be removed from the graph, and instead of the outgoing edge npost → n a new edge npost → n′ is created indicating that n′ represents all states from where npost is reachable through e. the algorithm terminates when there is a node in the state space graph (zone graph) that represents the initial state of the automaton or when the complete state space is explored. 4.1.3 data structure and operations while the state space exploration approach is generally used, the underlying data structure (of the nodes), the initial node, the operations for preimage computation and coverage checking and the termination criteria depend on the formalism. in case of timed automata with data variables the proposed approach uses the following concepts. data structure the proposed algorithm extends the data structure of zone-based backward exploration with first order predicates that are used to denote the set of possible values of data variables. therefore, the nodes of the zone graph can be formalized as 〈l,p,z〉, where l is a location of the automaton, p is a first order predicate representing a set of data valuations and z is a zone representing a set of clock valuations. a state 〈l,vd,vc〉 is represented by a node 〈l,p,z〉 iff vd |= p and vc ∈ z. initialization the initial node can be formalized as 〈ltrg,ptrg,jtruek〉. preimage computation for a node 〈l,p,z〉 and incoming edge 〈l′,g, p,r,u,l〉 the preimage 〈l′,p′,z′〉 is calculated as follows. • the preimage of the location is the source location l′ of the edge. • the preimage of the zone can be calculated as presented in subsubsection 3.2.1: z′ = preg,r(z). avocs 2018 10 / 20 eceasst 𝑙0 𝑙1 𝑥 == 10 𝑥 ≔ 0 𝑖 ≔ 𝑖 + 1 𝑖 ≔ 0 𝑙0 𝑙1 𝑥 ≔ 0 𝑦 ≔ 0 𝑥 == 10 𝑥 ≔ 0 𝑦 − 𝑥 > 0 𝑖 ≔ 𝑖 + 1𝑖 ≔ 0 𝑦 − 𝑥 > 0 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 (a) input automaton 𝑙0 𝑙1 𝑥 == 10 𝑥 ≔ 0 𝑖 ≔ 𝑖 + 1 𝑖 ≔ 0 𝑙0 𝑙1 𝑥 ≔ 0 𝑦 ≔ 0 𝑥 == 10 𝑥 ≔ 0 𝑦 − 𝑥 > 0 𝑖 ≔ 𝑖 + 1𝑖 ≔ 0 𝑦 − 𝑥 > 0 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 𝑙1, 𝑖 ≤ 2, 𝑡𝑟𝑢𝑒 𝑙0, 𝑖 ≤ 2,𝑦 − 𝑥 > 0 𝑙0, 𝑖 ≤ 1,𝑥 ≤ 10 𝑙0, 𝑖 ≤ 0,𝑥 ≤ 10 (b) explored state space figure 1: state space exploration example • p′ is only calculated if z′ 6= /0. in this case p′ = wp(p,u)∧ p∧cond(v ). it is important to check if p′ is satisfiable (for instance by using a sat solver). checking coverage a node 〈l,p,z〉 is covered by another node 〈lc,pc,zc〉 if l = lc,z ⊆ zc and p =⇒ pc. there are many ways to check implication. in our implementation we use a solver to determine whether p∧¬pc is unsatisfiable. termination the algorithm terminates if there are no unexplored nodes in the current graph or if it reached the initial state. the set of states represented by a node n = 〈l,p,z〉 contains the initial state if l = l0, vd0 |= p, and v0 ∈ z. 4.2 example this section demonstrates the operation of backward exploration on the automaton presented in figure 1a and the target location l1 with predicate i ≤ 2. in this automaton (which is a modified version of the one presented in [by03]), there are two clock variables x and y and a data variable i that serves as a loop counter. the property to decide is whether it is possible to reach a state where the current location is l1 and i ≤ 2 – considering the automaton the property represents reaching l2 by taking the loop transition less than two times. initially, clocks x and y are both initialized to 0, which means x = y will hold as long as the system stays in l0. when the loop edge is taken (that can first happen when x = y = 10) x is reset but the value of y continues to increase from the same value – that is, taking the loop edge means increasing y−x by 10. the algorithm operates as follows. the initial node is n0 = 〈l1,i ≤ 2,jtruek〉. the only incoming edge does not change the data valuation, but has a clock guard. therefore the preimage of the node is n1 =〈l0,i ≤ 2,y−x > 0〉. the preimage of n1 based on the loop edge can be calculated as follows. prex=10,{x}(y−x > 0) = ([{x}← 0]−1(y−x > 0)∩jx = 10k) ↓ = (y > 0∩jx = 10k)↓, resulting in x ≤10, and wp(i≤2,i := i+1) = i≤1. therefore, the created node is n2 =〈l0,i ≤ 1,x ≤ 10〉. the preimage of n2 based on the loop edge is n3 = 〈l0,i ≤ 0,x ≤ 10〉. since i ≤ 0 =⇒ i ≤ 1, n2 covers n3. this means all the states represented by n3 are also represented by n2, so if n3 is reachable from a state, n2 is also reachable. because of the coverage, node n3 does not need to be expanded further. the exploration terminates. the explored graph can be seen in figure 1b with a frame around n2 and a dashed arrow n3 → n2 (indicating coverage). naturally, the reachability algorithm can terminate after creating n2. since i = 0 |= i ≤ 1 and x = y = 0 |= x ≤ 10, n2 represents the initial state – the property is evaluated to true. 11 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables 4.3 proof of correctness the presented algorithm is a combination of two existing approaches. zone calculations are proven to be correct, and the weakest precondition operation is defined to be correct. the correctness of the algorithm can be proven based on the fact that the values of clock and data variables are independent of each other. therefore, since the computation of zones and (data) predicates are correct, the complete algorithm is also correct. the formal proof is constructed as follows. claim (correctness) the presented algorithm is correct: 〈l0,vd0,v c 0〉 is represented by one of the nodes of the abstract reachability graph iff there is a run s0 =〈l0,vd0,v c 0〉→···→ s ′ n =〈ln,vdn,vcn′〉 of a where ln = ltrg is the target location. proof. (⇐) sn is represented by the initial node. suppose a state of the run s′k is represented by some nk = 〈ck,pk,zk〉 in this case nk also represents sk since the vck ∈{v c k′} ↓. let ek−1 = 〈lk−1,g, p,r,u,lk〉 be the edge corresponding to the discrete transition sk−1 → sk. in this case the following claims hold: • vck−1 ∈ preg,r({v c k}), since the zone operations are correct, • vdk−1 |= wp( ∧ v∈v v = v d k (v),u) (since the weakest precondition was defined like that), therefore • vdk−1 |= wp(p,u) for any p where v d k |= p, • vdk−1 |= p because the transition is enabled, and • vdk−1 |= cond(v ). therefore, there is also an edge of the graph representing e from nk to some other node nk−1 that represents sk−1 and – by induction – there is also a node representing s0. (⇒) let node n0 = 〈l0,p0,z0〉 be a node of the graph, where l0 is the initial location vc0 ∈ z0 and v0d |= p0. if a node n of the abstract reachability graph is not the initial node, then it was created along with an incoming edge e(n). find the path ni e(ni−1)−−−−→ ni−1 ...n1 e(n0)−−−→ n0 where ni is the initial node. because of the way the edges are chosen, all states represented by a node nk are a preimage of some state represented by nk+1 (other incoming edges might have been introduced based on coverage and in that case, the preimage might be just a subset of the states represented by nk+1). therefore for all states sk represented by nk there is a state sk+1 represented by nk+1 such that sk+1 is reachable from sk by the edge corresponding to e(nk). by induction, ni represents a state reachable from s0. remark 4 the path ni e(ni−1)−−−−→ ni−1 ...n1 e(n0)−−−→ n0 is the abstract representation of a run from s0 represented by n0 to s′i represented by ni through the discrete transitions e(ni−1) →···→ e(n0). delay transitions can also be derived by further analysis of the path. avocs 2018 12 / 20 eceasst 5 comparison of backward and forward exploration this section presents the measurements ran to analyze and compare the efficiency of the proposed algorithm to forward approaches. the results are discussed and possible improvements are also proposed. 5.1 measurements to analyze the applicability and the efficiency of the algorithm we have implemented it in the theta verification framework [thv+17] and ran measurements on the xtabenchmarksuite1, that is a set of test cases for benchmarking timed automaton verification algorithms (we have presented an earlier version of the benchmark suite in [fb18], but it has been improved since). to compare the algorithm to forward exploration we also ran measurements on the algorithm presented in [hsw13] that we have also implemented in the theta framework. the benchmark suite contains networks of timed automata with data variables. as mentioned in subsubsection 3.2.2, for some inputs the properties only define the target location for a few of the automata in the network. in these cases, the possible target configurations were manually collected – all possible combinations of the locations of the remaining automata were included. in many cases, this resulted in a set of target configurations too large for efficient verification. however, by observing the models, we could eliminate many of the configurations. to demonstrate the significance of describing a precise property, we ran the backward exploration algorithm on both the original and the modified property. these modifications did not affect the forward exploration algorithms. the measurements were executed on a virtual 64 bit windows 7 operating system with a 2 core cpu (2.50 ghz) with 1,5 gb of memory. each algorithm was run 10 times on each input, the longest and the shortest was eliminated and the average of the remaining runtimes was taken. the timeout was 10 minutes. 5.2 evaluation the xtabenchmarksuite consists of more models than those mentioned here, but we have excluded those that contain a model element that is not yet supported by theta (e.g. broadcast channels) and those where the property to check is not a reachability property (e.g. liveness properties) or only constrains the data variables. we have also excluded the models where both of the studied algorithms timed out. table 1 describes the results of the benchmarks on diagonal-free timed automata. the column name contains the name of the model in the xtabenchmarksuite and in case of scalable models, the value of the parameter. the next two columns contain the number of target configurations as described by the original and – when we managed to refine it – the precise property. the remaining columns contain the runtime and the number of explored nodes by the algorithms. the columns denoted by lu correspond to the algorithm presented in [hsw13], while the remaining columns correspond to the execution of our backward exploration algorithm on the model with the original and the modified property. 1 https://github.com/farkasrebus/xtabenchmarksuite 13 / 20 volume 076 (2019) https://github.com/farkasrebus/xtabenchmarksuite backward reachability analysis for timed automata with data variables table 1: results on diagonal-free systems name target configurations lu bw original precise original precise time (ms) nodes time (ms) nodes time (ms) nodes exsith 1 1 4 2 5 latch 1 2 7 1 2 srlatch 4 1 0 6 5 28 4 16 andor 4 1 11 9 42 39 13 21 engine 288 35 674 3731 8783 simop 8960 128 72 325 9820 26271 800 1517 maler 1 553 7157 134127 53519 mutex 5 1248 5563 [to] critical2 56 1 135 112 1631 1914 18 22 critical3 784 8 148 1632 [to] 599 811 critical4 10976 64 770 25202 [to] 233114 51488 csma2 4 23 18 16 26 csma3 16 29 71 247 338 csma4 64 55 262 16547 11306 csma5 256 177 855 [to] fischer2 1 14 18 19 11 fischer3 4 11 65 93 78 fischer4 16 59 220 476 594 fischer5 64 79 727 10221 10426 fischer6 256 366 2378 96102 93735 fischer7 124 1913 7737 [to] lynch2 1 20 38 18 33 lynch3 9 32 125 656 821 lynch4 81 47 380 35344 27523 train2 64 14 44 156 380 train3 256 37 165 694 1330 train4 1024 315 1123 6886 10290 train5 4096 3874 6488 66837 79892 train6 16384 103455 60379 [to] avocs 2018 14 / 20 eceasst table 2: results on diagonal timed automata lu bw name transformation algorithm total time (ms) time (ms) time (ms) nodes time (ms) nodes split (original) 4 4 8 9 3 4 split (modified) 27 16 43 10 4 4 diag (original) 14 6 20 22 8 8 diag (modified) 32 22 54 24 14 8 table 2 describes the results of the benchmarks on timed automata with diagonal constraints. we did not manage to find an industrial case study containing diagonal constraints, thus we use the models we found in the literature as examples. model split was introduced in [by03] to demonstrate the incorrectness of the forward exploration algorithm and diag was used to demonstrate techniques describes in [blr05]. we also run the algorithms on modified versions: we added new edges to these examples to create cyclic models. 5.2.1 weakest precondition one of our research goals was to find out if the weakest precondition operation can be used to efficiently calculate data variables during backward exploration of timed automata. models of the benchmark suite only contain a few data variables (protocols usually one for each participant, and inputs of category system have integer variables, but their set of possible values is rather small). a possible difficulty would have occurred if the abstract reachability graphs were deeper, but this was not the case as we used breadth-first search. out of these models engine had the deepest reachability graph with a depth of 63. the results show that despite its limitations (such as the solver overhead introduced by coverage checking) in practice weakest precondition can be used to handle data variables. furthermore, while most algorithms calculate the values of data variables explicitly, weakest precondition makes it possible to use predicate abstraction over the data variables that can also increase the efficiency of an algorithm. 5.2.2 property definition one of the motivations for using backward exploration is that the state space explored from the target states might be smaller than the reachable state space. however, in practice the properties describing the target states are kept simple, only mentioning a few locations and variables of the system. while an understandable property definition is usually beneficial, it also increases the number of target states exponentially. for instance, in case of mutual exclusion protocols (that appears to be the most common area of applicability for timed automata) the target state is any state where at least two processes are in the critical section. in case of a system of n similar processes containing k locations there are kn−2 possible control vectors that satisfy this property. clocks and data variables can be handled 15 / 20 volume 076 (2019) backward reachability analysis for timed automata with data variables with symbolic methods, but locations have to be explored explicitly. we believe this issue could be overcome in many cases, such as the critical example, where the target location is only given for the prod cell automata, however it is easy to determine the current location of the corresponding arbiter automata. therefore, we believe that some initial static analysis of the automaton and the constraints (e.g. the forward exploration of the location graph) could decrease the number of initial states. as it is seen in table 1 adding details to the property increases the efficiency of backward exploration. 5.2.3 timed automata with diagonal constraints one of the key strengths of backward exploration for timed automata is that it is correct (sound) for timed automata with diagonal constraints. the transformation of a timed automaton containing diagonal constraints to a diagonal-free automaton takes time and increases the size of the automaton and thus makes verification less efficient – as demonstrated in table 2. we were only able to perform these measurements on small examples from the literature, since there are no public industrial case studies of timed automata with diagonal constraints. we believe this is due to the fact that most analysis tools do not support diagonal constraints and because of this the case studies are stored in diagonal-free form. 5.2.4 general conclusions in case of timed automata with diagonal constraints, backward exploration performs better on the small examples, although, we could not find an industrial example with diagonal constraints to support this claim. in case of diagonal-free timed automata forward exploration performs better in most cases. however, for many small models backward exploration explored a smaller state space, e.g. the latch circuit and protocols with a small number of participants. forward and backward exploration are complementary techniques. theta is able to perform both which makes it possible to chose the more appropriate one for a certain model. 5.3 possible improvements one of the reasons why forward exploration performs better on the case studies is that there are many optimizations for zone-based forward search (e.g. lu abstraction, lazy abstraction, etc. – see section 2). it would be desired to apply these optimizations for backward exploration. throughout these measurements we analyzed the models manually to strenghten the properties, although it would be possible (and beneficial) to perform automatic preprocessing on the input to decrease the number of target states (initial states for the algorithm). backward exploration can also be combined with other techniques to improve the efficiency of existing algorithms. a common application for backward exploration is to run it in parallel with forward exploration – i.e. bidirectional search. this way, if the target state is reachable, the explored state space becomes smaller than a single search from any direction. the two algorithms can also increase each others efficiency by exchanging information on the explored state space [vgs13]. bidirectional search for timed automata appears to be an area worth exploring. avocs 2018 16 / 20 eceasst 6 conclusions and future work in this paper we have presented an algorithm that uses zone-based backward exploration for the reachability analysis of timed automata. unlike zone-based forward exploration, this algorithm is also applicable for timed automata with diagonal constraints. we have extended the algorithm to handle complex data: the weakest precondition operation is suitable for calculating the values of data variables. the combination of the two algorithms resulted and efficient procedure for timed systems with data. xtabenchmarksuite is a benchmark suite consisting of timed automata including small examples and industrial case studies. xtabenchmarksuite was extended in this paper to evaluate the various timed algorithms more rigorously. measurements on the xtabenchmarksuite demonstrated the efficiency and the applicability of our new approach. we have shown that while the algorithm performs better on timed automata with diagonal constraints than forward exploration, some improvements and optimizations are necessary in order to be applicable for industrial case studies. our results provide a step towards the efficient verification of real-time systems. in the future we will improve the backward exploration algorithm to solve complex industrial case studies. we will analyze the applicability of the improvements of the forward exploration algorithm presented in [hsw13, tm17] to our backward exploration approach. we will also combine backward and forward search algorithms – as it was investigated that bidirectional search is efficient for sat-based algorithms in [vgs13]. we will also study the combination of forward and backward algorithms in the cegar framework as it was discussed in [rrt08]. in order to further investigate the strengths and weaknesses of the timed algorithms, we will extend the xtabenchmarksuite with more industrial case studies (e.g. the flexray protocol [gefp10]) and perform an exhaustive benchmark on the existing approaches. based on the results a – possibly automatic – process can be derived for deciding which algorithm is expected to be the most efficient for verifying a given system. diagonal constraints represent one extension of timed automata, which proved to be useful for a certain class of models. in the future, we have to analyze other extensions from the verification point of view. bibliography [ad91] r. alur, d. l. dill. the theory of timed automata. in proceedings of the realtime: theory in practice, rex workshop. pp. 45–73. springer, 1991. doi:10.1007/bfb0031987 [bc05] p. bouyer, f. chevalier. on conciseness of extensions of timed automata. journal of automata, languages and combinatorics 10(4):393–405, 2005. [bll+95] j. bengtsson, k. g. larsen, f. larsson, p. pettersson, w. yi. uppaal a tool suite for automatic verification of real-time systems. in dimacs/sycon 1995. pp. 232–243. springer, 1995. doi:10.1007/bfb0020949 17 / 20 volume 076 (2019) http://dx.doi.org/10.1007/bfb0031987 http://dx.doi.org/10.1007/bfb0020949 backward reachability analysis for timed automata with data variables [blr05] p. bouyer, f. laroussinie, p. reynier. diagonal constraints in timed automata: forward analysis of timed systems. in formats 2005. pp. 112–126. springer, 2005. doi:10.1007/11603009 10 [bm07] a. r. bradley, z. manna. the calculus of computation decision procedures with applications to verification. springer, 2007. doi:10.1007/978-3-540-74113-8 [bou03] p. bouyer. untameable timed automata! in stacs 2003. pp. 620–631. springer, 2003. doi:10.1007/3-540-36494-3 54 [bou04] p. bouyer. forward analysis of updatable timed automata. formal methods in system design 24(3):281–320, 2004. doi:10.1023/b:form.0000026093.21513.31 [bou05] p. bouyer. an introduction to timed automata. etr 2005, pp. 25–52, 2005. [by03] j. bengtsson, w. yi. timed automata: semantics, algorithms and tools. in acpn 2003. pp. 87–124. springer, 2003. doi:10.1007/978-3-540-27755-2 3 [ds+04] b. dutertre, m. sorea et al. timed systems in sal. technical report, sri international, computer science laboratory, 2004. [fb18] r. farkas, g. bergmann. towards reliable benchmarks of timed automata. in proceedings of the 25th phd mini-symposium. pp. 20–23. budapest university of technology and economics, department of measurement and information systems, 2018. [fs01] a. finkel, p. schnoebelen. well-structured transition systems everywhere! theoretical computer science 256(1-2):63–92, 2001. doi:10.1016/s0304-3975(00)00102-x [gefp10] m. gerke, r. ehlers, b. finkbeiner, h.-j. peter. model checking the flexray physical layer protocol. in fmics 2010. lncs 6371, pp. ”132–147”. springer, 2010. doi:10.1016/j.entcs.2005.04.014 [gms18] p. gastin, s. mukherjee, b. srivathsan. reachability in timed automata with diagonal constraints. in concur 2018. pp. 28:1–28:17. schloss dagstuhl leibnizzentrum fuer informatik, 2018. doi:10.4230/lipics.concur.2018.28 [hnsy92] t. a. henzinger, x. nicollin, j. sifakis, s. yovine. symbolic model checking for real-time systems. in lics 1992. pp. 394–406. ieee, 1992. doi:10.1109/lics.1992.185551 avocs 2018 18 / 20 http://dx.doi.org/10.1007/11603009_10 http://dx.doi.org/10.1007/978-3-540-74113-8 http://dx.doi.org/10.1007/3-540-36494-3_54 http://dx.doi.org/10.1023/b:form.0000026093.21513.31 http://dx.doi.org/10.1007/978-3-540-27755-2_3 http://dx.doi.org/10.1016/s0304-3975(00)00102-x http://dx.doi.org/10.1016/j.entcs.2005.04.014 http://dx.doi.org/10.4230/lipics.concur.2018.28 http://dx.doi.org/10.1109/lics.1992.185551 eceasst [hrsy14] h. hojjat, p. rümmer, p. subotic, w. yi. horn clauses for communicating timed systems. in hcvs 2014. pp. 39–52. 2014. doi:10.4204/eptcs.169.6 [hsw13] f. herbreteau, b. srivathsan, i. walukiewicz. lazy abstractions for timed automata. in cav 2013. pp. 990–1005. springer, 2013. doi:10.1007/978-3-642-39799-8 71 [iw14] t. isenberg, h. wehrheim. timed automata verification via ic3 with zones. in icfem 2014. pp. 203–218. springer, 2014. doi:10.1007/978-3-319-11737-9 14 [lei05] k. r. m. leino. efficient weakest preconditions. inf. process. lett. 93(6):281–288, 2005. doi:10.1016/j.ipl.2004.10.015 [mit07] i. m. mitchell. comparing forward and backward reachability as tools for safety analysis. in hscc 2007. pp. 428–443. springer, 2007. doi:10.1007/978-3-540-71493-4 34 [mp95] o. maler, a. pnueli. timing analysis of asynchronous circuits using timed automata. in charme 1995. pp. 189–205. springer, 1995. doi:10.1007/3-540-60385-9 12 [mps11] g. morbé, f. pigorsch, c. scholl. fully symbolic model checking for timed automata. in cav 2011. pp. 616–632. springer, 2011. doi:10.1007/978-3-642-22110-1 50 [rrt08] f. ranzato, o. rossi-doria, f. tapparo. a forward-backward abstraction refinement algorithm. in vmcai 2008. pp. 248–262. springer, 2008. doi:10.1007/978-3-540-78163-9 22 [rsv10] a. p. ravn, j. srba, s. vighio. a formal analysis of the web services atomic transaction protocol with uppaal. in isola 2010. pp. 579–593. springer, 2010. doi:10.1007/978-3-642-16558-0 47 [thv+17] t. tóth, a. hajdu, a. vörös, z. micskei, i. majzik. theta: a framework for abstraction refinement-based model checking. in fmcad 2017. pp. 176–179. ieee, 2017. doi:10.23919/fmcad.2017.8102257 [tm17] t. tóth, i. majzik. lazy reachability checking for timed automata using interpolants. in formal modelling and analysis of timed systems. lncs 10419, pp. 264– 280. springer, 2017. doi:10.1007/978-3-319-65765-3 15 [tm18] t. tóth, i. majzik. lazy reachability checking for timed automata with discrete variables. in spin 2018. pp. 235–254. springer, 2018. doi:10.1007/978-3-319-94111-0 14 19 / 20 volume 076 (2019) http://dx.doi.org/10.4204/eptcs.169.6 http://dx.doi.org/10.1007/978-3-642-39799-8_71 http://dx.doi.org/10.1007/978-3-319-11737-9_14 http://dx.doi.org/10.1016/j.ipl.2004.10.015 http://dx.doi.org/10.1007/978-3-540-71493-4_34 http://dx.doi.org/10.1007/3-540-60385-9_12 http://dx.doi.org/10.1007/978-3-642-22110-1_50 http://dx.doi.org/10.1007/978-3-540-78163-9_22 http://dx.doi.org/10.1007/978-3-642-16558-0_47 http://dx.doi.org/10.23919/fmcad.2017.8102257 http://dx.doi.org/10.1007/978-3-319-65765-3_15 http://dx.doi.org/10.1007/978-3-319-94111-0_14 backward reachability analysis for timed automata with data variables [vgs13] y. vizel, o. grumberg, s. shoham. intertwined forward-backward reachability analysis using interpolants. in tacas 2013. pp. 308–323. springer, 2013. doi:10.1007/978-3-642-36742-7 22 [yov97] s. yovine. kronos: a verification tool for real-time systems. international journal on software tools for technology transfer 1(1-2):123–133, 1997. doi:10.1007/s100090050009 [ypd94] w. yi, p. pettersson, m. daniels. automatic verification of real-time communicating systems by constraint-solving. in ifip 1994. pp. 243–258. 1994. avocs 2018 20 / 20 http://dx.doi.org/10.1007/978-3-642-36742-7_22 http://dx.doi.org/10.1007/s100090050009 introduction related work preliminaries timed automata basic definitions operational semantics extensions of timed automata verification of timed automata zone-based verification verification of extended timed automata weakest precondition backward exploration using weakest precondition algorithm overview of the approach state space exploration data structure and operations example proof of correctness comparison of backward and forward exploration measurements evaluation weakest precondition property definition timed automata with diagonal constraints general conclusions possible improvements conclusions and future work model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience electronic communications of the easst volume 75 (2018) 43rd international conference on current trends in theory and practice of computer science student research forum, 2017 (sofsem srf 2017) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience predrag filipovikj, guillermo rodriguez-navas and cristina seceleanu 20 pages guest editors: anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience predrag filipovikj1, guillermo rodriguez-navas1 and cristina seceleanu1 predrag.filipovikj@mdh.se, guillermo.rodriguez-navas@mdh.se, cristina.seceleanu@mdh.se 1 school of innovation, design and technology mälardalen university, sweden abstract: industry relies predominantly on manual peer-review techniques for assessing the correctness of system specifications. however, with the ever-increasing size, complexity and intricacy of specifications, it becomes difficult to assure their correctness with respect to certain criteria such as consistency. to address this challenge, a technique called sanity checking has been proposed. the goal of the technique is to assess the quality of the system specification in a systematic and rigorous manner with respect to a formally-defined criterion. predominantly, the sanity checking criteria, such as for instance consistency, are encoded as reachability or liveness properties which can then be verified via model checking. recently, a complementary approach for checking the consistency of a system’s specification by reducing it to a satisfiability problem that can be analyzed using satisfiability modulo theories has been proposed. in this paper, we compare the two approaches for consistency analysis, by applying them on a relevant industrial use case, using the same definition for consistency and the same set of requirements. since the bottlenecks of analyzing large systems formally are most often the construction of the model and the time needed to return a verdict, we carry out the comparison with respect to the: i) required effort for generating the analysis model and the latter’s complexity, and ii) consistency analysis time. assuming checking only invariance properties, our results show no significant difference in analysis time between the two approaches when applied on the same system specification under the same definition of consistency. as expected, the main difference between the two comes from the required time and effort of creating the analysis models. keywords: smt-based consistency analysis, model-checking-based consistency analysis 1 introduction a system’s requirements specification, often simply called system specification, represents one of the most important artifacts during the system’s development life cycle, especially for software systems. when a traditional development process like the waterfall model (w-model) [roy87] is followed, the system specification is created in the early stages of the development and is used as a basic input in the subsequent software development phases including the design and 1 / 20 volume 75 (2018) mailto:predrag.filipovikj@mdh.se mailto:guillermo.rodriguez-navas@mdh.se mailto:cristina.seceleanu@mdh.se model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience architecture, implementation, and verification and validation. it is known that errors introduced in the specification propagate into the subsequent artifacts, until they are eventually detected and corrected, incurring considerable costs. for this reason, it is essential to ensure that the system specification has good quality, that is, it is free from errors like inconsistency (internal logical contradictions). assuming checking only invariance properties, the traditional, and still predominant way for assessing the correctness of a system specification is through manual peer-review. however, in areas such as embedded systems, where the system specifications are growing in size, complexity and intricacy, a number of methods for formal and automated (computer-aided) verification of system specifications have been proposed [hjl96, php11b, msl16, frns17]. in order to analyze a system specification by using formal methods, first, the systems’ behavior has to be formally encoded, that is, expressed in some formal notation. second, one has to formally define the quality assessment criterion, and third, propose an automated technique that can be employed to assess the formally-encoded system specification with respect to the formally defined criterion. kupferman [kup06] coined the term sanity checking to denote this process. in the literature, there are many criteria for assessing the quality of a system’s specification, out of which consistency (lack of contradicting formulas within a specification) [hl96, hjl96, php11b], is the one that we focus in this paper. the sanity checking with respect to consistency is suitable for assessing the internal quality of the specification without requiring a more detailed system model. this type of sanity checking for consistency that does not require a structural or functional model of the system is called model-free checking [bbb12]. the benefits of the model-free sanity checking are mainly given by the possibility of detecting errors in specifications, at early phases of development. existing approaches reduce the consistency checking to a reachability or liveness property that is then assessed via model checking [cgp99]. assuming a simple definition of requirements consistency, in our previous work [frns17, frns18] we have proposed a satisfiability modulo theories (smt)-based [db11] approach for checking the consistency of system specifications formalized as sets of timed computation tree logic (tctl) [acd93] formulas. according to the assumed definition, the notion of consistency is reduced to checking whether the system specification is realizable as such, that is, whether there exists at least one consistent interpretation of the specification, consequently reducing the consistency checking to a satisfiability problem. the proposed approach is restricted to invariance properties, denoted as ag(ϕ) in tctl, where ϕ is a formula that contains predicates and nested operators. the decision to resort to smt for assessing the specification’s consistency is motivated by the following: i) the realizability of a set of formulas can be reduced to a constraint satisfiability problem, and ii) it might be efficient for consistency analysis of large sets of requirements. the proposed smt-based consistency analysis procedure as reported previously [frns17] shows a considerable reduction of the analysis time over the model-checking-based one as reported in literature [bbb+16]. however, since the notion of consistency differs between the smt-based and the model-checking-based one, comparing them as such is not meaningful. in this paper, we chose to compare the model-checking-based and the smt-based consistency analysis techniques, by applying them on the same industrial example from the automotive domain, namely the fuel level display (fld) system from scania, using the same definition of consistency over a set of invariance (ag(ϕ)) properties as defined above. for the comparison of sofsem srf 2017 2 / 20 eceasst the approaches, we consider two criteria, usually seen as the bottlenecks of formal analysis: i) the required effort to create the analysis model, and the resulting complexity of the latter, and ii) the required analysis time. additionally, we discuss the potential for adoption of both approaches in industrial settings. the smt-based approach is adopted as such [frns17], whereas for the model-checking-based one, we propose a transformation scheme for the restricted set of system specifications encoded in tctl, into a timed automata (ta) [ad94] model suitable for analysis with the uppaal [lpy97] model checker. then, we manually build the model, and analyze it with uppaal. next, we compare the efficiency of the method to our findings of applying the smt-based approach, on the same industrial system [frns17]. the rest of the paper continues as follows. in section 2, we give an overview of the preliminary concepts that are used in the remainder of the paper. next, in section 3, we introduce the fld system used as the running example on which both approaches are applied, after which a short overview of the smt-based approach is given in section 4. in section 5, we show how to transform a set of tctl properties of type ag(ϕ) into a ta model suitable for analysis with uppaal. after this, we compare the results from applying both approaches of analyzing the consistency of the fld specification, in section 6. we present an overview and comparison with related approaches in section 7. finally, we summarize the paper by providing concluding remarks and setting some directions for future work, in section 8. 2 preliminaries in this section, we introduce the preliminary concepts that are used in the rest of the paper. first, we present an overview of timed computation tree logic, which is the formalism that we use to formalize the system specification. then, we present the formal definition for consistency that we use in this paper. finally, we give an overview of the techniques and tools that we use to check the consistency of the formalized system specification, namely satisfiability modulo theories (smt) and the z3 tool, as well as model checking and the uppaal tool. 2.1 formal system specifications in timed computation tree logic in this work, we use timed computation tree logic (tctl) [acd93] to formalize the fld system requirements specification. tctl is a timed extension of computation tree logic (ctl) [ce82] suitable for the specification of real-time systems. tctl is interpreted over a branchingtime model (timed transition system) that consists of a non-empty set of states s, a successor relation r and a labeling function label that assigns a set of atomic propositions to locations. each state is defined as a pair (l,u), where l represents the set of valid propositions for that state, whereas u represents the valuation of the clock variables that measure the passage of time in the model. the syntax of tctl consists of path quantifiers (“a”, “e”), and path-specific temporal operators. the universal path quantifier “a” stands for “all paths”, while the existential quantifier “e” denotes that “there exists a path” from the set of all future paths pm(s) starting from a given state s. a valid tctl formula is of type ϕ u./t ψ , where ϕ , ψ are state predicates, u (“until”) represents the basic path-specific temporal operator, which is combined with either one of the 3 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience two path quantifiers, ./∈ {<,≤,=,≥,>}, and t is a numeric bound on clock variables. the rest of the path-specific temporal operators are defined based on the u operator. the future operator, denoted as f./t (alternative notation ♦./t ), is interpreted as eventually true along a given path, when the clock valuation satisfies ./ t (e.g., f./t ϕ ⇔ true u./t ϕ , with ϕ a state predicate). the path-specific temporal operator that we use in our formal requirements, is called globally, represented as g./t (alternative notation �./t ) denotes always true in all states along a given path in which the clock valuation satisfies ./ t (e.g., g./t ϕ ⇔¬f./t¬ϕ ). there exists a weaker version of the u operator called “weak-until” denoted as w./t , which is used to capture formulas where the right hand side term might never be satisfied. the semantics of w./t is defined as: ϕ w./t ψ ≡ (ϕ u./t ψ)∨g./t ϕ . if one pairs g with the universal path quantifier a, one gets properties of the form agϕ , called invariance properties, where ϕ is combination of predicates and nested operators. they should be fulfilled at any state along any execution of the system model. this is the class of properties of interest in this work. 2.2 consistency of system specifications to assess the consistency of a system’s specification encoded as a set of logical formulas, we use the following definition: definition 1 (inconsistent specification) let φ = {ϕ1,ϕ2,...,ϕn} denote the system requirements specification, where each of the formulas (ϕ1,ϕ2,...,ϕn) encodes a requirement in the original system specification. we say that the set φ is inconsistent if the following implication is satisfied: ϕ1 ∧ϕ2 ∧...∧ϕn =⇒ false. according to definition 1, a system’s requirements specification is inconsistent if there does not exist a valuation of the variables in ϕ1,ϕ2,...,ϕn, such that the conjunction of all formulas evaluates to true. conversely, a specification is consistent if there exists at least one valuation of the variables such that the conjunction of all the formulas is true. this restricted definition of consistency refers to internal consistency of requirements, which is equivalent to the lack of logical contradictions. 2.3 satisfiability modulo theories and z3 the problem of determining whether a formula expressing constraints (equality, inequality, etc.) has a solution is called constraint satisfiability problem. the best-known constraint satisfiability problem is the propositional satisfaction sat, where the problem is to decide if a formula over boolean variables, formed using logical connectives can become true by assigning false/ true values to the constituent variables. to express the requirements as constraints, in this paper we use first-order logic. a first-order logic formula is a logical formula formed using logical connectives, variables, quantifiers and function and predicate symbols. a solution of first-order logic formulas is a model, which in fact is an interpretation of the variables, function and predicate symbols that makes the given formulas true. for checking satisfiability of formulas that contain additional theories, as for instance theory of arithmetics, we use satisfiability modulo theories (smt) [db11], which form an sofsem srf 2017 4 / 20 eceasst extension of the classical sat problem over first-order logic formulas, where the interpretation of some symbols is constrained by a background theory. in this work, we use z3 [db08], which is a state-of-the-art smt solver and theorem prover developed and maintained by the microsoft rise group. the advantage of z3 is that it has a stable group of developers who maintain the tool, as well as a broad academic community that is actively using it. the input to the tool is a set of assertions that can be either declarations or formulas. originally, the assertions are specified using the smt-lib language [bft15]. declarations in z3 can be either constants or functions. in fact, in z3 everything is expressed as functions, with constants being functions with no input parameters. the set of predefined types in z3 includes: int, real, bool and function. the set of supported types can be extended with user-defined types. z3 supports two types of quantifiers: universal quantifier (forall) and existential quantifier (exists). for optimizing decision procedures, the tool uses a number of tactics. the set of formulas whose satisfiability is to be checked by the tool is kept on the internal stack. the command assert adds a new formula to the stack. the smt decision procedure is invoked by executing the command check-sat, which checks where there is a solution for the conjunction of all the assertions on the stack. if the set of assertions is satisfiable, the z3 tool returns the result sat, which can be accompanied by the model that contains the witness assignment of the variables. the model is generated using the command get-model. in the opposite case, that is, when the set of assertions on the stack is not satisfied, the tool returns unsat, together with a minimal set of inconsistent assertions. 2.4 model checking model checking [cgp99] is an automated formal verification technique that checks, in a systematic and exhaustive manner, whether a finite-state system model satisfies a given property expressed most often in temporal logic. the core of model checking is the verification algorithm, performed by the model checker. the input to the model checker is a system model expressed in a formal notation and a set of formally specified logical properties. for verification of qualitative properties (that admit a yes/no answer) there are two possible outcomes of the model checking procedure. if the model conforms to a given property, the model checker returns a positive answer. for reachability and some liveness properties (e.g., something good will eventually happen) the model checker returns a witness trace in case of fulfillment. when an invariance property is not satisfied, the model checker generates a counter example, which is usually a path (error trace) to the state that violates the property. 2.4.1 timed automata and uppaal in our work, we use uppaal [lpy97], the state-of-the-art model checker for real-time systems. uppaal provides an integrated environment for modeling, simulation and verification of realtime systems. the uppaal model checker accepts formal system models specified as timed automata [ad94], and a set of properties that the formal model is checked against, specified in tctl [acd93]. 5 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience figure 1: a timed automaton for a timer-based lamp. timed automata (ta) is an extension of finite-state automata with real-valued variables called clocks, suitable for modeling the behavior of real-time systems. the clocks are non-negative variables that grow at a fixed rate of 1, and capture the passage of time. a timed automaton is represented by a tuple, 〈l,l0,x,v,a,σ,i〉, where: l is the set of locations, l0 ∈ l is the initial location, x is the set of clocks, v is the set of data variables, a represents the set of actions, σ ⊆ l×a×b(x,v )×2x ×l is the set of edges, where each edge e = (l,g,a,r,l′) ∈ σ is characterized by a source location l, and a sink location l′, respectively, a guard g, action label a, and a set of clocks (r) that are reset when the edge is traversed, and b(x,v ) represents the constraints over the clock and data variables, respectively. i : l → b(x) is a function that assigns invariants to locations, which bound the allowed time in a particular location. b(x) represents the set of formulas of the form: x ./ c or x−z ./ c called clock constrains, where x,z ∈ x , c ∈ n and ./∈ {<,≤,=,≥,>}. a clock constraint is downwards closed if ./∈ {<,≤,=}. similarly, b(v ) denotes the set of non-clock constraints that are conjunctive formulas of type i ∼ j or i ∼ k, where i, j ∈ v , k ∈z and ∼∈{<,≤,=,≥,>}. the semantics of ta is defined over a timed transition system (s,→), where s is the set of states, and → is the transition relation that describes how the system evolves from one state to another. a state s∈s is a pair s = (l,u), where l is the location and u is the valuation of the clocks. a progress in the system is performed by either a discrete or a delay transition. by executing a discrete transition the automaton moves from one location to another, instantaneously, whereas by executing a delay transition the automaton remains in the same location while the time passes. a path of a ta is an infinite sequence of states σ = s0a0s1a1s2a2... alternated by transitions, be they delay or discrete (here they are abstracted into a generic type of transition), such that si ai−→ si+1. uppaal extends ta with a number of features, such as: constants, bounded data variables, arithmetic operators, urgent and committed locations, as well as urgent and broadcast channels. a committed location is used to indicate that time is not allowed to pass while the system is in that location. the synchronization between ta in performed via synchronization channels in a hand-shake or broadcast manner. the synchronization is modeled by annotating edges with synchronization labels (a! for the sender automaton, and a? for the receiver automaton). when two or more edges are synchronized, they execute simultaneously, that is locations in all the involved automata in the synchronization are changed (provided that all involved automata are in the corresponding locations, and the guards of the annotated edges are true at the time). a network of uppaal timed automata (nta) is a parallel composition of and arbitrary number sofsem srf 2017 6 / 20 eceasst fld pbs ems icl coo fuel anin dmac hw actualparkingbrake indicatedfuelvolume can2 dmacch actualfuelvolume sg f s r i c l midd ssr1dmac ssr2dmac ft fuelsensor figure 2: excerpt of the high-level architecture of the fuel level display system. of ta over x and σ, synchronizing on actions and using shared variables. uppaal uses symbolic semantics and symbolic reachability techniques to analyze the densetime state space of the timed automata model, with respect to a set of properties formalized in a decidable subset of (t)ctl. for a more comprehensive overview of the properties that are supported by uppaal, we refer the reader to the literature [lpy97]. in figure 1 we show a timed automaton that models the behavior of a timer-based lamp. initially, the lamp is off, represented by the location off. the system remains in the given location until a synchronization message press? is received, which models the press of a button. once the synchronization message is received, the system transitions into location dim. during the transition, the automaton resets the system clock (denoted as t) via an update action t := 0. the lamp can stay in dim location for at lest 3 but not more than 5 time units, ensured by the invariant t < 5 and the guard t >= 3, after which it returns to location off. if the light is dim and the button is pressed again, the light goes bright (transition to location bright). once the light is bright, the only way to turn it off is to push the turn on button again and issue press? synchronization message. 3 industrial use-case: fuel level display in this section, we introduce the industrial system called the fuel level display (fld), used as a case study on which we evaluate both approaches for consistency checking. the fld system is a function installed in all heavy-load vehicles produced by the swedish 7 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience truck manufacturer scania. the main functionality of the fld is to estimate the remaining fuel in the vehicle, which is computed based on different sensor readings, and display the correct value to the driver. the fuel estimation feature is implemented as a software function deployed on the coordinator (coo) electronic control unit (ecu) system. the remaining fuel that is displayed to the driver is calculated based on the sensed fuel level obtained from the fuel tank provided by the fuel sensor (fuelsensor) placed inside the fuel tank (ft), and the current fuel consumption rate provided by the engine management ecu system (ems). the system is classified as safety critical, meaning that its proper functioning must be ensured while the vehicle is moving, to prevent hazardous situations that can endanger human lives. the simplified architectural break-down of the fld system, including all aforementioned parts, is given in figure 2. the design description is based on a set of elements [wn15], which are represented as rectangles in figure 2 (ex: fld, pbs, etc.). the elements are used to model all entities in the system’s design description, including both physical and logical ones. the interface of an element is represented via one or more ports (ex: actualparkingbrake, actualfuelvolume, etc.), which represent the tangible entities of an element as seen by an external observer. the communication between the different elements occurs via their ports. the behavior of an element is defined through a set of constraints over its ports, which for the fld system are specified using the contract-based approach, through assertions of type assume-guarantee, represented with dashed lines in figure 2. in the following, we present some of the requirements of the fld’s system specification, which model the functional and time-bounded functional aspect of the system. sg if actualparkingbrake (apb) is false, then indicatedfuelvolume (ifv), shown by the fuel gauge, is less than or equal to actualfuelvolume (afv). fsricl if it has not passed more than 1s since the last time can message dashdisplay (dd) appeared on can2 can bus, and the dd message is valid, then the ifv, shown by the fuel gauge, corresponds to fuellevel (fl) signal value from the dd message. ssr1dmac the direct memory access (dma) channel that corresponds to the input value of dmacch when dmac enablech() function is called, is enabled when dmac enablech() function finishes its execution. ssr2dmac the dma channel that corresponds to the input value of dmacch when dmac disablech() function is called, is disabled when dmac disablech() function finishes its execution. for the detailed functional description of the system we redirect the readers to other work [wn15]. 4 smt-based consistency analysis: method and application in this section we give an overview of the smt-based consistency analysis method that we have proposed in our earlier work [frns17]. the method is intended to be lightweight, supported sofsem srf 2017 8 / 20 eceasst by a fast analysis procedure, suitable for application in early stages of system development, and appealing to engineers. step 1 step 2 step 3 step 4 model unsatcore text to tctl tctl to fol encoding in z3 smt analysis sat (consistent) unsat (inconsistent) figure 3: our smt-based method for consistency checking. the smt-based method is given in figure 3. it is composed of 5 steps, as follows: step 1 transforms the informal free-text requirements into a formal notation suitable for the formal analysis. the step is based on specification patterns (sps) [dac98] [kc05] [agl+15], which have been shown expressive enough for formalizing requirements in the automotive domain [fnr14] [pmhp12]. the procedure of creating the formal system specification is supported by the sesamm specifier tool [fjn+16] that we have also proposed in our earlier work. the result of applying the specification patterns and the sesamm specifier tool is a set of requirements that can be expressed in different notations, including controlled natural language and various formal notations. the advantage of this automated step is the fact that, based on the patterns, one can automatically generate the set of temporal formulas expressed in tctl, where each tctl formula corresponds to a single requirement of the original system specification. the results from analyzing the pattern-based formal system specification for fld shows that only 5 patterns are enough to formalize the complete set of 23 requirements. the patterns used in the formalization are given as follows: p1: globally, universally: ag(ϕ) p2: timed globally, universally: ag(ag≤t (ϕ)⇒ ψ) p3: globally, response: ag(ϕ ⇒ af≤t ψ) p4: after ϕ until θ universally ψ : ag(ϕ ⇒ a(ψ w≤t θ )) p5: timed after ϕ until θ universally ψ : ag(ag≤t (ϕ)⇒ a(ψ w≤t θ )) the smt-based analysis is carried out over formulas encoded in first order logic (fol). due to the semantic gap between the temporal logics and the fol, we propose step 2, in which we bridge this semantic gap by instantiating the semantics of the path quantifiers and the path specific temporal operators in fol logic. the step-by-step procedure of instantiating the operators is explained in full details in our previous work [frns17]. in this paper we assume that all the used sps patterns can be transformed in fol using the described procedure. consequently, a set of fol formulas is obtained, each corresponding to a tctl formula from step 1. 9 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience once the fol formulas have been obtained, in step 3 we propose a way of encoding them into z3 assertions using z3py, which is a python api of the z3 tool. however, using z3 is not mandatory, as one might opt to use another smt solver. during this step, we also propose three abstraction rules intended to simplify the original formulas without any loss of potential inconsistency in the system. the abstraction rules are suitable for system specifications expressed as invariance properties. in such cases, we show that instead of having three quantified variables (branch, location and time), each fol formula can be reduced to a single quantified variable (time), while still preserving the information about the potential inconsistencies in the system. the application of abstraction rules is mandatory, as the smt procedure proves not to terminate for the original set of fol formulas. an additional advantage of the abstraction rules is the fact that their application speeds up the analysis procedure significantly [frns17]. finally, in step 4, the smt analysis is performed to determine whether a witness assignment of variables, which satisfies the conjunction of all the encoded z3 assertions, exists. if the set of assertions is proven satisfiable, the smt solver returns a model containing the valuation of all the atomic propositions such that the conjunction of all the assertions evaluates to true. in the opposite case, that is when there exists no solution for the conjunction of all the assertions representing the system specification, the smt solver returns unsat-core. considering the fact that during the transformation there is a consistent one-to-one mapping of natural language requirements into z3 assertions via a unique identifier for each requirement in the specification allows us to trace the unsat-core assertions back to the original set of requirements. the smt analysis procedure is applied over the complete set of fld requirements that comprises of 36 z3 assertions. it is executed on a linux machine with 2.4 ghz dual core processor and 4gb ram. initially not all assertions could be solved by the z3 procedure, but after a series of conservative mitigation strategies the smt analysis over the complete set of fld system requirements terminates within seconds [frns17]. 5 consistency analysis by model checking: method and application in this section, we provide details on how we build the model that encodes the requirements specification of a system, with application on fld, as well as on how to asses the consistency of the system requirements encoding via model checking. according to definition 1, in order to disprove the inconsistency of a system’s requirements specification represented as a set of logical formulas, it is enough to find a state in which all the requirements in the specification are non-vacuously satisfied. to explain the non-vacuous satisfaction, let us consider the following property: ag(ϕ ⇒ ψ ). the given property can be satisfied in two ways: i) the property is vacuously satisfied if ϕ is false in all states, or ii) nonvacuously if there exists at least one state in which ϕ is true, and whenever ϕ is true ψ is also true. next, we give an overview of our approach for building the network of ta from the system requirements specification as a set of tctl formulas (section 5.1), after which we show the properties of the fld model that we have checked for consistency (section 5.2). sofsem srf 2017 10 / 20 eceasst 5.1 building the system model in order to be able to analyze the consistency of requirements specifications via model checking, first one has to build a formal model of the system specification. as an input, we use the system specification expressed as a set of tctl formulas, as presented in section 2.3. for the analysis, we use uppaal, which means that the set of tctl formulas needs to be transformed into an nta. to be able to compare the smt and model checking for analyzing consistency of requirements as invariance properties, we apply common modeling principles in both methods, such that the comparison becomes feasible. the basic modeling principle applied in the process of transforming the tctl requirements into an nta relies on mapping each tctl formula onto a single timed automaton. the goal is to transform each individual formula (requirement) in isolation, by using only minimal contextual information. additionally, the one-to-one mapping between the tctl formula and the respective automaton ensures the traceability between the requirements in the system specification and the ta model, which is fundamental for error localization and its further mitigation. all system variables (usually ports of components in figure 2) are modeled as global data variables in uppaal. all the formalized requirements in the specification are invariance properties (ag(ϕ )), meaning that the properties must hold in all system states. however, some of the tctl formulas contain implications, thus can be vacuously satisfied. to make sure that we can clearly distinguish between the vacuous and non-vacuous satisfaction for each formula, we propose two basic templates for encoding requirements as ta that eliminate vacuous satisfaction by design, shown in figure 4. (a) (b) figure 4: ta templates for transforming tctl formulas into ta. the template given in figure 4a is used for modeling the tctl formulas that do not contain 11 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience implication. the automaton is composed of three locations, called initial, intermediate and active. the behavior of the automaton is defined as follows: initially, the automaton is in the initial location, and remains there until either the precondition for execution is satisfied or its execution is triggered by some event. if the precondition is a predicate over system variables, then it is modeled as a guard decorating the outgoing edge from the initial location. for modeling the events in the system, we use broadcast channels. given the fact that the requirements are specified using the assume-guarantee contract-based approach [wn15], a requirement is guaranteed to be fulfilled provided that the set of assumptions for that requirement holds. in the context of fld, it means that the postcondition of a given requirement can be guaranteed if the requirements that have been annotated as assumptions have already executed and their postconditions established. by using this mechanism we assure the correct ordering of execution of the automata, that is, it is guaranteed that a given requirement ta is executed (can transition to the active location) if and only if its precondition is established. once the automaton is triggered, it performs a transition from initial location into active location, which is decorated with an invariant corresponding to the postcondition that has to be established when a given requirement is non-vacuously fulfilled. since the update transition action and the invariant of the destination location are over the same data variables, the transition is divided into two parts by a committed location denoted as intermediate, otherwise a deadlock occurs. the first part, made of two edges, one for the precondition over variables, and one for triggering via a broadcast channel, is additionally decorated with an update action intended to update the values of variables such that the requirement is actively fulfilled. the choice of two edges is motivated by the fact that the invariant on the active location is over data variables. once location active is reached, the automaton remains in that location indefinitely, as we do not model any release condition. the automaton shown in figure 4b is used as a basis for representing the tctl formulas that contain implication. this is a most basic form of an automaton model meant to encode the tctl formulas obtained by using patterns p2 to p5 as presented in section 4. it represents an extension of the automaton given in figure 4a, with an additional location called inactive that denotes the mode in which the antecedent of the formula has not yet been satisfied. the template automaton in general models two distinct branches of execution. the first branch starts with location initial, and then reaches location active, via locations inactive and intermediate. this branch models the behavior corresponding to the antecedent not being satisfied. the second branch of execution involves locations initial, intermediate and finally active, and models the behavior in which the antecedent holds at the time the execution of the automaton is started. as already mentioned, the template given in figure 4b represents a basic template, which, in order to correctly capture the behavior of the tctl formulas obtained by using patterns p2 p5, has to be modified accordingly. relying on the explanation that we have given for the basic behavior, the extension to accommodate the behavior of the aforementioned patterns is trivial, hence we do not discuss it further. the fld system specification includes a number of events that trigger the behavior of some of the requirements. the problem is that the existence of such events in the system specification is assumed, and there is no detailed information about their occurrence, duration, etc. in order to enable the execution of requirements that depend on the occurrence of events, we have sofsem srf 2017 12 / 20 eceasst figure 5: controller automaton for the actual parking brake event. to additionally include components in the nta model, which are responsible for generating those events. we call such components controllers, and for the fld system model we include nine controllers; the latter are responsible for triggering individual events such as function calls (ex: dmac enablech, dmac disablech, etc.), or modeling the dynamics of some of the system’s variables’ evolution (ex: actualfuelvolume, sensedfuelvolume, actualparkingbrake, etc). since there is no information about the frequency of their occurrence or the order at which they are allowed to occur, the behavior of the controller automata is completely non-deterministic. one example of a controller is given in figure 5, and its responsibility is to model the behavior of the parking brake sensor. the controller models the two operational modes of the sensor, which in the nta model is represented by the actual parking brake global boolean variable, which is considered applied (engaged) if set to true, and disengaged if set to false. the controller starts the execution in the initial location and non-deterministically decides whether the parking brake is initially applied or not. since the execution of the controller starts before any of the requirements is enabled, no event is raised on either of the edges. once initialized, the controller then non-deterministically switches between the two modes. if the controller decides to switch mode, then it will first update the value of the sensor variable and issue the c brake status changed! broadcast event to notify the rest of the automata in the network. 5.2 analyzing the consistency of the fuel-level-display system specification as already presented in section 2.1, in order to prove the consistency of requirements it is sufficient to show that all the requirements in the specification can be (non-vacuously) satisfied simultaneously at least by one witness trace. in model checking terms, this means that it is enough to show that there exists a run of the model, such that all the automata (excluding the controllers) simultaneously reach their active location, respectively. additionally, special care has to be taken when there are requirements in the specification that describe complementary behaviors, as they cannot be actively fulfilled at the same time. consequently, the consistency of the system specification consisting of m temporal logic formulas (requirements), encoded as an nta composed of automata a1,a2,...,an, n ∈ n, can be 13 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience proved if the following reachability property of the model is satisfied: e♦(a1.active and a2.active and ... and an.active), where i ∈ [1,n] and n < m if there are complementary requirements in the specification, otherwise n = m. provided that each location active in the model is decorated by an invariant, respectively, the given property can never be satisfied if two postconditions contradict each other. 6 comparison and discussion in this section, we present and discuss the results of applying the model-checking-based approach for checking the consistency of the fld system requirements, in terms of modeling effort and time required for the procedure to complete, and compare the approach to the smt-based one. modeling. for validation, we have applied the model-checking-based approach on a set of requirements of the fld display system, responsible for measuring, estimating and displaying the correct information about the remaining fuel in the vehicle. the resulting nta that models the behavior of the fld system obtained by applying the ta templates given in figures 4a and 4b in section 5.1 consists of 32 automata. in the model, 23 automata correspond to the requirements from the system specification, while the remaining 9 correspond to the different controllers that model the behavior of the various system variables and events. as already defined in section 5.2, the consistency checking for the fld system specification is reduced to a reachability problem, according to which the specification is consistent if a system state where all of the 20 operational fld requirements are actively fulfilled is reachable. the defined property does not include the requirements that describe complementary behavior, and in case of fld only thee of the total requirements are of this type. when the two presented methods are compared in terms of time and effort for creating the system model that is then used for consistency analysis, we observe that: the mapping between the intermediate first-order-logic(fol)-based system requirements specification and the smt-lib assertions is more intuitive compared to building the nta model of formal system specification expressed in tctl. the reason for this is that, in the first case, one can easily define the mapping between the different formulas, whereas the mapping between a temporal logic formula and an automata template is not as straightforward. this is primarily due to the different modeling concepts and constructs that are available in the different formalisms. for instance, in z3’s smt-lib representations, there is no special encoding of the events in the system, whereas in the timed automata world, the events can be modeled via different mechanisms, depending on whether the event has the purpose of synchronizing the execution of automata, or just triggering the execution of some of them. however, the encoding of the fol formulas in the smt-based consistency analysis approach, relies on abstractions defined in advance, so the encoding is an approximation rather than an exact one. another difference is the fact that the smt-lib assertions describe the static structure of the system in which there is no notion on how the system evolves in time. the z3 model (encoded as smt-lib script) is represented through a set of constraints of the system’s variables, which the solver tries to solve such that that they become satisfiable. in contrast, when building a ta sofsem srf 2017 14 / 20 eceasst model for the system specification, one has to correctly capture the system’s evolution in time. this means that additional effort has to be invested in order to model the nta such that the system’s execution and evolution are correct. this includes the modeling of poorly documented entities of the system, encoded by the controller automata, which have to be modeled based on contextual information and some assumptions from the system designer. ideally, there should exist a detailed specification on how the events that trigger the requirements occur, which sometimes can be part of the specification of another system. from the above observations, it follows that the transformation of tctl formulas into nta can be more challenging compared to their transformation in smt-lib script via patterns. even though these findings are somewhat expected, the contribution of our modeling exercise over the fld system shows them in practice on an industrial use-case. analysis time. the second aspect in which we compare the two approaches is the analysis time required by both the smt solver and the model checker to complete the consistency analysis and come up with an answer. the procedure for analyzing the consistency of the 23 fld requirements via reachability analysis as described in section 5.2 terminates in less than 60 seconds on a standard workstation personal computer. the model checker provides a witness execution trace which shows how the set of requirements has been actively satisfied, which disproves the inconsistency of the fld system requirements specification. as mentioned in section 4, and reported in detail in our previous work on the smt-based consistency analysis approach [frns17], the consistency analysis of the fld requirements specification terminates within seconds (usually less than 10, depending on other processes executing on the machine). therefore, we can conclude that there is no considerable difference in the analysis time in both approaches when applied to the fld case study, which renders the two methods almost equally efficient. however, in order to draw more accurate conclusions on the analysis time between the two techniques, we need to setup evaluations on a larger scale, including larger and more complex models. 7 related work there is a number of consistency analysis approaches proposed in the literature. in this section, we try to relate the most prominent to the consistency analysis approaches presented in this paper. barnat et al. [bbb12] propose a model-free sanity checking procedure for consistency analysis of system requirements specification in linear temporal logic (ltl) [pnu77] by means of model checking. the approach has later been extended [bbb+16] to support the generation of a minimal set of inconsistent requirements. despite the exhaustiveness, the approach suffers from the inherent complexity of transforming the ltl formulas into automata, especially for complex systems, rendering the method unusable in industrial settings. a similar approach for consistency checking of requirements specified in ltl is proposed by ellen et al. [esh14]. the authors introduce a definition for the so-called existential consistency, that is, the existence of at least one system run that satisfies the complete set of requirements. similar to what we propose, the analysis procedure has been integrated into an industrially-relevant tool, aiming at industrial application. the work by post et al. [php11b] defines the notion of rt-(in)consistency of real-time requirements. the definition covers cases where the requirements in the systems requirements 15 / 20 volume 75 (2018) model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience specification can be inconsistent due to timing constrains. the checking for rt-inconsistency is reduced to model checking, where a deadlock situation implies the rt-inconsistency of requirements. despite the exhaustiveness of the consistency checking approaches mentioned above, all of them suffer from two major limitations: the long time needed to create the formal requirements model, as well as the time for analysis that grows exponentially with the number of requirements that are analyzed. the model-checking-based consistency analysis approach applied in this paper shows some intricacy of building the ta model, however, compared to the aforementioned approaches, our approach relies on transformation patterns, which can be used to partially or fully automate the model generation, thus potentially reducing the modeling time. regarding the consistency analysis efficiency, the model-checking-based approach applied in this paper takes less time if compared to the checking efficiency, reported in related work [bbb+16, php11a]. the reason for this difference should be investigated in more detail, but at this point it seems that the main reason stays in the different definition of consistency (ours is weaker), and the different modeling principles applied to build the models. our definition of consistency is closest to the one proposed by ellen et al. [esh14], however, the latter approach is yet to be applied on industrial use cases, in order to have a basis for a meaningful comparison. 8 conclusions and future work in this paper, we have evaluated two methods of checking the consistency of system requirements specifications based on model checking and smt analysis techniques, respectively, on an industrial use-case from the automotive domain, namely fuel level display system. the input of both methods is a set of invariance properties encoded as ag(ϕ) in tctl, where ϕ is a formula that contains predicates and nested operators. the aim of the evaluation is to compare the two different methods for consistency analysis, with respect to: i) modeling effort, and ii) analysis time. the smt-based consistency analysis technique is completely based on our earlier work [frns17], whereas for the model-checking-based consistency analysis, we have proposed an approach for transforming the supported tctl requirements into nta, which we have shown how to analyze for existential consistency, as defined in our earlier work [frns17]. in order for our comparison to be meaningful, we have formalized the same set of requirements [frns17] that describe the fuel level display system, which is an operational function installed in all heavy load vehicles produced by scania. after applying and analyzing both approaches, our results show that there is no significant difference in the efficiency of the two consistency analysis procedures, however the modelchecking-based method requires a more intricate modeling effort. despite the fact that such observation is somewhat expected, we present the actual reasons on why building timed automata models is more challenging than generating a set of smt constraints. basically, the main modeling challenge is the encoding of the dynamics of the system behavior in ta model (for instance, the existence of locations intermediate), whereas in the smt-based approach one represents the model just as a set of constraints. given the fact that the required analysis time for both methods is measured in seconds, the difference in the modeling effort becomes the advantage to consider when it comes to industrial sofsem srf 2017 16 / 20 eceasst adoption. the generation of smt-lib script can be fully automated, thus requiring no manual intervention during the complete process [frns17, frns18], yet based on abstraction rules that eliminate some of the initial behavioral information (without losing the potential sources of inconsistency). on the other hand, even though we have shown that the transformation of the system specification expressed as tctl properties into nta can be automated to a large extent via patterns, complete automation of the same seems quite unlikely primarily due to the inability to automate the modeling of the synchronization mechanism for the execution of the requirements and the environment. the future work goes in several directions. first, we aim at applying the two techniques on more industrial examples in order to extend the boundaries of their understanding, applicability and usability. knowing that model checking suffers from the infamous state-space-explosion problem, it would be beneficial to investigate the scalability of each approach on larger industrial case studies. as a second direction for future work, we target developing appropriate tool support that will automate (partially or completely) the process of generation of the formal model, in both approaches. this should reduce the time required for creating the models, allowing us to test the approaches on more systems. the last direction of future work envisions the extension of the definition of consistency, in both methods, such that it can be applied for full consistency of requirements: instead of checking for the existence of a consistent valuation of the system specification variables, one could check for the existence of any inconsistent interpretation of the requirements. our initial work on the subject shows that both approaches can be extended for checking such property of an industrial system’s specification. acknowledgements: this work has been funded by the swedish governmental agency for innovation systems (vinnova) under the verispec project 2013-01299. bibliography [acd93] r. alur, c. courcoubetis, d. dill. model-checking in dense real-time. information and computation 104(1):2 – 34, 1993. doi:http://dx.doi.org/10.1006/inco.1993.1024 http://www.sciencedirect.com/science/article/pii/s0890540183710242 [ad94] r. alur, d. l. dill. a theory of timed automata. journal of theoretical computer science 126(2):183–235, apr. 1994. doi:10.1016/0304-3975(94)90010-8 http://dx.doi.org/10.1016/0304-3975(94)90010-8 [agl+15] m. autili, l. grunske, m. lumpe, p. pelliccione, a. tang. aligning qualitative, real-time, and probabilistic property specification patterns using a structured english grammar. ieee transactions on software engineering 41(7):620–638, 2015. [bbb12] j. barnat, p. bauch, l. brim. checking sanity of software requirements. in proceedings of the 10th international conference on software engineering and formal methods. sefm’12, pp. 48–62. springer-verlag, berlin, heidelberg, 2012. 17 / 20 volume 75 (2018) http://dx.doi.org/http://dx.doi.org/10.1006/inco.1993.1024 http://www.sciencedirect.com/science/article/pii/s0890540183710242 http://dx.doi.org/10.1016/0304-3975(94)90010-8 http://dx.doi.org/10.1016/0304-3975(94)90010-8 model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience [bbb+16] j. barnat, p. bauch, n. beneš, l. brim, j. beran, t. kratochvı́la. analyzing sanity of requirements for avionics systems. form. asp. comput. 28(1):45–63, mar. 2016. doi:10.1007/s00165-015-0348-9 http://dx.doi.org/10.1007/s00165-015-0348-9 [bft15] c. barrett, p. fontaine, c. tinelli. the smt-lib standard: version 2.5. technical report, department of computer science, the university of iowa, 2015. available at www.smt-lib.org. [ce82] e. m. clarke, e. a. emerson. design and synthesis of synchronization skeletons using branching-time temporal logic. in logic of programs, workshop. pp. 52– 71. springer-verlag, london, uk, uk, 1982. http://dl.acm.org/citation.cfm?id=648063.747438 [cgp99] e. m. clarke, o. grumberg, d. peled. model checking. mit press, 1999. [dac98] m. b. dwyer, g. s. avrunin, j. c. corbett. property specification patterns for finitestate verification. in proceedings of the second workshop on formal methods in software practice. fmsp ’98, pp. 7–15. acm, new york, ny, usa, 1998. doi:10.1145/298595.298598 http://doi.acm.org/10.1145/298595.298598 [db08] l. de moura, n. bjørner. z3: an efficient smt solver. in proceedings of the theory and practice of software, 14th international conference on tools and algorithms for the construction and analysis of systems. tacas’08/etaps’08, pp. 337–340. springer-verlag, berlin, heidelberg, 2008. http://dl.acm.org/citation.cfm?id=1792734.1792766 [db11] l. de moura, n. bjørner. satisfiability modulo theories: introduction and applications. commun. acm 54(9):69–77, sept. 2011. doi:10.1145/1995376.1995394 http://doi.acm.org/10.1145/1995376.1995394 [esh14] c. ellen, s. sieverding, h. hungar. detecting consistencies and inconsistencies of pattern-based functional requirements. pp. 155–169. springer international publishing, cham, 2014. [fjn+16] p. filipovikj, t. jagerfield, m. nyberg, g. rodrı́guez-navas, c. seceleanu. integrating pattern-based formal requirements specification in an industrial tool-chain. in 40th ieee annual computer software and applications conference, compsac workshops 2016, atlanta, ga, usa, june 10-14, 2016. pp. 167–173. ieee computer society, 2016. doi:10.1109/compsac.2016.140 http://dx.doi.org/10.1109/compsac.2016.140 [fnr14] p. filipovikj, m. nyberg, g. rodriguez-navas. reassessing the pattern-based approach for formalizing requirements in the automotive domain. in proceedings of the sofsem srf 2017 18 / 20 http://dx.doi.org/10.1007/s00165-015-0348-9 http://dx.doi.org/10.1007/s00165-015-0348-9 http://dl.acm.org/citation.cfm?id=648063.747438 http://dx.doi.org/10.1145/298595.298598 http://doi.acm.org/10.1145/298595.298598 http://dl.acm.org/citation.cfm?id=1792734.1792766 http://dx.doi.org/10.1145/1995376.1995394 http://doi.acm.org/10.1145/1995376.1995394 http://dx.doi.org/10.1109/compsac.2016.140 http://dx.doi.org/10.1109/compsac.2016.140 eceasst 22nd ieee international requirements engineering conference (re). volume 00, pp. 444–450. ieee computer society, los alamitos, ca, usa, 2014. [frns17] p. filipovikj, g. rodriguez-navas, m. nyberg, c. seceleanu. smt-based consistency analysis of industrial systems requirements. in the proceedings of the 32nd acm symposium on applied computing (sac). marrakech, morocco. acm, april 2017. [frns18] p. filipovikj, g. rodriguez-navas, m. nyberg, c. seceleanu. automated smt-based consistency checking of industrial critical requirements. sigapp appl. comput. rev. 17(4):15–28, jan. 2018. doi:10.1145/3183628.3183630 http://doi.acm.org/10.1145/3183628.3183630 [hjl96] c. l. heitmeyer, r. d. jeffords, b. g. labaw. automated consistency checking of requirements specifications. acm transactions software engineering methodology 5(3):231–261, july 1996. doi:10.1145/234426.234431 http://doi.acm.org/10.1145/234426.234431 [hl96] m. p. e. heimdahl, n. g. leveson. completeness and consistency in hierarchical state-based requirements. ieee trans. softw. eng. 22(6):363–377, june 1996. doi:10.1109/32.508311 http://dx.doi.org/10.1109/32.508311 [kc05] s. konrad, b. h. c. cheng. real-time specification patterns. in proceedings of the 27th international conference on software engineering. icse ’05, pp. 372–381. acm, new york, ny, usa, 2005. doi:10.1145/1062455.1062526 http://doi.acm.org/10.1145/1062455.1062526 [kup06] o. kupferman. sanity checks in formal verification. in proceedings of the 17th international conference on concurrency theory. concur’06, pp. 37–51. springerverlag, berlin, heidelberg, 2006. [lpy97] k. g. larsen, p. pettersson, w. yi. uppaal in a nutshell. int. journal on software tools for technology transfer 1:134–152, 1997. [msl16] n. mahmud, c. seceleanu, o. ljungkrantz. resa tool: structured requirements specification and sat-based consistency-checking. in ganzha et al. (eds.), proceedings of the 2016 federated conference on computer science and information systems, fedcsis 2016, gdańsk, poland, september 11-14, 2016. pp. 1737–1746. 2016. doi:10.15439/2016f404 http://dx.doi.org/10.15439/2016f404 19 / 20 volume 75 (2018) http://dx.doi.org/10.1145/3183628.3183630 http://doi.acm.org/10.1145/3183628.3183630 http://dx.doi.org/10.1145/234426.234431 http://doi.acm.org/10.1145/234426.234431 http://dx.doi.org/10.1109/32.508311 http://dx.doi.org/10.1109/32.508311 http://dx.doi.org/10.1145/1062455.1062526 http://doi.acm.org/10.1145/1062455.1062526 http://dx.doi.org/10.15439/2016f404 http://dx.doi.org/10.15439/2016f404 model-checking-based vs. smt-based consistency analysis of industrial embedded systems requirements: application and experience [php11a] a. post, j. hoenicke, a. podelski. vacuous real-time requirements. in proceedings of the 2011 ieee 19th international requirements engineering conference. re ’11, pp. 153–162. ieee computer society, washington, dc, usa, 2011. doi:10.1109/re.2011.6051657 http://dx.doi.org/10.1109/re.2011.6051657 [php11b] a. post, j. hoenicke, a. podelski. rt-inconsistency: a new property for real-time requirements. in proceedings of the 14th international conference on fundamental approaches to software engineering: part of the joint european conferences on theory and practice of software. fase’11/etaps’11, pp. 34–49. springer-verlag, berlin, heidelberg, 2011. http://dl.acm.org/citation.cfm?id=1987434.1987440 [pmhp12] a. post, i. menzel, j. hoenicke, a. podelski. automotive behavioral requirements expressed in a specification pattern system: a case study at bosch. requir. eng., pp. 19–33, 2012. [pnu77] a. pnueli. the temporal logic of programs. in proceedings of the 18th annual symposium on foundations of computer science. sfcs ’77, pp. 46–57. ieee computer society, washington, dc, usa, 1977. doi:10.1109/sfcs.1977.32 http://dx.doi.org/10.1109/sfcs.1977.32 [roy87] w. w. royce. managing the development of large software systems: concepts and techniques. in proceedings of the 9th international conference on software engineering. pp. 328–338. 1987. [wn15] j. westman, m. nyberg. contracts for specifying and structuring requirements on cyber-physical systems. in rawat et al. (eds.), cyber physical systems: from theory to practice. crc press, 2015. sofsem srf 2017 20 / 20 http://dx.doi.org/10.1109/re.2011.6051657 http://dx.doi.org/10.1109/re.2011.6051657 http://dl.acm.org/citation.cfm?id=1987434.1987440 http://dx.doi.org/10.1109/sfcs.1977.32 http://dx.doi.org/10.1109/sfcs.1977.32 introduction preliminaries formal system specifications in timed computation tree logic consistency of system specifications satisfiability modulo theories and z3 model checking timed automata and uppaal industrial use-case: fuel level display smt-based consistency analysis: method and application consistency analysis by model checking: method and application building the system model analyzing the consistency of the fuel-level-display system specification comparison and discussion related work conclusions and future work towards optimization-based predictive congestion controlfor the tor network electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) towards optimization-based predictive congestion control for the tor network christoph döpmann, felix fiedler, sergio lucia and florian tschorsch 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards optimization-based predictive congestion control for the tor network christoph döpmann, felix fiedler, sergio lucia and florian tschorsch tu berlin and tu dortmund abstract: the multi-hop nature of the tor network makes it challenging to achieve efficient and fair congestion control. in this paper, we investigate predictor, a novel approach towards multi-hop congestion control based on distributed model predictive control (mpc), an advanced optimization-based control technique. keywords: multi-hop congestion control, tor, distributed model predictive control 1 introduction the tor network [dms04] serves a globally growing demand for online privacy, supporting freedom of speech and censorship circumvention. this growing demand comes with higher expectations with respect to the quality of service, i.e., bandwidth, latency, and fairness. in tor, congestion control is a major factor for suboptimal—sometimes poor—performance [ag16]. in order to tackle the performance problems, we build upon and extend our previous work on predictor [fdtl20]. predictor is the conceptual study of a congestion control mechanism for the tor network that builds upon advanced optimization-based control techniques. in particular, it operates predictively using distributed model predictive control. in [fdtl20], we presented the concept behind predictor as well as the optimization problem’s formal description. in this paper, we complement a networking perspective and investigate predictor’s ability to improve congestion control in non-trivial network scenarios. more specifically, we make the following novel contributions: first, we elaborate on the networking protocol of predictor and present thoughts on its implementation. second, we carry out an initial simulation-based evaluation of predictor in networks with complex topologies. we thereby demonstrate predictor’s potential to clearly improve latency and fairness in multi-hop scenarios. we also point out current weaknesses, leading to our third main contribution: we make the idea of predictive congestion control accessible to the networking community, opening a perspective on future research directions for congestion control, especially in multi-hop scenarios. our work points out open research questions that will have to be tackled in order to follow this promising path. 2 predictor the tor network [dms04] implements the onion routing protocol. that is, user data is forwarded over a series of intermediate servers (relays) along a cryptographically-secured path (circuit). this multi-hop data transfer constitutes a challenge towards usable performance. in particular, proper congestion control is challenging, because a circuit consists of several independent tcp connections in a sequence. as a consequence, tor currently fails to deliver low latency as well as fair network resource allocation for circuits [ag16]. 1 / 4 volume 080 (2021) optimization-based congestion control to tackle this issue, we introduced the concept of predictor in [fdtl20]. predictor is built on the idea of distributed model predictive control (mpc), a novel technique from the field of control theory. in contrast to traditional approaches, mpc yields the potential to clearly outperform today’s congestion control due to its predictive behavior. it relies on a mathematical system description (model) and a formal optimization objective (cost function). furthermore, it allows the flexible integration of constraints to be satisfied. the resulting optimal control problem is solved repeatedly using numerical optimization. for predictor, we encoded the following goals into this mathematical framework to define the optimal scheduling strategy for any point in time: max-min fairness the resource allocation between circuits should adhere to local max-min fairness which is known to converge to global fairness. minimize queue sizes by taking the current and future buffer sizes into account, the scheduler can proactively prevent congestion in the network. minimizing queues results in lower latency. maximize data throughput at the same time, the optimization goal consists in allocating the maximum possible data rates to circuits such that the available bandwidth is fully utilized. we refer to [fdtl20] for the full description of the resulting formal model. 3 network protocol details it lies in the nature of distributed mpc that multiple entities interact so they can react to each other’s behavior. in the case of predictor, each tor relay independently carries out the optimization locally to define the scheduling strategy that is optimal at this moment in time. the predicted behavior is shared with the relay’s neighbors so it can be taken into account for their upcoming optimization steps. these predictions are represented by numeric vectors, so-called trajectories, that contain the future expected data rates and buffer sizes. we call the messages used for exchanging them feedback messages because they create the feedback loop between any two adjacent tor relays as far as congestion control is concerned. feedback messages carry the following trajectories: the expected input and output data rates, vin and vout, a desired output data rate vhatout,1 and the expected development of local buffer sizes sbuffer. each trajectory consists of ten double values and a one-byte type identifier. these trajectories are included per shared circuit between two adjacent relays. we envision the exchange of feedback messages going hand in hand with a novel transport protocol for tor, avoiding issues that stem from the use of tcp [ag16]. using, e.g., udp gives predictor maximum flexibility for scheduling, reliability, and flow control on the application layer. currently, tor sends data as fixed-size cells over tcp. similarly, predictor splits its feedback messages into equally-sized chunks to mitigate inference of, e.g., the number of circuits. note that predictor (same as tor) exchanges control messages hop-by-hop only, even though the propagation of optimization results leads to distributed convergence towards a network-wide scheduling strategy. we argue that the changes are compliant with tor’s adversary model as information (data rates and buffer sizes) is exchanged between neighbors only. however, a more comprehensive security analysis would be desirable for the future. 1 this is a minor improvement of predictor w.r.t. robustness, which we cannot elaborate due to space constraints. netsys 2021 2 / 4 eceasst predictor vanilla tor pctcp max-min fairness 0 200 400 600 800 1,000 0 1 2 3 4 number of circuits a ve ra ge la te nc y [s ] (a) latency (50 relays, variable circuits) 0 20 40 60 80 100 0.0 0.2 0.4 0.6 0.8 1.0 circuit throughput [kb/s] c um ul at iv e sh ar e (b) fairness (50 relays, 750 circuits) figure 1: evaluation results. (1a) average byte-wise latency (different random scenarios, 25-fold repetition each), and (1b) fairness (cdf plot of throughput per circuit, representative example). 4 evaluation in [fdtl20], predictor was evaluated only for trivial model scenarios to visualize its general behavior. we continue this work and give an initial idea of how predictor performs in nontrivial networks. in particular, we include considerably larger, random networks and compare predictor’s performance against (vanilla) tor as well as pctcp [ag13], an alternative circuit handling strategy for tor. to this end, we implemented a proof of concept for the ns-3 network simulator2, which has a series of limitations. however, on this conceptual level, our main objective is to explore the potential of distributed mpc for congestion control. 4.1 scope and limitations one of our main simplifications includes that we do not simulate the transmission of feedback messages, but emulate their exchange “out of band”. since feedback traffic is independent of the network speed, running the simulations at different simulated data rates, one could achieve arbitrary goodput-overhead ratios, which we refrain from doing. however, we note that, in real networks, feedback overhead would constitute a severe issue due to its linear growth with the number of circuits. another limitation is that our simulated network exhibits constant, uniform latency between relays. however, the mathematical predictor system model can be extended to handle varying latencies [fdtl20]. moreover, for this prototype, we base the data transfer on tcp (like tor and pctcp) instead of introducing a tailored transport protocol. predictor thus merely takes the role of a scheduler. 4.2 methodology and results we generate simulation scenarios with 50 relays and a varying number of circuits, ranging from 10 to 1,000. circuits consist of three randomly selected relays, each requesting an infinite stream 2 https://www.nsnam.org/ 3 / 4 volume 080 (2021) https://www.nsnam.org/ optimization-based congestion control of data (bulk traffic). after a lead time, we evaluate the steady state (identified manually by ourselves), i.e., the last two seconds of simulation time. for this time span, we analyze the following metrics: byte-wise end-to-end latency, throughput, and fairness. figure 1 presents our results for achieved latency and fairness. with respect to latency, we can see that predictor offers great potential to heavily improve on the status quo (see figure 1a). in particular, by explicitly requiring small queues during optimization, predictor achieves low latency independently of the number of circuits. in contrast, latency grows indefinitely for denser networks in the case of vanilla tor and pctcp. at the same time, we observe unfair data rate allocations for vanilla tor and pctcp when compared to an optimal max-min fair rate distribution (see figure 1b): most circuits receive either too low or too high data rates than their fair share. in predictor, however, circuits achieve data rates very close to max-min fairness. one can also see that predictor tends to give circuits rather too low data rates than too high. this also becomes apparent when analyzing the overall achieved throughput (not depicted for brevity): predictor consistently achieves around 20% less throughput than vanilla tor and pctcp. this was to be expected due to the fact that our predictor prototype operates as an additional scheduler limiting data rates on top of tcp. all in all, one can say that predictor illustrates the strong potential of distributed mpc for (multi-hop) congestion control, due to its effectiveness in improving latency and fairness. however, several issues like linearly growing feedback overhead, adaption to dynamic latencies, and slightly degraded throughput remain as open research questions. 5 conclusion in this paper, we presented a networking perspective on predictor, a multi-hop congestion control approach based on distributed mpc. our results show that mpc bears the potential to clearly improve latency and fairness. open research questions include reducing the overhead of feedback messages, which currently grow linearly with the number of circuits. references [ag13] m. alsabah, i. goldberg. pctcp: per-circuit tcp-over-ipsec transport for anonymous communication overlay networks. in ccs ’13: proceedings of the 20th acm conference on computer and communications security. 2013. [ag16] m. alsabah, i. goldberg. performance and security improvements for tor: a survey. acm computing surveys 49(2), 2016. [dms04] r. dingledine, n. mathewson, p. f. syverson. tor: the second-generation onion router. in usenix security ’04: proceedings of the 13th usenix security symposium. 2004. [fdtl20] f. fiedler, c. döpmann, f. tschorsch, s. lucia. predictor: predictive congestion control for the tor network. in ccta ’20: proceedings of the 2020 ieee conference on control technology and applications. 2020. netsys 2021 4 / 4 introduction predictor network protocol details evaluation scope and limitations methodology and results conclusion graph rewriting with contextual refinement electronic communications of the easst volume 61 (2013) selected revised papers from the 4th international workshop on graph computation models (gcm 2012) graph rewriting with contextual refinement berthold hoffmann 20 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst graph rewriting with contextual refinement berthold hoffmann fachbereich mathematik und informatik, universität bremen, germany abstract: in the standard theory of graph transformation, a rule modifies only subgraphs of constant size and fixed shape. the rules supported by the graph-rewriting tool grgen are far more expressive: they may modify subgraphs of unbounded size and variable shape. therefore properties like termination and confluence cannot be analyzed as for the standard case. in order to lift such results, we formalize the outstanding feature of grgen rules by using plain rules on two levels: schemata are rules with variables; they are refined with meta-rules, which are based on contextual hyperedge replacement, before they are used for rewriting. we show that every rule based on single pushouts, on neighborhood-controlled embedding, or on variable substitution can be modeled by a schema with appropriate meta-rules. it turns out that the question whether schemata may have overlapping refinements is not decidable. keywords: graph rewriting – two-level rewriting – critical overlap 1 introduction everywhere in computer science and beyond, one finds systems with a structure represented by graph-like diagrams, and with a behavior described by incremental transformation. model-driven software engineering is a prominent example for an area where this way of system description is very popular. graph rewriting is a natural formalism, which has been used to specify such systems in an abstract way, ever since this branch of theoretical computer science emerged in the seventies of the last century [eps73]. graph rewriting has a well developed theory [eept06] that gives a precise meaning to such specifications. it also allows to study fundamental properties, such as: does the system terminate? is it confluent? i.e., does rewriting of some start state lead to a unique final state? over the last decades, various tools have been developed that generate (prototype) implementations for graph rewriting specifications. some of them do also support the analysis of specifications: agg [ert99] allows to determine confluence by the analysis of critical pairs [plu93], and groove [ren04] allows to explore the state space. some years ago, the very efficient graph rewrite generator grgen has been developed in the group of gerhard goos at karlsruhe institute of technology [bgj06]. this tool supports an object-oriented graph model with subtyping and attributes, and rewrite rules with negative application conditions. recently, edgar jakumeit has extended the rules of grgen radically, by introducing recursive refinement of sub-patterns, application conditions, and sub-rules [jak08, hjg08]. a single rule of this kind can match, delete, replicate, and transform subgraphs of unbounded size and variable shape. these rules have motivated the research presented in this paper. because, the plain theory [eept06] covers only graphs and rules with attributes and subtyping; recently, it has been extended to cover application conditions, even in nested form [ehl+10, egh+12]. however, it does not capture 1 / 20 volume 61 (2013) graph rewriting with contextual refinement recursive refinement, so that such rules cannot be analyzed for properties like termination and confluence, and no tool support concerning these questions can be provided. our ultimate goal is to lift results concerning termination and confluence to rules with recursive refinement. as a first step, we formalize refinement by combining concepts of the existing theory, on two levels: we define a grgen rule to be a schema – a plain rule containing variables. on the meta-level, a schema is refined by replacing variables, using meta-rules based on contextual hyperedge replacement [hm10, dhm12]. refined rules then perform the rewriting on the object level. this mechanism is simple enough for formal investigation. for instance, properties of refined rules can be studied by using induction over the meta-rules. in this paper, we explore the expressiveness of rule refinement in comparison to other kinds of rules, which are based on single pushouts, neighborhood-controlled embedding, and variable substitution. it turns out that the expressiveness has a price: it can, in general, not be decided whether two schemata can have refinements that are parallelly dependent. the examples shown in this paper arise in the area of model-driven software engineering. refactoring shall improve the structure of object-oriented software systems (models) without changing their behavior. graphs are a straight-forward representation for the syntax and semantic relationships of object-oriented programs (and models). many of the basic refactoring operations proposed by fowler [fow99] do require to match, delete, copy, or restructure program fragments of unbounded size and variable shape. several plain rules are needed to specify such an operation, and they have to be controlled in a rather delicate way in order to perform it correctly. in contrast, we shall see that it can be specified by a single rule schema with appropriate contextual meta-rules, in a completely declarative way. the paper is organized as follows. the next section defines graphs, plain rules for graph rewriting, and restricted rules – called “contextual” – for deriving sets, or languages, of graphs. in sect. 3 we recall related work on substitutive rules, and define schemata, meta-rules, and the refinement mechanism. then we relate rule schemata to other kinds of graph rewrite rules, in sect. 4. it turns out that a rule defined by single pushouts, by neighborhood-controlled embedding, or by substitution of graph variables can be modeled by a single schema with appropriate meta-rules. in sect. 5 we study the existence of overlaps for schemata. we conclude by indicating future work, in sect. 6. 2 graphs, rewriting, and derivation we define graphs wherein edges may not just connect two nodes – a source to a target – but any number of nodes. such graphs are known as hypergraphs in the literature [hab92]. a pair c = (ċ , ~c ) of finite sets of colors is used to label nodes and edges of a graph, where a subset x ⊆ ~c with a type function type : x → ċ ∗ shall be used to name variables, which only appear in rules. definition 1 (graph) a graph g = (ġ,~g,att,`) consists of disjoint finite sets ġ of nodes and ~g of edges, a function att : ~g → ġ∗ that attaches sequences of nodes to edges; and of a pair ` = ( ˙̀,~̀) of labeling functions ˙̀: ġ → ċ for nodes and ~̀ : ~g → ~c for edges so that, for every variable, i.e., every edge x ∈ ~g with `g(x) ∈ x , the attached nodes attg(x) are distinct to each selected revised papers from gcm 2012 2 / 20 eceasst other, and labeled so that ˙̀∗g(attg(x)) = type(`g(x)). 1 we will often refer to the component functions of a graph g by attg and `g. a (graph) morphism m : g → h is a pair m = (ṁ,~m) of functions ṁ : ġ → ḣ and ~m : ~g → ~h that preserve attachments and labels: atth ◦~m = ṁ∗◦attg, ˙̀h = ˙̀g ◦ṁ, and ~̀h = ~̀g ◦~m. the morphism m is injective, surjective, and bijective if its component functions have the respective property. if m is bijective, we call g and h isomorphic, and write g ∼= h. if m maps nodes and edges of g onto themselves, it defines the inclusion of g as a subgraph in h, written g ↪→ h. for a graph g, xg = {x ∈ ~g | ~̀g(x) ∈ x } is the set of variables, and its kernel g is the subgraph without xg; g is called terminal if xg = /0. the subgraph of g consisting of a variable x ∈ xg and its attached nodes is called a star of x, and denoted by 〈x〉. the kernel of a star is discrete, it consists of the attached nodes of x, and is denoted as 〈x〉. example 1 (program graphs) figure 1 shows a program graph. circles represent nodes, and have their labels inscribed. in our examples, terminal edges are always attached to exactly two nodes, a source and a target, and are drawn as straight or wave-like arrows between these nodes. boxes represent variables, to be seen in fig. 3 to fig. 6; they have variable names inscribed, and are connected with their attached nodes by lines and arrows. the order of the attached nodes will always be clear from the context. program graphs have been proposed in [vj03] to represent object-oriented programs. in the simplified version of [dhj+08], nodes labeled with c, v, e, s, and b represent program entities: classes, variables, expressions, signatures and bodies of methods, respectively. straight arrows represent the hierarchical syntactical structure of entities, whereas wave-like arrows represent semantic relations between them. we define rewriting of graphs as in [eept06], but represent rules in a slightly different way. we also insist on injective matching of rules. this is not a restriction, see [hmp01]. definition 2 (rewriting) a (graph rewrite) rule ρ = (p ↪→ b ←↩ r) consists of a body graph b with subgraphs p and r, which are called pattern and replacement, respectively. their common subgraph i = p∩r is called the interface. nodes and edges in b are called obsolete if they lie in p\i, and new if they lie in r\i. we sometimes refer to graphs of ρ by pρ , bρ etc. an injective morphism m : p → g is a match of ρ in a terminal graph g if it satisfies the following gluing condition: every edge of g that is attached to the match of an obsolete node in m(p\i) lies in the match of the pattern m(p). then the rule ρ rewrites g under m into a graph h that can be constructed uniquely (up to isomorphism) by (1) removing the match m(p\i) of obsolete nodes and edges, giving the kept graph k, and (2) uniting k disjointly with a fresh copy of r, and gluing the interface i ↪→ r to its match m(i) in k, giving h.2 then we write g ⇒ρ,m h; k and h can be constructed so that there are inclusions g ←↩ k ↪→ h. in [eept06], a rule is represented as a “span” (p ←↩ i ↪→ r). our representation as a “join” 1 a∗ denotes finite sequences over a set a; the empty sequence is denoted by ε , and |w| denotes the length of a sequence w∈a∗. for a function f : a→b, its extension f∗ : a∗→b∗ to sequences is defined by f∗(a1 ...an) = f (a1)... f (an), for all ai ∈ a, 1 6 i 6 n, n > 0. for functions or morphisms f and g, f ◦g denotes their composition. 2 only the nodes and edges in the subgraph (p∪r) ↪→ b are relevant for rewriting. 3 / 20 volume 61 (2013) graph rewriting with contextual refinement c cs b v e s b e e v b e e e e v v s b e e figure 1: a program graph pum′ = c c s c b v v sb b e e e e e e e e figure 2: a rule performing pull-up method (p ↪→ b ←↩ r) is equivalent. however, the fact that the body b contains both pattern and replacement makes it easier to define the refinement of a rule (schema), which is a central concept of this work, see def. 4 below. example 2 (a refactoring rule) figure 2 shows a rule pum′. blobs painted red and green designate its pattern and replacement, respectively. together they designate the body, and their overlap defines the interface. an edge belongs only to those blobs that contain it entirely; so the straight arrow connecting the top-most c-node in the interface to a b-node in the replacement belongs only to the replacement, but not to the pattern (and the interface) of pum′. the pattern of pum′ specifies a situation where two subclasses of a class contain obsolete bodies for the same signature. the replacement specifies that one of these bodies is new in the superclass. if the obsolete bodies are semantically equivalent (which cannot be checked automatically, in general, but has to be confirmed by verification), pum′ performs a pull-up method refactoring. however, pum′ only applies if the class has exactly two subclasses, and if the method bodies have the particular shape seen in the pattern. the general pull-up method refactoring of fowler [fow99], which works for an unbounded number of subclasses and for method bodies of varying shapes, cannot be specified with a simple rule like this, but with schema refinement, see example 7 below. graph rewriting can be used for computing by reduction: a set of rules is applied to some input graph as long as possible. if no rule applies, a graph is a result (called normalform). reduction is terminating if every sequence of steps leads to a normalform. the normalform for some graph will always be unique if the rewriting relation is confluent. rules can also be used to derive sets, or languages, of graphs. a simple form of rules, where the pattern is a variable with its attached nodes, is known as context-free (hyperedge) replacement [hab92]. here we extend these rules so that their pattern may contain isolated nodes. this increases their generative power considerably. definition 3 (derivation) a rule π = (p ↪→ b ←↩ r) is contextual if x is the only edge in p and r equals b without x. for a set π of contextual rules, we write g ⇒π h, and say that π directly derives g to h if there is a rewrite g ⇒π,m h for some match m of some π ∈ π. as usual, ⇒+π denotes the selected revised papers from gcm 2012 4 / 20 eceasst bdy b e exp . . . . . . e exp exp ev exp exp ev e exp exp s e e exp . . . . . . e exp figure 3: contextual rules m for method bodies c v v sb bdy +⇒ m c v v sb e e figure 4: deriving a method body transitive closure of this relation. with some start graph g0, π defines a contextual grammar (c ,π,g0) over the labels c , which derives the language of terminal graphs derived from g0: l (c ,π,g0) ={h | g0 ⇒+π h,xh = /0}. the pattern p of a contextual rules π is the disjoint union of a star 〈x〉 with a discrete context graph, say c. we call π context-free if c is empty. the (context-free) borrowing rule π̄ = (〈x〉 ↪→ b ←↩ r[c]) of π is obtained by removing c from p, and distinguishing the subgraph c ↪→ r as a debt in r. π̄ is the set of borrowing rules for π. we write derivations with π̄, which we call endebted, as g ⇒+ π̄ h[d] where d is the debt, i.e., the embeddings of the nodes borrowed in the rules used in the derivation. derivations always extend the kernels of graphs. fact 1. (1) for every contextual rule π = (p ↪→ b ←↩ r), p ↪→ r. (2) for every derivation g ⇒π h, it holds that g ↪→ h. proof. let x ∈ ~p. (1) since p = i by definition, i ↪→ r. (2) thus, by definition of ⇒π , k = g−m(x). then k = g, and k ↪→ h implies k ↪→ h. example 3 (method bodies) when drawing contextual rules like those in fig. 3, we omit the blob around the pattern, and paint that of the replacement in grey. the variable outside the replacement box designates the star of the pattern, and green filling (appearing grey in b/w print) designates the context nodes. figure 3 defines the set m of contextual rules that derive method bodies of program graphs, or rather their data flow graphs: a body consists of expressions, which in turn either use the value of a variable, define it as the value of an expression, or call a method signature with actual parameters. the ellipses “. . . ” in two of the rules abbreviate replicative (context-free) rules that derive n > 0 copies of exp-stars. in the rules for exp, the nodes representing variables and signatures are context nodes. figure 4 shows a derivation of a method body with m. note that the body can only be derived from a graph that contains appropriate context nodes. for a start graph g0 = 〈x〉 with `g0(x) = bdy, we have l (c ,m,g0) = /0. the grammar for program graphs discussed in [hm10] does derive appropriate context nodes. note that the language of program graphs cannot be derived with context-free rules alone: in infinitely many program graphs, nodes labeled s, v, or b have an unbounded connectivity [hab92, theorem iv.3.3]. 5 / 20 volume 61 (2013) graph rewriting with contextual refinement 3 schema refinement with contextual meta-rules the idea to refine rules with meta-rules before applying them originated in two-level string grammars [cu77] that have been devised for defining the programming language algol-68. the idea has been transferred to graphs – with the aim to derive graph languages – rather early [hes79, gö79]. in [ph96], detlef plump and annegret habel have used the same idea for graph rewriting. their definition of a substitutive rule is inspired by term rewriting [ter03]: the pattern and replacement may contain graph variables. before applying the rule, every variable in the pattern is substituted with some graph; thus the rule may match a subgraph of unbounded size and arbitrary shape. if a variable does not occur in the replacement, the rule will just delete its substitution; otherwise the rule will replicate it as many times as the variable occurs in the replacement. in [ph96], a variable may be substituted with any graph. then rule matching becomes highly non-deterministic, so that reduction may involve a lot of backtracking. this can be very inefficient. if the substitution of a variable is required to be “shaped”, meaning that it is a graph derived with some set of contextual rules, matching gets feasible, as the rules guide the recursive search for a matching substitution. the context-free rules proposed for this purpose in [hof01] turned out to be too restrictive in practice: method bodies, for instance, cannot be derived with context-free rules so that they could not be used to define the shape of graph variables. (in [dhj+08], adaptive star rules [dhjm10] have been proposed to derive substitutions. this is powerful enough, but adaptive star rules tend to be complicated.) the graph rewriting tool grgen [bgj06] supports rules that are even more expressive [jak08, hjg08]: • substitutions of variables may be defined by rules that are contextual, not just context-free. thus we may substitute variables with graphs that cannot be derived by context-free rules, e.g., with graphs of method bodies as defined in fig. 3. • a variable may be attached to both, pattern nodes and replacement nodes. its substitution refines the pattern and the replacement of a rule at the same time. this does not only allow to match, delete, or replicate subgraphs of unbounded size and arbitrary shape: the rules that derive recursive sub-rules that transform such subgraphs in a single rule application. this way of rewriting with contextual refinement shall be studied in this paper. example 4 (pull-up method revisited) in order to generalize the pull-up method rule of fig. 2 so that it applies to classes with a varying number of subclasses, and method bodies of varying shape, we turn a rule into a schema with variables. variables are attached to nodes in the pattern and/or replacement of the schema. figure 5 shows a schema pum for pull-up method. two variables named bdy10 and one variable named bdy11 indicate spots of refinement. contextual meta-rules are used to refine a schema. their replacement is not just a graph, but a schema (called the embodied schema), i.e., a body graph with distinguished pattern and replacement, and with variables for further refinement if necessary. figure 6 shows some meta-rules for the variables in pum. the meta-rules for bdy10 and exp10 refine the obsolete part of pum according to the contextual rules m of fig. 3, whereas the meta-rules for bdy11 and exp11 replicate equal method bodies in the obsolete and new part of the schema. (the superscripts in the variable names indicate how many copies of a method body are made in its pattern and replacement.) selected revised papers from gcm 2012 6 / 20 eceasst pum = c c . . . c s c bc b . . . b b bdy10 bdy10. . . bdy11 figure 5: a schema for pull-up method bdy10 b e exp10 . . . . . . e exp10 e e bdy11 b e exp11 . . . e exp11 b e . . . . . . e exp10 e v e e exp exp11 e v e exp figure 6: meta-rules for bdy10, bdy11, exp10, and exp11 the meta-rules for the remaining contextual rules of m are defined analoguously. (in pum, the dots between the subgraphs containing the variable bdy10 are a shortcut for any number of these subgraphs. these can be generated easily by auxuliary meta-rules.) refinement of a schema generates rules, called instances, wherein all variables are gone. refining pum with the meta-rules in fig. 6 can generate the rule pum′ in fig. 2 as a particular instance. it may generate instances for any number of subclasses, and for method bodies of any shape. so it implements a general pull-up method refactoring according to [fow99]. contextual meta-rules, like those for exp10 and exp11, can only be applied to a schema that contains a node matching its context node (a v-node in this example). this is too restrictive: the context node could also be generated as an “ordinary” refinement of the rule in order to become an interface node that is matched when the instance is applied to a source graph. this can be achieved by using the borrowing version of every “truly” contextual meta-rule. in borrowing meta-rules for exp10 and exp11, the v-nodes would not be context nodes. in rule pum′, three nodes (painted green) have been derived from pum with borrowing meta-rules for m. we can now formally define schemata and meta-rules. in that context, variables must be used in a way that is consistent with this distribution: for all variables carrying the same name, corresponding attached nodes must belong to the same part of the schema: to the pattern, to the replacement, or to both. definition 4 (schema, meta-rule) we assume that the variable names x come with two functions pat,rep : x →n so that pat(ξ ) 6 |type(ξ )| and 1 6 rep(ξ ) 6 pat(ξ ) for every variable name ξ ∈ x . for every variable x named ξ with attg(x) = v1 ...vk in a graph g, these functions designate discrete subgraphs of g: the pattern attachment 〈x] consists of the leading attached nodes v1 ...vpat(ξ ), and the replacement attachment [x〉 consists of the trailing attached nodes 7 / 20 volume 61 (2013) graph rewriting with contextual refinement vrep(ξ ) ...vk. 3 a rule σ = (p ↪→ b ←↩ r) is a schema if p∪r = b and every variable x ∈ xb is consistently distributed, which means that 〈x] ↪→ p and [x〉 ↪→ r. a meta-rule δ = (π,ε) has a contextual rule π = (pπ ↪→ bπ ←↩ rπ ) as a spine, with a schema ε = (pε ↪→ bπ ←↩ rε ), called the embodied schema of δ . a match m : pπ → b is a meta-match of the spine rule π in the body b of σ if it maps the context cπ of π to the interface of σ , i.e., if m(cπ ) ↪→ i. the following properties are direct consequences of this definition. proposition 1 consider a schema σ = (p ↪→ b ←↩ r), a meta-rule δ = (π,ε) with a metamatch m : pπ → b so that there is a derivation b ⇒π,m b′. then there are unique graphs p′ and r′ so that σ ′ = (p′ ↪→ b′ ←↩ r′) is a schema with p ↪→ p′ ←↩ m(pε ) and r ↪→ r′ ←↩ m(rε ). proof. the morphisms between components of a meta-rule δ in fig. 7 are used to prove the claim. actually, all of them are inclusions, but we draw them simply as arrows. the solid arrows pπ iπ rε π pε rπ rε bπ pε π figure 7: a meta-rule pπ pε π rε π iπ pε rπ rε p b r k p′ b′ r′ m̄ m figure 8: schema refinement exist by def. 4. since rπ equals bπ without the single variable x in pπ , the terminal graphs pε and rε are included in rπ , and (pε ↪→ rπ ←↩ rε ) is a schema as well. the intersections pε π = pε ∩pπ and rε π = pπ ∩rε are discrete, as pπ does not contain terminal edges. let cπ be the context graph of π . then pπ = 〈x〉]cπ and iπ = 〈x〉]cπ . since variable attachments are consistently distributed, pε π = 〈x]∪cπ , rε π = [x〉∪cπ , and (pε π ↪→ pπ ←↩ rε π ) is a schema as well. as pπ = iπ , (pε π ↪→ iπ ←↩ rε π ) is another schema. this gives the dashed morphisms in fig. 7. thus the derivation b⇒π,m b′ has the solid morphisms shown in fig. 8, where m̄ shall denote the embedding rπ → b′ of m. consistent distribution of variable attachments in b implies that m(pε π ) ↪→ p and m(rε π ) ↪→ r. since k equals b without m(x), we get inclusions forming the schema p ↪→ k ←↩ r. now p′ is the unique subgraph of b′, containing the subgraph p and the subgraph m̄(pε ); r′ is determined likewise. the resulting inclusions σ ′ = (p′ ↪→ b′ ←↩ r′) are a schema if p′∪r′ = b′ and all variables in b′ are consistently distributed. in rπ and k, all terminal edges are in the pattern or replacement subgraphs (or in both), and all variables are consistently distributed. so it is easy to see that so are the terminal edges and variables in b′. this proposition allows to define the refinement of schemata by meta-rules. refinement proceeds until all variables have disappeared, and the resulting rule can be used to rewrite a graph. 3 thus the nodes vrep(ξ ) ...vpat(ξ ) are in the interface. in figures like fig. 5 and fig. 9 , the lines between an attached node v and a variable x get an arrow tip at x if v is obsolete, at v if v is new, and none otherwise. selected revised papers from gcm 2012 8 / 20 eceasst definition 5 (schema refinement and rewriting) consider a schema σ = (p ↪→ b ←↩ r) and a meta-rule δ = (π,ε) as above. for the derivation b ⇒π,m b′, fig. 1 allows to extend b′ to a unique schema σ ′ = (p′ → b′ ← r′). then we write σ ⇓δ ,m σ ′, and say that δ refines σ to σ ′ (at m). for a contextual meta-rule δ = (π,ε), the borrowing meta-rule is δ̄ = (π̄,ε). let ∆ be a finite set of meta-rules so that δ ∈ ∆ implies δ̄ ∈ ∆. then ⇓∆ denotes refinement steps with one of its meta-rules, and ⇓+ ∆ denotes repeated refinement, its transitive closure. ∆(σ) denotes the derivates of a schema σ = (p ↪→ b ←↩ r), containing its refinements without variables: ∆(σ) ={ρ | σ ⇓+ ∆ ρ,xbρ = /0} we write g ⇒∆,σ h and say that σ , refined with ∆, rewrites g to h if g ⇒ρ h for some derivate ρ ∈ ∆(σ). by lifting proposition 1 to refinement sequences, we see that derivates do indeed refine a schemata. fact 2. for derivates ρ ∈ ∆(σ), pσ ↪→ pρ , bσ ↪→ bρ , and rσ ↪→ rρ . it can be checked whether schemata do have refinements, or not. theorem 1 for a schema σ , it is decidable whether ∆(σ) = /0, or not. proof. a rule ρ is in ∆(σ) if and only if its body bρ is in the language of the contextual grammar (c ,π,bσ ) of spine rules π = {π | (π,ε) ∈ ∆} of ∆ that has the body of σ as a start graph. emptiness of the language is decidable for contextual grammars, by [dhm12, corollary 1]. example 5 (encapsulate-field) another refactoring operation, encapsulate field, shall replace using and defining accesses to an attribute (or field) a of a class by invocations of getter or setter methods, resepctively. since a program graph may contain an unbounded number of accesses to a, the operation cannot be specified by a single rule. however, it can be defined by a schema with meta-rules. the pattern of the schema ef in fig. 9 consists of a class node connected to a variable node. to this pattern, the replacement adds graphs representing signatures and bodies of the setter and getter methods. the variables uses and defs indicate points of refinement. their meta-rules are context-free, and have a similar structure: one using (defining) access of some expression to a in the pattern is replaced by a call of the getter (setter) method in the replacement, and the meta-rule is called recursively. the other meta-rules terminate this iteration. a single rewriting step with some derivate of ef transforms an arbitrary number of using and defining accesses to a variable into calls to the getter and setter method, respectively. this cannot be achieved by a plain rewrite rule; it goes even beyond the expressiveness of the substitutive rules that will be considered in section 4.2 further below. note that the meta-rules derive rules that encapsulate an arbitrary subset of variable accesses, and leaves the remaining ones direct. in practice, an access to v shall be encapsulated if and only if it is non-local; this could be specified by extending meta-rules with application conditions, as proposed in [hm10]. 9 / 20 volume 61 (2013) graph rewriting with contextual refinement ef = c uses defs s b b s e v e e v uses uses sv e ee uses sv defs sv defs defs sv e ee figure 9: a schema for encapsulate-field with four meta-rules note that the application of a derivate ρ ∈ ∆(σ), although it is the result of a compound metaderivation, is a single rewriting step g ⇒ρ h, like a transaction in a data base. note also that the refinement process is completely rule-based. operationally, we cannot construct the derivates of a schema σ first, and apply one of them later, because ∆(σ) is infinite in general. rather, we interleave matching and refinement in a goal-oriented algorithm. algorithm 1 (applying a schema to a graph) input: a terminal graph g, a schema σ0 = (p0 ↪→ b0 ←↩ r0), and a set ∆ of meta-rules. output: either a refinement σi ∈ ∆(σ0) with a match mi : pi → g, or the answer “no” if no derivate in ∆(σ0) applies to g. 1. search for an injective morphism m0 : p0 → g of the original schema σ0, and set i to 1. 2. search for a context-free meta-rule δi ∈ ∆ with a refinement (pi−1 ↪→ bi−1 ←↩ ri−1)⇓+δi (p i ↪→ bi ←↩ ri) such that the morphism mi−1 can be extended to a morphism mi : pi → g. if δi is the borrowing rule of some contextual meta-rule δ ′ = (π′,ε′), m may identify context nodes of the spine rule π′ with nodes in the interface pi−1 ∩ri−1; otherwise it must be injective. 3. if no such meta-rule can be found, undo refinements to the closest step j < i where some meta-rule exists that has not been inspected for σ j previously; if already all meta-rules have been inspected, for all previous steps, and for all initial matches m0, answer “no”. 4. if σi does contain further variables, increase i by one and goto step 2. 5. otherwise, σi is a rule with a morphism mi : pi → g. if mi violates the gluing condition, goto step 3. otherwise, output mi as a match of the derivate σi in g. actually, all matches for all applicable derivates can be enumerated, so that potential nondeterminism in the refinement can be handled by backtracking. grgen rules are executed this way. but, the match of a particular pattern pi is determined according to an efficient search plan that is pre-computed, taking into account the shape of the type graph, as well as that of the particular host graph g, and the whole rule is compiled into sequences of low level c# instructions that do graph matching and construction in an efficient way [gei08]. we need a mild condition to show that the algorithm terminates. selected revised papers from gcm 2012 10 / 20 eceasst definition 6 (pattern loops in meta-rules) a set ∆ of meta-rules does not loop on patterns if σ ⇓+ ∆ σ ′ implies pσ � rσ ′ . note that the meta-rules in fig. 9 of example 5 do not loop on patterns, nor do those in fig. 10 and fig. 11 of def. 7, nor those in fig. 6 of example 7. theorem 2 algorithm 1 is correct, and terminates if ∆ does not loop on patterns. proof sketch. in its course, the algorithm constructs a tree of refinements. this tree is finite: it has finite breadth, as step 1 chooses among finitely many initial morphisms m0 in g, and step 2 chooses among a finite number of morphisms for a finite number of meta-rules. its depth is finite as well, because every δi in step 2 satisfies |pi−1| 6 |pi|, and the length of chains with |pi−1|= |pi| is bound by |∆| since ∆ does not loop on patterns. for correctness, consider the following arguments: the identification condition in step 2 makes sure that the morphism mi either is an injective morphism for the borrowing meta-rule δ̄i, or an injective morphism for the original meta-rule δi. thus step 5 determines an injective morphism of a derivate of σ0, and checks whether it is a match. the backtracking in step 3 and step 5 makes sure that every possible candidate for a derivate with a match is considered. corollary 1 for a schema σ and meta-rules ∆ as above, it is decidable whether some derivate ρ ∈ ∆(σ) applies to a graph g, or not. 4 relation to other ways of graph rewriting in this section, we compare schemata to other ways of graph rewriting known in the literature: graph rewriting by single pushout, by neighborhood-controlled embedding, and by substitutive rules. in all three cases, a rule can be modeled by a single schema with appropriate meta-rules, whereas they cannot be modeled by a single plain rule. 4.1 graph rewriting with node [dis-]connection we investigate ways of graph rewriting where a single rule may delete and redirect a variable number of edges, respectively. first we define generic meta-rules that allow to model such rules. definition 7 ([dis-]connecting meta-rules) figure 10 shows a disconnecting meta-rule δ +d that extends a schema by a b-node in its interface, which is connected by an obsolete a-edge to an obsolete a-node. a disconnecting configuration d ∈ ċ × ~c ×{in,out}×ċ specifies the labels of the refined nodes and the label and direction of the refined edge. its borrowing meta-rule δ̄ + d is not shown. the (context-free) meta-rule δ 0 d terminates disconnection. a so refined schema will remove edges that connect nodes in the interface to the obsolete node that is attached to the variable disconnectd . a set of cooperating disconnecting meta-rules for all possible disconnecting configurations will remove all edges to the indicated obsolete nodes. it is important that the b-node is contextual: only then several edges connected to such a node can be disconnected. 11 / 20 volume 61 (2013) graph rewriting with contextual refinement δ 0 d = a c disconnectd δ + d = a c b disconnectd disconnectd a figure 10: meta-rules for a disconnecting configuration d = (a,a,in,b) δ 0 c = a c connectc δ + c = a c b connectc connectc a b figure 11: meta-rules for a connecting configuration c = (a,a,in,b,b,in,c) figure 11 shows a connecting meta-rule δ +c that extends a schema by nodes in its interface, which are connected to an obsolete node and to a new node. a connecting configuration c ∈ ċ × ~c ×{in,out}× ċ × ~c ×{in,out}× ċ specifies the labels of the refined nodes and the labels and directions of the refined edges. again, the borrowing meta-rule δ̄ +c is not shown. the context-free meta-rule δ 0c terminates disconnection. a so refined schema will remove, for the obsolete node v and the new node v′ attached to the variable, edges connecting v to interface nodes, and insert edges connecting these nodes to v′ instead.4 again, it is important that the b-nodes are contextual in order to redirect several edges incident with a node. ∆ dc shall denote the set of all disconnecting and connecting meta-rules, for all disconnecting and connecting configurations over the label alphabet c . graph rewriting defined with single pushouts [löw93] (spo, for short) is a variation of standard graph rewriting [eept06] as in def. 2. apart from technical details of their definition, spo rules have the same form as dpo rules. however, rewriting is defined differently: no dangling condition needs to be checked when matching a rule; the match m(v) of every obsolete node v of τ is always deleted, together with all its incident edges, including those outside the match m(p) that would violate the dangling condition in the standard case. we define how a plain rule according to def. 2 is turned into a schema that performs spo graph rewriting. definition 8 (modeling spo rewriting with schema refinement) for a rule ρ = (p ↪→ b ←↩ r), construct the spo schema σρ = (p ↪→ b ←↩ r) by attaching, to every obsolete node v in p\r, variables x named disconnectd , for every disconnecting configuration d = ( ˙̀p(v),a,io,a) where a ∈ ~c , io ∈{in,out}, and a ∈ ċ . fact 3. consider a rule ρ with an injective morphism m : p → g. then the spo schema σρ has a derivate ρ′∈ ∆dc(σρ ) with a rewriting step g ⇒ρ′ h so that all obsolete nodes of π are deleted, together with their incident (“dangling”) edges in the subgraph g\m(p). proof sketch. consider m : p → g. then p ↪→ p′ by proposition 1. now, at every obsolete node v of ρ , the schema can be refined with disconnecting meta-rules so that it covers every “dangling” 4 the meta-rules for uses and defs in example 5 are similar to connecting rules; only the node being disconnected, which is labeled v, is not obsolete, but in the interface. selected revised papers from gcm 2012 12 / 20 eceasst edge e incident in ṁ(v) and its “neighborhood node” – say v′ – that is outside m(p). as the preimage of v′ in the schema is in the interface of the refined schema, and the edge is in the obsolete part of the pattern, the dangling edges are removed while the nodes in the neighborhood are preserved. the refined rule satisfies the gluing condition, and does exactly what spo rewriting does. 5 graph grammars with neighborhood-controlled embedding are “the other notion” of graph rewriting. their definition is set-theoretic, and their most widely investigated subclass has rules where the pattern consists of a single node [er97]. here, we consider the more general case where the pattern is a graph. more precisely, neighborhood-controlled embedding rewriting (nce rewriting, for short) is defined as follows. 6 definition 9 (nce graph rewriting) an nce rule η = (m,d,i) consists of terminal graphs m and d, called mother graph and daughter graph respectively, and of a set of connecting instructions i ⊆ ṁ× ~c ×{in,out}×ċ × ~c ×{in,out}×ḋ. let ĩ denote the tuples (v,a,io,a) ∈ ṁ × ~c ×{in,out}×ċ without a connecting instruction c = (v,a,io,a,b,io′,v′)∈ i (for some (b,io′,v′)∈ ~c ×{in,out}×ḋ). a rule η as above applies to a graph g if there is an injective morphism m : m → g so that no edge in g\m(m) is incident with a node in m(m). then the application of η at m deletes the subgraph m(m) from g, adds a fresh copy of the daughter graph d, and obtains the graph h by executing the connecting instructions as follows: • if c = (v,a,io,a,b,io′,v′)∈ i, for all a-nodes z in the subgraph g\m(m) where g contains an a-edge e connecting z with ṁ(v) in direction io, a b-edge e connecting z with the node v′ ∈ ḋ in direction io′ is inserted in h. • for every d = (v,a,io,a) ∈ ĩ, a-edges between v and a-nodes in direction io are deleted from g. example 6 (an nce rule for encapsulate-field) the nce rule ef ′ in fig. 12 defines a variant of the encapsulate field operation ef shown in fig. 9. the mother graph is drawn left of the daughter graph. as the nodes c and v of the mother graph are obsolete, we have to add new nodes c′ and v′ with the same label to the daughter graph. the connecting instructions ief ′ are as follows: • all wave-like arrows from the node v to e-nodes, which represent direct using accesses to v, are redirected to the getter method g. (this corresponds to the meta-rules for uses in fig. 9.) • all wave-like arrows from e-nodes to the node v, which represent direct defining accesses to v, are “turned around” and redirected to the setter method s. (this corresponds to the meta-rules for defs in fig. 9.) 5 we have ignored the fact that matches of spo rules need not be injective. however, we can construct the (finite) set the quotients q(ρ) by identifying arbitrary isomorphic subgraphs in p. then for every non-injective match of ρ , q(ρ) contains a quotient with an equivalent injective match. 6 the abbreviation “ednce” used in [er97] emphasizes the fact that the directed graphs being rewritten have labeled edges. 13 / 20 volume 61 (2013) graph rewriting with contextual refinement ef′ = cc vv c c ′ s g b b s s e v v ′ e e v ief′ = {(v, ,out,e, ,out,g′)} ∪ {(v, ,in,e, ,out,s′)} ∪  (c,a,d,`,a,c′) ∣∣∣∣∣∣ a ∈ ~c , d ∈{in,out}, `∈ ċ   figure 12: an nce rule for encapsulate-field • all edges incident with the node c are redirected to the node c′ without changing their label or direction. (these instructions are overhead caused by the fact that the mother graph is completely obsolete.) rule ef ′ will replace all direct accesses to the variable v – local accesses cannot be preserved in this framework. definition 10 (modeling nce rewriting with schema refinement) an nce rule η = (m,d,i) as above can be transformed into a schema ση = (m → b ← d) where the underlying rule ση has an empty interface (i.e., b = m ] d), and b contains, for every connecting instruction c = (v,a,io,a,b,io′,v′) ∈ i, a variable x named connectc′ with attb(x) = vv′ and c′ = ( ˙̀m(v),a,io,a,b,io′, ˙̀d(v′)), and for every d = (v,a,io,a) ∈ ĩ, a variable x named disconnectd′ with attb(x) = v, and d′ = ( ˙̀m(v),a,io,a). fact 4. for an nce rule η as above, there exists an nce graph rewriting step g ⇒η h if and only if there is a rewriting step g ⇒ρ h using some derivate ρ ∈ ∆dc(ση ) of its schema σ η . proof sketch. as in the case of modeling spo rewriting, a match m : mη → g can be taken as a basis to refine ση so that all connection instructions are “performed”, and all other “dangling” edges are deleted. there are other derivates that do not satisfy the dangling condition although the nce rule applies. this is the case when the terminating meta-rules are applied before the recursive metarules have been applied exhaustively. if this is done, the nce rule applies iff the schema applies. even then, a refinement of the schema may violate the dangling condition. this is the case exactly when the match of the refined pattern contains nodes that are connected by edges outside the match. this, however, violates the application condition for nce rules as well, where the match must be the induced subgraph of the matched nodes. 4.2 substitutive graph rewriting we recall the definition of substitutive rules [hof01], re-phrase it slighty according to our definition of plain rules, and extend it to borrowing substitutions: definition 11 (substitutive rule) consider a finite set π of contextual rules. a substitutive rule γ = (p ↪→ b ←↩ r) consists of two graphs p,r with variables so that selected revised papers from gcm 2012 14 / 20 eceasst (1) all variables in b belong to p or to r, but not to both, and (2) every variable name occurring in r occurs in p as well. a substitution σ is a mapping from variable names to borrowing rules so that, for every variable name ξ ∈ x , σ(ξ ) = (〈ξ〉 ↪→ b ←↩ r[d]) with x (r) = /0. a rule ρ = (p′ ↪→ b′ ←↩ r′) is a σ -instance of γ if its body b′ is obtained from the (unique) terminal graph b∗ with b ⇒+ σ b∗ by identifying the debts of all variables carrying the same names, and by including them both in p′ and in r′. by identifying arbitrary nodes in p∩r with the debt, one obtains further σ -instances of γ . a substitutive rewrite step g ⇒ρ h applies some σ -instance ρ of γ , for some substitution σ . substitutive rules can be modeled as schemata refined by meta-rules as follows. definition 12 (meta-rules and schemata for substitutive rules) let γ be a substitutive rule for contextual rules π. then r = (k,m) is a replication instruction of a variable name ξ ∈ x if: (a) ξ labels, in γ = (p ↪→ b ←↩ r), k variables in p and m variables in r, or (b) (inductively) π contains a rule (p′ ↪→ b′ ←↩ r′) where the variable name ξ occurs in r′, and the variable name ξ ′ in p has a replication instruction r. we transform γ and π into a schema σγ and meta-rules ∆γ,π as follows: 1. whenever a variable ξ with type(ξ ) = l1 ...ln has a replication instruction r = (k,m), x shall contain a fresh replication variable name ξ r with type(ξ r) = lk+m1 ...l k+m n and pat(ξ r) = k ·pat(ξ ), rep(ξ r) = m ·rep(ξ ). 2. we transform every substitutive rule γ = (p ↪→ b ←↩ r) into a schema σγ = (p ↪→ b′←↩ r) by replacing all variables x1,...,xk+m named ξ in b (where we assume that xi is in p iff 1 6 i 6 k) by a replication variable y named ξ r with attb′(y) = pcat(attb(x1),...,attb(xk+m)).7 3. for every rule π = (p ↪→ b ←↩ r) ∈ π with r = b−x and x named ξ ∈ p, and for every replication instruction r = (k,m) of ξ , ∆γ,π shall contain a context-free reproducing metarule δ r π = (π r,ε) so that (a) the kernel bπ r of its spine rule consists of k + m disjoint copies b1,...,bk+m of b so that b1,...,bk are in its embodied pattern pε and bk+1,...,bk+m are in its embodied replacement rε ; (b) for every variable x named ξ in b, where we assume that wi is the copy of the attached node sequence attb(x) in bi (for 1 6 i 6 k + m), bπ r contains a variable y named ξ r with attbπ r (y) = pcat(w1,...,wk+m). 7 note that the replication rule δ r π̄ of the borrowing rule π̄ of a contextual rule π equals the borrowing rule of δ r π so that ∆γ,π does also contain all borrowing meta-rules. thus 〈y〉 ↪→ pπ r if x is the variable in p, and all other variables belong to rπ r . in bπ r , a copy bi belongs to pε if 1 6 i 6 k, and to rε if k + 1 < i 6 k + m. if δ is contextual, its contextual nodes belong both to pε and to rε , are shared by all copies, and are contextual nodes in π r. 7 if, for 1 6 i 6 k, the words wi = ai,1 ...ai,n have equal length n > 0, their pointwise concatenation is pcat(w1,...,wk) = a1,1 ...ak,1 ...a1,n ...ak,n. 15 / 20 volume 61 (2013) graph rewriting with contextual refinement pum∗ = cm1 c . . . c s c b c c b . . . . . . b b m1 mn m m figure 13: pull-up method: substitutive rule note that the replications of meta-rules do not loop on patterns if the original meta-rules do not have looping derivations p ⇒+ π p. example 7 (pull-up method) figure 13 shows a substitutive rule pum∗ for pull-up method. all variables have the shape bdy defined by the contextual rules m in fig. 3. the substitutions of m0,...,mn,m are obsolete, but the variable named m is also new so that its substitution is re-inserted in the replacement.8 the rule pum′ in fig. 2 is an instance of pum∗. the schema of pum∗, and the meta-rules for m equal those in fig. 5 and fig. 6, respectively. fact 5. a rule ρ is the instance of a substitutive rule γ if and only if it is a derivate of the schema ρ of γ . 5 existence of critical overlaps in this section, we study whether the existence of critical overlaps, a decidable property for plain rewriting, is decidable for schemata as well. definition 13 (critical overlap) two rules ρ = (p ↪→b←↩ r) and ρ′ = (p′ ↪→b′←↩ r′) overlap critically if there exists a graph g with matches m : p → g and m′ : p′ → g that intersect in deleted nodes or edges, i.e., if m(p)∪m′(p′) 6↪→ m(p∩r)∪m′(p′∩r′). an overlap is minimal if every node and edge of g is in the image either of p or of p′. it suffices to check whether the finite number of minimal overlaps are parallel independent in the sense of [eept06, def. 5.9] or not. in the case of schema refinement, the more interesting question is whether two schemata may have derivates that overlap critically, or not. since schemata have infinitely many derivates in general, this question is harder to answer. unfortunately, we obtain: theorem 3 for rule schemata σ1 and σ2 with meta-rules ∆, it is, in general, undecidable whether or not σ1 and σ2 have derivates ρ1 ∈ ∆(σ1) and ρ2 ∈ ∆(σ2) with critical overlaps. proof. (by contradiction.) we reduce this problem to deciding whether context-free languages are disjoint, which is known to be undecidable [hu79, thm. 14.3]. 8 it is not forseen to have variables like m in the interface of a rule. selected revised papers from gcm 2012 16 / 20 eceasst we define a representation of words as string graphs, and context-free rules as context-free rules over string graphs. (1) let ċ = {◦} and let all variable names ξ ∈ x have arity arity(ξ ) = ◦◦, pat(ξ ) = 2, and rep(ξ ) = 0. (2) a graph g with nodes ġ ={vo,v1,...,vn}, edges ~g ={eo,e1,...,en} where attg(ei) = vi−1vi for 1 6 i 6 n is a string graph representing the word w =~̀∗g(e1 ...en)∈ ~c ∗. the string graph representing a word w is unique up to isomorphism, and denoted by w•. (3) now a proper context-free rule r = (ξ ,w) ∈ x × ~c + can be represented as a meta-rule δr with a spine rule π = (pπ →bπ ←↩ rπ ), where p = ξ•, r = w•, and, in b, p and r are disjoint up to their start and end nodes. it is shown in [hab92] that these rules perform context-free derivations on string graphs. in the embodied schema ε = (pε → bε ←↩ rε ) of δ , pε = bπ and rε is empty. now consider schemata where the string graphs for ξ and ξ ′ are enclosed in edges labeled with triangles (as start and end markers): σ1 = ξ b c σ2 = ξ ′ b c then derivates ρ1 = (p′1 → b ′ 1 ←↩ r ′ 1) ∈ ∆(σ1) and ρ2 = (p ′ 2 → b ′ 2 ←↩ r ′ 2) ∈ ∆(σ2) have critical overlaps if p′1 ∼= p′2. by the definition of derivates, and meta-rules, this implies that p ′ 1 ∼= p′2 ∼= w • for some word w ∈ ( ~c \x )∗, i.e., if w is in the context-free string languages derived from ξ and from ξ ′, respectively. in other words, σ1 and σ2 have critical overlaps if the languages derived from ξ and ξ ′ have an empty intersection. (there is no loss of generality if we assume that the context-free rules are proper, i.e., have non-empty right-hand sides, since every context-free grammar can be transformed into one where only the start symbol has a rule with an empty right-hand side. then the question is still undecidable for the sublanguages without the empty word.) this result holds even if the meta-rules are context-free. 6 conclusions in this paper we have defined how schemata of plain graph rewriting rules can be refined with contextual meta-rules. this models the outstanding feature of grgen. until now, we have not considered attributed graphs and subtyping. as they are included in the foundation [eept06], we expect that this can be added in a straight-forward way. we also restricted ourselves to unconditional rules. rules with nested application conditions have been added to the theory in [ehl+10, egh+12]; recently, hendrik radke has studied recursive refinement of such conditions [hr10]. we plan to add this concept to our definition in the future. we have shown that several other kinds of graph rewrite rules can be defined with contextual refinement: rules based on single pushouts, neighborhood-controlled embedding, and variable substitution. lack of space hindered us to present the definition of other kinds of rules: adaptive star replacement [dhjm10], a combination of context-free rules with nce rules, can be 17 / 20 volume 61 (2013) graph rewriting with contextual refinement modeled along the lines of nce graph rewriting; rules with variables substituted by adaptive star replacement [dhj+08] can be modeled along the lines of the substitutive rules considered in def. 11. the rules of [ph96] where variables can be substituted with arbitrary graphs are a special case of the substitutive rules considered here, as the language of all graphs can be defined with contextual replacement [dhm12, ex. 1]. even if graph rewriting with refinement is not to far from plain rewriting, some properties get lost since schemata have infinitely many derivates. so it is not decidable whether schemata may have parallelly (in-) dependent derivates, or not. an advanced property like confluence (based on the joinability of critical pairs) can probably only be considered in restricted situations. this will be the major direction of our future work. we want to provide assistance for users of grgen in analyzing the behavior of their specifications. acknowledgements: i wish to thank several people: edgar jakumeit conceived and implemented recursive refinements for rules in the grgen rewriting tool, under the supervision of rubino geiß. katharina saemann and ruth schönbacher identified an obvious error in fig. 8, and giorgio busatto, annegret habel, and hendrik radke have lent their ears (and brains) to simplify and consolidate early drafts of this paper. frank drewes has carefully reviewed two later versions of the paper. bibliography [bgj06] j. blomer, r. geiß, e. jakumeit. grgen.net: a generative system for graphrewriting, user manual. www.grgen.net, universität karlsruhe, 2006. version v3.6ms1b (2012). [cu77] c. cleaveland, r. uzgalis. grammars for programming languages. elsevier, new york, 1977. [dhj+08] f. drewes, b. hoffmann, d. janssens, m. minas, n. van eetvelde. shaped generic graph transformation. in schürr et al. (eds.), applications of graph transformation with industrial relevance (agtive’07). lecture notes in computer science 5088, pp. 201–216. springer, 2008. [dhjm10] f. drewes, b. hoffmann, d. janssens, m. minas. adaptive star grammars and their languages. theoretical computer science 411:3090–3109, 2010. [dhm12] f. drewes, b. hoffmann, m. minas. contextual hyperedge replacement. in schürr et al. (eds.), applications of graph transformation with industrial relevance (agtive’11). lecture notes in computer science 7233, pp. 182–197. springer, 2012. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs. springer, 2006. selected revised papers from gcm 2012 18 / 20 eceasst [egh+12] h. ehrig, u. golas, a. habel, l. lambers, f. orejas. adhesive transformation systems with nested application conditions. part 2: embedding, critical pairs and local confluence. fundam. inform. 118(1-2):35–63, 2012. [ehl+10] h. ehrig, a. habel, l. lambers, f. orejas, u. golas. local confluence for rules with nested application conditions. in ehrig et al. (eds.), icgt. lecture notes in computer science 6372, pp. 330–345. springer, 2010. [eps73] h. ehrig, m. pfender, h. schneider. graph grammars: an algebraic approach. in ieee conf. on automata and switching theory. pp. 167–180. iowa city, 1973. [er97] j. engelfriet, g. rozenberg. node replacement graph grammars. in rozenberg (ed.), handbook of graph grammars and computing by graph transformation. vol. i: foundations. chapter 1, pp. 1–94. world scientific, singapore, 1997. [ert99] c. ermel, m. rudolf, g. taentzer. the agg approach: language and environment. in engels et al. (eds.), handbook of graph grammars and computing by graph transformation, vol. ii: applications, languages, and tools. chapter 14, pp. 551– 603. world scientific, singapore, 1999. [fow99] m. fowler. refactoring—improving the design of existing code. object technology series. addison-wesley, reading, ma, 1999. [gei08] r. geiß. graphersetzung mit anwendungen im übersetzerbau (in german). dissertation, universität karlsruhe, 2008. [gö79] h. göttler. semantical descriptions by two-level gaph-grammars for quasihierarchical graphs. in nagl and schneider (eds.), graphs, data structures, algorithms (wg’79). applied computer science 13, pp. 207–225. carl-hanser verlag, münchen-wien, 1979. [hab92] a. habel. hyperedge replacement: grammars and languages. lecture notes in computer science 643. springer, 1992. [hes79] w. hesse. two-level graph grammars. in claus et al. (eds.), graph grammars and their application to computer science and biology. lecture notes in computer science 73, pp. 255–269. springer, 1979. [hjg08] b. hoffmann, e. jakumeit, r. geiß. graph rewrite rules with structural recursion. in mosbah and habel (eds.), 2nd intl. workshop on graph computational models (gcm 2008). pp. 5–16. 2008. [hm10] b. hoffmann, m. minas. defining models – meta models versus graph grammars. elect. comm. of the easst 29, 2010. proc. 6th workshop on graph transformation and visual modeling techniques (gt-vmt’10), paphos, cyprus. [hmp01] a. habel, j. müller, d. plump. double-pushout graph transformation revisited. mathematical structures in computer science 11(5):637–688, 2001. 19 / 20 volume 61 (2013) graph rewriting with contextual refinement [hof01] b. hoffmann. shapely hierarchical graph transformation. in proc. ieee symposia on human-centric computing languages and environments. pp. 30–37. ieee computer press, 2001. [hr10] a. habel, h. radke. expressiveness of graph conditions with variables. elect. comm. of the easst 30, 2010. international colloquium on graph and model transformation (gramot’10). [hu79] j. e. hopcroft, j. d. ullman. introduction to automata theory, languages and computation. addison-wesley, reading, massachusetts, 1979. [jak08] e. jakumeit. mit grgen zu den sternen. diplomarbeit (in german), universität karlsruhe, 2008. [löw93] m. löwe. algebraic approach to single-pushout graph transformation. theoretical computer science 109:181–224, 1993. [ph96] d. plump, a. habel. graph unification and matching. in cuny et al. (eds.), proc. graph grammars and their application to computer science. lecture notes in computer science 1073, pp. 75–89. springer, 1996. [plu93] d. plump. hypergraph rewriting: critical pairs and undecidability of confluence. in sleep et al. (eds.), term graph rewriting, theory and practice. pp. 201–213. wiley & sons, chichester, 1993. [ren04] a. rensink. the groove simulator: a tool for state space generation. in nagl et al. (eds.), applications of graph transformation with industrial relevance (agtive’03). lecture notes in computer science 3062, pp. 479–485. springer, 2004. [ter03] terese (ed.). term rewriting systems. cambridge tracts in theoretical computer science 55. cambridge university press, cambridge, uk, 2003. [vj03] n. van eetvelde, d. janssens. a hierarchical program representation for refactoring. electronic notes in theoretical computer science 82(7), 2003. selected revised papers from gcm 2012 20 / 20 introduction graphs, rewriting, and derivation schema refinement with contextual meta-rules relation to other ways of graph rewriting graph rewriting with node [dis-]connection substitutive graph rewriting existence of critical overlaps conclusions 20 years of triple graph grammars: a roadmap for future research electronic communications of the easst volume 73 (2016) graph computation models selected revised papers from gcm 2015 20 years of triple graph grammars: a roadmap for future research anthony anjorin, erhan leblebici and andy schürr 20 pages guest editors: detlef plump managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst 20 years of triple graph grammars: a roadmap for future research anthony anjorin1, erhan leblebici2 and andy schürr2 1anjorin@chalmers.se chalmers | university of gothenburg 2surname@tu-darmstadt.de technische universität darmstadt abstract: triple graph grammars (tggs) provide a declarative, rule-based means of specifying binary consistency relationships between different types of graphs. over the last 20 years, tggs have been applied successfully in a range of application scenarios including: model generation, conformance testing, bidirectional model transformation, and incremental model synchronisation. in this paper, we review the progress made in tgg research up until now by exploring multiple research dimensions, including both the current frontiers of tgg research as well as important future challenges. our aim is to provide a roadmap for the coming years of tgg research by stating clearly what we regard as adequately researched, and what we view as still unexplored potential. keywords: triple graph grammars, bidirectional model transformation, model synchronisation 1 introduction and motivation triple graph grammars (tggs) [sch94] provide a declarative, rule-based means of specifying binary consistency relationships between different types of graphs. over the last 20 years, tggs have been primarily used as a bidirectional model transformation language. models are encoded as graphs and model transformations, used to maintain the consistency of related pairs of models in a concurrent engineering scenario by propagating changes in both directions, are derived from a given tgg specification. bidirectional transformations (bx) are highly relevant in numerous domains [cfh+09], and multiple frameworks, approaches, and tools have been suggested for bx (cf. [ste08] for an overview). important application scenarios of bx include model synchronisation, round-tripping, and realising editable views [dwgc14]. as a bx approach, tggs enjoy both a solid formal foundation rooted in algebraic graph transformation [eept06], as well as rich and varied tool support (cf. [las+14b, hlg+13] for an overview). research on tggs has been fairly active in recent years, and results, foci, and challenges have shifted and developed considerably since the last visionary paper on tggs [sk08]. this paper provides essentially an update of [sk08], reviewing and reporting on results and progress after 20 years of tgg research. we extend the challenges posed in [sk08] to cover five dimensions, with most extensions strongly influenced by recent research in the field of bx in 1 / 20 volume 73 (2016) mailto:anjorin@chalmers.se mailto:surname@tu-darmstadt.de 20 years of triple graph grammars general. in each dimension we (i) review the relevant status quo, providing ample references to existing formalisations and implementations, and (ii) pose future challenges required to push the current frontiers of tgg research in what we believe are the most promising directions. the rest of the paper is structured as follows: section 2 provides a brief introduction to tggs with a running example taken from the bx example repository [cmsg14]. section 3 presents our main contribution as a radar chart of research dimensions, motivated and clarified informally using the running example. in section 4 we compare our contribution with other related “visionary” papers, and conclude in section 5 with a brief summary and outlook on future work. 2 running example and preliminaries a tgg specification consists of a tgg schema and a set of tgg rules. a tgg schema is a triple of source, correspondence, and target metamodels, which define the languages of models of the two domains (source and target) over which consistency is to be specified, as well as a language of explicit correspondence links that are created between related elements of source and target models. tggs are symmetric as the consistency relation is not in any way directed. referring to one domain as “source” and the other as “target” is, therefore, just a historic convention. the tgg schema for our running example, a variant of modeltests [ste] from the bx examples repository [cmsg14], is depicted in fig. 1. the source metamodel represents a simple language of class diagrams consisting of a hierarchy of diagrams (diagram), classes (class), and methods (method). all elements are named (string attribute name), and methods can be public or private (boolean attribute public). as multiplicities can only express simple constraints (diagrams/classes contain arbitrarily many classes/methods, and every class/method is connected to exactly one diagram/class), an additional constraint language is required to formulate more complex domain constraints. in this paper, we use so called graph conditions (cf., e.g., [rab+15]), which are less expressive than the object constraint language (ocl) but fit better in the general framework of algebraic graph transformation and consequently tggs (cf., e.g., [ast12]). two domain constraints, nc for negative constraint and pc for positive constraint, are used in the source metamodel to ensure that no two classes exist with the same name, and that every class has a public method, respectively. name:string diagram name:string testsuite name:string testclass d2ts name:string class public:boolean name:string method c2t m2t 1 0..* 1 0..* 1 0..*classes methods testclasses src src src trg trg trg c1:class c2:class c1.name == c2.name nc c:class c:class pc public == true m:method ) figure 1: tgg schema: source, correspondence, and target metamodels with domain constraints selected revised papers from gcm 2015 2 / 20 eceasst a negative constraint is a pattern n that must not exist in a valid model. a positive constraint is of the form p → c, where p and c are patterns representing the premise and conclusion of the constraint, respectively. if the premise can be found in a model then the conclusion, as an extension of the premise, must also hold. for formal definitions of graph conditions and multiplicities we refer to [tae12, rab+15]. to clearly differentiate patterns from (meta)models, patterns are placed in a light grey border that is tagged with the name of the pattern, and capital letters are used for the names of objects in patterns. where there is only one possible association between types, the name of the link is omitted to prevent diagram clutter (e.g., the link between c:class and m:method can only be of type methods and is thus omitted). patterns contain attribute conditions such as c1.name == c2.name in nc, or public == true in pc, where the latter condition is inlined in the object m:method. the target metamodel consists of test suites (testsuite) with test classes (testclass), while the correspondence metamodel provides types for “links” between source and target elements: diagrams correspond to test suites, classes and methods correspond to test classes. the consistency relation between class diagrams and test suites is specified informally in [ste], and we extend it by introducing an additional requirement concerning methods (condition 3 below). to fit in a tgg context, the conditions are additionally interpreted as requirements on the correspondence model between consistent source and target models: 1. for every diagram there exists a test suite with the same name. 2. for every class with name “foo”, there exists at least one test class called “testfoox” for some natural number x . 3. every public method of a class is associated with all test classes for the class. an example of a consistent triple of source, correspondence, and target models is depicted in fig. 2. the source model is a diagram with two classes, while the target model is a test suite with three test classes. note that every class has at least one public method (cf. source domain constraint pc), and every public method is connected to every test class for its containing class. name = "ordering" d:diagram name = "ordering" ts:testsuite name = "customer" c1:class name = "testcustomer0" t1:testclass public = true name = "placeorder" m1:method name = "order" c2:class name = "testcustomer1" t2:testclass public = true name = "load" m3:method public = true name = "save" m4:method name = "testorder0" t3:testclass public = false name = "init" m2:method figure 2: example consistent triple 3 / 20 volume 73 (2016) 20 years of triple graph grammars this is a model and not a pattern, so small letters are used for node names, and attribute values are depicted with a single equals sign, e.g., name = ordering. correspondence links are depicted as dashed bidirectional arrows with the assumption that they are of the correct type. an informal consistency specification can be formalised with a set of tgg rules that together generate the language of all consistent triples such as the triple depicted in fig. 2. two simple tgg rules r1 and r2 for the running example are depicted in fig. 3. a tgg rule consists of two patterns l → r, where l is the precondition and r, an extension of l, is the postcondition for applying the rule. elements in l are called context elements as they must be present to apply the rule, while elements in r\l are called created elements as they are created as a result of applying the rule. to represent rules, a compact concrete syntax is used, merging both patterns l and r into a single pattern by using colours and markup to distinguish elements: context elements are black, while created elements are green with an additional “++” markup. as with the types of links, this markup is only depicted when absolutely necessary, e.g., all links connected to a created object must be also created and do not have any explicit markup. the rule r1 (to the left of fig. 3) creates a consistent pair of a diagram and a test suite, demanding that they have the same name via the simple attribute condition d.name == ts.name. rules such as r1 are referred to as island rules [alk+15] as they do not require context and are thus always applicable, resulting in an “island” that is not connected to anything else. the rule r2 (to the right of fig. 3) demands a consistent pair of a diagram and a test suite, and extends this pair by creating a class and a test class. a simple attribute condition is used to demand that the name of the test class be formed by adding the suffix “0” to the name of the class. such rules are called extension rules [alk+15] as they create elements that are directly attached to existing context elements. with just these two tgg rules, a substantial part of the example triple in fig. 2 can already be created: r1 can be used to create d ↔ ts, r2 can be applied two times to create c1 ↔ t1, and c2 ↔ t3. all other elements require advanced tgg language features, which will be discussed in the following sections. d:diagram ts:testsuitel:d2ts ++++++ r1 c:class t:testclassl2:c2t ++++++ d:diagram ts:testsuitel1:d2ts c.name + "0" == t.name r2 d.name == ts.name figure 3: basic tgg rules for running example 3 research dimensions research on tggs can be viewed in a hyperspace spanned by five dimensions each representing the progress in a certain direction, going from basic to advanced. every “point” in this hyperspace is thus a specific combination of five properties taken from these dimensions, and can be represented as a trace through a radar chart as depicted in fig. 4. the points depicted in fig. 4 represent the state of tgg research in 1995 (as presented in the first paper on tggs [sch94]), the current state as of 2015, and our vision for the future. selected revised papers from gcm 2015 4 / 20 eceasst concurrency expressiveness reliability tolerance scalability multi-domain integration synchronization batch nacs complex attribute conditions multi-amalgamation pacs transformation correctness transformation completeness domain correctness domain completeness consistent model, consistent delta consistent model, inconsistent delta inconsistent model, inconsistent delta exponential in model size polynomial in model size polynomial in delta size simultaneous complex conditions least change/surprise 1995: 2015: ??? : figure 4: overview of tgg research dimensions a brief overview of all research dimensions is provided in the following, before the five dimensions are discussed in detail in corresponding sections 3.1 – 3.5. expressiveness, defined in this paper as the class of consistency relations that can be expressed with a set of tgg language features, is a crucial dimension as increasing expressiveness is important for the practical applicability of tggs, i.e., capturing real-world consistency relations as precisely as possible. the expressiveness dimension in fig. 4 lists tgg language features that have been discussed in existing literature. as we shall see in section 3.1, our relatively simple running example already requires negative application conditions (nacs), complex attribute conditions, and even multi-amalgamation. the concurrency dimension represents the various operational scenarios in which tggs can be used. the main idea is to induce a high-level consistency relation with the tgg as follows: a pair of source and target models are consistent, if they can be generated as part of a triple using the rules of the tgg. this specification is then adjusted appropriately (operationalised) so it can be used to accomplish different tasks. typical operational scenarios are discussed in section 3.2. to ensure the practical applicability of tggs, scalability is important so that real-world models of realistic size can be handled appropriately. scalability with respect to relevant factors (model size, size of changes to be propagated) is discussed in section 3.3. the reliability dimension comprises desirable formal properties that can be guaranteed for the different tgg-based operational scenarios. in section 3.4, we discuss the most established properties in this dimension, and give references to different existing formalisations. 5 / 20 volume 73 (2016) 20 years of triple graph grammars the focus up until now in tgg research has been primarily on building fully automated transformations that guarantee consistent output for consistent input, i.e., all formal properties (cf. reliability dimension) are typically only guaranteed for consistent input. as argued by stevens in [ste14], however, models might never be fully consistent in practice, with engineers working concurrently and using tool support to improve (but not necessarily enforce!) consistency at regular steps. related challenges for tgg research are discussed in section 3.5. 3.1 expressiveness negative application conditions (nacs): consider our running example and the tgg consisting of the schema depicted in fig. 1 and tgg rules r1 and r2 (fig. 3). apart from not yet being able to fully create the example triple depicted in fig. 2, r2 can be applied multiple times to create classes with the same name. this violates the negative source domain constraint nc (fig. 1) and should be prevented. nacs are a well-known feature from graph transformation used to control rule applicability, and have been studied extensively in the context of tggs [ehs09, geh11, hego10, klks10, ast12]. r2 can be extended with a nac that forbids the presence of a class with the same name as the class to be created. such an extension is depicted in fig. 5 as r2’. negative elements are depicted as “crossed out” and extend the precondition of the rule, blocking rule application if they can be found in a model. transferring nacs to tggs is, however, not as straightforward as it might seem. in contrast to normal graph transformation, the set of tgg rules is typically used as a high-level specification of consistency to derive operational transformations (cf. the concurrency dimension) and it is challenging to extend the various operationalisations to take nacs into account. most approaches restrict the usage of nacs in some way or the other, e.g., to source and target nacs consisting of only source or target elements, respectively. depending on the tgg approach, nacs can also have an adverse effect on scalability and, e.g., [ast12] restricts the usage of nacs to only enforcing negative domain constraints as in r2’. indeed, some approaches with a primary focus on scalability have explicitly chosen not to provide any support for nacs, e.g., [ghl14]. nacs are, nevertheless, an important and useful tgg language feature and the current support for nacs can still be improved especially regarding lifting current restrictions. c:class t:testclassl2:c2t ++++++ d:diagram ts:testsuitel1:d2ts c.name == name t.name == name + "0" r2' c':class c'.name == name figure 5: using a nac to control rule application selected revised papers from gcm 2015 6 / 20 eceasst complex attribute conditions: in any practical application, specifying the consistency of attribute values cannot be avoided. as algebraic graph transformation is generally more suitable for specifying structural rather than attribute-related relationships [ren10], integrating a flexible handling of complex attribute conditions in tggs has been a long standing challenge. some of the difficulties involved are discussed in [kw07, lhgo12]. allowing arbitrary ocl constraints in tgg rules [krw04] certainly increases expressiveness, but also makes it harder (perhaps impossible) to guarantee any formal properties (cf. reliability dimension). another approach is to use the attribute constraints in tgg rules as an “interface”, i.e., only to check the conformance of manually implemented operationalisations (e.g., in ocl or plain java) [ghl14]. a further approach is to integrate black-box constraints in tgg rules, guaranteeing that such atomic constraints can be mixed and combined as required to formulate complex constraints in each rule [avs12]. this allows for both user-defined, problemspecific constraints (implemented in, e.g., java) as well as a supplied set of library constraints. to handle our running example, a constraint adduniqueindex(classname, testclassname) can be implemented as a user-defined constraint and used in a tgg rule that creates a new test class for an existing class. this is depicted as rule r3 to the left of fig. 6 (ignore r4 for the moment). depending on the operationalisation, the constraint implementation might have to deal with (i) deciding if a given class name and test class name are consistent, (ii) deriving a consistent test class name from a given class name by post-pending a unique index, (iii) deriving a consistent class name from a given test class name by simply stripping off the index, and finally (iv) generating consistent pairs of class names and test class names. depending on how a constraint is combined with other constraints, however, note that not all possible cases must be supported. the “feasibility” of a combination of constraints can be checked at runtime when operationalising the rules [avs12]. support for complex attribute conditions in tgg rules is now supported in most tgg tools to a certain extent, but again this can still be improved, especially regarding corresponding formal analysis techniques (cf. reliability dimension), which often do not take attribute values and conditions into account (cf. [dv14] for a discussion and ongoing work on this). c:class t:testclassl2:c2t ++++ d:diagram ts:testsuitel1:d2ts adduniqueindex(c.name, t.name) c:class t:testclassl2:c2t public == true m:method ++++ l3:m2t ++ r3 r4 figure 6: rules for adding additional test classes multi-amalgamation: considering our running example and the triple depicted in fig. 2, we can now create all test classes with appropriate attribute values using r3. whenever an additional test case is created, however, a correspondence link is supposed to be created to all 7 / 20 volume 73 (2016) 20 years of triple graph grammars public methods of the class. as c1 only has a single method m1, creating the correspondence link m1 ↔ t2 could be accomplished by extending r3 and adding an additional rule for this case. in the case of c2 that has two public methods, however, two links m3 ↔ t3 and m4 ↔ t3 have to be created meaning that a further extension of r3 is again required. this will not work in general as classes can have arbitrarily many public methods. a solution to the problem of establishing 1-to-m relations in a single rule application is provided by multi-amalgamation [bfh87, geh10], a well-known language feature from graph transformation. progress on transferring multi-amalgamation to tggs has been made [last15, las15] and the so-called multi-rule r4 depicted in fig. 6 can be used to handle the creation of correspondence links to existing public methods. the main idea is to generalise tgg rules to interaction schemes, which consist of a kernel rule that is applied once, and a number of multi-rules (denoted in the concrete syntax with a double border and an incoming arrow from the kernel rule) that are applied as often as possible in such a manner that all applications agree with the kernel application. in this case, the kernel is r3, which is applied to create a new test class for an existing class, while r4 is the multi-rule that is applied as often as possible (creating a correspondence link to every existing public method of the class). multi-rules contain and extend the entire kernel, but only necessary elements, emphasised with a grey background, need to be specified in the concrete syntax. to complete our running example, we still have to add rules that create methods and connect them to their classes. interestingly, this also requires multi-amalgamation as a newly added public method must be connected to all existing test classes. figure 7 depicts an interaction scheme consisting of kernel r5 to add a new public method, and multi-rule r6 to create correspondence links to all existing test classes. finally, a so-called ignore rule r7 [alk+15] is used to specify that adding private methods does not affect the target or correspondence models in any way. support for multi-amalgamation is still work in progress and requires further research, especially regarding the development of the fundamental theory and related static analyses [tg15]. public := true m:method c:class c:class t:testclassl:c2t l1:m2t ++ r5 r6 ++ ++ public := true m:method public := false m:method c:class r7 ++ figure 7: rules for adding methods positive and complex application conditions: the final two points on the expressiveness axis can be viewed as challenges for future tgg research. positive application conditions (pacs) generalise nacs and are required in tgg rules, e.g., to ensure that positive constraints such as pc (fig. 1) are not violated. as nacs can only ensure upper bounds of multiplicities, pacs are also required to ensure lower bounds. pacs can be further generalised to complex application conditions, providing support for nesting of conditions. this has been shown to be selected revised papers from gcm 2015 8 / 20 eceasst equivalent to first order logic and covers a useful subset of ocl [rab+15]. although complex application conditions have been integrated into tggs in [geh11], this is only a first step in the direction as the operationalisation of such tgg rules and corresponding algorithms for the various application scenarios (cf. concurrency dimension) are not discussed. 3.2 concurrency simultaneous creation of consistent triples: this might seem surprising but applying tgg rules directly as specified can already be useful. this “simultaneous” creation of triples can, for example, be used to implement a syntax directed visual modelling tool with separate models for concrete syntax and semantic interpretation [lgb07]. in this case, the tgg models the synchronised evolution of both models in parallel. another application for the simultaneous creation of triples is for test generation [was14, hlg+11]. the idea here is to view the tgg as a high-level specification of correctness, i.e., a “test model” for a transformation that can be implemented manually in any language of choice. even though such a transformation could be automatically derived from the tgg, in some cases it still makes sense to do this manually: (i) the tgg tool in use does not support the target platform, (ii) extra possibly problem-specific optimisations are necessary for efficiency reasons, or (iii) the tgg is incomplete in the sense that only certain (very important) aspects of the transformation are modelled and are to be tested. supporting the simultaneous creation of triples is straightforward but, as is often the case, the devil is in the details. challenges include supporting nacs efficiently, implementing complex attribute conditions as high-quality attribute value generators, and guiding the generation process to produce “balanced” or realistic models with respect to the concrete task or domain. some of these challenges are discussed in [was14]. batch transformations: a considerable amount of work has been invested in supporting batch forward and backward transformations, which are derived automatically from a tgg. the main idea is to derive a forward transformation fwd that is able to extend an existing source model to a complete triple, i.e., appending a consistent correspondence and target model. this is depicted for our running example in fig. 8 and applies analogously to a backward transformation bwd. these operational scenarios are referred to as “batch” transformations as the output is created from scratch, and the entire input is processed afresh, independent of former results. name = "ordering" d:diagram name = "customer" c1:class public = true name = "placeorder" m1:method name = "ordering" d:diagram name = "ordering" ts:testsuite name = "customer" c1:class name = "testcustomer0" t1:testclass public = true name = "placeorder" m1:method fwd figure 8: a batch forward transformation 9 / 20 volume 73 (2016) 20 years of triple graph grammars there exist theoretical results characterising precisely when a tgg can be operationalised to yield forward and backward transformations, and when given forward and backward transformations conform to a tgg [eee+07]. this is particularly important when considering or introducing new language features as it might no longer be possible to derive a forward/backward transformation that retains the semantics of the tgg, i.e., conforms to the tgg. different approaches can be used to derive forward and backward transformations, ranging from fully interpretative approaches [krw04], to “compiling” the tgg to yield a set of “forward” graph transformation rules that can be directly executed to realise the forward transformation [eh12]. most approaches take a mixed approach, deriving forward/backward rules and controlling their application with an underlying tgg control algorithm [ghl14, las14a]. a comparison of tgg approaches with a focus on batch transformations is provided in [hlg+13]. batch transformations are certainly relevant and useful in practise [hgn+13], but it is difficult to argue why tggs are better than a straightforward combination of unidirectional model transformation languages. arguments do include increased productivity and consistency by construction, but these can be guaranteed for a combination of separate unidirectional approaches, effectively “faking” bidirectionality [pdpr14] without a bx tool. indeed, batch forward and backward transformation might not be a very convincing primary application scenario for tggs, especially as unidirectional approaches are often more efficient [las14a]. model synchronisation: the true potential of tggs lies more in realising incrementally working synchronisation tools, already mentioned as future work in the first paper on tggs [sch94]. a forward model synchroniser syncf takes a triple and a change to the source model ∆s (referred to as a source delta) as input, and produces a consistent output triple by manipulating the existing correspondence and target models. this means that ∆s is propagated to yield corresponding ∆c and ∆t in a manner that conforms to the underlying tgg. this is depicted schematically in fig. 9 for our running example (analogously for backward model synchronisers). note that ∆s consists of an attribute change (c1.name is changed from client to customer), an addition of an object (method m1), and a link (connecting c1 to m1). the challenge here is to work incrementally, taking the entire input triple into account and only changing what is necessary. this is indicated in fig. 9 by greying out unaffected parts. model synchronisation is a generalisation of the batch case as batch transformations correspond to the empty triple as input, and creating an entire source or target model as the source/target delta to be propagated. model synchronisation cannot be “faked” so easily by combining unidirectional transformations, as it is impossible to avoid information loss in general without accessing the old state of the models involved. in our example, applying a batch forward transformation to the source model in fig. 9 would result in the same triple depicted in fig. 8, i.e., test class t2 would not be created. the reason here is that it is impossible to know how many additional test classes to create for each class in the source model, solely by inspecting the source model. building well-behaved incremental synchronisation tools is challenging, and establishing a theoretical foundation for this task is a current focus of the bx community [cfh+09, ste08]. practical scenarios that require synchronisation are often “symmetric” in the sense that both domains contain data that is irrelevant for consistency but must not be discarded in the synchronisation process [dwgc14]. tgg-based formal synchronisation frameworks (e.g., [heo+11]), selected revised papers from gcm 2015 10 / 20 eceasst name = "ordering" d:diagram name = "ordering" ts:testsuite name = "client" c1:class name = "testclient0" t1:testclass name = "testclient1" t2:testclass name = "ordering" d:diagram name = "ordering" ts:testsuite name = "customer" c1:class name = "testcustomer0" t1:testclass name = "testcustomer1" t2:testclass �s public = true name = "placeorder" m1:method �t �c syncf figure 9: a forward synchronisation as well as multiple implementations (cf. [las+14b] for a comparison) exist. the different approaches apply various strategies and pose certain restrictions to make a compromise between efficiency, being as incremental as possible, and guaranteeing well-behavedness. improving the existing support for model synchronisation is a current focus of tgg research. model integration: model synchronisation can be further generalised to model integration, where the task is not just to propagate a source or target delta, but to consolidate a given pair of source and target deltas applied independently to the same triple of models. model integration is required to support concurrent engineering activities, where engineers work for a “sprint” in parallel on multiple models and then restore consistency at given points in time (cf. [anj14, rlss11]). model integration thus requires some form of conflict detection and resolution as the pair of source and target deltas cannot be expected to be consistent in any sense. existing frameworks for model integration all follow the straightforward idea presented by [xsht13] of combining forward and backward model synchronisers with a model merge: source and target deltas are propagated to the respective other side so they can be merged with the changes applied directly there. the tgg-based model integration framework of [heeo12] combines this idea with existing theory of conflict detection and resolution provided by [eet11]. these “propagation based” frameworks for model integration are far from ideal (see [obe+13] for a comparison and discussion) and share the common problem of treating the forward and backward synchronisation steps in a black-box manner, i.e., not being to control them for optimal conflict avoidance. a more “bidirectional” approach is suggested by [obe+13] as a possible improvement. the tgg-based frameworks are also all currently only theoretical and are yet to be implemented and practically evaluated with respect to, e.g., scalability and expressiveness. 11 / 20 volume 73 (2016) 20 years of triple graph grammars model integration can be seen as the application scenario for bx in general and tggs in particular. it is relatively easy to argue the added value of a bx language with direct support for model integration, as opposed to somehow combining unidirectional transformation languages. model integration is, therefore, a promising current and future focus of tgg research. multi-domain tggs: in practice, even though some cases might involve only two related models, supporting concurrent engineering activities in general will involve maintaining the consistency of a whole set of related models. the bx community is currently only considering the simplified case of handling a pair of related models, not because this is all that is required, but simply because this simplifies the problem, which is already complex enough. nonetheless, [ks06, ta15] have already shown that at least the basic theory for tggs can be extended elegantly from triples to arbitrarily connected networks of models. all tgg tools we are aware of, however, still consider multi-domain tggs to be currently out-of-scope. 3.3 scalability an advantage of tggs compared to, e.g., constraint solver-based solutions is the potential to scale better. this is due to the considerable experience in the graph transformation community with developing scalable graph pattern matching engines, which have been successfully leveraged for tggs [las+14b, hlg+13]. the underlying problem of “graph parsing”, however, remains difficult and naı̈ve solutions can easily explode exponentially, even for tggs with only a few rules, and moderate model sizes. in practice, therefore, the class of supported tggs is typically restricted in some suitable way to guarantee scalability [alst14, hego10, klks10]. there are two relevant factors when discussing scalability of tgg-based tools: (i) the average size (number of elements) of (rule) patterns k, and (ii) the size (number of elements) of involved models n. to be useful in practice, current tgg tools make a tradeoff between expressiveness (e.g., restricting the usage of nacs) and scalability, ensuring at least polynomial runtime in model size, i.e., at most o(nk). the challenge for future work is to completely decouple synchronisation/integration time from model size, i.e., to scale polynomially with respect to the number of elements changed n′, where n′ is normally much smaller than n. approaches such as [jks06, ards14, ghl14] have shown that this can be attained if the set of supported tggs is severely restricted. further relaxing these restrictions and still scaling with respect to delta size (perhaps at least in most “important” cases) is ongoing and future work. 3.4 reliability to simplify the following discussion, models will denoted by gx (g for graph), where x ∈ {s,c,t} represents the domain (source, correspondence, or target) of the model. triples of models are consequently denoted by gs ← gc → gt . the rules of a tgg generate a language of consistent triples, denoted by l (t gg). with this notation, we can now formulate tgg-based consistency succinctly as: gs,gt are consistent ⇔∃ gs ← gc → gt ∈ l (t gg). selected revised papers from gcm 2015 12 / 20 eceasst transformation correctness and completeness: let us refer to one of the operationalisations on the concurrency axis as a transformation τ . a fundamental requirement is that such a derived transformation τ conform to its underlying tgg: a transformation τ is transformation correct if it produces consistent triples only. this is formalised differently depending on the exact operationalisation: for batch transformations cf. [klks10, sk08, eee+07], for model synchronisation [heo+11, lavs12], and for model integration [heeo12, obe+13]. considering our running example, transformation correctness guarantees that the result of executing a synchronisation (fig. 9) will always be a triple that could also be created from scratch by applying the rules of the tgg (fig. 3, 6, 7). a related and equally desired property of transformations is totality, i.e., demanding that the domain of a transformation τ be precisely stated and that τ be total on its set of valid inputs: τ is transformation complete if it is total on a precisely defined set of valid inputs. although not demanded explicitly, “precisely defined” often means a set of conditions that can be checked at design time via static analysis techniques. the practical relevance of transformation completeness is that when an implementation throws an exception, this can only mean that the input was invalid (and this can possibly be ruled out with a corresponding static analysis). once again, transformation completeness is formalised differently depending on the operational scenario: for batch transformations cf. [klks10, sk08, eee+07], and for model synchronisation [heo+11, lavs12]. for our running example, transformation completeness guarantees that any source delta that leads to a source model, which is part of a consistent triple, can be forward synchronised (fig. 9). note that the concept of transformation completeness does not seem to make sense in the more general context of model integration, where a host of properties have been suggested to formulate reasonable expectations on the conflict detection and resolution process instead [heeo12, obe+13]. indeed, capturing an analogous completeness property for model integration can be viewed as work in progress. domain correctness and completeness: when working with models and metamodels, the rules of a tgg are not the sole source of consistency. the domains of the source and target models also comprise “domain” constraints, which should not be violated by valid or domain consistent models. according to [eept06], a triple of metamodels can be formalised as a type triple graph t g together with a set c of domain constraints. in analogy to l (t gg), l (t g) denotes the set of all well-typed triples, while l (t g,c ) denotes the set of all domain consistent triples that are well-typed and additionally do not violate any domain constraints from a given set of constraints c . given these independent sources of consistency requirements, l (t gg) and l (t g,c ), the following two properties are used to demand the “compatibility” of a tgg with its domains: a tgg is domain correct if: g ∈ l (t gg)⇒ g ∈ l (t g,c ). this means that transformation correctness is sufficient for domain consistency. domain completeness requires that transformation correctness also be necessary for domain consistency in both the source and target domains. to express this for the source domain (applies analogously 13 / 20 volume 73 (2016) 20 years of triple graph grammars to the target domain), let l (t gs,cs) denote the set of all source domain consistent models, i.e., well-typed and valid source models according to the source type graph t gs and given set of source domain constraints cs: a tgg is source domain complete if: gs ∈ l (t gs,cs)⇒∃ gs ← gc → gt ∈ l (t gg). a static analysis technique for ensuring domain correctness given a tgg and a set of domain constraints is presented in [ast12], while initial results on analysing domain completeness is given by [ehsb13]. in both cases, an extension to advanced language features (cf. expressiveness dimension), an implementation, and integration in a tgg tool is still work in progress. the tgg for our running example is not domain correct, as it can create classes without any public methods using r2’ (fig. 5). the analysis of [ast12] would identify this violation, and even suggest extending r2’ to create a public method together with every new class c. the tgg is also not domain complete, as numerous target domain constraints are missing, e.g., to ensure that the names of test classes are unique and can actually be generated by the tgg. the practical relevance of domain correctness is to ensure that tgg-based tools take domain constraints adequately into account. a check for domain completeness can be used to indicate that certain domain consistent models cannot yet be generated by the tgg. this is often unwanted as it points to implicit domain constraints. in certain operational scenarios, domain completeness can also be exploited as a means of checking for input validity: for a batch forward transformation that is both transformation complete and domain complete, a source model is valid input if it is source domain consistent. least change, least surprise: especially relevant in the general case of model integration, the formal property of least change or least surprise is meant to capture the perceived quality of the synchronisation / integration process. transformation correctness is only a very basic requirement and does not pose any restrictions on how consistency is restored. for instance, based solely on transformation correctness, i.e., ignoring runtime, there are tggs for which it is impossible to distinguish a forward synchroniser that simply deletes all correspondence / target elements and always performs a batch forward transformation, from a forward synchroniser that works incrementally and only performs minimal changes. compare the case of our running example depicted in fig. 8 and fig. 9: retaining test class t2 during synchronisation is obviously desirable (fig. 9), yet there is nothing stating formally that this is better than the result in fig. 8! the intuition here is to prefer synchronisers that restore consistency by “changing as little as possible”. this turns out, however, to be challenging to formalise and is a current focus of bx research. amongst other factors, the “best behaviour” of a synchroniser is not necessarily directly connected to the “size” of the changes applied according to, e.g., some form of metric, but might be more related to being as predictable as possible, i.e., causing least surprise as opposed to afflicting least change. the interested reader is referred to [cgms15] for a detailed overview of related work in this context as well as a discussion of challenges. in some (simple) cases, the round-tripping laws of the delta lens framework [dis08], often capture desirable behaviour better than transformation correctness. first steps at comparing the lens laws with tggs have been taken by [heo+11], but only for the simplified case of tggs with functional behaviour, i.e., rule r3 in our running example would not be allowed as it can be applied arbitrarily often, leading to the discrepancy between batch (fig. 8) and sync (fig. 9). selected revised papers from gcm 2015 14 / 20 eceasst 3.5 tolerance the current trend, especially for model integration, is towards tools that tolerate or better yet embrace inconsistencies [ste14]. as indicated in the tolerance dimension (fig. 4), a first step in this direction could involve accepting inconsistent deltas but ensuring that the resulting triple is always consistent. in many cases, however, this might not be what is wanted at all. it might actually be better for a tool to only improve the situation if possible, and not enforce full consistency (which could mean deleting everything in an extreme case) [ste14]. for bx tools to be of any use in practice, a fine grained notion of consistency should be supported, i.e., not consistent or inconsistent, but providing something akin to a “lattice” of consistency, together with formal guarantees to ensure that the bx tool either improves the situation with respect to consistency, or does nothing. the argument is that in practice, models might never be fully consistent, with engineers working constantly and concurrently on them [ste14, cgms15]. this is a completely new challenge for tgg research, as all formal results are currently based on a fully consistent starting point. it is still unclear how to provide a fine grained notion of consistency for tggs and how best to integrate a concept of “tolerance” in the current formal framework. in combination with model integration, providing support for tolerance is perhaps the primary future challenge that tgg research must address. 4 related work the goals and scope of the bx community are outlined in [cfh+09]. a survey of bx approaches is provided by [ste08], while a more recent feature-based bx taxonomy is given by [htch15]. a complementary classification of bx scenarios is presented in [dwgc14]. while all these papers present and classify research in bx, giving a vision in some cases, e.g., support for increasingly symmetric bx scenarios in [dwgc14], our paper focusses solely on tgg research, and is thus able to discuss tgg-specific issues and challenges in more detail. a proposal and vision for a repository of bx examples is presented in [cmsg14]. the bx repository has since then been established and is now a source for a growing number of bx examples, including numerous tgg specifications. while [cmsg14] does not explicitly discuss tggs, the repository serves as a source for examples that cannot or can only partially be specified using tggs, motivating new language features, application scenarios, and formal properties. visionary papers in the context of bx such as [ste14] on tolerance, and [cgms15] on the principle of least change / surprise, have had a substantial influence on tgg research. in this paper, we have discussed these challenges for tggs, stating relevant current and future work. there are currently two tgg tool comparison papers: [hlg+13] for general aspects, and [las+14b] to focus primarily on support for model synchronisation. this paper complements these practical and often technical, tool-specific comparisons, by providing a more general discussion and a vision for future tgg research. this paper can be seen as a continuation of [sch94], already with a vision for “incrementally working translators”, and [sk08], summarising 15 years of tggs and focussing on challenges concerning mainly tgg-based batch transformations. in contrast to [sk08], we have chosen to distinguish two different kinds of correctness/completeness: transformation correctness/completeness and domain correctness/completeness. we have also posed, for the first time 15 / 20 volume 73 (2016) 20 years of triple graph grammars for tggs, challenges concerning tolerance and least change/surprise, both currently areas of active research in the bx community. finally, we have identified model integration, considered clearly out-of-scope in [sk08, sch94], as a primary focus for future tgg research. 5 summary and conclusion in this paper, we have given an overview of the current state-of-the-art in tgg research, organising the different directions in five research dimensions with past, current, and future challenges. as a conclusion, we believe that the primary potential of tggs in the years to come lies in realising tolerant, scalable, and reliable tools for model integration. some practical but equally important points we did not have space to discuss include: extending the current support for the modularity of tgg specifications [gr12, kks07, asls14], establishing debugging frameworks, providing ample documentation (handbooks, examples, tutorials), and improving tool support in general. some of these issues are discussed in our tgg tool comparison papers [las+14b, hlg+13]. bibliography [alk+15] a. anjorin, e. leblebici, r. kluge, a. schürr, p. stevens. a systematic approach and guidelines to developing a triple graph grammar. in cunha and kindler (eds.), bx 2015. ceur workshop proceedings 1396, pp. 81–95. ceur-ws.org, 2015. [alst14] a. anjorin, e. leblebici, a. schürr, g. taentzer. a static analysis of nonconfluent triple graph grammars for efficient model transformation. in giese and könig (eds.), icgt 2014. lncs 8571, pp. 130–145. springer, 2014. [anj14] a. anjorin. synchronization of models on different abstraction levels using triple graph grammars. phd thesis, technische universität darmstadt, 2014. [ards14] a. anjorin, s. rose, f. deckwerth, a. schürr. efficient model synchronization with view triple graph grammars. in cabot and rubin (eds.), ecmfa 2014. lncs 8569, pp. 1–17. springer, 2014. [asls14] a. anjorin, k. saller, m. lochau, a. schürr. modularizing triple graph grammars using rule refinement. in gnesi and rensink (eds.), fase 2014. lncs 8411, pp. 340–354. springer, 2014. [ast12] a. anjorin, a. schürr, g. taentzer. construction of integrity preserving triple graph grammars. in ehrig et al. (eds.), icgt 2012. lncs 7562, pp. 356–370. springer, 2012. [avs12] a. anjorin, g. varró, a. schürr. complex attribute manipulation in tggs with constraint-based programming techniques. in hermann and voigtländer (eds.), bx 2012. eceasst 49, pp. 1–16. easst, 2012. selected revised papers from gcm 2015 16 / 20 eceasst [bfh87] p. boehm, h.-r. fonio, a. habel. amalgamation of graph transformations: a synchronization mechanism. jcss 34(2-3):377–408, 1987. [cfh+09] k. czarnecki, j. n. foster, z. hu, r. lämmel, a. schürr, j. terwilliger. bidirectional transformations: a cross-discipline perspective. in paige (ed.), icmt 2009. lncs 5563, pp. 260–283. springer, 2009. [cgms15] j. cheney, j. gibbons, j. mckinna, p. stevens. towards a principle of least surprise for bidirectional transformations. in cunha and kindler (eds.), bx 2015. ceur workshop proceedings 1396, pp. 66–80. ceur-ws.org, 2015. [cmsg14] j. cheney, j. mckinna, p. stevens, j. gibbons. towards a repository of bx examples. in candan et al. (eds.), proceedings of the workshops of edbt/icdt 2014. ceur workshop proceedings 1133, pp. 87–91. ceur-ws.org, 2014. [dis08] z. diskin. algebraic models for bidirectional model synchronization. in czarnecki et al. (eds.), models 2008. lncs 5301, pp. 21–36. springer, 2008. [dv14] f. deckwerth, g. varró. attribute handling for generating preconditions from graph constraints. in giese and könig (eds.), icgt 2014. lncs 8571, pp. 81– 96. springer, jul 2014. [dwgc14] z. diskin, a. wider, h. gholizadeh, k. czarnecki. towards a rational taxonomy for increasingly symmetric model synchronization. in ruscio and varró (eds.), icmt 2014. lncs 8568, pp. 57–73. springer, 2014. [eee+07] h. ehrig, k. ehrig, c. ermel, f. hermann, g. taentzer. information preserving bidirectional model transformations. in dwyer and lopes (eds.), fase 2007. lncs 4422, pp. 72–86. springer, 2007. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. monographs in theoretical computer science. an eatcs series. springer, 2006. [eet11] h. ehrig, c. ermel, g. taentzer. a formal resolution strategy for operation-based conflicts in model versioning using graph modifications. in giannakopoulou and orejas (eds.), fase 2011. lncs 6603, pp. 202–216. springer, 2011. [eh12] c. ermel, f. hermann. visual modeling and analysis of emf model transformations based on triple graph grammars. eceasst 54:1–12, 2012. [ehs09] h. ehrig, f. hermann, c. sartorius. completeness and correctness of model transformations based on triple graph grammars with negative application conditions. in boronat and heckel (eds.), gt-vmt 2009. eceasst 18. easst, 2009. [ehsb13] h. ehrig, f. hermann, h. schölzel, c. brandt. propagation of constraints along model transformations using triple graph grammars and borrowed context. vlc 24(5):365–388, 2013. 17 / 20 volume 73 (2016) 20 years of triple graph grammars [geh10] u. golas, h. ehrig, a. habel. multi-amalgamation in adhesive categories. in ehrig et al. (eds.), icgt 2010. lncs 6372, pp. 346–361. springer, 2010. [geh11] u. golas, h. ehrig, f. hermann. formal specification of model transformations by triple graph grammars with application conditions. in echahed et al. (eds.), gcm 2010. eceasst 39. asst, 2011. [ghl14] h. giese, s. hildebrandt, l. lambers. bridging the gap between formal semantics and implementation of triple graph grammars. sosym 13(1):273–299, 2014. [gr12] j. greenyer, j. rieke. applying advanced tgg concepts for a complex transformation of sequence diagram specifications to timed game automata. in schürr et al. (eds.), agtive 2011. lncs 7233, pp. 222 – 237. springer, 2012. [heeo12] f. hermann, h. ehrig, c. ermel, f. orejas. concurrent model synchronization with conflict resolution based on triple graph grammars. in lara and zisman (eds.), fase 12. lncs 7212, pp. 178–193. springer, 2012. [hego10] f. hermann, h. ehrig, u. golas, f. orejas. efficient analysis and execution of correct and complete model transformations based on triple graph grammars. in bézivin et al. (eds.), mdi 2010. mdi 2010 1866277, pp. 22–31. acm press, 2010. [heo+11] f. hermann, h. ehrig, f. orejas, k. czarnecki, z. diskin, y. xiong. correctness of model synchronization based on triple graph grammars. in whittle et al. (eds.), models 2011. lncs 6981, pp. 668–682. springer, 2011. [hgn+13] f. hermann, s. gottmann, n. nachtigall, b. braatz, g. morelli, a. pierre, t. engel. on an automated translation of satellite procedures using triple graph grammars. in duddy and kappel (eds.), icmt 2013. lncs 7909, pp. 50–51. springer, 2013. [hlg+11] s. hildebrandt, l. lambers, h. giese, d. petrick, i. richter. automatic conformance testing of optimized triple graph grammar implementations. in schürr et al. (eds.), agtive 2011. lncs 7233, pp. 238–253. springer, 2011. [hlg+13] s. hildebrandt, l. lambers, h. giese, j. rieke, j. greenyer, w. schäfer, m. lauder, a. anjorin, a. schürr. a survey of triple graph grammar tools. in stevens and terwilliger (eds.), bx 2013. eceasst 57. easst, 2013. [htch15] s. hidaka, m. tisi, j. cabot, z. hu. feature-based classification of bidirectional transformation approaches. sosym, pp. 1–22, 2015. [jks06] j. jakob, a. königs, a. schürr. non-materialized model view specification with triple graph grammars. in corradini et al. (eds.), icgt 2006. lncs 4178, pp. 321–335. springer, 2006. [kks07] f. klar, a. königs, a. schürr. model transformation in the large. in crnkovic and bertolino (eds.), fse 2007. pp. 285–294. acm, 2007. selected revised papers from gcm 2015 18 / 20 eceasst [klks10] f. klar, m. lauder, a. königs, a. schürr. extended triple graph grammars with efficient and compatible graph translators. in schürr et al. (eds.), festschrift nagl. lncs 5765, pp. 141–174. springer, 2010. [krw04] e. kindler, v. rubin, r. wagner. an adaptable tgg interpreter for in-memory model transformations. in schürr and zündorf (eds.), fujaba days 2014. pp. 35– 38. 2004. [ks06] a. königs, a. schürr. mdi: a rule-based multi-document and tool integration approach. sosym 5(4):349–368, 2006. [kw07] e. kindler, r. wagner. triple graph grammars: concepts, extensions, implementations, and application scenarios. technical report, software engineering group, department of computer science, university of paderborn, 2007. [las14a] e. leblebici, a. anjorin, a. schürr. developing emoflon with emoflon. in ruscio and varró (eds.), icmt 14. lncs 8568, pp. 138–145. springer, 2014. [las+14b] e. leblebici, a. anjorin, a. schürr, s. hildebrandt, j. rieke, j. greenyer. a comparison of incremental triple graph grammar tools. in hermann and sauer (eds.), gt-vmt 2014. eceasst 67. easst, 2014. [las15] e. leblebici, a. anjorin, a. schürr. tool support for multi-amalgamated triple graph grammars. in parisi-presicce and westfechtel (eds.), icgt 2015. lncs 9151, pp. 257–265. springer, 2015. [last15] e. leblebici, a. anjorin, a. schürr, g. taentzer. multi-amalgamated triple graph grammars. in parisi-presicce and westfechtel (eds.), icgt 2015. lncs 9151, pp. 87–103. springer, 2015. [lavs12] m. lauder, a. anjorin, g. varró, a. schürr. efficient model synchronization with precedence triple graph grammars. in ehrig et al. (eds.), icgt 2012. lncs 7562, pp. 401–415. springer, 2012. [lgb07] j. de lara, e. guerra, p. bottoni. triple patterns: compact specifications for the generation of operational triple graph grammar rules. eceasst 6, 2007. [lhgo12] l. lambers, s. hildebrandt, h. giese, f. orejas. attribute handling for bidirectional model transformations: the triple graph grammar case. eceasst 49, 2012. [obe+13] f. orejas, a. boronat, h. ehrig, f. hermann, h. sch. on propagation-based concurrent model synchronization. eceasst 57, 2013. [pdpr14] c. m. poskitt, m. dodds, r. f. paige, a. rensink. towards rigorously faking bidirectional model transformations. in dingel et al. (eds.), amt 2014. ceur workshop proceedings 1277, pp. 70–75. ceur-ws.org, 2014. 19 / 20 volume 73 (2016) 20 years of triple graph grammars [rab+15] h. radke, t. arendt, j. s. becker, a. habel, g. taentzer. translating essential ocl invariants to nested graph constraints focusing on set operations. in parisipresicce and westfechtel (eds.), icgt 2015. lncs 9151, pp. 155–170. springer, 2015. [ren10] a. rensink. the edge of graph transformation graphs for behavioural specification. in engels et al. (eds.), festschrift nagl. lncs 5765, pp. 6–32. springer, 2010. [rlss11] s. rose, m. lauder, m. schlereth, a. schürr. a multidimensional approach for concurrent model driven automation engineering. in osis and asnina (eds.), model-driven domain analysis and software development: architectures and functions. pp. 90–113. igi publishing, 2011. [sch94] a. schürr. specification of graph translators with triple graph grammars. in mayr et al. (eds.), wg 1994. lncs 903, pp. 151–163. springer, 1994. [sk08] a. schürr, f. klar. 15 years of triple graph grammars. in ehrig et al. (eds.), icgt 2008. lncs 5214, pp. 411–425. springer, 2008. [ste] p. stevens. modeltests v0.1 in bx examples repository. http://bx-community. wikidot.com/examples:home. [ste08] p. stevens. a landscape of bidirectional model transformations. in lämmel et al. (eds.), gttse 07. lncs 5235, pp. 408–424. springer, 2008. [ste14] p. stevens. bidirectionally tolerating inconsistency: partial transformations. in gnesi and rensink (eds.), fase 2014. lncs 8411, pp. 32–46. springer, 2014. [ta15] f. trollmann, s. albayrak. extending model to model transformation results from triple graph grammars to multiple models. in kolovos and wimmer (eds.), icmt 2015. lncs 9152, pp. 214–229. springer, 2015. [tae12] g. taentzer. instance generation from type graphs with arbitrary multiplicities. in fish and lambers (eds.), gt-vmt 2012. eceasst 47. easst, 2012. [tg15] g. taentzer, u. golas. towards local confluence analysis for amalgamated graph transformation. in icgt 2015. lncs 9151, pp. 69–86. springer, 2015. [was14] m. wieber, a. anjorin, a. schürr. on the usage of tggs for automated model transformation testing. in di ruscio and varró (eds.), icmt 2014. lncs 8568, pp. 1–16. springer, 2014. [xsht13] y. xiong, h. song, z. hu, m. takeichi. synchronizing concurrent model updates based on bidirectional transformation. sosym 12(1):89–104, 2013. selected revised papers from gcm 2015 20 / 20 http://bx-community.wikidot.com/examples:home http://bx-community.wikidot.com/examples:home introduction and motivation running example and preliminaries research dimensions expressiveness concurrency scalability reliability tolerance related work summary and conclusion an application layer protocol to support cooperative navigation of multiple uavs systems electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) an application layer protocol to support cooperative navigation of multiple uavs systems maik basso, alexey vinel and edison pignaton de freitas 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst an application layer protocol to support cooperative navigation of multiple uavs systems maik basso1, alexey vinel2 and edison pignaton de freitas2 1 maik@maikbasso.com.br 3 edison.pignaton@ufrgs.br federal university of rio grande do sul (ufrgs), brazil 2 alexey.vinel@hh.se halmstad university, sweden abstract: applications involving multiple uavs have gained increasing relevance in recent years, due to the benefits that cooperative systems tend to provide to their applications. in addition to performing several simultaneous tasks, the time spent to perform a certain task is reduced. in this article, an architecture for sharing navigation information is demonstrated to support applications composed of systems with multiple uavs. keywords: multiple uavs, data sharing, cooperative systems 1 introduction unmanned aerial vehicles (uavs) are vehicles that can operate with different degrees of autonomy and can be disposable or reusable [nkyb13]. its increasing popularity is related to the number of proposed applications that use sensor data, integrated into its mission control channel, to improve its navigation skills [amg+18, kn17]. cooperative systems, can perform missions in unstructured environments and achieve the mission objectives, with distributed computational cost and reduced time, benefiting from greater precision and efficiency, caused by their heterogeneous resources, in addition to better accessibility and robustness in the mission [zlz17]. for these autonomous cooperative navigation systems to work in completely unknown environments, it is of utmost importance that they can collect and store environment information efficiently so they can be used as a source of knowledge to create their trajectory during the mission which is destined to fulfill. these experiences are stored in the form of maps that need to be shared with group members of the cooperative system so they can integrate these experiences into a unique and more reliable knowledge base. a new approach to share this information is needed [vp20, ysy+18]. in the approach presented in this work, the maps are compressed and then shared with the members of the group that are within the range of communication. 1 / 4 volume 080 (2021) mailto:maik@maikbasso.com.br mailto:edison.pignaton@ufrgs.br mailto:alexey.vinel@hh.se an application layer protocol to support cooperative navigation of multiple uavs systems 2 approach overview the idea behind this work is to provide the information sharing infrastructure to support a cooperative navigation system composed of multiple uavs. figure 1 demonstrates the proposal’s architecture. in this system, data is collected by sensors and transformed into grid maps. these, in turn, are the only information shared among the other vehicles that compose the network. the shared information is used to incorporate local information and then give the vehicle a sense of the global experiences obtained by the group. figure 1: integrated architecture of the information data sharing system. the sharing of local maps is performed by the data sharing module (highlight in figure 1) whenever two or more vehicles are within the communication range. in this module, local data is collected, compressed, serialized, and divided into blocks of 256 bytes of size per message. after, the messages are sent to the other nodes in the network through tcp protocol under an exclusive communication channel composed of ieee 802.11ac modules. in this work, the shared data is composed of occupancy grid maps, stored in memory in one-dimensional structures (1d) using the row-major order indexing method. this storage method allows a compression technique to be applied to compress the maps before sharing. the proposed compression method is more simple than the conventional methods and takes into consideration the map data characteristics, consumes little computational resources, and it is suitable for embedded systems. an example of this technique is shown in figure 2. -1 -1 100 100 100 100 100 0 -1 -1 -1 -1 original map -1 -1 -2 100 5 0 -2 -1 4 compressed map a) d) a) a) uncompressed space b) compression identifier character a) b) c) b) c) d) c) repetition value d) number of occurrences figure 2: example of map compression algorithm. the used compression method identifies sequences with more than three repetitions and then netsys 2021 2 / 4 eceasst replaces the sequence with three elements that have the function of representing the sequence. the compression identifier element identifies that there is the beginning of a sequence (figure 2 b). the following elements (figure 2 c) identify the value contained in the cells of the sequence while the third element (figure 2 d) identifies the number of repetitions in the sequence. finally, the other elements (figure 2 a) were not susceptible to compression. 3 case study demonstration to evaluate the effectiveness of the proposal, a shared simulation environment was created using gazebo. this environment is shown in figure 3a and has an area of 16 m × 14 m. (a) experiments scenario. (b) merged robot information. figure 3: (a) case study simulation environment. (b) resulting merged map. in this simulation, two notebooks connected to the same network, running the same algorithm and simulation environment, but representing different uavs in different locations of the scenario. the uavs were manually piloted in each notebook using a joystick and the obtained local maps were shared using the approach proposed in this work. figure 4 shows in four different moments a timeline of the information shared between the vehicles. instant 1 instant 2 instant 3 instant 4 uav 0 uav 1 figure 4: timeline of information shared among uavs during the tests. after instant 4, shown in figure 4, the algorithm responsible for merging the shared information converged in each notebook, and the result is the map shown in figure 3b. then, each vehicle has its own complete representation of the information obtained by the group and can use it to improve its navigation process, avoiding visiting regions previously visited by other 3 / 4 volume 080 (2021) an application layer protocol to support cooperative navigation of multiple uavs systems vehicles, for instance. in summary, the global map is generated locally by each notebook and is available in both systems. 4 conclusion this work demonstrates a communication system used for information sharing to support cooperative navigation systems used in multiple uavs systems. this approach is under development and is part of the studies developed for a ph.d. thesis. this work presents the developed application architecture as well as the ideas and tools used for its development. based on a case study, the first results obtained in this stage of the project are presented. as demonstrated, the application fulfills its function within the proposed architecture, but to improve the approach, an algorithm is needed to optimize the routes of the messages, reducing the traffic of network information, particularly considering groups with large numbers of members. also, it is necessary to carry out tests with real vehicles so that it is possible to evaluate the influence of the vehicle mobility model on the transmission of data between them. acknowledgements: this work was supported in part by the knowledge foundation (kks) through the framework of safesmart “safety of connected intelligent vehicles in smart cities” synergy project (2019– 2023), in part by the swedish foundation for strategic research (ssf) through the framework of strategic mobility program (2019-2020), and in part by the elliit strategic research network. the authors also thank to capes-brazil finance code 001. bibliography [amg+18] a. al-kaff, d. martı́n, f. garcı́a, a. de la escalera, j. m. armingol. survey of computer vision algorithms and applications for unmanned aerial vehicles. expert systems with applications 92(supplement c):447 – 463, 2018. [kn17] c. kanellakis, g. nikolakopoulos. survey on computer vision for uavs: current developments and trends. j. of intellig. & robotic systems 87(1):141–168, jul 2017. [nkyb13] k. nonami, m. kartidjo, k. yoon, a. budiyono. autonomous control systems and vehicles. intelligent systems, control and automation: science and eng. 65, 2013. [vp20] c. a. velásquez hernández, f. a. prieto ortiz. a real-time map merging strategy for robust collaborative reconstruction of unknown environments. expert systems with applications 145:113109, 2020. [ysy+18] y. yue, p. g. c. n. senarathne, c. yang, j. zhang, m. wen, d. wang. hierarchical probabilistic fusion framework for matching and merging of 3-d occupancy maps. ieee sensors journal 18(21):8933–8949, 2018. [zlz17] w. zhao, r. li, h. zhang. finite-time distributed formation tracking control of multi-uavs with a time-varying reference trajectory. ima journal of mathematical control and information, p. dnx028, 2017. netsys 2021 4 / 4 introduction approach overview case study demonstration conclusion demonstration: a cloud-control system equipped with intrusion detection and mitigation electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) demonstration: a cloud-control system equipped with intrusion detection and mitigation fatemeh akbarian, william tärneberg, emma fitzgerald, and maria kihl 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrück, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst demonstration: a cloud-control system equipped with intrusion detection and mitigation fatemeh akbarian1, william tärneberg1, emma fitzgerald21, and maria kihl1 1 dept. of electrical and information technology at lund university, lund, sweden 2 institute of telecommunications, warsaw university of technology, poland abstract: the cloud control systems (ccs) are inseparable parts of industry 4.0. the cloud, by providing storage and computing resources, allows the controllers to evaluate complex problems that are too computationally demanding to perform locally. however, connecting physical systems to the cloud through the network can provide an entry point for attackers to infiltrate the system and cause damage with potentially catastrophic consequences. hence, in this paper, we present a demo of our proposed security framework for ccs and demonstrate how it can detect attacks on this system quickly and mitigate them. keywords: cloud control systems, intrusion detection, attack mitigation, test-bed, cyber security 1 introduction by adoption of new technologies, we have had several revolutions in industry and now some modern technologies like iot, cloud computing, etc are paving the way for smart factory that will realise industry 4.0. industrial control systems (ics) as part of industry 4.0 are becoming more efficient and smarter. however, these systems are also becoming more and more connected and part of a network systems and this communication link between different components of ics can provide an access point for attackers to intrude into the system and manipulate the signals that are sent through the network. for example, the attacker by manipulating measurement signals can deceive the controller to generate a wrong control signal that can make our system unstable and lead to catastrophic consequences like what we had in recent years. in recent years, we have had several attacks in different parts of industry that demonstrate ics are still prone to cyber attacks and highlight the necessity for an appropriate security measure to protect these systems. the cloud provides seemingly endless computing and storage resources that can be used to execute more advanced control strategies in ics. however, in cloud control systems (ccs), there is a network between the plant and the cloud that the measurement and control signals are sent through this network and this can make these systems vulnerable to cyber attacks. in this paper, we present a demo of our proposed security framework that is applied on ccs and include intrusion detection and mitigation. in this system, we have a ball and beam process as our plant, a kubernetes (k8s)-cluster that hosts an intrusion detection and the main controller, and a local controller that is part of our mitigation method and implemented using python code beside the plant. 1 / 4 volume 080 (2021) demonstration: a cloud-control system equipped with intrusion detection and mitigation (a) security framework overview. (b) test-bed overview. figure 1: an overview of the demo system. 2 secure cloud control systems demo in this section, we present our demo and explain how different parts of the test-bed are implemented. figure 1 shows an overview of our demo system. figure 1a shows our proposed security framework, and figure 1b shows the test-bed implementation. the system’s components are detailed below. 2.1 plant we use a ball and beam process as our plant. the ball and beam system consists of a long beam which can be tilted by an electric motor together with a ball rolling back and forth on top of the beam. this system is open-loop unstable and without a controller, it will swing to one side or the other, and the ball will fall off the end of the beam. our motivation for choosing the ball and beam system is that it is an intrinsically unstable and time-critical system such that any attack on this system can make it unstable quickly. so, evaluating our proposed security framework on this system can prove its effectiveness. 2.2 kubernetes cluster the test-bed has been equipped with a six-node kubernetes cluster as the edge cloud. kubernetes (k8s) 1 is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation . the cluster has been equipped with an nginx ingress 2 and prometheus operator 3 . the nginx ingress is exposed 1 https://kubernetes.io/ 2 https://github.com/kubernetes/ingress-nginx/ 3 https://github.com/coreos/prometheus-operator/ netsys 2021 2 / 4 https://kubernetes.io/ https://github.com/kubernetes/ingress-nginx/ https://github.com/coreos/prometheus-operator/ eceasst using the k8s nodeport paradigm. we use this k8s cluster to implement our main controller and intrusion detection algorithm. 2.3 main controller to stabilize the ball, we need a feedback controller that uses measurement signals to adjust the beam accordingly. a model predictive control (mpc)-based controller is designed based on [ståk20] as the main controller in figure 1. this controller for execution needs some computation resources that cloud can provide it. thus, we deploy this controller using python and container technology as a pod in the kubernetes cluster. 2.4 attack and intrusion detection all communication between the plant and the cloud is over a local area network (lan) and uses a protocol defined in protocol buffers (protobuf) 4 which is realized in grpc 5. measurement signals includes position of the ball, angle of the beam, and speed of the ball are sent through this network to the main controller in the cloud. the main controller using these generates the control signal and send it back to the plant. this control signal by adjusting the beam’s speed controls the position of the ball on the beam. we assume the attacker tries to manipulate the measured position signal, and we implement the attack by adding a ramp signal with small slope (between 0.001 to 0.05) to the position signal using python codes. we deploy our proposed intrusion detection in [atfk21] using python and container technology as a pod in the kubernetes cluster. this intrusion detection consists of two parts: residual generator and decision system. residual generator estimates the value of the measurement signal and then by comparing it with the real one generates a residual signal. in healthy condition during which there is no attack, the residual signal is close to zero. thus, the decision system evaluates the residual signal and by comparing it with a certain threshold decides if there is any attack in the system or not. if it detects any attack in the system, it will trigger an alarm signal. 2.5 attack mitigation method and ancillary controller our objective for mitigation is to keep the plant stable under the attack with an acceptable performance. as mitigation, we consider an ancillary controller that is placed close to the plant such that there is no public network between the plant and this controller so there is no possibility for the attacker to intrude into the system. measurement signals from the plant are sent to both main and local controller, but our priority is to use the control signal generated by the main controller that is more advanced controller. once the attack has been detected, and the alarm signal has beet triggered, we will switch to the ancillary controller. ancillary controller is implemented as a linear–quadratic regulator (lqr). we refer to [atfk21] for a full detail of the mitigation algorithm. lqr is a simpler controller than mpc and it requires little computational capacity, allowing it to be implemented in the physical domain. 4 https://developers.google.com/protocol-buffers/ 5 https://grpc.io/ 3 / 4 volume 080 (2021) https://developers.google.com/protocol-buffers/ https://grpc.io/ demonstration: a cloud-control system equipped with intrusion detection and mitigation (a) security framework overview. (b) test-bed overview. figure 2: results for ramp attack with slope=0.001. 3 experiments we design the attack based on section 2.4 and start applying it on the position signal at the 14500th sample. figure 2 shows effects of this attack on the system in the presence and absence of our security framework. as it is seen in figure 2a, our intrusion detection can detect this attack really fast and based on this detection, our mitigation will be activated quickly. so, as the blue line in figure 2b shows, the attack tries to deviate the ball from its setpoint, but by activating the mitigation part and switching to ancillary controller, we can move the ball back to its setpoint. otherwise, in the absence of mitigation method, as the red line shows, the attack will move the ball to the end of the beam and finally cause the ball to fall off. acknowledgements: this paper was supported by the celtic-next project 5g perfecta funded by vinnova, and the ssf project sec4factory under grant no. ssf rit17-0032. the authors are part of the excellence center at linköping-lund on information technology (elliit) strategic research area, and the nordic university hub on industrial iot (hi2ot) funded by nordforsk. maria kihl is partially funded by the wallenberg ai, autonomous systems and software program (wasp) funded by the knut and alice wallenberg foundation. the work of emma fitzgerald was supported by the national science centre, poland, under the grant no. 2019/35/d/st7/00350 “quality of service in iot applications using large scale antenna systems”. bibliography [atfk21] f. akbarian, w. tärneberg, e. fitzgerald, m. kihl. a security framework in digital twins for cloud-based industrial control systems: intrusion detection and mitigation. in 2021 ieee 26th international conference on emerging thecnologies and factory automation (etfa), in press. 2021. [ståk20] p. skarin, w. tärneberg, k.-e. årzén, m. kihl. control-over-the-cloud: a performance study for cloud-native, critical control systems. in 2020 ieee/acm 13th international conference on utility and cloud computing (ucc). pp. 57–66. 2020. netsys 2021 4 / 4 introduction secure cloud control systems demo plant kubernetes cluster main controller attack and intrusion detection attack mitigation method and ancillary controller experiments user space packet schedulers: towards rapid prototyping of queue-management algorithms electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) user space packet schedulers: towards rapid prototyping of queue-management algorithms ralf kundel, paul stiegele, dat tran, julian zobel, osama abboud, rhaban hark, ralf steinmetz 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst user space packet schedulers: towards rapid prototyping of queue-management algorithms ralf kundel1, paul stiegele1, dat tran1, julian zobel1, osama abboud2, rhaban hark1, ralf steinmetz1 ralf.kundel@kom.tu-darmstadt.de 1 multimedia communications lab (kom) technical university of darmstadt, germany 2 huawei technologies duesseldorf gmbh, germany abstract: quality of service indicators in computer networks reached tremendous importance over the last years. especially throughput and latency are directly influenced by the dimension of packet queues. determining the optimal dimension based on the inevitable tradeoff between throughput and latency tends to be a hard, almost infeasible challenge. several algorithms for active queue management have been proposed to address this challenge over the last years. however, the deployment and by that the development of such algorithms is challenging as they are usually located within the operation systems’ kernel or implemented in fixed hardware. in this work, we investigate how novel algorithms can be deployed in user space for rapid prototyping with tolerable effort. we provide core performance characteristics and highlight the viability and reasonability of this approach. keywords: aqm, user space, congestion control, bufferbloat introduction, background, and related work: internet applications have experienced an enormous upswing, most notably through intensive video streaming and conferencing applications realized by congestion-controlled tcp. besides steadily increasing requirements regarding throughput and availability, especially latency became more and more important as a quality of service (qos) criterion. however, there is a tradeoff between high bandwidth utilization and low latency packet forwarding for congestion-controlled flows when determining the dimension of packet queues on forwarding routers. throughput-intensive applications require sufficiently large packet queues in order to entirely utilize a link, whereas latency-sensitive applications suffer from too large packet queues, known as bufferbloat phenomenon [gn12]. the optimal queue size in terms of maximizing throughput without unnecessary increase in latency is considered to be b = rtt·c√n , where b is the maximum queue size, c the bottleneck link speed, and rt t the round trip time of n tcp flows [akm04]. however, this formula and its application on packet queue engineering has several challenges. first, this “optimal” queue size primarily focuses on full utilization of the subsequent bottleneck link and only secondary on latency reduction. second, constantly having n congestion-controlled tcp flows with a known rt t is not realistic as internet traffic changes dynamically and numerous different congestion control algorithms are present in parallel [kwm+19]. third, this rule of thumb considers only long data transmissions, so called “elephant flows”, although there is always a mixture of long and short flows in real networks. 1 / 4 volume 080 (2021) mailto:ralf.kundel@kom.tu-darmstadt.de user space packet schedulers to this end, numerous general but advanced active queue management (aqm) algorithms have been proposed [ada13][kbv+18]. they tackle the problem of bufferbloat by intelligently dropping packets or marking them with a congestion notification bit. however, no algorithm fitting all use cases has been found to this point and it is unlikely to exist. certainly, the development and experimental evaluation of such algorithms is challenging as they are either located within the operating system kernel, e.g., the linux kernel, or within hardware of packet forwarding chips (i.e., asics). with this work, we propose the idea of packet queuing and scheduling in the user space for rapid prototyping and preliminary evaluation of novel aqm algorithms. note that congestion control experiments are usually not performed by simulations, due to an easier reproduction of complexity and heterogeneity of real computer networks in emulation environments, mainly mininet. hence, our work focuses on network emulations. the most related approach to this work is the linux kernel extension libnetfilter queue1. this library enables a hybrid coexistence of queues in the kernel space and a packet scheduler in the user space. the scheduler decides whether a packet is dropped or not based on packet metadata information. however, advanced queuing and scheduling structures exceed the api capabilities, e.g., front drop instead of tail drop or push-in-extract-out queues cannot be investigated. prototype and preliminary evaluation results: in order to realize a user space queue emulator, we first investigate which programming languages should be used with regard to their packet i/o performance. for that, we create a simple mininet topology h1 ←→ h2 ←→ h3 consisting of three hosts. host h1 and h3 perform a bandwidth performance test with the iperf3 tool. host h2 is responsible to forward all packets from h1 to h3 and vice versa without queuing. to evaluate the performance of the packet forwarding, we measure the throughput of the iperf3 tcp flow and the observed round trip time (rtt). performance characteristics for six different packet forwarding implementations are displayed in figure 1. we use native linux kernel and the userspace implementation in c as baseline. forwarding incoming packets based on the linux kernel’s ipv4 routing table represents a theoretically achievable upper bound for throughput and a lower bound for rtt. the low-level user space implementation in c, compiled with -lpcap flags and no further optimizations, is supposed to be a even better upper bound for throughput. we realized four implementations in different programming languages with similar behavior to the baseline designs for the user space queuing system. note that the user space implementations are built upon a raw socket kernel module and thus the kernel is still involved. they are implemented as multi-threaded applications and use raw sockets to receive and send packets. one thread receives packets on the first interface and immediately sends them out on the second one. the second thread is responsible for similar packet forwarding in the opposite direction. more threads per direction are only meaningful if a hardware network interface card with load balancer is in use. the third and main thread is responsible to monitor these two workers. this multi-threading approach achieves almost a twofold increase in forwarding performance compared to a single-threaded approach. as depicted in figure 1, within the user space implementations, go achieves the best rtt. the c user space baseline-implementation, in contrast, achieves the best throughput, but surprisingly also experiences a significantly higher rtt. this is caused by a different interrupt handling 1 the netfilter.org libnetfilter queue project. www.netfilter.org/projects/libnetfilter queue/. accessed: 2020-10-13. netsys 2021 2 / 4 www.netfilter.org/projects/libnetfilter_queue/ eceasst linux kernel c go rust python2 python3 0 1000 2000 3000 4000 5000 6000 7000 tc p ra te [m bi t/s ] linux kernel c go rust python2 python3 0 1 2 3 4 5 6 o bs er ve d rt t [m s] figure 1: user space packet forwarding characteristics with disabled checksum offloading. the linux ipv4 forwarding is by default part of the linux kernel and represents an upper bound. all tests are compiled and running on a intel xeon d-1541 with ubuntu 16.04 (kernel 4.4.0). structure within the c raw socket implementation. note that this comparison is an evaluation of the raw socket performance within these languages only and not a benchmark of the languages itself. in total, go performed best considering both metrics of the four high-level languages. as prototyping in the queueing system should be as easy as possible, a high-level language such as go, rust or python is pursued instead of low-level c. as it performed best in our preceding tests, we decided to implement the user space queuing system in go, including queues with exchangeable schedulers and aqm algorithms. to showcase the benefits of such a user space queuing system, the prototype was integrated into the previous mininet topology, as depicted in figure 2a. for that, two experiments with different queue behavior were performed using (1) a tail drop queue and (2) a front drop queue with a rate limit of 50 mbit/s . in case of a full queue, when packet loss is unavoidable on receiving another packet, the former approach drops the new packet, while the latter drops the first in the queue and then adds the new packet at the tail. as the congestion control detects the packet loss earlier in the latter case, we assume a different behavior in both scenarios which shall be further investigated. exemplary results for both approaches are compared in figure 2b. in this concrete case, h1 queueing system fx gx h3 mininet network raw socket raw socket kernel space user space h2 (a) 0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0 0 25 ta il d ro p 0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0 time [s] 0 50 fr on t d ro p (b) figure 2: results of an exemplary user space queuing experiment. (a) integration of queueing system into simple mininet topology. (b) packet latency for dropping packets in the front/tail of the queue while overflowing. red bars mark dropped packets (22 tail drops, 15 front drops). 3 / 4 volume 080 (2021) user space packet schedulers we observe that the front drop queue creates less packet loss—15 compared to 22 lost packets— because tcp congestion control receives feedback earlier and thus adapts the sending rate sooner. this quickly realized experiment in combination with easily generated but yet expressive results highlight the major advantage of our user space queue emulator. in contrast to kernel or hardware implementations, the user space allows to log all dropping events. in essence, it is easy and convenient to determine why, where, and when a packet is dropped using user space packet schedulers for rapid prototyping. conclusion and outlook: active queue management is highly important in modern networks in order to meet the growing quality-of-service requirements. however, their development and evaluation is challenging due to their typical implementation in the kernel or in hardware. we therefore propose the idea of user space queuing systems for rapid prototyping of novel aqm algorithms. we performed experiments comparing four different high level programming languages for their applicability to implement such a system. the results have shown that raw sockets and user space packet queues achieve bandwidths above 1 gbit/s, which is sufficient for most aqm-experiments. additionally, two simple queuing algorithms were evaluated using a prototypical implementation of our user space queuing system. because aqm prototyping in user space allows to conveniently test and evaluate novel aqm approaches, future work will focus on the realization of programmable user space queues in real computer networks based on high performance packet i/o frameworks together with high-level programming languages. acknowledgements: this work has been supported by the federal ministry of education and research (bmbf, germany) within the software campus project ”5g-pci” and in parts by the german research foundation (dfg) as part of the projects b1 and c2 within the collaborative research center (crc) 1053 maki and the loewe initiative (hessen, germany) within the project nature 4.0 and the emergencity centre. bibliography [ada13] r. adams. active queue management: a survey. ieee communications surveys tutorials 15(3):1425–1476, 2013. [akm04] g. appenzeller, i. keslassy, n. mckeown. sizing router buffers. in conference on applications, technologies, architectures, and protocols for computer communications. p. 281–292. acm, 2004. [gn12] j. gettys, k. nichols. bufferbloat: dark buffers in the internet. communications of the acm 55(1):57–65, 2012. [kbv+18] r. kundel, j. blendin, t. viernickel, b. koldehofe, r. steinmetz. p4-codel: active queue management in programmable data planes. in proceedings of the conference on network function virtualization and software defined networks (nfv-sdn). pp. 1–4. 2018. [kwm+19] r. kundel, j. wallerich, w. maas, l. nobach, b. koldehofe, r. steinmetz. queueing at the telco service edge: requirements, challenges and opportunities. in workshop on buffer sizing. stanford, us, 2019. netsys 2021 4 / 4 improvements to the secure construction and utilization of greedy embeddings in friend-to-friend overlays electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) improvements to the secure construction and utilization of greedy embeddings in friend-to-friend overlays martin byrenheid, stefanie roos, and thorsten strufe 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst improvements to the secure construction and utilization of greedy embeddings in friend-to-friend overlays martin byrenheid1, stefanie roos2, and thorsten strufe3 1tu dresden 2delft university of technology 3karlsruhe institute of technology abstract: routing based on greedy network embeddings enables efficient and privacypreserving routing in overlays where connectivity is restricted to mutually trusted nodes. in previous works, we proposed security enhancements to the embedding and routing procedures to protect against denial-of-service attacks by malicious overlay participants. in this work, we propose an improved timeout scheme to reduce the stabilization overhead of secure tree maintenance in response to node failures and malicious behavior. furthermore, we present an attack-resistant packet replication scheme that leverages alternative paths discovered during routing. keywords: friend-to-friend overlay, network embedding, secure routing 1 introduction friend-to-friend (f2f) overlay networks, such as freenet and gnunet, provide a substrate for privacy-preserving and censorship-resistant communication services. to reduce the exposure of identifying information, such as the ip address, of participating nodes as well as to limit the effectiveness of sybil attacks, f2f overlays restrict connectivity to mutually trusted nodes. to enable communication beyond directly connected nodes, f2f overlays require a routing algorithm for restricted topologies that is 1) highly efficient, 2) privacy-preserving, 3) robust against network dynamics, and 4) resistant to attacks. the solution proposed by roos et al. [rbs16] achieves (1) to (3), making it the most promising candidate. their approach leverages greedy network embeddings, which assign a unique logical coordinate to every node based on a rooted spanning tree of the network. state-of-the-art embedding algorithms [rbs16, h+15, hwt11] however provide limited protection against denial of service attacks by malicious nodes. consequently, a malicious node with just two links to the honest part of the overlay can reduce routing success ratio by up to 40% [bsr20b]. to protect against malicious node behavior, we thus proposed attack-resistant algorithms for root election [bsr20a], breadth-first-search (bfs) tree setup [brs19], and coordinate assignment [bsr20b]. in this work, we present an improvement to our secure tree construction that reduces stabilization overhead in response to non-root node failures. furthermore, we propose an adaptive packet replication mechanism to further increase the chance of succesful routing in the presence of malicious nodes. 1 / 4 volume 080 (2021) improvements to the secure construction and utilization of embeddings in f2f overlays (a) (b) () (7) (53)(53,9) (53,24) (c) figure 1: primary steps of state of the art embedding algorithms: (a) root election, (b) tree construction, (c) coordinate assignment. 2 system model and adversary model we model a f2f overlay as a network of nodes with bidirectional, logical communication links. the network is dynamic, such that nodes may join or leave the network and links are set up and torn down over time. to enable routing, the overlay utilizes a distributed embedding algorithm, which assigns a unique logical coordinate to each overlay node. in our work, we focus on embeddings that use vectors of integers as coordinates, as these enable efficient addressing without the need to obtain global topology information, such as the number of participating nodes. current embedding algorithms assign coordinates by first constructing a distributed bfs spanning tree of the overlay network. afterwards, the root node chooses the empty vector as its logical coordinate. each node subsequently obtains a logical coordinate by appending a random integer to the coordinate of its parent in the spanning tree, as illustrated in figure 1. to route a message to a given destination coordinate d, nodes use a distance metric to measure the logical distance of each neighbor’s coordinate to d. the message is then forwarded greedily to one of those neighbors whose coordinate has the lowest logical distance to d. in our work, we consider an internal adversary that controls a subset of the nodes participating in the overlay, which we call malicious nodes. for readability, we call a non-malicious node an honest node in the following. each malicious node may collude with other malicious nodes and deviate arbitrarily from the correct behavior, e.g. by sending messages with incorrect data and dropping messages. due to the absence of a central admission control, the adversary may furthermore introduce an arbitrary number of additional malicious nodes that are not connected to any honest node. while the adversary can arbitrarily set up links between malicious nodes, we assume that the total number of links between malicious and honest nodes is bounded. we consider this assumption to be realistic, since the setup of connections to honest nodes requires social engineering, which we consider to be too costly to conduct on a large number of individuals. with regards to computational resources, we assume that the adversary is limited to polynomial time and hence unable to break computationally secure cryptographic primitives. however, the total computational power of the adversary may still be much higher than the computational power of the honest nodes combined. netsys 2021 2 / 4 eceasst 3 timeout thresholds for efficient and secure tree maintenance to securely detect the failure of a root node, we proposed the periodic propagation of timestamps along with cryptographic signatures generated by the root node [bsr20a]. if the root node fails or becomes unreachable due to overlay partitioning, the existing timestamps will eventually expire and nodes will start to elect a new root node. however, if a non-root node u fails, its children may not be able to tell whether the root node is still reachable via another path. to reduce stabilization overhead if the root node is still reachable, it is desirable to ensure that nodes in the subtree formerly rooted at u will first try to locate an alternative path before electing a new root. however, state-of-the-art algorithms for secure bfs tree maintenance [dmt15, brs19] may temporarily create cycles, which require the affected nodes to change their state multiple times before a stable state is reached. to avoid the formation of cycles and thus reduce convergence time, we extend our algorithm by distinguishing between two thresholds tsearch ∈ n and treset ∈ n with tsearch < treset . when the difference between u’s system time and the most recent timestamp reported by its current parent exceeds tsearch, u checks if there are neighbors whose reported timestamp does not exceed threshold ttree. if this is the case, then u will select one of those neighbors as its new parent. otherwise, u will not change its parent. if all timestamps reported by u’s neighbors exceed threshold treset , then u will consider its current root node failed. let fheartbeat be the frequency at which the root node generates new timestamps and let du be the hop distance from u to the root node. given upper bounds on the maximum clock difference ∆c between any two nodes, the maximum processing and transmission delay ∆p between any two nodes, the number of lost timestamp messages nlost , we set tsearch = ∆c + ∆pdu + nlost · fheatbeat . given an upper bound d on the network diameter, we set treset = tsearch + ∆pd. we consider knowledge of an upper bound on the diameter to be realistic, as studies on social graphs indicate that even networks with millions of users have a diameter below 35 [les]. in the case the root node actually became unreachable, the comparatively high value for treset causes the overlay to operate without a valid root node for a longer time. however, the study by roos et al. [rbs16] shows that if multiple embeddings are constructed, routing is still highly likely to succeed despite a temporary root failure. thus, it is possible to tolerate a delayed reaction to root node failures in favor of reduced overhead for adaptation to non-root faults. 4 adaptive packet replication for robust and secure routing when a node u routes a message m towards a particular coordinate c, it is possible that multiple neighbors of u have a lower distance to c. to enable discovery of alternative paths in the presence of faults, roos et al. [rbs16] propose backtracking: if the neighbor v chosen by u as next hop is unable to forward m further towards c, it will notify u accordingly and u will send m to a different neighbor with a lower distance. if u is not the originator of m and received negative feedback from all closer neighbors, it will notify its predecessor about its failure to forward m. while backtracking increases robustness against node failures, it relies on nodes to correctly report failures to route. thus, if a malicious node silently drops a message received from an honest node u, then u will not detect the loss and initiate backtracking. as an alternative, we 3 / 4 volume 080 (2021) improvements to the secure construction and utilization of embeddings in f2f overlays propose an adaptive replication of packets. to do so, we let the originator include a replication counter r in each message. if a node u needs to forward a message with r = k and has at least k closer neighbors, it will send a copy of m with r = 1 to the k closest neighbors. if u has less than k closer neighbors, it may send a copy of m to each closer neighbor such that the sum of the r values yields k. the initial value of r can be changed to trade off overhead and attack-resistance. compared to having the originator sending the same message multiple times, this approach avoids duplicate transmissions of the same message over the same link. 5 conclusion and future work in this work, we proposed a timeout scheme that enables nodes to check for alternative paths to the root node before starting a new election. furthermore, we presented a proactive message replication scheme to improve resilience against packet dropping by malicious nodes. to evaluate the effectiveness of the proposed measures, we will conduct a simulation study using different real world social graphs. for the timeout thresholds proposed in this paper, we expect a significant reduction in stabilization overhead over a naive root timeout in response to failure of nodes with degree, as these are likely to have a large number of children. for the adaptive packet replication, we expect the increase in routing success ratio over routing with backtracking in the presence of malicious nodes to grow with the network density, as more alternative paths become available. bibliography [brs19] m. byrenheid, s. roos, t. strufe. attack-resistant spanning tree construction in route-restricted overlay networks. in srds. 2019. [bsr20a] m. byrenheid, t. strufe, s. roos. attack resistant leader election in social overlay networks by leveraging local voting. in icdcn. 2020. [bsr20b] m. byrenheid, t. strufe, s. roos. secure embedding of rooted spanning trees for scalable routing in topology-restricted networks. in srds. 2020. [dmt15] s. dubois, t. masuzawa, s. tixeuil. maximum metric spanning tree made byzantine tolerant. algorithmica, 2015. [h+15] r. houthooft et al. robust geometric forest routing with tunable load balancing. in infocom. 2015. [hwt11] j. herzen, c. westphal, p. thiran. scalable routing easy as pie: a practical isometric embedding protocol. in ieee icnp. 2011. [les] j. leskovec. friendster social network and ground-truth communities. http://snap.stanford.edu/data/com-friendster.html. february 2021. [rbs16] s. roos, m. beck, t. strufe. anonymous addresses for efficient and resilient routing in f2f overlays. in infocom. 2016. netsys 2021 4 / 4 introduction system model and adversary model timeout thresholds for efficient and secure tree maintenance adaptive packet replication for robust and secure routing conclusion and future work evaluation of multi-hop ad-hoc routing protocols in wireless seismic data acquisition electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) evaluation of multi-hop ad-hoc routing protocols in wireless seismic data acquisition aliyu makama, koojana kuladinithi, musab ahmed eltayeb ahmed, andreas timm-giel 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst evaluation of multi-hop ad-hoc routing protocols in wireless seismic data acquisition aliyu makama1, koojana kuladinithi2, musab ahmed eltayeb ahmed3, andreas timm-giel4 1aliyu.makama@tuhh.de, 2koojana.kuladinithi@tuhh.de, 3musab.ahmed@tuhh.de, 4timm-giel@tuhh.de, https://www.tuhh.de/et6 institute of communication networks hamburg university of technology, germany abstract: due to impediments associated with cable-based seismic survey, wireless seismic data acquisition (wsda) has recently gained much attention from contractors, exploration companies, and researchers to layout enabling wireless technology and architecture for wireless geophone networks (wgn) in seismic explorations. a potential approach is to employ multi-hop wireless ad-hoc communication. in this study, we propose a multi-hop wgn architecture consisting of several subnetworks to realize the expected network performance. we investigate the performance of proactive and reactive routing protocols to examine the optimal number of geophones that could be effectively supported within a subnetwork. the performance metrics used are packet delivery ratio (pdr) and average end-to-end delay. keywords: wireless geophone network (wgn), wireless gateway (gw), central control unit (ccu), wireless seismic data acquisition (wsda) 1 introduction seismic survey is a method of obtaining an image of the earth’s sub-surface structure in order to determine optimal places to drill for oil and gas. in land survey, an energy source generates variable frequency waves (referred to as sweep or shot) that propagates down the earth’s surface. these waves are reflected and refracted as they hit various subsurface layers, which are recorded by devices at the surface called geophones and then sent down to the central control unit (ccu) for further processing. the source is then moved to the next shot point and the process is repeated. depending on the coverage area, the survey can last for several weeks. a measured geophone response sampled at 0.5 ms and digitized with 24 bit resolution will result in a data rate of 48 kbit/s. wgns are often large-scale networks with tens of thousands of geophones deployed along receiver lines, covering several squares of kilometres of the survey area. for real-time wsda systems, defining a scalable network architecture and employing a suitable wireless technology is of essential importance. infrastructure based architectures for wgns have been proposed in many literatures, [rsa+19] etc., whereby group of geophones transmit their sensed data to a wireless gateway (gw), and from the gateway down to the ccu in single-hop. however, this increases the number of gws to be deployed in the survey. higher data rate, higher communication coverage, and regard for imposed cost are some of the key factors to consider when selecting wireless technology for wgns. 1 / 5 volume 080 (2021) mailto:aliyu.makama@tuhh.de mailto:koojana.kuladinithi@tuhh.de mailto:musab.ahmed@tuhh.de mailto:timm-giel@tuhh.de https://www.tuhh.de/et6 evaluation of multi-hop ad-hoc routing protocols in wireless seismic data acquisition network architecture: our proposal is to enable multi-hop ad-hoc communication in the wgn architecture proposed in [mkt21], to reduce the number of gws to be deployed, while keeping the wgns performance intact. therefore, a flat-based network architecture in which the survey area is divided into subnetworks is employed (figure 1). each subnetwork consists of certain number of geophones that relay their seismic data via neighbouring geophones to a gw node over multi-hop wireless network. the gw then forwards the aggregated data to the ccu. the size of the subnetwork determines the optimal number of hops supported satisfying the wgn requirements, with 100% pdr and the upper limit of the delay for real-time acquisition systems. to limit the effect of adjacent and co-channel interference, neighbouring gws are expected to use non-overlapping channels in such a way that no adjacent subnetwork uses the same channel. traffic demand in a subnetwork: the common orthogonal geometry where receiver and source lines are placed perpendicular to each other is employed [cgp00]. geophones are placed on four parallel receiver lines, separated by a distance of 200 m and an inter-geophone distance of 25 m as defined in a typical survey [rsa+19]. the traffic from each geophone is generated according to the geophone recording period acquisition technique in [mkt21], at a rate of 48 kbit/s which is transmitted to the gw node. depending on the number of hops, a forwarding geophone will transmit twice the rate or more, as shown in figure 1 (logical view). although the data generated per geophone is quite small, the aggregate data generated in a subnetwork could be significantly large. if the subnetwork size has been selected with up to 200 nodes maximum, around 9.6 mbit/s of the network capacity will be required with per node data rate of 48 kbit/s, assuming all nodes can reach the gw in a single hop. however, this value increases with more number of hops in the network. moreover, when various protocol headers are taken into consideration the available bit rate is less than the nominal data rate. wireless technologies: considering the large-scale geophone deployment and higher data rate requirements, wireless communication technologies/protocols used in conventional wireless sensor networks (wsn) such as, ieee 802.15.4 or lora are not suitable for wgns. longer range random access technologies like ieee 802.11af and ieee 802.11ah are more suitable as they can cover more geophones and can provide higher data rates. the main goal of this work is to evaluate a suitable routing protocol to enable multi-hop adhoc communication in a wgn subnetwork with acceptable network performance. ad-hoc in this work refers to infrastructure-less communication. many routing protocols for wireless adhoc networks have been discussed and classified based on the underlying network structure (i.e. flat, tree, mesh, and hierarchical based) in literature [pnv13]. the ad-hoc routing protocols are categorized as pro-active, reactive, and hybrid [pnv13]. in proactive protocols route to destinations are established and maintained by periodically distributing routing information in the network. in reactive protocols, route discovery is initiated only on demand from source nodes. two prominent proactive protocols i.e., optimised link state routing “olsr” (mostly used in mobile ad-hoc networks) and ipv6 routing protocol for low-power and lossy networks “rpl” (commonly used in wsns), and a widely used reactive protocol i.e., ad-hoc on-demand distance vector “aodv” are investigated in this study. ieee 802.11g, which has same random access behavior of csma/ca like in ieee 802.11af, ieee 802.11ad, is used as an example mac protocol to evaluate the multi-hop routing protocols. olsr is based on link-state algorithm, that uses the concept of multipoint relays (mpr) to netsys 2021 2 / 5 eceasst 200 m 25 m central control unit gateway geophone channel a channel b channel c source line subnetwork subnetwork subnetwork receiver line shot points wgn with multiple subnetworks (physical view) multi-hop connectivity in a subnetwork (logical view) figure 1: architecture for wireless geophone networks optimize the number of control messages flooded in the network. rpl is an ipv6 distance vector protocol that employs the concept of destination oriented directed acyclic graph (dodag) to establish network topology, with all links oriented towards the sink or dodag root. it uses an objective function to construct routes, which define how routing metrics and other constraints are taken into account when building the network topology[wtb+12]. aodv is a distance vector protocol based on the bellman-ford algorithm in which route discovery is initiated on demand by a transmitting node. using omnet++ simulation tool, we evaluate the performance of these protocols considering wgn’s traffic pattern, network size and structure to analyze the size of a subnetwork. 2 results analysis one subnetwork with various network size settings is configured in omnet++ simulator as shown in figure 1. each geophone accumulates the data during the interval of 250 ms and send the accumulated data periodically till the end of geophone recording period of 5 s, for a single shot. the payload size of a single packet is configured as 1500 b (= 48 kbit/s at 250 ms). ieee802.11g is used with ad-hoc mode of operation supporting both 11 mbit/s and 54 mbit/s data rates. the latter is used to investigate the routing protocol performance for the maximum achievable data rate in 802.11g, as 11 mbit/s might not be enough to cater for our application data rates over several hops. figure 2 shows wgn requirement of the pdr of 100% can be achieved only up to 20 nodes irrespective of the type of routing protocol used to enable multi-hop communication in a sub network, when using 11 mbit/s. the offered load approaches the maximum capacity the network can handle, thereby leading to severe packet loss at the mac layer due to retransmission failures or queue overflow. in addition to the offered load, routing overhead resulting from periodic exchange of hello message and topology control messages further occupies the network capacity. in general, higher number of routing overhead is involved in proactive compared to reactive routing. here, aodv shows a slight improvement in pdr beyond 20 nodes with 11 mbit/s. some cases, rpl shows better pdr, compared to olsr as it uses the trickle timer algorithm to dynamically adjust the rate of sending control packets. 3 / 5 volume 080 (2021) evaluation of multi-hop ad-hoc routing protocols in wireless seismic data acquisition figure 2: packet delivery ratio figure 3: average end-to-end delay the pdr of rpl and olsr outperform aodv when using 54 mbit/s. the pdr for all protocols closely follows till the network size (n) of 80 where the network capacity can bear the offered load and the routing overhead with mulit-hop communication. at n = 100, the pdr for aodv protocol significantly drops to almost 50%. this is caused by the specific traffic model of the wgn. geophones transmit data packets almost simultaneously during the geophone recording period of 5 s. this is a bottleneck for aodv as route discovery process is initiated whenever a node wants to transmit a packet, thereby overloading the network capacity with route request (rreq) packets leading to collisions. this results in failure in route discovery process causing more packets to be dropped. figure 3 shows the average packet end-to-end delay in the network. as expected, the delay decreases with higher data rate as a lower data rate implies longer packet transmission time. the delay increases with increase in network size as a packet might travel over two or three hops. in addition, as the probability of collision increases with an increase in network size, packets will take longer time in the queue due to the csma/ca back-off algorithm, especially in aodv protocol during the route establishment process. 3 conclusion the preliminary study sets to investigate the performance of proactive and reactive protocols in wgns, with focus on determining the optimal number of geophones that could be supported in a subnetwork. the initial results show that this clearly depends on the type of link layer technology (data rate, mac) and the underlying routing protocols strategy. rpl and olsr show more promising results as compared to aodv protocol. these protocols offer low delay during the route setup process as routes are immediately available when data transmission begins. however, high bandwidth requirement might be a major drawback in olsr as the control overhead is proportional to the number of nodes in the network. rpl looks more promising in terms of cost effectiveness as it employs trickle mechanism to optimize the dissemination of topology control information over the network. future work will be directed towards realizing the architecture presented in figure 1 with enhancements to mac scheme, e.g., dedicating the resources, and also to optimizing the routing strategy within the subnetworks. netsys 2021 4 / 5 eceasst acknowledgements: this work is supported by deutscher akademischer austauschdienst (daad) under the nigerian-german postgraduate training programme, in collaboration with the nigerian petroleum technology development fund (ptdf). bibliography [cgp00] a. cordsen, m. galbraith, j. peirce. planning land 3-d seismic surveys. society of exploration geophysicists, jan. 2000. [mkt21] a. makama, k. kuladinithi, a. timm-giel. wireless geophone networks for land seismic data acquisition: a survey, tutorial and performance evaluation. sensors 21(15), 2021. doi:10.3390/s21155171 [pnv13] n. a. pantazis, s. a. nikolidakis, d. d. vergados. energy-efficient routing protocols in wireless sensor networks: a survey. ieee communications surveys tutorials 15(2):551–591, 2013. doi:10.1109/surv.2012.062612.00084 [rsa+19] v. a. reddy, g. l. stuber, s. al-dharrab, w. mesbah, a. h. muqaibel. a wireless geophone network architecture using ieee 802.11af with power saving schemes. ieee transactions on wireless communications, pp. 5967–5982, 2019. doi:10.1109/twc.2019.2940944 [wtb+12] t. winter, p. thubert, a. brandt, j. hui, r. kelsey, p. levis, k. pister, r. struik, jp. vasseur, r. alexander. rpl: ipv6 routing protocol for low-power and lossy networks. technical report rfc6550, rfc editor, mar. 2012. 5 / 5 volume 080 (2021) http://dx.doi.org/10.3390/s21155171 http://dx.doi.org/10.1109/surv.2012.062612.00084 http://dx.doi.org/10.1109/twc.2019.2940944 introduction results analysis conclusion property inference-based federated learning groups for collaborative network anomaly detection electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) property inference-based federated learning groups for collaborative network anomaly detection jens wettlaufer 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst property inference-based federated learning groups for collaborative network anomaly detection jens wettlaufer universität hamburg jens.wettlaufer@uni-hamburg.de abstract: while the use of anomaly detection in network security has a long research history, it is rarely used in practice. besides privacy concerns when applied in cross-network settings, and a more difficult attack interpretation, the major drawback consists of the high number of false alarms. one reason is the heterogeneity of sources the model is trained on. in this paper, we propose a network anomaly detection extension that counteracts the heterogeneity of participants by dividing them into learning groups during central or federated training. the learning groups finally contain similar behaving clients, e.g., light bulbs, or pcs of the same department. similar behavior is extracted by hierarchically clustering the predictions of all individual client models similar to a passive property inference attack. our preliminary results based on infiltration attacks of the ids2017 dataset show that the method increases the accuracy and f1 score up to 4.4% and 2.5%, respectively. keywords: anomaly detection, unsupervised learning, property inference, network security, hierarchical clustering, collaborative learning 1 introduction anomaly detection intends to identify deviations or non-conforming patterns from expected behavior. these patterns are called anomalies or outliers. it is broadly researched in tumor identification on mri images, credit card fraud, identity theft, spam detection, and intrusion detection [cbk09]. the common problem of a high false positive rate does not concern for example credit card fraud that much, because the users can clarify the situation easily. however, in network intrusion detection of large networks, even a false positive rate of 1% in a million network flows a day is impractical to manually assess [sp10]. additionally, the interpretation of an anomaly often requires expert knowledge when the anomaly detection task is not clearly formulated [sp10]. furthermore, heterogeneous networks with different types of devices, end users, and thus behavior patterns make it hard to learn normal behavior, and interpret anomalies afterwards. essentially, while anomaly models intend to capture a normal profile, such that subtle deviations are detected, the heterogeneity of entities counteracts this. in addition, real-world challenges arise for the usage of centralized anomaly detection. first, it is challenging for large networks to collect all data for training and prediction. second, startups or small businesses may have too few data samples to train the model effectively. this could be circumvented by collaborating with others, which introduces privacy concerns. in consequence, network anomaly detection is rarely used in practice, even though it is capable of detecting unknown attacks in contrast to signature or policy-based approaches. to overcome these problems, we suggest to extend existing 1 / 5 volume 080 (2021) property inference-based learning groups anomaly detection procedures by dividing heterogeneous clients during the training into groups with similar behaviors, e.g., service usage or user behavior, in an unsupervised fashion. this enables given anomaly models to learn normal behavior more precisely in order to detect even subtle deviations, such as a slight increase of ssh traffic in the it department. further, anomalies can be interpreted and solved easier due to a decreased number of participating clients for a particular anomaly. therefore, our main contributions include: identification of similar behavior. we provide an unsupervised method based on the principle of property inference to identify similar behaving clients, further called learning groups. the method is not restricted to, but evaluated on network anomaly detection in this work. central and collaborative learning. we show that this method can be applied to central and collaborative learning by providing a federated learning extension that does not interfere with its actual protocol nor its privacy and performance guarantees. preliminary results. our preliminary results achieve an increased accuracy by 2.3-4.4% and f1 score by 1.2-2.5% on average between different models. the rest of the paper is structured as follows. section 2 identifies differences to existing solutions. section 3 provides the main research questions, explains the approach, and discusses preliminary results. finally, section 4 summarizes the paper and states next steps. 2 related work network anomaly detection models for different attacks are widely researched. for example, fernandes et al. [frc+19] survey numerous papers emphasizing that the kind of data, i.e., tcpdump, snmp, and ip, determines the detection capabilities. our approach is not determined by a specific method or data type. some works intend to profile ip hosts based on previously analyzed traffic or host parameters [yr08, mdbc10, jgl15]. our method does not necessarily target a specific network anomaly problem, but rather improves existing models. additionally, we intend to integrate the division of learning groups into the actual training without the need for a prior assessment of hosts, which might be infeasible in cross-network scenarios in regard to privacy. aiello et al. [akm+05] analyze host-level communities of interest, i.e., entities that share a common goal or environment, based on host connections to other hosts in regard to popularity and frequency. while this approach is not characteristic dependent, we argue that host-level goals are not necessarily interchangeable with similar behavior of hosts, e.g., regarding time shifts of actions. nguyen et al. [nmm+19] present a federated anomaly detection in a twofold approach. calculated fingerprints are clustered to identify iot device types, which are then used as static properties to apply their anomaly model within a group of devices of one device type only. in contrast, our approach aims at integrating the grouping step into the actual anomaly model training. additionally, our work goes beyond device type similarities and allows for the creation of non-obvious learning groups. 3 property inference-based federated learning groups this work hypothesizes that if groups of similar behaving clients, e.g., smart light bulbs, web servers, or pcs of the hr department, separately train together, the anomaly detection results in netsys 2021 2 / 5 eceasst a more accurate prediction. thus, we aim at answering the following research questions: rq1 how can we automatically infer client behavior properties during training? the goal is to identify similar behaving clients independent of the anomaly detection task, model, and training procedure. rq2 which (non-obvious) properties exist that improve the anomaly detection after training in property-based learning groups? [nmm+19] achieve promising results with device type specific learning groups. however, we also aim at recognizing non-obvious groups of devices that improve the prediction. rq3 how can we apply learning groups in a privacy-preserving and collaborative scenario? to further apply this method in large networks with higher performance and privacy requirements, we need to show that the method also works for collaborative learning. the following paragraphs first sketch an answer to rq3 and focus further on rq1, while addressing rq2 partially in the discussion of our preliminary results. approach. federated learning (fl) is a distributed round-base learning technique between clients with private data and a coordinating server. we modify the fl procedure as follows. first, the server distributes a tuple (mglobal,sn), i.e., a randomly initialized global model and n random samples of network traffic, to the participating clients. then, each client ci trains the received mglobal with its own data, makes a prediction pcin of the random samples sn, and extracts its model updates u ciglobal . it then sends the tuple (u ci global, p ci n ) back to the server. the server now applies the learning group metric to all received predictions pcin and determines the learning groups. finally, the clients continue fl training together within their assigned learning groups. learning group metric. client behavior is expressed through client data. client data is used to train ml models, which then become a representation of the data. thus, client behavior can be inferred based on the trained model. therefore, a metric to identify similarities between models is required. related work in the field of property and membership inference attacks on ml has shown that it is feasible to infer properties of the training data that are solely represented in the model predictions [ssss17]. consequently, we measure the similarity by comparing the prediction outputs of each trained client model for a given input. to identify client behaviors that are closest to each other, we choose hierarchical clustering, in particular agglomerative clustering. while we used three default distance metrics for our first results, further distance metrics [pah+19] will be analyzed subsequently. dataset and implementation. the preliminary results are based on the ids2017 dataset [shg18] containing simulated corporate communication of ten clients and two servers. we choose a subset of the attacks containing infiltration attacks. then, we apply the recommended task related flow-based features [shg18] to our simple anomaly detection models, i.e., isolation forest and elliptic envelope. we provide four baselines including all clients training together and separate, as well as training in obvious learning groups, i.e., clients/servers and operating systems. the values in table 1 are the average of five rounds. further, we test three variants of establishing learning groups by varying the percentile of the training data before clustering, while keeping three as a fixed number of clusters. additionally, we apply three different clustering metrics (cm) to the client-wise predictions of the samples sn with n = 1000: average (average distance), 3 / 5 volume 080 (2021) property inference-based learning groups complete (maximum distance), and ward (minimizes the variance of the clusters being merged). preliminary results and discussion. table 1 compares all performed tests, where min and max correspond to the result of a single learning group, while mean averages all of them. cells highlighted in red provide the information that they consist of one learning group that scores worse than the all together prediction. the goal, however, is to achieve a set of learning groups that all score equal or greater than the all together learning group. thus, none of the baselines address the most effective client properties for learning group separation. our experiments have several limitations, including the lack of comparison in regard to the fixed size of clusters, the use of simple ml models with discrete instead of probabilistic predictions, and a restricted set of features. learning groups isolation forest accuracy isolation forest f1 elliptic envelope accuracy elliptic envelope f1 min mean max min mean max min mean max min mean max baselines all together 0.863 0.927 0.914 0.955 all separate 0.835 0.886 0.946 0.901 0.939 0.972 0.891 0.926 0.973 0.942 0.961 0.986 machine 0.883 0.899 0.930 0.938 0.947 0.964 0.903 0.911 0.925 0.949 0.953 0.961 machine + os 0.850 0.893 0.940 0.919 0.943 0.969 0.907 0.923 0.955 0.951 0.960 0.977 10% training 3 clusters cm: average 0.870 0.899 0.944 0.931 0.947 0.971 0.915 0.921 0.934 0.956 0.959 0.966 cm: complete 0.844 0.883 0.944 0.915 0.938 0.971 0.915 0.921 0.934 0.956 0.959 0.966 cm: ward 0.902 0.908 0.926 0.949 0.952 0.961 0.929 0.935 0.949 0.963 0.966 0.974 20% training 3 clusters cm: average 0.863 0.885 0.926 0.926 0.939 0.962 0.926 0.936 0.949 0.961 0.967 0.974 cm: complete 0.893 0.907 0.946 0.943 0.951 0.972 0.926 0.936 0.949 0.961 0.967 0.974 cm: ward 0.882 0.901 0.940 0.937 0.948 0.969 0.926 0.936 0.949 0.961 0.967 0.974 30% training 3 clusters cm: average 0.867 0.897 0.940 0.929 0.945 0.969 0.928 0.937 0.949 0.963 0.967 0.974 cm: complete 0.870 0.901 0.950 0.930 0.947 0.975 0.924 0.933 0.949 0.961 0.965 0.974 cm: ward 0.850 0.892 0.950 0.919 0.942 0.974 0.924 0.933 0.949 0.961 0.965 0.974 table 1: evaluation of predicting normal behavior on the infiltration attacks dataset. bold values represent the maximum in a column. highlighted values are less than the all together baseline. 4 conclusion and future work in this paper, we present an unsupervised division of participants into learning groups during the semi-supervised training of an anomaly detection model. clients within learning groups have trained the initial model in a similar way, meaning that they have similar data and thus similar behavior. we showed that it is also feasible to introduce this method in a collaborative learning setup without revealing private data. by applying it to network anomaly detection of infiltration attacks, it achieves an increased accuracy and f1 score by up to 4.4% and 2.5%, respectively, in contrast to the common training procedure. teh next steps include advancing from a fixed cluster size to a threshold, a detailed analysis of distance metrics for hierarchical clustering, and a deeper look into the data to answer rq2. additionally, further models, e.g., neural networks and datasets of different domains, e.g., iot, industrial networks, or image recognition, will be evaluated to show the independence of this approach. subsequent work will reduce the attack surface on the property inference step, e.g., by introducing secure multi-party computation, and generalize the approach on other ml tasks. netsys 2021 4 / 5 eceasst bibliography [akm+05] w. aiello, c. kalmanek, p. mcdaniel, s. sen, o. spatscheck, j. van der merwe. analysis of communities of interest in data networks. in passive and active network measurement. 2005. [cbk09] v. chandola, a. banerjee, v. kumar. anomaly detection: a survey. acm computing surveys, 2009. [frc+19] g. fernandes, j. j. p. c. rodrigues, l. f. carvalho, j. f. al-muhtadi, m. l. proença. a comprehensive survey on network anomaly detection. telecommunication systems, 2019. [jgl15] a. jakalan, j. gong, s. liu. profiling ip hosts based on traffic behavior. in ieee international conference on communication software and networks. 2015. [mdbc10] g. münz, h. dai, l. braun, g. carle. tcp traffic classification using markov models. in traffic monitoring and analysis. 2010. [nmm+19] t. d. nguyen, s. marchal, m. miettinen, h. fereidooni, n. asokan, a.-r. sadeghi. dïot: a federated self-learning anomaly detection system for iot. 2019. [pah+19] v. b. s. prasath, h. a. a. alfeilat, a. b. a. hassanat, o. lasassmeh, a. s. tarawneh, m. b. alhasanat, h. s. e. salman. distance and similarity measures effect on the performance of k-nearest neighbor classifier – a review. big data, 2019. [shg18] i. sharafaldin, a. habibi lashkari, a. a. ghorbani. toward generating a new intrusion detection dataset and intrusion traffic characterization:. in proceedings of the 4th international conference on information systems security and privacy. 2018. [sp10] r. sommer, v. paxson. outside the closed world: on using machine learning for network intrusion detection. in ieee symposium on security and privacy. 2010. [ssss17] r. shokri, m. stronati, c. song, v. shmatikov. membership inference attacks against machine learning models. 2017. [yr08] t.-f. yen, m. k. reiter. traffic aggregation for malware detection. in detection of intrusions and malware, and vulnerability assessment. 2008. 5 / 5 volume 080 (2021) introduction related work property inference-based federated learning groups conclusion and future work how we know the practical impact of clone analysis electronic communications of the easst volume 63 (2014) proceedings of the eighth international workshop on software clones (iwsc 2014) how we know the practical impact of clone analysis — position paper — norihiro yoshida, eunjong choi , yuki yamanaka , katsuro inoue 5 pages guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst how we know the practical impact of clone analysis norihiro yoshida1, eunjong choi 2, yuki yamanaka 2, katsuro inoue 2 1 yoshida@is.naist.jp graduate school of information science nara institute of science and technology, japan 2 ejchoi, y-yuuki, inoue@ist.osaka-u.ac.jp graduate school of information science and technology osaka university, japan abstract: in order to develop and improve clone analysis techniques for industrial application, it is necessary to know about how those techniques provide impacts on clone management in industry. in this position paper, we discuss approaches to observing the practical impact of clone analysis on the basis of our experience in applying clone analysis into an industrial development process. keywords: clone management, industrial experience, refactoring 1 introduction the impact of software analytics is generating a lot of discussions in the software engineering community [nii13, mz13b, mz13a]. although a lot of techniques have been proposed on software analytics so far, how those techniques provide positive impacts is still unclear. the clone research community has provided a greater number of industrial case studies on clone analysis techniques compared to other analytics research fields [jdhw09, hg13, yhki12]. however, most of those studies simply applied clone analysis techniques to industrial source code, and only a few studies have been done on the application of those techniques into an industrial development process. it is clearly difficult to confirm the practical impact of applying clone analysis techniques without any application of those techniques into an industrial development process. mining software repositories (msr) allows researchers to know the evolution of code clones in version archives[ksnm05, gk11, srs13]. however, it does not tell them whether or not the evolution was intentionally achieved by a developer who was inspired by the result of clone analysis. for example, msr is insufficient to distinguish whether clone analysis techniques helped a developer to notice code clones to be maintained or the developer noticed them without any clone analysis technique. in this position paper, we introduce our experience in observing the practical impact of clone analysis during the application of the analysis into a development process in nec corporation. during the application, we successfully confirmed that our clone change management system helped a project manager to notice newly-appeared code clones to be maintained. then, we discuss future challenges for observing the practical impact. 1 / 5 volume 63 (2014) mailto:yoshida@is.naist.jp mailto:{ejchoi, y-yuuki, inoue}@ist.osaka-u.ac.jp how we know the practical impact of clone analysis developer version control system commit source code checkout source code report clone evolution information • e-mail notification • web-based ui clone notifier figure 1: an overview of clone notifier clone notifier report questionnaire feedback project manager our group figure 2: an overview of the case study 2 industrial experience with clone change notification system in this section, we introduce the experience with 40-day application of clone notifier [ycy+13] into a development process in nec corporation. figure 1 shows an overview of clone notifier. it is a clone change notification system for notifying creation and change of code clones. it regularly identifies newly-appeared and changed clones by analyzing svn commits and using ccfinder[kki02], and then notifies them to developers by e-mail and a web-based ui. we used the default setting of ccfinder. in the default setting, the minimum token length of the detected code clones is 30. the target system consists of approximately 350 files and 12 kloc written in java. the duration of the application was about 40 days, from december 2011 to january 2012. to observe the practical impact of the clone analysis technique, we used questionnaires to the project manager of the development team. figure 2 shows an overview of the questionnaires. at first, we asked him whether he discovered at least one unintentionally-developed clone, and then asked him how the development team should maintain the unintentionally-developed clone. we showed three options for the second question (i.e., refactoring, write a source code comment to denote the existence of the clone, leave the clone as it is). proc. iwsc 2014 2 / 5 eceasst 2.1 application result during 40 days application, clone notifier notified overall 119 newly-appeared clone sets. between 119 clone set of newly-appeared clone set, the project manager recognized 10 clone sets as clone sets should be refactored, and a clone set should be noted in a source code comment. in the questionnaires, he told us that his criteria whether or not a newly-appeared clone set should be maintained (i.e., refactored, noted) are the amount of code clones that can be reduced in the clone set and the possibility of editing the clone set in the future maintenance, and the criterion whether a newly-appeared clone set should be refactored or noted is the cost of refactoring. the noted clone set includes a number of the name differences between code clones. therefore, he regarded merging those differences and performing a test to verify the merging as time-consuming task. two of the ten clone sets was merged into a single function during the 40 days, respectively. the other eight clone sets were designated as refactoring candidates that will be merged during next maintenance project. 2.2 manual observation of newly-appeared clone sets as an ex-post analysis, we investigated the characteristics of clone sets recognized as refactoring candidates by the experienced project manager at nec. the aim of the analysis is data collection for the development of a technique to recommend refactoring candidates from all newlyappeared and changed clones. the recommendation is able to help developers to reduce the cost of finding clone sets should be merged into a single module. we manually checked the differences between the 10 clone sets should be merged and the other 109 clone sets. as a result, we learned interesting insights about the clone sets that should be merged. 2.2.1 code clones introduced without code addition as the first insight, in the case of clone sets that were newly-appeared by adding new code, the project manager frequently recognized them as ones should be merged. on the other hand, clone sets were sometimes accidentally created by only the replacement or the deletion of statements. in other words, even if no line is added to a code fragment, it sometimes became a code clone in a clone set together with other code fragments when at least one character is changed in it. in such case, the project manager mostly decided to leave those duplicates as it is. from our observation of the 119 clone sets, we found that only coding idioms (e.g., programming or api/library specific idioms) are involved in clone sets that were newly-appeared by only the replacement or the deletion of statements. basically, such idioms are difficult to merge or have an overall positive effect on maintenance and development [kg06, kg08] therefore they should be eliminated from refactoring candidates. according to this observation, we eliminated clone sets that were newly-appeared by only the replacement or the deletion of statements from the 119 clone sets. the result shows that the elimination not only left the all of clone sets that should be refactored but also reduced the number of the number of 119 newly-appeared clone sets by approximately 86%(16/119). 3 / 5 volume 63 (2014) how we know the practical impact of clone analysis 2.2.2 syntactically incomplete clone sets as the second insight, code sets include whole parts of loop or branch statements were considered as ones should be merged. meanwhile, the project manager rarely recognized clone sets include only parts of loop or branch statements as ones should be merged because it is difficult to merge syntactically incomplete clone sets. according to this observation, we eliminated syntactically incomplete clone sets from the 119 clone sets. the result shows that the elimination not only left the all of clone sets should be refactored but also reduced the number of 119 newly-appeared clone sets by approximately 90%(12/119). note that this does not include the previous reduction. 3 challenges in this section, we discuss future challenges for observing the practical impact of clone analysis. at first, the clone research community should develop a collection of common and disciplined approaches for the observation to share and generalize study results presented by different researchers. we believe that our industrial experience introduced in section 2 can be a good starting point to discuss a collection of common and disciplined approaches for the observation. secondly, it is strongly needed to apply various kinds of clone analysis techniques into industrial development processes because it is promising to give a clue to the development of clone analysis techniques. as introduced in section 2, applying clone analysis into development process tells us what kinds of clones should be notified to developers for what kinds of maintenance activities. for example, the industrial case study in section 2 tells us newly-appeared clones should be notified to developers who perform refactoring. finally, it is also important for the improvement of clone analysis techniques to perform expost analysis after the application of those techniques into development process. as introduced in section 2, our ex-post analysis tells us that more sophisticated techniques are needed for efficient clone notification. acknowledgements: this work was supported by jsps kakenhi grant numbers 25220003, 21240002. bibliography [gk11] n. göde, r. koschke. frequency and risks of changes to clones. in proceedings of the 33rd international conference on software engineering. icse ’11, pp. 311– 320. acm, new york, ny, usa, 2011. doi:10.1145/1985793.1985836 http://doi.acm.org/10.1145/1985793.1985836 [hg13] j. harder, n. gde. cloned code: stable code. journal of software: evolution and process 25(10):1063–1088, 2013. proc. iwsc 2014 4 / 5 http://dx.doi.org/10.1145/1985793.1985836 http://doi.acm.org/10.1145/1985793.1985836 eceasst doi:10.1002/smr.1551 http://dx.doi.org/10.1002/smr.1551 [jdhw09] e. juergens, f. deissenboeck, b. hummel, s. wagner. do code clones matter? in proc. of icse. pp. 485–495. 2009. [kg06] c. kapser, m. w. godfrey. ”cloning considered harmful” considered harmful. in wcre. pp. 19–28. 2006. [kg08] c. j. kapser, m. w. godfrey. ”cloning considered harmful” considered harmful: patterns of cloning in software. empir software eng 13(6):645–692, 2008. [kki02] t. kamiya, s. kusumoto, k. inoue. ccfinder: a multilinguistic token-based code clone detection system for large scale source code. ieee trans. softw. eng. 28(1):654–670, 2002. [ksnm05] m. kim, v. sazawal, d. notkin, g. c. murphy. an empirical study of code clone genealogies. in proc. of esec/fse. pp. 187–196. 2005. [mz13a] t. menzies, t. zimmermann. the many faces of software analytics. ieee software 30(5):28–29, 2013. doi:http://doi.ieeecomputersociety.org/10.1109/ms.2013.114 [mz13b] t. menzies, t. zimmermann. software analytics: so what? ieee software 30(4):31–37, 2013. doi:http://doi.ieeecomputersociety.org/10.1109/ms.2013.86 [nii13] nii shonan meeting on software analytics: principles and practice. 2013. http://www.nii.ac.jp/shonan/blog/2012/11/19/software-analytics-principles-and-practice/ [srs13] r. k. saha, c. k. roy, k. a. schneider. gcad: a near-miss clone genealogy extractor to support clone evolution analysis. in software maintenance (icsm), 2013 29th ieee international conference on. pp. 488–491. 2013. doi:10.1109/icsm.2013.79 [ycy+13] y. yamanaka, e. choi, n. yoshida, k. inoue, t. sano. applying clone change notification system into an industrial development process. in icpc. pp. 199–206. 2013. [yhki12] n. yoshida, y. higo, s. kusumoto, k. inoue. an experience report on analyzing industrial software systems using code clone detection techniques. in software engineering conference (apsec), 2012 19th asia-pacific. volume 1, pp. 310–313. 2012. doi:10.1109/apsec.2012.98 5 / 5 volume 63 (2014) http://dx.doi.org/10.1002/smr.1551 http://dx.doi.org/10.1002/smr.1551 http://dx.doi.org/http://doi.ieeecomputersociety.org/10.1109/ms.2013.114 http://dx.doi.org/http://doi.ieeecomputersociety.org/10.1109/ms.2013.86 http://www.nii.ac.jp/shonan/blog/2012/11/19/software-analytics-principles-and-practice/ http://dx.doi.org/10.1109/icsm.2013.79 http://dx.doi.org/10.1109/apsec.2012.98 introduction industrial experience with clone change notification system application result manual observation of newly-appeared clone sets code clones introduced without code addition syntactically incomplete clone sets challenges towards deterministic reconfigurable networks electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) towards deterministic reconfigurable networks zikai george zhou 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards deterministic reconfigurable networks zikai george zhou1* 1 george.zhou@tum.de, chair of communication networks technical university of munich abstract: compared with legacy networks, programmable networks are highly flexible and need to be reconfigured dynamically. in this early work paper, we study the fast and consistent network update which is the key enabler to realize deterministic reconfigurable networks. the reconfiguration speed is one side of the coin. the ongoing best-effort traffic cannot be interrupted during the network reconfiguration as well. in terms of reconfiguration speed, we implement and compare our method with the state-of-the-art decentralized and centralized update methods. keywords: reconfigurable networks, network measurements, programmable data plane with p4 1 introduction communication networks have become a critical infrastructure and continuously increase in scale and complexity. in order to adapt the massive amount of devices and services, and to tune according to policy, networks are required to be re-configured or updated dynamically. the approach of centrally controlling networks can prevent many oscillations brought by distributed route computation [jlg+14]. meanwhile, since the update schedule is computed at the centralized controller, it also brought multiple challenges when updating the network. the first challenge is how to roll out updates efficiently and correctly. the efficiency is to realize shortest update time. the correctness is to maintain consistency properties e.g., blackholefreedom, loop-freedom, and congestion-freedom during the update [fsv19]. however, operators commonly have to make a trade-off between these two goals. even worse, if the controller has an inconsistent view to the network or inaccurate state of the data plane, the consistency properties during update could be violated e.g., forwarding loop or link congestion. the second challenge is to ensure that deterministic transmission should not be violated during the update, especially for those time-triggered networks such as industrial control networks and industrial internet of things (iiot). the deterministic transmission reflects in predictable endto-end latency [vdz+19] and bounded number of frame loss [lwp+19]. to make the update time short, we propose and implement a p4update framework which make the data plane update fast and provably consistent. a local verification scheme is proposed to solve the first challenge with the help of programmable data plane with p4 [bdg+14]. the data plane state such as graph information maintained by the controller is pushed to and temporarily stored by programmable switches. probe packets carrying the real-time data plane ∗ 1 / 5 volume 080 (2021) towards deterministic reconfigurable networks state are used to compare with the controller’s view. the data plane update is triggered by the verification result. to demonstrate the update efficiency, we emulate our approach and compare with a decentralized update scheme ez-segway which showcases the bottleneck of update speed [ncc17]. we prove that our approach maintains the consistency without the interactions with the centralized controller during the update. before solving the second challenge, we study and measure the predictability of static network performance. in particular, we build a testbed setup with nic in the end stations and time sensitive networking (tsn) evaluation switches as the intermediate nodes. both the application to application layer delay and the nic to nic delay are measured. 2 motivation software-defined network (sdn) has brought tremendous benefits, such as high performance in throughput, high utilization, and high data plane availability [fgh+21]. due to the limitations of adopting new protocols, programmable data plane (pdp) has been born and evolved continuously [hhm+21]. on one hand, programmable networks has shown great flexibility through centrally managing the networks [hab+19]. on the other hand, some common challenges occur during reconfiguring the network, such as consistency properties violation and un-deterministic real-time quality of service (qos), service level agreement (sla) violation [fsv19]. solving these challenges became necessary especially when many networks exist in a constant state of change. operators of isp must update the data plane state frequently independent of their optimization goal [jlg+14]. the dynamic behavior of iiot requires the time-triggered schedules in tsn to adapt to dynamic updates while maintaining the strict latency requirements [lwp+19]. to meet these requirements and solve these challenges in reconfigurable networks, we must firstly know what is going on in the current networks. often network measurements are the fundamental tasks of network control and management. the operators need to measure network performance continuously to ensure qos to their customers [yrs15]. moreover, they also need to troubleshoot their network in case there are some failures or misconfigurations [hhj+14]. along the timeline, the network measurements could be classified into traditional network measurements, software-defined network measurements and emerging network telemetry. traditional network measurements have been widely used in the network management due to ease of deployment, but it lacks of accuracy and affects the network state [mor16]. with the emergence v0 v4 v2 v7 v1 v6v5 v3 v0 v4 v2 v7 v1 v6v5 v3 figure 1: illustration of sland dl-p4update. the blue line represents the update in slp4update and the green lines show the dl-p4update segmentation. netsys 2021 2 / 5 eceasst of sdn and pdp, some software-defined measurement schemes have been proposed which improves measurement openness and transparency [yls+15]. network telemetry was becoming a popular technology to make fine-grained measurements to the current network state [yu19]. 3 towards consistent network updates in programmable networks with p4 when implementing network updates, operators commonly choose a trade-off between update speed and consistency. in order to ensure the consistency properties, probe packets are generated at the data plane to provide two functions. the first one is to coordinate between data plane. the figure 1 is used to demonstrate the coordination process. the network flows are segmented according to the old (solid line) and new routing paths (dashed line). in most update scenarios in which the old and new paths are disjoint, we adopt the single-layer (sl) approach. v 7 is the egress node, using the sl approach, the probe packets are sent back from v 7 to v 0 along the blue line. the main idea is to avoid complicated coordination procedures. in order to improve the update speed, we design a duallayer update mechanism. the dual-layer (dl) approach is applied to complicated scenario which could implement parallel updates of multiple segments. using the dl approach, v 0 to v 2 and v 4 to v 7 are two forwarding segments which could be updated in parallel. v0 v1 v2 v3 dn v 3 1 1 1 2 1 0 1 (a) no inconsistencies. v0 v1 v2 v3 dn v 2 1 2 1 (b) erroneous distance. figure 2: verifying update consistency, where the probe packets are forwarded via v3,v1,v2,v0 to update from the solid old path to the dashed new path. scenario (a) shows a successful update without inconsistency issues, whereas (b) shows one example with inconsistent update information. the second one is to verify the consistency between centralized controller and data plane state. the figure 2 is used to demonstrate the verification process. the routing configuration version and distance of each node to the destination are stored in the probe packets. for example, the version of solid and dashed path is 1 and 2 separately. the distance of v 3,v 1,v 2,v 0 is 0,1,2,3 separately. from controller’s perspective, if v 2 contains the same distance as v 1 in figure 2b, blackhole or loop could occur. to demonstrate the update speed, we implement two approaches of p4update and ez-segway using p4 and evaluate using bmv2 switch target [con16] in typologies of b4 and internet2. the centralized update method is used as the baseline. we measure the total update time of a single 3 / 5 volume 080 (2021) towards deterministic reconfigurable networks 500 600 700 800 900 update time [ms] 0.0 0.5 1.0 cd f central ez-segway dl-p4update sl-p4update (a) b4. 300 350 400 450 500 update time [ms] 0.0 0.5 1.0 cd f central ez-segway dl-p4update sl-p4update (b) internet2. figure 3: total update time cdf flow which is from the timestamp the controller sending the new configuration to the timestamp the controller receiving the last update finish notification. the total update time of dl-p4update is 15% and 14% less than the ez-segway. the reason is that dl-p4update involves fewer rounds of communication with controller and involve higher degrees of parallelism. 4 future work and outlook the reconfiguration mechanisms should be considered to adapt into the programmable hardware. the main challenge is about the hardware limitations, such as limited access times of stateful objects. moreover, more measurement studies during the reconfiguration are considered to be done. but gathering and understanding the real-time data plane state is not trivial. moreover, today’s network measurement mechanisms are mostly done for offline analysis. using online network measurement techniques to help ensure the stable performance during the network reconfiguration is also unknown. as a long-term goal, a closed-loop measurement, verification and control knob for reconfigurable networks is treated as the working direction. references [bdg+14] p. bosshart, d. daly, g. gibb, m. izzard, n. mckeown, j. rexford, c. schlesinger, d. talayco, a. vahdat, g. varghese et al. p4: programming protocol-independent packet processors. acm sigcomm computer communication review 44(3):87– 95, 2014. [con16] t. p. l. consortium. p4 behavioral-model. https://github.com/p4lang/ behavioral-model/, 2016. [fgh+21] a. d. ferguson, s. gribble, c.-y. hong, c. e. killian, w. mohsin, h. muehe, j. ong, l. poutievski, a. singh, l. vicisano et al. orion: google’s softwaredefined networking control plane. in nsdi. pp. 83–98. 2021. netsys 2021 4 / 5 https://github.com/p4lang/behavioral-model/ https://github.com/p4lang/behavioral-model/ eceasst [fsv19] k. foerster, s. schmid, s. vissicchio. survey of consistent software-defined network updates. ieee communications surveys & tutorials 21(2):1435–1461, 2019. [hab+19] m. he, a. m. alba, a. basta, a. blenk, w. kellerer. flexibility in softwarized networks: classifications and research challenges. ieee communications surveys & tutorials, 2019. [hhj+14] n. handigol, b. heller, v. jeyakumar, d. mazières, n. mckeown. i know what your packet did last hop: using packet histories to troubleshoot networks. in 11th {usenix} symposium on networked systems design and implementation ({nsdi} 14). pp. 71–85. 2014. [hhm+21] f. hauser, m. häberle, d. merling, s. lindner, v. gurevich, f. zeiger, r. frank, m. menth. a survey on data plane programming with p4: fundamentals, advances, and applied research. arxiv preprint arxiv:2101.10632, 2021. [jlg+14] x. jin, h. h. liu, r. gandhi, s. kandula, r. mahajan, m. zhang, j. rexford, r. wattenhofer. dynamic scheduling of network updates. in sigcomm. pp. 539– 550. acm, 2014. [lwp+19] z. li, h. wan, z. pang, q. chen, y. deng, x. zhao, y. gao, x. song, m. gu. an enhanced reconfiguration for deterministic transmission in time-triggered networks. ieee/acm transactions on networking 27(3):1124–1137, 2019. [mor16] a. morton. active and passive metrics and methods (with hybrid types inbetween). rfc 7799, may 2016. doi:10.17487/rfc7799 https://rfc-editor.org/rfc/rfc7799.txt [ncc17] t. d. nguyen, m. chiesa, m. canini. decentralized consistent updates in sdn. in proceedings of the 2017 acm symposium on sdn research (sosr). pp. 21–33. 2017. [vdz+19] a. van bemten, n. derić, j. zerwas, a. blenk, s. schmid, w. kellerer. loko: predictable latency in small networks. in proceedings of the 15th international conference on emerging networking experiments and technologies. pp. 355–369. 2019. [yls+15] c. yu, c. lumezanu, a. sharma, q. xu, g. jiang, h. v. madhyastha. softwaredefined latency monitoring in data center networks. in international conference on passive and active network measurement. pp. 360–372. 2015. [yrs15] a. yassine, h. rahimi, s. shirmohammadi. software defined network traffic measurement: current trends and challenges. ieee instrumentation & measurement magazine 18(2):42–50, 2015. [yu19] m. yu. network telemetry: towards a top-down approach. acm sigcomm computer communication review 49(1):11–17, 2019. 5 / 5 volume 080 (2021) http://dx.doi.org/10.17487/rfc7799 https://rfc-editor.org/rfc/rfc7799.txt introduction motivation towards consistent network updates in programmable networks with p4 future work and outlook askthecode: interactive call graph exploration for error fixing and prevention electronic communications of the easst volume 77 (2019) interactive workshop on the industrial application of verification and testing, etaps 2019 workshop (interavt 2019) askthecode: interactive call graph exploration for error fixing and prevention robert husák, jan kofroň and filip zavoral 6 pages guest editors: anila mjeda, stylianos basagiannis, goetz botterweck eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst askthecode: interactive call graph exploration for error fixing and prevention robert husák1, jan kofroň2 and filip zavoral3 1 husak@ksi.mff.cuni.cz 2 jan.kofron@d3s.mff.cuni.cz 3 zavoral@ksi.mff.cuni.cz charles university faculty of mathematics and physics, prague, czech republic abstract: in order to prevent and fix errors in program code, developers need to understand its semantics to a significant extent. for this purpose, they use various approaches, such as manual call graph exploration or dynamic analysis with a debugger. however, these techniques tend to be cumbersome in a larger codebase, because they provide either underapproximate or overapproximate results and it is often hard to combine them. therefore, we present askthecode, a microsoft visual studio extension enabling to interactively explore a call graph, ensuring that only feasible execution traces are taken into consideration. askthecode is based on control flow analysis and backward symbolic execution. we show its potential to significantly improve developers’ experience on a complex code example. keywords: control flow analysis, symbolic execution, call graph, interactive, debugging 1 introduction when developers want to fix and prevent errors by understanding the semantics of the source code, they usually use manual call graph exploration and debugging. however, call graphs are often complicated and the calls can be constrained by various conditions. debugging, on the other hand, might be misleading and incapable of capturing all the possible situations. therefore, finding the exact context under which a bug can occur is tedious and error-prone [lm10]. we believe there is an opportunity to utilize a sound analysis technique for this task, for several reasons. first, the context is usually much more limited than in the case when we try to verify the program as a whole. second, the developers might be more willing to wait long enough for the analysis to complete, because it may save much more time to them than if they wanted to do it manually. last, even if the problem is too complicated to be handled properly in a reasonable time, developers can interact with the tool, applying appropriate abstractions and assumptions. therefore, we have created a tool named askthecode, which utilizes control flow analysis and backward symbolic execution to help developers investigate particular problems in the source code. 1 / 6 volume 77 (2019) mailto:husak@ksi.mff.cuni.cz mailto:jan.kofron@d3s.mff.cuni.cz mailto:zavoral@ksi.mff.cuni.cz askthecode: interactive call graph exploration for error fixing and prevention 2 design the primary purpose of askthecode is to reason about the context under which a certain situation in a program can occur. therefore, an efficient way to formulate what problem we need to address is writing an assertion a0 specifying the expected semantics and check in which situations it can be violated. notice that this approach is suitable not only for bug fixing, but also for their prevention, because developers can use the tool to confirm their possibly incorrect ideas about the program semantics. to verify an assertion, a natural approach is to inspect the code against the control flow and look for any input that eventually violates it. because askthecode is a microsoft visual studio extension aimed at c# code analysis, it can access the roslyn .net compiler [nh14]. we use it to construct control flow graphs and the call graph of the methods related to the problem being solved. next, we utilize backward symbolic execution [bcd+18, cfs09] to perform the assertion verification itself, employing the z3 smt solver [db08]. depending on the user configuration, an entry point is either a non-private method in the same class as where a0 occurs, or a public method in a public class within the project. to tackle path explosion and other symbolic execution problems, users can also adjust loop unwinding, recursion limit, and timeout. all the execution traces from entry points to violating a0 are continuously gathered during the run of backward symbolic execution. we provide users with a panel allowing them to interactively explore those traces as if they were a program under execution. they can step forward and backward throughout the particular methods and statements and see their intermediate values. furthermore, they can also inspect the relevant heap structure and its changes. there is also a high-level overview in the form of an annotated call graph, rendered using the microsoft automatic graph layout library [nnb+16]. the graph is continuously updated as backward symbolic execution runs on background. at the beginning, it consists only of the method m0 containing a0, but then it expands as the explored states extend to the callers and callees of m0. whenever an execution trace is discovered, all the methods it traverses are emphasized in red to draw the user’s attention. on the other hand, if there are not any states capable of extending to a method mu, we mark mu as unreachable by making its background green. the user can also explicitly ignore certain methods, letting the analysis focus on less complicated ones. 3 example to demonstrate how can askthecode help developers, let us inspect the code example in figure 1. it presents an excerpt from a library working with singly linked lists. they are represented by the node class containing an integer field val and a reference to the following node called next. due to a certain implementation issue, it is demanded that whenever a node is last in a list, its value must be zero. in lastnode, we check this property using an assertion. imagine that we have received a bug report stating that this property is sometimes violated, but we were not given any exact context under which it can happen. the most common approaches to solving these tasks are manual call graph exploration and debugging, both of which can be problematic in certain situations. manual call graph exploration interavt 2019 2 / 6 eceasst private bool lastnode(node n) { debug.assert(n.next != null || n.val == 0); return n.next == null; } public void checkeduse(node n) { if (n.val == 0 && lastnode(n)) { /*...*/ } } public node uncheckeduse(node n) { node gen = randomnode(); if (lastnode(gen)) { gen.next = n; } return gen; } private node randomnode() { int v = getrandomnumber(); if (v == 0) return new node(0, null); if (v == 1) return new node(10, null); return toocomplicatedoperation(); } figure 1: example c# code with an assertion in lastnode to be verified requires us to inspect the logic of each affected method to ensure the situation is handled in there. in our example, we need to inspect checkeduse, although it never allows the error to happen. debugging, on the other hand, reveals only the situations which can indeed cause the error being inspected. however, it might be often difficult to reproduce the error and we cannot be sure that we have discovered all the contexts under which it can occur. furthermore, the information provided by the debugger is limited. considering our example, after reproducing the error and pausing the program execution on the violated assertion, we can see uncheckeduse in the call stack. however, we cannot see what exactly happened in the call of randomnode, because we no longer know the indeterministic value v and hence the executed branch. the mentioned problems can be solved using askthecode, as we can see in figure 2. the call graph displayed in the top right panel shows that lastnode is called both by checkeduse and uncheckeduse. checkeduse is displayed with a green background and dashed arrow, as it is proven not to cause the error. on the other hand, uncheckeduse is emphasized in red together with its callees randomnode, getrandomnumber and the node constructor, as there was found an assertion violating program trace going through them. randomnode can also potentially call another method, toocomplicatedoperation, whose definition we have intentionally skipped. as we can tell from its name, it was too complicated for backward symbolic execution to handle automatically. therefore, as it is shown in the call graph, we at least know that it is worth to be inspected manually, unlike checkeduse. regarding the found trace, we can explore it in the bottom panel by inspecting its call tree and the particular statements. whenever we select a statement in the table, the appropriate piece of code is selected in the opened code editor in the top left part. furthermore, there is a replay panel on the right in which we can see the contents of the heap and of all the local variables at the given step of the trace. on its bottom, there are buttons to navigate through the trace in a debugger-like fashion, with the added capability of stepping backward in the history. from the trace, we can now easily discover that at least one of the problematic situations happens when v in randomnode is 1. 3 / 6 volume 77 (2019) askthecode: interactive call graph exploration for error fixing and prevention figure 2: askthecode in microsoft visual studio 2017 4 related work in the field of human interface design, there are numerous tools helping developers to understand the semantics of the code [sbm17, dr10]. probably the closest one to our approach is reacher [lm11], a tool to interactively and intuitively explore complex call graphs. however, these tools do not reason about reachable paths as soundly as symbolic execution. furthermore, they are not directly aimed at verifying assertions, hence no production of error traces. on the other hand, to discover erroneous program inputs, we can use symbolic execution, whose current state of the art is summarized in [bcd+18]. most of these techniques analyse a program by systematically exploring its state space from various entry points in a forward fashion, aiming for high code coverage. in order to reason about particular assertions, we use the backward variant of symbolic execution, whose most important representative is snugglebug [cfs09]. despite its advanced capabilities used to alleviate the path explosion problem, it can still occur in practice. in such situations, snugglebug and other related tools [da14, myfh11] cannot provide sufficient information due to their lack of interactivity. interavt 2019 4 / 6 eceasst 5 conclusion on a complex example which models situations known from practice, we demonstrate that askthecode can help developers understand causes of errors. utilizing interactive approach, certain limitation of used backward symbolic execution can be alleviated, e.g. by voluntarily omitting certain problematic places or controlling loop unwinding. in the future, we plan to extend the interactivity even more, and implement more advanced features such as state merging [kkbc12] or directed call graph construction [cfs09], ultimately making askthecode production-ready. acknowledgements: this work was supported by the project progress q48, the czech science foundation project 18-17403s and the grant svv-2017-260451. bibliography [bcd+18] r. baldoni, e. coppa, d. c. d’elia, c. demetrescu, i. finocchi. a survey of symbolic execution techniques. acm computing surveys (csur) 51(3):50, 2018. doi:10.1145/3182657 [cfs09] s. chandra, s. j. fink, m. sridharan. snugglebug: a powerful approach to weakest preconditions. sigplan not. 44(6):363–374, june 2009. doi:10.1145/1543135.1542517 [da14] p. dinges, g. agha. targeted test input generation using symbolic-concrete backward execution. in 29th ieee/acm international conference on automated software engineering (ase). acm, västerås, sweden, september 15-19 2014. doi:10.1145/2642937.2642951 [db08] l. de moura, n. bjørner. z3: an efficient smt solver. in proceedings of the theory and practice of software, 14th international conference on tools and algorithms for the construction and analysis of systems. tacas’08/etaps’08, pp. 337–340. springer-verlag, berlin, heidelberg, 2008. doi:10.1007/978-3-540-78800-3 24 [dr10] r. deline, k. rowan. code canvas: zooming towards better development environments. in proceedings of the 32nd acm/ieee international conference on software engineering volume 2. volume 2, pp. 207–210. 05 2010. doi:10.1145/1810295.1810331 [kkbc12] v. kuznetsov, j. kinder, s. bucur, g. candea. efficient state merging in symbolic execution. in proceedings of the 33rd acm sigplan conference on programming language design and implementation. pldi ’12, pp. 193–204. acm, new york, ny, usa, 2012. doi:10.1145/2254064.2254088 5 / 6 volume 77 (2019) http://dx.doi.org/10.1145/3182657 http://dx.doi.org/10.1145/1543135.1542517 http://dx.doi.org/10.1145/2642937.2642951 http://dx.doi.org/10.1007/978-3-540-78800-3_24 http://dx.doi.org/10.1145/1810295.1810331 http://dx.doi.org/10.1145/2254064.2254088 askthecode: interactive call graph exploration for error fixing and prevention [lm10] t. d. latoza, b. a. myers. developers ask reachability questions. in proceedings of the 32nd acm/ieee international conference on software engineering volume 1. icse ’10, pp. 185–194. acm, new york, ny, usa, 2010. doi:10.1145/1806799.1806829 [lm11] t. d. latoza, b. a. myers. visualizing call graphs. in 2011 ieee symposium on visual languages and human-centric computing (vl/hcc). pp. 117–124. sep. 2011. doi:10.1109/vlhcc.2011.6070388 [myfh11] k. ma, k. yit phang, j. s. foster, m. hicks. directed symbolic execution. in static analysis. pp. 95–111. springer berlin heidelberg, berlin, heidelberg, 2011. doi:10.1007/978-3-642-23702-7 11 [nh14] t. neward, j. hummel. rise of roslyn. msdn 29(11):70, 2014. https://msdn.microsoft.com/en-us/magazine/dn818501.aspx [nnb+16] l. nachmanson, a. nocaj, s. bereg, l. zhang, a. holroyd. node overlap removal by growing a tree. in graph drawing and network visualization. pp. 33– 43. springer international publishing, cham, 2016. doi:10.1007/978-3-319-50106-2 3 [sbm17] j. smith, c. brown, e. murphy-hill. flower: navigating program flow in the ide. in 2017 ieee symposium on visual languages and human-centric computing (vl/hcc). pp. 19–23. 10 2017. doi:10.1109/vlhcc.2017.8103445 interavt 2019 6 / 6 http://dx.doi.org/10.1145/1806799.1806829 http://dx.doi.org/10.1109/vlhcc.2011.6070388 http://dx.doi.org/10.1007/978-3-642-23702-7_11 https://msdn.microsoft.com/en-us/magazine/dn818501.aspx http://dx.doi.org/10.1007/978-3-319-50106-2_3 http://dx.doi.org/10.1109/vlhcc.2017.8103445 introduction design example related work conclusion microsoft word silvafitzgerald_ interavt2020_cr.doc electronic communications of the easst volume 079 (2020) guest editors: stylianos basagiannis, goetz botterweck, anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 interactive workshop on the industrial application of verification and testing etaps 2020 workshop (interavt 2020) parsing bdd stories for automated verification of software artefacts thiago rocha silva and brian fitzgerald 8 pages eceasst 2 / 9 volume 079 (2020) parsing bdd stories for automated verification of software artefacts thiago rocha silva, brian fitzgerald lero the irish software research centre university of limerick (ul) limerick, ireland. {thiago.silva,brian.fitzgerald}@lero.ie abstract: this position paper reports on our ongoing developments towards the automated verification of software artefacts by parsing sentences on behaviourdriven development (bdd) stories. the solution we propose is based on different strategies for analysing the consistency of user requirements specified in bdd stories on task models, graphical user interfaces (guis), gui prototypes, and domain models. we illustrate our solution through concrete examples and discuss its challenges and limitations. keywords: behaviour-driven development (bdd), user requirements assessment, software artefacts, automated verification. 1 introduction in recent years, user stories [1] have been widely adopted, especially by agile methods, as an artefact allowing to specify user requirements in a simple, understandable, but yet automatable semi-structured natural language favouring effective communication between the different stakeholders. the use of scenarios in user stories additionally provides, in a single artefact, the requirements specification along with the set of acceptance criteria which is required to assess whether the system behaves in accordance with such requirements. this strategy has been explored by agile methodologies such as behaviour-driven development (bdd) which gave rise to a particular instance of user stories, the so-called bdd stories [2]. title (one line describing the story) narrative: as a [role], i want [feature], so that [benefit] scenario n: [title] given [context], when [event], then [outcome] fig. 1. “bdd story” template [3]. a bdd story (figure 1) is described with a title, a narrative and a set of scenarios representing the acceptance criteria. the title provides a general description of the story, referring to a feature this story represents. the narrative describes the referred feature in terms of the role that will benefit from the feature, the feature itself, and the benefit it will bring to the business. the acceptance criteria are defined through a set of scenarios, each one with a title and three main clauses: “given” to provide preconditions for the scenario, “when” to describe an event that will trigger the scenario and “then” to present outcomes that might be checked to verify the proper behaviour of the system. each one of these clauses can include an “and” statement parsing bdd stories for automated verification of software artefacts interavt 2020 3 / 9 to provide multiple contexts, events and/or outcomes. each statement in this representation is called “step”. by specifying the system’s expected behaviour through the use of examples, bdd stories carry important information about the system’s domain and about how the user is expected to interact with this system. this position paper reports on our developments towards a toolsupported approach to parse these bdd stories and gather information to be automatically verified and assessed on different software artefacts in order to ensure consistency between them. our motivation for this work resides in the fact that manual verification and software inspections are still the first approaches to verify the consistency between user requirements and such artefacts [4], although manually ensuring the consistency of software specification and its artefacts every time a requirement is introduced and/or modified is extremely timeconsuming and highly error-prone. promoting automated verification is, therefore, a key factor to support assessment in an ever-changing environment. to achieve this goal, we rely on a previously developed ontology for describing common interactive behaviours on bdd stories [5], [6] which is currently used to support the assessment of user interface design artefacts (task models, gui prototypes and web guis). we have been working on an extension of this approach to also cover the assessment of domain models, such as class diagrams. the final solution is expected to be integrated as an eclipse plugin which would allow both the specification of the bdd stories and the upload of the respective artefacts being considered for assessment. that would allow a more straightforward integration with other eclipse-based modelling tools. the next sections of this paper briefly illustrate, through concrete examples, the solution we propose for assessment on the different covered artefacts, besides discussing its challenges and limitations. 2 automated verification of software artefacts the strategy we propose for automated verification of software artefacts [7] has been evolving since 2016 [8]–[11] and is based on an analysis, with the support of an ontology, of different elements specified in the bdd stories’ sentences depending on the artefacts being considered for assessment. figure 2 illustrates the direct relationship between different elements from the bdd stories and the specific elements we verify in the targeted artefacts. in the example, a scenario for successfully withdrawing money from a current account is presented as a user requirement. the scenario states, in the user’s point of view and by means of an example, the resultant effect of withdrawing a certain amount of money. in the figure, the domain-specific behaviour “withdraw” is being detailed in the 5 interaction steps required to effectively conclude the respective action on the user interface of a given system. thus, to complete the action of withdrawing money in a web system, for example, the user needs to reach the interface in which the transaction types are enlisted, select that he wants to withdraw money, select the current account as the type of account, inform the amount he wants to withdraw, and finally validate the operation by clicking on a button. taking the example presented in figure 2, from the domain-specific behaviours “given my balance is $1000” and “then my new balance will be $900”, balance can be identified as an attribute of the class account, and from the behaviour “when i withdraw $100”, withdraw can be identified as an operation of the class account. the set of interaction steps provides more information to be assessed on the other artefacts. for the first one (“when i go to ‘transaction eceasst 4 / 9 volume 079 (2020) type’”), transaction can be identified as a class, and type as an attribute. for this step, a corresponding task can also be identified in the task model (“go to transaction type”), as well as the interaction element browser window in the gui. for the second step (“and i select ‘withdraw money’”), withdraw can be identified as an operation of the class account, and money as the argument passed when calling it. a corresponding task can also be identified in the task model (“select withdraw money”), as well as the interaction element vertical tabs in the gui. the other steps can be analysed in a similar manner. the identification of useful elements for assessment on each targeted artefact is discussed hereafter. fig. 2. tracing the elements from the steps to check the consistency with different artefacts. task models. task models (tm) provide a goal-oriented description of interactive systems. tasks can be specified at various abstraction levels, describing an activity that has to be carried out to fulfil the user’s goals [12]. by manipulating task models, we can obtain scenarios that represent the valid interaction paths in the system. this characteristic is particularly useful when identifying test scenarios for the system. step of scenario task name when i set “valid departure date” in the field “departure date” set departure date fig. 3. formatting rule for assessing interaction steps and tasks. for assessing task models, we propose a sentence analysis of each interaction step (covered by the ontology) in the bdd stories following a pattern to identify potential tasks to be verified in the model. as task models are designed to support the multiple paths that users may accomplish to perform their tasks, assessing such models involves initially extracting the possible scenarios that are supposed to be tested. the equivalence of steps in bdd stories and tasks in scenarios extracted from task models is supported by the aforementioned ontology which encompasses a formatting rule as exemplified in figure 3. our tool applies such a rule parsing bdd stories for automated verification of software artefacts interavt 2020 5 / 9 in order to verify whether a behaviour described in a step has an equivalent task to model it in the task model. this rule aims to eliminate unnecessary components of the step that do not need to be present in the task name. in the example, the component “when” refers to the transition in the state machine which is not addressed in a task model. the subject “i” signalizes that is the user who performs the task. tasks models encompass the definition of user role, so the statement “i” refers to any users that might correspond to the role assigned to the task model. the verb “set” indicates the action that will be performed by the user, so it begins naming the task in the task model. the value “valid departure date” indicates the test data domain that will be used to perform and test the task (in this example, any valid value for a departure date of a flight). this is an information which is not present in the task name. the sentence complement “in the field” just signalizes that an interaction element (a “field”) will be referenced in the sequence. finally, the target field “departure date” indicates the name of the interaction element that will be affected by this task, so it composes the final name of the task to be assessed on the task model. after getting the name of the task to be assessed, we search for that task in the set of scenarios extracted from the task models and if it is found, we evaluate the position in which it has been found in the tm scenario comparing to the position of the corresponding step in the bdd scenario. thus, we consider there is an inconsistency when (i) we do not find a corresponding task in the tm scenario to match the name of the corresponding step in the bdd scenario; or (ii) we find a corresponding task in the tm scenario but at a different position of the corresponding step in the bdd scenario. graphical user interfaces (guis) and gui prototypes. a gui prototype is an early representation of a user interface. prototypes are often used in an iterative design process where they are refined and become more and more close to the final gui through the identification of user needs and constraints. by running simulations on prototypes, we can determine and evaluate potential scenarios that users can perform in the system [13]. fullfledged gui versions are the source for acceptance testing and are used by users and other stakeholders to assert whether or not features can be considered as done. for assessing guis (both prototype and final versions), we propose a sentence analysis of each interactive step (covered by the ontology) in the bdd stories identifying (i) the interactive behaviour specified, and (ii) the affected interaction element. each step is analysed as follows: fig. 4. structure of an interactive behaviour as specified in the ontology. an extensive set of interactive behaviours is modelled in the ontology describing how users are supposed to interact with the systems whilst manipulating graphical elements of the gui. an example of behaviour specification is illustrated by figure 4. the specification of behaviours encompasses when the interaction can be performed (using “given”, “when” eceasst 6 / 9 volume 079 (2020) and/or “then” clauses – which corresponds to the context-event-action elements of a state machine), and which graphical interaction elements can be affected. altogether, behaviours and interaction elements are used to implement the test of an expected system behaviour. in the example presented in the figure, the step “i choose ‘’ referring to ‘’” manipulates a “”, which is associated with some test data; and a “”, which refers to the interaction element supported by this behaviour, i.e., in this case, a radio button, a checkbox, a calendar, or a link. thus, we consider there is an inconsistency when steps are specified using interactive behaviours that are semantically inconsistent with the affected interaction element on the gui, such as a selection to be made on a button, for example. domain models. a domain model is a visual representation of conceptual classes or realworld objects in a domain of interest [14]. class diagrams are among the widest used type of domain models in software engineering. it describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects [15]. our strategy for assessing class diagrams as domain models is based on parsing the sentences of a bdd story trying to semantically identify elements that should be present in a class diagram. for that, we follow existing heuristics proposed by different works in the literature on natural language processing for requirements engineering and software modelling. table 1. heuristics for parsing natural language requirements (adapted from lucassen et al. [16]) rule head (if) rule tail (then) entities noun potential entity common noun entity sentence subject entity compound noun take compound together to form entity gerund entity non-hierarchical relationships verb potential relationship transitive verb relationship verb (phrase) linking the subject and an object relationship verb followed by preposition relationship including preposition noun–noun compound non-hierarchical relationship between prefix and compound hierarchical relationships verb “to be” subjects are children of parent object head of noun–noun compound is-a relationship between compound and head rule head (if) rule tail (then) attributes adjective attribute of noun phrase main adverb modifying a verb relationship attribute possessive apostrophe entity attribute genitive case entity attribute verb ‘‘to have’’ entity attribute specific indicators (e.g., “number”, “date”, “type”, ...) entity attribute object of numeric/algebraic operation entity attribute cardinality singular noun (+definite article) exactly 1 indefinite article exactly 1 part in the form “more than x” x..* indicators many, each, all, every, some, any ??..* most of these works rely on stanford parser [17] and wordnet [18]. the stanford parser parses sentences in different languages and returns a phrase structure tree (pst) representing the semantic structure of the sentence. wordnet is a large lexical database of english which parsing bdd stories for automated verification of software artefacts interavt 2020 7 / 9 groups nouns, verbs, adjectives, and adverbs into sets of cognitive synonyms, each representing a lexicalized concept. by using these tools, soeken et al. [19] propose a specific set of heuristics for bdd stories in order to identify class diagram elements by parsing their sentences. the authors claim that (i) regular nouns in sentences usually are realized as objects in the system, and therefore, they can be represented by classes; (ii) adjectives usually provide further information about the respective objects. thus, they can be represented by attributes of classes; and (iii) verbs usually describe actions in a scenario and can therefore be represented by operations of classes. additionally, they provide information about when an operation is called and by whom. other authors have provided more refined heuristics to identify conceptual elements from general requirements in natural language. a comprehensive list of these heuristics is presented in table 1 adapted from lucassen et al. [16]. we are currently analysing such heuristics to identify to which extent they fully apply for parsing bdd stories as well. we are also investigating the tools visual narrator [16] and redomex [20] which apply a given subset of these heuristics to generate models. visual narrator generates an ontology as a conceptual model from ordinary user stories, and redomex generates a class diagram as a domain model from, according to the authors, unrestricted natural language requirements. after identifying the conceptual elements, the idea is to point out an inconsistency whenever such elements cannot be found in the class diagrams under assessment. 3 challenges and conclusions we have conducted preliminary case studies with this approach using task models [21], gui prototypes [22] and final guis [23]. below, we summarize the main challenges, limitations and lessons we have learned so far. comprehension of bdd stories. as this approach is expected to benefit a wide range of stakeholders involved with software requirements, verification and testing, one of the main challenges is to ensure that bdd stories are well understood and effectively used by the different stakeholders involved in the project. in a previous study [24], we have preliminary evaluated (i) the comprehension of the bdd story template by potential product owners (pos), and (ii) their ability to effectively use the set of predefined interactive behaviours to specify their own user requirements. although the participants have followed different specification strategies, we observed an overall high level of adherence to the proposed set of interactive behaviours. the results also pointed out a wide use of domain-dependent behaviours, with the interactive behaviours defined by the ontology being, to some extent, reproduced by the participants even without prior training in the adopted vocabulary. further studies, however, are still needed to evaluate how useful the proposed vocabulary is to specify user requirements for real software projects in industry involving different stakeholders. relevance of artefact maintenance. this approach benefits from the independence for assessing artefacts, i.e. the assessment can be conducted in an independent manner, for example, only in a subset of the artefacts under development or being considered at a given time. in theory, the approach is also well suited to run within any macro software development process, but the maintenance and evolution of the targeted artefacts must make sense in the context of the project. we acknowledge that for some projects, especially in the agile context, artefacts resultant from modelling activities are only used to clarify and agree upon a common understanding of user requirements and are not kept or evolved in practice. naturally, for these cases, this approach has limited value. eceasst 8 / 9 volume 079 (2020) flexibility and artefact coverage. so far, we are only covering the assessment of task models modelled with the hamsters1 notation and tool, gui prototypes designed with the balsamiq2 tool, and web guis developed under whatever technology for the presentation layer. the approach, however, is domain-independent, i.e. the interactive behaviours described in the ontology (such as clicks, selections, etc.) are the same regardless of the software business domain, and the architecture is flexible enough to accommodate new notations and tools in the future. a limitation is that even with the ontology mapping synonyms for some specific behaviours, it does not provide any kind of semantic interpretation, i.e. the behaviours must be specified exactly as they were defined. at first glance, nonetheless, the restricted vocabulary seems to bring less flexibility to designers, testers, and requirements engineers, but at the same time, it establishes a common vocabulary, avoiding the typical problems of miscommunication, ambiguity, and incompleteness in requirements and testing specifications. variety of inconsistencies identified. we identified a wide range of inconsistency problems when running the approach in preliminary case studies. while simple inconsistencies such as differences in names of tasks and fields are easy to be solved, conflicts between specification and modelling along with different specification strategies for task models compose a more critical group of problems and must be prioritized. concerning the guis, the presence of semantically inconsistent elements, the presence of more than one element to represent the same field, and fields already filled-in on web guis are also critical groups of problems and denotates inconsistencies that exposes important design errors. finally, we are still working on case studies to evaluate our strategy for assessing domain models. acknowledgments this work was supported with the financial support of the science foundation ireland grant 13/rc/2094 and has also received funding from the european union’s horizon 2020 research and innovation programme under the marie skłodowska-curie grant agreement no 754489. references [1] m. cohn, user stories applied for agile software development. addison-wesley, 2004. [2] d. north, “introducing bdd,” better software, 2006. [3] d. north, “what’s in a story?,” 2019. [online]. available: https://dannorth.net/whats-in-a-story/. [4] m. chechik and j. gannon, “automatic analysis of consistency between requirements and designs,” ieee trans. softw. eng., vol. 27, no. 7, pp. 651–672, 2001, doi: 10.1109/32.935856. [5] t. r. silva, j.-l. hak, and m. winckler, “a behavior-based ontology for supporting automated assessment of interactive systems,” in proceedings ieee 11th international conference on semantic computing, icsc 2017, 2017, pp. 250–257, doi: 10.1109/icsc.2017.73. [6] t. r. silva, j.-l. hak, and m. winckler, “a formal ontology for describing interactive behaviors and supporting automated testing on user interfaces,” int. j. semant. comput., vol. 11, no. 04, pp. 513–539, 2017, doi: 10.1142/s1793351x17400219. [7] t. r. silva, m. winckler, and h. trætteberg, “extending behavior-driven development for assessing user interface design artifacts,” in proceedings of the international conference on software engineering and knowledge engineering, seke, 2019, pp. 485–488, doi: 10.18293/seke2019-054. [8] t. r. silva, j.-l. hak, and m. winckler, “an approach for multi-artifact testing through an 1 https://www.irit.fr/recherches/ics/softwares/hamsters/ 2 https://balsamiq.com parsing bdd stories for automated verification of software artefacts interavt 2020 9 / 9 ontological perspective for behavior-driven development,” complex syst. informatics model. q., no. 7, pp. 81–107, 2016, doi: 10.7250/csimq.2016-7.05. [9] t. r. silva, j.-l. hak, and m. winckler, “testing prototypes and final user interfaces through an ontological perspective for behavior-driven development,” in 6th international working conference on human-centred software engineering, and 8th international working conference on human error, safety, and system development (hcse 2016 and hessd 2016), vol. 9856, 2016, pp. 86–107. [10] t. r. silva, “definition of a behavior-driven model for requirements specification and testing of interactive systems,” in proceedings 2016 ieee 24th international requirements engineering conference, re 2016, 2016, pp. 444–449, doi: 10.1109/re.2016.12. [11] t. r. silva and m. winckler, “a scenario-based approach for checking consistency in user interface design artifacts,” in ihc’17, proceedings of the 16th brazilian symposium on human factors in computing systems, 2017, vol. 1, pp. 21–30, doi: 10.1145/3160504.3160506. [12] f. paternò, c. santoro, l. d. spano, and d. raggett, “w3c, mbui task models,” 2017. [online]. available: http://www.w3.org/tr/task-models/. [13] m. beaudouin-lafon and w. e. mackay, “prototyping tools and techniques,” in prototype development and tools, 2000, pp. 1–41. [14] c. larman, applying uml and patterns: an introduction to object-oriented analysis and design and iterative development. addison wesley professional, 2004. [15] i. jacobson, g. booch, and j. rumbaugh, the unified software development process, 1st ed. addison-wesley professional, 1999. [16] g. lucassen, m. robeer, f. dalpiaz, j. m. e. m. van der werf, and s. brinkkemper, “extracting conceptual models from user stories with visual narrator,” requir. eng., vol. 22, no. 3, pp. 339– 358, 2017, doi: 10.1007/s00766-017-0270-1. [17] m.-c. de marneffe, b. maccartney, and c. d. manning, “generating typed dependency parses from phrase structure parses,” in proceedings of the fifth international conference on language resources and evaluation, lrec 2006, 2006, pp. 449–454. [18] g. a. miller, “wordnet: a lexical database for english george a. miller,” commun. acm, vol. 38, no. 11, pp. 39–41, 1995. [19] m. soeken, r. wille, and r. drechsler, “assisted behavior driven development using natural language processing,” in tools europe 2012, 2012, vol. 7304 lncs, pp. 269–287. [20] c. arora, m. sabetzadeh, l. briand, and f. zimmer, “extracting domain models from naturallanguage requirements: approach and industrial evaluation,” in proceedings 19th acm/ieee international conference on model driven engineering languages and systems, models 2016, 2016, pp. 250–260, doi: 10.1145/2976767.2976769. [21] t. r. silva, m. winckler, and h. trætteberg, “ensuring the consistency between user requirements and task models: a behavior-based automated approach,” proc. acm human comput. interact., vol. 4, no. eics, pp. 77:1–32, 2020, doi: 10.1145/3394979. [22] t. r. silva, m. winckler, and h. trætteberg, “ensuring the consistency between user requirements and gui prototypes: a behavior-based automated approach,” in proceedings of the 17th ifip tc 13 international conference on human-computer interaction – interact 2019, 2019, vol. lncs 11746, pp. 644–665, doi: 10.1007/978-3-030-29381-9_39. [23] t. r. silva, m. winckler, and h. trætteberg, “ensuring the consistency between user requirements and graphical user interfaces: a behavior-based automated approach,” in proceedings of the 19th international conference on computational science and its applications – iccsa 2019, 2019, vol. lncs 11619, pp. 616–632, doi: 10.1007/978-3-030-24289-3_46. [24] t. r. silva, m. winckler, and c. bach, “evaluating the usage of predefined interactive behaviors for writing user stories: an empirical study with potential product owners,” cogn. technol. work, may 2019, doi: 10.1007/s10111-019-00566-3. an architecture to support learning-based adaptation of persistent queries in mobile environments electronic communications of the easst volume 19 (2009) proceedings of the second international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2009) an architecture to support learning-based adaptation of persistent queries in mobile environments jamie payton, richard souvenir, and dingxiang liu 6 pages guest editors: romain rouvoy, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst an architecture to support learning-based adaptation of persistent queries in mobile environments jamie payton, richard souvenir, and dingxiang liu department of computer science university of north carolina at charlotte {payton, souvenir, dliu}@uncc.edu abstract: queries are frequently used by applications in dynamically formed mobile networks to discover and acquire information and services available in the surrounding environment. a number of inquiry strategies exist, each of which embodies an approach to disseminating a query and collecting results. the choice of inquiry strategy has different tradeoffs under different operating conditions. therefore, it is beneficial to allow a query-based application to dynamically adapt its inquiry strategy to the changing environmental conditions. to promote development by non-expert domain programmers, we can automate the decision-making process associated with adapting the inquiry strategy. in this paper, we propose an architecture to support automated adaptative query processing for dynamic mobile environments. the decision-support module of our architecture relies on an instance-based learning approach to support context-aware adaptation of the inquiry strategy. keywords: adapation, context-awareness, pervasive computing, machine learning, query processing, ad hoc network 1 introduction mobile computing devices have become more powerful, affordable, and widely available, which has led to their widespread adoption. interest in developing new applications that take advantage of connections among devices to achieve a task continues to grow. such applications would allow emergency responders carrying mobile devices to exchange information to coordinate triage activities; construction supervisors could connect to sensors to monitor and react to the presence of hazardous chemicals on a construction site; tourists could use mapping, transportation, and weather services available in the vicinity to generate an itinerary for sightseeing. these and other applications can be supported by mobile ad hoc networks, which are formed on-demand without any fixed network infrastructure, allowing for deployment at any time in virtually any location. developing applications that must acquire information and services across a highly dynamic mobile ad hoc network (manet) can be challenging. queries are a popular abstraction used to hide the complex network communication details associated with discovering and collecting distributed information. often, applications must continuously monitor for changes in information or conditions in the environment. for example, a construction supervisor’s application may monitor for the presence of a dangerous leak to ensure the safety of workers, or a tourist may wish to take advantage of any audio guide services she encounters as she wanders through a his1 / 6 volume 19 (2009) an architecture to support learning-based adaptation of persistent queries in mobile environments torical area. in such cases, a persistent query, which provides continuous reporting of relevant state changes, can support application development. employing an ideal persistent query that reports all state changes in a rapidly changing environment is expensive in terms of message overhead and resource consumption. instead, we can approximate a persistent query as a sequence of one-time queries (i.e., queries that are issued and evaluted once). the persistent query’s inquiry strategy, which defines where, when, and how one-time queries are issued, has different tradeoffs and its suitability depends on the operating conditions. therefore, the notion of an adaptive persistent query [rjpr08] has been introduced to allow the inquiry strategy to be dynamically adjusted. in previous work, the task of determining how to adapt the inquiry strategy was left to the application programmer. here, we focus on automating the process of adaptation for adaptive persistent queries to simplify the programming task. we present an architecture to support persistent query-based application development in manets. our approach to persistent query adaptation is independent of application-specific details; the adaptation decision is based on maximizing the reflection of changes in available data while minimizing the overhead associated with the query’s execution. we use an instance-based learning approach to estimate the quality of the persistent query’s result as a function of the changing state of the environment. 2 background on adaptive continuous queries researchers have begun to develop a formal framework to support expression of adaptive persistent queries and to support reasoning about their execution [rjpr08]. the framework defines a persistent query as a sequence of one-time queries. this sequence is controlled by the specification of an inquiry strategy, which defines: 1) the frequency with which one-time queries are issued, 2) the inquiry mode (i.e., the protocol used to implement a one-time query), and 3) inquiry mode parameters. to create a persistent query result, the results from the component one-time queries can be coalesced. using the formal framework as a foundation, a set of inquiry modes have been identified and formalized [rjpr09]. flooding queries are commonly used in mobile settings [ige+03, jmb01, pr99] to acquire information from all network nodes. in a flooding query, the sending node broadcasts the query to all of its one-hop neighbors; every recipient of the query will rebroadcast the query to its one-hop neighbors until the network boundary is reached. this approach can be very expensive in terms of message overhead and resource consumption [ntcs99], but yields the most information about the state of the environment. in a static network (no value or connectivity changes), successive one-time flooding queries should give exactly the same results. location-based queries operate in a similar fashion, but can reduce overhead costs by targeting a specified region of the network. probabilistic queries can also reduce overhead; a parameter is provided for query propagation to randomly select the subset of neighbors that will receive (and probabilistically propagate) the query. similarly, random sampling queries propagate the query to all one-hop neighbors but randomly select nodes to execute and reply to the query. different inquiry strategies are appropriate in different situations. for example, a construction site worker may prolong the lifetime of a network when conditions are normal by randomly sampling for safety information; if the query returns a dangerous chemical reading, a flooding proc. campus 2009 2 / 6 eceasst query is needed to acquire as much information as possible about a possible leak regardless of the cost. in the formal framework, a persistent query’s intermediate result (i.e., the coalesced history of one-time query results) can be assessed to determine the suitability of the inquiry strategy. in the framework, a persistent query’s introspection strategy is a function that defines the “quality” of the query result. adaptation of the inquiry strategy is based on the evaluation of the introspection strategy’s metric. the goal of this paper is to provide automated support for the processes involved in deciding when and how to adapt persistent queries. in section 3, we present an architecture that allows for learning a general introspection metric that minimizes the overhead associated with the query while maximizing the quality of the query result. 3 architecture description learner pc f adaptive persistent query module autoadapt learner application one-time query simulator module network simulator network node messaging sensing one-time query module discovery adaptive persistent query module appadapt autoadapt query propagator reply processor application f network node one-time query module adaptive persistent query module appadapt autoadapt query propagator reply processor application f figure 1: adaptive persistent query architecture figure 1 illustrates our architecture for supporting adaptation in persistent query processing. although omitted from the diagram, we assume every network node has low-level functions which support exchange of messages, interaction with local sensors, and maintenance of an up-to-date list of its own one-hop neighbors. the one-time query module supports an inquiry mode through the use of the appropriate conjunction of query propagation schemes implemented in the query propagator (qp) and reply processing schemes implemented in the reply processor (rp). both the qp and the rp units make use of the discovery module to send query-related messages over network links to the appropriate one-hop neighbors. applications that require knowledge about the changing state of the environment can be developed using the adaptive persistent query (apq) module; a persistent query is implemented as a series of one-time queries, which are executed by the one-time query module. applications that wish to have tight control on the conditions that trigger adaptation of a persistent query and the manner in which the inquiry strategy is adapted can specify these conditions within a code fragment that is given to the architecture and automatically deployed. the appadapt module is responsible for managing the user-specified adaptation, but is not the focus of this paper. instead, we focus on the further development of the autoadapt module, which uses a learned function f (shown as an oval) that captures the “quality” of the query result under a set of environmental conditions to automatically adapt the inquiry strategy. below, we describe how we learn the function f and how the autoadapt module uses this function to adapt a persistent query’s execution. 3.1 learning problem overview it is desirable for our persistent query (comprised of a sequence of one-time queries) to closely approximate the ideal persistent query. in other words, we want our persistent query to capture as much information as possible about the changes that occur in the environment. we could simply use an inquiry strategy with a high frequency of issue and an inquiry mode that collected infor3 / 6 volume 19 (2009) an architecture to support learning-based adaptation of persistent queries in mobile environments mation from all nodes (e.g., a flooding query), but message overhead and resource consumption is a concern in networks of mobile devices. therefore, we want to learn when and how to adapt the inquiry strategy to balance the tradeoff between the “quality” of result (i.e., how well the approximate persistent query reflects the ideal query) and the cost of the query. learner pc f adaptive persistent query module autoadapt learner application one-time query simulator module network simulator network node messaging sensing one-time query module discovery adaptive persistent query module appadapt autoadapt query propagator reply processor application f figure 2: architecture for the offline learner we frame this as a numerical optimization problem where the goal is to maximize the difference, f −αc, where f is a function that defines this “quality” value, c is the cost of execution using a particular inquiry mode, and α is a scaling constant. f(r, r∗, s), where r is the set of results (i.e., representations of responding hosts) returned by a one-time query with inquiry strategy s and r∗ is the ideal set of reachable results reachable using strategy s, is defined as |r|/|r∗| if s is a flooding strategy and |r|/(|r∗|∗ p) if s is a probabilistic strategy with probability p. that is, f represents the percent of hosts that, ideally, should have responded. in reality, however, we cannot compute r∗, and therefore we cannot compute f . so, our approach is to approximate f using the history of previous query results. it is the task of the autoadaptlearner in figure 2 to learn a function f̂ that approximates f to estimate how well we use one-time queries to implement a continuous query. to do so, we use an instance-based learning approach to learn f̂ and modify our optimization function to f̂ −αc; this allows us to learn a general function without requiring the overhead associated with an online learning approach. 3.2 learning the quality function to learn our quality function, f̂ , which is based on the history of query results, we need to define how to compute the difference between sets of results for successive one-time queries. each query collects a node’s data as well as local properties of the node at the time that the query executed. the result of the ith one-time query, ri, is a set of hosts that responded to the query. we define a host, h, as a tuple, (ι, ν, λ , ω, ε) where ι is a unique node identifier, ν is a data value, λ is the node’s location, ω is the node’s velocity, and ε is a measure of the remaining energy. our approximation of quality of the query’s execution, then, is defined as a function of the difference between the query results for ri and ri−1. as a first step, we propose simple metrics for computing the difference between successive query results; we expect that more complex metrics will be developed and can be applied using our method. in our metrics, we compare values of nodes that provided results in successively issued one-time queries. we define m as the set of nodes that contribute results both in ri and ri−1: m = {hx ∈ ri ⋂ hy ∈ ri−1 : hx.ι = hy.ι}. for each component of the host tuple (excluding the id), we use the variance of the values in m as input to f̂ . this gives us σ (νm), σ (λm), σ (ωm), and σ (εm) as parameters. in addition, we calcuate a matching score m = |m| |ri−1| which penalizes for differences between the sets of responding nodes. other measurements, such as higher-order statistics or domain-specific metrics, may prove to be useful. proc. campus 2009 4 / 6 eceasst to learn f̂ by example, we run a series of one-time queries in simulation. for each query, we compute m, σ (νm), σ (λm), σ (ωm), and σ (εm). we also compute the value of f using the “oracle” view of the network provided by the simulator. to compute the approximation f̂ , we use generalized radial basis functions (grbf) [pg90], which estimate functions of the form: f̂(~x, s) = ∑cj=1 w jφ (||~x−~z j||2) + b, where f : r 5 ∗z → r, ~x is a vector whose components are m, σ (νm), σ (λm), σ (ωm), and σ (εm), s is an inquiry strategy, b is a bias vector, w j is the real-valued weight of kernel center~z j, for j ∈ 1, 2, ...,c, and φ is a real-valued basis function. in our algorithm, we choose the gaussian function for φ : φ (r) = e−r 2/σ 2w , where σw is the average intra-center distance. the learned function f̂ is incorporated into the autoadapt module that is deployed on the network nodes. the autoadapt module makes decisions regarding how to adapt the inquiry strategy to best suit the conditions of the environment by finding an inquiry mode and frequency to maximize f̂ −αc, where c is the cost of issuing a query using a particular inquiry strategy. 4 related work query processing for streaming data has been an active area of research in the sensor networks community [ige+03, mfhh03, mfhh02], and several query processing systems provide some version of persistent queries, typically implemented as a sequence of one-time queries. previous work noted the need for adaptive persistent queries and strategies for deciding when to adapt inquiry strategies [rjpr09, rjpr08]. other work has also studied the problem of how to adapt a probabilistic persistent query’s execution [rj08] by using application-specified data quality metrics and thresholds to adapt the value of the probability parameter that influences propagation of query-related messages, while we propose the use of a machine learning algorithm to determine how to adapt the inquiry strategy. our work uses a simple set of metrics to capture the quality of a persistent query’s execution and to determine adaptation; more complex metrics, like measures of consistency [pjr07], may be appropriate. 5 conclusions and future work in this paper, we have taken a first step towards developing an architecture to support applications that use adaptive persistent queries in manets. here, we focused on automating the process of deciding when and how to adapt a persistent query to deliver results with the most suitable degree of quality given the conditions of the environment. currently, an implementation of the offline learner is in progress using the omnet++ network simulator [var], its mobility framework [lwk], and battery module extension [for] to implement and collect data about the execution of persistent queries; we apply the radial basis function implementation in the weka machine learning workbench [hdw94] to the collected data. to determine if this approach is truly useful, we plan to perform a thorough evaluation of a full implementation and will compare performance measurements to those of traditional persistent queries. future work also includes further investigation of properties of the environment that can impact the quality and cost of a persistent query’s execution, as well as more careful study of metrics that define meaningful differences between sets of query results. 5 / 6 volume 19 (2009) an architecture to support learning-based adaptation of persistent queries in mobile environments bibliography [for] a. forster. downloads web page. http://www.inf.unisi.ch/phd/foerster/downloads. html. [hdw94] g. holmes, a. donkin, i. witten. weka: a machine learning workbench. in proc. of the 2nd austrailia and new zealand conference on intelligent info. systems. 1994. [ige+03] c. intanagonwiwat, r. govindan, d. estrin, j. heideman, f. silva. directed diffusion for wireless sensor networking. ieee/acm trans. on networking 11(1):2–16, february 2003. [jmb01] d. b. johnson, d. a. maltz, j. broch. dsr: the dynamic source routing protocol for multi-hop wireless ad hoc networks. ad hoc networking 1:139–172, 2001. [lwk] m. loebbers, d. willkomm, a. koepke. the mobility framework for omnet++ web page. http://mobility-fw.sourceforge.net. [mfhh02] s. madden, m. franklin, j. hellerstein, w. hong. tag: a tiny aggregation service for ad-hoc sensor networks. acm sigops 36(si):131–146, 2002. [mfhh03] s. madden, m. franklin, j. hellerstein, w. hong. the design of an acquisitional query processor for sensor networks. in proc. of the 2003 acm sigmod int’l. conf. on management of data. pp. 491–502. 2003. [ntcs99] s.-y. ni, y.-c. tseng, y.-s. chen, j.-p. sheu. the broadcast storm problem in a mobile ad hoc network. in proc. of the 5th int’l. conf. on mobile computing and networking. pp. 151–162. 1999. [pg90] t. poggio, f. girosi. networks for approximation and learning. proceedings of the ieee 78:113–125, 1990. [pjr07] j. payton, c. julien, g.-c. roman. automatic consistency assessment for query results in dynamic environments. in proc. of esec/fse. pp. 245–254. 2007. [pr99] c. perkins, e. royer. ad hoc on-demand distance vector routing. in proc. of the ieee wkshp. on mobile computing systems and applications. february 1999. [rj08] v. rajamani, c. julien. adaptive data quality for persistent queries in sensor networks. technical report tr-utedge-2008-001, 2008. [rjpr08] v. rajamani, c. julien, j. payton, g.-c. roman. supporting adaptive persistent queries in dynamic environments. technical report tr-utedge-2008-017, 2008. [rjpr09] v. rajamani, c. julien, j. payton, g.-c. roman. inquiry and introspection for nondeterministic queries in mobile networks. in proc. of fase. may 2009. [var] a. vargas. omnet++ web page. http://www.omnetpp.org. proc. campus 2009 6 / 6 http://www.inf.unisi.ch/phd/foerster/downloads.html http://www.inf.unisi.ch/phd/foerster/downloads.html http://mobility-fw.sourceforge.net http://www.omnetpp.org introduction background on adaptive continuous queries architecture description learning problem overview learning the quality function related work conclusions and future work big red: a development environment for bigraphs electronic communications of the easst volume 61 (2013) selected revised papers from the 4th international workshop on graph computation models (gcm 2012) big red: a development environment for bigraphs alexander faithfull, gian perrone, thomas t. hildebrandt 10 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst big red: a development environment for bigraphs alexander faithfull1, gian perrone2, thomas t. hildebrandt3 1 alef@itu.dk 2 gdpe@itu.dk 3 hilde@itu.dk it university of copenhagen copenhagen, denmark abstract: we present big red, a visual editor for bigraphs and bigraphical reactive systems, based upon eclipse. the editor integrates with several existing bigraph tools to permit simulation and reachability analysis of bigraphical models. we give a brief introduction to the bigraphs formalism, and show how these concepts manifest within the tool using a small motivating example developed in big red. we go on to outline its architecture and implementation, and comment on possible future work. keywords: bigraphs, editor, reactive systems 1 introduction bigraphical reactive systems are a class of graph-rewriting systems designed to capture orthogonal notions of connectivity and locality through the use of two graph structures—a place graph, and a link graph. they were first proposed by robin milner [mil09] to address the challenges associated with modelling of ubiquitous computing applications. bigraphs have been successful in capturing the syntax and semantics of a number of well-known formalisms (e.g., π -calculus [jen06], petri nets [lm06], ccs [mil06], and many more), as well as more diverse applications such as business processes [hno06], biological systems [dk08], wireless networks [cs12], and applications for context-aware systems [bde+06]. the big red tool is a prototype editor to support the development of bigraphs and bigraphical reactive systems in a visual manner. it interfaces with existing bigraph tools such as the bigmc bigraphical model checker [pdh12] to permit the execution of models. big red aims to make bigraphs more accessible to novice users, as well as providing development support to more experienced bigraph users. bigraphs have a visual presentation that is formal and unambiguous, and one of the major benefits is the ability to present a relatively complex bigraphical model in a way that is comprehensible by non-experts. this is the motivation for the development of big red: making it easier to create and interact with bigraphs increases the applicability and utility of the formalism in more diverse application areas. below we first briefly in section 2 describe the previous efforts to implement bigraphical reactive systems. we then proceed in section 3 describing how bigraphs are expressed in big red, using a small example of a context-aware printing system, inspired by that given in [bde+06]. finally, section 4 briefly describes the implementation of the tool, and suggests ways in which it may be extended using additional modules. 1 / 10 volume 61 (2013) mailto:alef@itu.dk mailto:gdpe@itu.dk mailto:hilde@itu.dk big red 2 related work to date, bigraphical reactive systems have been largely implemented using term representations of bigraphs, such as that used in the bpltool [gdbh07], or in the bigmc model checker [pdh12]. (while the bpltool does support graphical visualisation of its results, its input can only be given textually.) while this is appropriate for bigraph experts, it presents a significant learning curve for novice users, and ignores the benefits provided by the formal graphical syntax provided by bigraphs. one of the first attempts at creating a graphical editor for bigraphs was within the bigraphspace [gre09] project in 2009, during which a prototype bigraph editor—also based upon eclipse— was developed; however, this work was never completed, and no usable editor currently exists. bigraphspace used the correspondence between the structure of bigraphs and xml documents [hno06] to provide a tuplespace-like api with which to manipulate bigraphs. 3 bigraphs in big red by example below we describe bigraphs and how to construct them within big red using an example of a bigraphical reactive system: a context-aware printing system, inspired by that given in [bde+06]. this system describes a building in which users can submit print jobs to a print spool, and then move into a room with any printer connected to that print spool, at which point the printer will complete the job. fig. 1 shows big red’s graphical and internal representations of a bigraph of this system. it contains a single print spool (shown as a heptagon) and two rooms (squares) connected by a door (the yellow link); the left room contains a printer which is linked to the print spool, and the right room contains a user (a triangle) with the identity user. the user has a print job (a circle) which has not yet been submitted to the spool. in more detail, a bigraph consists of two graphs: the place graph and the link graph (hence the name bi-graph). the place graph is a forest of labelled trees, the roots of which are indexed by integers (which milner referred to as regions). the place graph parent relationship is indicated by nesting of nodes in the graphical syntax. the example bigraph in fig. 1, with one region, uses the place graph to represent both physical nesting (rooms contain users and printers) and logical nesting (users contain their print jobs). each of the non-root nodes of the place graph is assigned a label, called its control, which is drawn from the bigraph’s signature. our example defines five controls: room (r), printer (p), spool (s), job (j) and user (u). we will use “x node” to mean a node that is labelled with the control x. the control of a node also defines the number of ports of the node, referred to as the arity of the control and provided by a function ar given as part of the signature. all controls in this example have arity 1, meaning that every node labelled with a control has a single port. each port is mapped to a name, which can be thought of as an attribute of a node. names can either be global or local to a bigraph. a global name is represented by placing the name in the set of so-called outer names of the bigraph, and providing a link to that name from every port to which it is assigned. the example bigraph has a single global name, user, representing the (globally accessible) identity of the user. a local name is simply represented by providing a link to an edge from every port to which it is assigned. the example bigraph has two edges, selected revised papers from gcm 2012 2 / 10 eceasst figure 1: an example bigraph expressed in big red’s visual and xml syntaxes. one connecting the two rooms, and one connecting the printer to the spool. the links between names, ports, and edges together constitute the link graph, which can be viewed as an undirected hypergraph. a key feature of bigraphs is that they can be composed as contexts; this is facilitated in the place graph by allowing some of the leaves to be holes (also called sites by milner), which—like the roots—are indexed by integers, and in the link graph by partioning the global names into outer names and inner names. intuitively, a bigraph a with n holes is a context in which a bigraph b with n roots (regions) can be inserted, the result of which is a bigraph a◦b in which the ith hole of a is replaced by the nodes nested inside the ith region of b, so that the holes of a and roots of b are deleted. the set of inner names of bigraph a must be equal to the set of outer names of b, as each outer name of b is re-linked in the composed bigraph a◦b to the global—or local—name of a linked to the corresponding inner name. an important use of bigraphical composition is in defining the dynamic behaviour of a bigraphical reactive system as a set of reaction rules. (the reaction rules for our example system are shown in figures 2–5.) a reaction rule is a pair of bigraphs connected by an arrow from left to right, a → b. the intuition of a reaction rule is that if the left hand bigraph a matches a sub bigraph inside the bigraph s representing the system, then a reaction can occur, replacing a by b. a bigraph a matches a sub bigraph inside s if s can be decomposed as s = c◦a◦d, i.e. a placed in a context c, and a bigraph d (the parameters of the rule) placed in the holes of a, represented as indexed, shaded place graph leaf nodes. if a and b have the same hole indexes the bigraph resulting from the reaction is c◦b◦d. the reaction can only occur if none of the holes in c are nested within nodes assigned a non-active control. whether a control is active or non-active is defined in the signature and is used to restrict where reactions can occur in a system. only the room control must be active in our example; we explain why below. the constituents of a bigraph are defined formally by milner [mil09] as a 5-tuple: (v,e,ctrl, prnt,link) : 〈n,x〉→〈m,y〉 3 / 10 volume 61 (2013) big red where v is the set of nodes, e is a set of edges, ctrl : v → σ assigns controls to nodes drawn from a signature σ, prnt : n]v → v ]m is the parent map defining the place graph nesting (where n is the indexes of holes and m is the index set of regions), and link : x ]p → e ]y is the link map, where x is the set of inner names, p ={(v,i) : v ∈v ∧ i ∈ 0...ar(ctrl(v))} is the set of all ports, and y is the set of outer names. together, we refer to 〈n,x〉 as the inner interface of the bigraph and 〈m,y〉 as the outer interface. we explain the four reaction rules that define the behaviour of the context-aware printing system below. big red allows for the definition of reaction rules, but does not itself perform reactions; however, it can import from and export to the term language of the bigmc tool, which can execute reaction rules. below the graphical representations of the reaction rules, we additionally give their representation in this term language. room[a].(user[b].$3 | $1) || room[a].$2 -> room[a].$1 || room[a].($2 | user[b].$3) figure 2: the moveroom rule. fig. 2 shows the moveroom rule, which matches a user (represented by a u node), and selects any two rooms that are connected by some name a (which may be any name in common, as the context may freely rename or alias outer names). it then (in the right-hand bigraph) specifies that the user will move to the other room, leaving the contents of each room otherwise unchanged— the contents of the rooms, captured by the holes 1 and 2, and anything the user is carrying, captured by hole 3, are preserved between the left and the right hand side. we can find a match for this rule in fig. 1; the context contains the spool and two holes, and the parameters consist of the empty bigraph (captured by hole 1), the printer (captured by hole 2) and the user’s print job (captured by hole 3). fig. 3 shows the finishjob rule, which captures the idea of a printer finishing a job (by executing the actual print process), and the job is therefore removed completely from the system by this rule, disconnecting it from its associated user. (in our example system, printers are always contained in rooms, and so the context in any match of this reaction rule necessarily includes the room that contains the printer. as a consequence, the room control must be active to allow the reaction to take place.) selected revised papers from gcm 2012 4 / 10 eceasst printer[b].job[a] -> printer[b] figure 3: the finishjob rule. printer[a] | user[b].$1 || spool[a].($2 | job[b]) -> printer[a].job[b] | user[b].$1 || spool[a].$2) figure 4: the jobtoprinter rule. fig. 4 shows the jobtoprinter rule, which transfers a job from the spool to a printer (represented by a p node) that is co-located with the user associated with that job. (notice that printers may only contain one job at a time.) user[x].($1 | job[-]) || spool[y].$2 -> user[x].$1 || spool[y].($2 | job[x]) figure 5: the jobtospool rule. fig. 5 shows the jobtospool rule, which allows a print job (represented by a j node) to be transferred from a user (represented by a u node) to a spool (represented by an s node), adding an identifying link to connect users to their submitted print jobs. we can also find a match for this rule in fig. 1; the context contains a hole, the room containing the printer, and the other room containing a hole, and both the parameters consist of the empty bigraph (as neither the user nor 5 / 10 volume 61 (2013) big red the spool have any other print jobs). interested readers are referred to [mil09] for a more detailed description of bigraphs and bigraphical reactive systems. 4 implementation 4.1 architecture big red is implemented as a number of eclipse plugins, which extend the eclipse platform with additional file formats representing the objects of a bigraphical reactive system, wizards to create model files, and editors to modify them. in turn, big red defines several eclipse extension points: these allow other plugins to contribute extensions to big red, adding support for new external tools, export formats, and variants of the bigraphical model. eclipse model wrappergef big red extensions figure 6: an architectural overview of big red. as an overview of big red’s architecture, fig. 6 gives its dependency graph. circles represent plugins, and rectangles represent groups of plugins: those with dashed outlines are part of the eclipse platform, while those with solid outlines make up big red. most of big red’s dependencies are simply parts of the basic eclipse platform—the user interface and the workspace and resource management code. support for building modelling tools is added by the graphical editor framework (gef), a specialised toolkit for implementing model-view-controller-based editors; big red’s bigraph and reaction rule editors are both built on top of this component. (the other contributions to the ui are made using jface and swt, both standard eclipse components.) quite apart from its specific support for modelling tools, eclipse is a very portable and widelyused platform with an active community and many pre-built features, which makes it an ideal choice for the rapid development of an editor. independent but integrated. the implementation of the bigraphical model is actually split between two plugins. the bigraphical model itself (and all of its supporting infrastructure) is not a true eclipse plugin—it has no dependencies upon eclipse, contributes no extensions, and selected revised papers from gcm 2012 6 / 10 eceasst exposes no extension points, and so it can also be used outside of the eclipse platform. this plugin also implements the extensibility mechanisms, but it does not expose them as extension points—this is the job of the second plugin, which wraps those mechanisms in eclipse concepts. 4.2 the user interface big red uses two different eclipse components to construct its contributions to the user interface: swt and gef. the bigraph editor, which uses gef, and the signature editor, which uses swt and jface, have been chosen as representative examples of both technologies, and are presented below. figure 7: big red’s bigraph editor. big red’s bigraph editor, shown in fig. 7, is essentially a structured vector graphics editor. the palette on the left provides the tools that can be used to modify the model—for example, the ‘link’ tool can be used to connect points and links, and the ‘room’ tool can be used to create new nodes whose control is room—while the view on the right shows the view of the model. (the bigraph editor also integrates with eclipse’s ‘outline’ view, using it to display the place graph.) the editor enforces the structural rules and visual conventions of bigraphs; if the user attempts to modify the model in a way that would cause them to be violated (for example, by dragging node j out of root 1), an explanatory error message will be displayed. it can also (optionally) provide snap-to-grid and snap-to-object editing behaviour, as well as guidelines indicating the visual conventions (these are visible in fig. 7). the signature editor, shown in fig. 8, manages both the bigraphical and visual properties of controls. the list view on the left shows the controls of the signature, and allows controls to be added and removed, while the panel on the right allows controls to be modified. the appearance and arity of a control are defined using the canvas in the centre-right of fig. 8. 7 / 10 volume 61 (2013) big red figure 8: big red’s signature editor. the black circles are the vertices of the control’s polygon, while ports are shown on the polygon as red circles (in this case, only one is shown). all of these objects can be created, moved and removed using the canvas and its context menu. visual fallback behaviour. although big red is reliant upon layout information, the user interface can also load model objects that lack it; in these cases, automatically-generated layout information will be assigned. 4.3 the bigraphical model big red’s implementation of the bigraphical model strikes a balance between theoretical purity and practicality: • it provides a pure, concrete bigraphical model, which can be extended with new properties and new constraints to implement other variations of bigraphs; • the model can only be modified by executing an edit script (in the style of højsgaard [høj12]), a reversible description of a modification, which allows related changes to be grouped together and validated as a whole (and which provides reliable and automatic undo and redo support); • it defines a standard xml representation of the model objects (and schemas to validate them), which can be extended to portably include new properties and relations; and • it is independent of eclipse, so external tools can use it without pulling in hundreds of megabytes of dependencies—although a separate eclipse integration component makes it easy to use from within the eclipse environment. some of the extensions built on top of the model are presented below. selected revised papers from gcm 2012 8 / 10 eceasst visual information. big red uses the model’s extensibility mechanisms to implement large parts of its own functionality—the visual information used to draw, colour, and position objects, for example, has no privileged support. parameterised controls. consider a simple extension to the bigraphical model: parameterised controls. these are identical in every way to traditional controls, except that they can optionally specify a type (for example, ‘string’ or ‘integer’); in turn, a node whose control specifies a type can specify a parameter of that type. (parameterised controls provide a convenient and simple way to introduce infinitely many controls; however, note that any concrete bigraph will contain only finitely many controls.) an implementation of this extension (consisting of around 250 lines of java code and 20 lines of xml) is included with big red. controls and nodes are given “type” and “parameter” properties, support for which is also added to the file formats, and a node’s parameter can only be changed in accordance with its control’s type. while this is a simple extension to the model, it could serve as a foundation for more interesting work elsewhere—for example, a tool built to use this model could assign some semantics to parameters in order to cleanly implement extra-bigraphical operations on data (like arithmetic or counters). 4.4 interacting with external tools big red defines a special extension point for plugins that want to operate on a complete bigraphical reactive system. when an extension registered with this point is activated, big red’s user interface is suspended, and the extension takes over. this extension point is a simple way of adding new functionality to big red: it essentially gives developers the ability to write small subprograms that operate on big red’s model objects without having to delve too deeply into the workings of eclipse. the integration between big red and bigmc [pdh12] is implemented in this way—as an plugin which converts a big red model into its bigmc term language representation, executes bigmc as a subprocess, and parses the results back into big red model objects so that they can be visualised. 5 conclusion we have presented a brief introduction to the bigraphical formalism, outlined the architecture and design of big red, and described the motivation for developing the tool. big red and its accompanying user documentation are available from http://bigraph.org under the terms of the eclipse public license. big red is still under active development. we intend to integrate support for other bigraph tools, and—together with the university of udine—we are working on developing big red into a generally-useful platform for building and hosting new tools for bigraphs. in particular, we intend to use its model as an interchange format, unifying the previously incompatible and toolspecific representations of bigraphical reactive systems. 9 / 10 volume 61 (2013) http://bigraph.org big red 6 acknowledgements this research is supported by it university of copenhagen and the danish council for strategic research, grant no.: 2106-080046. bibliography [bde+06] bigraphical models of context-aware systems. 2006. doi:10.1007/11690634 13 [cs12] m. calder, m. sevegnani. process algebra for event-driven runtime verification: a case study of wireless network management. in integrated formal methods. pp. 21– 23. 2012. [dk08] t. damgaard, j. krivine. a generic language for biological systems based on bigraphs. technical report, citeseer, 2008. [gdbh07] a. glenstrup, t. damgaard, l. birkedal, e. højsgaard. an implementation of bigraph matching. 2007. [gre09] c. greenhalgh. bigraphspace. 2009. http://bigraphspace.svn.sourceforge.net/ [hno06] t. hildebrandt, h. niss, m. olsen. formalising business process execution with bigraphs and reactive xml. in coordination’06. lecture notes in computer science 4038, pp. 113–129. springer-verlag, jan. 2006. doi:10.1007/11767954 8 [høj12] e. højsgaard. bigraphical languages and their simulation. phd thesis, ituniversitetet i københavn, 2012. [jen06] o. jensen. mobile processes in bigraphs. october 2006. available at http://www.cl. cam.ac.uk/∼rm135/jensen-monograph.pdf. [lm06] j. leifer, r. milner. transition systems, link graphs and petri nets. journal of mathematical structures in computer science 16(6):989–1047, 2006. doi:10.1017/s0960129506005664 [mil06] r. milner. pure bigraphs: structure and dynamics. information and computation 204(1):60–122, jan. 2006. doi:10.1016/j.ic.2005.07.003 [mil09] r. milner. the space and motion of communicating agents. cambridge university press, 2009. [pdh12] g. perrone, s. debois, t. hildebrandt. a model checker for bigraphs. in acm symposium on applied computing 2012 – software verification and testing track. acm, 2012. selected revised papers from gcm 2012 10 / 10 http://dx.doi.org/10.1007/11690634_13 http://bigraphspace.svn.sourceforge.net/ http://dx.doi.org/10.1007/11767954_8 http://www.cl.cam.ac.uk/~rm135/jensen-monograph.pdf http://www.cl.cam.ac.uk/~rm135/jensen-monograph.pdf http://dx.doi.org/10.1017/s0960129506005664 http://dx.doi.org/10.1016/j.ic.2005.07.003 introduction related work bigraphs in big red by example implementation architecture the user interface the bigraphical model interacting with external tools conclusion acknowledgements microsoft word sse2007 electronic communications of the easst volume 8 (2008) guest e managin eceass proceedings of the third international ercim symposium on software evolution (software evolution 2007) package evolvability and its relationship with refactoring a. mubarak, s counsell, r. hierons and youssef hassoun ditors: tom mens, maja d’hondt, kim mens g editors: tiziana margaria, julia padberg, gabriele taentzer t home page: http://www.easst.org/eceasst/ issn 1863-2122 15 pages eceasst 2 / 15 volume 8 (2008) package evolvability and its relationship with refactoring a. mubarak 1 , s. counsell 1 , r.m. hierons 1 and y. hassoun 2 1 {asma.mubarak, steve.counsell, rob.hierons} @brunel.ac.uk department of information systems and computing brunel university, uxbridge, middlesex, uk 2 youssef.hassoun@kcl.ac.uk department of computer science, king’s college, london, uk abstract in this paper, we address a set of research questions investigating trends in changes to an open-source system (oss). an interesting ‘peak and trough’ effect trend was found to exist in the system studied, suggesting that developer activity comprises of a set of high and low periods. trends in overall changes applied to the system were complemented with empirical evidence in refactoring data for the same system; this showed a similar peak and trough effect but at different versions of the same system. this result suggests a contrasting motivation between regular maintenance practice and that of refactoring. our analysis of high-level package trends informed some interesting cross-comparisons with refactoring practice, and some insights into why refactoring might be applied after a burst of regular change activity, rather than consistently. we use data extracted from seven java oss as a basis for our refactoring analysis. 1. introduction a software system is modified and developed many times throughout its lifetime to maintain its effectiveness. in general, it grows and changes to support increases in information technology demands. while from a research perspective, we know a reasonable amount about facets of object-oriented (oo) and procedural system evolution belady and lehman (1976), bieman et al., (2003), arisholm et al., (2006), relatively less well-understood is whether changes at the package level exhibit any specific trends. the benefits of such a study are clear. understanding changes at higher levels of abstraction may give a project manager a much more broad-brush idea of likely, future maintenance or refactoring opportunities. in particular, such a study may also be able to focus developer effort in specific areas of packages susceptible to large numbers of changes. a further area of interest to oo researchers and practitioners is the link between maintenance as part of every system’s evolution and that dedicated to refactoring fowler (1999), mens and tourwe (2004). in this paper, we investigate the trends in versions of the ‘velocity’ open-source system (oss), with respect to added classes, methods, attributes and lines of code. to support our analysis, we also looked at empirical refactoring data for the same system and associated trends for two other java osss. mailto:asma.mubarak@brunel.ac.uk mailto:steve.counsell@brunel.ac.uk mailto:rob.hierons@brunel.ac.uk package evolvability and refactoring proc. software evolution 2007 3 / 15 we suggest that if the set of regular (i.e., essential) maintenance changes exhibit specific characteristics then a set of specific refactorings will also exhibit similar features. results showed an interesting discrepancy between trends in those regular changes made to the system studied and those as part of a specific set of changes according to refactorings specified in fowler (1999). the remainder of the paper is organised as follows. in the next section, we present related work and in section 3, we provide details of the data analysis addressing three research questions. in section 4, we tie the trends in package data to those found in a refactoring study using seven java oss. finally, we conclude and point to possible future work in section 5. 2. related work from an empirical stance, the relationship between oo classes and packages is not welldefined. ducasse et al. (2005) suggest that it is necessary, for the re-engineering and development of oo systems, to recognize and investigate both sets of classes and packages. focusing on the latter provides a means of comparison with previous work focusing on class changes only. the same authors also suggest that packages have varying functions: they may include utility classes or they may include some fundamental sub-classes enlarging a framework. ducasse et al. (2004) suggest that the cost of modifying a program may be influenced by the relationship between packages and their enclosed classes. to support the developer in achieving a mental image of an oo system and understanding its packages, they introduce a top-down engineering method based on visualization. consequently, they raise the abstraction level by detecting packages rather than classes; classifying packages at a high-level prevents developers from being flooded with information. bieman et al., (2003) found a relationship between design structures and development and maintenance changes. the same study tried to examine whether potential changes to a class could be predicted by the architectural design context of a class. they found that in four of five case-studies, classes which have function in design patterns were modified more frequently than other classes gamma et al., (1995). in terms of the architecture of a system, bieman et al., (2001), found that classes belonging to a design pattern were the most change-prone classes in a system (this might also suggest that change-prone classes are implemented by design patterns). finally, demeyer et al. (2000) identified refactoring indicators when comparing different releases of a software system. they used four heuristics to find refactorings; each was identified as a mixture of change metrics. in this paper, we also consider relationships between trends in changes at the class level with refactoring data extracted using a bespoke tool. in terms of early work in the area, a key refactoring text is that by fowler (1999). in this text, fowler describes the mechanics of seventy-two different refactorings in four key categories and describes assorted ‘bad smells’ in code. according to fowler, the key indicator of when refactoring is overdue is when code starts to ‘smell’. the earlier work of johnson and foote (1988) and of foote and opdyke (1995) have all made significant contributions to the refactoring discipline and also helped to demonstrate the viability and potential of refactoring. recent empirical work by najjar et al., eceasst 4 / 15 volume 8 (2008) (2003) has shown that refactoring can deliver both quantitative and qualitative benefits the refactoring ‘replacing constructors with factory methods’ of kerievsky (2004) was used as a basis. the mechanics of the refactoring require a class to have its multiple constructors converted to normal methods, thus eliminating the code ‘bloat’ which tends to occur around constructors. results showed quantitative benefits in terms of reduced lines of code due to the removal of duplicated assignments in the constructors as well as potential qualitative benefits in terms of improved class comprehension. a full survey of recent refactoring work can be found in tourwe and mens (2003). 3. data analysis the main objective of the research described is to assess how a system changes through the analysis of packages in the system and to compare that data with corresponding results from refactoring the same system. knowledge of trends and changes within packages is a starting point for an understanding of how effective the original design may have been, how susceptible types of packages may be to change and can also inform our knowledge of facets of software such as coupling and cohesion. to this end, a case study approach was adopted using multiple versions of an evolving system. this system was a large oss called ‘velocity’ – a template engine allowing web designers to access methods defined in java. for each version, we collected the number of added classes, lines of code (loc), methods and attributes. hereafter, we define a loc as a single executable statement; we therefore disregard comment lines and white space from calculation of loc. 3.1 the three research questions  rq1: does the number of new classes over the course of nine selected versions increase constantly? this question is based on the notion that a system will grow over time in a constant fashion in response to regular changes in requirements.  rq2: is the increase in loc over the course of the nine versions constant? this question is based on the assumption that the change in loc over the nine versions will always increase due to evolutionary forces.  rq3: is the increase in the number of attributes and methods in a package constant across the versions of a system? this question is based on the assumption that the change in the number of attributes and methods will increase consistently over time in response to constant changes in requirements. 3.1.1. research question 1 (rq1) table 1 shows the number of packages in each of the nine versions, the number of new classes across those packages, the number of new classes in total, the maximum increase in classes and the package name where that increase took place. in each of the nine versions, new classes were added to packages and the number added varied significantly from one version to package evolvability and refactoring proc. software evolution 2007 5 / 15 another. between versions three and four and six and seven, relatively little change can be seen, while the peak of added classes is reached in the fifth version with 2032 new classes added. clearly, the addition of classes to this system over the versions investigated is not constant. interestingly, the version with the highest number of new classes was also accompanied by a drop in the number of packages (from 42 to 36). equally, some of the largest additions to classes were made after only minor changes to the numbers of packages. both effects may possibly be due to classes being moved around in the same package and simply renamed. table 1. packages and the new classes over the course of nine versions version no. of packages no. of new classes max inc. package name 1st 28 788 176 editor 2nd 32 1116 207 java 3rd 38 17 5 core 4th 42 11 3 javadoc 5th 36 2032 329 debuggerjpda 6th 39 45 13 openide 7th 39 297 92 core 8th 38 1274 357 web 9th 39 1386 217 core a feature not immediately apparent from the data in table 1 is the peak and trough effect of this data. a graph was therefore used to present the changes in the number of the new added classes (figure 1). we suggest that this trend is symptomatic of a burst of developer change activity followed by a period of relative stability and accumulation of new requirements, before another burst of change activity. for rq1, we conclude that the number of new classes over the course of the nine versions increases at an inconsistent rate, rather than remaining constant. it is not the case that there is constant addition of classes to the velocity system over the nine versions investigated; rq1 cannot thus be supported. figure 1. line chart of new classes added to the packages over the nine versions eceasst 6 / 15 volume 8 (2008) 3.1.2. research question 2 (rq2) to investigate rq2, the ‘maximum’ increase in the number of loc among all the versions was used. the data is presented in table 2. it can be seen that there are increases in loc over the course of the versions but these increases fluctuate wildly. interestingly, the core and vcscore packages were the packages that saw the maximum increases in loc for five of the versions. the core package is the only common package to tables 1 and 2, suggesting that the addition of a large number of classes does not necessarily imply the addition of a correspondingly large number of loc. one explanation for this feature might simply be that one class has been split into two (c.f., the ‘extract class’ refactoring of fowler (1999)). table 2. max. increase in the number of loc over the course of the nine versions version max inc in loc package name 1st 3955 core 2nd 5077 form 3rd 889 vcscore 4th 910 javacvs 5th 6985 vcscore 6th 1109 vcsgeneric 7th 369 core 8th 6418 core 9th 6743 schema2beans figure 2. line chart of the max increase in the number of loc (nine versions) figure 2 confirms that the increases in the number of lines of code over the course of the nine versions fluctuates across versions. again, the peak and trough effect is apparent from the figure. the most significant changes to vcscore appear in the first five versions and those of core appear in the seventh and eighth versions; rq2 cannot be supported either. 3.1.3. research question 3 (rq3) package evolvability and refactoring proc. software evolution 2007 7 / 15 for rq3, the maximum increase in the number of the attributes, and the maximum increase in the number of the methods for each version were used. this data is presented in table 3 and shows that over the course of the nine versions there are consistent increases in the number of attributes (a) and number of methods (m). however, these increases vary from one version to another. the largest increase in the number of the attributes and methods is at version five. once again, two packages dominate table 3 those being core and vcscore (seven of the eighteen entries in columns 4 and 7 relate to these two packages). as per table 2, the maximum increase in methods occurs at earlier versions for vcscore, and, for core, towards later versions. table 3. summary of the increase in the no. of attributes and methods over the nine versions version inc in a max inc in a package name inc in m max inc in m package name 1st 153 26 core 228 36 vcscvs 2nd 262 49 form 335 84 vcscore 3rd 25 7 jndi 46 11 vcscore 4th 24 7 diff 22 6 diff 5th 325 51 form 489 70 vcscore 6th 39 10 debuggercore 73 14 openide 7th 17 4 i18n 29 6 core 8th 238 57 core 371 150 core 9th 226 34 java 378 76 xml figure 3. inc. in attributes and methods figure 4. max. inc. in attributes and methods figure 3 shows that the number of the attributes and number of methods both increase during the course of the nine versions, but at a fluctuating rate. version four shows that more attributes were added than methods; the pattern for all other versions is the opposite. in contrast with the previous analysis, figure 4 shows that version eight appears to be the source of the largest increase in methods. in keeping with the results from rq1 and rq2, we conclude for rq3 that the increase in attributes and methods is not constant across the nine versions investigated. while the results so far give a fairly intuitive understanding of how a system might evolve, what is not so clear is the relationship between the ‘regular’ set of eceasst 8 / 15 volume 8 (2008) changes as we have described them, and the opportunities for undertaking a set of changes such as those associated with refactoring techniques opdyke (1992), tourwe and mens (2003). these are both interesting and potentially fruitful areas of refactoring research as well as challenges facing the refactoring community, mens and van deursen (2003). 4. refactoring relationships a current, open research question is whether there is any identifiable relationship between changes as we have described so far and specific refactorings. beck (2002) suggests that a developer should refactor ‘mercilessly’ and hence consistently. we would therefore expect refactorings for the velocity system to be consistently applied across all versions. 4.1 velocity table 4 shows the fifteen refactorings collected by a software tool as part of a full study of refactoring in seven java oss systems by advani et al., (2006). the fifteen refactorings were chosen by two developers with industrial experience and reflected, in their opinion, in consultation with fowler’s text, the common refactorings likely to be made by developers over the course of system’s life. as such, refactorings embracing inheritance, encapsulation, movement of class features and their addition and removal all feature amongst the fifteen refactorings. table 4. refactorings for the velocity system across nine versions no. refactoring ver1 ver2 ver3 ver4 ver5 ver6 ver7 ver8 ver9 1. addparameter 0 0 14 0 1 2 0 0 1 2. encapsulatedowncast 0 0 0 0 0 0 0 0 0 3. hidemethod 0 2 1 0 0 1 0 0 0 4. pullupfield 0 0 4 0 2 4 0 0 0 5. pullupmethod 0 4 13 0 24 5 0 0 9 6. pushdownfield 0 0 0 0 7 0 0 0 0 7. pushdownmethod 0 0 1 0 1 0 0 0 4 8. removeparameter 0 0 3 0 1 0 0 0 3 9. renamefield 0 3 14 0 1 2 0 0 3 10. renamemethod 0 5 11 0 15 14 0 0 10 11. encapsulatefield 0 5 4 0 0 0 0 0 0 12. movefield 0 0 18 0 1 2 0 0 0 13. movemethod 0 3 16 0 3 3 0 0 2 14. extractsuperclass 0 1 3 0 8 1 0 0 2 15. extractsubclass 0 0 0 0 1 0 0 0 0 package evolvability and refactoring proc. software evolution 2007 9 / 15 versions 3, 5 and 6 can be seen as the main points when refactoring effort was applied to the velocity system (these columns are bolded). in versions 1, 4, 7 and 8, zero refactorings were applied to this system. figure 5 shows table 4 in graphical form (with the ‘per version sum’ of the fifteen refactorings on the y-axis). the figure shows that refactoring effort is applied most significantly at one version (in this case version 3) and thereafter a peak and trough effect can be seen. comparing the trend in figure 5 with that in figures 1-4 suggests that the majority of the refactoring effort occurred between versions where significant changes in classes, loc, methods and attributes took place; version 3 is a trough in terms of these added features. conversely, version 5 from table 4 shows significant refactoring effort to have been applied, coinciding with large changes in the aforementioned features. version 6 activity (again a trough in terms of figures 1-4) also shows relatively large amounts of refactoring effort. a number of conclusions can be drawn from this analysis. firstly, it is clear that developers do not seem to refactor consistently across the versions of the system studied (velocity). secondly, while there is some evidence of peaks in refactoring effort occurring at the same time as large changes in classes, loc, methods and attributes, refactoring seems to occur largely after a peak of the same type of changes. one of the claims by fowler as to why developers do not do refactoring is that they simply do not have the time. finally, in the preceding analysis, and from figure 5, it is not the initial versions where the majority of regular change activity is applied to a system. we note, as an aside, that a valuable and interesting analysis of specific dates of version release remains a topic of future work. the first question that naturally arises is why refactoring changes tend to follow the regular changes applied to a system? after all, it is quite feasible for refactoring to be carried out at the same time as other changes (there is limited evidence of this occurring from the data). moreover, the opportunity for refactoring often arises as part of other maintenance activity and we would thus expect developers to spot opportunities for refactoring as they undertake other work on a system. there is one relatively straightforward explanation for this phenomenon. all of the fifteen refactorings in table 4 are semantics-preserving and do not explicitly add large numbers of classes, loc, methods or attributes as part of their mechanics. for example, the ‘move field’ and ‘move method’ refactorings would have no net effect on the number of fields or methods in a system, on a package basis. simple renaming refactorings such as ‘rename field’ and ‘rename method’ do not, per se, add any loc to the system. equally, none of the inheritance-related refactorings explicitly add loc to a system. one further suggestion as to why refactoring occurs at different versions is that after a burst of regular maintenance effort and a new version being released, the decay to the system that those changes have caused may need to be remedied. in other words, after a concerted effort to modify the system through regular maintenance, developers may feel that only then is refactoring necessary. eceasst 10 / 15 volume 8 (2008) figure 5. refactorings in the nine versions of velocity this does not explain, however, why for the velocity system there is significant refactoring effort in version 5 coinciding with a large set of changes in terms of added classes, loc, methods and attributes? one explanation could be that developers refactor during the course of normal maintenance but without explicitly recognizing it as refactoring. in other words, they may ‘tidy up’ in situ. we could hypothesise that while for velocity (and the refactorings we have extracted) refactoring effort is not applied consistently, there are two key occasions when, consciously or sub-consciously, it is applied. 4.2 pdfbox and antlr the question we could then ask is whether refactoring effort is consistent in terms of the versions where it is undertaken and whether a similar trend in refactoring appears in other systems. figure 6 shows the versions where refactorings were undertaken for the pdfbox system. versions 3 and 6 appear to be where the majority of the refactoring effort was invested. although we do not have the dataset of regular maintenance changes applied to the pdfbox system, it is interesting that a peak and trough effect is clearly visible for this system as well as for velocity. figure 6. refactorings for pdfbox figure 7. refactorings for antlr package evolvability and refactoring proc. software evolution 2007 11 / 15 figure 7 shows the refactoring trends for the antlr system. version two appears to be the point when most refactoring effort was invested, reinforcing the view that relatively more refactoring seems to be undertaken at early versions of system’s life (but not at its inception). it is interesting that across all three systems, version one seems to have been the subject of virtually no refactoring effort. one explanation might be that version one is simply too early in the life of a system for refactoring effort to be applied. on the other hand, it appears that version two or three is when the bulk of refactoring occurs. the question that then arises is whether the numbers of each type of refactorings in each of the three systems were similar? inspection of the raw data reveals a common trend for refactoring 1 (add parameter) and refactorings 9, 10, 12 and 13 (rename field, rename method, move field and move method). we hypothesize that these types of refactoring have been applied relatively more frequently than any of the other fifteen because they ‘tidy up’ a system with relatively little effort being required. after a significant amount of maintenance effort has been applied to a system, minor modifications are bound to be necessary. this may further explain why there is no coincidence between regular maintenance effort and that of refactoring. in the analysis of changes made at the package level, a significant number of methods and attributes were added over the versions studied. based on the refactoring evidence, we could claim that the five stated refactorings were a direct response to the problems associated with the addition of so many attributes and methods. for example, the motivation for the ‘move field’ refactoring is when ‘a field is, or will be, used by another class more than the class on which it is defined’. in such a case, the field needs to be moved to the place ‘where it is being used most’. equally, the ‘move method’ refactoring is applicable when: ‘a method is, or will be, using or used by more features of another class than the class on which it is defined’. for the velocity system, the large number of these two refactorings at version three suggests that the correspondingly large number of fields and methods added were the cause of required subsequent refactoring. in other words, simple refactorings may have been undertaken to remedy the problems associated with such an intense set of added fields and methods. we also note that these two refactorings were popular across all three systems studied (and at specific points), which adds weight in support of this argument. the same principle applies to simple renaming of fields and methods. it is perfectly reasonable to suggest that when large numbers of attributes and methods have been added to a system, a certain amount of refactoring may be necessary subsequently to disambiguate and clarify the role and meaning of those fields and methods. fowler (1999) suggests that the ‘move method’ refactoring is the ‘bread and butter of refactoring’. equally, ‘move field’ is the ‘very essence of refactoring’. similarly, fowler reveals an interesting point about the ‘rename method’ refactoring: ‘life being what it is, you won’t get your names right the first time’. one explanation for the lack of the more ‘structurally-based’ refactorings (i.e., those that manipulate the inheritance hierarchy) in the systems studied might be that the package access provides the necessary inter-class access that inheritance might otherwise provide. the ‘extract subclass’ and ‘extract superclass’ refactorings would fall into this category. one final point relates to why versions two and three were the source of the most refactoring effort (as opposed to later versions of the system across all three systems). one explanation is that eceasst 12 / 15 volume 8 (2008) when a system is at early stages of its lifetime, the design documentation is more likely to be up-to-date. consequently, the system is relatively easy to modify from a refactoring perspective. as the system ages, increasing amounts of effort and time needs to be devoted to changes as the code ‘decays’. 4.3 across all systems one aspect of the analysis that we have not yet considered is the relationship between the refactorings from table 4. figure 8 shows the sum of refactorings across all nine versions of the velocity system (the numerical data for this graph is exactly that in table 4). each line in the graph represents the sum of each refactoring for a single version. so, for example, refactoring five (add parameter) when taken in totality is a common refactoring across most versions (at least five); the graphs at refactoring 5 show simultaneous peaks. equally, refactoring ten (rename method) can be considered as a popular refactoring in each of the versions. for the fifteen refactorings, a clear trend of peaks and troughs in the fifteen refactorings can be seen. in other words, there is a trend in the propensity of refactorings to occur in ‘parallel’ (at the same time). figure 8 thus illustrates the strong bond between the fifteen refactorings. figure 8. ‘peak and trough’ effect of refactorings for velocity two notable exceptions to the trend of refactorings follow peaks and troughs apply to refactoring one (add parameter) and twelve (move field). at times, there are large numbers of this refactoring in a particular version and very few other refactorings in the same corresponding versions. a simple explanation may account for this trend. they are both refactorings that are used by the mechanics of many other refactorings. they are also two refactorings that a developer may undertake in the course of regular maintenance for example, to fix a fault without the use of any other refactorings. in other words, they can both act as stand-alone refactorings in contexts other than that of refactoring. package evolvability and refactoring proc. software evolution 2007 13 / 15 4.4 threats to study validity there are a number of threats to the validity of the study that need to be considered. one threat to the validity of the study is that we have only considered a relatively small sample of systems to investigate. in defence of this threat, we accept that a larger sample of systems might demonstrate that the results in this paper are more generalisable to the population of systems (external validity). however, the same criticism could be made of a study with double the number of systems studied, for example. the over-arching aim of this paper is to promote further studies and research in this area and that is when the results in this study can be supported or refuted. a further threat to the validity of the study is that we have only considered fifteen refactorings from the 72 stated in fowler (1999). one plan for future work is to extend the extraction of data to more than fifteen refactorings. we have also only considered a relatively small number of versions of each system; again, in defence of this claim, we chose the most number of versions available at the time the research was being undertaken. one final threat to the validity of the study relates to the time gap between each version of a system. we have assumed, so far, that there is an equivalent time gap between versions and hence that, other things remaining equal, there is a reasonable chance of the same number of refactorings being undertaken between each version. table 5 shows the time gap in months (m) and days (d) between the nine versions of the velocity system and the total number of refactorings that were identified in that time the totals are calculated by summing the individual columns of table 4. (for the sake of argument, we assume a month to be 30 days duration.) table 5 shows that there is a wide variation in times between versions of the velocity system. the minimum gap is 8 days and the maximum gap 8 months, 8 days. version version gap refactorings ver 1 0 ver 2 8d 23 ver 3 10d 102 ver 4 5m 28d 0 ver 5 1m 21d 65 ver 6 6m 28d 34 ver 7 15d 0 ver 8 8m 8d 0 ver 9 7m 9d 34 table 5. duration between each version and associated refactorings (velocity) what is most interesting and noteworthy from table 5 is that there is no clear pattern or proportionality with the number of refactorings based purely on the version time gaps. in other words, the length in time between versions seems to have no bearing on the number of refactorings extracted by the tool and undertaken by the developers of this system. for example, the 8 month, 8 day gap between version 7 and version 8 realised zero refactorings. equally, the 10 days between version 2 and 3 realised the highest number of (102) refactorings. inspection of the velocity change logs detailing the changes between versions eceasst 14 / 15 volume 8 (2008) revealed a mixture of patches, bug fixes and new requirements. it would therefore seem that refactoring may be motivated by factors other than time per se. the amount of developer effort invested into the system between versions, for example, may be a more significant factor than time. a finer-grained analysis of exactly at what date and time the refactorings were undertaken (i.e., a timestamp approach) as well as some indication of effort on the part of the developers might also provide a greater insight and reveal more informative patterns in the refactorings; we leave this detailed aspect of the analysis for future work. 5. conclusions and further work the goal of this research was to investigate how a system evolved at the package level and this goal was achieved through the use of a case study. a set of three research questions investigated trends in changes of nine versions of an open-source java system. a bespoke tool was written to extract data relating to changes across those nine versions. an interesting ‘peak and trough’ effect trend was found to exist in the system studied at specific versions of the system, suggesting that developer activity comprises a set of high and low periods. a contrast was found between those regular changes and those associated with refactoring activity. the results address a hitherto unknown area that of the relationship between regular changes made to a system as part of maintenance and that of refactoring. while the study describes only a limited sample of systems and evidence of the peak and trough effect is similarly restricted (both threats to study validity), we view the research as a starting point for further replicated studies and for an in-depth and generalised analysis of coupling/refactoring, both interand intra-package. future work will focus on a number of threads. firstly, we plan an empirical study to investigate package coupling data across six further oss using an automated tool called jhawk (2007) to collect relevant metrics. we also plan to use the tool used by advani et al., (2006) to correlate with the data extracted by jhawk. finally, we plan on investigating the formal and theoretical properties of refactoring relationships to support the conclusions we have made about the empirical data. for example, to explore the testing implications induced by the empirical relationships described. bibliography advani, d., hassoun, y. and counsell s. (2006) extracting refactoring trends from opensource software and a possible solution to the related refactoring conundrum. proceedings of the acm symposium on applied computing, dijon, france, april 2006. arisholm, e. and briand, l.c., predicting fault-prone components in a java legacy system, proceedings of 2006 acm/ieee intl. symposium on empirical software engineering. beck, k., (1999) extreme programming explained: embrace change, addison wesley. belady, l., lehman m., (1976) a model of large program development, ibm sys. journal, 15(3), pages 225-252. package evolvability and refactoring proc. software evolution 2007 15 / 15 bieman, j. m., straw, g., wang, h., munger, p. and alexander, r. (2003) design patterns and change proneness: an examination of five evolving systems. in proc of the ninth int software metrics symposium, sydney, australia, pp.40-49. bieman, j. m., jain, d. and yang, j. y. (2001) oo design patterns, design structure, and program changes: an industrial case study. in proceedings of the in.l conf. on software maintenance, florida, italy, pp.580-589. demeyer, s., ducasse, s., nierstrasz, o., (2000) finding refactorings via change metrics. in proceeding of oopsla ’00: proc of the 15th acm sigplan oopsla, minneapolis, minnesota, united states. pp. 166–177. acm press, new york, ny, usa. ducasse, s., lanza, m. and ponisio, l. (2005) butterflies: a visual approach to characterize packages. in proceedings of the 11 th intl. software metrics symposium, como, italy, pp.7-16. ducasse, s., lanza, m. and ponisio, l. (2004) a top-down program comprehension strategy for packages. technology report iam-04-007, university of berne, institute of applied mathematics and computer sciences. foote, b., and opdyke, w., life cycle and refactoring patterns that support evolution and reuse. pattern languages of programs (james o. coplien and douglas c. schmidt, editors), addison-wesley, may, 1995. fowler, m., (1999) refactoring (improving the design of existing code). addison wesley. gamma, e., helm, r., johnson, r. and vlissides, j. (1995) design patterns: elements of reusable object-oriented software. massachusetts, addisonwesley. jhawk tool: http://www.virtualmachinery.com/jhawkprod.html, accessed 2007. johnson, r., and foote, b., designing reusable classes, journal of object-oriented programming 1(2), pages 22-35. june/july 1988. kerievsky, j., refactoring to patterns, addison wesley, 2004. mens, t. and van deursen, a. (2003) refactoring: emerging trends and open problems. proceedings first international workshop on refactoring: achievements, challenges, effects (reface). university of waterloo. mens, t. and tourwe, t. (2004) a survey of software refactoring, ieee transactions on software engineering 30(2): 126-139. najjar, r., counsell, s., loizou, g., and mannock, k., the role of constructors in the context of refactoring object-oriented software. proc. seventh european conference on software maintenance and reengineering (csmr '03). benevento, italy, 2003. pages 111 – 120. opdyke, w. (1992) refactoring object-oriented frameworks, ph.d. thesis, univ. of illinois. tourwe, t. and mens, t., (2003) identifying refactoring opportunities using logic meta programming, proc. 7th european conf. on software maintenance and re-engineering, benevento, italy, 2003, pages 91-100. http://www.virtualmachinery.com/jhawkprod.html http://csdl.computer.org/comp/proceedings/csmr/2003/1902/00/1902toc.htm http://csdl.computer.org/comp/proceedings/csmr/2003/1902/00/1902toc.htm synthesising evolvable smart manufacturing scenarios electronic communications of the easst volume 81 (2021) 9th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2021 synthesising evolvable smart manufacturing scenarios ivan guevara 14 pages guest editors: sven jörges, anna-lena lamprecht, anila mjeda, stefan naujokat eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst synthesising evolvable smart manufacturing scenarios ivan guevara 1 ivan.guevara@ul.ie, http://www.ul.ie/ university of limerick, limerick, ireland abstract: smart manufacturing contexts have been experiencing an increasing complexity over the years, leveraged by higher computational power (cpu/gpu), increasing speed connections (5g/6g), ai transformation from use case to mass adoption and robotic systems enhancements. research has been focusing on architectural issues to improve disposition of the components involved within a smart manufacturing scenario and find the most effective configuration to provide the most efficient production environment. we introduce in this paper an improved version of our ”maze generator”, a navigation scenario generator that uses a machine learning approach from the evolutionary computing branch called grammatical evolution (ge) to automatically generate different scenarios with different configurations. ge takes advantage of a bnf grammar (rules describing the experiment) to define the search space, and genetic operations (crossover, mutation, selection, etc) to provide novelty to the solutions found. this not only enables the possibility to test autonomy, self-sufficiency and performance on a simplified model, but also to determine levels of difficulty to test the simulated navigation model under specific conditions. keywords: smart manufacturing, machine learning, grammatical evolution, robotic navigation 1 introduction robotic navigation scenarios provide a way to implement, analyse, control, and test over a simplified model, to enable quick insights about the behaviour of our system. they are a key component of this research, being a cost-effective answer to the enquiries we might have during the process. these ones also allow us to tackle important issues, i.e, how the disposition of elements can be optimised, generalization capabilities of our controllers, incidence of selected raw materials to build real world scenarios, interaction between cobots, shape optimization for elements, etc. in this context, we also discuss which elements essentially constitute the “grammar of scenarios”, how they can be associated to various concepts of complexity (based, e.g., on those spaces, cost of production of the scenario, skill levels needed to move around, and other perspectives), and how these different understandings can impact the experience of robots and humans navigating. as mentioned before, one of the challenges in robotic navigation is to tackle the generalization problem, i.e., finding a robotic controller general enough to cover the different levels of complexity and navigate most of the presented scenarios the robot will have to face. although significant work is found in that area, where we can mention [nut17] and [nrg+20] show1 / 14 volume 81 (2021) mailto:ivan.guevara@ul.ie http://www.ul.ie/ synthesising evolvable smart manufacturing scenarios ing that controllers can be efficiently evolved themselves through ge using various strategies (controllers that prefer novelty search, moderated free exploration, were able to outperform the conventional objective-based search approach), we cannot apply the same criteria to evolvable scenarios. we still require a lot of the preparation and pre-training on prepared scenarios (the mazes of our title), to reach a level of navigation confidence sufficient to be ported to real world tasks. but what are the crucial characteristics of a scenario? what’s the difficulty profile of a maze? the paper is organized as follows: section 2 covers related work in the application domain, maze generation, as well as our technology of choice, genetic algorithms, grammatical evolution and its relationship with robotic navigation. section 3 will explain in the detail the experiment setup (maze grammar, hyperparameters, fitness function and software architecture) and results and lessons learned are reported in sections 4 and 5 respectively. 2 related work 2.1 scenario generation although lacks in variety with the type of figures they produce, we can find in the literature very efficient and broadly used algorithms that build 2d maze scenarios with high precision, such as kruskal’s algorithm [kru56], prim’s algorithm [pri57], wilson’s algorithm [wil96] and aldous-broder algorithm [ald90] [bro89]. other approaches for maze generation through evolution with more realistic output can be found in [sp10], where a fi2-2pop genetic algorithm is used to evolve scenarios in popular video-games such as mario bros and legend of zelda, also [alm11] shows the usage of dynamic programming for maze-like levels used in games, [tpy10] developed a multiobjective evolutionary algorithm to generate, not only strategy game maps, but to optimise experiences for different types of players, [ora10] uses evolutionary algorithms in order to generate solutions for the japanese game called ”shinro”. 2.2 grammatical evolution ge is a machine learning technique inspired in biology that uses mainly 3 stages (fig. 1) in order to evolve solutions: 1) initializes a random population 2) using structural characteristics provided in backus-naur form, bnf [bbg+63], maps those individuals (solutions) and generates a set of solutions in terms of the bnf grammar (phenotypes) and then, evolves the population by utilising genetic operations (mutation, crossover, selection). 3) determines which are the most apt individuals to use them for the next generation. it works by successive approximation based on a population approach and tries to achieve better and improved individuals in each generation, improving the fitness score of the overall population. in this particular context, as shown in (fig. 2), random population (characterized by integer arrays) goes through a mapping process with the bnf grammar, where genotype is transformed into a combination of figures given by the grammar (phenotype). the process begins by grabbing the first element in the array, doing a mod operation and the result of that operation corresponds to an index in the grammar previously defined. it will continue until the solution has derived all the elements (in this case, our final solution found was square(eshape())). it could be the case that a solution is not found, isola ds 2021 2 / 14 eceasst figure 1: generic workflow for a ge experiment so we will mark our individual as invalid and discard it during the evolutionary process. we can find several number of success cases where ge has been applied, such as communication networks [flk+17] , search-based software engineering [cfr+17], program synthesis [or99], sport analytics [flk+17] and animation [mur11]. it is one of the prominent success stories of irish research in applied ai. 2.3 robotic navigation ge has been used for robotic navigation, to mostly produce controllers that navigate predefined mazes. in [nrg+20] using netlogo [wil99] as a basis, controllers language were evolved for moving through the maze and reach the target, using two different strategies expressed by means of their respective fitness functions: the objective-based search (os) rewarding those moves that get the agent closer to the target and novelty search (ns) rewards exploring new areas over proximity to the target. the general idea of the experiment was to see whether ge could enable a controller general enough to navigate the majority of the produced scenarios, and for that the controllers were trained with a dataset containing 60 maze instances and a test set with 100 different ones. the best controllers were chosen to be tested in a sort of cross-validation set with 15 more scenarios(fig. 3) in order to reach the decision of which one was the best. as we can evidence in the same figure, we have increasing complexity in the maze configurations starting with easy, medium and hard. the easiest mazes are being represented by only 1 wall (brown large line) and the target point (red point), the ones with medium difficulty with 2 walls and the target point and finally the hardest ones with 3 walls and the target point. all the mazes were developed by hand, using the netlogo scripting language, making 5 for each of them with code basically consisting of indicating coordinates, colours and disposition of each element, a quite 3 / 14 volume 81 (2021) synthesising evolvable smart manufacturing scenarios figure 2: step by step for the mazegen experiment complex task as the scripting language does not allow us to use high-level abstractions in an easy way. the development cycle was inefficient as we needed the exact coordinates for the elements, not having even the possibility to use high-order functions (fig. 4) 2.4 framework direction mazegen aims to support for scenarios: 1) automated generation, 2) increasing complexity generation, 3) an easy learning curve for rapid development, and 4) a library of available predefined building blocks ready to use. pygevo, the framework giving support to mazegen, was conceived with a focus in a low-code fashion, trying to imitate different approaches available in the industry such as ludwig [mdm19], fastai [hg20], nni [mic21] or the turicreate engine from apple [app18]. mazegen was developed aiming to bring a powerful tool that can easily bootstrap an experiment, trying to put the application expert (a potential non-programmer) in the center of the development process, instead of relying on the manual reuse of boilerplate code, which is hard to maintain and scale. we refer here as a blueprint to the jabc framework [smn+06], a development framework which follows the xmdd (extreme model-driven design) [ms12] and the ota (one thing approach) [ms09]. it has 2 development levels: a modelling level where models are defined in a high-level abstraction layer, and the implementation level, where the actual program artifacts are created. the idea behind the mazegen framework is to follow the same organization structure as jabc: we do not only interact with high-level abstractions (models), but the whole workflow experiment can be accomplished by using a few lines of code and easily extended. this is appropriate for people with no experience in programming languages, isola ds 2021 4 / 14 eceasst figure 3: mazes generated for validation process as shown in [lt14] and [tat20] in various learning and adoption contexts. 3 experimental setup in order to concretely define the experiment, we need to work on 4 main issues: 1) define the rules for the bnf grammar to limit the universe of solutions we want to have. 2) developing a software architecture capable of dealing with the graphical framework and, at the same time, providing a friendly and easy way to interact with the api. 3) hyperparameters, defining the number of runs/population size/genetic operations to apply to the ongoing experiment 4) fitness function, which will define the criteria to look for the most apt individuals. 3.1 bnf grammar representing the composability of elements for creating the scenario, in the context of our bnf grammar, we might see different figures that will take part of it. the majority of the figures are a geometric element composed by dots (x1,y1),(x2,y2),..........,(xn,yn) where x1,x2,......,xn and ,y1,y2,.......,yn ∈ z and n ∈ n. the geometric figures are the following ones: • : this is the first and unique rule from the bnf grammar. it will contain all the figures allowed in the scenario and their respective recursive forms. • triangle: a six dot element placed in random coordinates with a random size. • square: an eight dot element also placed with random coordinates and a random size, representing a simple obstacle to the robot. 5 / 14 volume 81 (2021) synthesising evolvable smart manufacturing scenarios figure 4: a fragment of the netlogo scripting code used for maze development • lshape: also an eight dot element placed in random coordinates with also random size, representing a simple trap to avoid the pass. • eshape: a sixteen dot element placed in random coordinates with also random size, representing a conjunction of walls working as a trap to avoid the pass of the robot, a more complex trap that the one before. • recursive forms: a composable element where any kind of combination between the ones mentioned before is allowed, i.e., triangle(square), triangle(square(lshape)), etc. 3.2 fitness function two basic criteria were used for the fitness function in order to pick the most performing individuals through the evolutionary process during the experiment: 1. more geometric elements −→ better individual 2. more geometric elements + size filters −→ better individual the first criterium was too simplistic as we only counted the number of elements the individual could reach and select those ones for the next generation. then we applied genetic operations (crossover, mutation, selection) and continued with the evolutionary process. that fitness function created some issues as there was a tendency to create big objects, as big as the whole scenario, so we decided to modify it and have a second version. the improved function took into account bigger objects and penalized all the individuals whose elements were above 500 pixels. this is still a simplistic approach, as we don’t take into account solvability of the maze, real world scenarios and targeted complexity , but it was a good start as a preliminary approach. 3.3 hyperparameters each experiment was run 10 times to have enough information to reach reliable conclusions for each configuration. in terms of hyperparameters, we carried out 6 sets of experiments with isola ds 2021 6 / 14 eceasst different configurations reported in table 1. all the parameters were defined based on a range of numbers, this way we could appreciate how the experiment evolved : 1. individuals: represented by an array of numbers (binary or integer), these ones will be part of the solution once they go through the mapping process. 2. genotype size: size for the array of numbers. representing a ”genetic representation” of the individual. 3. generations: the amount of time within the experiment. 4. p. selection: a percentage of selection defining the number of individuals that will go to the next generation. 5. f. function: defines the criteria why an individual is better than other. table 1: experiments set up: hyperparameters and option configuration for the 6 sets of experiments. hyperparameters experiment 1 experiment 2 experiment 3 experiment 4 experiment 5 experiment 6 runs 10 10 10 10 10 10 individuals 1000 5000 1000 5000 10000 50000 genotype size 32 32 32 32 32 32 generations 15 15 15 15 30 30 p. selection 0.1 0.1 0.1 0.1 0.1 0.1 f. function higher−→ better higher −→ better penalize penalize penalize penalize 3.4 software architecture having a highly simplified grammar with one rule for the scenario composition is not enough, we need a ”bridge” between our machine learning models and the graphical representation. to accomplish that, in the first version of this paper, we defined a software architecture where external components took care of the attribute evaluation, fitness evaluation and serialization of graphical components. despite the fact it was a good approach, we lacked of control for the different elements drawn in the scenario as we didn’t track elements, we just rendered points. having control of those ones is key to have a more easy way to interact with them and allow a more straightforward handling of new behaviours such as collision detection, color definition, rotation, etc. in particular, we created several data classes in order to contain the graphical representations: layout, eshape, lshape, rectangleshape, triangleshape, scenariobuilder. each of those objects will represent an element, giving each of them the responsibility for their own actions. as shown in 5, the experimental set up still uses pygevo [il], a state-of-the-art grammatical evolution framework, to manage the bnf and the genotype to phenotype evaluation, and kivy [mga+20], a free and open-source python-based graphical framework that we use to visualize the scenarios. both are chosen because they are open source and provide tools for rapid development, which led us to a rapid bootstrapping of the development process. we can also see the interaction between the scenariobuilder and our data classes, being the one in charged of generating those instances. 7 / 14 volume 81 (2021) synthesising evolvable smart manufacturing scenarios figure 5: the new architecture developed for the 2nd version of the mazegen (uml notation) the main orchestration occurs in a python script which defines the fitness function and invokes pygevo. pygevo abstracts all the logic for the evolutionary process and the synthesis of the phenotypes, handling the grammar-related part of the ge approach. the cache also helps us to achieve a better performance when dealing with individuals. as soon as our phenotypes are derived, they are translated into kivy code and placed into a proper log. for this, we created a simple domain specific language for the scenario builder’s interface, to easily handle the creational part of the elements. 4 results the results improved with the new version of the architecture as we were able to manage more easily the creational part of each element. experiments in general had between 14 and 20 geometric figures with diverse complexity, this is due to the relationship between the simplicity of the grammar and the genome size of 32 codons: it takes a low number of codons to completely describe an object with this grammar, therefore it tends to derive phenotypes with a large number of elements. in turn, the length of the genome relates to the computational time, so we see that there is a trade-off between the expressiveness of a grammar in terms of number of productions and the computational effort needed to derive scenarios of a sufficient or good complexity taking [nrg+20] as a reference for scenarios of sufficient and good quality. in fig. 6 and fig. 7 we obtained 2 scenarios with 16 and 17 elements respectively, most of them being triangles located in random locations. we can also observe black squares and a rectangle, acting as a big obstacle. fig. 8 and fig. 9 show a 18 and 19 element scenario generated: we see several elements distributed across the scenario acting as a container wall, composed by triangles, isola ds 2021 8 / 14 eceasst squares and lshapes. for each of the figures located in the these scenarios, we have a correlated object describing a bounding box. this would make possible, despite the complexity observed, to use them to train robotic controllers. we still face an issue with the fitness function: despite its improvement by considering the large sized obstacles, we still do not take into account important details such as resolution of the maze, real world components or equivalence classes to address complexity. this has a clear impact on the quality of the solutions that we could provide to a real-world scenario, but we can still reach a good level of complexity with the building blocks defined in the grammar. figure 6: scenario 1 figure 7: scenario 2 figure 8: scenario 3 figure 9: scenario 4 5 future work the preliminary work accomplished with mazegen evidences a novel way to recreate maze scenarios with an evolutionary machine learning approach, leveraging the rules and constraints described in a bnf grammar and the corresponding fitness function. the approach itself, despite the good results obtained in the first version of the framework, still needs improvement as it shows some problems concerning the solvability of the scenario and the lack of connection of the figures with a real world case study. in this context, a new version of the mazegen (v2.0) is 9 / 14 volume 81 (2021) synthesising evolvable smart manufacturing scenarios being developed with a new grammar representing new, more realistic elements tied to a specific application domain (e.g., in a manufacturing floor, the stations of a production line, a cobot, a router, a vertical and horizontal wall) and a fitness function capable of penalizing overlapping objects, in order to have a better distribution between the elements of the robotic scenario. in this new version, the elements (still represented using the kivy framework) are placed around the scenario and the fitness score will diminish in relation to the amount of overlapped figures it contains. as we can see in fig. 10 and fig. 11, the resulting scenarios have a better disposition, with an improved ”semantic meaning”: on the left, we see 2 vertical walls (black) and 3 production lines (blue and yellow background), and the right one is composed by an horizontal wall, 3 production lines and a router (represented by a yellow square). this work is in line with the different tools we have been developing as a research group, for instance the self-contained model-driven solution in the context of a digital thread platform for cps [mcg+21], where the general idea of this platform is to enable a high-level abstraction layer sufficient enough to orchestrate different levels of heterogeneity, being capable of easily plug solutions found in the industry and include them in the development cycle as self-contained models. we can also evidence different projects such as [cgj+22], [cm21] or [jgmp21] concerning various other smart manufacturing aspects, where the main focus is put on model-driven architectures that can be easily bootstrapped in a simple fashion way, not having to deal with boilerplate code, but with models. the logic behind these tools goes through a model-to-code transformation of the workflows, where single functionalities are placed in a sib (service-independent building block), that can be used in an environment like dime [bfk+16], a friendly model-oriented intuitive ide. figure 10: scenario 1 version 2 figure 11: scenario 2 version 2 6 lessons learned and conclusions evolving robotic navigation scenarios through ge is a novel way to have systematic and automatic scenario development, providing a variety in terms of elements that compose each maze, isola ds 2021 10 / 14 eceasst giving control on the global settings and tracking the different elements with their corresponding coordinates. a new architecture was built to accomplish the aforementioned findings, but it took quite a time to re-adapt the building of each scenario in order to have, not only coordinates drawn in the scenarios, but objects to interact with. despite the known issues from the fitness function (e.g., possibility to specify some predefined complexity, correlate complexity and configuration inside a scenario, as well as the overall solvability itself), we managed to give a great step towards it, as we replace ordinary coordinates in a x-y plane for objects that can address behaviour in order to have more complex interactions among them. enabling control over the figures will allow detecting collisions, which will deliver the possibility to filter also those who cannot be solved, improving the accuracy of the overall experiment. acknowledgements: this work was supported by the science foundation ireland grant 16/rc/3918 (confirm, the smart manufacturing research centre). bibliography [ald90] d. j. aldous. the random walk construction of uniform spanning trees and uniform labelled trees. siam journal on discrete mathematics 3(4):450–465, 1990. doi:10.1137/0403039 https://doi.org/10.1137/0403039 [alm11] d. ashlock, c. lee, c. mcguinness. search-based procedural generation of mazelike levels. ieee transactions on computational intelligence and ai in games 3(3):260–273, 2011. doi:10.1109/tciaig.2011.2138707 [app18] apple. turicreate engine. 1 2018. https://github.com/apple/turicreate [bbg+63] j. w. backus, f. l. bauer, j. green, c. katz, j. mccarthy, p. naur, a. j. perlis, h. rutishauser, k. samelson, b. vauquois, j. h. wegstein, a. van wijngaarden, m. woodger. revised report on the algorithmic language algol 60. the computer journal 5(4):349–367, 01 1963. doi:10.1093/comjnl/5.4.349 https://doi.org/10.1093/comjnl/5.4.349 [bfk+16] s. boßelmann, m. frohme, d. kopetzki, m. lybecait, s. naujokat, j. neubauer, d. wirkner, p. zweihoff, b. steffen. dime: a programming-less modeling environment for web applications. in international symposium on leveraging applications of formal methods. pp. 809–832. 2016. [bro89] a. broder. generating random spanning trees. in 30th annual symposium on foundations of computer science. pp. 442–447. 1989. doi:10.1109/sfcs.1989.63516 11 / 14 volume 81 (2021) http://dx.doi.org/10.1137/0403039 https://doi.org/10.1137/0403039 http://dx.doi.org/10.1109/tciaig.2011.2138707 https://github.com/apple/turicreate http://dx.doi.org/10.1093/comjnl/5.4.349 https://doi.org/10.1093/comjnl/5.4.349 http://dx.doi.org/10.1109/sfcs.1989.63516 synthesising evolvable smart manufacturing scenarios [cfr+17] b. cody-kenny, m. fenton, a. ronayne, e. considine, t. mcguire, m. o’neill. a search for improved performance in regular expressions. in proceedings of the genetic and evolutionary computation conference. gecco ’17, p. 1280–1287. association for computing machinery, new york, ny, usa, 2017. doi:10.1145/3071178.3071196 https://doi.org/10.1145/3071178.3071196 [cgj+22] h. a. a. chaudhary, i. guevara, j. john, a. singh, t. margaria, d. pesch. low-code internet of things application development for edge analytics. in camarinhamatos et al. (eds.), ifip advances in information and communication technology. springer international publishing, 2022. [cm21] h. a. a. chaudhary, t. margaria. integrating external services in dime. in international symposium on leveraging applications of formal methods. pp. 41–54. 2021. [flk+17] m. fenton, d. lynch, s. kucera, h. claussen, m. o’neill. multilayer optimization of heterogeneous networks using grammatical genetic programming. ieee transactions on cybernetics 47(9):2938–2950, 2017. doi:10.1109/tcyb.2017.2688280 [hg20] j. howard, s. gugger. fastai: a layered api for deep learning. information 11(2):108, 2020. [il] g. ivan, g. lucas. pygevo. https://github.com/ivanhguevara/pygevo [jgmp21] j. john, a. ghosal, t. margaria, d. pesch. dsls for model driven development of secure interoperable automation systems with edgex foundry. in 2021 forum on specification design languages (fdl). pp. 1–8. 2021. doi:10.1109/fdl53530.2021.9568378 [kru56] j. b. kruskal. on the shortest spanning subtree of a graph and the traveling salesman problem. proceedings of the american mathematical society 7(1):48–50, 1956. [lt14] a.-l. lamprecht, m. tiziana. process design for natural scientists. springer, 2014. [mcg+21] t. margaria, h. a. a. chaudhary, i. guevara, s. ryan, a. schieweck. the interoperability challenge: building a model-driven digital thread platform for cps. in margaria and steffen (eds.), leveraging applications of formal methods, verification and validation. pp. 393–413. springer international publishing, cham, 2021. [mdm19] p. molino, y. dudin, s. s. miryala. ludwig: a type-based declarative deep learning toolbox. 2019. [mga+20] v. mathieu, p. gabriel, a. akshay, e. matthew, t. alexander, l. richard, b. peter, a. sebastian, s. terje, c. ilya, t. kathryn, h. thomas, d. christopher, k. jacob, r. ben, r. philip, u. meet, mitō), k. rafał, b. guillaume, m. andre, p. jeff, p. t. isola ds 2021 12 / 14 http://dx.doi.org/10.1145/3071178.3071196 https://doi.org/10.1145/3071178.3071196 http://dx.doi.org/10.1109/tcyb.2017.2688280 https://github.com/ivanhguevara/pygevo http://dx.doi.org/10.1109/fdl53530.2021.9568378 eceasst karl, m. charles, f. ian, m. edwin, k. brian, p. dusty, s. zachary, l. s. kristian, j. paige, g. mirko, o. m. edwin, x. x. jason, h. ben, b. sam, n. mihai, s. azim, b. docimique, g. mikhail, d. denys, w. kjell, b. julien, s. ethan, l. dominik, c. vernon, n. robert, k. joseph, a. ismael, s. eric, j. abhinav, m. stuart, p. stéphane, m. jim, e. roger, j. richard, o. oleksandr, w. björn, l. alex, r. victor, l. sander, h. rene, s. niko, k. don, c. david, g. cayci, j. alan, m. mihály, m. oliver, o.-e. ng, s. karl, m. julien, b. jakub, v. gabriel, r. clément, k. albert, o. shayne, e. godwin, a. m. ronnie, p. rasmus, w. phunsuk. kivy. dec. 2020. doi:10.5281/zenodo.5097751 https://doi.org/10.5281/zenodo.5097751 [mic21] microsoft. neural network intelligence. 1 2021. https://github.com/microsoft/nni [ms09] t. margaria, b. steffen. business process modeling in the jabc: the one-thing approach. in handbook of research on business process modeling. pp. 1–26. igi global, 2009. [ms12] t. margaria, b. steffen. service-orientation: conquering complexity with xmdd. in conquering complexity. pp. 217–236. springer, 2012. [mur11] j. e. murphy. applications of evolutionary computation to quadrupedal animal animation. phd thesis, university college dublin, 2011. [nrg+20] e. naredo, c. ryan, i. guevara, t. margaria, p. urbano, l. trujillo. general controllers evolved through grammatical evolution with a divergent search. p. 243–244. association for computing machinery, new york, ny, usa, 2020. https://doi.org/10.1145/3377929.3390059 [nut17] e. naredo, p. urbano, l. trujillo. the training set and generalization in grammatical evolution for autonomous agent navigation. soft computing 21(15):4399–4416, aug 2017. doi:10.1007/s00500-016-2072-7 https://doi.org/10.1007/s00500-016-2072-7 [obf16] m. o’neill, a. brabazon, d. fagan. an exploration of grammatical encodings to model six nations rugby match outcomes. in 2016 ieee congress on evolutionary computation (cec). pp. 4429–4436. 2016. doi:10.1109/cec.2016.7744353 [or99] m. o’neill, c. ryan. automatic generation of caching algorithms. evolutionary algorithms in engineering and computer science 30:127–134, 1999. [ora10] d. oranchak. evolutionary algorithm for generation of entertaining shinro logic puzzles. in european conference on the applications of evolutionary computation. pp. 181–190. 2010. 13 / 14 volume 81 (2021) http://dx.doi.org/10.5281/zenodo.5097751 https://doi.org/10.5281/zenodo.5097751 https://github.com/microsoft/nni https://doi.org/10.1145/3377929.3390059 http://dx.doi.org/10.1007/s00500-016-2072-7 https://doi.org/10.1007/s00500-016-2072-7 http://dx.doi.org/10.1109/cec.2016.7744353 synthesising evolvable smart manufacturing scenarios [pri57] r. c. prim. shortest connection networks and some generalizations. the bell system technical journal 36(6):1389–1401, 1957. [smn+06] b. steffen, t. margaria, r. nagel, s. jörges, c. kubczak. model-driven development with the jabc. in haifa verification conference. pp. 92–108. 2006. [sp10] n. sorenson, p. pasquier. towards a generic framework for automated video game level creation. in di chio et al. (eds.), applications of evolutionary computation. pp. 131–140. springer berlin heidelberg, berlin, heidelberg, 2010. [tat20] a. tatnall. encyclopedia of education and information technologies. springer, 2020. [tpy10] j. togelius, m. preuss, g. n. yannakakis. towards multiobjective procedural map generation. in proceedings of the 2010 workshop on procedural content generation in games. pcgames ’10. association for computing machinery, new york, ny, usa, 2010. doi:10.1145/1814256.1814259 https://doi.org/10.1145/1814256.1814259 [wil96] d. b. wilson. generating random spanning trees more quickly than the cover time. in proceedings of the twenty-eighth annual acm symposium on theory of computing. stoc ’96, p. 296–303. association for computing machinery, new york, ny, usa, 1996. doi:10.1145/237814.237880 https://doi.org/10.1145/237814.237880 [wil99] u. wilensky. netlogo (version 4.1. 2)[software]. center for connected learning and computer-based modeling, northwestern university. illinois: evanston. available from http://ccl. northwestern. edu/netlogo/appendices, 1999. isola ds 2021 14 / 14 http://dx.doi.org/10.1145/1814256.1814259 https://doi.org/10.1145/1814256.1814259 http://dx.doi.org/10.1145/237814.237880 https://doi.org/10.1145/237814.237880 introduction related work scenario generation grammatical evolution robotic navigation framework direction experimental setup bnf grammar fitness function hyperparameters software architecture results future work lessons learned and conclusions using graph transformation systems to specify and verify data abstractions electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) using graph transformation systems to specify and verify data abstractions luciano baresi, carlo ghezzi, andrea mocci and mattia monga 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst using graph transformation systems to specify and verify data abstractions luciano baresi1, carlo ghezzi2, andrea mocci3 and mattia monga4 { baresi1, ghezzi2, mocci3 } @elet.polimi.it deepse group dipartimento di elettronica e informazione politecnico di milano piazza l. da vinci, 32 20133 milano, italy 4 mattia.monga@unimi.it, dico università degli studi di milano via comelico, 39 20135 milano, italy abstract: this paper proposes an approach for the specification of the behavior of software components that implement data abstractions. by generalizing the approach of behavior models using graph transformation, we provide a concise specification for data abstractions that describes the relationship between the internal state, represented in a canonical form, and the observers of the component. graph transformation also supports the generation of behavior models that are amenable to verification. to this end, we provide a translation approach into an ltl model on which we can express useful properties that can be model-checked with a sat solver. keywords: graph transformation systems, specifications, data abstractions, model checking, sat solving 1 introduction abstraction by specification [lg00] is the fundamental approach to abstract from implementation details by providing a high-level description of the behavior of a software component. such an abstract description of the behavior is the specification of the software component. in this paper, we focus on the specification of data abstractions [lg00], which can be viewed as a particular class of stateful components. in a data abstraction, the internal state is hidden; clients can interact with the component by invoking the operations exposed by its interface. common examples of data abstractions are stacks, queues, and sets, which are usually part of the libraries of modern object oriented languages, such as java. several formalisms have been proposed in the past for the specification of data abstractions. among these, we mention the pioneering work on algebraic specifications [gh78, gtw78]. recently, in the area of recovering specifications and program analysis, behavior models (see for example [dlwz06, xmy06]) have been proposed as a simple formalism to relate the observable part of a data structure with the methods used to modify its internal state. in this paper, we propose a generative approach for the construction of behavior models based on graph transformation systems. moreover, we found that the generative capabilities of graph transformation 1 / 14 volume 10 (2008) mailto:baresi@elet.polimi.it mailto:ghezzi@elet.polimi.it mailto:mocci@elet.polimi.it mailto:mattia.monga@unimi.it using graph transformation systems to specify and verify data abstractions tools are suitable for the generation of models that can be easily translated into logic models for verification. for this purpose, we propose a translation of graph-transformation generated models into a linear temporal logic, on which verification is possible via bounded model checking. this paper is organized as follows. section 2 recalls some background concepts on the specification of data abstractions. section 3 presents the case of a traversable stack, a container whose specification has been critically analyzed in the past because of its subtle intricacies. section 4 describes our approach to the specification of stateful components implementing data abstractions. section 5 contains our bounded model checking approach to the verification. finally, section 6 concludes the paper. 2 formalisms for data abstractions data abstractions hide their internal state and implementation and export a set of operations (methods), to allow clients to access their instances. methods can be classified as: • constructors, which produce a new instance of a class; • observers, which return some view of the internal state; • modifiers, which change the internal state. a method might both modify the internal state and return some information about it. in this case, such an observer is called impure; otherwise, it is pure, that is, it has no side-effects and does not alter the internal state of the object. stateful components implementing data abstractions may be specified by providing preand post-conditions [hoa69] for the methods exposed by the component’s interface. because a method may also change the internal state, this approach requires the introduction of a logical abstraction of the internal state, which complicates the specification of the component. for example, the jml language [lbr99] uses models for this purpose. algebraic specifications do not generally require an explicit abstraction of the hidden state, since it is implicitly taken into account through the use of axioms on sequences of operations. an algebraic specification is composed of two parts: the signature and the set of axioms. the algebraic signature defines the types (sorts) used in the set of axioms, and the signatures of the operations. the set of axioms is usually composed of a sequence of universally quantified formulae expressing equalities among terms in the algebra. for example, an algebraic specification for a class implementing a stack of strings may be characterized by the following axiom: ∀s ∈ stack,∀e ∈ string : pop(push(s, e)) = s which states that for every possible stack, the object obtained by the application of a push followed by a pop is equivalent to the original object. algebraic specifications are supported nowadays by various languages and tools [gh93, com04]. 2.1 behavior models a behavior model is a finite-state automaton that captures the relationship among the modifiers and return values of the observers. in a behavior model, each state is an abstraction of a set of proc. gt-vmt 2008 2 / 14 eceasst isempty() size ()=0 stack () !isempty() size ()>0 push( string ) push( string ) string pop() string pop() figure 1: a simple abstracted behavior model of a stack. size ()=0 read ()= error stack () pop() throws error size ()=1 read ()=a size ()=1 read ()=b size ()=2 read ()=b size ()=2 read ()=a size ()=2 read ()=b size ()=2 read ()=a push(a) push(b) push(a) pop() pop() pop() push(b)push(b) push(a) pop() pop() pop() figure 2: a deterministic behavior model for a stack different internal states of the actual component, identified by a simple predicate on the return values of a set of observers. several different approaches to recover behavior models have been implemented for various purposes. for example, adabu [dlwz06] behavior models are characterized by states labeled with pure observers, while transitions are labeled with method names (without actual parameters). other approaches, such as abstra [xmy06], produce more precise finite state machine abstractions by using different techniques to represent the component’s state. figure 1 shows the simple behavior model of a stack produced by adabu; in this model, the behaviors of all the stacks with size greater than zero are abstracted in a unique state. since infinitely many states are summarized in a finite-state machine, the resulting automaton is necessarily non-deterministic. however, a deterministic model is often more useful to reason about the properties of the component or to generate test cases; thus, we aimed at producing a deterministic specification, that is, one in which the application of each operation brings the automaton to a unique state, which represents a unique state of the object. figure 2 shows a partial deterministic model of the behavior of a stack. deterministic models grow bigger and, for components with infinite possible internal states, they can only partially represent the behavior of the component. deterministic models, such as the one of figure 2, rely on the presence of a set of instance pools for the actual parameters and represent the behavior of the component for such parameters. in the example, the push method is tested with an instance pool for the input parameter composed of two different strings, “a” and “b”. in this paper, we present 3 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions p u b l i c c l a s s mtstack { p u b l i c mtstack ( ) { . . } p u b l i c v o i d p u s h ( s t r i n g e l e m e n t ) { . . } p u b l i c v o i d pop ( ) t h r o w s e r r o r { . . } p u b l i c v o i d down ( ) { . . } p u b l i c v o i d r e s e t ( ) { . . } p u b l i c s t r i n g r e a d ( ) t h r o w s e r r o r { . . } p u b l i c b o o l e a n i s e m p t y ( ) { . . } p u b l i c i n t s i z e ( ) { . . } } figure 3: the public interface of majster’s traversable stack an approach to the representation of the complete, unabstracted and thus deterministic behavior of stateful components defining data abstractions by using graph transformation systems. 3 traversable stack in this section we introduce an example of data abstraction that is used as a running example to explain our approach. the example is inspired by a case study that generated a lively debate in the late 1970s in the community working on algebraic specifications. we will refer to the example as majster’s traversable stack (mts) [maj77], by the name of the author who first addressed the problem. the public interface of mts is shown in figure 3. for simplicity, we assume the contained object to be of type string . mts defines the usual operations of a stack, such as push and pop, and allows for traversal by using a hidden pointer and by exposing the following operations: • down, which traverses the stack circularly by moving the pointer stepwise towards the bottom of the stack; • read, which yields the element returned by the pointer; • reset, which moves the pointer on the top of the stack. for example, let us consider a stack of three elements, obtained by applying the constructor and three push operations of three different elements, the strings “a”, “b” and “c”. in this case, the read observer returns “c”. if a down operation is applied, the hidden pointer moves towards the bottom of the stack; thus, the read observer returns “b”. if the hidden pointer reaches the bottom of the stack, a further application of the down operation brings the hidden pointer to the top of the stack. mts was introduced because the author argued that no finite set of axioms could specify the data abstraction in an algebraic way without using auxiliary functions, that is, purely in terms of the externally visible operations. for example, the specification of the down operation would require axioms like the following: proc. gt-vmt 2008 4 / 14 eceasst downn ( downn−1 ( . . . ( down1 ( pushn ( . . . push2 ( push1(mt stack(), o1), o2 ) . . . ) , on )) . . . )) = pushn ( pushn−1 ( . . . push2 ( push1(mt stack(), o1), o2 ) . . . , on−1 ) , on ) since n 1 is generic in the axiom formula, the specification would require an axiom for each n > 0. in the sequel, we will show how mts can be rigorously specified in our approach, based purely on the operations exported by the data abstraction’s interface. 4 a graph transformation approach in this section we illustrate our approach to the specification of data abstractions based on graph transformations. let us consider the behavior model for a stack depicted in figure 2: it describes the behavior of all the stacks up to size 2. the specification of an abstract data type is given as a graph transformation system whose rules can be applied not only to generate such a partial (deterministic) model but also any other model that, for example, describes the behavior of stacks up to a generic size n. in this paper we use the approach to graph transformation systems implemented in agg [tae04], which supports a rich set of features, such as negative application conditions, attributes defined as java objects, and conditions on attributes. in the following, we define the type graph for mts, which defines the kinds of graph nodes and edges that are needed in the specification, and then we define the graph transformation rules. 4.1 type graph the type graph for mts is shown in figure 4. a state of the behavior model is either a null state or an object state (a stack of strings). conventionally, a null state represents the state of an instance object of the data abstraction before any application of a constructor. the null state is unique and represents the initial state of the behavior model. the type node representing an object state is labeled with a set of attributes, which represent the return values of the observers invoked when the object is in the corresponding state. edges represent constructors and modifiers. constructors link the null state node with a node representing the object state after applying a constructor, while modifiers are loops on the state node since they change the state of the instance. each edge is labeled with attributes corresponding to the parameters, the return value, and the exception the method might rise when applied (exceptions are modeled as boolean values). as already said, behavior models rely on instance pools of parameters to be used to generate actual invocations of modifiers. for example, we can generate a behavior model for mts that uses two strings, “a” and “b” as the possible contained objects. the type graph has a node for each type needed, labeled in the same way as the data abstraction node. for primitive types and 1 in this and in the following formulae, the superscript j above each operation indicates the j-th subsequent operation of that kind. 5 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions figure 4: mts type graph strings, we can box the value in a node that contains just an attribute representing the primitive type. 4.2 rules and canonical form since data abstractions hide their internal state, the information gathered by just invoking observers might be insufficient to uniquely identify the object state. for example, let us consider two mts of size 2, containing the same string “a” on the top and two different strings on the bottom, “a” for the first stack and “b” for the second. in both cases, let us consider the hidden pointer to be on the top of the stack. the invocation of the three observers (read, size, isempty) of the mts is insufficient to reveal the different internal state, since they would return the same values (i.e., “a” for read, 2 for size and false for isempty). inspired by veloso’s algebraic specification of mts [vel79], we use a canonical form for the data abstraction to identify each different object state. we define the canonical form as a language composed by method applications as tokens. the canonical form language must satisfy the following properties: • each string of the language is composed of an initial constructor and a —possibly empty— sequence of modifiers; • for each possible internal state, there is one and only one string of the canonical form language to represent it; • for each string of the language, there is an internal state that is labeled by that string, such that the invocation of the corresponding sequence of methods produces an object of that state. as a convenience, we identify a language of operations, which satisfies these properties, as a canonical form of the data abstraction. this explains why the object state node of the type graph on figure 4 is enriched with an attribute (cf) describing its canonical form. according to this approach, any possible mts instance can be represented with a string of the following canonical form language lmt s: • ε , which conventionally labels the null state; proc. gt-vmt 2008 6 / 14 eceasst nac lhs rhs (a) constructor rule nac lhs rhs ac: ! cf0 . contains (”down”) (b) canonical push rule nac lhs rhs ac: x>1 ∧ cf0 . count(”push”)−cf0.count(”down”)>1 (c) canonical down rule figure 5: partial gt specification of mts (part i) • mt stack(), that is, the empty stack after calling the empty constructor; • pushn ( pushn−1 ( . . . push1 (mt stack(), o1) . . . , on−1 ) , on ) , that is, a stack after any nonempty sequence of pushes; • downm ( downm−1 ( . . . ( pushn ( . . . push1 (mt stack(), o1) . . . , on )) . . . )) , 1 ≤ m < n, that is, any non-empty and non-singleton stack with at least one down invocation but strictly less than the stack size. for each internal state of the instances of the data abstraction, and thus for each string of the canonical form language, we can define which operations on that state are canonical, and those that are not. given a state x labeled with a canonical form x ∈ lmt s, an operation m is canonical in x if x ·m ∈ lmt s. for example, in the case of the canonical form of mts described above, the language defines when a push operation has to be considered as canonical, that is, whenever no (canonical) down operations have been applied to the instance. every other operation is non-canonical: such 7 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions operations bring the data abstraction in a state for which a corresponding different canonical string in the canonical language already exists. for example, the chosen canonical form language lmt s implies that every pop operation is non-canonical. once the language has been identified, we can define gt rules dealing with canonical operations (explained in section 4.3) and other rules dealing with non-canonical operations (explained in section 4.4. for example, the language of canonical method applications defined in section 3 for mts can be used as a canonical form language for the specification of the data abstraction. since for each state of the instances there exists a corresponding string of the canonical form language, we can use it to label each state of the graph. we implemented the canonical form attribute type with an ad-hoc java class that stores a list of strings, each representing an application of a canonical operation. each string is stored together with all the actual parameters of the corresponding operation application, which can be accessed by invoking the observers on the instance of the canonical form. 4.3 canonical form rules a canonical form rule defines a state generation, i.e., it specifies how a new state in a canonical form can be generated from an existing one by applying a canonical operation. canonical form rules share the following common template: • the left-hand side (lhs) of the rule is always composed of a single node for the data abstraction state, and a set of nodes representing the parameter’s values needed for applying the canonical operation; • the right-hand side (rhs) preserves the nodes contained in the lhs and, furthermore, it adds the new canonical state and a new edge between the two data abstraction states, to represent the application of the canonical operation. for example, the mts requires a canonical rule for the default constructor, and other rules for the canonical applications of methods push and down. canonical constructor rules generate new transitions from the null state to new nodes representing the object state after the invocation of a constructor. the lhs of constructor rules is composed of the null state and a set of nodes representing the parameter values for the invocation of the constructor. the rhs adds the generated state and initializes the observer attributes. the canonical form representation of the generated node is initialized with a new value representing the application of the constructor. for example, mts exposes only one constructor, which can be chosen as part of the canonical form. the canonical constructor rule is shown in figure 5a. modifier rules differ from constructor rules just because the node in the lhs is a node representing an object state: it cannot be the null state. the node must be identified by a set of attribute conditions, which uniquely identify the correct state on which the rule must be applied. figure 5b shows the rule for operation push. attribute conditions state that the canonical form cf0 must not contain any down operation. the rule introduces a new state, with size increased by one, the read observer returning the argument of the last push operation, and the canonical form modified by appending the push operation. figure 5c shows the canonical down rule, which can be applied whenever the difference between the number of push operations and that of down proc. gt-vmt 2008 8 / 14 eceasst nac lhs rhs ac: x>1 ∧ cf0 . contains (”down”) ∧ cf1 . equals ( cf0 . appendat(x+1,”push”,z )) ∧ z1 . equals ( cf1 . attr (1+cf1 . count(”down”))) (a) non-canonical push rule nac lhs rhs ac: x>1 ∧ cf0 . count(”push”)−cf0.count(”down”)==1 ∧ cf1 . equals ( cf0 . removeall(”down”)) ∧z1 . equals ( cf0 . attr (x )) (b) non-canonical down rule nac lhs rhs ac: x>1 ∧ cf1 . count(”down”)==0 ∧ cf1 . equals ( cf2 . append(”push”,z1 )) (c) pop rule figure 6: partial gt specification of mts (part ii) operations in the canonical form is greater than one. the introduced state has the same size as the previous and the read method returns the first attribute of the jth element of the normal form, where j = (x + 1) − cf0. countoperations (“down” ). it is not hard to prove that with the defined canonical form language that element in the canonical form is always a push and that after each down operation the read method returns the corresponding element obtained by moving the hidden pointer towards the bottom of the stack. negative application conditions (nacs) preserve the determinism of the generated behavior model. 4.4 non-canonical method rules the generative approach of canonical constructors and modifiers rules defines the state space of the data abstraction. thus, we represent non-canonical method applications as rules that add edges between existing nodes of the graph. with this approach, non-canonical method rules can 9 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions be applied iff the related states have been already generated by canonical form rules. the lhs and rhs of a non-canonical method rule must contain the two nodes, and the rhs of the rule creates the edge between them that represents the application of the method. in the mts case, method pop is not part of the canonical form. thus, every transition corresponding to the application of a pop operation is added by non-canonical modifier rules (see figure 6c). a more complex case regards operations down and push. in fact, these operations are not always part of a canonical form, depending on the context of the previous canonical operations applied to the object. for example, operation down is canonical only when applied after a sequence of n > 1 pushes, starting with a constructor, and for a maximum of n−1 times. otherwise, it is not canonical. thus, a non-canonical rule (see figure 6b) for operation down must be added to handle the non-canonical case. the non-canonical rule has a different context of application, represented by a different condition on attributes. in this case, the non-canonical down moves the hidden pointer to the top of the stack. in a similar way, the push operation is not canonical when applied after a down operation. in veloso’s specification, the operation is valid, and we can specify it with the rule of figure 6a. the mts specification does not contain any example of non-canonical constructor rule. such a rule would be similar to the case of non-canonical modifiers. 4.5 canonical form and topology in principle, attribute conditions on the canonical form could be expressed by topological patterns. for example, given the canonical push rule of figure 5b, one can notice that the attribute condition that states that the canonical form does not contain any down operation could be expressed by the following informal topological constraint: there exists a path from the null state to the node on the lhs of the rule, starting with a constructor edge and composed only of push edges. such topological conditions cannot be expressed with agg, thus we used equivalent attribute conditions. 5 verification our specification can be used to verify interesting properties of data abstraction specifications. our verification approach has two steps: (1) agg is used to generate a behavior model of the data abstraction; (2) the resulting model is translated into a linear temporal logic (ltl) model, on which we apply sat-solving [dp60] to model-check properties. 5.1 model generation in general, model checking a specification expressed with graph transformations is not easy; several solutions have been proposed for the general case [bs06, rsv04]. however, the behavior of our rules, as expressed in the previous section, is limited: they can only add new nodes or edges to the graph. at each transformation step, the graph on which the rule is applied is left unmodified by the rule itself. for this reason, the model to be checked is an instance graph (i.e., a behavior model of the data abstraction) after a limited number of rule applications, and it can be generated by simply using agg. proc. gt-vmt 2008 10 / 14 eceasst graph transformation rules can generate infinitely many behavior models. for example, for any data abstraction with potentially infinite states, our specification approach can generate an unbounded number of graphs representing the behavior of the data abstraction. to model check the specification against certain properties we need to bound generated models by adding some attribute conditions on the canonical form rules. non-canonical form rules are implicitly limited by the fact that they operate by only adding edges between existing nodes. for example, suppose that we want to verify a given property on the mts previously defined; we might choose to limit the scope of the verification to all the possible states of a mts with size < 4. we can limit the application of canonical rules, and thus the size of the model, by adding this constraint as a constraint to the attributes of canonical form rules. in the case of mts, the canonical rule to be constrained is the push canonical rule. if the size attribute of the node on the lhs is greater than or equal to 4, the push canonical rule is not applied, thus stopping the generation of new nodes. 5.2 ltl translation the model obtained by applying the rules of the graph grammar is translated into an ltl description which can be fed to zot [pms07], together with the set of properties that should be satisfied by all the possible states of the data abstraction. zot produces a corresponding set of propositional formulae which can be automatically used as input for a sat-solver. the axioms for the logical model are built in the following way: • we define a variable with finite domain for the state of the behavior model; the domain is a set of items defining the state in which an object of the data abstraction can be. • similarly, we define a set of variables for each observer attribute on each node representing a state of the object; for example, we might define a variable named size for the corresponding observer that can assume a set of different integer values, such as {0, 1, 2, 3} if we correspondingly limit the model. • we define a variable called do that represents the name of the operation enabled in the transition; it can assume a set of values composed of the names of the constructors and modifiers, together with a string representation of their actual parameters. axioms a set of axioms is needed to characterize each state with the corresponding observer variables. thus, the translation contains a set of implications of the following kind: state = s1a ⇒ (size = 1)∧(isempty = f alse)∧(read = a) enabled transitions can be expressed by defining axioms that denote which operations can be applied in a state. for example, the following axiom: state = s0 ⇒ (do = pusha ∨do = pushb ∨do = pope ) states that the only possible operations that can be done on the empty stack are push and pop operation, which is exceptional. 11 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions finally, we need axioms to define the postcondition of the application of methods. for example, the axiom: do = stack ⇒ x (state = s0) states that the next state after the invocation of the constructor is the state corresponding to the empty stack. another example is given by the following implications: (state = s0 ∧do = pusha ⇒ x (state = s1a))∧(state = s0 ∧do = pushb ⇒ x (state = s1b)) these implications define the different behavior obtained by pushing different elements on the empty stack. with all these axioms defined, we have an ltl specification on which each transition represents the application of an operation on instances of the data abstraction. for this reason, we can use the ltl operator x to predicate on which states are reached after the application of a sequence of methods. 5.3 example properties let us consider the following simple property, which states that the application of a pop after a push in any state brings the object to the same initial state: ∀x ∈ state vals ((state = x)∧(do = pusha ∨do = pushb)∧x (do = pop) ⇒ x 2(state = x)) precisely, the property states that if we are in state x and we push a or b, and then we do a pop, the final state is again x. another, more complex property, for the mts is that for any state x where the size of the stack is greater than or equal to 2, the application of n = size() down operations brings the object to state x: ∀x ∈ state vals, y ∈{2, 3} ((state = x)∧(size = y)∧ ( ∀k(0 ≤ k < y ⇒ x k(do = down)) ) ⇒ x y(state = x)) we fed zot with the ltl translation of a generated behavior model with states with size < 4, and checked it against these two properties. the ltl model, together with the negated properties, was found unsatisfiable in a few seconds; thus, the two properties are valid for the chosen bound. 6 conclusions this paper presents an approach to the specification and verification of data abstractions by using graph transformations. the generative nature of graph transformation provided a means to describe intensionally the (potentially infinite) behavior models of abstract data types, thus overcoming the limitations of plain finite-state automata. graph transformations can be used to generate behavior models of the specified data abstraction which can be easily translated into proc. gt-vmt 2008 12 / 14 eceasst a finite set of axioms suitable for automatic verification, for example by using a sat-solver. by using a generative approach, the complexity of the generated model can be tailored to the verification needs. our ongoing work is now on trying to infer behavior models defined through graph transformation systems by observing execution traces of existing module libraries. bibliography [bs06] l. baresi, p. spoletini. on the use of alloy to analyze graph transformation systems. in corradini et al. (eds.), icgt 2006: proceedings of 3rd international conference on graph transformation. lecture notes in computer science 4178, pp. 306–320. springer, 2006. [com04] common framework initiative. casl ref. manual. lncs 2960. springer, 2004. [dlwz06] v. dallmeier, c. lindig, a. wasylkowski, a. zeller. mining object behavior with adabu. in woda 2006: proceedings of 4th international workshop on dynamic analysis. may 2006. [dp60] m. davis, h. putnam. a computing procedure for quantification theory. j. acm 7(3):201–215, 1960. [gh78] j. v. guttag, j. j. horning. the algebraic specification of abstract data types. acta informatica 10(1), 1978. [gh93] j. v. guttag, j. j. horning. larch: languages and tools for formal specification. springer-verlag new york, inc., new york, ny, usa, 1993. [gtw78] j. a. goguen, j. w. thatcher, e. w. wagner. an initial algebra approach to the specification, correctness and implementation of abstract data types. in current trends in programming methodology. volume 4, pp. 80–149. prentice hall, 1978. [hoa69] c. a. r. hoare. an axiomatic basis for computer programming. cacm 12(10):576– 580, 1969. [lbr99] g. t. leavens, a. l. baker, c. ruby. jml: a notation for detailed design. in kilov et al. (eds.), behavioral specifications of businesses and systems. pp. 175–188. kluwer academic publishers, 1999. [lg00] b. liskov, j. guttag. program development in java: abstraction, specification, and object-oriented design. addison-wesley, boston, ma, usa, 2000. [maj77] m. e. majster. limits of the “algebraic” specification of abstract data types. acm sigplan notices 12(10):37–42, 1977. [pms07] m. pradella, a. morzenti, p. san pietro. the symmetry of the past and of the future: biinfinite time in the verification of temporal properties. in esec-fse ’07: proceedings 13 / 14 volume 10 (2008) using graph transformation systems to specify and verify data abstractions of the 6th joint meeting of the european software engineering conference and the acm sigsoft symposium on the foundations of software engineering. pp. 312–320. acm, new york, ny, usa, 2007. [rsv04] a. rensink, á. schmidt, d. varró. model checking graph transformations: a comparison of two approaches. in ehrig et al. (eds.), icgt 2004: proceedings of 2nd international conference on graph transformation. lecture notes in computer science 3256, pp. 226–241. springer, 2004. [tae04] g. taentzer. agg: a graph transformation environment for modeling and validation of software. in pfaltz et al. (eds.), application of graph transformations with industrial relevance. lncs 3062, pp. 446–456. springer, 2004. [vel79] p. veloso. traversable stack with fewer errors. acm sigplan notices 14(2):55–59, 1979. [xmy06] t. xie, e. martin, h. yuan. automatic extraction of abstract-object-state machines from unit-test executions. in icse 2006: proceedings of 28th international conference on software engineering, research demonstrations. pp. 835–838. may 2006. proc. gt-vmt 2008 14 / 14 introduction formalisms for data abstractions behavior models traversable stack a graph transformation approach type graph rules and canonical form canonical form rules non-canonical method rules canonical form and topology verification model generation ltl translation example properties conclusions properties of euler diagrams electronic communications of the easst volume 7 (2007) proceedings of the workshop on the layout of (software) engineering diagrams (led 2007) properties of euler diagrams gem stapleton, peter rodgers, john howse and john taylor 15 pages guest editors: andrew fish, alexander knapp, harald störrle managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst properties of euler diagrams gem stapleton1, peter rodgers2, john howse3 and john taylor4 1 g.e.stapleton@brighton.ac.uk,3 john.howse@brighton.ac.uk 4 john.taylor@brighton.ac.uk www.cmis.brighton.ac.uk/reseach/vmg university of brighton, uk 2 p.j.rodgers@kent.ac.uk university of kent, uk abstract: euler diagrams have numerous application areas, with a large variety of languages based on them. in relation to software engineering, such areas encompass modelling and specification including from a formal perspective. in all of these application areas, it is desirable to provide tools to layout euler diagrams, ideally in a nice way. various notions of ‘niceness’ can be correlated with certain properties that an euler diagram may or may not possess. indeed, the relevant layout algorithms developed to date produce euler diagrams that have certain sets of properties, sometimes called well-formedness conditions. however, there is not a commonly agreed definition of an euler diagram and the properties imposed on them are rarely stated precisely. in this paper, we provide a very general definition of an euler diagram, which can be constrained in varying ways in order to match the variety of definitions that exist in the literature. indeed, the constraints imposed correspond to properties that the diagrams may possess. a contribution of this paper is to provide formal definitions of these properties and we discuss when these properties may be desirable. our definition of an euler diagram and the formalization of these properties provides a general language for the euler diagram community to utilize. a consequence of using a common language will be better integration of, and more accessible, research results. keywords: information visualization, software specification, venn diagrams 1 introduction in software engineering, a large variety of diagrammatic languages are used to model and reason about software. of these languages, many are based on closed curves including some components of the unified modeling language (uml) such as class diagrams and state charts [dc05]. indeed, for the formal specification of software, kent introduced constraint diagrams [ken97] which are based on the well-known euler diagram language. constraint diagrams can express system invariants and operation pre-conditions and post-conditions. an example can be seen in figure 1 which shows an invariant on a video rental system, expressing that titles are partitioned into two disjoint subsets. the asterisks are universal quantifiers and the arrows, together with their sources and targets, make statements about properties of binary relations. in this particular 1 / 15 volume 7 (2007) mailto:g.e.stapleton@brighton.ac.uk mailto:john.howse@brighton.ac.uk mailto:john.taylor@brighton.ac.uk www.cmis.brighton.ac.uk/reseach/vmg mailto:p.j.rodgers@kent.ac.uk properties of euler diagrams example the arrows are both labelled nc, for ‘number of copies’. the diagram thus asserts that all elements in the set excoll (ex-collection) have no associated copies; all other titles are ‘incollection’ and are associated with some number of copies distinct from zero. the four closed curves in this diagram constitute and euler diagram. � � � � � � � � � � � � � � � � � � � � � � � � figure 1: a constraint diagram. constraint diagrams fulfil a similar role to that of the object constraint language, the only non-visual part of the uml; see [hs05, kc99] for examples of software modelling using constraint diagrams. a well studied fragment of the constraint diagram language, called spider diagrams [hst05], which are also based on euler diagrams has been used in a variety of application areas; see, for example, [cla05] where they are used in a safety critical environment. the relationship between spider diagrams, regular languages and finite state machines has also been investigated [ds07]. euler based diagrams have numerous other application areas; for example [des03, hes+05, kmgb05, lov02, sa05, tvv05]. thus, there are a whole range of languages based on closed curves that find applications in, or related to, software engineering. a collection of closed curves can be viewed as an euler diagram but there are a host of differing views of what constitutes such a diagram which will be discussed later in the paper. in all of the application areas mentioned above, the automatic layout of diagrams has the potential to be important and in some cases could be considered essential. for example, when using constraint diagrams to specify operations it might be necessary to prove that the postcondition of one operation implies the precondition of another. in such situations the reasoning may be automated; see [smf+07]. to display the results of that reasoning to the software engineer, the automatic generation of the diagrams in the proof is needed. titles incoll excoll titles incoll excoll titles incoll excoll figure 2: three euler diagrams. euler diagrams are used to make statements about sets. for example, given the sets titles = {x, y, z}, incoll = {x, y} and excoll = {z}, we can draw any one of the euler diagrams in figure 2 to represent this situation where the label titles represents the set titles and so forth. in general, proc. led 2007 2 / 15 eceasst the ideal is that an euler diagram can be found that represents the given collection of sets and has nice visual qualities, allowing the diagram to be interpreted by the user with ease; in figure 2, the lefthand diagram would probably be considered to be the nicest of the three because one can easily differentiate the curves. to this end, most of the generation algorithms developed to date draw euler diagrams that have certain properties, sometimes called well-formedness conditions. in general, the generation problem is to find an euler diagram that possess some given properties and represents some specified collection of sets. so, the generation problem can be broken down into a collection of subproblems, one for each set of properties. various methods for generating euler diagrams have been developed, each concentrating on a particular class of euler diagrams; see, for example [cr05b, cr03, fh02, kmgb05, vv04]. ideally, such generation algorithms will produce diagrams with desirable properties in an efficient way. the generation algorithms developed so far produce euler diagrams that have certain sets of properties. however, within the generation community, there is not a commonly agreed definition of an euler diagram and the properties imposed on them are rarely stated precisely. such precision is vital if we are to fully explore how to generate euler diagrams effectively and to answer various related questions such as whether an euler diagram exists that represents a certain statement and possesses certain properties. in section 2, we provide a general definition of an euler diagram and formalize various concepts which are necessary for the remainder of the paper. section 3 provides a formalization of a variety of properties that have been imposed on euler diagrams, either in existing layout work or in related application areas. finally, section 4 concludes and discusses implications for layout that imposing these properties brings. 2 euler diagram syntax there are various definitions of euler diagrams, most of which start with a set of closed curves and proceed to state that these curves have certain properties. for example, in [fh02] an euler diagram is a finite set of simple, labelled, closed curves, no pair of which have the same label or meet tangentially, and no point in r2 is in the image of more than two curves (that is, there are no triple points). by contrast, [vv04] allows curves to have the same label. exceptions to the curved based definitions include that in [lp97], where an euler diagram is viewed as a set of connected regions in the plane. in this section, we give a very generic definition of an euler diagram and build up the necessary language required to formulate certain properties that euler diagrams may possess. to begin, we recollect the definition of a closed curve. definition 1 a curve is a continuous function defined on an interval [x, y] ⊂ r. let c be a curve with domain [x, y]. if c(x) = c(y) then c is closed [bla83]. from this point, we assume that all curves are closed, have domain [0, 1] and have codomain r2 unless stated otherwise. we further assume that all curves c : [x, y] → r2 can be defined by c(t) = ( f (t), g(t)) where f and g are continuous; this allows us to utilize various topological concepts necessary for the formalization of the properties euler diagrams may possess. in an euler diagram, all curves have a label; we assume that their labels are drawn from a fixed set l . definition 2 an euler diagram, d, is a pair, (curve, l) where 3 / 15 volume 7 (2007) properties of euler diagrams 1. curve is a finite collection of closed curves each with codomain r2, 2. l : curve → l is a function that returns the label of each curve. in our figures, we sometimes draw a rectangle around euler diagrams to delineate them; such rectangles are not formally part of the diagram. given an euler diagram, we need to be able to identify the interior of the curves, since these diagrams make statements about set inclusion and disjointness by representing these relations in an isomorphic way; for example, to express incoll is a subset of titles, a curve labelled incoll is placed interior to a curve labelled titles; see figure 2. given a curve that does not self-intersect, one can easily identify the interior: by the jordan curve theorem, such a curve splits r2 into two pieces, the bounded piece which forms the interior and the infinite face which is exterior. however, the case for non-simple closed curves is not so obvious; see [fs06] for a discussion on this issue. in the case of any simple closed curve, c, we observe that any point, p ∈ r2, is inside c whenever c ‘winds’ exactly once around that point. for example, in figure 3, the leftmost curve is simple and the point p lies in its interior; here, c(0) denotes where we ‘start drawing the curve’ and the arrows indicate how we traverse the curve. for all three curves, the point p is interior and the curve winds around p exactly once; the shaded regions represent the interiors of the curves. in the middle and righthand curves, the point q is in the exterior; the middle curve does not wind around q at all whereas the righthand (non-simple) curve winds exactly twice around q. we use this insight to formally define the interior (and exterior) of general closed curves. titles c(0) p titles c(0) p titles c(0) p q q figure 3: identifying the interior: winding numbers. definition 3 let c be a closed curve and let p be a point in r2 −im(c). the point p is interior to c if the winding number of c with respect to p, denoted wind(c, p) is odd, with the set of all such points denoted int(c). all points in r2 that are not interior to c are exterior to c, with the set of all such points denoted ext(c). for any simple closed curve the winding number around any point in the bounded face is one, thus the definition of interior just given agrees with the intuitive notion interior in such cases. given an euler diagram, there may be more than one curve with a given label, such as d1 in figure 4. in [vv04], an euler diagram is permitted to have curves with common labels, augmented with a + or a −. the diagram d2 in figure 4 shows such a diagram. there are two curves labelled titles of which one is ‘positive’, labelled titles+, and the other is ‘negative’, labelled titles−. the area inside the curve labelled titles− represents the set incoll − titles. proc. led 2007 4 / 15 eceasst in [vv04], any curve, c1, with the same label as another curve, c2, is only placed inside c2 as titles titles incoll d1 titles + titles – incoll + d2 figure 4: diagrams with common labels. a result of their generation algorithm if c2 is augmented with a plus and c1 is augmented with minus. as a consequence, the augmentation is redundant because the placement of the curves implicitly provides the sign; the diagram d1 in figure 4 can be considered as having the same meaning d2. in [joh05], an euler diagram may also contain two curves with the same label. in general, curves with the same label are referring to the same set. just as with closed curves, we need to be able to identify the interior and exterior of curves with the same label. for example, d1 in figure 4 contains two labels: titles, which labels two curves, and incoll. the ‘interior’ of titles is the set of points interior to the curve labelled titles which contains the other two curves but not those points interior to the other curve labelled titles. this notion is consistent with our definition of interior for curves, using winding numbers. definition 4 let (curve, l) be an euler diagram and let cur(l) be the set of all curves in d with the label l. a point p is interior to cur(l) if the sum of the winding numbers of the curves in cur(l) with respect to p is odd; more formally, the sum ∑ c∈cur(l) wind(c, p) is odd. the set of interior points is denoted int(cur(l)). all points in r2 which are not interior to cur(l) are exterior to cur(l), the set of which is denoted ext(cur(l)). for any singleton set of curves of the form cur(l), we immediately see that the points interior to cur(l) are the same as those interior to the single curve which cur(l) contains. a set of curves cur(l) represents a set and the spatial arrangement of the curves in a diagram provides information about the relationship between those sets. thus it is useful to identify how the sets of curves of the form cur(l) partition the plane into pieces. definition 5 let d = (curve, l) be an euler diagram and let cur ⊆ {cur(l) : l ∈ im(l)}. if the set z = ⋂ cur(l′)∈cur int(cur(l′))∩ ⋂ cur(l′)∈{cur(l′):l∈im(l)}−cur ext(cur(l′)) is non-empty then z is a zone of d, with the set of such zones denoted z(d). in figure 4, d1 contains four zones (the four components of r2 minus the images of the curves). the zones are essentially given rise to by the labels used in the diagram: each subset of the label set gives rise to a set of the form cur as above. 5 / 15 volume 7 (2007) properties of euler diagrams 3 formalizing properties typically, generation techniques for euler diagrams aim to produce a layout that possess certain properties deemed desirable, possibly related to the understandability of the resulting diagram or appropriate for the application area. for example, a diagram with a certain property may be more understandable than one without that property. for each of the properties below, we provide examples to motivate their usefulness and discuss where they have been used in the related literature. 3.1 simplicity property many definitions of euler (based) diagrams stipulate that the curves must be simple [br98, cr05b, cr03, ham95, hst05, sa04, vv04] but others do not [bh96, cc04, dc05, sk00, shi94, sa05]. indeed, the layout work in [cr05b, fh02, vv04] assumes that all curves are simple. to recall, a simple curve is one that does not self-intersect. in figure 5, there are two diagrams with the same meaning and the lefthand side one contains a non-simple curve, labelled vinnie jones. guy richie uk gangster movies vinnie jones a diagram with a non simple curve. guy richie uk gangster movies vinnie jones a diagram with a duplicated curve label. vinnie jones figure 5: simplicity of curves. definition 6 a curve c is simple if for all x, y ∈ [0, 1], c(x) = c(y) implies x = y or |x − y| = 1. definition 7 an euler diagram, d, possesses the simplicity property if and only if all of the curves in d are simple. euler diagrams that possess the simplicity property are highly desirable due to the potential difficulty users may meet when interpreting diagrams whose curves are not simple. 3.2 unique labelling property the definitions of an euler diagram given in [bh96, br98, cc04, cr05b, cr03, dc05, ham95, hst05, sk00, sa05, sa04] allow labels to occur at most once in any euler diagram. thus, the unique labelling property is one that is commonly imposed on euler diagrams. an example can be seen in figure 5, where the lefthand diagram only uses labels once whereas the righthand diagram uses vinny jones twice. proc. led 2007 6 / 15 eceasst definition 8 an euler diagram, (curve, l), possesses the unique labelling property if the function l is injective. 3.3 connected zones property the lefthand diagram in figure 6 contains a zone (that inside both employees and members) which consists of two parts. such a zone is said to be disconnected. frequently, zones are required to form connected components of r2, as in [fh02, vv04, cr05b]. it can be hard to interpret euler diagrams with disconnected zones under some circumstances, for example when items are placed in zones. such a collection of items might be split up in two or more minimal regions, thus not allowing an immediate interpretation about the number or distribution of items. employees members mail subs a diagram with a disconnected zone. employees members mail subs a diagram with a 3 -point (triple point). figure 6: disconnected zones and multiple points. definition 9 let d = (curve, l) be an euler diagram. a non-empty set of points, m, in r2 is a minimal region of d provided m is a connected component of r2 − ⋃ c∈curve im(c) with the set of such minimal regions denoted m(d). definition 10 an euler diagram, d, possesses the connected zones property if all of the zones of d are also minimal regions of d, that is z(d) = m(d). 3.4 zone area property it is often desirable to visualize some value associated with the zones such as the cardinalities of the sets they represent. this motivates the need for generating area proportional euler diagrams, which are characterized by using a weight function to measure zone area. thus we introduce a zone area property that euler diagrams may possess. to satisfy this property, the zones in an euler diagram must have the area specified by a weight function. as an example, figure 7 shows an area proportional diagram providing information about the number of films in different categories. the weight function does not assign an area to the zone which is not inside any curves. in figure 7 the zone sizes are proportional to the weights within them. definition 11 let d be an euler diagram and w : z(d)−{ ⋂ cur(l′)∈{(cur(l)):l∈im(l)} ext(cur(l′))} → r+ 7 / 15 volume 7 (2007) properties of euler diagrams thrillers comedies romances 45 15 94 32 28 35 figure 7: an area proportional diagram. be a function. the diagram d possesses the w-zone area property if and only if all of the zones, z in the domain of w have area w(z). there are obvious variations of this property; for example, when drawing bounding rectangles around euler diagrams, rather than embedding them in the whole of r2, one can stipulate the area of all of the zones. the work on laying out area proportional euler diagrams typically produces diagrams that have connected zones [cr03, cr05b, kmgb05]. furthermore, some approaches to layout attempt to find area proportional diagrams with unique labelling and the property that each curve is a circle [cr05a, kmgb05]. exact area proportional layouts under these conditions is not always possible. the desirability of utilizing circles and getting an approximate result has also led to the notion of relative size, so that more diagrams can be drawn where the size of one zone is specified to be bigger than another [cr05a]. 3.5 connected diagram property a diagram is said to be connected if the (images of) the curves form a connected set, such as that in figure 7. any collection of sets can be represented by a connected diagram: intuitively, any disconnected diagram can be made connected by creating brushing points (defined later); [cho07] uses this result in the generation process. for example, figure 8 shows a disconnected diagram (left) which is ‘made connected’ by moving the curve labelled games upwards, shown in the middle diagram. all of the diagrams in this figure contain concurrent curves, but they have been slightly pulled apart for visual clarity. definition 12 an euler diagram, d = (c, l), possesses the connected diagram property if⋃ c∈c im(c) is connected. given a collection of sets, if we wish to find a diagram representing that collection but do not wish it to possess the connected diagram property then we can embed the disconnected parts separately; it is possible to identify disconnected (atomic) parts from the set information [fht04]. proc. led 2007 8 / 15 eceasst films dvds tapes games a disconnected diagram. films dvds tapes games a diagram with two curves brushing. films dvds tapes games a diagram with partial concurrency. figure 8: three diagrams with concurrent curves. 3.6 multiple point properties given an euler diagram that possesses the simplicity property, a point p in r2 is called an npoint if the number of curves that pass through p is exactly n. in the non-simple case, curves can pass through a point more than once and in such cases the number of times each curve passes through p contributes to the value of n. for example, the righthand diagram in figure 6 contains a 3-point, also called a triple point. with non-simple curves, a triple point can be formed from a single curve. a diagram in which all points are at most 2-points can make a diagram easier to understand, but reduces the number of diagrams that can be drawn without introducing other undesirable properties, such as concurrency and non-simple curves. the layout method in [fh02] draws diagrams that have a most 2-points. definition 13 let d = (curve, l) be an euler diagram and let p be a point in r2. we say that p is an n-point in d if ∑ c∈curve ∣∣{x ∈ [0, 1) : c(x) = p}∣∣ = n. definition 14 an euler diagram, d = (curve, l), possesses the n-point property provided each point in r2 is at most an n-point in d. 3.7 curve crossing property in an euler diagram, d, two curves in d may cross at a point p. furthermore, the two curves might intersect at p but not cross, in which case they brush at p. it may well be the case that two curves brush and cross at a point. for example, all intersection points of the curves in the diagram in figure 7 are crossing points whereas the middle diagram in figure 8 contains a brushing point, where games and films intersect. it is possible for a point to be both a crossing and a brushing point. we now proceed with a series of definitions that allow us to identify whether two curves cross at a point and whether they brush at a point. some generation algorithms produce diagrams that only permit curves to intersect only at crossing point that are not brushing points [fh02]. as an example, the curves in the lefthand diagram in figure 9, cross at the point p. to identify this formally, we can consider a disc neighbourhood n(p) around p see that it contains four 9 / 15 volume 7 (2007) properties of euler diagrams regions, one for each of the four combinations of being ‘inside’ or ‘outside’ c1 and c2. however, had c1, say, been non-simple it need not have had an interior. thus, we cannot use the notion of interior to define a crossing point. given c1, n(p) is cut into two pieces and we can arbitrarily assign positive and negative to each of these two pieces respectively. the curves in the middle diagram brush at p. here, the positive and negative regions do not correspond to each of the four combinations of being positive or negative to the two curves. c 1 c2 a diagram with a crossing point. pos(c1) pos(c2) neg(c1) pos(c2) neg(c1) neg(c2) pos(c1) neg(c2) n(p) p c 1 c 2 a diagram with a brushing point. neg(c1) neg(c2) neg(c1) pos(c2) neg(c1) neg(c2) pos(c1) neg(c2) n(p) p a b a diagram with brushing and crossing concurrency. c figure 9: crossing and brushing curves. definition 15 let c : [x, y] → r2, where the notation [x, y] denotes any closed interval of r2. let p be a point in im(c) and let n(p) be a disc neighbourhood of p. if n(p)− im(c) consists of exactly two connected components then n(p) is called a splitting neighbourhood of p for c. definition 16 let c1 : [x, y] → r2 and c2 : [a, b] → r2 be two curves such that there is a unique point p in im(c1)∩ im(c2). if there exists a disc neighbourhood n(p) such that 1. n(p) is a splitting neighbourhood of p for c1; arbitrarily call one of the two connected components pos(c1) and the other neg(c1), 2. n(p) is a splitting neighbourhood of p for c2; arbitrarily call one of the two connected components pos(c2) and the other neg(c2), 3. n(p) contains a point in pos(c1)∩ pos(c2), 4. n(p) contains a point in pos(c1)∩ neg(c2), 5. n(p) contains a point in neg(c1)∩ pos(c2) and 6. n(p) contains a point in neg(c1)∩ neg(c2) then c1 and c2 are said to cross at p. otherwise c1 and c2 brush at p. let c1 : [0, 1] → r2 and c2 : [0, 1] → r2 be two closed curves such that there is a point p in im(c1)∩ im(c2). if there exist closed intervals i1, i2 ⊆ [0, 1] such that 1. im(c1|i1 )∩ im(c2|i2 ) contains exactly p, 2. the curves c1| and c2| cross at p proc. led 2007 10 / 15 eceasst then c1 and c2 cross at p. if there exists i1, i2 ⊆ [0, 1] such that 1. im(c1|i1 )∩ im(c2|i2 ) contains exactly p, 2. the curves c1| and c2| brush at p then c1 and c2 brush at p. definition 17 an euler diagram, d, possesses the crossing property if and only if whenever two curves, c1 and c2, in d intersect they cross but do not brush. the concepts of crossing and brushing can be generalized to curve segments as well as being defined for points; see the discrete property below. 3.8 discrete property the embedding methods of [vv04, cr05b] sometimes produce diagrams with concurrent line segments. if concurrency is permitted, along with either non-simple curves or multiple curves with the same label, then any collection of sets can be represented by an euler diagram. moreover, many collections of sets can only be represented by euler diagrams with concurrent line segments when certain properties are imposed. however, concurrent line segments can make it difficult to interpret a diagram; the generation algorithm in [fh02] only produces diagrams without concurrency; thus the curves in these diagrams intersect only at a discrete set of points. definition 18 a set of points, x ⊆ r2, is discrete if for every point x ∈ x there exists ε > 0 such that {p ∈ r2 : d(p, x) ≤ ε}∩ x = {x} where d(p, x) is the standard euclidean distance between p and x. definition 19 an euler diagram, d = (curve, l), possesses the discrete property if all pairs of curves in curve do not run concurrently: {x ∈ r2 : ∃a, b ∈ [0, 1]a 6= b ∧ c1(a) = c2(b) = x} is a discrete set of points. so, any diagram that possesses the discrete property does not have concurrent curves. with non-simple curves, self concurrency is possible, so that the curve is concurrent with itself. there are a number of variations of concurrency. its possible to have ‘crossing’ or ‘brushing’ concurrency depending on whether the curves cross at the start and end of the concurrency segment. for example, the righthand diagram in figure 9 a and b brush concurrently (where the concurrent line segments have been drawn slightly pulled apart for clarity) and a crosses c concurrently, as does b. an important variation is the distinction between ‘full’ concurrency and ‘partial’ concurrency. full concurrency can be seen in figure 8, with the curves labelled dvds and films have full concurreny, as do tapes and films whereas the curves labelled games and films have partial concurrency. 11 / 15 volume 7 (2007) properties of euler diagrams for full concurrency the line segments of the two curves, c1 and c2, separate at a point which is a crossing point or a brushing point for some pair of curves or a point where another curve separates from a concurrent line segment; any other concurrency is partial. it is thought that partial concurrency can always be removed from a diagram. 3.9 curve shape properties curves may have the property of having a particular geometric shape, such as circle, oval, triangle, square or being n-gons; the work in [cr05a, kmgb05] generates euler diagrams consisting only of circles and that in [cfw05] is concerned with k-gons with a particular focus on triangles. a weaker constraint may be to require that all curves are the same shape, even if it is not regular. further, a curve may be smooth, in the sense that its function is differentiable. sometimes there is a requirement that all curves are convex, so concave curves are not permitted, see, for example, [lp97]. in practice, most implemented diagram visualization methods restrict the shape of the curves to some extent, due to the restrictions on line visualization in software environments; for example, [cr05a, fh02, vv04] generates diagrams whose curves are polygons. definition 20 an euler diagram, d = (curve, l), possesses the smooth property if all of the curves in curve are smooth. a curve, c, is convex if it is simple and its interior is convex; that is, for each pair of points in the interior of c there is a straight line between those points that lies in the interior of c. definition 21 an euler diagram, d = (curve, l), possesses the convex property if all of the curves in curve are convex. definition 22 let s be a set of shapes. an euler diagram, d = (curve, l), possesses the sshapes property if all of the curves in curve are one of the shapes in s. 4 conclusion in this paper, we have provided a very general definition of an euler diagram and provided a formalization of many properties that such diagrams are frequently required to possess. this definition and formalization provides a common language for the euler diagram community to utilize. a consequence of using this common language will be more accessible and better integrated research results. given the wide variety of languages based on closed curves that are utilized in software engineering, the framework described here has the potential to bring many important benefits. there is a range of further properties that euler diagrams may possess that can also be considered desirable which we have not formalized in this paper. however, they are not so commonly considered by euler diagram users. a monotonic diagram is one which always allows zones to be resized or collapsed and still maintain simple curves. it is a property of diagrams formed from the [cr05b] embedding process, which produces an area proportional diagram from a venn diagram construction. we do not include it amongst the main properties, as the definition of a proc. led 2007 12 / 15 eceasst monotonic diagram relies on the notion of the dual of the euler diagram, rather than the direct definition of a diagram. it is also possible to add zones to diagrams in order to ensure a diagram has certain properties. here, the added zones might be shaded, as with the original work of venn [ven80] and the embedding process of [kmgb05] which does not guarantee that the initially specified zones are present. in this case a desirable property of a diagram might be that it has the smallest number of extra zones so as to possess certain other properties. one area of study in the venn community is the notion of drawing a diagram in a symmetric manner. although certain collections of sets can be represented by symmetric euler diagrams, in the general case symmetry is not possible. it is also unclear how much an aid to user interpretation of a diagram is helped by symmetry. the context in which an euler diagram is to be used is likely to influence those properties deemed desirable. the generation work to date produces diagrams that have specified selections of properties we have formalized. many difficult open problems remain to be solved. given a collection of sets, it is unknown which properties can be possessed by euler diagrams which represent those collections. for instance, classifying exactly which collections of sets can be represented by diagrams which possess the simplicity and unique labelling properties remains unanswered. we might also choose which properties a generated euler diagram has, given a collection of sets that we wish to visualize. an algorithm that incorporates such user choice where possible has not yet been developed. some collections of sets can be represented by an euler diagram that possess exactly one of the discrete property and the 2-point property; under such circumstances these two properties are exchangeable. further study into which properties can be exchanged needs to be performed. acknowledgements: this work is support by esprc grants ep/e011160/1 and ep/e010393/1 for the visualization with euler diagrams project. additionally, gem stapleton is supported by a leverhulme trust early career fellowship. thanks to andrew fish for discussing various aspects of this paper. bibliography [bh96] j. barwise, e. hammer. diagrams and the concept of logical system. in allwein and barwise (eds.). oxford university press, 1996. [bla83] d. blackett. elementary topology. academic press, 1983. [br98] b. bultena, f. ruskey. venn diagrams with few vertices. electronic journal of combinatorics 5:1–21, 1998. [cc04] l. choudhury, m. k. chakraborty. on extending venn diagrams by augmenting names of individuals. proceedings of 3rd international conference on the theory and application of diagrams, springer, pages 142–146, march 2004. [cfw05] j. carroll, f. ruskey, m. weston. which n-venn diagrams can be drawn with kgons. proceedings of euler diagrams 2005, 2005. 13 / 15 volume 7 (2007) properties of euler diagrams [cho07] s. chow. generating and drawing area-proportional euler and venn diagrams. phd thesis, university of victoria, 2007. [cla05] r. clark. failure mode modular de-composition using spider diagrams. proceedings of euler diagrams 2004 elsevier, entcs vol. 134, pages 19–31, 2005. [cr03] s. chow, f. ruskey. drawing area-proportional venn and euler diagrams. proceedings of graph drawing 2003, perugia, italy, springer, 466–477, september 2003. [cr05a] s. chow, p. rodgers. constructing area-proportional venn and euler diagrams with three circles. proceedings of euler diagrams 2005, 2005. [cr05b] s. chow, f. ruskey. towards a general solution to drawing area-proportional euler diagrams. proceedings of euler diagrams, elsevier, entcs vol 134, pages 3–18, 2005. [dc05] h. dunn-davies, r. cunningham. propostional statecharts for agent interaction protocols. proceedings of euler diagrams 2004, brighton, uk elsevier, entcs vol 134, pages 55–75, 2005. [des03] r. dechiara, u. erra, v. scarano. a system for virtual directories using euler diagrams. proceedings of information visualisation, ieee computer society, pages 120-126, 2003. [ds07] a. delaney, g. stapleton. on the descriptional complexity of a diagrammatic notation. accepted for visual languages and computing, knowledge systems institute, 2007. [fh02] j. flower, j. howse. generating euler diagrams. proceedings of 2nd international conference on the theory and application of diagrams, springer, pages 61–75, april 2002. [fht04] j. flower, j. howse, j. taylor. nesting in euler diagrams: syntax, semantics and construction. software and systems modelling 3:55–67, march 2004. [fs06] a. fish, g. stapleton. formal issues in languages based on closed curves. proceedings of distributed multimedia systems, international workshop on visual languages and computings, knowledge systems institute, pages 161–167, 2006. [ham95] e. hammer. logic and visual information. csli publications, 1995. [hes+05] p. hayes, t. eskridge, r. saavedra, t. reichherzer, m. mehrotra, d. bobrovnikoff. collaborative knowledge capture in ontologies. proceedings of the 3rd international conference on knowledge capture, pp. 99–106, 2005. [hs05] j. howse, s. schuman. precise visual modelling. journal of software and systems modeling 4:310–325, 2005. proc. led 2007 14 / 15 eceasst [hst05] j. howse, g. stapleton, j. taylor. spider diagrams. lms journal of computation and mathematics 8:145–194, 2005. [joh05] c. john. projected contours in euler diagrams. euler diagrams 2004 elsevier, entcs vol 134, pages 103–126, 2005. [kc99] s.-k. kim, d. carrington. visualization of formal specifications. 6th asia pacific software engineering conference, ieee computer society press, pages 102–109, 1999. [ken97] s. kent. constraint diagrams: visualizing invariants in object oriented modelling. proceedings of oopsla97, pages 327–341, october 1997. [kmgb05] h. kestler, a. muller, t. gress, m. buchholz. generalized venn diagrams: a new method for visualizing complex genetic set relations. journal of bioinformatics 21(8):1592–1595, 2005. [lov02] j. lovdahl. towards a visual editing environment for the languages of the semantic web. phd thesis, linkoping university, 2002. [lp97] o. lemon, i. pratt. spatial logic and the complexity of diagrammatic reasoning. machine graphics and vision 6(1):89–108, 1997. [sa04] n. swoboda, g. allwein. using dag transformations to verify euler/venn homogeneous and euler/venn fol heterogeneous rules of inference. journal on software and system modeling 3(2):136–149, 2004. [sa05] n. swoboda, g. allwein. heterogeneous reasoning with euler/venn diagrams containing named constants and fol. proceedings of euler diagrams 2004 elsevier, entcs vol 134, 2005. [shi94] s.-j. shin. the logical status of diagrams. cambridge university press, 1994. [sk00] h. sawamura, k. kiyozuka. jvenn: a visual reasoning system with diagrams and sentences. proceedings of 1st international conference on the theory and application of diagrams springer, pages 271–285, 2000. [smf+07] g. stapleton, j. masthoff, j. flower, a. fish, j. southern. automated theorem proving in euler diagrams systems. journal of automated reasoning, june 2007. [tvv05] j. thiévre, m. viaud, a. verroust-blondet. using euler diagrams in traditional library environments. euler diagrams 2004 elsevier, entcs vol 134, pages 189– 202, 2005. [ven80] j. venn. on the diagrammatic and mechanical representation of propositions and reasonings, phil.mag, 1880. [vv04] a. verroust, m.-l. viaud. ensuring the drawability of euler diagrams for up to eight sets. proceedings of 3rd international conference on the theory and application of diagrams springer, pages 128–141, 2004. 15 / 15 volume 7 (2007) introduction euler diagram syntax formalizing properties simplicity property unique labelling property connected zones property zone area property connected diagram property multiple point properties curve crossing property discrete property curve shape properties conclusion enhancing planning-based adaptation middleware with support for dependability: a case study electronic communications of the easst volume 11 (2008) proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) enhancing planning-based adaptation middleware with support for dependability: a case study romain rouvoy, roman vitenberg and frank eliassen 12 pages guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst enhancing planning-based adaptation middleware with support for dependability: a case study romain rouvoy, roman vitenberg and frank eliassen universitetet i oslo, department of informatics, networks and distributed systems group p.o.box 1080 blindern — 0316 oslo, norway rouvoy@ifi.uio.no, romanvi@ifi.uio.no, frank@ifi.uio.no abstract: recent evolutions of mobile devices have opened up for new opportunities for building advanced mobile applications. in particular, these applications are capable of discovering and exploiting software and hardware resources that are made available in their environment. a possible approach for supporting these ubiquitous interactions consists in adapting the mobile application to reflect the functionalities that are provided by the environment. however, these approaches often fail in offering a sufficient degree of resilience to potential device, network, and software failures, which are particularly frequent in ubiquitous environments. therefore, the contribution of this paper is to integrate the dependability concern in the process of mobile applications adaptation. in particular, we propose to reflect dependability mechanisms as alternative configurations for a given application. this reflection allows the planning-based adaptation middleware to automatically decide, based on contextual information, to enable the support for dependability or not. keywords: planning-based adaptation, component-based architecture, dependability mechanisms, self-adaptation 1 introduction the growing interest for highly collaborative applications, such as social networks, and the democratization of mobile devices open up opportunities for new trends of mobile applications. in particular, these applications are able to discover and benefit from software and hardware resources available in their environment. user devices that support such ubiquitous computing systems require continuous software adaptations to face the changes in the user environment (e.g., physical location, network connectivity, energy consumption). however, the state-of-theart adaptation methods and technologies do not consider possible device, network, and software failures; they may cease being functional in face of such failures [ccki07]. although dependability mechanisms provide relevant solutions for building fault-tolerant mobile applications (replication, group communication, etc.) [hhs04], the configuration and the deployment of such mechanisms remains a cumbersome task since it requires to correlate the characteristics of the environment to the attributes of the mechanisms. in a ubiquitous environment, this task becomes critical since the particularities of the environment are not foreseen by definition. therefore, we propose to enhance an existing adaptation middleware with the capability of selecting, deploying and monitoring dependability mechanisms. in particular, we are 1 / 12 volume 11 (2008) mailto:rouvoy@ifi.uio.no, romanvi@ifi.uio.no, frank@ifi.uio.no dependability support for an adaptive application: a case study interested in modeling legacy dependability mechanisms in terms of quality of service (qos) properties. thanks to that, we aim at supporting the seamless planning of dependability mechanisms and their respective strategies and thus making easier their integration into mobile applications. the rest of the paper is organized as follows. section 2 describes a typical scenario of a social application built atop a planning-based adaptation middleware. it also derives a few salient characteristics of the scenario and illustrates how dependability enhances the application behavior. section 3 provides background on common adaptation and dependability techniques and solutions. section 4 outlines our contribution for the seamlessness support of dependable configurations. section 5 describes and discusses related work, while section 6 concludes the paper. 2 motivating scenario to further motivate the need for adaptation in dependable computing environments, let us consider the following scenario. paul recently bought an internet tablet and installed a version of the instantsocial (is) application on this mobile device. this application aims at creating virtual communities by instant sharing of multimedia content. in particular, the application offers functionalities, such as picture sharing, instant messaging, and video broadcasting. scene 1. the scenario starts with paul going to a concert of björk in paris. unfortunately, he arrives a bit late and is a bit far away from the stage to see the artists. however, his is application detects that an ad hoc network is available and that john, who is closer to the stage, broadcasts a video of the performance. the application connects to the broadcasting service advertised by john’s mobile device and allows paul to watch the artists while listening to the music. the video stream is relayed by other mobile devices located in the same place. scene 2. the battery of john’s device gets depleted so that his device adaptively changes its configuration to prohibit relaying unnecessary data. fortunately, paul’s is application detects that joanne provides a similar video stream, transparently reconnects to joanne’s device, and proceeds with minimal frame loss. scene 3. because paul really enjoys the concert, he takes some pictures of the event in order to feed his blog when going back home. the photos he takes with the device camera are automatically tagged by the is applications with his current position using the embedded gps of the device. the is application starts looking for other photos taken around him and display them on paul’s device. scene 4. now the concert is over, it’s time to go back home and paul enters the metro station. the is application detects the network infrastructure provided to the travelers and adapts itself to connect to the available facilities. in particular, the infrastructure provides a service buddy finder that helps travelers finding buddies who share common interests. the is application requests the service to find buddies who share multimedia content related to the concert of björk that just finished. the service federates multimedia content provided by other devices all around the station and displays it on paul’s device. scene 5. the notification service of the metro station broadcasts a message about train delay in the line that paul was about to take. this announcement causes paul to take a different transportation path. proc. campus 2008 2 / 12 eceasst characteristics of the scenario the scenario we introduce exhibits properties that are representative of nowadays mobile applications: moderate to high dynamicity. the application operates in a dynamic environment in which the rate of changes is high and there exists a turnover in the nodes participating in the application. the above scenario illustrates high node mobility and fluctuations in the resource availability. large scale. the application may potentially include hundreds and even thousands participating distributed nodes. realistically, it is quite easy to envision the extension of the above scenario to such scales. distribution of nodes and services. the application is based on a fully distributed architecture where nodes can cooperate using a moderately involved communication scheme (as opposed to the star-based architecture wherein all nodes communicate with a single server). furthermore, we assume that the application knowledge (e.g., the application configurations and available resources) is also distributed among the participating nodes. broad diversity of application-required qos. the application combines many different activities that involve communication between the nodes. we assume that data exchanged between the distributed nodes have different priorities (e.g., logging information [not critical], control information [very critical]), different bandwidth demands (from a few byte long message to intensive multimedia data), and different interaction frequency (e.g., from every 5 seconds to every few days). diversity in communication paradigms. the same application may combine different communication types (messaging vs. streaming) and paradigms (client-server, overlay-based, pubsub). needs for dependability although the scenario we exposed proposes usual functionalities of a social application, we foresee that the use of such applications in ubiquitous environments requires the support of dependable mechanisms to ensure an acceptable behavior under volatile connectivity and changing environmental conditions. for example, the entire scenario motivates the need for reliable communication mechanisms. in particular, the video content being delivered by john to paul should be made highly available to ensure that the quality of the stream will not be critically affected by the number of users watching the video and by the quality of the network. this also means that the content delivery should be made reliable. however, the degree of reliability may depend on a number of factors: type of content, data intensity, update frequency, number of interested consumers, etc. in addition, different contents (photos and videos) may also require varying degrees of freshness and in the case of multi-source updates, policies for conflict resolution (update order errors). in addition, most of the scenes motivate the need for service discovery. for example, when paul joins the network infrastructure available in the metro station in scene 4, its application should discover the services provided by third parties. when fulfilling the requirements of the application, these services should be seamlessly integrated by the mobile device. scene 1 emphasizes the demand for dependable cooperation and ad-hoc routing between the devices. it also illustrates the need for reliable synchronization between different streams, such as the audio stream the device receives directly from the technical equipment of the concert settings and the video stream it receives from other cooperating mobile devices. in the general 3 / 12 volume 11 (2008) dependability support for an adaptive application: a case study case, reliable synchronization should be performed between content of different types: video with video, audio with video, text with multimedia, etc. scene 2 motivates the need for failure detection, monitoring operational capacity and connectivity, and membership maintenance. these functionalities can obviously prove useful in other scenes as well. additionally, this scene illustrates the value of transparent takeover mechanisms for the is application. in scene 3, the pictures concert fans take should be replicated for the sake of high-availability and fault-tolerance through redundancy. since it is impossible to store all data on every device, data-sharing should be attained through partial and content-dependent replication. 3 foundations this section introduces the foundations of our contribution by presenting concepts related to planning-based adaptation middleware (cf. subsection 3.1), and dependability mechanisms (cf. subsection 3.2). 3.1 planning-based adaptation middleware planning-based middleware refers to the capability of adapting an application to changing operating conditions by exploiting knowledge about its composition and quality of service (qos) metadata associated to the application components [fhs+06, ahpe07]. we therefore consider applications that are developed with a qos-aware component model. the qos model associated with a ubiquitous application defines all the reasoning dimensions used by the planning-based middleware to select and deploy the component implementations that contribute to provide the best utility. the utility of an application grows when its constituting components better fulfill user preferences while optimizing device resource consumption. for example, in figure 1, we illustrate the modeling of a self-adaptive logger component using a qos-aware component model. the configuration of this logger can be optimized dynamically in order to maximize the satisfaction of the user. in particular, the component logger composition is made of three components receiver, handler, and storage, which have one, three, and two alternative configurations, respectively. as we already mentioned, the evaluation of these alternative configuration is driven by the qos properties associated to the application. for example, table 1 reflects possible property dimensions for describing the logger qos. these properties values are then specified and associated to components using notes in the application model. in case of composite components, the value is a function combining the qos properties of contained components. in case of atomic components, the value usually refers to a primitive value. then, planning refers to the process of selecting components that make up an application variant that provides the best possible utility to the end user. this process can be triggered during several steps of the application life cycle, such as during the deployment of the application or at runtime if the execution context suddenly changes. the parts of the application that are considered during planning are called variation points. these correspond to functionalities (type of behavior) defined in the component frameworks modeling the application. thus, each variproc. campus 2008 4 / 12 eceasst receiver simple receiver pp lat = 0 bat = 10 storage file storage pp lat = 100 cap = sys://hda@free bat = 30 db storage pp lat = 30 cap = sys://hdb@free bat = 100 handler pretty handler pp lat = 30 bat = 25 plain handler pp lat = 10 bat = 15 xml handler pp lat = 50 bat = 20 logger logger composition storagereceiver hrl pp cap = storage.cap lat = (receiver.lat + handler.lat + storage.lat) x sys://processor@clock bat = receiver.bat + handler.bat + storage.bat handler h s s ilogger figure 1: the model of a component-based logger. table 1: the specification of the logger qos property dimensions. property name description value range cap capacity of the logger 0–? lat latency of the logging request 0–100 bat battery consumption of the logger 0–100 ation point identifies a functionality of the application that can be implemented differently. in addition, each component implementation suitable for a variation point is reified as a plan by the planning-based middleware. a plan mainly consists of a structure that reflects the type of the component implementation and the qos properties associated to the services it provides. in particular, the plan exhibits both requested properties (e.g., memory consumption, network bandwidth, network connectivity) and offered properties (e.g., request throughput, latency, result accuracy) referring to the qos model of the application. to estimate the offered properties of a plan, the planning-based middleware relies on property predictors. the property predictors are used to predict the offered properties of a component implementation as a function using the required properties and the current execution context as parameters. the predictors can also take into account the state of the component implementation associated to the plan—i.e., described, deployed, or running—to refine the prediction. the qos model used by the planning framework can be customized to handle new qos dimensions (e.g., monetary cost), while the property predictors can be configured to support complex heuristics (e.g., qos negotiation protocols). the predicted properties are input to a normalized utility function that computes the expected utility of a composition of plans making up an alternative application configuration [bhre07]. for example, the utility function used to evaluate the logger configuration can be configured as the following: utility(logger) = u serbat norm(bat) + u serlat norm(lat) + u sercap ×norm(cap) 5 / 12 volume 11 (2008) dependability support for an adaptive application: a case study this utility function minimizes the battery consumption and latency of the configuration, while maximizing its capacity. the user preferences (u serxxx) are used to weight each qos dimension and ensure that the output will be a normalized value. the function norm(xxx) is used to normalize the property prediction to a scalar value between 0 and 1. the planning-based middleware compares the expected utility of all alternate application configurations, and finally selects the one that provides the highest value. figure 2 illustrates the architecture of the music middleware, which supports the planningbased adaptation. the component planner supports the planning procedure by operating a generic reasoning heuristics that exploits metadata included in the available plans. in particular, the plans are composed based on their type compatibility to describe alternative application configurations. then, the heuristics ranks the application configurations by evaluating their utility with regards to the application objectives. this evaluation is achieved by computing the offered properties using the property predictors associated to each plan contained in the selected application configuration and retrieved from the component plan repository. adaptation manager planner am pp property predictor pp c configurator c p b kernel factoryp binderb plan repository br b p brbr cm cl context manager cmcl pm pm am plplpl prprpr ipredictormanager iadaptationmanager iplanrepository iplanresolver iplanlistener icontextlistener icontextmanager ipredictor iconfigurator ifactory ibinder figure 2: the architecture of the music planning-based adaptation middleware. the component plan repository provides an interface iplanresolver for the planner to retrieve plans associated with a given component type during planning. the planner may request plans that are compatible with a given variation point, at which point the plan repository will search for matching component types. any additional metadata on the required component type will help the plan repository to exclude plans and filter the search space [lso+07, bhre07]. plans are typically published to (and discarded from) the plan repository by applications and component development tools using the interface iplanrepository, and can thus trigger the planner for re-planning of the application if needed (e.g., the discarded plan was associated to a running component). proc. campus 2008 6 / 12 eceasst the reconfiguration process is handled by the component configurator and consists of taking the set of plans selected by the component planner and reconfiguring the application. before deploying the application configuration selected by the reasoning engine, the component configurator brings the current application into a quiescence state, by suspending the execution of its contained components. then, if the component described by a plan is in the running or deployed state, the associated component instance is configured for the variation point and connected to other components using the component binder. if the component is in the described state, then the component should be preliminary instantiated and deployed by the component factory using the component implementation description associated to the plan. the result of the reconfiguration (e.g., reference of the deployed instance) is automatically reflected into the selected plans. thus, the music planning-based middleware offers a modular and extensible approach for adapting applications built with various types of component models. in particular, the concept of plan can be derived to support heterogeneous artifacts and their associated states. furthermore, the components factory and binder provide sufficient abstractions for supporting different dependability mechanisms (e.g., replication, load-balancing, group communication). 3.2 dependability mechanisms dependability covers a wide range of mechanisms, and each of these mechanisms exhibit strategies and parameters that usually need to be set up based on application-specific and contextdependent information. for example, we observed that each of the following dependable mechanisms can be configured in different ways. replication mechanisms are used to replicate parts of system state in order to ensure fault tolerance and high availability. however, there exist a large variety of replication strategies (e.g., passive/active replication) and each of these strategies supports several configuration parameters (e.g., replication factor, update propagation scheme and frequency, replication degree); load-balancing mechanisms rely on different scheduling strategies to dispatch the incoming requests to services that are expected to be highly available. the goal of these mechanisms is to ensure that the system latency is not severely affected by the load. however, scheduling-based approaches can use different heuristics to dispatch the requests (e.g., round-robin, load-aware) and these heuristics behaves differently depending on the type of load introduced into the system; group communication mechanisms provide a paradigm for reliable many-to-many communication with advanced properties with regards to reliable delivery, ordering, and synchronization of messages with membership changes. the possible strategies implemented by these mechanisms are related, e.g., to the underlying multicast mechanism employed, buffering and congestion handling, as well as the required synchronization guarantees between delivery of application messages and membership change notifications; reliable communication mechanisms support techniques for ensuring reliable message delivery. such mechanisms are especially important for mobile networks and have to support dy7 / 12 volume 11 (2008) dependability support for an adaptive application: a case study namic reconfiguration to react to unstable situations. an example is mobile ip, which supports network handovers. other examples in this category include message redundancy and concurrent paths. all these mechanisms provide different quality of service with respect to reliability and costs and their configuration can vary depending on the environmental conditions. transaction mechanisms ensure the consistency of system states. each transaction must succeed or fail as a complete unit; it cannot remain in an intermediate state. however, the performance of the services supporting the transactions can be impacted by the evolution of the execution environment [rsm06]. thus, in a ubiquitous environment, the configuration of transaction properties (e.g., commit protocol, locking strategy) can be planned by the adaptation middleware depending on the context information. discovery mechanisms provide a support for detecting new operational nodes in the system. once again, these services are influenced by different strategies that are related to the type of the underlying network (e.g., infrastructure, ad hoc) as well as the supported technology (web services, osgi, etc.). besides, some protocols define lookup strategy (proactive or reactive) as well as lookup frequency. due to the dynamic nature of the environment, these strategies and their related parameters may require to be reconfigured on the fly. for example, the lookup frequency can be increased when in an indoor environment depending on the available battery of the mobile device. 4 dynamic planning of dependability this section exposes our first elements for supporting dependability using a planning-based adaptation middleware. in particular, we propose to reflect the characteristics dependable mechanisms using plans (cf. subsection 4.1), and to use composite components to model dependable configurations (cf. subsection 4.2). 4.1 specification of quality of dependability it is important to observe that for each of these mechanisms, ensuring high dependability of service compositions implies that the planning heuristics take the corresponding dependability parameters into account. this also ought to be reflected in the qos model, which should include new qos dimensions (number of faults, cost, etc.) and incorporate them into the utility function. while plans were initially designed to reflect components making up an application, we demonstrated in [ref+08] that plans can also reflect other kind of artifacts, such as serviceoriented architectures (soa). in particular, we proposed a component-based architecture for discovering, negotiating, and planning application configurations supporting soa. more generally, we observed that plans provide a suitable abstraction for reasoning on quality of service independently of underlying artifacts. based on this assumption, we believe that plans can also be use to reflect dependability concerns. in particular, plans and the enclosed qos properties can be reused to model a dependable mechanism and its characteristics. to attain this goal, we intend to characterize existing dependable mechanisms (e.g., active/passive replication, group proc. campus 2008 8 / 12 eceasst communication, resilient routing protocols at the level of both networking and application overlay networks) in terms of qos properties. for example, table 2 identifies the qos model that can be used to reflect the qos of a replication mechanism, namely the factor, degree, frequency, and reliability of replication. as this qos model is an extension, default values are provided (using the square brackets) if the property is not mentioned explicitly. table 2: the specification of the replication qos property dimensions. property name description value range fac factor of replication 0–? [0] deg degree of replication (none) 0–1 (full) [0] fre frequency of replication (never) 0–1 (always) [0] rel reliability of replication (weak) 0–? (strong) [0] 4.2 modeling of dependable configurations once such qos properties are specified, the role associated with a dependability mechanism can be combined with other application roles in the architecture using composition plans (cf. figure 3). in particular, the qos properties can be associated to the configuration either implicitly or explicitly by the modeling approach. the implicit modeling approach consists in integrating the dependability qos properties in the property predictors associated to the application qos properties. this approach reflects seamlessly the impact of the dependability mechanism on existing qos properties (e.g., if employed under specific circumstances, the active replication mechanism increases the logger capacity by 10% and reduces its throughput by 15%). for example, the configuration depicted in figure 3 extends the one presented in figure 1 by introducing a new configuration dependable store that supports the replication of the logger storage component. the type store is connected to the type replicate using stereotype dependable to specify that the connector is not a component binding. the qos properties associated to this dependable configuration use the properties of the dependable mechanisms to reflect how the dependable mechanism impact the qos of the configuration. then, available replication mechanism strategies are described as alternative component implementations for the type replicate, while their respective parameters are reflected as qos properties. the explicit modeling approach consists in integrating the dependability qos properties in the function used to compute the utility of the application configuration. for example, the utility function below extends the one defined in subsection 3.1 and specifies that the reliability of replication should be enforced: utility(logger) = u sercap ×norm(cap) + u serbat norm(bat) + u serlat norm(lat) +u serrel ×norm(rel) this approach enables the user to specify its preferences with regards to the reliability concern (reflected by the user preference u serrel ). thanks to this abstraction, the planning-based adaptation middleware is able to reason about the most suitable configuration to deploy in the current context. in particular, the reasoning 9 / 12 volume 11 (2008) dependability support for an adaptive application: a case study replication active replicate pp fac = {2:5} deg = {0.5:1} fre = 1 passive replicate pp fac = {4:10} deg = {0:1} fre = 0.5 storage dependable store composition s pp rel = replicate.fre x replicate.fac cap = store.cap / replicate.deg lat = store.lat x replicate.fac replicate r store rs «dependable» istorage figure 3: the model of a dependable storage configuration. process will decide whether the replication mechanism needs to be enabled or not, thus avoiding potential loop feedback problems. if the replication is needed, then it will determine which strategy has to be selected and the best fitting value for its different attributes. this means that, at runtime, the planning-based adaptation middleware can reconfigure the dependable mechanism to tune the replication attributes or change the strategy. at the middleware level, supporting these dependable mechanisms requires to extend the architecture of the component adaptation manager (depicted in figure 2) in order to interpret dependable configurations. this implies that the alternative implementation of components factory and binder have to be developed to support the configuration and the deployment of a dependable mechanisms, respectively. thus, for each dependable mechanism supported by the music middleware, a pair of factory and binder components is integrated into the architecture and connected to the component configurator in order to instantiate the dependable mechanism and configure the selected strategy, respectively. 5 related work a vast body of work has been devoted to dependability techniques, such as replication and group communication [bir05] as well as transactions [gr93, bhg87]. however, most of the research on dependability did not target adaptive and autonomous systems: most existing technologies require manual configuration and assume that the universe of nodes is static. furthermore, scalability is known to be a general issue for dependability mechanisms. only a handful of works consider adapting dependability mechanisms by taking the context into account. [kibw99] and [fss03] consider adaptive fault-tolerance for component-based models. according to their claims, componentization may facilitate implementation of schemes for fault-tolerance and load-balancing. [hhs04] presents a quality of service (qos) architecture that allows flexible combinations of dependability attributes such as reliability, timeliness, and security to be enforced on a perservice request basis. in addition to components that implement the underlying dependability techniques, the architecture includes policy components that evaluate a request’s requirements and dynamically determine an appropriate execution strategy. the aqua project [rbc+03] has developed an architecture that allows distributed applicaproc. campus 2008 10 / 12 eceasst tions to request and obtain a desired level of availability using the quality objects (quo) framework. the architecture includes a dependability manager that attempts to meet the requested availability levels by configuring the system in response to outside requests and changes in system resources due to faults. while the research has been focusing on developing dependable techniques [bir05, gr93, bhg87] and making them adaptable [kibw99, fss03, rbc+03], the contribution introduced in this paper proposes an flexible adaptation framework for selecting, configuring, and monitoring dependable mechanisms. the selection process is driven by the correlation of the qos properties reflected by a given dependable mechanism with the current context information monitored by the associated context middleware. this approach allows the developer to specify the dependable mechanisms that can be integrated into the application as configuration alternatives, while the adaptation framework decides dynamically which configuration should be applied in a given execution context. 6 conclusion & perspectives this paper introduced the motivations for generalizing the support of dependable mechanisms in mobile applications. in particular, the expansion of ubiquitous environments and the growing role of mobile devices open up new opportunities for these mobile applications. although these new applications are capable of reconfiguring themselves to face changes in their environment, they are still missing missing dependable features to reasonably tolerate possible device, network, and software failures. therefore, we proposed to extend an existing planning-based adaptation middleware with the capacity of reasoning about dependable configurations. by reflecting dependability as a new qos dimension, the developer can model application configuration that are resilient to faults. these configurations are selected and configured automatically by the planning-based adaptation middleware depending on the current execution context of the user. as a matter of perspectives, we plan to experiment the support of various state-of-the-art dependable mechanisms in order to identify a comprehensive qos model dedicated to dependability issues. this support will be realized as part of the music project. the framework will be validated using real world pilot applications of the industrial partners of the music project (http://www.ist-music.eu). acknowledgements: the authors thank the partners of the music project and reviewers of the campus workshop for their valuable comments. the authors would also like to thank luı́s fraga from mobicomp for suggesting the instantsocial scenario. this work is partly funded by the european commission through the project music (eu ist 035166). bibliography [ahpe07] m. alia, s. o. hallsteinsen, n. paspallis, f. eliassen. managing distributed adaptation of mobile applications. in 7th ifip wg 6.1 int’l conference on distributed applications and in11 / 12 volume 11 (2008) http://www.ist-music.eu dependability support for an adaptive application: a case study teroperable systems (dais). lecture notes in computer science 4531, pp. 104–118. springer, paphos, cyprus, june 2007. [bhg87] p. a. bernstein, v. hadzilacos, n. goodman. concurrency control and recovery in database systems. addison-wesley, reading, ma, 1987. [bhre07] g. brataas, s. o. hallsteinsen, r. rouvoy, f. eliassen. scalability of decision models for dynamic product lines. in int’l splc workshop on dynamic software product line (dspl). p. 10. kyoto, japan, sept. 2007. [bir05] k. p. birman. reliable distributed systems: technologies, web services, and applications. springer, secaucus, nj, usa, mar. 2005. [ccki07] m. cinque, d. cotroneo, z. kalbarczyk, r. k. iyer. how do mobile phones fail? a failure data analysis of symbian os smart phones. in 37th annual ieee/ifip int’l conference on dependable systems and networks (dsn). pp. 585–594. ieee computer society, edinburgh, uk, june 2007. [fhs+06] j. floch, s. o. hallsteinsen, e. stav, f. eliassen, k. lund, e. gjørven. using architecture models for runtime adaptability. ieee software 23(2):62–70, mar./apr. 2006. [fss03] f. favarim, f. siqueira, j. da silva fraga. adaptive fault-tolerant corba components. in workshops of the int’l middleware conference. pp. 144–148. puc-rio, 2003. [gr93] j. gray, a. reuter. transaction processing: concepts and techniques. morgan kaufman publishers, 1993. [hhs04] j. he, m. a. hiltunen, r. d. schlichting. customizing dependability attributes for mobile service platforms. in 34th int’l conference on dependable systems and networks (dsn). pp. 617–626. ieee computer society, florence, italy, june/july 2004. [kibw99] z. t. kalbarczyk, r. k. iyer, s. bagchi, k. whisnant. chameleon: a software infrastructure for adaptive fault tolerance. ieee transactions on parallel and distributed systems 10(6):560–579, 1999. [lso+07] s. a. lundesgaard, a. solberg, j. oldevik, r. b. france, j. ø. aagedal, f. eliassen. construction and execution of adaptable applications using an aspect-oriented and model driven approach. in 7th ifip wg 6.1 int’l conference on distributed applications and interoperable systems (dais). lecture notes in computer science 4531, pp. 76–89. springer, paphos, cyprus, june 2007. [rbc+03] j. ren, d. e. bakken, t. courtney, m. cukier, d. a. karr, p. rubel, c. sabnis, w. h. sanders, r. e. schantz, m. seri. aqua: an adaptive architecture that provides dependable distributed objects. ieee transactions on computers 52(1):31–50, 2003. [ref+08] r. rouvoy, f. eliassen, j. floch, s. hallsteinsen, e. stav. composing components and services using a planning-based adaptation middleware. in 7th int’l symposium on software composition (sc). lecture notes in computer science 4954, pp. 52–67. springer, budapest, hungary, mar. 2008. [rsm06] r. rouvoy, p. serrano-alvarado, p. merle. towards context-aware transaction services. in 6th ifip wg 6.1 int’l conference on distributed applications and interoperable systems (dais). lecture notes in computer science 4025, pp. 272–288. springer, bologna, italy, june 2006. proc. campus 2008 12 / 12 introduction motivating scenario foundations planning-based adaptation middleware dependability mechanisms dynamic planning of dependability specification of quality of dependability modeling of dependable configurations related work conclusion & perspectives on the resilience of opportunistic networks against dos attacks electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) on the resilience of opportunistic networks against dos attacks s. afzali, a. udugama, a. förster and m. fischer 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst on the resilience of opportunistic networks against dos attacks s. afzali1, a. udugama1, a. förster1 and m. fischer2 1 university of bremen, germany 2 university of hamburg, germany abstract: opportunistic networks (oppnets) enable contact-based networking and service provisioning when no infrastructure exists, e.g., in disaster areas. in such sensitive scenarios, maintaining their availability is important, but most existing work on oppnets mainly assume fully cooperative and thus not malicious nodes. in this paper, we study the impact of different flavors of low-intensity denial of service (dos) attacks on oppnets, which are hard to detect and to counter. our results indicate that low-rate dos and black hole attacks as a special case of dos, seem to have a huge impact on the packet delivery ratio and the delivery delay of an oppnet. keywords: opportunistic networks, attacker models, security, ops, omnet++ 1 introduction opportunistic networks (oppnets) are networks used to communicate in environments where end-to-end paths and networking infrastructure are non-existent. applications that use oppnets have to be delay tolerant and nodes exploit any available communication opportunity to exchange information with other nodes using direct communication. communication in the aftermath of disasters, for remote or unconnected villages, or for offloading saturated networks are some of the scenarios where oppnets can play an important role. an integral and critical part of an oppnets node is the forwarding mechanism employed to exchange data between nodes. there are a number of forwarding protocols developed to efficiently exchange data [ktuf19]. however, these protocols assume well behaving nodes only. however, there are many types of attacks that can inflict damage on a network and thus also on oppnets. oppnets might be seriously affected by denial of service (dos) and as special case of dos also by blackhole attacks [ada16]. the main contribution of this paper, is an evaluation of the impact of low-rate dos and black hole attacks on oppnets, so that efficient countermeasures can be developed in the future. our results indicate that both attack types can significantly decrease the packet delivery ratio of oppnets. the remainder of this paper is structured as follows: section 2 briefly summarizes related work. section 3 describes our methodology and section 4 our evaluation results. section 5 concludes the paper. 2 related work a survey of the previous work on evaluating attacks on oppnets shows that almost all focus on individual attack models and improvements to protocols rather than on a collective look on the severity of the problem[ada16]. there exist also some work on analysis of attack models for some specific protocols like maxprop [ccc10]. in this work, we look at the impact of low-rate dos and black hole attacks and quantify to which extent they can degrade the network operation. 1 / 4 volume 080 (2021) on the resilience of opportunistic networks against dos attacks in a low-rate dos attack, the attacker injects apparently valid packets into the network to deplete the network bandwidth and forwarding resources of other nodes for legitimate users. a special case of dos is a blackhole attack, in which malicious nodes do not cooperate with the rest of the network and thus only request and receive messages, without ever forwarding them. 3 methodology dos attacks in this paper we mainly focus on low-rate dos attacks and black hole attacks. both types of attacks are hard to detect and hard to counter in an oppnet setting. in a low-rate dos attack, a malicious node will send garbage packets to other nodes to consume resources and to impede the forwarding of legitimate content. in a black hole attack, a malicious node will receive packets, but will never forward them. hence, such a node is consuming transmission resources of other nodes without contributing the own resources for spreading content. simulation the evaluation of the effects of dos attacks on oppnets are performed using the omnet++ network simulator together with the oppnets framework ops [ufdk19]. in this work, ops has been extended with two attacker models described in section 2. unlike traditional networks, oppnets have a specific set of evaluation metrics that highlight their performance: the delivery ratio, the network wide ratio of packets successfully delivered over the total expected packets, and average delay, the network wide average of the time taken for a packet to reach a destination. these two metrics are independent of each other and typically used to benchmark oppnets. simulation setup the simulated oppnet consists of 50 nodes, including attackers and genuine nodes. each simulation run is set to 5 days. data (packets) by genuine nodes are injected into the network every 900 seconds, with a payload of 10 kb each. the forwarding of packets are limited by a maximum of 30 hops. nodes are configured to have infinite caches. the wireless connectivity is configured to be bluetooth le like with a range of 30 meters and a bandwidth of 100 kbps. mobility of nodes is modelled using the swim mobility model. the mobility area is 1,500 meters by 1,500 meters. epidemic routing [vb00] is used to disseminate data, probably the best one and used protocol for oppnets. this experimental setup is quite standard for oppnets and sufficient to show the severity of dos attacks [ktuf19]. the attack configuration includes the attacker model, the attack frequency, and the number of attackers explored. unless otherwise stated, attackers inject malicious data every 90 seconds. 4 results in this section we summarize our results on black hole and low-rate dos attacks on oppnets. black holes figure 1 plots the delivery ratio (left) and the delivery delay (right) in 95% confidence intervals in dependence on a varying number of black hole nodes and by keeping the overall number of nodes constant at 50 (red graph) and in dependence on a varying number of legitimate nodes without malicious nodes as baseline (blue graph). with an increasing number of black holes, the delivery of data decreases and the delivery delay increases. even at this rather low attack intensity it can be seen that the effect is significant. the results also indicate that a black hole node does not correspond to a decreased density of the network. while 25 black hole nodes in a setting with in total 50 nodes decrease the delivery ratio to under 50%, the delivery netsys 2021 2 / 4 eceasst 50/0 50/2 48/0 50/5 45/0 50/10 40/0 50/25 25/0 node combinations 0.00 0.25 0.50 0.75 1.00 d el iv er y ra tio blackhole attacks mix of total nodes to attackers 50/0 50/2 48/0 50/5 45/0 50/10 40/0 50/25 25/0 node combinations 0 20 40 d el iv er y de la y (h rs ) blackhole attacks mix of total nodes to attackers figure 1: delivery ratio (left) and delivery delay (right) for a varying number of malicious nodes carrying out black hole attacks. 50/2 refers to 50 total nodes and two of them are attackers. ratio stays at around 75% for a comparable setting with 25 legitimate nodes only and thus lower density. this is due to the fact that attackers still occupy networking resources, forcing legitimate nodes to waste their contact times on black hole nodes that do not forward their content. low-rate dos figure 2 shows the delivery ratio and delivery delay of oppnets during dos attacks for varying number of attacking nodes and attack frequencies and for a setting with malicious nodes (red graphs) and a setting without (red graphs). the graphs indicate that with an increasing number of attackers (top row) and increasing attack intensity (bottom row), the performance deteriorates quickly. already five attacking nodes are sufficient to decrease the delivery ratio from close to 100% to around 60%, while the average delivery delay nearly doubles at the same time. at the same time, delivery ratio and delay stay nearly constant from 50 to 45 legitimate nodes without any attackers. 5 conclusion in this work, we have evaluated the performance of oppnets in the presence of two relevant attacker models. we have explored dos attacks and blackhole attacks via simulations. our results are very interesting and show potential new directions for security-aware protocols in oppnets. blackhole and dos attacks severely impact the performance of the network, even at low-intensity attacks which are very hard to detect. in the future, we plan to explore systematically further oppnets relevant attack models.at the same time, we will focus on developing counter-measures for them. furthermore, we will explore also the impact of dos and blackhole attacks with data dissemination protocols other than epidemic. references [ada16] m. alajeely, r. doss, a. ahmad. security and trust in opportunistic networks – a survey. iete technical review 33(3):256–268, may 2016. 3 / 4 volume 080 (2021) on the resilience of opportunistic networks against dos attacks 50/0 50/2 48/0 50/5 45/0 50/10 40/0 50/25 25/0 node combinations 0.00 0.25 0.50 0.75 1.00 d el iv er y ra tio dos attacks mix of total nodes to attackers 50/0 50/2 48/0 50/5 45/0 50/10 40/0 50/25 25/0 node combinations 0 20 40 d el iv er y de la y (h rs ) dos attacks mix of total nodes to attackers 900 sec 450 sec 180 sec 90 sec 45 sec attack frequency (sec) 0.00 0.25 0.50 0.75 1.00 d el iv er y ra tio dos attacks x sec inter-packet interval 900 sec 450 sec 180 sec 90 sec 45 sec attack frequency (sec) 0 20 40 d el iv er y de la y (h rs ) dos attacks x sec inter-packet interval figure 2: effect of dos attacks by varying attackers (top row) and attack intervals (bottom row). in the top row 50/2 refers to 50 nodes from which two are attackers (95% confidence intervals). in the bottom row, the network uses a 50/10 node combination for each attack frequency. [ccc10] f. c. choo, m. c. chan, e. chang. robustness of dtn against routing attacks. in 2010 second international conference on communication systems and networks (comsnets 2010). pp. 1–10. 2010. [ktuf19] v. kuppusamy, u. m. thanthrige, a. udugama, a. förster. evaluating forwarding protocols in opportunistic networks: trends, advances, challenges and best practices. future internet 11(5):113, 2019. [ufdk19] a. udugama, a. förster, j. dede, v. kuppusamy. simulating opportunistic networks with omnet++. in virdis and kirsche (eds.), recent advances in network simulation: the omnet++ environment and its ecosystem. pp. 425–449. 2019. [vb00] a. vahdat, d. becker. epidemic routing for partially-connected ad hoc networks. technical report, 2000. netsys 2021 4 / 4 introduction related work methodology results conclusion electronic communications of the easst volume 080 (2021) guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrück, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 conference on networked systems 2021 (netsys 2021) idn-laser-tester: a framework for detecting and testing ilda digital network consumers for laser projection matthias frank 4 pages eceasst 2 / 5 volume 080 (2021) idn-laser-tester: a framework for detecting and testing ilda digital network consumers for laser projection matthias frank matthew@cs.uni-bonn.de, http://lll.net.cs.uni-bonn.de/ institute of computer science 4 / laser & light lab university of bonn, germany abstract: the ilda digital network (idn) is a novel protocol family providing digital data transmission for laser projection. while the new standards mainly aim to replace the old analogue signal transmission, the digital streaming concept also enables completely new applications and flexible networked scenarios. very simple tools are existing to check the old analogue connection. our demo presents the idn-laser-tester, a new framework that allows for detecting and testing idn enabled hardware or software in a local network in a user friendly manner from smartphone, tablet or portable computer. keywords: application layer protocols, availability in networking, ilda digital network 1 introduction to idn & motivation of the demo laser shows are widely used for entertainment purposes, e.g. to accompany music performances. a typical laser projector consists of a laser module and a fast-moving mirror system, which deflects the laser beam to create shapes and patterns either on a projection surface or in mid-air when using artificial haze or fog. the international laser display association (ilda) defines the de facto technical standards used in both laser show hardware and software. traditionally, laser projectors are controlled with analogue input signals. the analogue ilda standard projector (isp, [ild99], the connector is also called isp-db25) was the relevant specification on how to connect laser control interfaces with laser projectors in a vendor-independent way, which is in use for more than two decades (technical specification of 1999). each laser projector was connected to a control-interface by an analogue cable with db25 connectors (25 wires carrying the signals for x, y, colours red, green, blue and others), if necessary over long distances. the ilda digital network (idn) stream specification is a novel standard to transmit laser show artwork in digital data streams inside a computer network [fpb15]. the digital transmission allows for very flexible setups as opposed to the old analogue interfacing and cabling systems. for example, in previous work we have already shown how an idn software driver can complement existing laser show software to directly generate idn streams [fra15]. these are being sent into the local network with destination to an idn capable laser projector or a suitable idn-to-analogue converter for legacy ilda controlled laser projectors, the so called dexlogic stagemate isp, cf. [dex21]: it can generate the analogue laser projector signals for isp-db25 from incoming idn streams. it fully implements the idn stream specification. furthermore, the transmitted idn streams can easily be received and analysed to help with testing and debugging of laser show systems. the idn-toolbox is able to display the received short article title netsys 2021 3 / 5 idn stream on a 2d computer screen [fra17]. with the idn-laser-vr software, a more authentic approach on virtual laser show visualization from idn streams using virtual reality (vr) headsets is possible: using a vr headset, the user can move around in a virtual room with several virtual laser projectors and watch laser show artwork generated by typical laser show software. even without a vr headset connected, the user will see a 3d preview on the computer screen [fm19]. another idn specification is still work in progress: the idn discovery protocol (aka idnhello) describes the protocol for the detection, enumeration and query of idn-enabled devices. current idn hardware and all of our idn tools already support idn-hello discovery. it is also important to understand the content of the idn streams. the so-called idn channel messages contain a sequence of laser projector samples each with values for x and y coordinates and at least three colours, red, green and blue. a laser projector as idn consumer would use these sample values to generate the control signals of x and y mirrors for laser beam deflection and the colour signals (r, g, b) for control of multi-colour laser modules. the sample sequence describes the laser projection in a vector-oriented style, similar to probably known from “connect the dots” puzzles. exactly those signals for x, y and r, g, b were already included in the analogue isp-db25 connector and were generated by separate control interfaces. there are tester devices available for the analogue ilda isp-db25 connector, e.g. the so called “ilda gem pocket laser projector tool” by stanwax laser (uk), see [stan21]. such a tester can be connected to an ilda db25 cable and check with simple rgb-coloured test patterns if the (analogue) connection is working with all necessary signal lines for colours and x/y laser scanner between the tester device, the ilda cable and the connected laser projector at the cable’s end. the new ilda digital network is the digital counterpart of the (old) analogue isp db25 connection. the digital transmission in local networks allows for very flexible configuration and placement of all network elements as well as sharing and multiplexing on single network links. this level of flexibility also imposes an increased complexity in the network setup and topology which brings in new sources for errors or faulty configurations. this brought up the idea to create a simple (digital) idn-based testing tool and test framework  to be able to connect the testing tool at different points of attachment to the local network,  to scan the network for available idn consumer instances (e.g. real laser projectors or idn visualization software), and  to send simple test frames or frame sequences for laser projection to selected idn consumers 2 subject of the demo: the idn-laser-tester in a complex laser show setup with a lot of idn consumers (laser projectors) and a possibly complex local network it is useful to test the idn components independently of the laser show software. our idn-laser-tester framework uses two components: firstly, a server component (a piece of given software) that needs to run “somewhere” in the local idn network (several options are discussed below). secondly, an off-the-shelf smartphone, tablet, laptop or other computer with a web browser that is used as a client to eceasst 4 / 5 volume 080 (2021) control the idn-laser-tester server component via the local network (two connection options are discussed below). to prepare the server component, there are these options: server option 1: the software can be started in a virtual machine on any computer in the local network. a virtualbox appliance is pre-configured to boot a linux ubuntu instance and start the idn-laser-tester server automatically without any user interaction. it then displays a splash screen with instructions about how to connect to the server from the web browser and gives information like the ip address and the idn-laser-tester status. alternatively, (server options 2 a/b) the software can be installed and executed on a raspberry pi, either with a connected display or also in so called headless mode (without display). the raspberry pi needs to be connected to the local network with idn consumers and also starts up the server software after boot. the server component runs a web server based on nodejs javascript runtime. the nodejs server is able to trigger the execution of idn functions implemented in the c programming language. service discovery (idn-hello) can be executed and test frames for laser projection can be sent to selected idn consumers. web client interaction is done using the websocket protocol. the server also gives feedback to the web client’s gui via this connection. to connect a client to control the server component via a standard web browser, there are two connection options: first, the client can be connected using the available wlan of the local network. second, if the local network does not offer wlan access, the raspberry pi wlan is configured in access point mode and offers wlan connectivity to the client to access and control the idn-laser-tester server component. furthermore, the raspberry pi’s ethernet may be connected to different network points of attachment to identify possible idn connectivity issues in different segments of the local network. more detailed documentation with a description of all features, some background information, use cases and requirements are given in the public gitlab software repository [lll21]. figure 1: idn-laser-tester system architecture illustration figure 1 illustrates the architecture of the idn-laser-tester framework: the local idn network may have different types of idn consumers including idn converters (legacy ispdb25 connection), idn-enabled laser projectors, or idn visualization software. the components of the idn-laser-tester are outlined in red colour: the server component needs to be connected to the idn network (mark (1)). the smartphone needs to use an existing short article title netsys 2021 5 / 5 wlan from the local network (marked as (2a)) or can use the wlan access point when using the raspberry pi setup for the server component (2b). 3 conclusion the idn-laser-tester framework is available for free download on gitlab.com and it is even possible to try out and use the idn-laser-tester without idn hardware and/or laser projector: the idn-toolbox or the idn-laser-vr visualization software maybe used as idn consumer, as the most recent versions also implement the idn service discovery (idn-hello) and will be detected by the idn-laser-tester as valid idn consumer. a short demonstration video on setup and some usage examples are available on the gitlab project repository as well as portable (windows) versions [lll21]. the idn-laser-tester demonstration will be given in a remote fashion. the output of a real laser projector and the preview of idn-toolbox/idn-laser-vr will be visible via camera and screen share, and also the controlling side of the idn-laser-tester will be visible using a web browser. acknowledgements: the idn-laser-tester framework has been initially created in a bachelor project course by the student fabian fritz and has been finalized and evaluated in a bachelor thesis by fabian in april 2020. fabian also created the content and documentation in the gitlab repository and the demonstration video. 4 bibliography [dex21] dexlogic hardware and software solutions (ilda member), karlsruhe, germany, http://dexlogic.com (last accessed aug. 13, 2021) [fm19] matthias frank, fabian marquardt. idn-laser-vr: a demonstration of realtime multimedia streaming in local networks using the ilda digital network protocol. demonstrations of the 44th ieee conference on local computer networks (lcn), 2019 [fpb15] matthias frank, horacio pugliese, andrew berry, tim walsh, and dirk apitz. the ilda digital network stream specification. international laser display association, tech. rep. revision 001, 2015 [fra15] matthias frank. a multi-platform library for a software sender for the (proposed) ilda digital network. international conference on networked systems, netsys 2015, cottbus, march 2015 [fra17] matthias frank. demonstration of “idn-toolbox”: a software to visualize and analyze idn (ilda digital network) streams. demonstrations of the 42nd ieee conference on local computer networks (lcn), 2017 [ild99] the ilda technical committee. the ilda standard projector. international laser display association, tech. rep. revision 002, 1999 [lll21] laser & light lab university of bonn gitlab repository. several idn related projects. https://gitlab.com/laser_light_lab_uni_bonn/ (last accessed aug. 13, 2021) [stan21] stanwax laser uk. ilda gem pocket laser projector tool https://shop.stanwaxlaser.co.uk/ilda-gem-pocket-laser-projector-tool-563-p.asp (last accessed aug. 13, 2021) lattice-extended coloured petri net rewriting for adaptable user interface models electronic communications of the easst volume 67 (2014) proceedings of the 13th international workshop on graph transformation and visual modeling techniques (gtvmt 2014) lattice-extended coloured petri net rewriting for adaptable user interface models jan stückrath, benjamin weyers 13 pages guest editors: frank hermann, stefan sauer managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst lattice-extended coloured petri net rewriting for adaptable user interface models jan stückrath1, benjamin weyers2 1jan.stueckrath@uni-due.de abteilung inko, universität duisburg-essen, duisburg, germany 2weyers@vr.rwth-aachen.de virtual reality group, rwth aachen university, aachen, germany abstract: adaptable user interfaces (ui) have shown a great variety of advantages in human computer interaction compared to classic ui designs. we show how adaptable uis can be built by introducing coloured petri nets to connect the ui’s physical representation with the system to be controlled. ui development benefits from formal modelling approaches regarding the derived close integration of creation, execution, and reconfiguration of formal ui models. thus, adaptation does not only change the physical representation, but also the connecting petri net. for the latter transformation, we enhance the dpo rewriting formalism by using an order on the set of labels and softening the label-preserving property of morphisms, i.e., an element can also be mapped to another element if the label is larger. we use lattices to ensure correctness and state application conditions of rewriting steps. finally we define an order compatible with our framework for the use in our implementation. keywords: coloured petri nets, rewriting, user interface modelling, redesign and reconfiguration, lattices 1 introduction modelling in user interface creation has a long tradition, starting in the 1980th with cognitive architectures, such as goms and ctt [cmn80, kp85], or later approaches for modelling usersystem dialogues [jwz93]. as known from software engineering [hjsw10], the gap between model and implementation is often a great issue in the design of systems, also affecting the creation of interactive systems and user interfaces. one possible solution to reduce this gap is the use of formal modelling approaches, which can be executed on the computer without further need of extra implementation. various examples can be found regarding creation and modelling of user interfaces using formal methods, such as works published by navarre et al. [nplb09]. still, resulting models are often inflexible and static, lacking of formal and modelintrinsic adaptation and reconfiguration approaches. especially regarding the implementation of adaptable uis, a full-fledged modelling and reconfiguration concept is necessary. adaptable uis extend uis by software support to enable the user to change the ui according to his preferences. for this we developed a coloured petri net-based [jen97] modelling approach for creating formal user interface models [wey12, wblk12] accompanied with an extended graph rewriting concept introduced in this paper. the combination of using coloured petri nets and rewriting 1 / 13 volume 67 (2014) mailto:jan.stueckrath@uni-due.de mailto:weyers@vr.rwth-aachen.de lattice-extended cpn rewriting for adaptable ui models creates an executable modelling approach paired with a formal adaptation allowing the creation of flexible and reconfigurable user interface models, thus realising adaptable uis. rewriting of p/t nets has already been considered for instance in [ehp06, lo04], where the latter focuses on linking transformations of the nets structure and marking. properties of coloured petri nets, such as types or guard conditions, are modelled by labels on places, transitions and arcs, and a greater modelling flexibility can be achieved by a formalism including the possibility of relabelling. however, this is in conflict with the often used restriction that rules (i.e. morphisms) preserve labels. one approach is to allow non-labelled elements in rules, which is done in [hp02, ros75], such that the label of an element will change if its interface node is unlabelled. in our approach we introduce an order on the labels (later called inscriptions) and allow rules to be applied to elements with possibly larger labels. with sufficiently complex labels, a rewriting step can partly rewrite a label, letting the rest of the label untouched. a very similar idea was presented in [pem87], interestingly using orders with reversed direction compared to ours. although more flexible wrt. the orders they need quite elaborate application conditions while we obtain simpler results (and proofs) by using lattice theory [bir67] and are able to use non-injective morphisms in rules. note that it is also possible to combine a rewriting formalism for the nets structure and with one for the labels, but this will result in higher complexity. in the next section we develop two rewriting formalisms based on the so-called dpo approach. the first one is a straightforward extension of dpo to our morphisms, while the other prefers deletion of (parts of) labels, in the case of a conflict. in section 3 and 4 we show how our approach can be used to realize adaptive user interfaces based on xml inscriptions. due to space restrictions the proofs are published only in a long version [sw14] of this paper. 2 coloured petri net rewriting with lattices since our focus lies on the rewriting formalism, we consider petri nets as special kinds of graphs which can be transformed as described in [roz97]. we will not define the semantics of coloured petri nets [jen97] and just assumes the existence of inscriptions of transitions, places, and arcs. in practice these inscriptions are often used to model guard conditions or typing tokens. definition 1 (in-coloured petri net) an in-coloured petri net is a 6-tuple (p,t,e,in,c,in) with p a set of places, t a set of transitions, and e a set of edges where p, t , and e are pairwise disjoint. the function c ∶ e → (p × t )∪(t × p) defines the source and target of each edge. in is a (possibly infinite) set of inscriptions and the total function in ∶ (p ∪ t ∪ e) → in assigns an inscription to each element of the net. often, transformation formalisms can only change inscriptions by deleting and recreating the corresponding objects, since morphisms are usually required to preserve inscriptions. exceptions are for instance [hp02, ros75], where labelling functions can be partial and [pem87], which uses orders on inscriptions. we pursue the latter approach by extending the notion of morphisms with orders and using lattices [bir67] to order inscriptions. definition 2 (total ⊑-morphisms on in-coloured petri nets) let ⊑ be a partial order on the set of inscriptions in. a total ⊑-morphism r ∶ a→b on coloured petri nets a = (pa,ta,ea,in,ca,ina) proc. gtvmt 2014 2 / 13 eceasst and b = (pb,tb,eb,in,cb,inb) is a triple (rp,rt ,re ) of the three total morphisms rp ∶ pa → pb, rt ∶ ta → tb, and re ∶ ea → eb, such that the following conditions hold (omitting indices or r): ∀e ∈ ea with ca(e) = (x,y) ∶ cb(r(e)) = (r(x),r(y)) and ∀x ∈ (pa ∪ta ∪ea) ∶ ina(x) ⊑ inb(r(x)) a ⊑-morphism is an isomorphism if it is injective, surjective and inscription preserving, i.e. in the second condition above equality holds. definition 3 (complete lattice) a complete lattice is a pair (l,⊑), where l is a set and ⊑ is a partial order on l. furthermore, for every set l′ ⊆ l there is an infimum (greatest lower bound) ⊓l′ ∈ l such that: 1) for all l ∈ l′, ⊓l′ ⊑ l holds, and 2) for all l′ satisfying the first condition, if ⊓l′ ⊑ l′, then ⊓l′ = l′. analogously, there is a supremum (least upper bound) ⊔l′ ∈ l such that: 1) for all l ∈ l′, l ⊑⊔l′ holds, and 2) for all l′ satisfying the first condition, if l′ ⊑⊔l′, then ⊔l′ = l′. as shorthand we use l1 ⊔l2 and l1 ⊓l2 to denote ⊔{l1,l2} and ⊓{l1,l2} respectively. we call a lattice meet-infinite distributive if m ⊔(⊓l∈l′ l) = ⊓l∈l′ (m⊔l) and join-infinite distributive, if m⊓(⊔l∈l′ l) = ⊔l∈l′ (m⊓l) holds for all m ∈ l and l′ ⊆ l. note that our definition of a morphism is equal to the inscription preserving definition, if an identity relation ⊑ is used. in the following our inscription sets will not be ordinary lattices, but disjoint unions of complete lattices, i.e. (in,⊑) is a partial ordered set such that there is a partition πl over l where (π,⊑ ∩(π × π)) is a complete lattice for every π ∈ πl and if x ⊑ y, then there is a π ∈ πl with {x,y} ⊆ π. we use cpn [in,⊑] to denote the category of in-coloured petri nets where in has this form. note that the label preserving case is subsumed by our approach since any identity relation also forms a disjoint union of complete lattices. the double pushout approach (dpo) is based on the notion of pushouts and pushout complements. these constructions are used to add (former) and delete (latter) elements of a net in a rewriting step. definition 4 (pushouts) given two morphisms f ∶ a → b and g ∶ a →c, the triple (d, g′ ∶ b → d, f ′ ∶c→d) is called a pushout of ( f ,g), if: 1) g′○ f = f ′○g, and 2) for all nets e and morphisms f ∗ ∶ c →e and g∗ ∶ b→e that fulfil the former constraint, there is an unique morphism h ∶ d→e with h○g′ = g∗ and h○ f ′ = f ∗. we call (c,g, f ′) the pushout complement of ( f ,g′) if (d,g′, f ′) is a pushout of ( f ,g). an example of a pushout can be seen in figure 1, where the morphisms are indicated by position with the exception of the two places in a which are non-injectively mapped to the same place in b. the pushout contains the elements of b and c, but merges elements related via a, i.e. elements are merged if they share a common preimage in a. the labels of elements in d are thereby the supremum of the labels of all their preimages in b and c. thus, d can be seen as the smallest merging of b and c via the interface a. we state the existence of pushouts and pushout complements in our setting by the following two lemmas. lemma 1 for ⊑-morphisms b ∶ a → b and c ∶ a →c the pushout exists in cpn [in,⊑] and is unique up to isomorphism. 3 / 13 volume 67 (2014) lattice-extended cpn rewriting for adaptable ui models a b c d {a} {b} {a,b} {c} {a,b} {b} {c} {a,b} {c}{c} f g g′ f ′ figure 1: example of a pushout using the lattice (p({a,b,c}),⊆) as inscriptions. a b c d {a} {a,b} f g′ figure 2: example morphisms, where no pushout complement exists lemma 2 for morphisms b ∶ a → b and d ∶ b → d the pushout complement in the category cpn [in,⊑] exists, if and only if the following conditions hold: • for every x ∈ pb ∪ tb without a preimage in a, d(x) is only connected to edges with a preimage in b (dangling edge condition), • for every x,y ∈ pb ∪ tb ∪ eb, if d(x) = d(y) and x ≠ y, then x and y have preimages in a (identification condition), and • for every x ∈ pb ∪ tb ∪ eb without a preimage in a, inb(x) = ind(d(x)) holds (inscription condition). the first two conditions of lemma 2 are well-known conditions for the existence of pushout complements for general graphs. the last condition is illustrated in figure 2. the place in d cannot have a preimage in c, since the pushout of b and c would contain two places, but then d is not minimal since the inscription would have to be {a}. thus, no pushout complement exists in this case. note that pushout complements in cpn [in,⊑] are not necessarily unique, even if all involved morphisms are injective. we approach this ambiguity by introducing the notions of preservationfocused and deletion-focused rewriting. while the first one arises from a natural refinement of dpo rewriting, the latter notion prefers deletion to preservation when rewriting inscriptions and its application is illustrated in more detail in section 3. definition 5 (dpo rule and matching) a (dpo) ⊑-rule ρ is a pair of ⊑-morphisms l ∶ i → l and r ∶ i → r. a ⊑-match of a rule ρ to a net n is a ⊑-morphism m ∶ l → n. definition 6 (preservation-focused rewriting) let l ∶ i → l and r ∶ i → r be a rule and let m ∶ l → n be a match of the rule in n. a net n can be rewritten to a net n′ if there is a minimal pushout complement c, m′ ∶ i →c, l′ ∶ c →n such that n′ is isomorphic to the pushout of m′ and r. a pushout complement c is minimal if for all pushout complements d, m′′ ∶ i → d, l′′ ∶ d → n it holds that if there exists an injective ⊑-morphism k ∶ d→c with m′ = k ○m′′ and l′′ = l′○k, then k is an isomorphism. proc. gtvmt 2014 4 / 13 eceasst we call a rule preservation-applicable, if at least one pushout complement exists. when using preservation-focused rewriting, inscriptions are rewritten in the classical dpo sense. a rule application tries to delete the ”difference” between an inscription in l and its preimage in i from its image in n. if this deletion is not possible, the deletion is not performed. however, the rule is still preservation-applicable (taking the conditions of lemma 2 into account), but the inscription remains unchanged, as demonstrated in the following example. example 1 figure 3a shows the minimal pushout complement using the lattice (p({a,b}),⊆), since {b} is the smallest inscription such that {b}⊔{a} = {a,b}. the rule can simply delete the ’a’ part of the inscription {a,b} to obtain {b}. however, this is not always possible as shown in figure 3b, where the lattice in figure 3c is used. this lattice does not contain {b} such that {a,b} is now the minimal inscription. effectively the inscription remains unchanged although the rule specifies a (partial) deletion. note that figure 3b is also a pushout complement if (p({a,b}),⊆) is used, although it is not minimal in that case. l i n c {a} ∅ {a,b} {b} (a) the minimal pushout complement using the lattice (p({a,b}),⊆) l i n c {a} ∅ {a,b} {a,b} (b) the minimal pushout complement using the lattice shown in figure 3c {a,b} {a} ∅ (c) hasse diagram of a lattice figure 3: a preservation-focused rule application using two different (distributive) lattices in general a preservation-focused rewriting step generates a set of rewritten nets, but we can state the following uniqueness criterion. proposition 1 let ρ be a ⊑-rule where the left leg is injective and let m be a ⊑-match such that ρ is preservation-applicable to some net n. the preservation-focused application of ρ to n via m results in a unique net n′ (up to isomorphism) if the set of inscriptions of n is a disjoint union of lattices and each lattice is meet-infinite distributive. in preservation-focused rewriting, places, transitions and arcs with larger inscriptions than their preimage in l cannot be deleted due to the third condition of lemma 2 and inscriptions may remain unchanged even if the rule specifies otherwise. these properties are not always desired, for instance not in our application presented in section 3 and 4. therefore, we present an alternative approach which deletes as much of the inscriptions as necessary in these situations. as an auxiliary construction we define a functor mapping form cpn [in,⊑] to cpn [in,=], the category where ⊑ is the identity. the functor effectively removes the inscriptions. 5 / 13 volume 67 (2014) lattice-extended cpn rewriting for adaptable ui models definition 7 (forgetful functor) let f ∶ cpn [in,⊑] → cpn [in,=] be a functor. for every object a = (pa,ta,ea,in,ca,ina) of cpn [in,⊑] we define f(a) = (pa,ta,ea,in,ca,in′a) with in′a(x) =⊓π for all x ∈ pa ∪ta ∪ea, where ina(x) ∈ π for some element π of the partition πin of in. for every arrow m ∶ a → b we define f(m)(x) = m(x) for all x ∈ pa ∪ta ∪ea. definition 8 (deletion-focused rewriting) let l ∶ i →l and r ∶ i →r be a rule and let m ∶ l→n be a match of the rule in n. a deletion-focused rewriting step is performed in the following way: 1. calculate a pushout complement n′ = (pn′,tn′,en′,in,cn′,inn′) of f(l) and f(m) with morphisms m′ ∶ f(i)→ n′, l′ ∶ n′ → f(n). 2. for every x ∈ n′ let the set of inscriptions ix be defined as follows: ix = {z ∈ in ∣ (∀x′ ∈ i ∶ (m′(x′) = x ⇒ z⊓inl(l(x′)) = ini(x′)))∧z ⊑ inn(l′(x))}. if ix is non-empty for all x ∈ n′, construct a net n′′ = (pn′,tn′,en′,in,cn′,inn′′) where inn′′(x) is any maximal element of ix and the morphisms m′′ ∶ i → n′′, l′′ ∶ n′′ → n with m′′(x) = m′(x), l′′(x) = l′(x). 3. calculate the pushout of m′′ and r to obtain the rewritten petri net m. we call a rule deletion-applicable if the first two conditions of lemma 2 hold and for at least one net n′ calculated in the first step, ix is non-empty for all x ∈ n′. by construction m′′ and l′′ defined in definition 8 are valid ⊑-morphisms and the diagram l′′○m′′ = m○l commutes, but is not necessarily a pushout. the application condition differs from preservation-focused rewriting and arises from conflicts shown in figure 4b. l i n c {a} ∅ {a,b} ∅ (a) deletion-focused rewriting of the example in figure 3b l i n c {a} {a} {a} ∅ {a,b} ? (b) example of a rule which is not deleting applicable figure 4: examples of deletion-focused rewriting steps example 2 figure 4a shows the deletion-focused rewriting step applied to the example in figure 3b using the lattice in figure 3c. we search for every inscription z for which z ⊓{a} = ∅ holds and which is also smaller or equal to {a,b}. since ∅ is the only possibility, it is a maximal element. effectively, since there is no inscription containing b without a, the deletion of a from {a,b} also deletes b. figure 4b shows a conflict, such that the rule is not deletion-applicable. the proc. gtvmt 2014 6 / 13 eceasst rule specifies a preservation and a rewriting of the same inscription, such that ix is empty for the node in c. the node cannot be labelled with ∅ since then m′′ would not be a valid ⊑-morphism. note that in this case a pushout complement does exist. although ambiguous in the general case, we can state a uniqueness criterion for deletionfocused rewriting which is analogue to proposition 1. proposition 2 let ρ be a ⊑-rule where the left leg is injective and let m be a ⊑-match such that ρ is deletion-applicable to some net n. the deletion-focused application of ρ to n via m results in a unique net n′ (up to isomorphism) if the set of inscriptions of n is a disjoint union of lattices and each lattice is join-infinite distributive. 3 deletion-focused pnml rewriting the petri net markup language (pnml) is a well established xml-based format for making petri net-based models persistent [hkk+09]. therefore, we use pnml in our implementation as basis for describing so-called reference nets [kum02]. these are coloured petri nets where the tokens are references to objects in a class hierarchy and also support code execution when firing transitions. we clarify how rewriting steps will be performed in this setting, by defining a mathematical model for xml below. this also illustrates how our rewriting formalisms can be implemented in practice. in this setting, inscriptions are xml nodes, and hence have a tree-like structure. we will show that they form a disjoint union of lattices compatible with our rewriting formalisms. we assume that xml nodes are distinguishable by an id (which can be the node name or a designated attribute) and the order on child nodes (but not the content of nodes) is negligible. furthermore, every xml node has a value (possibly a tuple) which describes its properties, such as attributes, excluding child nodes. we use ⊎ to denote the disjoint union. definition 9 (xml inscription) let (val,t) be a disjoint union of complete lattices vali of values with ⊎i∈i vali = val and let n be a set of ids, which is sorted such that it can be partitioned in ni with n = ⊎i∈i ni. an xml inscription xmln,val is a directed rooted tree (v,e,r,γ) of finite height, where v is a set of vertices, e ⊆ v ×v is a set of edges, r ∈ v is the root and γ ∶ v →⋃i∈i(ni × vali) maps properties to each vertex. additionally for every two edges (v1,v2),(v1,v3) ∈ e with γ(vi) = (ni,wi) (for i ∈ {2,3}) it holds that n2 ≠ n3. for every v ∈ v we define v↓= (v ′,e′,v,γ′) to be the subtree of xmln,val with root v, which is an xml inscription itself. definition 10 let xmln,val be the set of all xml inscriptions xmln,val. we define the ordered set (xmln,val,⊑), where for two elements (v1,e1,r1,γ1) ⊑ (v2,e2,r2,γ2) holds if and only if: let γi(ri) = (ni,wi) for i ∈ {1,2}, then n1 = n2, w1 t w2, and for all v1 ∈ v1 with (r1,v1) ∈ e1 there is a v2 ∈ v2 with (r2,v2) ∈ e2 such that v1↓⊑ v2↓. lemma 3 (xmln,val,⊑) is a disjoint union of complete lattices, provided val is. 7 / 13 volume 67 (2014) lattice-extended cpn rewriting for adaptable ui models the proof of lemma 3 is based on the following observations: each lattice in within xmln,val consists of all inscriptions, where the id of the root elements are equal. the supremum exists if and only if this is the case and can be computed inductively as follows. let l ⊆ in be a nonempty subset of in where root elements have id k. for every id n ∈ n, we define c⊔n (l) = {v↓ ∣ (v,e,r,γ) ∈ l,(r,v) ∈ e,γ(v) = (n,w)}, the set of all direct subinscriptions of inscriptions of l, where the root id is n. furthermore, let m = {n ∈ n ∣ c⊔n (l) ≠ ∅} be the set of all ids for which child nodes exist and let (vm,em,rm,γm) = ⊔c⊔m(l) be their supremum for each m ∈ m. the supremum of l can be expressed as follows: ⊔l = ({x}⊎ ⊎ m∈m vm,{(x,v) ∣ v ∈ {rm ∣ m ∈ m}}⊎ ⊎ m∈m em,x,γ ′), where γ′(y) = γm(y) for y ∈ vm and γ′(x) = (k, l∈l wl) with l = (vl,el,rl,γl) and γl(rl) = (k,wl). the infimum can be expressed in an analogous way, with the exception that c⊓n (l) = c⊔n (l) if every inscription of l has a child with id n and c⊓n = ∅ otherwise. example 3 to illustrate the use of (xmln,val,⊑), we give a complete deletion-focused rewriting step in figure 5. the rule as well as the rewritten nets are show in figure 5a. for clarity, the inscriptions of the shown transitions are displayed separately in figure 5b. inscriptions of arcs have a root id ia and either a variable (x or y) or no variable (�a with x,y ⊒ �a) as value. root elements of inscriptions of transitions have always the id it and value �t , but have a more complex substructure. this can consist of a guard condition g (a boolean expression preventing firing), an action a (assigning the result of an arithmetic to a variable when firing) and a style s (describing the visual appearance). the style can consist of a position p and a colour c. (ia,�a) (ia,�a) α l (ia,�a) (it,�t ) i (ia,�a) β r (ia,x) (ia,y) γ n (ia,x) γ ′ n′ (ia,x) γ ′′ n′′ (a) deletion-focused rewriting using (xmln,val,⊑) as inscriptions (it,�t ) (a,�a) α (it,�t ) (it,�t ) (s,�s) (c,red) β (it,�t ) (g,x ≤ 10) (a,y = 2 ⋅x) (s,�s) (p,(10,10)) γ (it,�t ) (g,x ≤ 10) (s,�s) (p,(10,10)) γ ′ (it,�t ) (g,x ≤ 10) (s,�s) (p,(10,10))(c,red) γ ′′ (b) shows how the inscriptions of the transitions in figure 5a are rewritten figure 5: example of a deletion-focused rewriting of an xmln,val-coloured petri net the given rule can be matched to any net n that contains a transition with one incoming arc, one outgoing arc, and an action with any value. in the first step, it deletes the outgoing arc and the action to generate the net n′. the inscription γ′ is the largest inscription satisfying γ′⊓α = (it,�t ) as well as γ′ ⊑ γ , since the existence of an action in γ′ would cause γ′ ⊓α to contain an action as proc. gtvmt 2014 8 / 13 eceasst well. note that n′ is not a pushout complement (which does not exist), since the inscription of the deleted arc is strictly larger than its preimage in l, thus, the rule is not preservation-applicable to n. in the second step, the pushout n′′ is generated by calculating the supremum γ′′ = γ′ ⊔ β , which contains all merged subinscriptions of both γ′ and β . the value of it in γ′′ is generated by the supremum of its values in γ′ and β , i.e. by �t ⊔�t = �t (the same holds for s). effectively the transition is marked with the colour red, without changing other layout properties. in addition to the previous result, we can show that our approaches rewrite uniquely, if the lattices of values are meet-infinite or join-infinite distributive. lemma 4 every lattice of (xmln,val,⊑) is meet-infinite (or join-infinite) distributive, if every lattice of val is meet-infinite (or join-infinite) distributive. 4 application to user interface reconfiguration adaptable uis offer a great benefit to human-computer interaction, according to the fact that those uis can be adapted to the user’s personal preferences and abilities. the use of a formal modelling approach in this context offers the opportunity to close the gap between modelling and execution of uis on the one hand and the implementation of adaptable uis in a full-fledged computer-processable format on the other. based on a two-layered representation of a ui, we developed a visual modelling language for interactive modelling of interaction logic by experts. interaction logic can be defined as a data processing layer, modelling data-based communication between the physical representation and the system to be controlled. the physical representation is the second layer of the ui that directly interacts with the user and can be specified as a set of widgets, such as buttons, sliders, or text fields, etc. in the interaction logic, events are being processed that occur after, e.g., the user pressed a button or after he used another interaction element of the physical representation. vice versa, data emitted from the underlying system is prepared to be presented to the user via the physical representation. beside this data-based communication between user and system (also called business logic), also dialogue-specific structures are specified in interaction logic. here, data-based dependencies between input events and system data can influence interaction by predefined logic conditions. for visually modelling, a graph-based visual language called fill [wey12] has been developed, that is transformed into reference nets as introduced by kummer [kum02]. the reason for this is motivated by various aspects, such as that the transformation defines a formal semantic for fill, reference net-based interaction logic is executable using the implemented open-source simulator renew [kwd], and finally, interaction logic is accessible for formal graph rewriting concepts, as described in the paper at hand. thus, based on this transformation and the rewriting approaches introduced, the full-fledged concept required for the development of formal adaptable uis is provided. for modelling user interfaces using fill, a visual and interactive editor has been developed, called uieditor1. the editor is separated into two visual editors to (a) model the physical representation of a visual user interface and (b) to model interaction logic using fill. for execution 1 www.uieditor.org 9 / 13 volume 67 (2014) lattice-extended cpn rewriting for adaptable ui models of the user interface model, the uieditor offers a simulation component, which is also capable to transform fill models into reference nets. thus, a computer parseable representation of such a reference net has to be provided. we decided to use pnml, which is the main reason for applying the lattice-extended rewriting approach to pnml in section 3. the whole transformation algorithm has been described in [wey12, pg. 44–84]. a third component implements interactive reconfiguration, as it will be described in more detail, below, which is responsible for interactively creating rewriting rules. this interactive creation is the major aspect of implementing adaptable user interfaces, since the engineer modelling the ui is not able to foresee all possible adaptations a user could have in mind. hence, the changes in the ui – both in the physical representation and the interaction logic – should be controlled by the user and need not be predefined by the application provider (although this is also possible). using graph transformation to change interaction logic, the behaviour of a given user interface can be adapted to certain requirements. paired with the ability of reference nets to be executed based on simulation, the changes can be directly tested and used in an application scenario. for instance, in [wblk12] such an scenario has been described, where users were asked to reconfigure an initially given user interface of a simple simulation of a steam water reactor according to a variety of trained control tasks. these tasks were embedded to a controlling scenario of the reactor simulation. here, the user has to start and stop the reactor, or to handle upcoming system errors, such as the blackout of a water pump. in a test run, two groups were asked to perform these tasks in a predefined test scenario [bwkl13]. the experiment group was able to interactively reconfigure the user interface by choosing from a predefined set of operations, where the control group did not have this option. the users were able to combine various buttons to one, which was able to perform all operations in parallel, that were former triggered by the selected buttons. furthermore, users were able to discretize a continuous input operation, e.g., represented as a slider widget. for instance, a user can select a slider, chose the discretization operation, and define the discrete integer value that should be settable by a newly generated button. the rewriting rule generated for such an adaptation is shown in figure 6, including an exemplary rule application. (ia,�a) (ia,n) α l (ia,�a) (ia,n) (it,�t ) i (ia,�a) (ia,n) β r (ia,r) (ia,n) γ n (ia,r) (ia,n) γ ′ n′ (ia,r) (ia,n) γ ′′ n′′ (a) structure of the discretization rule (it,�t ) (a, number n = slider.getvalue();) α (it,�t ) (it,�t ) (a,integer n = 700;) β (it,�t ) (g,r ≥ 10) (a, number n = slider.getvalue();) γ (it,�t ) (g,r ≥ 10) γ ′ (it,�t ) (g,r ≥ 10) (a,integer n = 700;) γ ′′ (b) inscriptions changed by the discretization rule (a abbreviates actions, g abbreviates guard conditions) figure 6: example of the rewriting rule for the discretization, including an application proc. gtvmt 2014 10 / 13 eceasst all reconfiguration operations were applied to reference net-based interaction logic using deletion-focused pnml rewriting in a two step process. in the first step, the user interactively selected the interaction elements that should be affected (e.g. the slider), as well as the reconfiguration operation (e.g. discretization) that should be applied. the second step has been implemented algorithmically and was responsible for selecting the affected graphical parts of interaction logic (e.g. the button) and generating the xml-based graph rewriting rule, containing all parts to be changed and being applied to interaction logic afterwards. in figure 6a the resulting rule of the discretization operation can be seen where the inscriptions are show figure 6b. here, the lattice uses class inheritance to define a rule pattern which can match various number types in the inscription, such as double or integer. the new transition generates a specific integer value implementing the functionality of the new button, while the guard condition remains unchanged, since it was not specified to change by the rule. 5 conclusion by adding an order on the inscriptions, we introduced two rewriting formalisms for coloured petri nets, which are also able to (partially) change inscriptions. the first formalism is a straightforward extension of the classical dpo approach, while the second formalism tries to add an spo-like behaviour on the inscriptions, still providing the same behaviour on the net structure. the latter approach has similarities with the so called sesqui pushout approach introduced in [chhk06], where the left leg of a rule is not applied by calculating the pushout complement, but the final pullback complement. the main difference is that all incident edges are cloned in sqpo, if a node is split by a rule. further, there are rules, where our deletion-focused rewriting will be ambiguous while sqpo is not applicable due to the fact that the final pullback complement is unique if it exists. our approach is similar to [pem87] while correcting a minor error already mentioned in [hp02], coming from incorrect conditions for the existence of pushout complements. in section 3 and 4 we introduced a disjoint union of lattices compatible with our formalisms and illustrated how the uieditor uses this formalisms to realize adaptive user interfaces. i this context the approach of [lo04] could be interesting, where the application of transformation rule may depend on the current marking of the net. although out of the possibilities of this paper, it is not difficult to introduce typical extensions of the dpo approach into our approach, for instance negative application conditions. furthermore, its extension to other types of labelled graphs is quite straightforward. acknowledgements: we thank barbara könig for the helpful discussion on lattice theory and its possible application in our setting. bibliography [bir67] g. birkhoff. lattice theory. american mathematical society, 1967. [bwkl13] d. burkolter, b. weyers, a. kluge, w. luther. customization of user interfaces to reduce errors and enhance user acceptance. applied ergonomics, 2013. 11 / 13 volume 67 (2014) lattice-extended cpn rewriting for adaptable ui models [chhk06] a. corradini, t. heindel, f. hermann, b. könig. sesqui-pushout rewriting. in proc. of icgt ’06. pp. 30–45. springer, 2006. lncs 4178. [cmn80] s. k. card, t. p. moran, a. newell. the keystroke-level model for user performance time with interactive systems. communications of acm 23:396–410, 1980. [ehp06] h. ehrig, k. hoffmann, j. padberg. transformations of petri nets. electr. notes theor. comput. sci. 148(1):151–172, 2006. [hjsw10] f. heidenreich, j. johannes, m. seifert, c. wende. closing the gap between modelling and java. in software language engineering, lncs 5969. pp. 374–383. 2010. [hkk+09] l. m. hillah, e. kindler, f. kordon, l. pertrucci, n. trèves. a primer on the petri net markup language and iso/iec 15909-2. in petri net newsletter. volume 76. gesellschaft für informatik, bonn, 2009. [hp02] a. habel, d. plump. relabelling in graph transformation. in proc. of icgt ’02. pp. 135–147. springer, 2002. lncs 2505. [jen97] k. jensen. coloured petri nets: basic concepts, analysis methods and practical use. vol 1, basic concepts. springer, 1997. [jwz93] c. janssen, a. weisbecker, j. ziegler. generating user interfaces from data models and dialogue net specifications. in proc. of interact ’93 and chi ’93. chi ’93, pp. 418–423. acm, new york, ny, usa, 1993. [kp85] d. kieras, p. g. polson. an approach to the formal analysis of user complexity. international journal of man-machine studies 22(4):365–394, 1985. [kum02] o. kummer. referenznetze. logos, 2002. [kwd] o. kummer, f. wienberg, m. duvigneau. renew—the reference net workshop, online, url: http://renew.de/ (last visited: 30-10-2013). [lo04] m. llorens, j. oliver. introducing structural dynamic changes in petri nets: marked-controlled reconfigurable nets. in wang (ed.), automated technology for verification and analysis. lncs 3299, pp. 310–323. springer berlin, 2004. [nplb09] d. navarre, p. palanque, j.-f. ladry, e. barboni. icos: a model-based user interface description technique dedicated to interactive systems addressing usability, reliability and scalability. acm tochi 16(4):1–56, 2009. [pem87] f. parisi-presicce, h. ehrig, u. montanari. graph rewriting with unification and composition. in proceedings of the 3rd int’l workshop on graph-grammars and their application to computer science. pp. 496–514. springer, 1987. [ros75] b. k. rosen. deriving graphs from graphs by applying a production. acta informatica 4:337–357, 1975. proc. gtvmt 2014 12 / 13 http://renew.de/ eceasst [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation: volume i. foundations. world scientific publishing, 1997. [sw14] j. stückrath, b. weyers. lattice-extended coloured petri net rewriting for adaptable user interface models. technical report 2014-01, abteilung für informatik und angewandte kognitionswissenschaft, universität duisburg-essen, 2014. [wblk12] b. weyers, d. burkolter, w. luther, a. kluge. formal modeling and reconfiguration of user interfaces for reduction of errors in failure handling of complex systems. human-computer interaction 28(10):646–665, 2012. [wey12] b. weyers. reconfiguration of user interface models for monitoring and control of human-computer systems. dr. hut, 2012. 13 / 13 volume 67 (2014) introduction coloured petri net rewriting with lattices deletion-focused pnml rewriting application to user interface reconfiguration conclusion ray-tracing based inference attacks on physical layer security electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) ray-tracing based inference attacks on physical layer security paul walther, markus richter and thorsten strufe 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst ray-tracing based inference attacks on physical layer security paul walther1, markus richter1 and thorsten strufe2 1 chair for privacy and security, tu dresden 2 karlsruhe institute of technology (kit) and centre for tactile internet, tu dresden (ceti) abstract: in wireless network security, physical layer security provides a viable alternative to classical cryptography, which deliver high security guarantees with minimal energy expenditure. nevertheless, these cryptograhpic primitives are based on assumptions about physical conditions which in practice may not be fulfilled. in this work we present a ray-tracing based attack, which challenges the basic assumption of uncorrelated channel properties for eavesdroppers. we realize this attack and evaluate it with real world measurement, and thereby show that such attacks can predict channel properties better than previous attacks and are also more generally applicable. keywords: wireless network security, physical layer security, attack 1 introduction physical layer security (physec) promises to provide an alternative to classical encryption. information theoretic proofs demonstrate its high security guarantees [bb11]. additionally, it has low computational complexity and minimal energy consumption. this combination makes it very enticing for resource constrained devices, e.g. in sensor networks, iot or the tactile internet. physec exploits the properties of the physical medium to achieve security goals and it provides primitives for encryption, authentication and key derivation. despite the security proofs, the security is based on assumptions about the leveraged physical properties, which we deem questionable in realistic settings. physec is well suited for implementation in the field of wireless network security, as there is a multitude of physical properties that can be exploited for this purpose. authentication and key generation use the channel coefficients of the shared channel between the legitimate terminals to derive unique identifiers, or symmetrical keys respectively. these properties of the wireless channel are completely described by the channel impulse response (cir) [gol05]. the underlying security assumption in this context is derived from the so called uniform scattering model developed by jakes [jak95]. this assumption states, that an adversary residing more than half of a wavelength away from the legitimate terminals can only measure channel characteristics uncorrelated to those of the legitimate shared channel. if this assumption is not fulfilled, the attacker can observe channel properties with high correlation to the legitimate ones. this would mean that despite the proven security of the subsequent processing, the security primitives themselves must be considered compromised. here we want to collect evidence to determine whether this assumption is justified in the physec context or not. in continuation of this rationale, practical attacks have already been presented, which aim at directly predicting the cir of the legitimate channel [wks20, b+12]. such attacks have 1 / 4 volume 080 (2021) ray-tracing based inference attacks on physical layer security the following advantage: due to noise and interference, differences between observations also occur between the channel characteristics of the legitimate partners. the further processing of the cirs for physec primitives takes this into account and removes such differences [bb11]. this gives the attacker the advantage that no perfect prediction is necessary to compromise the corresponding security primitive. although the presented approaches demonstrate the basic feasibility of such attacks, they come with the disadvantage that they are not generally applicable yet. more precisely, they either achieve very little agreement between the legitimate and the predicted properties (even less than simple eavesdropping) or they are applicable to a very specifically given setting only. in this paper we present an alternative prediction attack based on ray-tracing concepts. this has the advantage that predictions about channel properties can be realized based solely on geometry and terminal position. thus, in contrast to the current state of the art, this attack is both generally applicable and completely independent of any kind of optimization. we will show that high correlation between the predictions and the actual channel properties can still be achieved. we implement the presented attack and evaluate it with real world measurements. the results are then compared to current state of the art attacks. finally, to demonstrate the effects of such attacks, we show that in the context of key derivation a significantly lower hamming distance is achieved than for an eavesdropping adversary. 2 ray-tracing based inference attacks the core approach of our attack is to directly predict the channel properties of the reciprocal channel shared by the legitimate partners. given an accurate enough prediction, the adversary can perform the same processing as alice and bob and thereby achieve the same results, e.g. the same key material. the rationale for a ray-tracing based attack on cirs is twofold: first, ray-tracing based simulations are very well suited for simulating wave propagation for high frequency electromagnetic waves [yi15]. in such settings, the power received at the target terminal can be simulated as the superposition of all relevant rays. hence, this method is suitable to simulate the amplitude of the resulting cir with high accuracy [yi15]. second, the ray-tracing calculation can be executed completely offline, without specific knowledge of the actual transmission. the only parameters required for the simulation are room geometry, terminal positions and wireless frequencies. all of these are accessible to attackers, since they can either be observed directly or are system parameters. together, these two reasons make the ray-tracing method an easy to implement but nevertheless promising method for the prediction of cirs. within this system we assume the following attacker model: the adversary is a passive eavesdropper, equipped with standard cots hardware. no setup steps for this attack need to be conducted. to carry out this attack, an adversary only needs to know the room geometry and the positions of the legitimate terminals, both of which can be easily obtained, e.g. by visual inspection. this attack model assumes a much weaker attacker than related works [wks20, b+12], as it does not require a preparatory phase in which the attacker collects specific measurements in the attacked room. additionally, no optimization with respect to these collected samples is required. netsys 2021 2 / 4 eceasst to execute such an attack, an adversary would proceed as follows: in a first step a representation of the current environment would be created — considering the typical use case of indoor wireless communication, this can be realized with negligible effort since most indoor rooms have cuboid shapes, which are easily modelled. during the actual attack, the attacker evaluates the ray-tracing model given the environment and the terminal position of the legitimate partners. these positions can be obtained visually at the point in time, at which the reciprocal measurement is conducted (which can be overheard by the adversary). the result of the ray-tracing simulation is then processed analogous to the actual key derivation. no actual observation of the legitimate partners exchange is required. 3 realization and evaluation the metric used to evaluate the accuracy of our predictions is the normalized cross-correlation as defined in [mit16]: cc(g,h) = max k rgh(k)√ egeh = max k ∑ ∞ i=−∞ g[i]h[i − k]√ ∑ ng−1 i=0 g[i] 2 ∑ nh−1 i=0 h[i] 2 . this calculates the cross correlation cc between the two signals g and h as a metric of the similarity. here, rgh is the non-normalized cross-correlation and eg and eh is the energy of the respective signal. in the concrete case g and h are the actual legitimate cir and the respective prediction from the ray-tracing attack. related work [wks20, b+12] use this metric as well, which facilitates a direct comparison. the dataset used for evaluation is the same as presented in [wks20]: the samples are cirs of ultra-wideband transmissions, realized with a center frequency of 4ghz and a bandwidth of 500mhz. we measured 17 different setups with 1000 cirs each in a typical indoor environment. 0 10 20 30 40 τ / ns 0 1 2 3 4 5 a m pl it ud e measurement attack prediction (a) prediction example this attack [b+12] [wks20] 0.6 0.7 0.8 0.9 1.0 a ve ra ge n or m al iz ed c ro ss c or re la ti on m ax im um o pt im iz ed reciprocal non-reciprocal (b) comparison of different attacks figure 1: evaluation results of the proposed ray-tracing attack. our implementation of the ray-tracing based attack using pylayers [alu13] achieved the following results. to demonstrate the general prediction performance, fig. 1a shows a direct comparison of a measured cir with the corresponding prediction from the ray-tracing attack. the core characteristics of the cir were accurately predicted by the attack. 3 / 4 volume 080 (2021) ray-tracing based inference attacks on physical layer security to further assess the effectiveness and to compare it against the state of the art, the average cross correlation achieved with this attack is present in fig. 1b. the dotted lines represent the average correlation of the legitimate, reciprocal cirs as well as the eavesdropped ones, i.e. the non-reciprocal cirs. the cross correlation of the proposed attack is shown as red bar on the left; the relevant related work are shown as blue bars on the right. the proposed attacks achieved a cross correlation of 0.851. this is higher than the maximum of 0.7 for [b+12] and higher than the average 0.825 for [wks20]. this means that our attack can more accurately predict the legitimate channel characteristics than the compared attacks. for [wks20] we compare our results against their general optimization as we want a generally applicable attack. the results show that the ray-tracing attack presented here achieves a better average cross correlation than comparable inference attacks. additionally, these results were achieved without any training or optimization. hence, this attack is more generally applicable and still outperforms the compared attacks. 4 summary in this work we investigated whether an adversary can directly predict channel properties used in physical layer security through ray-tracing based simulations. we realized such an attack and evaluated it on real world measurements. the results showed how this kind of attacks can achieve better correlated predictions than related works, while being more generally applicable and without the need for any optimization. bibliography [alu13] n. amiot, m. laaraiedh, b. uguen. pylayers: an open source dynamic simulator for indoor propagation and localization. in ieee icc. 2013. [b+12] s. ben hamida et al. on the security of uwb secret key generation methods against deterministic channel prediction attacks. in ieee vtc. 2012. [bb11] m. bloch, j. barros. physical-layer security: from information theory to security engineering. cambridge university press, 2011. [gol05] a. goldsmith. wireless communications. cambridge university press, 2005. [jak95] w. c. jakes (ed.). microwave mobile communications. an ieee press classic reissue. ieee press [u.a.], new york, ny, nachdr. edition, 1995. [mit16] s. mitra. signals and systems. oxford series in electrical and computer engineering. oxford university press, 2016. [wks20] p. walther, r. knauer, t. strufe. passive angriffe auf kanalbasierten schlüsselaustausch. gesellschaft für informatik e.v., bonn, 2020. [yi15] z. yun, m. f. iskander. ray tracing for radio propagation modeling: principles and applications. ieee access 3, 2015. netsys 2021 4 / 4 introduction ray-tracing based inference attacks realization and evaluation summary implementing dnssec soft delegation for microservices electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) implementing dnssec soft delegation for microservices andrés marı́n-lópez, patricia arias-cabarcos, thorsten strufe, gabriel barceló-soteras, daniel dı́az-sánchez, florina almenares-mendoza 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst implementing dnssec soft delegation for microservices andrés marı́n-lópez12∗, patricia arias-cabarcos1, thorsten strufe1†, gabriel barceló-soteras3, daniel dı́az-sánchez2, florina almenares-mendoza2 1 karlsruhe institute of technology, germany 2 universidad carlos iii de madrid, spain 3 parliament of the balearic islands, spain abstract: securing dns in edgeand fog computing, or other scenarios where microservices are offloaded, requires the provision of zone signing keys to the third parties who control the computing infrastructure. this fundamentally allows the infrastructure provider to create novel signatures at their discretion and even arbitrarily extend the certificate chain. based on our proposal on soft delegation for dnssec, which curtails this vulnerability, we report on our proof-of-concept: a c-implementation of chameleon hashes in openssl, a server side implementation of the mechanism in the ldns server, and an offline client that validates the signed records, in this paper. we also discuss different approaches for generating dnssec rrsig records, and the behavior of a resolver to verify the credentials and securely connect to an end point using tls with sni and dane. keywords: dnssec; dane; chameleon signatures; iot; microservices; fog computing 1 introduction interconnection of microservices requires name resolution and security support. dns and tls are by far the most used protocols for this purpose. local certification authorities (cas) and self-issued certificates are supported in tls, and suit in dynamic microservices scenarios. consider a group of off-shore windmills with dense local connectivity but expensive connection to the mainland, which is coordinated and managed by a local set of edge-servers, as one example. from the core of the network, several microservices are selected to be instantiated at the nodes in the windmills. once instantiated, the microservices will setup secure interconnections. most connections must be resolved inside the fog, including name resolution and certificate verification. our proposal in [dmaa19] was aimed at minimizing the intervention of the core of the network, especially the dns at the core (from now on the dnscore) with a soft delegation to the dns of the distant computing nodes, which we’ll call dnsfog. we proposed using chameleon hashes [kra00]. they allow an entity that possesses trapdoor information to create collisions – in ∗ funded by the comunidad de madrid project cynamon p2018/tcs-4566 and co-financed by european structural funds (esf and feder) † funded by the german research foundation (dfg, deutsche forschungsgemeinschaft) as part of germany’s excellence strategy – exc 2050/1 – project id 390696704 – cluster of excellence “centre for tactile internet with human-in-the-loop” (ceti) of technische universität dresden. 1 / 5 volume 080 (2021) dnssec soft delegation other words to compute signatures that verify alternative, arbitrary inputs. chameleon signatures are a lightweight solution compared to normal dnssec delegation. signed patterns impose the limits of the delegation to the dnsfog to only matching rrs. 2 dns security dns handles objects called resource records (rrs) of different types (a/aaaa, mx, name server ns, etc.) dns clients query for rrs matching a domain name (also known as owner field). dnssec adds integrity protection to dns, to prevent cache poisoning and spoofing. dnssec clients are provided with signatures to verify the integrity of the resource records in the response. validation requires the verification of the signatures, and dnssec introduces key chains for that matter. the chains originate at the root zone “.”. the zone records on each level are signed by a zone signing key (zsk). it’s integrity is verified by a using local key signing keys (ksk), which in turn are signed by the zsk of the parent zone in the ds records, basis for trust chain extension to a delegated zone. dnssec responses include the signatures (rrsig) of the rrs. as in dns, the answer may optionally include (1) the authoritative part including the name servers (ns) and corresponding rrsigs, and (2) the additional part, the prefetching mechanism of dns, with the rrs the server anticipates will be required by the client, for instance the a or aaaa records of the ns in the authoritative part, and corresponding rrsigs. the dns-based authentication of named entities (dane) specification [rfc6698] introduces the tlsa rr type. tlsa associates a certificate or a public key of an end-entity or a trusted issuing authority with the tls or dtls transport endpoint. dane tlsa records validated by dnssec can be used to augment or replace the use of trusted public cas. tls clients can use the service name indication (sni) when negotiating the connection with a tls server, and dane supports sni by tlsa records which can hold: a credential for the server (pkix-ee); a domain name trust anchor (ta) linking the authorized issuer ca for the domain (pkix-ta); a local ca entitled to issue trusted certificates for the domain (dane-ta); and even to indicate an ad-hoc key for the tls server (daneee). 3 dnssec soft delegation considering the usual dynamics in microservice deployments, dnssec would require the server to provide signatures for every local change. we hence propose soft delegation, allowing the dnscore to delegate signing of the microservices using chameleon signatures to the dnsfog. let us illustrate how the chameleon signatures work using discrete logarithms [am05]: 1. let dnsfog selects q a large prime, p = kq + 1, and g, a generator of z∗p. let sk f = x ∈ (1,q−1) be the trapdoor, with corresponding public key pk f = y = gxmod q. let (pks,sks) be the public and private keys of dnscore (the signer). 2. dnsfog sends the dnscore two random parameters a and b. the dnscore takes message m and computes e = sha256(m,b), cham-hash f (m,a,b) = a−(yegbmod p)mod q. 3. the dnscore signs it: sig = sigs(rrsig rdat a|a|b|cham-hash f (m,a,b)). netsys 2021 2 / 5 eceasst 4. the signature can be verified with (sig,m,a,b, p,g,q,y,pks). 5. when dnsfog wants to modify the message m′, it picks a new random l,computes the collision for the chameleon hash, the hash of m′, and the corresponding new b′: a′ = cham-hash f (m,a,b)+(g l mod p)mod q (1) e′ = sha256(m ′,a′) (2) b′ = k−e′xmod q (3) the new message signature can be verified with (sig,a,b,m′,a′,b′, p,g,q,y,pks), which means that the signature sig still holds for a modified m′. note that to verify the signature both the original parameters (a,b) and the new parameters (a’,b’) are required. that is how the dnscore limits the delegation to dnsfog by only allowing to generate modifications m′ from message m. m is obtained by hashing the serialization of a specially crafted rr, where the owner is modified to contain a placeholder (). we call this rr a pattern. an a pattern looks like: .example.com. 3600 in a rnd the pattern is serialized as: rrpattern=(owner|type|class|ttl|len(rdata)|rdata), rdata=.example.com|rnd. and the message is computed as m= sha256(rrpattern). in our soft delegation approach, the dnscore will generate the signature sig=sign(rrsig_rdata|a|b|cham-hash(m,a,b)). the signature is thus bound to the (a,b) parameters and to the chameleon hash of the pattern, which includes the dnsfog public key y. the public parameters y,p,g,q are in a ds record with private oid at the dnscore. the record generated by the dnscore will be like: .example.com 3600 in rrsig a 254 3 ttl d1 d2 32478 example.com. b64(sig,a,b) the algorithm value 254 (private_oid) indicates that the verification is different from standard. the (a,b) parameters are concatenated to the signature so that they can be recovered for verification. to create a new rr from the pattern, the dnsfog computes m′ as the sha256 of the serialization of the new rr, computes the parameters (a’,b’) to have a collision of the chameleon hash, and concatenates the (a’,b’) parameters to the signature. when the verifier gets the rrsig of the new rr, it will also query for the corresponding pattern rr and rrsig. it will compute the chameleon hash of the rrpattern using the (a,b) parameters from the rrsig of the pattern. next it will check the signature validity using the public key of the dnscore. then it checks that the chameleon hash of the new rr with (a’,b’) holds: cham-hash(m,a,b)=cham-hash(m’,a’,b’) finally, the verifier also has to check if the owner, type and ttl match the ones in the pattern. 4 implementation and evaluation the dnsfog has two alternatives to compute the collisions: approach 1: compute a single rrsig for the whole rrset of all the created microservices, or approach 2: multiple rrsigs: one per each of the created microservices. in approach 1, the signature is performed on the hash of the whole rr set. since no new rrsig 3 / 5 volume 080 (2021) dnssec soft delegation are added, there is no need to recalculate the nsec/nsec3 with each rr added. but this approach does not protect against domain enumeration, since the responses must include all the rrs to verify the signature of the rr set, disclosing thus all the existing a/tlsa records. besides responses size may exceed the limit of udp. in approach 2, each microservice will have its own rrsig, so equal number of nsec/nsec3 rrs have to be added. this approach provides domain enumeration protection but requires computing an extra collision for the nsec/nsec3 records, on the other hand responses are shorter, since only the required domain name a/tlsa are returned with the corresponding rrsig. we have opted in our implementation for approach 2. figure 1: verification of microservice queue.example.com figure 1 shows a microservice named queue.example.com instantiated by the orchestrator at ip 10.0.3.27 with a self-signed certificate entirely included in the tlsa record (daneee). the figure illustrates the whole process, asuming the client has already the public keys pks which is the zsk dnskey of the dnscore and the public parameters p,g,q,y which are in the ds record with private oid signed by the dnscore, i.e. the corresponding delegated public key of the dnsfog. 5 discussion and conclusions dnssec delegation is performed by signing a ds. normal delegation gives the dnsfog authority over a whole subdomain. an attacker may extract the delegated private key, if the dnsfog is in a remote site only visited for maintenance, as in the wind mill scenario. our proposal limits the delegation to a set of types (patterns), in the same way as we limit most verification traffic to the fog. in our proposal if the dnsfog is attacked, the attacker can only use the private key to alter rrs according to the pattern, and only locally at that fog. online signing requires the dnscore signing a key for each dnsfog and the key to be available at the dnsfog. this implies the above mentioned risk for remote unattended sites. in [dmaa19] we show that the collision computation time is negligible when compared with the signing time with rsa or ecdsa, while the time of computing the chameleon hash is 7 times slower than rsa signature, if advanced factorization is used. this increased load is pushed from the dnscore to the dnsfog, allowing the schema to scale. netsys 2021 4 / 5 eceasst the delegation increases the trust chain so that resolvers must also trust in the dnsfog. nevertheless, this is the same as in normal delegation scheme or in the pki trust model, where the trust is rooted at the top cas, but in the end you have to trust also the final entity presenting a certificate. at least for the time it takes a private security incident to be noticed and notified, and the final entity certificate to be revoked and the crl to be published or pushed to the ocsp server. trust is bounded by the patterns signed by the dnscore. they limit the delegation to the dnsfog, which has the trapdoor to add, delete or modify rrs according to the patterns. we call this a soft delegation since it is limited to the signed patterns: only rrs matching the delegated patterns can be modified by the dnsfog. the soft delegation alleviates the dnscore from the necessity of signing the whole zone with every new change in the microservices deployment in the fog. the dnscore only has to sign the delegated patterns using the chameleon hash. the dnsfog will compute the collision when a new rr is required using eqs. 1-3. we expect delegation to patterns of types a, aaaa and tlsa records. in an extended version of this article we will address more details of the implementation. our results from the server-side integration of the proposed soft delegation mechanism in the open source ldns dnssec server show that the chameleon hashes and the collisions are computed faster than in [dmaa19]. the proof of concept server side implementation is available at https://gitlab.pervasive.it.uc3m.es/100416942/ldns-tools-chamhash. besides we have developed an offline verifier which takes as input a json file containing all the required records to validate the signatures of dnssec records. we have verified that common cases of requests in microservice environments are protected through the use of the offline verifier together with some scripts and a python wrapper to invoke ldns. this can be found at https: //gitlab.pervasive.it.uc3m.es/100416942/core-fog-scripts. bibliography [am05] g. ateniese, b. de medeiros. on the key exposure problem in chameleon hashes. in blundo and cimato (eds.), security in communication networks. pp. 165–179. springer berlin heidelberg, berlin, heidelberg, 2005. [dmaa19] d. dı́az-sánchez, a. marı́n-lopez, f. almenárez mendoza, p. arias cabarcos. dns/dane collision-based distributed and dynamic authentication for microservices in iot. sensors 19(15):3292, 2019. [kra00] h. r. krawczyk. t: chameleon signatures. in proceedings of ndss. volume 2000, pp. 143–154. 2000. 5 / 5 volume 080 (2021) https://gitlab.pervasive.it.uc3m.es/100416942/ldns-tools-chamhash https://gitlab.pervasive.it.uc3m.es/100416942/core-fog-scripts https://gitlab.pervasive.it.uc3m.es/100416942/core-fog-scripts introduction dns security dnssec soft delegation implementation and evaluation discussion and conclusions preface electronic communications of the easst volume 8 (2008) proceedings of the third international ercim symposium on software evolution (software evolution 2007) preface tom mens, kim mens, ellen van paesschen, and maja d’hondt 4 pages guest editors: tom mens, ellen van paesschen, kim mens, maja d’hondt managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst preface tom mens1, kim mens2, ellen van paesschen3, and maja d’hondt3 1 université de mons-hainaut, avenue du champ de mars 6, 7000 mons, belgique 2 université catholique de louvain, place sainte-barbe 2, 1348 louvain-la-neuve, belgique 3 lifl/inria, cité scientifique, 59655 villeneuve d’ascq, france abstract: this volume of electronic communications of the easst contains a selection of the best submissions to the third edition of the international ercim symposium on software evolution, co-located with icsm in paris in october 2007. the event was organised by the ercim working group on software evolution, gathering researchers from all over the world to identify and discuss recent advancements and emerging trends in the state-of-the-art in research and practice on software evolution. keywords: software evolution, ercim 1 introduction software evolution refers to the phenomenon that software intensive systems constantly change, and have to change, in order to remain useful and usable. the research domain of software evolution is well-established and covers a wide diversity of different research topics [md08]. many conferences and workshops are devoted to software evolution, and this volume contains the postproceedings of one of them. on friday 5 october 2007, the third edition of the international symposium on software evolution was held, under the auspices of the ercim working group on software evolution. this year, the symposium was organised in paris, in co-location with the 23rd ieee international conference on software maintenance (icsm 2007). the organisers were tom mens (director of the ercim working group on software evolution), kim mens (lecturer at ucl, belgium), maja d’hondt (chargé de recherches at inria) and ellen van paesschen (ercim postdoctoral research fellow). the aim of the event was to gather people from both academia and industry to identify and discuss recent advancements and emerging trends in the state-of-the-art on research and practice in software evolution. as in previous years, the event was very successful with a total of 32 submissions, three of which were tool demonstrations. fifteen submissions and two tool demonstrations were accepted for presentation, and 11 of those were selected for inclusion in the current postproceedings, published as part of the electronic communications of easst. this corresponds to an overall acceptance ratio of 34.4 %. an international programme committee of experts in the field was in charge of ensuring the quality of the accepted and published papers. 37 persons, coming from 12 different countries attended the symposium. the presentations covered a wide variety of research topics, ranging from research advances in software refactoring, open source software evolution, reengineering of legacy code and software product lines, to evolution problems and issues in component-based, service-oriented, aspect1 / 4 volume 8 (2008) ercim evol 2007 preface oriented and model-driven software development. the two tool demonstrations focused on the support of feature modelling and maintaining design regularities in evolving code. last year’s postproceedings were published in elsevier’s electronic notes in theoretical computer science [mdd07]. 2 about the papers in this volume the following papers have been selected for inclusion in this volume of electronic communications of the easst because of their quality. first, there is a series of papers in the volume that provide empirical studies on the evolution of open source software systems: • the article on the resilience of classes to change by rajesh vasa et al. studies the evolution of several public domain open source object-oriented (java) software systems. more specifically, the rate and amount of change in individual classes is investigated. it turns out that most of the effort during evolution is spent on introducing new classes; only a small percentage of existing classes is modified, and these modifications tend to be small. • in the article package evolvability and its relationship with refactoring, asma mubarak et al. study the evolution of seven open source systems in java at package level, and try to investigate change trends in overall changes applied to these systems, complemented with empirical evidence in refactoring data for these systems. • karl beecher et al. report on the evolutionary success of open source software: an investigation into exogenous drivers. in particular, the chosen forge (i.e., the online repository in which the open source software products are made available to the community) seems to have an important impact on the relative success and change rate of a software project. these findings are corroborated by comparing about 50 projects from debian with about 50 projects from sourceforge. two articles in this volume are related to model-driven engineering, and deal with aspects like model refactoring and model-code synchronisation: • the article refactoring of uml models using agg by alessandro folli and tom mens reports on an experiment to implement uml model refactorings using the agg graph transformation tool, and provides recommendations on how agg and graph transformation in general may be improved to facilitate such support. • lászló angyal et al. present novel techniques for model-code synchronization that can be used to better support model-based iterative software development through efficient model-code change propagation. a bi-directional synchronization technique is proposed based on three-way abstract syntax tree differencing and merging, and a case study is provided to illustrate the technique. two more articles in this volume address aspects of migration and reverse engineering: proc. software evolution 2007 2 / 4 eceasst • the article lightweight visualisations of cobol code for supporting migration to soa by joris van geet and serge demeyer studies how legacy systems, programmed in cobol, can be migrated to a service-oriented architecture in a stepwise fashion. to this extent, existing reverse engineering and visualisation techniques are used throughout the process. some preliminary results of applying the approach on an industrial case study are discussed. • the supporting reengineering scenarios with fetch: an experience report by bart du bois et al. introduces fetch, a tool chain for reengineering. this tool chain has been applied in an industrial setting, and the results of this experience report are presented. the remaining articles in this volume are quite diverse, and treat topics like build systems, acceptance testing, and software product line evolution. • filippo ricca et al. report on the use of executable fit tables to support maintenance and evolution tasks. they carried out an experiment with master students to investigate the usefulness of executable acceptance tests for software evolution activities. the acceptance tests were developed with the framework for integrated test (fit). the initial results seem to indicate that evolution activities can be performed better (in the sense that the correctness of the evolved code is improved) in roughly the same amount of time as without using the technique. • bram adams et al. studied the evolution of the linux build system. just as source code is subject to continuous evolution, so is the build system. the challenge is to keep it fast, even though its complexity continues to grow over time. this study is quite interesting in that the laws of software evolution also seem to hold for the build system. in addition, it turns out that there is some inevitable amount of co-evolution between the source code and its build system. • klaus schmid and holger eichelberger propose a requirements-based taxonomy of software product line evolution. from the viewpoint of requirements engineering, a taxonomy of evolution operations for software product lines is proposed. the presented taxonomy can be used as a reference for product line evolution support that goes beyond existing levels of support. acknowledgements: the symposium was sponsored by the following organisations: • the european research consortium for informatics and mathematics (ercim) www.ercim.org • the inria futurs research center in france www.inria.fr/futurs • the université des sciences et technologies de lille (ustl) in france www.univ-lille1.fr 3 / 4 volume 8 (2008) www.ercim.org www.inria.fr/futurs www.univ-lille1.fr ercim evol 2007 preface • the fonds de la recherche scientifique fnrs in belgium www.frs-fnrs.be • the interuniversity attraction poles programme belgian state belgian science policy. prog.vub.ac.be/moves bibliography [md08] t. mens, s. demeyer. software evolution. springer, 2008. [mdd07] t. mens, m. d’hondt, l. duchien (eds.). proceedings of the ercim worshop on software evolution 2006. volume 166. elsevier science, january 2007. proc. software evolution 2007 4 / 4 www.frs-fnrs.be prog.vub.ac.be/moves introduction about the papers in this volume zero trust service function chaining electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) zero trust service function chaining leonard bradatsch, frank kargl and oleksandr miroshkin 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst zero trust service function chaining leonard bradatsch,1 frank kargl2 and oleksandr miroshkin3 1 leonard.bradatsch@uni-ulm.de 2 frank.kargl@uni-ulm.de institute of distributed systems ulm university, germany 3 oleksandr.miroshkin@uni-ulm.de communication and information center ulm university, germany abstract: in this paper, we address the inefficient handling of traditional security functions in zero trust (zt) networks. for this reason, we propose a novel network security concept that combines the ideas of zt and service function chaining (sfc). this allows us to efficiently decide which security functions to apply to which packets and when. keywords: network security, zero trust security, service function chaining 1 introduction zt [rbmc20] is one of the most discussed trends in the area of network security. the idea of zt is motivated by current security challenges such as the trend to home work that results in new resource access patterns. zt mainly addresses these challenges by strictly enforced trust-based authentication and authorization (auth*) for all resource requests. the most common zt component that enforces such auth* decisions is the centrally positioned policy enforcement point (pep), which must be passed before resource access is granted. in current zt architectures, traditional security functions such as multi-factor authentications (mfa) or intrusion prevention systems (ips) work independently from the zt components and are applied to all packets that flow through these functions’ paths. likewise, these functions are still necessary because they provide elementary security functionalities such as ddos protection that are not provided by the zt compotents. however, in modern networks with ever increasing bandwidths, the processing of all packets by such computationally expensive security functions causes a high load on the hardware that hosts the functions and may lead eventually to congestion at these points. to address this problem, we propose a dynamic orchestration of the traditional security functions in the network by the pep. this allows the pep to efficiently decide when to apply which traditional security function to which packet flows. for example, an ips can be saved if the requesting device is already sufficiently trusted after the pep’s auth* decision to access the resource. in the remainder of this paper, we introduce a novel security concept that implements the described problem solution by combining the ideas of zt and sfc [hp15]. furthermore, we present a first prototype based on tls and http. as a conclusion, we give a first resume as well as an impression of our upcoming works in this area. 1 / 5 volume 080 (2021) zero trust service function chaining 2 zero trust service function chaining to achieve a dynamic orchestration of traditional security functions by the zt components and thus a more efficient security-relevant packet processing, we propose a novel network security concept called zero trust service function chaining (ztsfc). in this paper, we focus on an implementation of the presented ztsfc concept in lans such as enterprise networks. sfc [hp15] alone describes the approach of dynamically chaining a set of available network functions (e.g., http header enrichers, congestion mitigators or firewalls) based on a decision made by a central classifier. such a decision is based on certain parameters such as ip addresses that packets of a network flow have. all thus chained functions are then applied to the packets of that very flow. on the other hand, the most central components in a zt architecture are the auth* decision making policy decision point (pdp) and the decision enforcing policy enforcement point (pep) [rbmc20]. for the sake of simplicity, we will use the term pep in this paper to represent both mentioned components and their functionalities. the pep makes and enforces central trustbased auth* decisions before it decides about the further processing of client’s requests. these decisions are based on the trustworthiness of the requestor. meaning a requestor is only allowed to access the resource, if it’s trustworthiness is higher than a predefined trust threshold. the trustworthiness is derived from multiple sources, e.g., user, device and history databases. there can be an arbitrary amount of peps in a lan, all responsible for a specific subset of resources. since of the central positioning of such a pep component in a zt architecture, it has access to all information needed to make sfc classification decisions as well. therefore we propose to combine the functionalities of the sfc classifier and the pep in the pep. the pep can therefore efficiently decide based on their information sources when and which security functions should be applied to packet flows. by doing this, we can achieve three major improvements: (1) we can dynamically increase the trustworthiness of a requester by applying additional security functions to their packets, or eliminate unnecessary security functions if the trustworthiness after the initial auth* process is already sufficient to access the requested resource. (2) we can relieve the pep of several security functionalities of a zt network and at the same time distribute these very functionalities by using appropriate service functions that are responsible for this task. (3) the auth* as well as the classification process can be automated by expressing respective deterministic context-based rules in the pep’s policies. figure 1a depicts a concrete showcase of how the above mentioned improvements can be achieved in practice. here a client wants to access an enterprise’s service. the pep is the only publicly accessible entry point to this service. all other components are logically microsegmented by strictly enforcing mutual authentication using enterprise certificates. upon arrival, the client’s trustworthiness consists of the presence of a client certificate and management software. if the client can prove that it is a managed device and can present a valid client certificate signed by the pep, the client’s trustworthiness is sufficient and the pep proxies the client directly to the service (green path). in the case of a device that does only have a valid client certificate but is not managed, the pep sets up an sfc that includes an ips function that can partially compensate for the missing security software on the device and increase the trustworthiness of the request to a sufficient level (blue path). in this way, security-related packet processing can be kept efficient by only applying extremely time-consuming tasks such as an ips if the client is netsys 2021 2 / 5 eceasst (a) exemplary ztsfc and all its chaining options with a pep as classifier. client pep service mfa enterprise lan internet cloud ips (b) http-based ztsfc with one target ip (service) in the http header. get / http/1.1 ... accept-encoding: [gzip, deflate, br] cachecontrol: [max-age=0] ... get / http/1.1 ... accept-encoding: [gzip, deflate, br] service: [10.5.0.2:443] cachecontrol: [max-age=0] ... extracts the service ip and then removes the service header field to restore the original request client pep/ classifier service enterprise lan internet ips 10.5.0.2 cloud automatically managed by reverse proxy session handling mtl s mtl s (m) tls figure 1: the depicted exemplary ztsfc consist of an ips and the left one additionally of a mfa as security service functions. not managed. only if the ips is passed successfully, the client’s trustworthiness is increased to a sufficient level to be allowed to access the resource. in the case that the device is managed but can not present a valid certificate, the pep enforces a sfc containing an additional mfa that is performing a check for a different factor (orange path). leveraging ztsfcs in such a way unburdens the pep by outsourcing such security tasks to respective functions. if the client can neither provide a certificate nor is managed, both exemplary functions are part of the enforced sfc (red or brown path; depending on the functions order). all functions can be set up by the pep completely dynamically and in an arbitrary order. furthermore, all these described steps can be automated by defining respective policies. 3 http-based ztsfc as a proof of concept, we implemented a first ztsfc prototype by using tls and http. we chose this approach because both protocols are widely used and supported by almost every computer system. thus, this approach has low barriers to entry and can be taken up by anyone easily. figure 1b depicts our early ztsfc prototype consisting of a pep, an ips function and a service. at the reception of a client’s request, the pep extracts all necessary parameters from the packet and decides based on the previously stated context-based deterministic policy rules how to set up the chain. in the case the pep includes the ips in the ztsfc, the pep adds the respective function ips into the http header as new custom header field. in this described scenario, it has to add one ip, the ip of the service, to the header. afterwards, the pep terminates a mtls connection with the ips and proxies the modified http packet to the ips function. the ips function can then extract the target’s ip of the next hop in the chain from the respective http header fields and proxies it to the service using a new mtls connection. if the packets do not pass the ips, they are dropped and the ips sends respective feedback to the pep. this approach can be applied analogously to any number of functions. the function ips are added to the http header similar to an onion routing approach. each function deletes the ip for it’s next hop. thus, 3 / 5 volume 080 (2021) zero trust service function chaining the service receives the original request. the way back through the chain to the pep is handled by a common session handling similar to a reverse proxy. the chosen http approach has shown several advantages. it is completely compliant with the http standard. there is neither a need for a new protocol nor a major adjustment to an existing one. furthermore, all functions required to implement an http-based ztsfc can be implemented at the application layer. thus, the http-based approach is easily realizable, provides a high portability and is independent from lower layer protocols (such as mpls) that are used to implement sfc technology in other systems. the obligatory confidentiality and integrity are provided by tls. 4 conclusion & future work in this paper, we addressed the problem of inefficient handling of traditional security functions in common zt architectures. to achieve greater efficiency in this area, we have introduced a novel network security concept that combines the ideas of zt and sfc. in this context, individual security functions are dynamically orchestrated by the pep. the concepts leverages contextbased deterministic rules evaluated by the zero trust pep to decide which security functions are chained and afterwards applied to the affected packets. by doing this, especially time, power and computing intensive functions such as ips can be avoided if not necessary. by an automated rule evaluation the whole chaining process can be automated by the pep. by only using tls and http this ztsfc approach can be realized in almost every computer network. furthermore, the whole approach is tls and http protocol-compliant. as future work and long-term goal, we plan to set up an elaborated ztsfc that have welldefined trust-based security policies that enforce highly efficient decisions. thereafter, comprehensive performance evaluations of the http approach is scheduled. comparisons with other alternative approaches such as mpls-based ones are also considered. furthermore, we are working on additional sfc-related security features. similar to the onion routing approach, for example, the header field containing the service’s ips could be encrypted with the public key of the respective sff exchanged during the tls handshake. by doing this, the other functions in the chain become hidden to the single functions except the adjacent ones. this method would increase the zero trust level in the network. to achieve proof of transit, the functions could add integrity providing security tokens to the http header encrypted by the pep’s public key after the processing of the packet. if a token is absent or shows changes when received by the pep, it could be dropped. acknowledgements: this work has been supported in the bwnet2020+ project by the ministry of science, research and the arts baden-württemberg (mwk). the authors alone are responsible for the content of this paper. netsys 2021 4 / 5 eceasst bibliography [hp15] j. halpern, c. pignataro. service function chaining (sfc) architecture. rfc 7665, rfc editor, october 2015. [rbmc20] s. rose, o. borchert, s. mitchell, s. connelly. zero trust architecture. nist computer security resource center 2nd draft, 2020. 5 / 5 volume 080 (2021) introduction zero trust service function chaining http-based ztsfc conclusion & future work from c++ refactorings to graph transformations electronic communications of the easst volume 3 (2006) proceedings of the third workshop on software evolution through transformations: embracing the change (setra 2006) from c++ refactorings to graph transformations lászló vidács and martin gogolla and rudolf ferenc 15 pages guest editors: jean-marie favre, reiko heckel, tom mens managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst from c++ refactorings to graph transformations lászló vidács1 and martin gogolla2 and rudolf ferenc1 1department of software engineering, university of szeged, hungary 2department for mathematics and computer science, university of bremen, germany abstract: in this paper, we study a metamodel for the c++ programming language. we work out refactorings on the c++ metamodel and present the essentials as graph transformations. the refactorings are demonstrated in terms of the c++ source code and the c++ target code as well. graph transformations allow to capture refactoring details on a conceptual and easy to understand, but also very precise level. using this approach we managed to formalize two major aspects of refactorings: the structural changes and the preconditions. keywords: metamodel, c++, uml, graph transformation, ocl, refactoring 1 introduction the programming language c++ is widely used in industry today. many applications written in c++ exist which are constantly developed further, for example, to be adapted to modern service-oriented aspects. on the other hand, there is an important current trend in software engineering that focuses on development activities for using models instead of concentrating on code production only. this contribution tries to narrow the bridge between industrial, code-centric development with c++ and model-centric development employing languages like the unified modeling language (uml). we discuss a c++ metamodel and display first ideas how development and maintenance of c++ artifacts can be performed on instantiations of this c++ metamodel based on refactorings. our proposal is to express c++ refactorings and development steps as graph transformations. we think it is important to clearly express transformation concepts for an involved domain like c++ software development. graph transformations possess a sound theoretical basis and allow to express properties on a conceptual level, not only on an implementation level. surprisingly, graph transformations have not yet been applied for c++ software development. graph transformations have been applied for the transformation of metamodels, see for example the work of gogolla [gog00] (among many other works on graph transformation on metamodels). in industry, refactoring techniques [ref06b] are regarded as promising means for software development. refactoring of c++ code is supported by a variety of tools [sli06][ref06a] [xre06]. however, refactorings are usually considered from the implementation point of view only, not from a conceptual view. a conceptual view on c++ refactorings on the basis of metamodels and graph transformations allows to express properties like refactoring applicability more precise. a conceptual view also opens the possibility for viewing refactorings on the semantical level, for example, in order to describe semantics preserving refactorings or to test whether they are semantics preserving. the paper is organized as follows. the next section introduces the c++ language metamodel used in this work. section 3 discusses c++ refactorings on this metamodel in terms of graph 1 / 15 volume 3 (2006) from c++ refactorings to graph transformations transformations. section 4 gives insight to our implementation. in section 5 we mention some important contributions of this area. finally, the paper ends with a short conclusion. 2 c++ metamodel metamodels, which are also called schemas in the re-engineering community, play a very important role in the process of source code analysis. they define the central repository for the whole process, from where the facts can be reached with the help of different transformations. several researchers have been working on defining metamodels for c++ programs for reverse engineering purposes (also for program comprehension or to define an exchange format) [ekrw02], [bel00], [fsh+01]. the columbus schema for c++ [fbtg02] satisfies some important requirements of an exchange format. it reflects the low-level structure of the code, as well as higher level semantic information (e.g., semantics of types). furthermore, the structure of the metamodel and the used standard notation (uml class diagrams) make its implementation straightforward, and what is even more important, an api (application programming interface) is very simple to be realized as well. because of the high complexity of the c++ language, the metamodel is divided into six packages. to introduce all packages is beyond the scope of this paper. to clearly present our ideas we created an excerpt mainly from the struc package of the metamodel. the presented approach is not limited to this subset of the c++ language, for example templates are also supported by the metamodel. to carry out refactorings on a c++ program it is necessary to deal with preprocessor directives. although we have a separate metamodel for the preprocessor directives [vbr04], coping with them is not included to this contribution. the excerpt of the c++ metamodel can be seen in figure 1 the upper part in the figure represents the scoping structure of a c++ program. class member is the parent of all kinds of elements which may appear in a scope (we use the term “member” in a more general way than usual). in the excerpt there are three important subclasses of member. class class stands for c++ classes. it may contain further members; it may have base classes (shown by basespecifier) and friends. in c++ a friend (class or function shown by friendspecifier in the figure) can access also protected and private members of the class. the class function stands for c++ functions. it has body (represented by block) which contains any number of statements; and has parameters (class parameter). the class object represents both variables and member fields in a class. in the lower left corner there are the necessary enumerations. in the middle there are classes for type representation. like in c, in c++ types can be complex, so each language element which has a type contains a wrapper class called typerep. a typerep contains typeformers (in complex cases a type consists of many code pieces, each piece is a type-former). in the figure many type-formers are omitted, only one is shown (typeformertype) which refers directly to a type (to a class in this case). this typing structure enables to express all kinds of types and helps to avoid redundancies in storing types. in the lower right corner there are some expressions which are used in this paper (functioncall, memberselection, id). an id expression is an identifier in the code which refers to member in the metamodel this means that it may refer to both classes and class members. these are the main classes used in our example. for further details please see [fro06]. as proc. setra 2006 2 / 15 e c e a s s t ��������� ������ ��� ���� �������� � � ����� ���� �� � �������� ������ �������� ������� ������ ���� ����������� � � �� ��� � ��� � ����� � �������� � �������� � ���� � ����� � � �������� ���� ��� � � �������� ���� ��� �� !����"����# ���� � ���� � �$�%& '� ������� � ���� ��� ��� ����� � �������� � �������� ��� ���&���' ������ � � �������� � � � ������� � � ��������� � � � �� ��"����%��� ��� �(�����"����%��� ����)��(��! #� ���(��������� #� ���(��������� �*� ��������� �*� � � �������� ���� ��� ��%��������� ��+��� ��,��) �� ��,�������� ��,'� �� -��'!�� ����. ������ � � �� �� � �� �� � �"��'�� � �/���� -��'!�� ����. ������ �� �� ������� ������ �� ���� ���� ��� � � �������� �� ������� � 0 �������� ���� ��� ���� ������ ������ ��������1�!���"� ���������� ����� ����� �� ����� ���� ��� � �������� �� !����"����# �� � ���� ��%�����+ !� ��������� !��$�� !�� ���2 -��'!�� ����. ����� ����� ��� �� f igure 1: e xcerpt from the c olum bus s chem a for c + + u m l class diagram 3 / 1 5 v o lu m e 3 (2 0 0 6 ) from c++ refactorings to graph transformations usual in case of complex class diagrams, we cannot express everything using uml class diagram notations easily. for example a function body (block statement) contains ordered positioned nodes. however a parameter is also positioned but it cannot be a part of a function body. ocl expressions as constraints of the class diagram solve many similar issues. we define the following condition (boolean expression, called invariant) that must be true for all block objects: context block inv: not self.contains.oclistypeof(struc_parameter) in the following sections we use the introduced metamodel and the ocl expressions together. 3 graph transformation rules on the c++ metamodel in this section we show how refactorings on the c++ metamodel can be described with graph transformation. we provide example, which are “classical” refactorings from fowler’s catalog [ref06b]. the basic idea is simple in both cases, however many subtle details arise when realizing these refactorings. we also concentrate on c++-specific issues. 3.1 graph transformation approach, notation we use a single pushout approach for graph transformation rules possessing a left and a right hand side. instead of too complicated nacs (negative application condition) we provide preconditions as ocl expressions. the definition of directed, attributed graphs are used as usual. a program graph is directed, labelled, attributed graph where: • nodes are labelled with class names shown in the uml class diagram • nodes have attributes which are called as class attributes, the possible values of the attributes are from the corresponding uml types • edges are labelled with relation names shown in the uml class diagram program graphs are introduced using an object diagram-like notation (see figure 2). � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �� � � � � � � � � � � � � � � � � �� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � figure 2: object diagram like notation of the graph not all graphs that correspond to the definition above represent c++ programs. for example an undeclared variable may occur according to the metamodel but the belonging code could not compile. the well formedness is not checked in this paper. in reverse engineering context we assume that the starting graph is a well-formed graph and this property is preserved due to the conditions of transformations. note that c++ class attributes are modeled with class object in proc. setra 2006 4 / 15 eceasst the metamodel so the nodes representing them have label object. all object and function nodes have typerep nodes which show their c++ type. these nodes are omitted from the figures and presented only where it aids comprehension. furthermore the notation of multi-nodes is introduced to describe general subgraphs. a multi-node with value k represents k pieces of nodes of the same type. usage of multi-nodes is shown in figure 3. ��������� � ����� � ��������� � �� ���������� ��������� ��������� � ����� � ��������� � ����� � ��������� � ����� � ��������� � �� ���������� �������� ��������� � ��������� � figure 3: usage of multi-nodes 3.2 extract class classes should serve a clear, well-defined aim. during development, classes are growing. in lots of cases, there are new responsibilities added to them. the aim of this refactoring is to extract a separate concept and corresponding data to a new class to improve the quality of the design. the idea is shown in figure 4 which is taken from the refactoring catalog [ref06b]. � � � � � � � � � � ! � " # $ % � & ' ( ) ! *+ , ! $ � ) . . *+ � / & � 0 1 � ) . . *+ � " # $ % � & 2 3 4 5 6 7 � � � � � � � � � � ! � " # $ % � & ' ( ) ! *+ , ! $ � 2 3 4 5 6 7 � � � � � � � � � � ! � " # $ % � & ' ( ) . . *+ � / & � 0 1 � ) . . *+ � " # $ % � & 8 3 93 : ; 6 7 3 < = > ? 3 4 @ . . *+ � � � �� � � ! � figure 4: extract class refactoring example there is a long way from this semi-informal description to an applicable transformation. based on this figure we make decisions about the context and purpose of the refactoring. after that we formalize it as graph transformation in two steps: the first part concentrates on the structure of the rule and the second part declares conditions using ocl expressions. the main questions to be considered when realizing this refactoring as a graph transformation is: who can use the new (extracted) class and how can it be used. at first, the old class must somehow access it. if it is the only class that uses the new class then their relationship can be implemented either as the new class is a member in the old class or as a dynamic object creation 5 / 15 volume 3 (2006) from c++ refactorings to graph transformations in the constructor of the old class and as a deletion of the object in the destructor of the old class (in this case the other classes can access the new class through public interface functions of the old class). on the other hand, if the new class is free to be used by other classes then it is more complicated for example a reference counter can be used. this is related to the question: who can instantiate the new class. similarly, it has to be determined how the new class can be accessed by other classes: through the old class only or through public functions of the new class as well. another obstacle is introduced by attributes which are used externally from the old class and are now moved to the new class. we assume that the visibility enables one to access those members through a known interface only (this is not a constraint, using the c++ metamodel, all usages of an attribute can be checked). in this paper we choose to protect the newly created class. the new class can be instantiated only by the old class. its properties can be modified by the old class, furthermore the old class provides the public interface to use the new class. as refactorings can be realized in many different ways so we formalize the extract class first as a rule schema. a rule schema has parameters and multi nodes and can be instantiated in concrete cases. we call rule only these concrete cases when the rule schema has concrete arguments and can be applied directly on a program graph. the attributes and operations to be moved must be determined by analyzing their usage. therefore these are parameters of the transformation: any number of object and function nodes which are contained by the old class. the graph transformation rule schema of extractclass(... : (object—function)) is shown in figure 5. ��������� �� ���� ������� � ����������� �� ����������� � �������� �� ��� ������� � ����������� �� ���� ���� ���������� �� ������� � ������� ���� ���� �������� �� ��� ������� � ����������� �� ���� ��� ����������� ��� ������� � ����������� �� ���� ��� � ���������� �� ������� � ������� ���� ���� ���������������� ���� ������� � ������������������ ����������� ���������������� ���� ������� � ������������������ ����������� � ��������� �� ���� ������� � ������������������ ����������� ����������� ��� ������� � ������������������ ���� ���� ������� �� ����������������� ���������!����"��� ��������� �� ���� ������� � ����������� �� ����������� � ���# ��� � ���# ��� � ���# ��� � ������������� � ���� ���$� � ���# ��� ���# ��� figure 5: extract class refactoring as graph transformation on the left hand side there is the old class. its members are divided into 3 groups: attributes, public (interface) functions and protected functions. on the right hand side there are both the old class and the new (extracted) class. the selected attributes and protected functions are comproc. setra 2006 6 / 15 eceasst pletely moved to the new class. public functions are copied from the old class to the new class. the existing implementation of these functions goes to the copy in the new class. the remaining functions in the old class have a new implementation: they only have to call the copied functions in the new class. the new class cannot be accessed from outside, so the copied public functions became protected. to ensure the connection between the two classes we have a new member (object) in the old class, its type is the new class. this is represented by new typerep and typeformertype nodes. (this abstraction of types is required to represent complex types in c++ [fbtg02].) now we have to let the old class access the new one, which has protected members/functions. this is done by giving friendship grant to the old class. this is represented by the friendspecifier node. concrete rule and ocl conditions the left hand side and right hand side of a concrete rule is given in the figures below. the c++ code before the transformation with the left hand side is shown in figure 6. the graph is in fact the object model of the code, so it contains a node (nickname) which does not take part in the transformation. the resulting source code and the right hand side is shown in figure 7. class person { protected: string nickname; string officeareacode; string officenumber; public: string gettelephonenumber(); }; a b c d e f d g h i a b j j d h h k l k m kn o e b j p f q l m kj p k a r e j m p s mb h h kh t l h n g b j n e u b mh d v s mb h h a b c d e a kj p a b c d b j j d h h kl k m kn o e b j p f g i n d j n d r v w l x d j n a b c d e y d n z d md [ \ i a d ] q c l d g b j j d h h k l k m kn o e b j p f q l m kj v ^ q a j n ki a a b c d e i uu kj d t gd b s i r d b j j d h h kl k m kn o e b j p f g i n d j n d r v w l x d j n a b c d e i uu kj d ] q c l d g b j j d h h kl k m kn o e b j p f g i n d j n d r v w l x d j n v _ mi j p figure 6: extract class c++ code and model instance before the transformation class person { protected: string nickname; telephonenumber _telephonenumber; public: string gettelephonenumber(); }; class telephonenumber { protected: telephonenumber(); string officeareacode; string officenumber; string gettelephonenumber(); friend class person; }; `abc d ecfgh ` aiicggjkjljmn d aioepklji oj`q d ilorlagg jgs kgmfaim d talgc u rlagg `abc d `jio`a bc aiicggjkjljmn d aioefhmcimcq u vkwcim `abc d xclc yzh`c{pbkc f aiicggjkjljmn d aioepklji oj`q d ilorlagg jgs kgmfaim d talgc u rlagg `abc d | xclcyzh `c {pbkcf aiicggjkjljmn d aioefhmcimcq u vkwcim `abc d }cmxc lc yzh`c {pbkcf aiicggjkjljmn d aioepklji u ~p`imjh` u �lhio u xnyc �cy u xnyc ~hfbc fxn yc u ~fjc`q�ycijtjc f `abc d httjicsfca rhqc aiicggjkjljmn d aioefhmcimcq u vkwcim `abc d httjic{pbkc f aiicggjkjljmn d aioefhmcimcq u vkwcim `abc d {c� rlagg aiicggjkjljmn d aioefhmcimcq u ~p`imjh` `a bc d }cmxclcth`c {pbkcf aiicggjkjljmn d aioefhmcimcq u ~p`imjh` u �lhio u �lhio u ~p`imjh`ra ll u �q figure 7: extract class transformed c++ code and model instance 7 / 15 volume 3 (2006) from c++ refactorings to graph transformations moving function from one class to another requires careful examinations of the body. class members or functions referenced from the body may become unaccessible because of changing the class (they are ”foreign” in the new class). (note that the friendship relation is not symmetric, only the old class can reach the new class.) to prevent accessing unreachable class members we have to check the subgraph of the function body. references to class members/functions are classified based on the relation of the old class and the referenced class as follows: inside the class, class hierarchy (base classes upwards) and outer classes. bad references that prevent applying the rules are the following ones: • reference to protected/private member of the old class which is not among the parameters of the rule (if the referenced member is public it means that the extract class refactoring is not so reasonable here) • reference to protected/private member of one of the base classes (in public case the above note applies) • reference to protected/private member of an outer class which is a friend of the old class according to the metamodel a reference is an id node which has a referstoname relation to a member, especially to a function or object. the referenced member is contained by a class which is the class we are looking for. to distinguish the 3 different cases mentioned above it is not enough to search ids in the subgraph in special container nodes like memberselection or functioncall. it may happen that a member selection contains this pointer and the function call without a memberselection may reference a function in a base class. so we have to scan all ids and find the referenced class members/functions and their container classes. note that in the case of memberselection expressions the container class can be found through the left hand side child id as well. the scan can be implemented as an ocl expression. let old : struc_class = b1.hasbody.containsmember.oclastype(struc_class) in let bases : bag(struc_class) = old.hasbasespecifier.derivesfrom in let m : bag (struc_member) = b1.containspositioned->select(i | i.oclistypeof(expr_id)). oclastype(expr_id).referstomember.select(oclistypeof(struc_object) or oclistypeof(struc_function)) in m.iterate( m : struc_member; res : boolean = true | let cont : struc_class = m.contains.oclastype(struc_class) in --condition a : referenced members are in the old class but they are not -among the parameters of the transformation rule if ((m.accessibility=’protected’) or (m.accessibility=’private’) and (cont=old) and not (bag{o2,o3,f1}.exists(i | i=m)) ) then res and false else --condition b : referenced members are in the base classes if ((m.accessibility=’protected’) or (m.accessibility=’private’) and proc. setra 2006 8 / 15 eceasst (bases.exists(bc | bc=old))) then res and false else --condition c : referenced members are outer friends let friends : bag(struc_class) = old.hasfriendspecifier.grantsfriendship in if ((m.accessibility=’protected’) or (m.accessibility=’private’) and (friends.exists(fc | fc=cont))) then res and false else res endif endif endif the expression checks for wrong references in a function body b1 (argument of the expression). in case of any occurrence of a wrong reference the expression returns false and prevents the rule to be applied. this example show the expressiveness of the ocl. ocl expressions may contain searches through collections which cannot be easily formulated with simple nacs. a general subgraph notation is needed for instance to check whether a class is one of the base classes of the old class. 3.3 other refactorings there are several refactorings which can be implemented on our metamodel as graph transformations in a similar way. in this paper we give only the (detailed) case study of extract class not only because of space limitation. it contains many structural changes and also complex preconditions. in a work of eetvelde [vj05] there is a list of 15 formalized refactorings in 29 pages. papers usually demonstrate two refactorings like pull up method and encapsulate variable [mvdj05], or extract code and move method refactorings [bpt04]. we may say that presenting more of the above examples will not say more than our extract class example regarding the two important aspects of refactorings: formalization of the structural changes and the preconditions; which was the aim of the current contribution. 4 implementation the extract class refactoring graph transformation was implemented using the use (uml-based specification environment) software [use05] instead of an existing graph transformation engine. use is a system for the specification of information systems. it is based on a subset of the unified modeling language (uml). a use specification contains a textual description of a model using features found in uml class diagrams (classes, associations, etc.). expressions written in the object constraint language (ocl) are used to specify additional integrity constraints on the model. a model can be animated to validate the specification against non-formal requirements. 9 / 15 volume 3 (2006) from c++ refactorings to graph transformations the use specification of c++ metamodel contains enumerations, classes and relations corresponding to the uml class diagrams of the metamodel. every c++ program can be instantiated as an object diagram (a graph based on the specification). use can handle and display our metamodel and model instances before and after the transformation fairly well. the transformation itself can not be handled directly in the environment. the left hand side and the right hand side of the transformation is modelled in the environment, both are saved to a text file. ocl expressions (used as postconditions to modify attributes of nodes) are added to this description. the description is processed by a script1 which creates a sequence of basic graph operations from it (create/delete nodes, insert/delete edges). after the use command file of the rule is generated this way, the rule can be applied on any model in the use environment. the script (based on the description) also generates a function that can list the possible nodes on which the rule can be applied and a function which applies the transformation (see appendix a). there is a generated class (called rulecollection) in the use model which contains information and functions regarding to transformation rules. to apply the rule, one has to pass the appropriate nodes as parameters. figure 8: object diagram in use after the refactoring the result of the extract class refactoring in use can be seen in figure 8. the execution of the script was quick because the parameters determined the place of the transformation so the modifications were made locally (below 1 sec). future work is to try this implementation 1 thanks to fabian büttner proc. setra 2006 10 / 15 eceasst on real life software systems. running time of the rule-creator script (which creates basic graph operations from a rule) depends on the size of the rule. in general the most time consuming part is identification of the places where the transformation is applicable. in case of refactorings in most cases the programmer has to consider and choose a place to apply the refactoring. the decision is made based on criteria which are not easy to formalize. for instance extract class refactoring may be applicable on almost every class (which has members or functions) but only in few cases it is useful to apply. thus in a real life software the identification of the big class can be done using other visualization or analyzer tools. after we have identified the place (parameters of the rule), the actual refactoring can be applied quickly like in our example. 5 related work since the pioneering work of opdyke [opd92] there were lots of efforts made to give a formalism for refactorings. graph transformations are also considered as a basis of formalizing refactorings. our work has close connections to such approaches. a solid contribution that shows the current state of the art is given in the work of mens at al. [mvdj05]. the graph representation of a program plays an essential role in the formalism. the paper describes a language independent formalism and also introduces two major issues in detail: preconditions and behaviour preservation. we borrowed ideas of the graph formalization from eetvelde at al. [vj05] like the multi-nodes and edges. bottoni [bpt04] uses a similar formalism, the focus in that work is on the coordination of a change in different model views of the code using distributed graph transformations. these works however are not specialized towards c++ as our approach is. although there is much progress in this area, industry uses more or less the same solutions as before: language specific refactorings are implemented separately. fanta and rajlich [fr98] contribute a natural way of implementing refactorings. the paper shows the key points but this solution is somehow “out of control” without a formal base. they state that these transformations are surprisingly complex and hard to implement. two reasons they give for that are the nature of object-oriented principles and the language specific issues. we agree with this view, our work shows how to deal with c++ specific issues on meta level with the checking possibilities provided by the ocl. our work also differs from the others in that instead of the usual graph transformation engines we used a script based ocl solution of the use system. 6 conclusion this paper presents work in progress on using graph transformations to express c++ refactorings in a clear way and on a conceptual level. although graph transformations have been used for metamodel transformation of various languages, they have not been extensively used for c++. for a successful use of graph transformations, it is necessary to work on cumbersome subjects like c++ refactorings and the accompanying nasty details. we are aware of the fact that many of our concepts are already known from other successful application areas of graph transformation. future work will elaborate further c++ language refactorings. we will also improve these refactorings in a graph rewriting machine resp. modeling tool. we think that such an implementation will give insight into the application conditions and properties of c++ refactorings 11 / 15 volume 3 (2006) from c++ refactorings to graph transformations on a conceptual level. such an implementation will thus enable a deeper understanding of c++ refactorings.2 bibliography [bel00] bell canada inc. datrix – abstract semantic graph reference manual. montréal, canada, version 1.2 edition, jan. 2000. [bpt04] p. bottoni, f. parisi-presicce, g. taentzer. specifying integrated refactoring with distributed graph transformations. lecture notes in computer science. 3062:220– 235, 2004. [ekrw02] j. ebert, b. kullbach, v. riediger, a. winter. gupro generic understanding of programs. electronic notes in theoretical computer science 72(2), 2002. [fbtg02] r. ferenc, á. beszédes, m. tarkiainen, t. gyimóthy. columbus reverse engineering tool and schema for c++. in icsm 2002: proceedings of the international conference on software maintenance. pp. 172–181. ieee computer society, montreal, canada, oct. 2002. [fr98] richard fanta and vaclav rajlich. reengineering object-oriented code. in icsm 1998: proceedings of the international conference on software maintenance, page 238, ieee computer society. washington, dc, usa, 1998. [fro06] homepage of frontendart ltd. http://www.frontendart.com, 2006. [fsh+01] r. ferenc, s. e. sim, r. c. holt, r. koschke, t. gyimóthy. towards a standard schema for c/c++. in wcre 2001. pp. 49–58. ieee computer society, oct. 2001. [gog00] m. gogolla. graph transformations on the uml metamodel. in gvmt’2000. pp. 359–371. carleton scientific, waterloo, ontario, canada, 2000. [mvdj05] t. mens, n. van eetvelde, s. demeyer, d. janssens. formalizing refactorings with graph transformations. journal on software maintenance and evolution: research and practice, 2005. [opd92] w. f. opdyke. refactoring object-oriented frameworks. phd thesis, urbanachampaign, il, usa, 1992. [ref06a] homepage of ref++. http://www.refpp.com, 2006. [ref06b] refactoring catalog. http://www.refactoring.com/catalog/, 2006. [sli06] homepage of slickedit. http://www.slickedit.com/, 2006. [use05] homepage of use. http://www.db.informatik.uni-bremen.de/projects/use/, 2006. [vbr04] l. vidács, á. beszédes, f. rudolf. columbus schema for c/c++ preprocessing. in csmr 2004. pp. 75–84. ieee computer society, mar. 2004. [vj05] n. van eetvelde, d. janssens. refactorings as graph transformations. technical report, university of antwerp, february 2005. ua wis/inf 2005/04. [xre06] homepage of xrefactory. http://xref-tech.com, 2006. 2 lászló vidács acknowledges the financial support provided through the european community’s human potential programme under contract hprn-ct-2002-00275, segravis. proc. setra 2006 12 / 15 eceasst appendix a use description ----------------------------------------------------------------------extract class refactoring ---------------------------------------------------------------------rule exclass left c1:struc_class o1:struc_object o2:struc_object f1:struc_function (c1,o1): containsmember (c1,o2): containsmember (c1,f1): containsmember right c1:struc_class c2:struc_class o1:struc_object o2:struc_object no1:struc_object f1:struc_function nf1:struc_function nf2:struc_function nb1:statm_block fs:struc_friendspecifier tr:type_typerep tf:type_typeformertype (c2,o1): containsmember (c2,o2): containsmember (c2,f1): containsmember (c2,nf1): containsmember (c1,nf2): containsmember (nf2,nb1): hasbody (c1,no1): containsmember (no1,tr): objecthastyperep (tr,tf): containstypeformer (tf,c2): referstoclass (c2,fs): hasfriendspecifier (fs,c1): grantsfriendshiptoclass -postconditions [c2.name = ’telephonenumber’] [c2.accessibility = ’ackprotected’] [c2.kind = ’clkclass’] [c2.isabstract = false] [c2.isdefined = true] [nf1.name = ’telephonenumber’] [nf1.accessibility = ’ackprotected’] [f1.accessibility = ’ackprotected’] [no1.name = ’telephonenumber’] [no1.accessibility = ’ackprotected’] [nf2.name = ’gettelephonenumber’] [nf2.accessibility = ’ackpublic’] end 13 / 15 volume 3 (2006) from c++ refactorings to graph transformations ----------------------------------------------------------------------extract class refactoring -exclassgt_exclass.cmd -exclass(_c1,_o1,_o2,_f1) -the ’match’ parameter can be bound with ’!let match = ...’ ---------------------------------------------------------------------!let _c1 = match->at(1) !let _o1 = match->at(2) !let _o2 = match->at(3) !let _f1 = match->at(4) !openter rc exclass(_c1,_o1,_o2,_f1) !create _c2 : struc_class !create _no1 : struc_object !create _nf1 : struc_function !create _nf2 : struc_function !create _nb1 : statm_block !create _fs : struc_friendspecifier !create _tr : type_typerep !create _tf : type_typeformertype !insert(_c2,_o1) into containsmember !insert(_c2,_o2) into containsmember !insert(_c2,_f1) into containsmember !insert(_c2,_nf1) into containsmember !insert(_c1,_nf2) into containsmember !insert(_nf2,_nb1) into hasbody !insert(_c1,_no1) into containsmember !insert(_no1,_tr) into objecthastyperep !insert(_tr,_tf) into containstypeformer !insert(_tf,_c2) into referstoclass !insert(_c2,_fs) into hasfriendspecifier !insert(_fs,_c1) into grantsfriendshiptoclass !set _c2.name := ’telephonenumber’ !set _c2.accessibility := ’ackprotected’ !set _c2.kind := ’clkclass’ !set _c2.isabstract := false !set _c2.isdefined := true !set _nf1.name := ’telephonenumber’ !set _nf1.accessibility := ’ackprotected’ !set _f1.accessibility := ’ackprotected’ !set _no1.name := ’telephonenumber’ !set _no1.accessibility := ’ackprotected’ !set _nf2.name := ’gettelephonenumber’ !set _nf2.accessibility := ’ackpublic’ !delete(_c1,_o1) from containsmember !delete(_c1,_o2) from containsmember !delete(_c1,_f1) from containsmember !opexit proc. setra 2006 14 / 15 eceasst figure 9: class diagram of the c++ metamodel excerpt in use figure 10: object diagram in use before the refactoring 15 / 15 volume 3 (2006) introduction c++ metamodel graph transformation rules on the c++ metamodel graph transformation approach, notation extract class other refactorings implementation related work conclusion use description polymorphic protocols for fighting bots electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) polymorphic protocols for fighting bots august see 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst polymorphic protocols for fighting bots august see richard.august.see@uni-hamburg.de universität hamburg, germany abstract: web robots (bots) that automate communication with a service on the internet via their api are efficient and easy to scale. a large number of bots leads to significant losses for providers and can frustrate users of social media, games or online stores. existing solutions such as captchas or complex registrations either frustrate users or are easy to circumvent. current solutions that make it difficult to create bots are only effective for the first bot. once the first bot is created, it can be easily duplicated to build an army of bots. this paper presents an approach inspired by polymorphic malware and censorship resistance to change this. each client that communicates with a service does so by using its own application protocol that is syntactically different but not semantically. thus, a bot creator is forced to either find a way to automatically extract the whole application protocol from a client or to reverse engineer a new protocol for each bot that is created. keywords: bots, protocol obfuscation, reverse engineering 1 introduction services on the internet are more and more interconnected. they communicate and exchange data. for example, price comparison portals automatically retrieve data from a number of different third party services. for other services, like social media, or games, an automated usage is often not wanted, since this might affect the satisfaction of human users. in online dating for example, probably no one wants to chat and meet with an automated program. there are several ways to automate [asln20]. one approach is to automate the use of the user interface where a bot presses buttons or writes in text fields just like the user. this approach is inefficient because each new bot needs its own user interface. this is especially expensive for applications that run natively (desktop or mobile) and do not have a web application. when the applications can not be run in parallel even a new instance of the operating system needs to be launched. a much more efficient way is to communicate directly with the service via its api, sticking to the application protocol. here a simple script is enough. neither a user interface is needed nor a specific operating system or a browser instance. the script can simply be executed multiple times to spawn a multitude of bots e.g., for nation wide spamming and influencing voting opinions in social media [bf16]. this is why this paper focuses on automation via the api of a service. the main problem of internet services is that automation cannot be prevented, it can only be made more difficult. if a human user can use a service, it can also be automated. currently mainly captchas coupled with risk assessment approaches are used to combat bots. depending on the calculated risk that a user is a bot, a more difficult captcha to no captcha at all is 1 / 5 volume 080 (2021) mailto:richard.august.see@uni-hamburg.de polymorphic protocols for fighting bots presented [liu18]. however, the effectiveness of captchas in general decreases with the advancement in machine learning [spk16, aa20]. another method to combat bots is to make the creation as difficult as possible. this can be done by using obfuscation or anti-reverse engineering techniques. these techniques increase the cost required to create one initial bot. however they do not affect the cost required to simply duplicate the first initial bot. simultaneously, this is what makes bots so dangerous: the ability to build many bots quickly and cost-effectively. the main contribution of this paper is a novel approach that increases the labor and computational cost of duplicating a bot. this is done by using so-called polymorphic protocols which are inspired by polymorphic malware and censorship resistance. the idea is that each client that communicates with a service does so with its own application protocol. the protocol can be considered as an identifier to distinguish between clients. this effectively eliminates the convenient way to simply duplicate a bot. the duplicated bots would all share the same protocol and can therefore all be detected together and excluded from further communication with the service. this increases the cost of bot creators to create multiple different bots. bot creators must now either: 1. manually extract the respective protocol from clients again and again. ideally the effort required for this is close to the effort to build the first bot. 2. find a way to automatically extract the respective protocol from clients. it is important to note that the approach is not about making it harder to create a bot or even to make an application or service bot secure. it is a proactive obfuscation approach that restricts the cost-effective duplication of bots. interoperability between different services or legitimate bots can still be ensured e.g., by giving the creators an api key after thorough verification. the rest of the paper is structured as follows. section 2 discusses other approaches that make it harder to create bots. section 3 explains how polymorphic protocols can be created and applied, and proposes possible research questions. finally, section 4 concludes the paper. 2 related work the word polymorphism comes from biology and refers to different forms (morphs) within the population of one species [hge76]. in the field of computer science this term is often used in the area of computer malware that evades signature detection due to that each instance of the same malware is different in its form [yy10]. polymorphic protocols are mostly mentioned in literature in connection with censorship resistance and privacy [wda+15]. a similar idea to polymorphic protocols is used by the authors of [rs10] which aim to achieve less shared vulnerabilities in server replicas by transforming the code while keeping the semantic. depending on the application there are different ways to make the creation of a bot more difficult. a common way is that some sort of identification is required for interacting with the service e.g., by registering. depending on the information required for registering, this process is more or less hindering the creation of bots. a registration where only some username and password is required is less secure than a form where in addition a valid email is required, which is less secure than when a valid phone number is required or even a valid document e.g., a passport. however, a registration needs time and may disturb user experience [gn16]. furthermore, not netsys 2021 2 / 5 eceasst proctocol generator fixed secret seeddynamic identifier formal protocol specification custom protocol public private could be public or private figure 1: polymorphic protocol generation overview every user might be willing to share a phone number or even documents with some service. another way is to make the protocol itself more resilient to analysis. a common way is to encrypt and authenticate the protocol in addition to tls1. when reconstructing the protocol one does not only need to know the specification of the protocol, but also the application key(s) to encrypt and authenticate messages. those application keys are then protected, using anti-reverse engineering techniques, like obfuscation [gtg07]. however, the protection is not ideal. on a controlled device those techniques only increase the cost of the bot creator in obtaining the key but they do not prevent it. even if the key would be different and hidden in different parts for each application, at some point the key has to be used. one of these points is when a message needs to be encrypted or authenticated. there the key can be extracted automatically e.g., by using hooks. than a bot can be duplicated again without much cost. 3 polymorphic protocols the objective is to limit the cost-effective duplication of bots. this is achieved by using a socalled polymorphic protocol. the creation of one bot is as difficult as without a polymorphic protocol. however, the creation of further bots should then be similarly difficult. the main assumption is that compared to automatically extracting application keys, the extraction of a whole communication protocol is a much greater effort. this assumption is supported by literature [nsc15, nbfs06, ljlw13] but not confirmed. a polymorphic protocol could also encrypt messages. as a result the automatic extraction of such a protocol can become at least as difficult as the extraction of an application key. the challenge is to estimate how much more demanding it is. 3.1 functionality and approach the basic functionality is shown in figure 1. the protocol generator takes a formal protocol specification as well as a dynamic identifier and fixed secret seed as input, and outputs a custom protocol, i.e., bound to the dynamic identifier. the dynamic identifier can be a device id, a username or some nonce, depending on the application. the fixed secret seed is there so that if all components are public, it is not possible to create a valid custom protocol without knowing this secret seed. the formal protocol specification is needed for the protocol generator to randomize the protocol, while making sure that any mandatory semantic dependencies of messages 1 https://github.com/see-aestas/sinoalice-api, https://github.com/see-aestas/jodelapi 3 / 5 volume 080 (2021) https://github.com/see-aestas/sinoalice-api https://github.com/see-aestas/jodelapi polymorphic protocols for fighting bots are preserved. the protocol generator can randomize the order, transmission method, encoding and other features of the protocol or even inject extra dummy bytes, creating a custom protocol. the custom protocol is then merged with a client application e.g., website, smartphone app, or desktop app. this means that each client has a different protocol for communicating with the same service. a challenge for this usage is to ensure that a custom protocol can not easily be extracted from a binary, in contrast to the usage of polymorphic protocols in censorship resistance. a combination with additional encryption on the custom protocol and the use of application packers like upx2 can amplify the effort of extracting a protocol from an application. depending on the application, a custom protocol can be assigned once to each client, or the same protocol to a group, or a new protocol every other day. however, this requires significant effort in terms of computing time and transmission. 3.2 arising research questions possible research questions are: 1. how much additional cost does the use of polymorphic protocols cause for an attacker who wants to set up multiple bots for a service? 2. how much additional cost does the use of polymorphic protocols cause for a service provider and how does the approach scale? the evaluation should include a comparison with methods where only an application key is used to secure the protocol against bots. however, evaluating the first research question is challenging in some aspects. it is hard to quantify the cost of extracting a protocol (automatically) for a generic attacker who could use any method. one possibility is to examine this question argumentatively on the basis of empirical research in this area. another possibility would be to exemplarily apply different automatic protocol extraction techniques on a client with polymorphic protocol. the second question is more straightforward to evaluate. aspects such as application size, data consumption, time and resources to create a custom protocol in comparison to non-polymorphic protocol can be quantified. it is also possible to investigate which common technologies can only be used to a limited extent due to the use of polymorphic protocols e.g., cdns. 4 conclusion this paper presents an approach to make it harder to duplicate bots. it adopts the technique of syntactically modification while maintaining the semantics of polymorphic malware and censorship resistance. the basic idea of the approach is to equip each application with a syntactic different protocol. this obfuscation makes it very expensive for a bot creator to assemble an army of bots because it is either necessary to find a way which extracts the protocol automatically or to extract each protocol manually. in future work such a polymorphic protocol will be implemented and evaluated. in addition, it will be tested whether the findings can be applied to censorship resistance. 2 https://upx.github.io/ netsys 2021 4 / 5 https://upx.github.io/ eceasst bibliography [aa20] f. h. alqahtani, f. a. alsulaiman. is image-based captcha secure against attacks based on machine learning? an experimental study. computers & security 88:101635, 2020. [asln20] b. amin azad, o. starov, p. laperdrix, n. nikiforakis. web runner 2049: evaluating third-party anti-bot services. in proceedings of the 17th dimva. 2020. [bf16] a. bessi, e. ferrara. social bots distort the 2016 us presidential election online discussion. first monday 21(11-7), 2016. [gn16] r. gafni, i. nagar. captcha–security affecting user experience. iisit 13:063– 077, 2016. [gtg07] m. n. gagnon, s. taylor, a. k. ghosh. software protection through anti-debugging. ieee security & privacy 5(3):82–84, 2007. [hge76] p. w. hedrick, m. e. ginevan, e. p. ewing. genetic polymorphism in heterogeneous environments. annual review of ecology and systematics 7(1):1–32, 1976. [liu18] w. liu. introducing recaptcha v3: the new way to stop bots. https://developers. google.com/search/blog/2018/10/introducing-recaptcha-v3-new-way-to, 2018. accessed: 2021-05-20. [ljlw13] m. liu, c. jia, l. liu, z. wang. extracting sent message formats from executables using backward slicing. in 2013 fourth international conference on emerging intelligent data and web technologies. pp. 377–384. 2013. [nbfs06] j. newsome, d. brumley, j. franklin, d. song. replayer: automatic protocol replay by binary analysis. in proceedings of the 13th acm conference on computer and communications security. pp. 311–321. 2006. [nsc15] j. narayan, s. k. shukla, t. c. clancy. a survey of automatic protocol reverse engineering tools. csur 48(3):1–26, 2015. [rs10] t. roeder, f. b. schneider. proactive obfuscation. tocs 28(2):1–54, 2010. [spk16] s. sivakorn, i. polakis, a. d. keromytis. i am robot:(deep) learning to break semantic image captchas. in 2016 ieee euros&p. pp. 388–403. 2016. [wda+15] l. wang, k. p. dyer, a. akella, t. ristenpart, t. shrimpton. seeing through network-protocol obfuscation. in proceedings of the 22nd acm sigsac conference on computer and communications security. pp. 57–69. 2015. [yy10] i. you, k. yim. malware obfuscation techniques: a brief survey. in 2010 international conference on broadband, wireless computing, communication and applications. pp. 297–300. 2010. 5 / 5 volume 080 (2021) https://developers.google.com/search/blog/2018/10/introducing-recaptcha-v3-new-way-to https://developers.google.com/search/blog/2018/10/introducing-recaptcha-v3-new-way-to introduction related work polymorphic protocols functionality and approach arising research questions conclusion detecting deadlocks in formal system models with condition synchronization electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) detecting deadlocks in formal system models with condition synchronization eduard kamburjan 19 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst detecting deadlocks in formal system models with condition synchronization eduard kamburjan department of computer science, technische universität darmstadt, germany kamburjan@cs.tu-darmstadt.de abstract: we present a novel notion of deadlock for synchronization on arbitrary boolean conditions and a sound, fully automatic deadlock analysis. contrary to other approaches, our analysis aims to detect deadlocks caused by faulty system design, rather than implementation bugs. we analyze synchronization on boolean conditions on the fields of an object instead of targeting specific synchronization primitives. as usual, a deadlock is a circular dependency between multiple tasks. a task depends on a second task if the execution of this second task has a sideeffect that makes the blocking guard-condition of the first one evaluate to true. this requires an analysis of the computations in a method beyond syntactic properties and we integrate a logical validity calculus to do so. keywords: deadlock, dependency, active object 1 introduction deadlock is an essential notion of error in distributed systems and is commonly defined as a blocked configuration with circular dependencies among multiple tasks. deadlocks have been examined for different notions of dependency: resource dependencies are defined between acquire and release actions, or message dependencies, which are defined between receiving and sending actions on channels, and other notions based on other synchronization primitives. the control flow of a system design or model can be described using common synchronization primitives like locks, in most languages. the primitives reduce to one of the aforementioned dependency notions and allow to use dependency analyses for deadlock detection. systems however are rarely directly designed with concrete primitives in mind – the design makes use of the more natural and abstract synchronization patterns with synchronization on conditions, which can be compiled into more concrete synchronization primitives. condition synchronization can be expressed with, e.g., a statement await i>0, which suspends the active task until the guard i>0 becomes true. such a statement is not available in most languages, but can be seen as an abstraction to the established monitor pattern. using a condition synchronization statement is nearer to the modelers intention of when a task will resume. condition synchronization can be compiled into other synchronization patterns, e.g., monitors, but requires the addition of low-level synchronization primitives, such as condition variables and locks. performing a deadlock analysis on the compiled code is thus less helpful for the system designer, as it operates on a lower level of abstraction than his system model. we propose a formalization of dependency that fits the intuition of the system designer better than approaches 1 / 19 volume 076 (2019) mailto:kamburjan@cs.tu-darmstadt.de detecting deadlocks in formal system models with condition synchronization based on translation into low-level synchronization primitives. a task t1 depends on t2 if the continuation of t2 would make the guard b of t1 true at a point where t1 may be scheduled. this notion of dependency requires to evaluate the guard b and to analyze all side-effects of the continuation of t2. the analysis builds a dependency graph: first, for each field new dependencies are added from each read in a condition synchronization to each write. in the second step, all those edges are removed, for which we can show that the execution of the writing method will never make the guard in question true. an await statement for condition synchronization is implemented by the object-oriented abstract behavioral specification (abs) modeling language [jhs+10]. however, the available deadlock analysis tools for abs [fag13, gll16, gdj+17] do not consider such await statements. motivated by this shortcoming, we implemented our approach for abs, while the theory can be applied to other languages. our implementation extends the deadlock checker for concurrent objects (deco) tool [fag13] in the static analysis for concurrent objects (saco) toolsuite, and integrates the key-abs theorem prover [dbh15a] to discard dependencies. we evaluate our approach on industrial case studies. the precision depends on the communication structure and the complexity of required smt-theories for the types occurring in the program. while false positive potential deadlocks are detected, the analysis is precise enough to provide enough user feedback to manually discard the remaining potential deadlocks: the number of false positives in all but one case studies is small enough to check them all manually. as condition synchronization is nearer to the modelers intention when a task will resume, it allows to detect deadlocks caused by errors in the modeled system rather than errors caused by the wrong use of synchronization primitives. consider the dining philosophers: the possible deadlock is caused by an error in the modeled control flow of the system (the conditions on putting down the fork depend on the conditions on picking up a fork and vice versa). a wrong use of synchronization would, e.g., be a philosopher that never puts his fork down. our main contributions are (1) a novel notion of dependency and deadlock for condition synchronization and (2) a sound deadlock analysis for full coreabs that integrates a theorem prover into a dependency-based deadlock analysis. paper overview. section 2 introduces condition synchronization and gives examples of its usage as an abstraction for low-level synchronization primitives. section 3 introduces a simple language with condition synchronization. section 4 defines our notion of deadlock and section 5 describes our analysis for it, section 6 reports on the implementation and section 7 concludes. 2 on condition synchronization in system design our aim is to analyze the control flow of a system design to ensure that it does not include circular dependencies. for this, we concentrate on the boolean conditions on which processes may synchronize to achieve the intended control flow. we are not concerned with the usage of lowlevel primitives like locks: deadlocks caused by low-level primitives are indications of incorrect usage of the concurrency model, e.g., forgetting to unlock or unlocking twice. deadlocks caused by the boolean conditions are signs of errors in the design: the program cannot progress because its designed control flow itself contains a bug. avocs 2018 2 / 19 eceasst 1 public void m1() { 2 lock.lock(); 3 a = 1; 4 aisone.signalall(); 5 6 } 7 public void m2(){ 8 lock.lock(); 9 while(a != 1) aisone.await(); 10 a = 0; 11 lock.unlock(); 12 } 1 public void m1() { 2 lock.lock(); 3 a = 2; //bug 4 aisone.signalall(); 5 lock.unlock(); 6 } 7 public void m2(){ 8 lock.lock(); 9 while(a != 1) aisone.await(); 10 a = 0; 11 lock.unlock(); 12 } figure 1: two java snippets for monitors. the methods run in separate threads. example 1 consider the java code on the left in fig. 1. if both described methods are running in parallel in two threads on the same object, they need not progress, as m1 fails to unlock. now consider the java code on the right. again both methods may not progress — however the reason is that m2 waits for m1 to change the internal state. the first example is an implementation bug: the lock is used wrongly. the second example is a design bug: the combined control flow of m1 and m2 is designed wrongly — m2 does not continue after m1. both kinds of errors cannot be sharply distinguished — a wrong usage of synchronization primitives may also be a result of erroneous design, e.g., if unlocking twice is a consequence of the intended control flow. deadlocks caused by synchronization primitives have been studied extensively [ny16, pvb+13, cgha18, hj18, gdj+17, gll16] and focus for the most part on syntactic properties, not information in the guard. in this work we concentrate on condition synchronization. we aim to detect bugs in the design itself, helping the software architect, not the implementing programmer and use this system model: we abstract away from the low-level primitives and only consider the aforementioned await statement with a cooperative scheduling concurrency model, where every context switch is explicit. condition synchronization as abstraction to illustrate the difference between condition synchronization and synchronization via low-level primitives, we use condition synchronization as an abstraction of monitors. a monitor is a predicate associated with a condition variable and a lock. all threads waiting for the condition are notified by the condition variable once the predicate may become true. if the guard evaluates to false, the notified threads become inactive again. the java code on the left in fig. 2 shows the uses condition variables to add an element to a bounded queue once the queue is not full. here, the thread waits for the list to be below its maximal capacity. otherwise it waits on the monitor notfull until the state changes and it is notified. if it modifies the state itself, it notifies all threads waiting for the list to be not empty by calling signalall on the monitor notempty. deadlock analysis can be performed by analyzing the possible sequences of calls to the synchronization primitives lock, await and signalall [lms10], as every call to signalall causes the process to execute one more 3 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization 1 public void put(object x) { 2 lock.lock(); 3 while (count >= items.length) 4 notfull.await(); 5 //add x to queue here 6 notempty.signalall(); 7 lock.unlock(); 8 } 1 put(object x){ 2 await count < items.length; 3 //add x to queue here 4 } figure 2: a java method and its abstraction loop iteration. with condition synchronization and cooperative scheduling, we can express this method as shown on the right in fig. 2. the lock and the monitors are not part of the code, it is thus not necessary to check their correct usage already in the design: the method only switches context at the await statement and continues execution once its guard evaluates to true. condition synchronization as a modeling tool condition synchronization is not only a useful tool for modeling, it clarifies reasoning about control flow by abstracting from implementation details. e.g., in the above example the notempty and notfull monitors are not part of the code. this makes it unnecessary to ensure that the correct monitors are used. notions of deadlock for monitors based on the correct use of the involved primitives have two down-sides: first, the condition itself is not determining the dependencies – dependencies are determined by the additional structure the programmer assumes to guarantee deadlock freedom. this structure (1) leads to a large overhead, as for each condition a monitor has to be added and (2) adds another layer between the system design and the analyzed artifact. secondly, in the sketched situation in java, the waiting thread may progress, if another process was active and called signalall; as it must execute the loop to reevaluate its guard-condition. we abstract away from the reevaluation, and assume it is handled by the runtime environment – by abstracting to condition synchronization, the results are nearer to the intuition of the designer. the abs implementation of await b evaluates the guard for scheduling in the runtime environment. the guard is side-effect free, thus evaluation does not alter the state of the object and can safely be done in the scheduler. replacing condition synchronization in presence of timed behavior in abs, it is not possible to replace condition synchronization with other synchronization primitives, even if a suspend statement (with the semantics of await true) is given. as the condition has to be checked at every point the thread could be scheduled, the check must be repeated inside the method and a busy waiting translation for await g; would be the following: 1 suspend; while(!g){ suspend; } the first suspension ensures that the thread releases at leats once. this translation has a different semantics than await g; as it allows to reschedule the thread multiple times if g does not hold, thus the configuration never gets stuck, as it can always make another loop iteration. the await statement only evaluates the guard once, until the heap memory of the object is changed. avocs 2018 4 / 19 eceasst while this may be acceptable (because the guard cannot have side effects in abs), it does livelock the system if timed behavior is modeled. abs has a await duration(t,t’) statement which suspends a method for t to t’ symbolic time steps. consider the following two methods: 1 mwait(){ 2 await x == 1; 3 } 1 mset(){ 2 await (1,1); x = 1; 3 } a program running these two methods in parallel terminates. it does not terminate if await x==1 is translated into the loop above: the semantics of timed behavior is that time is only advanced if nothing else in the system can be scheduled – but as seen above the loop in mwait could always be executed once more. thus, the translated program does not terminate, because it never advances time to execute x = 1;. while condition synchronization may be compiled into monitors, monitors require low-level primitives. some concurrency models, such as the active objects of abs, where locks are handled implicitly, cannot remove condition synchronization by translating it into other synchronization primitives. 3 a language with boolean guards and dynamic logic we introduce a simple language sync with cooperative scheduling, asynchronous communication and conditional synchronization. sync is a simplified version of abs [jhs+10], following the formalization of the semantics in [fag13]. we ignore futures, which synchronize processes on termination similar to thread joins, and return values for presentation’s sake, as those dependencies have been described by flores-montoya et al. [fag13]. our implementation considers full coreabs. a sync-program is a set of objects and a main block. each object has fields and methods. all objects are running in parallel and share no state. an object may only change its active task, if the active task explicitly releases control. control can be released by termination or a special statement await b; which suspends the active task, and allows its reactivation only once the boolean expression b evaluates to true. this statement models condition synchronization within one object. between multiple objects, only asynchronous method calls of the form async x.m(e) are possible. such an statement has been introduced and examined earlier [og76]. as seen in the previous section, await can be compiled into monitors, if condition variables and locks are synchronization primitives provided by the concurrency model. definition 1 (syntax) we underspecify the sets of types and expressions. for the examples, we assume types for booleans, integers, lists and object, as well as the usual operations and literals for their elements. let e range over expressions, t over types, v over variable names, f over field names and x over object names. · denotes possibly empty lists. a program prgm is defined as follows: prgm ::= o main{s} o ::= object x {m t f = e} m ::= m(t v){s} s ::= async e.m(e) | f = e | t v = e | await e | if(e)s else s fi | skip | s;s example 2 in the following code, the object queue models a queue with maximal length of 5 5 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization and the main block pushes a number into the queue and afterwards removes it. it is not guaranteed that the push method will start to execute first. the synchronization with await, however, guarantees that it terminates first. 1 object queue{ 2 list list = nil; 3 push(int i){ await size(list) < 5; list = [i]::list;} 4 pop(){ await size(list) > 0; list = tail(list);} 5 } 6 main{ 7 async queue!push(1); 8 async queue!pop(); 9 } definition 2 (runtime syntax) d is the value domain, with {tt,ff}⊆ d. let x range over object names, i over n, s over statements, σ over functions that map variable names to domain elements and ρ over functions that map field names to domain elements. we define configurations c as follows: c ::= tsk(x,i,s,σ) | obj(x,i,ρ) | c c the composition of configurations is associative and commutative, i.e. c (c′ c′′) = (c c′) c′′ and c c′ = c′ c. well-formedness conditions can be found in [jhs+10]. a configuration contains tasks and objects. an object obj(x,i,ρ) has a unique name x, an active task id i and a store ρ . if inactive, the task id is the special symbol ⊥. a task tsk(x,i,s,σ) has a unique id i, a local store σ , the id of its object x and the remaining statement. a terminated task has the special symbol ⊥ as its statement. we denote the initial configuration of a program prgm with i(prgm). the definition is straightforward and the main block is running in a special object. we assume that each store ρ is initialized with a special field x f for each object x with ρ(x f ) = x. the method body of a method m is denoted m(m) and the initial local store of a task executing m with parameters d with m̂(d). the most important rules are shown in fig 3: the rule (wait) suspends a process by setting the task id of the corresponding object to ⊥. the await statement is not removed. the rule (cont) removes the await statement when reactivating a process – the corresponding object must be inactive and the guard must hold. the rule (call) starts a new process, which is not set as active upon creation. a configuration is terminated if all tasks and objects have the forms tsk(xi,i,⊥,σi) obj(x,⊥,ρx) a configuration is stuck, if it can not be reduced further but it is not terminated. we denote with jekσ,ρ the evaluation of e with the stores σ and ρ . we write c |= e iff jekσ,ρ = tt and the object whose store ρ is evaluated is understood. we index the reduction relation with a tuple of active tasks. a singleton tuple (i) expresses that only i is active, a tuple (i, j) expresses that i is active and launches j. this allows us to reason avocs 2018 6 / 19 eceasst tsk(x,i, await e,σ) obj(x,i,ρ) c →(i) tsk(x,i, await e,σ) obj(x,⊥,ρ) c (wait) jekσ,ρ = tt tsk(x,i, await e,σ) obj(x,⊥,ρ) c →(i) tsk(x,i,⊥,σ) obj(x,i,ρ) c (cont) jekσ,ρ = x′ j does not appear in c c = obj(x′,l,ρ′) obj(x,i,ρ) c′ tsk(x,i, async e.m(e),σ) c →(i, j) tsk(x,i,⊥,σ) tsk(x′, j,m(m),m̂(jekσ,ρ )) c (call) figure 3: selected small-step operational semantics rules about restricted behavior, i.e. c ⇒(i) c′ expresses that c′ is reachable from c only by executing the task with id i. definition 3 (run) let c1,...,cn be configurations. a run from c1 to cn is denoted c1 ⇒ cn and defined as a tuple c1,...,cn with c1 →i1 c2 →i2 ...→in−1 cn for some tuples of task-ids i1,...,in−1. we say that the run is annotated with i1,...,in−1. for simplicity, we assume that all runs are finite. using the annotated tuples, we can define rooted runs: a run rooted in a task-id i is a run which only executes task i and tasks started by task i. rooted runs allow one to reason about system behavior caused by a certain task. definition 4 (rooted runs) let the following be the graph of some tuple of tuples of task ids i = (i1,...,in): g ( i ) = ( v,e ) v ={i | id i occurs in some ik} e = { (i, j) | ∃k < n. ik = (i, j) } a tuple i is rooted in i, if g (i ′) is a tree with root i for each prefix i ′ of i . a run rooted in i, denoted c1 ⇒i cn, is a run c1,...,cn annotated with i = i1,...,in−1, such that i is rooted in i. we write c ≡ex c ′ if two configurations are equal everywhere, except for the values of fields occurring in an expression e of object x: c≡ex c ′ ⇐⇒ ∃c′′. c = c′′ obj(x,i,ρ) ∧ c′ = c′′ obj(x,i,ρ′) ∧ ∧ f 6∈fields(e) ρ(f) = ρ′(f) 3.1 dynamic logic we use a dynamic logic, called sdl based on absdl [do15] to reason about programs. sdl extends first-order logic with a modality for sync programs and allows us to reason about all possible runs of a method. we refer to [do15, dbh15a] for full formal details about absdl. 7 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization definition 6 (syntax) let v range over logical variables and f over function symbols. sdlformulas φ and terms t are defined by the following syntax: φ ::=∃ v. φ | ¬φ | φ ∨φ | [s]φ | 〈[s]〉φ | t .= t t ::= f (t) | v the modality [s]φ expresses that φ holds after the execution of s and at every suspension point within. we introduce 〈[s]〉φ below. a formula is valid if it holds in all models. the other formulas express constraints on given configurations. we assume a formalization of the heap with two function symbols store and select with the connecting axiom select(store(heap,o,f,value),o,f) . = value for every heap heap, object o, field f and value value. a modality-free formula holds in a configuration if the constraints are satisfied – select is interpreted such that select(heap,o,f) . = value) is satisfied in a configuration c if c has the form obj(x,i,ρ) c′ and ρ(f) = jvaluekρ,σ ∧ jokρ,σ = x holds. the local store σ is also modeled globally, with one special function for each local variable. we assume for simplicity that all local variables have unique names. example 3 the following formula states that if in the beginning o.f is positive, then after the execution of f = f+1; in o, o.f is strictly positive. o.f≥ 0 → [f = f+1;]o.f > 0 the full semantics and a sequent calculus for validity are presented in [do15, dbh15a]. a sequent calculus operates on sequents of the form γ ⇒ ∆, where γ,∆ are sets of sdl-formulas. contrary to [do15] we use the sequent calculus not to ensure that an invariant is preserved by a method, but only to check that the method establishes a certain post-condition at all suspension points. we only show the rule for the await statement. the following rule is taken from [do15, dbh15a] and replaces the heap by a new function symbol to erase all knowledge. afterwards, i.e., once the method continues execution, only the guard expression can be assumed. this mirrors the concurrency model, as other tasks may modify the heap during the suspension of this task and the task can only be scheduled if the guard condition holds. it also proves that the post-condition holds at each suspension point. γ ⇒ φ,∆ γ ⇒{heap := newheap}e→ [s]φ,∆ γ ⇒ [await e;s]φ,∆ (await) we require a way to verify that a property holds at all suspension points, except the first one. this is needed to verify that a method will fulfill a post-condition after being suspended at least once – it is not relevant whether the execution up to the first suspension satisfies the postcondition. thus we use a special modality 〈[s]〉φ that expresses that φ holds after the execution of s and at each suspension point in s, except the first one. we use 〈[·]〉φ to verify that a method never releases a guard φ , after it was suspended once and thus this guard does not depend on the method in question. avocs 2018 8 / 19 eceasst the calculus is the same, except that for the await statement, we use the following rule which does not check the post-condition. note that afterwards the usual modality is used. γ ⇒{heap := newheap}e→ [s]φ,∆ γ ⇒〈[await e;s]〉φ,∆ (await) the connection to the language’s sos semantics follows from the correctness of the underlying validity calculus [do15]. lemma 1 let φ be a modality-free formula which contains function symbols only for the fields of object x, 〈[s]〉φ a formula and c1 a configuration of the form c1 = tsk(x,i,s,σ) obj(x,i,ρ) c′ if the proof for 〈[s]〉φ can be closed, then for every run c1 ⇒i cn with intermediate configurations c1,c2,...,cn the following holds: at every position, except the very first, with a transition ck →(i) ck+1 such that i is active in x in ck, but not in ck+1, (i.e., these configurations execute suspension points) φ holds in ck. sketch. our system differs from the absdl calculus developed by [do15] only by the (await) rules. the semantics of [s]φ is that φ holds at all suspension points of s. in the original calculus, it also assumed φ when continuing the process, as their system proved class invariants for all methods. our rule for [·] does not assume φ after continuing execution, the formula [s]φ is thus valid if s ensures that φ holds at the continuation at all suspension points within s, independent of how the heap is changed during the suspension, but does not use information from possible invariants. the rule for (await) for the 〈[·]〉 modality differs only in the missing first premisse, which is exactly proving that φ holds at the suspension point in question. as the premisse continues symbolic execution with the normal modality, all following suspension points have to guarantee φ – only the very first suspension point does not. 4 dependencies for condition synchronization a deadlock describes a stuck configuration, where tasks circularly depend on each other. to fix the notion of deadlock, we need to fix the notion of dependency. intuitively, a stuck task t depends on a task t′ in configuration c, if the continued execution of t′ leads to a configuration where t can continue its execution. if t′ is stuck at some guard b too, then t depends on t′ if the continuation of t′ in some configuration c′ where b holds leads to a configuration where t can continue its execution. we demand that c and c′ are as similar as possible: they are equal everywhere but in the fields occurring in b, as defined in def. 5. definition 7 we formally define a predicate dep(c,i, j) which expresses that i depends on j in configuration c. the formalization is not in sdl but references sdl-formulas. to do so, we first define a family of predicates n-dep(c,i, j), to model that i depends on j with at most n enforced continuations. let c be a configuration of the form tsk(x,i, await e;si,σi) tsk(x, j,s j,σ j) obj(x,⊥,ρ) c0 9 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization the base predicate models that by executing only j, a configuration can be reached, such that e evaluates to true: 0-dep(c,i, j)≡c 6|= e∧∃c′. (c⇒ j c′∧c′ |= e) the other predicates handle the case that both i and j are blocked and j has the guard e′: and by choosing a configuration c′′ w.r.t. c′, the guard e′ evaluates to true and in this configuration i depends on j. n-dep(c,i, j)≡∃e′. ∃c′,c′′. s j = await e′;s′j ∧c 6|= e∧c 6|= e ′∧c≡e ′ x c ′ ∧c′ |= e′∧c′ 6|= e∧c′ ⇒ j c′′∧ ( c′′ |= e∨(n−1)-dep(c′′,i, j) ) task i depends on j in c, written dep(c,i, j), if some n-dep(c,i, j) holds. we can now distinguish between deadlock and starvation. definition 8 (deadlock and starvation) the dependency graph of a configuration has its task ids as nodes and its dependencies as edges. a stuck configuration is deadlocked if its dependency graph contains a dependency cycle. a configuration is starving, if it is stuck, but not deadlocked. a starving configuration requires some condition e to become true, but no task can have such an effect. sometimes an active process which tries to acquire a resource is also said to be starving, but in our framework this is abstracted to await isavailable(this.resource) — all starving processes are stuck. example 4 (deadlock and starvation) consider the program on the left in figure 4. its execution leads to the configuration tsk(x,1, await f1; f2 = true;,σ1) tsk(x,2, await f2; f1 = true;,σ2) obj(x,⊥,ρx) tsk(x0,0,⊥,σ0) obj(x0,⊥,ρx0) this configuration is deadlocked as for the dependency of task 1 on task 2 we can set x.f1 = true and for the dependency of task 2 on task 1 we can set x.f2 = true. now consider the right program is figure 4. its execution leads to c =tsk(x,1, await f1; f2 = true;,σ1) tsk(x,2, await f2; f1 = false;,σ2) obj(x,⊥,ρx) tsk(x0,0,⊥,σ0) obj(x0,⊥,ρx0) c is starving, as task 1 does not depend on task 2: no configuration can be chosen to continue task 2, so it leads to a configuration that evaluates x1.f1 to true. it is undecidable in general whether a configuration is deadlocked, as the computation of the dependency includes the computation of all effects caused by the program following a guard. program and guard are both turing-complete, thus one can define a function encoding the universal turing machine and check in the guard for some property of the output of another turing machine, which is computed/encoded in the code of another method. proposition 1 given a stuck configuration c, it is not decidable whether c is deadlocked or starving. avocs 2018 10 / 19 eceasst 1 object x{ 2 bool f1 = false; bool f2 = false; 3 m(){ await f1; f2 = true; } 4 n(){ await f2; f1 = true; } 5 } 6 main{async x.m(); async x.n();} 1 object x{ 2 bool f1 = false; bool f2 = false; 3 m(){ await f1; f2 = true; } 4 n(){ await f2; f1 = false; } 5 } 6 main{async x.m(); async x.n();} figure 4: two example programs: the left will deadlock, the right will starve. indeed even the dependency relation is undecidable. this result may appear discouraging, but the presented notion of deadlock captures the intent of the designer more precisely than notions which do no take the information flow through the heap into account and do not differentiate between deadlock and starvation. the aim of our analysis is to present clues to the designer where the intended control flow has circular dependencies. it does not aim to catch any kind of error and is not supposed to catch implementation bugs, where every erroneous state is undesirable. the aim is to catch specific logical errors in the design of the control flow. under these assumptions, undecidability is not a deal-breaker. indeed, if the notion would be decidable, it would restrict the possible guards – our aim however is to give the designer full freedom and support him with clues where it might deadlock, not guarantee complete error-freedom. similarly, it is useful to distinguish between deadlock and starvation. both notions describe erroneous states, but the reason are different design flaws. also, starvation is not always undesirable. consider the following method: 1 server(){ 2 await requestlist != nil; 3 //handle requests 4 async this.server(); 5 } here, the object buffers and handles multiple requests at once. this pattern is used in practice [kh18]. starvation is only caused by a lack of requests, not erroneous control flow. similarly, the right code in figure 1 will terminate in a starving configuration, as m1 does not depend on m2. a starvation analysis would also be useful, but is out of the scope for this work. partially deadlocked configurations processes may depend on multiple other processes, and a situation can occur where a process is deadlocked and starving at the same time: consider the following configuration: c =tsk(x,1, await x > 0&&y > 0; z = 1, /0) tsk(x,2, await z > 0; x = 1, /0) tsk(x,3, await z > 0; y = 1, /0) this configuration is deadlocked with the following dependencies 1-dep(c,1,2),1-dep(c,1,3),1-dep(c,2,1),1-dep(c,3,1) 11 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization now consider the case that process 3 is not part of the configuration: c′ =tsk(x,1, await x > 0&&y > 0; z = 1, /0) tsk(x,2, await z > 0; x = 1, /0) the configuration is still deadlocked, as it contains the dependencies 1-dep(c′,1,2),1-dep(c′,2,1) if the deadlock would be resolved for process 1 (i.e., the guard x > 0 would hold), process 1 would not progress, as the second conjunct of its guard is starving. this example shows a further point where our definition of deadlock does not coincide with the simple notion of getting stuck: we consider configurations as c′ as deadlocked, even if they contain further reasons than only dependency cycles for getting stuck. if one wants to define a notion of deadlock where dependency cycles are the only reasons for getting stuck (e.g., c above), a possible definition where to bring the guard of the process in question into cnf, derive dependency edges for every conjunct and demand that each conjunct is part of a dependency cycle. in this case c′ would be not considered as deadlocked (as y>0 is not part of any cycle). 5 analyzing condition synchronization to detect deadlocks, the abstract dependency graph is computed. the abstract dependency graph subsumes all dependency graphs of reachable stuck configurations in a program: if the dependency graph of a reachable stuck configuration has a circular dependency, then the abstract dependency graph also has one. our approach extends the one of flores-montoya et al. [fag13] and the implementation thus handles a language with condition synchronization and synchronization on futures, i.e., termination of tasks. for presentation’s sake, we only define the object-insensitive abstract dependency graph. improvements of [fag13] can still be applied, e.g., their main improvement relies on a may-happen-in-parallel analysis, which is extended for condition synchronization in [afg15]. the abstract dependency graph is defined syntactically. let p be a program. definition 9 let x1,...,xn be all objects in p and mi,1,...,mi,o the methods of xi. the abstract dependency graph a(p)=(v,e) is defined as follows: • the nodes are all methods, i.e. v = ( mi, j ) i≤n j≤o • edges connect methods with writes into a field with methods which synchronize on this field: (mi, j,mk,l) ∈ e iff there is a field f such that mi, j contains a guard with f and mk,l contains f = e or a call to a method doing so. note that a guard may contain multiple fields and that methods on different objects may depend on each other. at this point, we do not analyse here whether call or write statement are in a branch or in dead code. avocs 2018 12 / 19 eceasst example 5 consider the following code and abstract dependency graph. the nodes in the graph correspond to the guards in x.m and x.n. the edge (x.m, x.n) is by the write to field b2 in x.n and its read in the guard of x.m. 1 object x { 2 bool b1 = false; bool b2 = false; 3 m(){ b1 = true; await b2; } 4 n(){ await !b1; b2 = true; } 5 } 6 main { async x.m(); async x.n();} x.mx.n to incorporate the side-effects of computations, we make two additional steps. the first improvement aims to discards cycles because there is no reachable deadlock configuration to which they correspond. in definition 9, the whole method was checked for written fields. a cycle, however, only represents some concrete configuration where the processes hold at specific guards: every field in a deadlocked configuration must be written after some synchronization statement. definition 10 (feasibility) a cycle m1,...,mn in a(p) is feasible, if for each k < n, every write causing the edge (mk,mk+1) is after the first guard of mk+1. nonfeasible cycles contain edges that refer to heap changes of the execution of an involved method, but happen before the stuck configuration is reached: example 6 consider again example 5. the edge from x.n to x.m is added, because the field b1 is written in m and read in a guard in n. this edge is missing in all concrete dependency graphs of reachable stuck configurations, because in the stuck configurations x.m has already reached its guard and thus will not change b1. i.e., the cycle (x.n,x.m,x.n) is not feasible. we increase the accuracy further by analyzing the transmitted information and ensure that every edge is refering to a write statement which actually may release the guard. given a guard e and a method mk,l with method body s, we check that after some suspension of inside of s the guard e evaluates to true. we may ignore the first suspension, as all side effects before it cannot influence the heap afterwards. i.e., if the formula 〈[s]〉¬e is valid, then after no execution of mk,l can resolve the blocking guard and we can remove the dependency edge. definition 11 (refined abstract dependency graphs) let g = (v,e) be an abstract dependency graph. let (mi, j,mk,l) be an edge, added because of a statement await e in mi, j. let s be the body of mk,l the edge (mi, j,mk,l) is dispensable if the formula 〈[s]〉¬e holds. the refined abstract dependency graph of a program is the graph that results from removing all dispensable edges from its abstract dependency graph. the use of the 〈[·]〉 is necessary, as we only reason about stuck configurations, thus we can ignore any side effects that happen before the first guard they do not refer to information flow that may release another guard afterwards. example 7 consider the right program in figure 4. as discussed this program will starve, but deadlock. the left graph below is its abstract dependency graph, the right graph the refined 13 / 19 volume 076 (2019) detecting deadlocks in formal system models with condition synchronization abstract dependency graph: x.mx.n x.m x.n theorem 1 (soundness) if a program has a reachable deadlocked configuration, then its refined abstract dependency graph has a feasible cycle. sketch. the proof follows the soundness proof of [fag13]: if a reachable configuration is deadlocked, then it has a dependency cycle: we show that for any dependency in the configuration between two tasks t1, t2, there is a dependency between the methods m1 and m2 executed by t1 (resp. t2) in the refined abstract dependency graph. if there is a dependency between t1 and t2 (note that as the configuration is deadlock it cannot be a 0-dependency), the t2 must have a rooted run that releases the guard of t1, as we may only change the fields in the guard to do the step in the unrolling of n-dependencies for n > 0. thus t2 must change one of the fields occuring in t1, or call a method doing so. this is exactly the condition used to derive the dependecy between m1 and m2. next, we show that the edge between m1 and m2 cannot be dispensable, and the whole cycle is feasable. if it were, 〈[s]〉¬φ (where s is the statement of t2 and φ the guard of t1) would not be valid. as t2 is doing the change in the heap after being unblock once in the definition of dep(,,t,h)e statement making the change (write or call) is after the first await. thus it is safe to use 〈[·]〉 in the check for dispensability. the argument is analogous for feasable cycles. 6 evaluation we implemented our approach in the saco [aaf+14] framework for coreabs and use keyabs [dbh15a] as the theorem prover to check for dispensable edges1. existing tools did not support conditional synchronization, so only six coreabs case studies made use of this feature and we rely on micro-benchmarks to evaluate on a wider code base. case studies and microbenchmarks cover full coreabs, including loops. the implementation is fully automatic. 1 class server implements s{ 2 list wlist = nil; 3 int status = 0; 4 unit in_pool(){ 5 await status == 1; 6 wlist = 1;} 7 unit add_worker(fut f){ 8 await f?; 9 wlist = [new work()| wlist];} 10 unit run(){ 11 this!init_all(); 12 fut f = this!in_pool(); 13 this!add_worker(f) } 14 unit init_all(){ 15 status = 1; 16 await length(wlist) >= 2; 17 wlist = [new work()| wlist]; 18 status = 2; }} figure 5: an abs class modeling the internal synchronization structure of a server during initialization. the main block is omitted and the abs code is prettified. we can show that the right example in figure 4 is deadlock free. figure 5 mixes conditional synchronization and future-synchronization. the implementation can deal with deadlocks where 1 available under formbar.raillab.de/deadlock avocs 2018 14 / 19 formbar.raillab.de/deadlock eceasst some dependencies are caused by futures and some dependencies are caused by condition synchronization. this example (and, e.g., example 2) requires the application of the theorem prover to detect and discard dispensable edges: two false positive deadlock risks are found otherwise. we analyzed the two largest examples in abs, the fredhopper trading and replicate systems which model industrial software systems [dbh+15b], and found 20 deadlock risks in the trading system and 52 in the replicate system. one reason for this is that the replicate system uses deployment components [jst12] modeling cloud architecture, which are not supported by keyabs. in [afg15, fag13] the trading system was already analyzed in a setting with conditional synchronization as deadlock free. in that work, only the mhp analysis was adjusted for conditional synchronization, the deadlock analysis however was not sound and does not detect the deadlock in the left program in figure 4. we were able to manually identify all 20 deadlock risks as false postives and confirm that the trading system is deadlock free. manual post-processing is acceptable as the tool outputs the methods involved in the deadlock risk and 18 of the 20 deadlock share one edge. selected microbenchmarks (5 of 42) name loc deadlock-free time found deadlocks back_dead 39 × 8ms 1 onequeue 37 × 13ms 2 figure 5 43 x 7ms 0 transitive 52 × 10ms 1 loop 39 × 8ms 1 case studies study loc potential deadlocks time critical edges blockchain 620 0 1312ms compugene 860 1 83ms 1 memory 351 3 49ms 2 yarn 199 3 144ms 3 hyvar 632 6 200ms 2 trading 1466 20 31s 3 replicate 2101 52 5s 11 formbar 2200 timeout table 1: evaluation on selected examples we analyzed the non-trivial models for industrial architecture from hyvar [lmry17] and formbar [kh16]. additionally, we evaluated an abs model for weak memory [kh18], an abs model for resource consumption in yarn clusters [lyjl16], and the compugene model for computational biology2. the analysis returns 3 (resp. 3 and 1) potential deadlocks, which are easily manually identified as false positives. the false positives in the yarn model are again due to the use of deployment components. the analysis confirms deadlock-freedom of an abs blockchain model [nak08]. the right side of table 1 summarizes our evaluation on these case studies. the critical edge column shows how many edges needs to be removed from the graph to remove all cycles. the lower the number, the more feasible manual post-processing is. except the mentioned industrial examples, the compugene, hyvar and weak memory models, all examples are written by us. the tool was run on a intel e5-2643 with 6 cores 3,4 ghz and 64 gb ram. our analysis does not scale only for the formbar model. this has two main reasons: (1) form2 http://www.compugene.tu-darmstadt.de 15 / 19 volume 076 (2019) http://www.compugene.tu-darmstadt.de detecting deadlocks in formal system models with condition synchronization bar models communication during railway operations and contains little computation, while the other example systems are less communication-heavy. (2) formbar makes heavy use of maps and contains several guards that read 4 fields of the class and every field is written in several methods the model contains a lot of information flow through fields. maps complicate analysis, as they require to ensure that the keys are passed around correctly. such global properties cannot be derived by analyzing methods in isolation. 7 conclusion we presented an approach for deadlock detection in presence of conditional synchronization, which integrates a theorem prover to analyze side-effects. the implementation is the first sound deadlock analysis for full coreabs. we are able to analyze all abs case studies, but are not precise if models contain synchronization points that access many fields of a class: the abstract dependency graph subsumes all information flow in a program and is highly connected in those cases. this reflects the inherent difficulty of reasoning about arbitrary side-effects. discussion of the use of deductive verification our analysis integrates a heavy-weight deductive verification tool into a light-weight static analysis. this allows us to reason about heap memory beyond analyzing the field names occurring in a method, but also offers other beneficial features from a design perspective. theorem provers have a clear interface and our implementation is not monolithic: our deadlock tool benefits from any future advance in the precision or performance of key-abs. every invocation of key-abs is caused by a pair of one guard and one method. this gives us modularity of the analysis results: if method and guard are unchanged, the prover does not have to be run again. we are able to handle unbounded data types and recursion without performance loss: key-abs works on symbolic values and analyzes single methods. non-termination is handled implicitly and we do not need to provide a maximal number of unrolling for loops or similar. contrary to that, model checking would involve rerunning the whole program after each change and relies on finite domains and traces. we are still fully automatic, but we propose that in some situations it would be acceptable to interact with the theorem prover. related work to the author’s best knowledge, no deadlock analysis for condition synchronization in an object-oriented setting has been proposed. some work has been done on simpler concurrency models, e.g., owicki and gries [og76], which does not to models with an arbitrary number of threads. for active objects (without condition synchronization) the following approaches are proposed: (1) the discussed approach of flores-montoya et al. [fag13]. (2) giachino et al. [gll16] use behavioral types to detect deadlocks in abs code. contracts, descriptions of the dependency-structure of methods, are inferred and cycles are detected in their composition. for boolean guards, manual annotations are proposed, but not implementeted and no inference algorithm is given. (3) gkolfi et al. [gdj+17] use petri nets for deadlock detection and do not consider or discuss boolean guards. as described, conditional synchronization is similar to condition variables and monitors. leino et al. [lms10] presented an approach to deadlock detection of locks that generalizes to avocs 2018 16 / 19 eceasst condition variables. deadlocks are checked on a manually annotated global order for releasing and acquiring locks, receiving and sending messages over channels, and joining on threads. de carvalho-gomes et al. [cgha18] translate java programs into colored petri nets for deadlock detection. while translation into petri nets and the analysis of these petri nets are automatic, the approach requires manual annotations. recently, hamin and jacobs [hj18] presented an approach that works directly on condition variables in c code, based on symbolic execution and verified in coq. java pathfinder [pvb+13] also uses symbolic execution, but does so on low-level primitives in java bytecode. future work we aim to integrate user-provided specifications in sdl to use more information about newheap in the await rule of the sdl-calculus, at the cost of no longer being fully automatic. to automate rejection of assumed false positives, we plan to adopt the approach of albert et al. [agi16] to generate tests. we plan an incremental approach to summarize detected cycles based on critical edges. we did not discuss starvation analysis, which is also an open question. acknowledgments this work is supported by formbar, part of ag signalling/db raillab. we thank antonio flores-montoya and michael lienhardt for insightful discussions and the anonymous reviewers for valueable feedback. references [aaf+14] e. albert, p. arenas, a. flores-montoya, s. genaim, m. gómez-zamalloa, e. martin-martin, g. puebla, g. román-díez. saco: static analyzer for concurrent objects. in tacas’14, proceedings. 2014. doi:10.1007/978-3-642-54862-8_46 [afg15] e. albert, a. flores-montoya, s. genaim. may-happen-in-parallel analysis with condition synchronization. in fopara’15, proceedings. 2015. doi:10.1007/978-3-319-46559-3_1 [agi16] e. albert, m. gómez-zamalloa, m. isabel. combining static analysis and testing for deadlock detection. in ifm 2016, proceedings. pp. 409–424. 2016. doi:10.1007/978-3-319-33693-0_26 [cgha18] p. de carvalho gomes, d. gurov, m. huisman, c. artho. specification and verification of synchronization with condition variables. sci. comput. program. 163:174– 189, 2018. doi:10.1016/j.scico.2018.05.001 [dbh15a] c. c. din, r. bubel, r. hähnle. key-abs: a deductive verification tool for the concurrent modelling language abs. in felty and middeldorp (eds.), cade’15, proceedings. pp. 517–526. 2015. doi:10.1007/978-3-319-21401-6_35 17 / 19 volume 076 (2019) http://dx.doi.org/10.1007/978-3-642-54862-8_46 http://dx.doi.org/10.1007/978-3-319-46559-3_1 http://dx.doi.org/10.1007/978-3-319-33693-0_26 http://dx.doi.org/10.1016/j.scico.2018.05.001 http://dx.doi.org/10.1007/978-3-319-21401-6_35 detecting deadlocks in formal system models with condition synchronization [dbh+15b] c. c. din, r. bubel, r. hähnle, e. giachino, c. laneve, m. lienhardt. deliverable d3.2 verification of project fp7-610582 (envisage). mar. 2015. available at http://www.envisage-project.eu. [do15] c. c. din, o. owe. compositional reasoning about active objects with shared futures. formal asp. comput. 27(3):551–572, 2015. doi:10.1007/s00165-014-0322-y [fag13] a. flores-montoya, e. albert, s. genaim. may-happen-in-parallel based deadlock analysis for concurrent objects. in forte’13, proceedings. 2013. doi:10.1007/978-3-642-38592-6_19 [gdj+17] a. gkolfi, c. c. din, e. b. johnsen, m. steffen, i. c. yu. translating active objects into colored petri nets for communication analysis. in fsen’17, proceedings. lncs 10522. springer, 2017. doi:10.1007/978-3-319-68972-2_6 [gll16] e. giachino, c. laneve, m. lienhardt. a framework for deadlock detection in coreabs. software & systems modeling 15(4):1013–1048, oct 2016. doi:10.1007/s10270-014-0444-y [hj18] j. hamin, b. jacobs. deadlock-free monitors. in esop’18, proceedings. lncs 10801, pp. 415–441. springer, 2018. doi:10.1007/978-3-319-89884-1_15 [jhs+10] e. b. johnsen, r. hähnle, j. schäfer, r. schlatte, m. steffen. abs: a core language for abstract behavioral specification. in aichernig et al. (eds.), fmco’10, proceedings. pp. 142–164. 2010. doi:10.1007/978-3-642-25271-6_8 [jst12] e. b. johnsen, r. schlatte, s. l. t. tarifa. modeling resource-aware virtualized applications for the cloud in real-time abs. in aoki and taguchi (eds.), icfem’12, proceedings. pp. 71–86. 2012. doi:10.1007/978-3-642-34281-3_8 [kh16] e. kamburjan, r. hähnle. uniform modeling of railway operations. in artho and ölveczky (eds.), ftscs’16, proceedings. ccis 694. springer, 2016. doi:10.1007/978-3-319-53946-1_4 [kh18] e. kamburjan, r. hähnle. prototyping formal system models with active objects. in ice’18, proceedings. eptcs 279, pp. 52–67. 2018. doi:10.4204/eptcs.279.7 [lmry17] j.-c. lin, j. mauro, t. b. røst, i. c. yu. a model-based scalability optimization methodology for cloud applications. in 7th ieee international symposium on cloud and service computing, ieee sc2 2017. 2017. doi:10.1109/sc2.2017.32 avocs 2018 18 / 19 http://www.envisage-project.eu http://dx.doi.org/10.1007/s00165-014-0322-y http://dx.doi.org/10.1007/978-3-642-38592-6_19 http://dx.doi.org/10.1007/978-3-319-68972-2_6 http://dx.doi.org/10.1007/s10270-014-0444-y http://dx.doi.org/10.1007/978-3-319-89884-1_15 http://dx.doi.org/10.1007/978-3-642-25271-6_8 http://dx.doi.org/10.1007/978-3-642-34281-3_8 http://dx.doi.org/10.1007/978-3-319-53946-1_4 http://dx.doi.org/10.4204/eptcs.279.7 http://dx.doi.org/10.1109/sc2.2017.32 eceasst [lms10] k. r. m. leino, p. müller, j. smans. deadlock-free channels and locks. in esop’10, proceedings. pp. 407–426. 2010. doi:10.1007/978-3-642-11957-6_22 [lyjl16] j. lin, i. c. yu, e. b. johnsen, m. lee. abs-yarn: a formal framework for modeling hadoop yarn clusters. in fase’16, proceedings. lncs 9633, pp. 49– 65. springer, 2016. doi:10.1007/978-3-662-49665-7_4 [nak08] s. nakamoto. bitcoin: a peer-to-peer electronic cash system. 2008. [ny16] n. ng, n. yoshida. static deadlock detection for concurrent go by global session graph synthesis. in cc’16, proceedings. pp. 174–184. acm, 2016. doi:10.1145/2892208.2892232 [og76] s. s. owicki, d. gries. an axiomatic proof technique for parallel programs i. acta inf. 6:319–340, 1976. doi:10.1007/bf00268134 [pvb+13] c. s. pasareanu, w. visser, d. h. bushnell, j. geldenhuys, p. c. mehlitz, n. rungta. symbolic pathfinder: integrating symbolic execution with model checking for java bytecode analysis. autom. softw. eng. 20(3):391–425, 2013. doi:10.1007/s10515-013-0122-2 19 / 19 volume 076 (2019) http://dx.doi.org/10.1007/978-3-642-11957-6_22 http://dx.doi.org/10.1007/978-3-662-49665-7_4 http://dx.doi.org/10.1145/2892208.2892232 http://dx.doi.org/10.1007/bf00268134 http://dx.doi.org/10.1007/s10515-013-0122-2 introduction on condition synchronization in system design a language with boolean guards and dynamic logic dynamic logic dependencies for condition synchronization analyzing condition synchronization evaluation conclusion bandwidth performance analysis of mobile voip solutions electronic communications of the easst volume 75 (2018) 43rd international conference on current trends in theory and practice of computer science student research forum, 2017 (sofsem srf 2017) bandwidth performance analysis of mobile voip solutions rafael dantas, chris exton and andrew le gear 12 pages guest editors: anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst bandwidth performance analysis of mobile voip solutions rafael dantas1, chris exton2 and andrew le gear3 1rafael.dantas@lero.ie lero the irish software research centre university of limerick, ireland 2chris.exton@ul.ie lero the irish software research centre university of limerick, ireland 3andrew.legear@horizon-globex.ie horizon globex ireland dac nexus innovation centre, ireland abstract: despite the efforts to improve current 4g technologies by developing the new 5g mobile network, much of the world’s population still relies on older 2g and 3g infrastructures. although old hardware can be replaced, the costs of such endeavour can be prohibitive for companies operating on developing nations. network traffic optimisations can be used to provide a better experience for the increasing population of mobile devices connected. this paper provides a base comparison of the bandwidth usage between horizon globex’s smart packet voip solution (spvs) and a group of popular applications like skype, viber and whatsapp. the experiment shows spvs consumes less than 50% the amount of data when compared against the second place, whatsapp. nevertheless, more research is required to measure the impacts of the optimisations with respect to quality. keywords: voip, mobile, bandwidth, consumption, network 1 introduction as the 5g era approaches fast and the number of connected smart devices continues to increase, we find existing network infrastructures under increasing strain [cis]. this change disproportionately affects developing nations, as old hardware will be required to support the increasing demand of growing populations [cis]. while old hardware can be upgraded, and new equipment added, it can quickly become an expensive task, especially considering that most users will expect access to the internet with 3g or faster connections. with the majority of the world’s mobile user population continuing to use 2g networks [cis], network traffic optimisations can still provide benefits for mobile voice over internet protocol (voip) applications where modern mobile internet infrastructure is not available. 1 / 12 volume 75 (2018) mailto:rafael.dantas@lero.ie mailto:chris.exton@ul.ie mailto:andrew.legear@horizon-globex.ie bandwidth performance analysis of mobile voip solutions horizon globex’s smart packet voip solution (spvs) [cd15] includes an android and ios mobile application, a series of node servers responsible for broker signalling between the phones’ mobile applications, voip servers for hosting calls between mobile applications and gateways to standard telephony protocols, if necessary. it also employs a series of network and codec optimisations to allow real-time communication that is also stable, reliable and bandwidth efficient. this paper presents the results of an experiment comparing the bandwidth usage between the spvs and nine popular mobile voip applications, which suggests that the former uses less bandwidth than the other applications tested. 2 related work performance and quality comparisons between applications are commonplace in mobile voip literature [dcr+95], [zwl10], [swb01], [kc11], [ll16], [mm01], [räm10]. often the objective of these tests is to evaluate the performance of existing technologies to select the best solution for the product under development. for example, [dcr+95] performed such an analysis for selecting the best codec for the inmarsat mini-m system. similarly, [zwl10] also performed comparisons for the s3c241o micro-controller. the objective may also be to test the performance of a solution against the market standards and alternative solutions [swb01], [kc11], [ll16], [mm01], [rt11]. when compared against other codecs like amr and amr-wb, the then newly developed opus voice codec provided usable voice quality in [rt11]. to decrease the degradation of quality on voip systems caused by packet loss, [swb01] proposed a new amr codec and tested it against the usual codecs used with the h.323 protocol. a performance evaluation of skype was made by [kc11] comparing it to industry standards. to improve bandwidth utilisation on mobile networks, [ll16] tested a tcp implementation with four alternatives and found significant improvements. even classic algorithms can be subject to such tests. [mm01] tried to find which change would optimise nagle’s algorithm [nag84] for network traffic control. lastly, quality tests may also be used to propose new ideas. [räm10] used mean opinion scoring (mos) [swh16] to test if subjects could distinguish between many narrowband and wideband codecs, and found a correlation between higher scores and higher bit rates. [wd15] evaluated the 3g network infrastructure in bangkok, by testing how the mos of skype and line were affected by it. 3 the smart packet voip solution the spvs is a complete mobile voip network solution including public switched telephone network (pstn) breakout capabilities. while spvs allows two users to communicate via traditional telephony infrastructure, it also supports one or both sides to be completely disconnected from regular pstn if that user has access to the internet. figure 1 shows the basic workings of a typical voip call using spvs: • first the application contacts a central node, which will try to find the other user inside the network. sofsem srf 2017 2 / 12 eceasst • the central node will then assign a voip server for handling the call, sending this information to both participants. • both ends will try to connect with the voip server. this is done to avoid any network address translation (nat) or proxy problems that would arise otherwise. • once connected, the voip server becomes responsible for relaying the call between the participants. • if one or both the participants are not able to connect to the voip server, a session initiation protocol (sip) server will call the unreachable user using the normal telephony infrastructure. 3.1 optimisations: header elimination most protocols carry some metadata alongside the payload. this header information is used by the receiver to understand and access the information contained inside, especially in cases where the configuration parameters can be changed for each individual packet. to improve bandwidth efficiency, the spvs’ protocol doesn’t carry metadata on every single packet. instead, the developers of the solution use a series of metadata packets to coordinate the call between the devices, allowing the packet to carry only the actual encoded speech data. in a similar way to protocols, codecs also carry a series of parameters that must be sent alongside the encoded data, which will be used by the decoding process. as an example, speex parameters can be quite complex; as detailed by [tma11]. if both sides of the communication agree on the configuration parameters of the payload the header section that carries this information becomes redundant. it is then possible to reduce header size, and ultimately remove it altogether, by standardising every parameter of the transmission. the spvs uses only one codec with a very specific set of parameters, making payload headers completely obsolete and allowing every packet to carry only the compressed speech signal. figure 1: typical workflow of a spvs call. 3 / 12 volume 75 (2018) bandwidth performance analysis of mobile voip solutions even if the payload does not carry a single bit of header information, every single network protocol will envelop all data produced by the layer above and append its own headers to it. since those protocols are usually outside the scope of the application and only accessible by the os layer or lower, the changes previously proposed in this section cannot be applied here. to reduce the overhead imposed by the network protocol stack, we have used a sampling size of 100ms instead of 20ms. this change allows for a better usage of the network infrastructure, similar to the optimisations provided by nagle’s algorithm [nag84] on tcp. since more data is being sent for each packet, the overall overhead size is drastically reduced as a larger part of the information is part of the actual payload. 3.2 optimisation: silence detection in a normal conversation, usually only one of the participants is speaking while the other is listening to what is being said. if an application is not aware of this special case, it will always record and send speech information both ways. using silence detection algorithms, it is possible to avoid sending useless data through the wire. the spvs has a special silence packet, which is sent by the application whenever it detects its user has gone silent. this packet also doubles as a keep-alive message, being sent periodically by the silent side to maintain the connection open. 3.3 optimisation: codec selection as a freely available open source voice codec, speex was selected to be integrated into horizon globex’s solution. it also provides good results when compared with other narrowband voice codecs like amr and ilbc [räm10] [tma11] [kc11]. speex has many compression levels that decrease speech fidelity in order to decrease the overall size of the stream. this value ranges between 0 and 10, the former being the on with the highest compression but lowest quality while the latter is the exact opposite. horizon’s developers decided to use compression level 3, since they have found that any higher setting does not provide improvement of the perceived speech quality through the phone speaker. 3.4 optimisations: transport protocol selection there are two main protocols that operate over the internet protocol, version 4 (ipv4) [pos81a]: 1. the user datagram protocol (udp) [pos80] is a very simple protocol, designed to provide a minimalistic mechanism for message exchange on an ip network. with simplicity as its main feature, a datagram has only 8 bytes of metadata. the error checking algorithm guarantees that every message received was not corrupted along the way but, since there is no error recovery built into the protocol, not all messages sent will arrive at their destination. 2. another protocol is the transmission control protocol (tcp) [pos81b]. it was built for reliable communication between two computers inside the same network or between two sofsem srf 2017 4 / 12 eceasst networks. to provide such reliability, the header is much bulkier than its simpler counterpart, containing at least 24 bytes of metadata. although this feature is very important for all sorts of applications, its retransmission routines are usually more harmful to real-time applications like voip than the lost data they were designed to retrieve. due to its simplicity and smaller footprint, udp was chosen as the best option as a transport layer protocol. 4 evaluation section 4.1 will analyse the network performance of the spvs, described in section 3, against the other solutions to test the assertions made in section 1. for this experiment, we have selected some of the most commonly used applications in the western market, namely “facebook messenger”, hangouts, line, skype, telegram, viber and whatsapp. we have also selected two popular chinese applications to represent that market, namely qq and wechat. table 1 presents the number of installed devices for all aforementioned applications. the numbers for all applications except wechat and qq were taken from google’s play store, in 01/03/2017. since wechat and qq’s mainly operate on the chinese market, their numbers were taken from huawei’s application store. lastly, hangouts’ numbers might not reflect its actual popularity since android devices usually come with it installed by default. 4.1 experimental design this experiment was designed to provide quantitative data for the analysis in section 4.3. we used two android mobile phone where the tested application was installed with two gnu/linux laptops acting as access points for both mobile phones and an earphone to reproduce a half minute-long audio file through both devices’ microphones. figure 2 is an illustration of this experiment. to properly intercept all data going through the internet, both phones were connected to it via application installations wechat 2,344,124,542 qq 2,004,169,512 messenger 1,000,000,000 hangouts 1,000,000,000 whatsapp 1,000,000,000 line 500,000,000 skype 500,000,000 viber 500,000,000 telegram 100,000,000 table 1: number of installations per application. 5 / 12 volume 75 (2018) bandwidth performance analysis of mobile voip solutions the wireless access points provided by both laptops, which were connected to the internet via two independent ethernet cables. using a personalised command-line interface (cli) described in section 4.2 to schedule 40 test executions for each application described in section 1. this cli was responsible for synchronising the actions of both computers during each test. all tests performed followed these steps: 1. all tests are queued on the console, grouped by application. 2. using a “next” command, the terminal loads the next test and waits for a user input. this input signals that both phones are connected in a call and ready for the audio playback. 3. once the “enter” key is pressed, “tcpdump” is invoked as a background process, to record all network activity necessary for data collection. 4. immediately after the previous step, the tool plays a half-minute-long audio file. this file contains phrases that alternate between the left and right channels to simulate a conversation with moments of activity and silence. 5. both sides wait until the audio reproduction is complete. then the terminal signals “tcpdump” to stop recording the network. 6. a counter is incremented to signals the completion of this test and the interface waits for a new “next” command or another user interaction. all data collected by tcpdump was filtered using wireshark, a network packet capture tool, which can read the format used by tcpdump and output the desired fields into the console, for further analysis. since all data going through the laptop was recorded into files, the most accessed ip address for that call was used to filter the data. figure 2: representation of the experiment. sofsem srf 2017 6 / 12 eceasst application wire throughput (kb/s) payload throughput (kb/s) packet rate (p/s) frame size (bytes) payload size (bytes) payload-to-header ratio horizon 8.24 5.90 7.97 130 93 2.52 whatsapp 23.59 17.44 22.23 133 99 2.83 qq 28.64 20.07 31.08 116 81 2.34 facebook 29.23 24.02 16.76 219 180 4.61 viber 40.66 28.22 45.02 113 79 2.27 wechat 44.85 35.83 33.13 170 136 3.98 telegram 48.22 40.40 27.71 218 183 5.17 line 53.82 42.21 42.33 159 125 3.64 hangouts 59.06 32.35 50.80 146 80 1.21 skype 84.54 61.69 83.98 126 92 2.70 table 2: comparison between various applications performances the following section details the tools used for the experiment. 4.2 tool support a personalised command-line interface was created to coordinate both laptops in all the tasks they were performing. this interface is able to connect the computers, interface with local network configuration by invoking “tcpdump” [jlm89] and “tc” [kuz01], and it’s also capable of rolling back a test if needed. “tc” [kuz01] is a tool created to configure traffic control inside the linux kernel. it is used for defining rules for incoming and outgoing packets on a device. this tool has many extensions, so called queuing disciplines or “qdiscs”, which are queues used to save packets while the network interface isn’t ready to handle them. all data was collected using “tcpdump” [jlm89], a tool for inspecting all traffic on a network and storing all data onto a file. the output format is widely supported by many tools. two bash scripts were written for the filtering of data after its collection. these filters use “tshark” [com12] to filter the pcap files created by “tcpdump”.1. the audio sample was reproduced using “mplayer” [tea05], a command-line interface player which was called by the script before changing the network properties. for data analysis, “tshark” [com12] and “wireshark” [c+07] were selected for filtering the results, removing unrelated network traffic and for selecting only the fields necessary for the analysis. in this experiment, every call happened after “tc” was used to create a new class. this class was configured to limit the bit rate to 100kbps, ensuring the application would use a narrowband codec and giving the previously mentioned terminal some band to run commands without interfering with the experiment. 4.3 quantitative analysis: bandwidth usage table 2 has a comparison between all applications analysed as part of our evaluation. • “wire throughput” and “payload throughput” are averages of the data rate sent to the network. the former’s numbers include the network overhead produced by all protocols in 1 these scripts, along with set up advice, are available from the authors on request. 7 / 12 volume 75 (2018) bandwidth performance analysis of mobile voip solutions the network stack while the latter’s numbers only include the data carried by the transport layer. smaller numbers represent smaller data consumption and cheaper calls. • “packet rate” is the average number of packets sent per second. applications with smaller values for this column might be less demanding on the network infrastructure while higher values may imply higher tolerance to individual packet losses. • “frame size” and “payload size” are the average sizes of the individual packets sent by each solution. the former includes the size of the network overhead while the latter does not. although higher numbers may imply higher network usage, this number only has true meaning when used together with packet rate. • “payload-to-header ratios” are simple ratios between the payload sizes and the average network overhead size, which is the frame size minus the payload size. smaller rations imply higher amount of data wasted on network headers. the solutions were presented in ascending order by wire throughput, this is the values that most closely relates to the cost of the calls made by each solution. when compared against the second closest solution in the first three categories, the spvs uses, in average, 65%, 66% and 52% respectively less resources. the results are striking using less than half the bandwidth than the second closest solution, whatsapp. the spvs has a network performance lead in this experiment. viber had the best results on both frame size and payload size. these numbers alongside a higher packet rate than the average of the other applications suggest they may be using a buffer size smaller than the other solutions. lastly, in the payload-to-header ratio column, telegram has the best payload-to-header ratio. they also have one of the biggest payload size, which naturally dwarfs the size of the header and inflates this ratio. 5 discussion the spvs shows the best results with respect to the amount of data sent through the network, using at worst half as much data as the second closest application but on average 80% less throughput than other applications. table 3 shows the average cost per second of a call using each solution tested here. to calculate the correct cost, we have assumed an approximate 0.10 usd/mb, the standard rate for intertelecom company gsm data, since a precise figure would vary between contract agreements between the solution’s developer and its internet service provider. although both qq and wechat performed well on their respective runs of this experiment, the sound received by the callee was of very poor quality. for all other applications, the voice message was adequate and understandable in its entirety. skype had the best payload-to-header ratio, but that was because the payload carried by each packet was also larger in comparison to the size of the header. since the only poor network condition tested was packet loss, most solutions probably could not trigger changes in protocol. sofsem srf 2017 8 / 12 eceasst application wire throughput (kb/s) cost (usd cents/s) horizon 8.24 0.08 whatsapp 23.59 0.23 qq 28.64 0.28 facebook 29.23 0.29 viber 40.66 0.40 wechat 44.85 0.44 telegram 48.22 0.47 line 53.82 0.53 hangouts 59.06 0.58 skype 84.54 0.83 table 3: average approximate cost of a call (assuming 10cent/s cost) it is also surprising that most of the tested solutions were using tcp as their transport protocol instead of udp, which would be the more sensible choice for real time applications like mobile voip, given the reasons discussed in section 3.4. we believe the authors of the solutions using tcp over udp believe that modern day internet connections are stable enough that the extra cost of developing for the latter protocol might not be justifiable. tcp already has concepts that are useful to voice calls like session and packet ordering that would need to be implemented by the application when using udp. 6 threats to validity network fluctuations could affect the results of this experiment, making one solution appear better or worse than it would have been otherwise. traffic shaping rules could also affect the numbers in a similar fashion. to minimise the effects of this threat, the experiments were run 40 times for the same application. a better separation between inbound and outbound traffic could also be more useful for analysis than the total amount of data exchanged between both sides of the call. finally, network performance isn’t the only important measure for a mobile voip solution the perceived quality of the audio must also be maintained. the experimenter listened to the transmitted audio for each data point and confirmed that quality audio was being maintained, but we feel that although these initial tests provide some bases for comparison, we intend to further investigate these results using a mos test in the next phase of our research. 7 future work the next step in this research is to develop a more comprehensive experiment for both assertions in section 1, which will record both how much data is being sent through the network and how much of it is getting to the other side of the call. this will require data from both cell phones to be recorded. 9 / 12 volume 75 (2018) bandwidth performance analysis of mobile voip solutions bandwidth savings are irrelevant if the overall quality of the audio sample has been degraded. therefore, another important step is to properly measure how much has this property been affected by the optimisations and how spvs’s audio quality compares against the other solutions using a mos assessment. finally, we intend to analyse ways to improve the current protocol. ideas for future refinements include: • a dictionary that will store common patterns produced by the codec to further compress the information being transmitted, • a permanent personal audio profile to improve codec compression when talking with the same person more than once. 8 conclusion although the spvs showed very promising results in this experiment, a more detailed experiment will provide us with better data regarding current mobile voip solutions, especially with respect to quality. 9 acknowledgements this work was supported with the financial support of the science foundation ireland grant 13/rc/2094 and co-funded under the european regional development fund through the southern & eastern regional operational programme to lero the irish software research centre (www.lero.ie). this work was possible thanks to brian collins, ceo of the horizon globex ireland dac, for permitting technical analysis of the product. (sow2016-034) bibliography [c+07] g. combs et al. wireshark. web page: http://www. wireshark. org/last modified, pp. 12–02, 2007. [cd15] b. collins, c. dziedzic. method and devices for routing in a satellite-based communication system. sept. 15 2015. us patent 9,137,729. [cis] c. v. n. i. cisco. global mobile data traffic forecast update, 2015–2020 white paper, 2016. [com12] g. combs. tshark-dump and analyze network traffic. wireshark, 2012. [dcr+95] s. dimolitsas, f. corcoran, c. ravishankar, a. wong, s. de campos neto, r. skaland. evaluation of voice codec performance for the inmarsat mini-m system. in digital satellite communications, 1995., tenth international conference on. pp. 101–105. 1995. sofsem srf 2017 10 / 12 eceasst [jlm89] v. jacobson, c. leres, s. mccanne. the tcpdump manual page. lawrence berkeley laboratory, berkeley, ca 143, 1989. [kc11] k. kim, y.-j. choi. performance comparison of various voip codecs in wireless environments. in proceedings of the 5th international conference on ubiquitous information management and communication. p. 89. 2011. [kuz01] kuznetsov, a. tc. 12 2001. [ll16] k. liu, j. y. lee. on improving tcp performance over mobile data networks. ieee transactions on mobile computing 15(10):2522–2536, 2016. [mm01] j. c. mogul, g. minshall. rethinking the tcp nagle algorithm. acm sigcomm computer communication review 31(1):6–20, 2001. [nag84] j. nagle. congestion control in ip/tcp internetworks. technical report, internet engineering task force (ietf), 1984. [pos80] j. postel. user datagram protocol. technical report, internet engineering task force (ietf), 1980. [pos81a] j. postel. internet protocol. technical report, internet engineering task force (ietf), 1981. [pos81b] j. postel. transmission control protocol. technical report, internet engineering task force (ietf), 1981. [räm10] a. rämö. voice quality evaluation of various codecs. in acoustics speech and signal processing (icassp), 2010 ieee international conference on. pp. 4662–4665. 2010. [rt11] a. rämö, h. toukomaa. voice quality characterization of ietf opus codec. in interspeech. pp. 2541–2544. 2011. [swb01] j. w. seo, s. j. woo, k. s. bae. study on the application of an amr speech codec to voip. in acoustics, speech, and signal processing, 2001. proceedings.(icassp’01). 2001 ieee international conference on. volume 3, pp. 1373–1376. 2001. [swh16] r. c. streijl, s. winkler, d. s. hands. mean opinion score (mos) revisited: methods and applications, limitations and alternatives. multimedia systems 22(2):213–227, 2016. [tea05] m. team. mplayer–the movie player. http:/www. mplayer. hq. hu, 2005. [tma11] e. touloupis, a. meliones, s. apostolacos. implementation and evaluation of a voice codec for zigbee. in computers and communications (iscc), 2011 ieee symposium on. pp. 341–347. 2011. 11 / 12 volume 75 (2018) bandwidth performance analysis of mobile voip solutions [wd15] p. wuttidittachotti, t. daengsi. quality evaluation of mobile networks using voip applications: a case study with skype and line based-on stationary tests in bangkok. international journal of computer network and information security (ijcnis) 7(12):28, 2015. [zwl10] j. zhou, t. wu, j. leng. research on voice codec algorithms of sip phone based on embedded system. in wireless communications, networking and information security (wcnis), 2010 ieee international conference on. pp. 183–187. 2010. sofsem srf 2017 12 / 12 introduction related work the smart packet voip solution optimisations: header elimination optimisation: silence detection optimisation: codec selection optimisations: transport protocol selection evaluation experimental design tool support quantitative analysis: bandwidth usage discussion threats to validity future work conclusion acknowledgements towards self-evolving context-aware services electronic communications of the easst volume 11 (2008) proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) towards self-evolving context-aware services m. autili, p. di benedetto, p. inverardi and d. a. tamburri 12 pages guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards self-evolving context-aware services m. autili1, p. di benedetto2, p. inverardi3 and d. a. tamburri4 1 marco.autili@di.univaq.it, 2 paolo.dibenedetto@di.univaq.it, 3 inverard@di.univaq.it, 4 damien.tamburri@di.univaq.it università dell’aquila dipartimento di informatica, italy abstract: the introduction of new communication infrastructures such as beyond 3rd generation (b3g) and the widespread usage of small computing devices are rapidly changing the way we use and interact with technology to perform everyday tasks. ubiquitous networking empowered by b3g networking makes it possible for mobile users to access networked software services across continuously changing heterogeneous infrastructures by resource-constrained devices. heterogeneity and devices’ limitedness, create serious problems for the development and dynamic deployment of mobile applications that are able to run properly on the execution context and consume services matching with the users’ expectations. furthermore, the everchanging b3g environment calls for applications that self-evolve according to context changes. out of these problems, self-evolving adaptable applications are increasingly emerging in the software community. in this paper we describe how chameleon, a declarative framework for tailoring adaptable applications, is being used for tackling adaptation and self-evolution within the ist plastic project. keywords: context-awareness, self-evolution, adaptation mechanisms 1 introduction the widespread usage of small computing devices and the introduction of new communication infrastructures are rapidly changing the ways we use and interact with technology to perform everyday tasks. today’s networking infrastructures are typically made of mobile resourceconstrained devices, characterized by their heterogeneity and limitedness: e.g., ubiquitous networking, empowered by b3g networks, makes it possible for mobile users to access networked software services across heterogeneous infrastructures through resource-constrained devices. mobility, inducing changes to the execution and network environments (and therefore changes to the availability of resources), demands for self-evolving applications capable of coping with resource scarcity and with the inherently faulty and heterogeneous nature of such environments. in this paper we describe how chameleon, a declarative framework for tailoring adaptable applications for resource-constrained devices, is being used for tackling a form of self-evolution and adaptation within the ist plastic project whose goal is the agile development/deployment of context-aware/self-adapting services for b3g networks. plastic introduces the notion of requested service level specification (sls) and offered sls to deal with the (extra-functional) preferences that will be used to establish the service level agreement (sla) between the service consumer and the service provider. 1 / 12 volume 11 (2008) mailto:marco.autili@di.univaq.it mailto:paolo.dibenedetto@di.univaq.it mailto:inverard@di.univaq.it mailto:damien.tamburri@di.univaq.it towards self-evolving context-aware services for the heterogeneous and ever-changing b3g environment, we propose a chameleonbased plastic solution to address self-evolution of j2me midlet applications by presenting: • a programming model that allows for easily specifying, in a flexible and declarative way, different adaptation alternatives for java applications. the model is based on an agile and userfriendly extension of the java language; • a mechanism that, based on the over-the-air (ota) provisioning technique [ota], allows for dynamic deployment, un-deployment, and re-deployment of different alternatives of mobile (client) applications able to (i) run properly on the execution context and (ii) consume services matching with the users’ expectations. the mechanism will require the ability to reason, on applications and environments alike, in terms of the resources they need and offer, respectively (i.e., resource supply and resource demand), as well as the ability to suitably adapt the application to the environment that will host it while meeting the requested sls; • a mechanism that, providing j2me midlet applications with ad-hoc methods for saving and restoring the (current) application state, enables applications’ evolution (against monitored context changes and according to adaptation policies) by dynamically un-deploying the no longer apt application alternative and subsequently (re-)deploying a new one with the desired aptitude. chameleon, whose foundations are presented in [imn04, mi07], is based on a static analysis approach to the inspection of java programs and their characterization w.r.t. their resource consumption in a given execution environment. explicitly targeting resource-constrained devices, we implemented and instantiated all the needed machinery on the java platform due to its widespread availability on today’s mobile devices (e.g., smart phones, pdas, etc.). the approach uses a light extension of the java language, a resource model, and an sls model that constitute the basis for a declarative technique that supports the development, deployment, and evolution of adaptable applications. by leveraging this approach we are able to perform a quantitative resource-oriented analysis of java applications, further accounting for the user preferences specified through sls model. in the context of such applications, our framework allows for evolution by uniting un-deployment to dynamic re-deployment of appropriate adaptation alternatives. the paper is structured as follows: section 2 sets the “context” and section 3 introduces the plastic development process model. section 4 gives an overview of the chameleon framework. a running example will be presented all throughout the evolution of the paper until section 5 where a simple usage scenario is described. related work is briefly discussed in section 6 and concluding remarks as well as future directions are given in section 7. 2 setting the “context” context awareness and adaptation have become two key aspects to be considered while developing applications for b3g networks. as pointed out in [beii06], while providing/consuming services, applications need to be aware of and adaptive to their context, i.e., the combination of user-centric data (e.g., information of interest for users according to their current circumstance) and resource/computer-centric data (e.g., resource limits and conditions of devices and network). strictly concerning our own purposes, context awareness identifies the capability of being aware of the user needs and of the resources offered by an execution environment (e.g., processor, memory, display, i/o capabilities, available radio interfaces), in order to decide whether that environment is suited to receive and execute the application in such a way that end-users expectations are satisfied. adaptation identifies the capability of changing the application in order to proc. campus 2008 2 / 12 eceasst comply with the current context conditions. in order to perform an adaptation it is essential to provide an actual way to model the characteristics of the application itself, of the heterogeneous networking infrastructure, and of the execution environment, aiming at a high end-user degree of satisfaction (depending on requested and offered sls). thus, while delivering services, it is useful to be able to reason about the resources demanded by an application (and its possible adaptation alternatives) and the ones supplied by the hosting environment. it is worth to note that although a change of context is measured in quantitative terms, i.e., in terms of availability of resources, an application can only be adapted by changing its behavior i.e., its functional/qualitative specification. in this setting, three different construction approaches towards adaptable applications might be considered: (i) self-contained applications that embed the adaptation logic as a part of the application itself and, therefore, are a-priori instructed on how to handle dynamic changes in the environment hence reacting to them at runtime; (ii) tailored applications that are the result of an adaptation process which has been previously applied on a generic version of the application; (iii) middleware-based adaptable applications in which the middleware embeds the adaptation logic in the form of meta-level information on how the applications can be adapted. self-contained adaptable applications are inherently dynamic in their nature but suffer the pay-off of the inevitable overhead imposed by the adaptation logic. on the contrary, tailored adapted applications have a lighter code that make them suitable also for limited devices, but are dynamic only with respect to the environment at deployment time, while remaining static with respect to the actual execution, i.e., they cannot self-adapt to runtime changes in the execution environment. considering the huge variety and limitedness of our target devices, and the complexity of b3g networks would make unfeasible the deployment of a fully self-adaptive application (i.e., a potentially huge-sized self-contained application) suitable for any resulting execution environment and possible context in which the user can move. the framework chameleon is for tailored applications. in this paper we propose how it can be used for tackling self-evolution (against context changes monitored through chameleon as supported by the plastic b3g middleware) through dynamic (re)deployment of adaptation alternatives and finally, in section 7, we argue how, by means of (physical) mobility patterns [mm07], it can be extended towards a compromise between self-contained and tailored service applications aiming at a more seamless self-evolution. 3 developing context-aware services in this section we briefly introduce the plastic development process model, that relies on the plastic conceptual model, by only focussing on specific details pertaining the chameleonbased approach to self-evolution we are going to present in following sections. for a complete description (text and diagrams) of the conceptual model and for a detailed instantiation of the plastic development process model we entirely refer to [plab] and [abc+07, plac], respectively. the conceptual model will be textually described by emphasizing words that identify conceptual model entities. the conceptual model is a reference model formalizing the needed concepts to realize serviceoriented b3g applications. the central entity here is service abstract archetypical notion of a real world service. in the context of b3g networking, we specifically focus on services concretized by adaptive software services, which are deployed and accessed in the specific network 3 / 12 volume 11 (2008) towards self-evolving context-aware services of interest. implemented by context adaptable software components, adaptive software services allow service consumer parties to access needed services anywhere over the b3g network, from any device, as provisioned by service provider parties. in the light of our goal, an adaptive software service might be provided/consumed by chameleon-based adaptable applications that are consequently able to run on resource-constrained plastic-enabled devices. a key feature of services for b3g networks is context-aware adaptation according to consumerside, network-side and provider-side contexts of service consumption. these various contexts of service consumption impact upon the qos of the service, also decomposing into consumerside, network-side and provider-side qoss. in particular, services may guarantee qos properties in a given context, possibly leading to service adaptation in broader contexts. on one side, network-side context identifies the characteristics of the (multiple) network(s) between consumer and provider such as number and type of networks, number of active users, number of available services, security, transmission protocol, access policy, etc. this is of particular relevance, since the network context impacts upon the qos represented by network-side qos (e.g., bitrate, transfer delay, packet-loss, network coverage). on the other side, considering the mobile nature of a plastic application deployed over heterogeneous plastic-enabled devices, the providerand consumer-side contexts model device characteristics in terms of available resources (e.g., screen resolution, cpu frequency, memory size, available radio interfaces). figure 1: plastic development process in our setting, overall contextual information is retrieved by chameleon exploiting the plastic b3g middleware. the middleware provides runtime support for the deployment and access/consuption of services and is the key to ease the management of b3g networking. exploitation of this specific middleware then relies upon the use of dedicated software components, i.e., consumer-side, bridge-side and provider-side middlewares, deployed on the service’s consumer, bridge and provider, respectively. the role of bridge is introduced in addition to the canonical roles for soa, i.e., consumer and provider. more specifically, bridges are those (plastic-enabled) devices which deploy and run the bridge-side middleware component and act as mediators. they are in charge of routing communication among independent networks making up b3g. introducing the notion of requested service level specification (sls) and offered sls, plastic considers the (extra-functional) preferences that will be used to establish the service level agreement (sla) between consumer and provider. the sla is an entity modeling the conditions on the qos accepted by both consumer and provider. sla represents a kind of contract that is influenced by the requested sls and the context where the service has to be provided/consumed. when a new service request is formulated, the plastic platform has to (possibly) negotiate the qos and upkeep it (possibly) through self-evolution. this contractual procedure may terminate either with or without a qos agreement between consumer and provider. with reference to figure 1, the service and the relative (potential) client models are specified proc. campus 2008 4 / 12 eceasst in terms of their functionalities and sls (possibly along with demanded/supplied resources). model-to-model transformation is performed in order to derive models for different kinds of analysis (e.g., for defining/estimating/refining slss). some models (not necessarily different from the previous ones) will be made available at deploymentand run-time to allow the adaptation of the service to the execution context, based on data retrieved by run-time analysis/monitoring and evolution policies (see the box “self-evolving/adaptive service” shown in figure 1). the sls will drive the adaptation strategies through model-to-code transformation (right-hand side of figure 1) that is used to build both the core and the adaptive code of the application. the core code is the frozen portion of the developed self-evolving/adaptive service and represents its invariant semantics. the adaptive one is a “generic code”. a generic code embodies a set of (preemptively envisioned) adaptation alternatives that will make the code capable of evolving. this code portion allows for evolution in the sense that, from contextual information and possible changes of the user needs, a currently deployed alternative that is no longer apt can be dynamically un-deployed and a new one with the desired aptitude subsequently (re-)deployed. in fact, a particular alternative might be suitable for a particular execution context and specified user needs. during service consumption, run-time analysis, monitoring and evolution policies selection are performed and, basing on the results, a new alternative might be selected. the generic code is written by using the extended java within the development environment while the alternatives’ selection is carried out through the customizer, both part of the chameleon framework we are about to introduce. 4 the chameleon framework chameleon allows the development and deployment of java applications that, via the envisioned adaptation alternatives, are generic and can be correctly adapted with respect to a dynamically provided context. figure 2 shows the components of the framework architecture. figure 2: chameleon architecture . development environment. the development environment is a standard java development environment that provides developers with a set of ad-hoc extensions to java for easily specifying, in a flexible and declarative way, the generic code. methods are the smallest building blocks that can be adapted. figure 3 shows a snippet of an adaptable midlet for consuming an e-learning service that promotes effective student/professor cooperation, providing a set of flexible tools that aid the work of online learning communities. the adaptable class e-learningmidlet contains four adaptable methods: connect, getlesson, savestate and restorestate (bearing the keyword adaptable). adaptable methods do not have a definition in the adaptable class where they are declared but they are defined within adaptation alternatives (see the keywords alternative and adapts). it is possible to specify more than one alternative for a given adaptable class provided that for each adaptable method there exists at least one alternative that contains a definition 5 / 12 volume 11 (2008) towards self-evolving context-aware services for it. such a generic code will be preprocessed and a set of standard java application alternatives will be derived by suitably combining the adaptable methods implementations provided in the various alternatives. these are then compiled using standard java compilers. the chameleon framework is used to adapt the e-learning service according to the executionand network-context of the student device and to his/her requested sls. in particular, the adaptable e-learningmidlet has two alternatives, each one providing implementation for all the adaptable methods. the gprs alternative connects via gprs and, considering the limited speed of this connection, allows for streaming (via the getlesson method) the lesson slides only. the wifi alternative connects via wifi and, exploiting the higher connection speed, allows for streaming the high-quality video lesson with all its multimedia content (slides plus other interactive multimedia objects). upon student request of the e-learning service, the suitable midlet alternative for consuming such a service will be delivered and deployed on the device with an on-the-fly fashion by using our suitable implementation of the over-the-air (ota) provisioning technique [ota] for automatic delivery and deployment of adapted applications. adaptable p u b l i c class e−l e a r n i n g m i d l e t extends m i d l e t implements commandlistener { s t a t e s t a t e ; p u b l i c e−l e a r n i n g m i d l e t ( ) { . . . } /∗ l i f e −c y c l e management methods ∗/ p r o t e c t e d void pauseapp ( ) { . . . } p r o t e c t e d void s t a r t a p p ( ) { . . . } p r o t e c t e d void d e s t r o y a p p ( ) { . . . } /∗ chameleon s p e c i f i c s t a t e management methods ∗/ adaptable p r o t e c t e d void s a v e s t a t e ( ) ; adaptable p r o t e c t e d void r e s t o r e s t a t e ( ) ; /∗ e−l e a r n i n g s p e c i f i c methods ∗/ adaptable void c o n n e c t ( ) ; adaptable void getlesson ( ) ; . . . } / /−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a l t e r n a t i v e class gprs adapts e−l e a r n i n g m i d l e t { void c o n n e c t ( ) { annotation . s l s a n n o t a t i o n ( ” cost ( low ) , e−l q u a l i t y ( low ) ” ) ; p l a s t i c m i d d l e w a r e . connectviagprs ( ) ; } void getlesson ( ) { /∗ s t r e a m i n g o f t h e l e s s o n s l i d e s ∗/ } p r o t e c t e d void s a v e s t a t e ( ) { /∗ save i n t o t h e s t a t e t h e number o f t h e c u r r e n t s l i d e ∗/ . . . } p r o t e c t e d void r e s t o r e s t a t e ( ) {/∗ r e s t o r e t h e saved s t a t e ∗/} } / /−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− a l t e r n a t i v e class wifi adapts e−l e a r n i n g m i d l e t { void c o n n e c t ( ) { annotation . s l s a n n o t a t i o n ( ” cost ( h i g h ) , e−l q u a l i t y ( h i g h ) ” ) ; p l a s t i c m i d d l e w a r e . c o n n e c t v i a w i f i ( ) ; } void getlesson ( ) { /∗ s t r e a m i n g o f t h e v i d e o l e s s o n w i t h i t s m u l t i m e d i a c o n t e n t ∗/ annotation . r e s o u r c e a n n o t a t i o n ( ” b a t t e r y ( h i g h ) ” ) ; . . . } p r o t e c t e d void s a v e s t a t e ( ) { /∗ save i n t o t h e s t a t e t h e c u r r e n t frame o f t h e v i d e o l e s s o n ∗/ . . . } p r o t e c t e d void r e s t o r e s t a t e ( ) {/∗ r e s t o r e t h e saved s t a t e ∗/} } figure 3: an adaptable midlet given that chameleon has to allow to dynamically un-deploy a running adaptation alternative and re-deploy a new alternative, it requests that the two methods savestate and restorestate must be implemented, in addition to the natively required midlet methods i.e., pauseapp, startapp and destroyapp. contextualizing in our example, let us assume that the wifi alternative is no longer suitable for running due to a change in context: it will have to be undeployed. upon un-deployment chameleon will invoke the savestate method to save into the state a number of key informations such as the current frame of the video lesson, current slide number, audio track offset and so on. let us now suppose that, entering the new context, the gprs alternative becomes more suitable, and hence has to be (re-)deployed substituting the previously running wifi alternative. the gprs alternative will be dynamically deployed and, since only slides can be now viewed, it will be set to start from the slide saved into the state as restored through the restorestate method. annotations may also add information about particular code instructions (see the keyword annotation). they are specified at the generic code level by means of calls to the “do nothing” methods of the dedicated annotation class. in this way, after compilation, annotations are encoded in the bytecode through well recognizable method calls to allow for easy processing. for instance, in figure 3, the method call annotation.slsannotation (”cost(high), e-lquality(high)”), first line of the connect method in the wifi alternative, specifies that the wifi connection, and hence the wifi alternative, bears a high proc. campus 2008 6 / 12 eceasst cost, but provides a high quality e-learning lesson. on the other hand, the method call annotation.resourceannotation (”battery(high)”), first line of the getlesson method, demands for a high battery state-of-charge, since the streaming of the video lesson along with its multimedia content calls for a considerable amount of energy to be consumed. . resource model the resource model is a formal model that allows the characterization of the computational resources needed to consume/provide a service. the resource model, enables the framework to reason on the set of adaptation alternatives and allows it to decide the “best-fit”, depending on execution context information. resource definition defineres b a t t e r y as {low , medium , h i g h} defineres wifi as boolean defineres wifinet as boolean defineres gprs as boolean defineres gprsnet as boolean demandgprs ={gprs(true),gprsnet(true)} demandwifi={wifi(true),wifinet(true), battery(high)} supply 1={gprs(true),wifi(true),gprsnet(true), wifinet(false),battery(low)} supply 2={gprs(true),wifi(true), gprsnet(true),wifinet(true),battery(high)} figure 4: resource examples broadly speaking a resource is any item that is required to accomplish an activity or complete a task. some resources are subject to consumption (e.g., energy, heap space), while others, if present, are never exhausted (e.g., function libraries, network radio interfaces). thus, we model a resource as a typed identifier that can be associated to natural, boolean or enumerated values. natural values are used for consumable resources whose availability varies during execution. boolean values define resources that can be present or not (i.e. non-consumable ones). enumerated values can define non-consumable resources that provide a restricted set of admissible values (e.g. screen resolution, network type). left-hand side of figure 4 shows an example of some resource definitions. a resource instance is an association res(val) where a resource res is coupled to its value val∈typeo f (res) (e.g. wifi(true)). a resource set is a set of resource instances with no resource occurring more than once. it is used to specify both the resource demand of an alternative and the resource supply of an execution environment. referring to the adaptable midlet in figure 3, demandwifi (as shown in figure 4) might be a simple resource demand (automatically chameleon-derived through ara see below) associated to the wifi alternative specifying that, to run correctly, the wifi alternative will require a device equipped with the wifi radio interface (wifi(true)), connected to a wifi network (wifinet(true)) and with a high battery state-of-charge (battery(high)). on the same figure, supply 2 might be a resource set specifying the resource supply of a device equipped with both gprs and wifi radio interfaces, connected to both gprs and wifi networks and with a high battery state-of-charge. the resource model also defines the notions of compatibility between two resource sets. compatibility is used to decide if an application can run safely on a certain device: a resource supply is compatible to a resource demand if for every resource demanded by the alternative, a “sufficient amount” is supplied by the execution environment. for instance, in figure 4, the supply 1 is only compatible with demandgprs (it neither has wifinet(true) nor battery(high)); conversely, supply 2 is compatible with both demands. . sls model the sls model is a formal model that allows the specification of extra-functional preferences that will be used to establish the sla. together with the resource model, the sls model enables the framework to choose the “best” adaptation alternative depending on both ex7 / 12 volume 11 (2008) towards self-evolving context-aware services ecution context information and consumer specific preferences. this model bases itself around the same formalisms as the resource model. sls model is basically identical to the resource model and, as shown in figure 5 is used for specifying both requested and offered slss. sls definition: definesls cost as {low , h i g h} requested (or offered) ssslllsss(gprs)={cost(low), e-lquality(low)} definesls e−l q u a l i t y as {low , h i g h} requested (or offered) ssslllsss(wifi) = {cost(high), e-lquality(high)} figure 5: sls examples referring again to the adaptable midlet in figure 3, o f f ered slsgprs (as shown in figure 5) might be a simple offered sls (automatically chameleon-derived through ara see below) associated to the gprs alternative, offering a low quality lesson at a low connection cost. it must be noted that offered slss might also be specified, by the developer/provider, without embedding them within the generic code. in addition to that of compatibility, the resource model and the sls model together allow to define the notions of goodness. goodness is used for comparing resource demands and offered slss associated to different alternatives of the same application, and hence for choosing the best alternative among all its compatible ones. it is based on a notion of priority among resources/slss and order between resource/slss’ instances. for example, let’s assume that a student wishes to attend a full quality on-line lesson, even at a high cost (i.e., requested sls:{e-lquality(high),cost(high)} in figure 5). the notion of goodness, combined with the notion of compatibility, permits to state that the wifi alternative (associated to demandwifi of figure 4 and to o f f ered slswifi of figure 5) is, yes compatible, but also better than the gprs alternative (associated to demandgprs and to o f f ered slsgprs). the framework encodes both resource and sls sets into xml files, not shown for sake of space. . abstract resource analyzer the abstract resource analyzer (ara) is an interpreter that, abstracting a standard jvm, is able to analyze java applications and derive their resource consumption also deriving, if specified, the offered slss. ara is parametric with respect to the characteristics of the execution environment as described through a resource consumptions profile that expresses the impact that computational elements (i.e., the java bytecode language instructions) have on resources (see also the execution environment below). specifically, resource consumption profiles associate resources consumption to particular patterns of java bytecode instructions specified by means of regular expressions 1. basically, we can look at ara as a function that takes as input a java application’s bytecode, a resource consumption profile and gives as output a resource set that represents the resource demand of the application, and (optionally) an sls set that represents the offered sls (i.e., the resources needed for that program to be safely executed by the target execution environment with the offered sls). 1) invokevirtual plasticmiddleware.connectviawifi → {wifi(true), wifinet(true)} 2) invokevirtual plasticmiddleware.connectviagprs → {gprs(true), gprsnet(true)} figure 6: a resource consumption profile excerpt figure 6 shows an excerpt of a possible resource consumption profile defined over the resources of figure 4 and possibly provided by the student’s device in the 1 resource consumption profiles can be created on the basis of experimental results based on benchmarking tools, on informations provided by device manufacturers or network instruments. proc. campus 2008 8 / 12 eceasst e-learning scenario. for example, row “1)” states that to execute the bytecode instruction invokevirtual plasticmiddleware.connectviawifi the jvm will require the device to have a wifi radio interface and a wifi network within range. note that this bytecode instruction is part of the wifi alternative’s connect method bytecode as derived from the compilation of the generic code after this has been preprocessed to obtain a standard java code. analyzing this bytecode against the provided profile, ara will realize that for the wifi alternative to be correctly executed on the student’s device, the device itself must have the above mentioned resources. consequently, the wifi alternative “asks” for those resources by means of the two entries wifi(true) and wifinet(true) within its resource demand. finally, the resource demands and offered slss of the two midlet alternatives of figure 3 (derived by ara on the base of the provided resource consumption profile and the resource/sls annotations) are those shown in figure 4 and figure 5, respectively. . execution environment the execution environment can be any device that will host the execution of the code. we target execution environments provided by pdas, smart phones, etc. the execution environment is not strictly part of our framework, however, it has to provide a declarative description of the resources it makes available to consume/provide the service (i.e., the resource supply) and the resource consumption profile. in other words, it has to be a plastic-enabled device running a consumer-side chameleon component that, via the embedded consumer-side middleware (see section 3), is able to communicate with a provider-side chameleon component. . customizer the customizer takes in the resource supply, the provided profile, explores the possible adaptation alternatives’ space and, according to compatibility and goodness (see resource and sls models in section 4), defines the proper evolution policy and decides the actual best alternative. it will deliver that alternative (i.e., standard bytecode) that can then be eventually un-deployed and substituted by a new dynamically (re-)deployed alternative properly selected according to the defined evolution policy (see section 3). user decisions will be called up to choose among different alternatives that are “equally-suitable” from the customizer perspective and negotiation might possibly be performed. chameleon has been fully implemented in java (although other languages are eligible) and uses xml-based data encoding for the resource and sls models. it is worth mentioning that, even though both the ara and the customizer could be space and time consuming, they are executed on the provider-side of the framework which does not suffer resource limitations. 5 case study damien is a student traveling from italy to canada. while on the train to the airport, he wants to start an e-learning session through his stand-alone e-learning client, as deployed upon registration to the e-learning service. . foreground: damien takes up his smartphone and connects, through his e-learning client, to the e-learning service and chooses to get the latest available lesson of the computer science course. since damien wants to obtain a fully featured lesson, he is willing to invest considerably in the process. when the e-learning client asks for the cost by displaying a multiple-choice form with both high and low cost options, he will opt for a high cost solution delivering the fully featured version. after processing the choice, the e-learning service will inform damien, via a pop-up message, that the fully featured lesson is not obtainable since a high-speed connection cannot be established and his battery state-of-charge is insufficient to support the energy demands 9 / 12 volume 11 (2008) towards self-evolving context-aware services for the duration of the fully featured solution. as an alternative, the e-learning service proposes a low-cost version of the lessons in which only slides will be provided. the system also informs damien that as soon the conditions exist, it will automatically switch to the fully featured version. damien accepts, the sla (see section 3) is established, and the first slides appear. damien also recharges his smartphone. upon reaching the airport damien, after a slight hiccup, will be able to enjoy video, audio and other multimedia content of the fully featured version. . behind the scenes: damien’s smartphone is indeed a plastic-enabled device. it embeds the consumer-side middleware and the consumer-side chameleon components (see section 3 and 4). initially, the e-learning client will exploit the former to establish a gprs connection to the b3g network, and the latter to express its desired cost through the multiplechoice form (i.e., requested sls ={cost(high), e-lquality(high)} as shown in figure 5). after retrieving the network-side context and the consumer-side context, (i.e. device context), once again through the middleware and chameleon facilities, the client will additionally send the supplied resources (i.e., supply 1 = {gprs(true), wifi(true), gprsnet(true), wifinet(false), battery(low)} as shown in figure 4) as well as the resource consumption profile (as shown in figure 6). processing requested sls, providerside chameleon component will deliver, via ota application provisioning [ota], the gprs alternative. while not being the “highest-goodness” alternative, it is the only compatible one (see resource and sls models in section 4). the established sla states that, as soon as the conditions rise, the fully featured version of the lesson has to be provisioned. to meet such an agreement, the consumer-side chameleon component monitors the battery state-of-charge and wifi connection availability, since, via the predefined evolution policy, it knows that the “highergoodness” wifi alternative is ready to be re-deployed when these two conditions are met. upon reaching the airport, the chameleon monitor detects that the battery is fully charged and wifi networking is in range and, hence, immediately initiates the alternative switching previously envisioned. the wifi alternative, as selected by the customizer (see section 4), will be delivered on-the-fly to damien’s device, the gprs alternative will be un-deployed (after saving the current state), and the newly acquired alternative will be dynamically re-deployed and put into execution, immediately restoring the state. 6 related work for sake of space, we cannot address all the recent related work in the wide domain of the plastic project and in the chameleon domain: we provide only some major references. current (web-)service development technologies, e.g., [ecl, pro04, ykkp] (just to cite some), address only the functional design of complex services, i.e., they do not take into account the extra-functional aspects (e.g., qos requirements) and context-awareness. our process borrows concepts from these well assessed technologies and builds on top of them to make qos issues clearly emerging in the service development as well as to take into account context-awareness of services for self-adaptiveness purposes. our resource model and abstract resource analyzer can be related to other approaches to resource-oriented analysis, such as [am06, bar05, agz07, smm07]. all these approaches use a resource model as we do and give an absolute over-estimation of resources’ consumption. differently from us, they do not use these models in the context of adaptation and they do not provide a reasoning mechanism for selecting the proper alternative basing on estimations that proc. campus 2008 10 / 12 eceasst allow for a relative comparison of the alternatives. in [pp] an interesting approach may be found which considers concerns separation between application logic and adaptation logic. the approach makes use of java annotations to express metadata needed to enable dynamic adaptation. stemming from the same idea of concerns separation, in [ref+08], supported by the music project 2, the authors propose the design of a middlewareand architectural-based approach to support the dynamic adaptation and reconfiguration of the components and service composition structure. they use a planning-based middleware that, basing on metadata included in the available plans, enables the selection of the right alternative architectural plan for the current context. similarly to us, the idea for the designed approach is based on requested and offered qos, and supports sla negotiation. differently from us, they do not tackle adaptability to the device execution context through resource oriented analysis, parametric w.r.t. its resource consumption profile. 7 conclusion and future work in this paper we described how a declarative framework for tailoring adaptable services (called chameleon) [imn04, mi07] is used within ist plastic project [plaa]. this framework is at the basis of the plastic process model for the development and deployment of adaptable software applications targeted to mobile (resource-constrained) devices in the heterogeneous b3g network. the specific deployed application is customized (i.e., tailored) with respect to the context at deployment time but, at run time, it is frozen with respect to evolution. evolution (against context changes monitored through chameleon as supported by the plastic b3g middleware) is realized by dynamically un-deploying the no longer apt application alternative and subsequently (re-)deploying a new alternative with the desired aptitude. assuming that, upon service request, the user knows (at least a stochastic distribution of) the mobility pattern [mm07] he will follow during service usage, an amount of determinism is introduced permitting to identify the successive finite contexts the user can move along during service usage. following this approach, an enhanced version of chameleon would be able to generate code that is a compromise between self-contained and tailored adaptable code. the code would embed all the adaptation alternatives that, associated to the specified mobility pattern, are necessary to preserve the offered sls. that is, the code would also embed some dynamic adaptation logic which is able to recognize context changes, seamlessly “switching” among the embedded adaptation alternatives. in this way, a seamless evolution is performed among the embedded alternatives associated to the mobility pattern, while the un-/re-deployment evolution we presented is performed when moving out of the mobility pattern’s context. ontology based specifications might be used to establish a common vocabulary and relationships among resource/sls types. this would allow to relate resource/sls types and to predicate about a common set of related types. for instance, a demand of {energy(high)} could be related to a supply of {battery(high)}. moreover, the resource model and the sls model might be described as java types. these types can then be used within java5 annotations and our annotation mechanism might be improved, accordingly. this would provide the developer with a solid means for describing fully typed resource/sls needs and offers, and static analysis tools (such as spoon [spo]) are then able 2 http://www.ist-music.eu/ 11 / 12 volume 11 (2008) towards self-evolving context-aware services to derive an xml-based representation of the models that are used to match service alternatives to resource consumption profiles and requested sls. acknowledgements: this work has been partially supported by the ist project plastic. we would like to acknowledge the anonymous reviewers for the valuable contributions in providing high-quality and constructive comments. bibliography [abc+07] m. autili, l. berardinelli, v. cortellessa, a. d. marco, d. d. ruscio, p. inverardi, m. tivoli. a development process for self-adapting service oriented applications. in icsoc. 2007. [agz07] e. albert, s. genaim, m. zamalloa. heap space analysis of java bytecode. in ismm’07. acm press, oct. 2007. [am06] d. aspinall, k. mackenzie. mobile resource guarantees and policies. in construction and analysis of safe, secure, and interoperable smart devices. 2006. [bar05] g. barthe. mobius, securing the next generation of java-based global computers. ercim news, 2005. [beii06] a. bertolino, w. emmerich, p. inverardi, v. issarny. softure: adaptable, reliable and performing software for the future. frcss, 2006. [ecl] eclipse.org. eclipse web standard tools. http://www.eclipse.org/webtools. [imn04] p. inverardi, f. mancinelli, m. nesi. a declarative framework for adaptable applications in heterogeneous environments. in sac. 2004. [mi07] f. mancinelli, p. inverardi. quantitative resource-oriented analysis of java (adaptable) applications. in wosp. 2007. [mm07] a. d. marco, c. mascolo. performance analysis and prediction of physically mobile systems. in wosp. 2007. [ota] over-the-air (ota). http://developers.sun.com/mobility/midp/articles/ota/. [plaa] plastic ist strep project. http://www.ist-plastic.org. [plab] plastic ist strep project. deliverable d1.2: formal description of the plastic conceptual model and of its relationship with the plastic platform toolset. [plac] plastic ist strep project. deliverable d2.2: graphical design language and tools for resource-aware adaptable components and services. [pp] n. paspallis, g. a. papadopoulos. an approach for developing adaptive, mobile applications with separation of concerns. in compsac. 2006. [pro04] a.-m. project. methodological framework for freeband services development. 2004. https://doc.telin.nl/dscgi/ds.py/get/file-47390/. [ref+08] r. rouvoy, f. eliassen, j. floch, s. o. hallsteinsen, e. stav. composing components and services using a planning-based adaptation middleware. in sc. 2008. [smm07] c. seo, s. malek, n. medvidovic. an energy consumption framework for distributed java-based systems. in ase. 2007. [spo] spoon project. http://spoon.gforge.inria.fr. [ykkp] h. yun, y. kim, e. kim, j. park. web services development process. in pdcs’05. proc. campus 2008 12 / 12 introduction setting the ``context'' developing context-aware services the chameleon framework case study related work conclusion and future work invited talk: on the concurrent semantics of transformation systems with negative application conditions electronic communications of the easst volume 58 (2013) proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gtvmt 2013) invited talk: on the concurrent semantics of transformation systems with negative application conditions andrea corradini 2 pages guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst invited talk: on the concurrent semantics of transformation systems with negative application conditions andrea corradini1 1 andrea@di.unipi.it, dipartimento di informatica, university of pisa, italy abstract: a rich concurrent semantics has been developed along the years for graph transformation systems, often generalizing in non-trivial ways concepts and results first introduced for petri nets. besides the theoretical elegance, the concurrent semantics has potential applications in verification and model checking, as witnessed by techniques like partial order reduction or the use of finite, complete prefixes of the unfolding. in practice (graph) transformation systems are often equipped with negative application conditions (nacs) that describe forbidden contexts for the application of a rule. the use of nacs increases the expressive power of rules, by reducing the number of rules needed to specify a system. in recent years several works addressed the problem of lifting the concurrent semantics developed for transformation systems to the case with nacs [leop08, hcek10]. the talk will summarize some recent results which are the outcome of joint works with reiko heckel, frank hermann, susann gottmann and nico nachtigall. essentially, we show that if the nacs are sufficiently simple (incremental) then the concurrent semantics lifts smoothly to systems with nacs, but the general case requires original definitions and intuitions. we start discussing the definition of sequential independence for direct derivations with nacs [leop08], showing that unlike the plain case, it does not enjoy the fundamental property of being stable under switching of derivations. the consequence is that sequential independence does not induce a well-defined causal partial ordering on direct derivations, unless nacs are incremental. as shown in [chh+12] a possible solution is to transform rules with arbitrary nacs into a set of rules with incremental nacs only. the resulting system is in general an over-approximation of the original one (it can have more derivations), and it can be exploited to identify the really independent direct derivations in the original system. next a step semantics for transformation systems with nacs is discussed (summarizing [ch13]), where several independent rules can be applied simultaneously to the same graph. unlike the plain case, where the parallel independence of rules guarantees sequentiability in any order, in presence of nacs one should also check that no nac of one of the rules is generated by any combination of applications of the other rules. if nacs are incremental, though, a static check is sufficient, simply comparing the nacs of each rule with the right-hand sides of the other rules. in this case, it is also shown that canonical derivations exist, that is maximally parallel 1 / 2 volume 58 (2013) mailto:andrea@di.unipi.it invited talk: on the concurrent semantics of transformation systems with nacs derivations where each rule is applied as early as possible. finally (deterministic) graph processes for derivations with nacs will be considered. it will be shown that the classical colimit construction that builds a process from a derivation diagram does not work properly with nacs, because isomorphic processes are obtained from derivations that are intuitively not equivalent. the same problem shows up with inhibitor nets, and the solution in the literature consists of enriching the process with some minimal additional information sufficient to distinguish among the non-equivalent derivations that it represents. we will discuss a similar and more general solution for derivations with nacs, suggesting that in the case of incremental nacs the solution coincides with the one proposed for inhibitor nets in [bp99]. bibliography [bp99] n. busi, g. m. pinna. process semantics for place/transition nets with inhibitor and read arcs. fundam. inform. 40(2-3):165–197, 1999. [ch13] a. corradini, r. heckel. canonical step sequences with negative application conditions. 2013. submitted for publication. [chh+12] a. corradini, r. heckel, f. hermann, s. gottmann, n. nachtigall. transformation systems with incremental negative application conditions. in martı́-oliet and palomino (eds.), wadt. lecture notes in computer science 7841, pp. 127–142. springer, 2012. [hcek10] f. hermann, a. corradini, h. ehrig, b. könig. efficient analysis of permutation equivalence of graph derivations based on petri nets. eceasst 29, 2010. [leop08] l. lambers, h. ehrig, f. orejas, u. prange. parallelism and concurrency in adhesive high-level replacement systems with negative application conditions. in ehrig et al. (eds.), proceedings of the accat workshop at etaps 2007. entcs 203 / 6, pp. 43–66. elsevier, 2008. proc. gtvmt 2013 2 / 2 ten virtues of structured graphs electronic communications of the easst volume 18 (2009) proceedings of the eighth international workshop on graph transformation and visual modeling techniques (gt-vmt 2009) ten virtues of structured graphs roberto bruni and alberto lluch lafuente 20 pages guest editors: artur boronat, reiko heckel managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst ten virtues of structured graphs roberto bruni1 and alberto lluch lafuente1 1bruni@di.unipi.it 2lafuente@di.unipi.it dipartimento di informatica, università di pisa abstract: this paper extends the invited talk by the first author about the virtues of structured graphs. the motivation behind the talk and this paper relies on our experience on the development of adr, a formal approach for the design of styleconformant, reconfigurable software systems. adr is based on hierarchical graphs with interfaces and it has been conceived in the attempt of reconciling software architectures and process calculi by means of graphical methods. we have tried to write an adr agnostic paper where we raise some drawbacks of flat, unstructured graphs for the design and analysis of software systems and we argue that hierarchical, structured graphs can alleviate such drawbacks. keywords: hierarchical graphs, graph grammars, visual languages if you can find something everyone agrees on, it’s wrong — m. udall 1 introduction graph-based notations, techniques and tools play a fundamental role in the analysis of complex systems: on the one hand they rely on a solid mathematical basis, on the other hand they make it possible to render the formal analysis in visual notation best accessible for non graph theorists, like business analysts. however, the complexity of modern software systems like those emerging in global computing and in service oriented architectures is such that the “representation distance” w.r.t. ordinary graph transformation methodologies has grown larger and larger and poses serious problems in terms of issues such as, e.g., scalability, open endedness, dynamicity and distribution. furthermore, the same kind of complication hampers indiscriminately all phases involved in the modeling process (specification, design, validation and verification). we aim to show that one good way to tackle complexity and to enhance efficient formal reasoning is to superimpose some structure on complex graphs, a general consideration that finds application in several different contexts where graphical notations are widely adopted and standardized (e.g., unified modelling language, petri nets, bpel and other workflow models, reference modeling languages, process calculi encodings). in other words, we propose to consider structured graphs instead of flat graphs. the most prominent approach to structured graphs is probably the use of hierarchical graphs. indeed, many hierarchical models have already appeared in the literature that exploit some notion of containment of a graph into a node or an edge and treat it differently from the ordinary linking of components. amongst the various approaches we mention bigraphs [jm03], hierarchical 1 / 20 volume 18 (2009) mailto:bruni@di.unipi.it mailto:lafuente@di.unipi.it ten virtues of structured graphs figure 1: two different drawings of the same network graphs [dhp02, dhj+08], shaped graphs [hm04] and designs [blmt08] (our own contribution to this field). we will discuss the benefits of using structured, hierarchical graphs over unstructured, flat graphs in the context of ten key aspects that arise in the graph-based engineering of software systems. more precisely, we shall consider design issues such as understandability (section 2), abstraction (section 3.2), composition (section 3.3) and requirements specification (section 3.1), dynamic aspects like behaviour (section 5.1) and reconfiguration (section 5.2), and analysis activities such as model finding (section 4.1), conformance (section 4.2) and verification (section 6). last, we survey a particular application of graphs: the visual encoding of process calculi (section 7). final remarks are in section 8. 2 understanding graphs: parsing and browsing graphs find important applications as a convenient visual formalism in many different fields, ranging from software engineering, database and web design to networking, systems biology, global and grid computing, to cite a few. through visual interfaces, graphs give the possibility to grasp at one glance the connection between the represented entities (think e.g. of entity-relationship diagrams, uml class diagrams, folder trees in virtual desktops). there are many different ways to represent graphs in textual notation, a task which is necessary for graph manipulation by machines (parsing, storing, analysing, modifying). wellknown examples are adjacency lists, adjacency matrices, xml formats such as gml [gml] and graphml [gra], or the dot format used by graphviz [dot]. all such formats are usually less amenable for user interaction, because the graph topology is less evident for human reading. similarly, some information can be rendered visually better than textually. for example, dblpvis [dbl] shows co-authorship relation between persons exploiting colours, node diameproc. gt-vmt 2009 2 / 20 eceasst ters and node distance to visualise different kinds of semantic information. in the case of large monolithic graphs, visual notation begins to suffer from the same limitations as the textual notation, because it can be problematic for the user to parse, find and browse the portion of the graph more relevant to her/him. in this sense, automatic drawing techniques are also important for visual rendering. a first virtue of structured graphs is overcoming several limitations related to the textual and visual representation. to see this, let us consider the representation of networks that connect different kinds of nodes including hosts and hubs. this kind of networks will be used as a running example over the paper. figure 1 shows two isomorphic flat graphs representing the same network, however it is evident that the “logical” structure of the connection topology emerges better in the rightmost representation, which exposes the presence of three rings whose hubs are attached together to form what informally can be called a “star of rings”. one can also note that a ring is just a line of hosts whose ends are connected to the same hub. this corresponds to fix a way to read the graph according to some sort of “blueprint” that explains how it is organised: at the topmost level there is the whole graph seen as a star of subgraphs, which in turn are all ring-shaped with a principal hub connected in line with a (possibly different) number of other components. recursively, one could think of a way to allow stars as components of rings, e.g. by introducing some adaptor components, like some special hubs. in this case, one would have to deal with even more complex networks, like the one in figure 2, where the blueprint is made explicit: components are grouped by encircling them in a titled box (i.e. the type of the subnetwork) and titled boxes can be nested. for example, figure 2 shows a network composed of three rings, where one of the rings contains a subnetwork with two rings. in this particular case, it is worth noting that the underlying flat graph would be ambiguous w.r.t. the proper structure of the network, as a different parsing could place the two leftmost rings as nested within the central one, and the two rightmost rings at the top layer. our point is that having some sort of “blueprint” of the graph would help to predicate over relevant subgraphs. for example, exposing the structure of the network can e.g. help in organising software updates or load balancing policies and also to carry inductive proofs of properties. it also allows for posing the attention to and navigate through smaller coherent portions of the graph. finally, it will be argued later that the hierarchy structure makes it possible to define textual notation that is machine-readable and human-readable at the same time. 3 designing graphs 3.1 requirements and specification graph-based approaches to software engineering (e.g. [bp05, bh04]) often reduce the specification of static (i.e. topological, structural) requirements to the characterisation of a set of graphs (those that fulfil the requirements) and requirement conformance to set membership. in our scenario, for instance, a requirement can be that networks must be ring-shaped which must be modelled by characterising in some way the set of ring-shaped graphs. typically, the sets of graphs to be specified are infinite (such as all ring-shaped graphs) or at 3 / 20 volume 18 (2009) ten virtues of structured graphs figure 2: a structured network with some explicit blueprint (a) (b) (c) figure 3: a type graph (a), an entity/relation diagram (b) and graph grammar production (c). least sufficiently large (such as all ring-shaped graphs with at most n hosts) to make an enumerative description cumbersome when not unfeasible. a variety of mechanisms have been developed and are used to finitely describe sets of graphs in order to make, for instance, set membership decidable and, possibly, efficient. this issue will be discussed in more detail in section 4.2. type graphs have been traditionally used in graph transformation approaches [cmr+97] as a convenient way to label graph items with types and to constrain the way in which items can be interconnected. type graphs have been used in various graph-based approaches to software engineering (e.g. [bbgm08, bhtv04]), but although they offer a simple and elegant mechanism for imposing local constraints, their main limitation is the intrinsic difficulty to express global ones. to see this, consider line-shaped graphs. a type graph can express the fact that there is a particular type of host which has two connections (tentacles) to a connection node (see figure 3(a)) but it is not possible to define a type graph that imposes requirements such as connectivity (no host is disconnected) or aciclicity (hosts do not form rings). intuitively, such properties are global in the sense that they regard the whole graph. type graphs resemble some mechanisms that are used in visual specification languages used in the area of software engineering. for instance, one of the de-facto standards, the uml, makes proc. gt-vmt 2009 4 / 20 eceasst use of entity-relationship diagrams that introduce both a vocabulary of items (entities) and the way they can be related (relations). a difference with type graphs that makes such diagrams a bit more flexible is the possibility to impose cardinality constraints. we can, for instance, impose an entity of type host to be connected to at least one and at most two connection nodes and, vice versa, we can impose each connection node to be related to at least one and at most two hosts of type host (see figure 3(b)). however, this is still not sufficient to characterise lineshaped networks: there are infinitely many collections of hosts that satisfy the former cardinality constraint while not being line-shaped. to tackle such limitations of uml specifications, complementary mechanisms have been developed, such as the object constraint language (ocl). the main idea is to impose further logic-based constraints over admissible graphs. such mechanisms are not new in the research area of graphs. indeed, courcelle has thoroughly studied logics for graphs and their expressiveness. one of the examples in his works is the well-known fact that graph reachability (required to characterise connectivity) cannot be expressed in first-order logic: second-order logic is needed. courcelle has developed the monadic second-order ogic for graphs (mso) and has studied its expressiveness in comparison to graph grammars [cou97]. graph grammars [cmr+97, ehk+97] are another fundamental approach to characterise graph sets by providing a grammar that inductively generates all the graphs of the set. a prominent example are hyperedge replacement grammars [hab92] that can be considered as the equivalent of traditional context-free grammars. in the context of software architectures, for instance, this approach was first proposed in [mét98] and subsequently followed by various authors [hm04, blmt08]. graph grammars do also have some limitations. for instance, it is wellknown that a context-free graph grammar cannot characterise the set of all regular grids [hab92]. the mentioned approaches can be considered as complementary and can be used together to express complex system requirements. the most evident example is uml technology. another analogy in this regard can be done with membership equational logic [mes98] and type systems for programming languages where a generative mechanism (e.g. the signature, the syntax) characterise the main types (i.e. sets of elements) and deduction mechanism based on inference rules are used to characterise more refined subtypes. which is the most convenient mechanism to deal with structured graphs? in [bbg+08] it is argued that logic-based definitions are more suitable when the system under study is in a primitive state where the actual requirements (and hence the structure) are not well-understood and are refined again and again (which mainly amounts to adding, removing or modifying predicates). instead, when the requirements become mature and the structure of the graphs becomes clear, then inductive definitions seem better suited. inductive mechanisms such as graph grammars (that also includes type graphs) provide unique advantages. consider the example of line-shaped graphs. an inductive definition simply says that a line-shaped graph is a host with two ports or the concatenation of two line-shaped graphs (see figure 3(c)) and the derivation tree explains the structure of the graph (how it has been generated). on the other hand, a logical characterisation of line-shaped graphs consists on stating that: a) they are strongly connected, b) they are acyclic, c) each host is connected to exactly two hosts except for the hosts at the extremes of the line. as a concrete example, predicate a) is roughly in mso as ∀a, b.∀x .((∀y, z(y ∈ x ∧z ∈ r(y, z) → z ∈ x )∧∀y.(r(a, y) → y ∈ x )) → b ∈ x ) , where 5 / 20 volume 18 (2009) ten virtues of structured graphs (a) (b) (c) figure 4: a flat, explicitly structured graph (a), a flat, implicitly structured graph (b) a hierarchically structured graph (c). x is a set of nodes, a, b, y and z are nodes, r abbreviates the existence of an edge between two nodes. predicates b) an c) can be formalized in a similar way. while the mso formulae are essentially (rather unstructured) logical sentences, the inductive definition is in some sense a structured definition, amenable to inductive reasoning and enjoying nice compositional features as we shall discuss in section 3.3 as well as having further virtues that we shall continue highlighting in the rest of the paper. 3.2 abstraction and refinement software systems are too complex to be designed, analysed and developed monolithically. one main remedy to master such complexity is abstraction. prominent examples are present in the layered approaches to computer networks (tcp/ip stack), operating systems (os layers) and software applications (architectural layers and tiers). abstraction layers allow us to handle a proc. gt-vmt 2009 6 / 20 eceasst complex system at different levels of granularity, abstracting away subsystems whose details are not relevant at that point. when needed, refinement can reveal the internals of an abstract component. another advantage of the use of abstraction and refinement arises in presence of open systems, where some parts of the system are not specified. in sum, abstraction is a fundamental aspect that enables scalability, understandability, and modularity. unfortunately, flat graphs are not a completely satisfactory model to deal with abstraction layers. layers in flat graphs are typically modelled using a tree-like structure. a prominent approach that follows this spirit are milner’s bigraphs [jm03] where the locality structure and the (unstructured) communication topology are represented by two overlapping graphs: a tree for locality, called the place graph, and an arbitrary graph for communication, called the link graph. still superimposing some structure is different than explaining how such structure has been obtained, an option that is found in structured hierarchical graphs and has further benefits. as a simple example that regards our running scenario, consider a network formed by a star of rings, where a ring is seen as a line closed in circle. using flat graphs the logical grouping of the hosts that form each line, for instance, must be encoded ad hoc (e.g. using the tree structure denoted with the edges of type sub in figure 4 (a)) to avoid confusion. the resulting structure becomes complex, hard to understand and to manipulate. an inductive definition of graphs (as explained in section 3.1) by means, e.g. of contextfree graph grammars [hab92], can mitigate the problem. the best analogy one can offer is the functional reading of a grammar, where syntactical categories are seen as types. so, implicitly, a graph produced by a graph grammar has a parsing and a type and so do its (proper) subgraphs. the idea is then that such information can be recovered to understand or manipulate graphs in a layered way (see figure 4 (b)). using hierarchical graphs (e.g. [dhp02, blm09]) we can combine the benefits of tree-like structuring of layers with the inductive definition of graphs. in a way, the layering is encoded within the graphs by the use of hierarchical edges, i.e. edges that contain graphs (figure 4 (c)). for this purpose, the notion of interface becomes crucial as it represents the relation between an abstract component (hierarchical edge) and its internal details (graph). we will see this in section 4.1. 3.3 composition we have seen in section 3.2 that structured graphs enable modularity and top-down development by refinement. we will see here that they facilitate bottom-up development by composition, as well. arbitrary compositions can result in ill-shaped systems. for example, figure 5(a) shows a broken pipeline obtained as the union of two pipelines and an incorrect attempt to repair it by fusing two nodes. this is the main disadvantage of flat graphs, i.e. they do not have an explicit mechanism to define the legal operations that can be used for composing larger graphs. to avoid this and to guarantee that only well-formed compositions are possible, the notion of a graph interface is fundamental. a flat graph can be decorated with ad-hoc items to represent its interface but this results in cumbersome representations where the interface is usually hard to recover. to overcome such limitations various notions of graphs with interfaces have been proposed. 7 / 20 volume 18 (2009) ten virtues of structured graphs (a) (b) figure 5: a free composition (a) and a functional production (b). a graph interface is usually formed by a skin (the external aspect of the graph) and a relation between the skin and the graph itself (usually called the body graph). a typical mechanism (used e.g. in [dhj+08, blmt08]) is to use a hyperedge as the skin and to define a relation between the surrounding nodes the edge is attached to and some nodes of the body graph. other mechanism have been proposed and are used for instance in ranked graphs [gad03], bigraphs [jm03], syntactic grap judgments [fhl+06] and borrowed contexts [ek06]. the notion of graph interface facilitates the development of composition mechanisms. various such notions can be found in the literature. for instance, compositions for graphs with name interfaces [gad03] operate by disjointly unifying graphs and merging their common nodes (those declared in the interfaces). other, more complex compositions can also be found for bigraphs [jm03]. in all such cases, a disciplined, structured way of composing graphs is given by means of some graph algebra. context-free graph grammar approaches to requirements such as those mentioned in section 3.1 provide a unique advantage in this sense: a functional reading of the grammar provides a set of well-formed compositions. for instance, figure 5(b) depicts the functional reading of the productions in figure 3(c): the left-hand side of a production is now drawn as the enclosing box (interface), while the right-hand side is drawn as the enclosed graph. the first operation can be seen as a constant that returns a pipeline formed by a single host, the second operation takes two arguments of type pipeline, concatenates them and returns the resulting pipeline (the order of the arguments is usually implicit in the graphical drawing, along occidental reading convention). moreover, we can assign names to such operations, like those shown in the top-bars of the corresponding boxes and then have a correspondence between the term algebra over such operators and the flat/structured graphs that we can build. for example, the term host;host denotes a pipeline with two hosts. 4 analysing graphs it is rather common that several attempts are needed before system requirements are fully assessed, i.e. the requirements need to be validated to make sure that all desired models can be proc. gt-vmt 2009 8 / 20 eceasst figure 6: constructing a line using a grammar derivation. accepted and that no erroneous model is allowed. in case some models are found that violate such assumptions, then the problem has to be reported as a feedback to possibly upgrade the specification of requirements. thus, model construction and model conformance can play a prominent role during (and also after) the phase of requirements assessment. 4.1 model construction once we have a first version of a system’s requirements we might want to study the set of systems that satisfy them, with the purpose of understanding better the requirements, finding inconsistencies with informal descriptions, or discovering missing specifications. this analysis activity has been coined by daniel jackson as model finding [jac06]. jackson’s approach is based on first-order logic and has been also applied to graph-based modelling [bbg+08]. the main idea is that boolean variables and predicates are used to denote the presence or absence of graph items (edges, nodes, tentacles, possibly typed) and further predicates are used to characterise the requirements. having fixed a bound on the admissible instances of each graph item, the set of all (bounded) graphs satisfying the requirements is given by all the possible ways of satisfying the boolean predicate that results from combining the available items. the imposed bounds restrict the approach to finite subsets of the graphs under study. still, the size of such sets can likely explode due to the arbitrary ways of pasting graph items. unstructured 9 / 20 volume 18 (2009) ten virtues of structured graphs (a) (b) figure 7: constructing a line using a grammar derivation. graphs are thus not easily handled. this is mitigated in alloy [jac06] (the tool implementing jackson’s approach) by introducing the predicates that represent the requirements (and thus the structure of graphs) which implicitly discard non-conformant instances. the efficiency of such mitigation is delegated to clever sat solvers. a similar situation arises when the structure of graphs is expressed inductively in terms of graph grammars. the unstructured case amounts to a grammar that can introduce any graph item in any possible way. again the state space of graphs to be considered exploits combinatorially and hampers any reasonable analysis. however, in presence of structured graphs the situation is different. for instance, consider a context-free grammar characterising pipeline-shaped graphs. the grammar does not only offer us simple way to construct all such graphs, but it also emulates a design-by-refinement construction on which we could also reason (see section 3.2). for instance, we can reason about the number of refinement decisions that an architect must take in order to achieve a certain network or how many different derivations are possible to achieve it. as an example, suppose that in the initial requirement for our networks the production for an empty and parallel pipelines were also considered (see figure 7(a)). then it would have been readily discovered that ill-shaped pipelines are possible, like the network in figure 7(b) that can be described by the term host; (host|empty);host: the problem is due to the presence of the empty pipeline, whose misuse can introduce unexpected cycles since it introduces node fusions. 4.2 model conformance useful analyses are concerned with checking whether a graph enjoys some characteristics like being well-typed, conformant to a certain architectural style or fulfilling some subtle requirement. in all cases we refer to the problem of checking whether a graph is a model of some property as conformance. as mentioned in section 3.1 a graph property can be seen as a set of graphs, which can proc. gt-vmt 2009 10 / 20 eceasst (a) (b) figure 8: an unstructured (a) and a structured (b) graph to be analysed. be characterised by means of some mechanism like graph grammars, various kind of diagrams and logical predicates. checking conformance for an unstructured graph means then applying expensive algorithms to check if the graph can be derived from a graph grammar, satisfies the constraints of the diagrams or fulfils the logical predicate. structured graphs, instead, carry the “blueprint” as an immediate witness that the underlying graph is conformant to a certain architectural style or to certain constraints required by the original specification. a hierarchical, structured graph can carry even more information, because part of its blueprint might be present in the graph itself. suppose that we do not trust such blueprint and we want to check it for conformance. consider the examples on figure 8 depicting a flat graph (a) and a structured graph, both representing a star of rings. let us start with the unstructured graph. checking conformance of a logical predicate potentially leads to consider each graph item (5 nodes and 6 edges) for each quantifier present in the predicate. note that typical properties involve a non-trivial depth of quantifier nesting. a similar situation arises if we want to check conformance against a graph grammar, where (sub)graph isomorphism is a fundamental test which, again, might consider every graph item in the match. consider now the hierarchical graph. observe that the hierarchical structure provides three layers, and each item in the layers is annotated with the declared shape type. the outermost layer is formed by a single edge declared as a star, the middle layer is the body of the star and contains two hubs and two pipelines (for a total of 4 edges and 5 nodes). each such pipeline edge contains a graph of the bottom-most layer formed by 3 nodes and two host-typed edges. clearly, the global conformance analysis can be divided in several smaller sub-problems driven by the declared structure of the hierarchical graph. 11 / 20 volume 18 (2009) ten virtues of structured graphs (a) (b) figure 9: behaviour rules for pipelines: conditional message passing using flat graphs (a) and hierarchical graphs (b). 5 transforming graphs 5.1 behaviour graphs have a long tradition as a structure for representing static aspects such as data, topologies or architectures. another example that we have seen in section 3.1 is the use of graphs to represent the specification of static system requirements. graph are also used to represent dynamic system aspects such as the behaviour of a system. the main idea is that graphs are used to represent the state of a system and graph rewrites model the execution of the system. various mechanisms for rewriting graphs have been proposed, ranging from the general-purpose graph transformation approaches by pushout construction [cmr+97, ehk+97, ek06] or replacement [hab92] to specific mechanism like those based on relative pushouts for bigraphs [jm03] or those based on multiple synchronisation for systems with mobility [fhl+06]. overall, such models can account for complex graph manipulations by exploiting negative application conditions and sophisticated synchronisation mechanisms with the big advantage of their solid theories related to concurrency and distribution. there are, however, some drawbacks in those cases in which flat, unstructured graphs are used. the first, obvious one regards the mechanism of rule matching. basically, graph matching rules are based on subgraphs isomorphism, i.e. finding a part of the graph under consideration that matches the left-hand-side of a graph rewrite rule. the situation is similar to the one discussed in section 4.2: in absence of structure the matching algorithm must consider the whole graph, while structure in the graph limits the number of subgraphs to be considered. another disadvantage of the use of flat graphs arises in presence of context-dependent behaviours. while standard techniques exist in term rewrite approaches to operational semantics (reactive contexts, sos), in most graph-based approaches one has to decorate the graphs with proc. gt-vmt 2009 12 / 20 eceasst figure 10: reconfiguration rule to migrate hosts. graph items that act as flags enabling or disabling the applicability of the rules (see [gad03] for an example of graph-based pi-calculus semantics, where rewriting under prefixes is inhibited). hierarchical graphs can be used as a more elegant and convenient graph version of the above mentioned term rewrite mechanisms. consider, for instance, that we want to model message passing in our running scenario, but we want to make it dependent on the status (active, non-active) of the network. using flat graphs one can, e.g., decorate active hosts network points with go-labelled edges. one rule for message passing would look like in figure 9 (a). one evident disadvantage is that our graphs will be full of active flags and that ad-hoc rules are needed to propagate the introduction or removal of those flags to enable or disable a part of the network. using hierarchical graphs we could encode the network status information at the level of hierarchical frames, distinguishing between active and non-active pipelines. for instance, the rule in figure 9 (b) conditions message passing for two hosts to be within an active frame.1 an additional disadvantage of using unstructured graphs is that the rules must be shown to be conformance-preserving, i.e. one must show that the rules cannot transform a valid graph into a graph that does not represent a valid system configuration. structured graphs, instead, are a convenient ground to define structure-preserving graph transaformations. we will see an example in the next section. 5.2 reconfiguration and refactoring we have seen in section 5.1 that graph transformations can be used to model ordinary run-time behaviour. there are, of course, other interesting applications of graph rewrite systems like the computation of graph algorithms, model-driven refactoring or architectural reconfiguration. in comparison to ordinary behaviour, the kind of transformations involved in the latter applications might be very subtle and impose particular constraints. for instance, when reconfiguration 1 in concrete hierarchical graph transformation approaches the rule might need additional information that we neglect here since this paper does not marry any particular technique. 13 / 20 volume 18 (2009) ten virtues of structured graphs rules are considered, like in self-repairing and self-adaptive systems, then it is important to guarantee the conformance of the reconfigured system and to keep the reconfiguration as local as possible. in the case of model-driven refactoring, the transformation must be metamodel conformant. when using flat graphs and ordinary graph transformation approaches such features are often hard to match and need to be studied case by case. for example, consider the case of a network made of a star of rings (see e.g. figure 8) and suppose we want to model the situation in which the hub of a ring may fail down triggering a network reconfiguration that migrates containment of the ring to another ring. such reconfiguration is not easy to accomplish with ordinary graph transformation rules.2 the main problem is that the containment of the ring might be formed by an arbitrary number of hosts or complex subnetworks. a complex program of rewrite rules is needed and several intermediate states must be considered, i.e. the transformation is not atomic. this is naturally accomplished by hierarchical graph transformation systems. indeed, all we need is a rule like that informally depicted in figure 10 which migrates a whole pipeline in one shot and guarantees that the resulting network is well-formed. more subtle reconfigurations can take place, for instance involving a change in the interface of a system’s components or requiring synchronisation to agree on the common reaction to a certain failure. in all such cases the use of flat graphs imposes several challenges due to the need to directly manipulate individual graph items, to the eventual risk of having bad formed graphs as intermediate graphs during the reconfiguration and the need to show or verify that resulting graphs are well formed. hierarchical graphs can be helpful in those challenges since they allow to work on the structure of graphs, to manipulate groups of items and to have a more disciplined control over the resulting interfaces and structure. in some cases (e.g. [blmt08]) well formedness (e.g., style or metamodel conformance) must not even be proven: it can be guaranteed by construction. 6 analysing graph transformations we have already argued the convenience of structured graphs for the analysis of systems. in particular, we discussed the issue of checking whether a graph satisfies some static properties in section 4.2. this section, instead, regards the dynamic aspects of systems modelled via some kind of graph rewrite system. verification approaches for graph transformation systems mainly consist on some mechanism to specify properties and algorithms to check them. various logics have been developed, for instance extending courcelle’s monadic second order logic (see [cou97] and section 3.1) with temporal modalities [bckl07]. an alternative approach is to use some kind of ad-hoc spatial logic, taking inspiration from caires spatial logic for the pi-calculus [cc03]. an approach to structured graphs based, e.g. on disciplined ways of composing graphs can inspire the derived logical operators for decomposing graphs. this might result in ad-hoc efficient algorithms, but also in a property specification closer to visualisation and thus easier to use. in any case, the model-checking problem can be very complex when not unfeasible due to the size of the state space and the expressiveness of the logics. indeed, the presence of rules 2 a detailed example can be found in [blmt08]. proc. gt-vmt 2009 14 / 20 eceasst (a) (b) figure 11: two alternative encondings for pi-calculus process (ν secret) facebook(secret) | facebook(message) | facebook(message) . (internet(message) | mailbox(message)) . introducing new items and logical quantifiers nested with temporal modalities complicates the verification problem. to mitigate such problems, standard verification techniques must be applied. some approaches exist that apply abstract interpretation techniques for the verification of graph rewrite systems (see [bck08] and the references therin) we argue that structured graphs can contribute further. indeed, as we have seen, structured graphs already offer a notable support for abstraction (c.f. section 3.2) and also for compositional issues (c.f. section 3.3). consider for instance an approach based on context free graph grammars. each syntactical category can be seen (in the functional reading) as a type. such types can be used to define various abstractions. in our running scenario, for instance we might want to verify a particular network where we abstract away from all rings and we keep the full information of stars, only. similarly, we can use the types to support a modular verification approach. finally, we might show that some properties are inherent to rings or stars by structural induction. 7 visual encoding of process calculi as exemplified by a vast literature, graphs offer a convenient ground for the specification and analysis of modern software systems with features such as distribution, concurrency and mobility. in this section we shall discuss the convenience of structured graphs for a particular purpose: the visual encoding of process calculi. various graph-based approaches have been used for this purpose. among them, we recall those based on traditional graph transformation [gad03], bigraphical reactive systems [jm03] 15 / 20 volume 18 (2009) ten virtues of structured graphs and synchronized hyperedge replacement [fhl+06]. using any of such approaches to build a visual representation of an existing language involves two major challenges: encoding states and encoding the operational semantics. a correct state encoding should map structurally equivalent states into equivalent (typically isomorphic) graphs. in addition, the state encoding should also facilitate the encoding of the operational semantics, which typically means mimicking term rewrites via suitable graph rewrites. an example of two possible encondings for pi-calculus process is depicted in figure 11. the first one, figure 11(a), resembles the syntactic tree of the term. the main drawback is that a particular parsing of the parallel composition is chosen and to get rid of the associativity and commutativity of parallel composition graph isomorphism is not enough: a weaker graph equivalence notion is needed. unfortunately, graph transformation approaches and tools are strongly based on graph isomorphism. another drawback is that the graph requires additional annotations for identifying the root of the process (the program control), which nodes represent free or restricted names, and so on. instead, the second encoding figure 11(b) is more convenient and elegant as it gets rid of the axioms for parallel composition by graph isomorphism, only. in addition, a suitable interface allows to see the whole graph as a process with well-identified root control and free names. when the language is a process calculus, the encoding of a state is facilitated by the algebraic structure of states (i.e. processes are terms) and it is typically defined inductively on such structure. however, the syntax of graph formalisms is often not provided with suitable features for names, name restrictions or hierarchical aspects. typical solutions consist in developing an adhoc algebraic syntax, involving an implicit or explicit structuring of the graph formalism based, e.g., on set-theoretic definition of graphs with interfaces (e.g. [gad03, gm08a]), enriched type systems (e.g. [bs06, gm08b]) or tree-based hierarchies (e.g. [jm03, gm08a]). the less structured the underlying graphs are, the more cumbersome the encodings and their correctness proof become. a disciplined graph algebra provides in some sense a structured view of graphs and their legal compositions that facilitates the visual specification of processes and simplifies the proofs of correctness: the algebraic structure of both states and graphs enables proofs by structural induction and defines a bijection between processes and graphs. one important advantage of graphical encodings is the intuitive visual modeling of complex systems, where the graph itself should offer an immediate characterisation of the represented system. this fact has been exploited with success, e.g., in the modeling of process calculi. in the case of process calculi for modern systems like those around global computing and service oriented paradigms, there are some notions like sessions, transactions and nested compensations that require logical grouping of components or some notion of containment. for example, when a transaction is aborted it is important that all participants counteract. again, when flat graphs are considered, some ad hoc encoding of containment is necessary. the literature provides some examples that witness the convenience of structuring graphs for encoding process calculi. for instance, the encoding of the pi-calculus of [gad03] which is based on a notion of graphs with interfaces for the free nodes of a graph (i.e. the free names of a process) has been simplified in [bgl09] with a richer notion of interface distinguishing nodes for the program control and the names. examples also exist for bigraphs, where restricted, more structured subsets of the bigraphs have been used to conveniently model different process calculi [bs06, gm08b]. proc. gt-vmt 2009 16 / 20 eceasst 8 conclusion we have discussed the advantages of structured graphs in up to ten different aspects of the graphbased engineering of software systems. our arguments are mainly inspired by the various approaches to structured (possibly hierarchical) graphs that can be found in the literature. it is out of the scope of this paper to overview all of them. interested readers are referred to bigraphs [jm03], hierarchical graph transformation [dhp02, dhj+08], shaped graphs [hm04] and the references therein. the main source of inspiration, however, is our own contribution to this field which is called architectural design rewriting (adr) [blmt08]. adr is a proposal for the design of complex software systems. the key features of adr are: 1) hierarchical graphs with interfaces; 2) algebraic presentation; 3) inductively-defined reconfigurations. roughly, the underlying model consists of some kind of interfaced graphs whose inner items represent the architectural units and their interconnections and whose interface expresses the overall type and its connection capabilities. architectures are designed inductively by a set of productions which enable: top-down refinement, like replacing an abstract component with a possibly partial realisation; bottom-up typing, like inferring the type of an actual architecture; well-formed composition, like composing some well-typed actual architectures together so to guarantee that the result is still well-typed. in the functional reading, the set of productions defines an algebra of terms, each providing a proof of style conformance. hence, the interpretation of a proof term is the actual architecture. the dynamics is then expressed by term rewrite rules acting over proof terms rather than over actual architectures. this has many advantages, like guaranteeing that all reconfigurations are style-preserving by construction. the flexibility of adr has been validated over heterogeneous models such as network topologies, architectural styles and modelling languages. a prototypical implementation of adr is also being developed using maude [cde+07], a high-performance tool implementing rewriting logic [mr07] and well suited for the approach as it offers native features such as conditional rewrite rules and built-in tools such as an ltl model checker. as an example, we have developed a simple visualiser of algebraic specifications of hierarchical graphs. the web site of adr (http://www.albertolluch.com/research/adr) makes both tools available and provides links to several additional resources. there are still some open challenges in the field of graphs and graph transformation systems: mimicking standard and advanced term rewrite techniques such as structural operational semantics or symbolic semantics, representation of complex models from service oriented applications to biological systems, and so on. we expect that in all cases, the use of structured, hierarchical graphs will play a fundamental role. acknowledgements: research on adr is supported by eu fet-gc2 ip project sensoria, ist-2005-016004. the work on adr has been done in collaboration with several colleagues, with whom we have been honoured to exchange many ideas, compare different perspectives and approaches, share stress and friendship and whose contribution has been fundamental for the topics of the talk of the first author and the paper: ugo montanari, emilio tuosto, fabio gadducci, antonio bucchiarone, stefania gnesi and dan hirsch. 17 / 20 volume 18 (2009) http://www.albertolluch.com/research/adr ten virtues of structured graphs the first author would also like to thank gt-vmt 2009 chairs artur boronat and reiko heckel for their kind invitation to present this work. bibliography [bbg+08] r. bruni, a. bucchiarone, s. gnesi, d. hirsch, a. lluch-lafuente. graph-based design and analysis of dynamic software architectures. in degano et al. (eds.), concurrency, graphs and models, essays dedicated to ugo montanari on the occasion of his 65th birthday. lect. notes in comput. sci. 5065, pp. 37–56. springer verlag, 2008. [bbgm08] r. bruni, a. bucchiarone, s. gnesi, h. melgratti. modelling dynamic software architectures using typed graph grammars. in koenig et al. (eds.), proceedings of gtvc’07. elect. notes in th. comput. sci. 213.1, pp. 39–53. elsevier science, 2008. [bck08] p. baldan, a. corradini, b. könig. unfolding graph transformation systems: theory and applications to verification. in degano et al. (eds.), concurrency, graphs and models, essays dedicated to ugo montanari on the occasion of his 65th birthday. lect. notes in comput. sci. 5065, pp. 16–36. springer verlag, 2008. [bckl07] p. baldan, a. corradini, b. könig, a. lluch-lafuente. a temporal graph logic for the verification of graph transformation systems. in proceedings of wadt’06. lect. notes in comput. sci. 4409, pp. 1–20. springer verlag, 2007. [bgl09] r. bruni, f. gadducci, a. lluch-lafuente. graphical representation of process calculi via an algebra of hierarchical graphs. 2009. manuscript available at http: //www.albertolluch.com/papers/adr.algebra.pdf. [bh04] l. baresi, r. heckel. tutorial introduction to graph transformation: a software engineering perspective. in ehrig et al. (eds.), proceedings of icgt’04. lect. notes in comput. sci. 3256, pp. 431–433. springer verlag, 2004. [bhtv04] l. baresi, r. heckel, s. thöne, d. varró. style-based refinement of dynamic software architectures. in proceedings of wicsa’04. pp. 155–166. ieee computer society, 2004. [blm09] r. bruni, a. lluch-lafuente, u. montanari. hierarchical design rewriting with maude. in rosu (ed.), proceedings of wrla’08. elect. notes in th. comput. sci. 238.3, pp. 45–62. elsevier science, 2009. [blmt08] r. bruni, a. lluch-lafuente, u. montanari, e. tuosto. style-based architectural reconfigurations. bulletin of the eatcs 94:161–180, 2008. [bp05] l. baresi, m. pezzè. from graph transformation to software engineering and back. in formal methods in software and systems modeling, essays dedicated to hartmut proc. gt-vmt 2009 18 / 20 http://www.albertolluch.com/papers/adr.algebra.pdf http://www.albertolluch.com/papers/adr.algebra.pdf eceasst ehrig, on the occasion of his 60th birthday. lect. notes in comput. sci. 3393, pp. 24–37. springer verlag, 2005. [bs06] m. bundgaard, v. sassone. typed polyadic pi-calculus in bigraphs. in proceedings of ppdp’06. pp. 1–12. acm, 2006. [cc03] l. caires, l. cardelli. a spatial logic for concurrency (part i). inf. comput. 186(2):194–235, 2003. [cde+07] m. clavel, f. durán, s. eker, p. lincoln, n. martı́-oliet, j. meseguer, c. talcott. all about maude a high-performance logical framework. lncs 4350. springer, 2007. [cmr+97] a. corradini, u. montanari, f. rossi, h. ehrig, r. heckel, m. löwe. algebraic approaches to graph transformation part i: basic concepts and double pushout approach. in handbook of graph grammars. pp. 163–246. 1997. [cou97] b. courcelle. the expression of graph properties and graph transformations in monadic second-order logic. in handbook of graph grammars and computing by graph transformation. pp. 313–400. world scientific, 1997. [dbl] dblpvis homepage. http://dblpvis.uni-trier.de/. [dhj+08] f. drewes, b. hoffmann, d. janssens, m. minas, n. van eetvelde. shaped generic graph transformation. in proceedings of agtive’07. lect. notes in comput. sci. 5088, pp. 201–216. springer verlag, 2008. [dhp02] f. drewes, b. hoffmann, d. plump. hierarchical graph transformation. journal on computer and system sciences 64(2):249–283, 2002. [dot] graphviz homepage. http://www.graphviz.org/. [ehk+97] h. ehrig, r. heckel, m. korff, m. löwe, l. ribeiro, a. wagner, a. corradini. algebraic approaches to graph transformation part ii: single pushout approach and comparison with double pushout approach. in handbook of graph grammars. pp. 247–312. world scientific, 1997. [ek06] h. ehrig, b. könig. deriving bisimulation congruences in the dpo approach to graph rewriting with borrowed contexts. mathematical structures in computer science 16(6):1133–1163, 2006. [fhl+06] g. l. ferrari, d. hirsch, i. lanese, u. montanari, e. tuosto. synchronised hyperedge replacement as a model for service oriented computing. in proceedings of fmco’05. lect. notes in comput. sci. 4111, pp. 22–43. springer verlag, 2006. [gad03] f. gadducci. term graph rewriting for the pi-calculus. in proceedings of aplas’03. lect. notes in comput. sci. 2895, pp. 37–54. springer verlag, 2003. 19 / 20 volume 18 (2009) http://dblpvis.uni-trier.de/ http://www.graphviz.org/ ten virtues of structured graphs [gm08a] f. gadducci, g. v. monreale. a decentralized implementation of mobile ambients. in ehrig et al. (eds.), proceedings of icgt’08. lect. notes in comput. sci. 5214, pp. 115–130. springer verlag, 2008. [gm08b] d. grohmann, m. miculan. an algebra for directed bigraphs. in proceedings of termgraph’07. elect. notes in th. comput. sci. 203.1, pp. 49–63. elsevier science, 2008. [gml] gml homepage. http://graphml.graphdrawing.org/. [gra] graphml homepage. http://www.infosun.fim.uni-passau.de/graphlet/gml/gml-tr. html. [hab92] a. habel. hyperedge replacement: grammars and languages. springer-verlag new york, inc., secaucus, nj, usa, 1992. [hm04] d. hirsch, u. montanari. shaped hierarchical architectural design. in proceedings of gt-vmt’04. elect. notes in th. comput. sci. 109, pp. 97–109. elsevier science, 2004. [jac06] d. jackson. software abstractions: logic, language and analysis. mit press, 2006. [jm03] o. h. jensen, r. milner. bigraphs and mobile processes. technical report 570, computer laboratory, university of cambridge, 2003. [mes98] j. meseguer. membership algebra as a logical framework for equational specification. in parisi-presicce (ed.), proceedings of wadt’97. lect. notes in comput. sci. 1376, pp. 18–61. springer verlag, 1998. [mét98] d. l. métayer. describing software architecture styles using graph grammars. ieee trans. software eng. 24(7):521–533, 1998. [mr07] j. meseguer, g. rosu. the rewriting logic semantics project. tcs 373(3):213–237, 2007. proc. gt-vmt 2009 20 / 20 http://graphml.graphdrawing.org/ http://www.infosun.fim.uni-passau.de/graphlet/gml/gml-tr.html http://www.infosun.fim.uni-passau.de/graphlet/gml/gml-tr.html introduction understanding graphs: parsing and browsing designing graphs requirements and specification abstraction and refinement composition analysing graphs model construction model conformance transforming graphs behaviour reconfiguration and refactoring analysing graph transformations visual encoding of process calculi conclusion well-formed model co-evolution with customizable model migration this work was partially funded by nfr project 194521 (formgrid) electronic communications of the easst volume 58 (gt-vmt 2013) proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gtvmt 2013) well-formed model co-evolution with customizable model migration florian mantz, gabriele taentzer, yngve lamo 13 pages guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst well-formed model co-evolution with customizable model migration ∗ florian mantz1, gabriele taentzer21, yngve lamo1 1 fma@hib.no, yla@hib.no institutt for data og realfag høgskolen i bergen, norway 2 taentzer@informatik.uni-marburg.de fachbereich mathematik und informatik philipps-universität marburg, germany abstract: model-driven engineering (mde) is a software engineering discipline which focuses on models as the primary artifact of the software development process while programs are mainly generated by means of model-to-code transformations. in particular, modeling languages tailored to specific domains promise to increase the productivity and quality of software. nevertheless due to e.g. evolving requirements, modeling languages evolve and existing models have to be migrated. corresponding manual model migration is tedious and error-prone, therefore tools have been developed to (partly) automate this process. we follow the idea of considering such modeling language and model co-evolutions as related graph transformations ensuring a correct and unique typing of migrated models. in this paper, we present a general and formal construction of well-formed model migration schemes that are able to co-adapt any model of a given modeling language to a performed meta-model change. we show how appropriate model migration schemes can be constructed and discuss how they may be customized. keywords: meta-model evolution, model migration, graph transformation 1 introduction model-driven engineering [fow10] (mde) is a software engineering discipline which raises the abstraction level in software development by using models as primary artifacts. in particular, domain-specific modeling languages (dsmls) are means to increase productivity and quality of software. developers can focus on their essential tasks while repetitive and technologydependent artifacts are automatically generated by transformations specified by experts in these areas. to keep this high level of abstraction, a modeling language has to evolve simultaneously to the evolving understanding of its target domain. however, this often causes trouble since existing models need to co-evolve with their languages (see. figure 1). this evolution-migration problem has been tackled in practice with the result that tools have been developed that (partially) automate this tedious and error-prone process (see e.g. [hbj09, rkpp10]). in current approaches however, parts of model migrations still have to be specified manually. in our work, ∗ this work was partially funded by nfr project 194521 (formgrid) 1 / 13 volume 58 (gt-vmt 2013) mailto:fma@hib.no mailto:yla@hib.no mailto:taentzer@informatik.uni-marburg.de well-formed model co-evolution with customizable model migration we support this step by generating default migration rule schemes for arbitrary meta-model evolution steps. these rule schemes may be customized by the user as long as the given correctness criteria are satisfied.�� ��modeling language evolution // �� ��modeling language′ �� ��model conforms to oo migration +3 �� ��model′ conforms to oo �� figure 1: model co-evolution: modeling language evolution and model migration modeling languages in mde are usually defined by meta-models. hence, the challenge of modeling language evolution in mde is often referred to as the problem of meta-model evolution with corresponding model migration. we tackle this model co-evolution challenge by using algebraic graph-transformations [eept06]. more specifically, we employ a variant of the classical double-pushout (dpo) approach using co-span rules [ehp09] offering a better synchronization of deletion and creation actions than the usual dpo approach [tml12]. for example, moving an element can be easier represented by first adding a new copy of the element before deleting its old version. in the co-span approach, the intermediate graph contains the whole context while in the span approach, it contains the preserved part only. this context can be advantageously used to formulate adequate model migrations. our earlier work in [tml12, mtl12] presents a general framework of co-transformations by graph transformations where meta-model evolutions and model migrations are defined as inter-related graph transformations. this framework allows for migration variants. it also shows how model migrations can be derived automatically from meta-model evolutions resulting in model-specific migration rules. in this paper, we go a step further and present model-independent migration schemes. given an evolution rule, a default migration scheme is automatically deduced and may be customized to special needs. while the default migration scheme replays changes in the evolution rule as far as possible, potential customizations may follow special strategies to insert new model elements or to glue existing ones. evolutions that need custom migration schemes are e.g. the insertion of a new objects of singleton classes such as registries, the insertion of new containers, new acyclic connections between model elements, new connections to existing model elements, etc. roughly spoken, customization of migration schemes is needed whenever the insertion of new elements and gluing of existing ones need to fulfill special requirements. after the customization phase, the adapted migration scheme is applied to a specific meta-model evolution and a specific instance model. we show how a well-formed, model-specific migration rule can be deduced automatically and then applied. 2 evolution scenario in the following, we consider a small example describing a co-evolution scenario of colored petri nets [jen03]. figure 2 shows a simplified meta-model for colored petri nets and an instance model, i.e. a petri net. the petri net variant in figure 2 supports weighted arcs as well as colored proc. gtvmt 2013 2 / 13 eceasst tokens. the meta-model and the example petri net are presented in abstract and concrete syntax. while we are working with the abstract syntax (on the right) in our theory, meta-models and models are also shown in concrete syntax (on the left) to give the reader an intuition how they are usually presented to a modeler. to illustrate our approach, the small evolution scenario covers several steps: petri nets shall be equipped with containers for places and transitions. the container insertion is done in two steps: first, a model container is inserted for all places and second, transitions are also put into those containers. third, the attribute “color” is moved from “place” to “token”. meta-model evolutions and model migrations are formulated by rule-based transformations, i.e. evolution and migration rules specify corresponding changes. figure 3 shows the insertion of a new container for places as example cotransformation depicting models in abstract syntax. figure 2: petri net meta-model with an instance model c1@place:class transition:node ptarc:class tparc:class int:datatype weight:attr token:class string:datatype weight:attr src:ref src:ref trg:ref trg:ref tokens: ref color:attr c2@container:class r1@places: ref 1@:place :ptarc :tparc 2@:place :transition :src :trg:weight 2:int :token:tokens "green":string :tparc 3@:place 1:int :color :src :src :trg :trg :token :tokens "red":string :color 4@:container 7@:has 6@:has5@:has c2:class r1:ref c1:class 7:r1 3:c1 6:r1 2:c14:c2 5:r1 1:c1 ti tu i u c1@place:class transition:node ptarc:class tparc:class int:datatype weight:attr token:class string:datatype weight:attr src:ref src:ref trg:ref trg:ref tokens: ref color:attr c1:class tl tg tm tl ti tg 1@:place :ptarc :tparc 2@:place :transition :src :trg:weight 2:int :token:tokens "green":string :tparc 3@:place 1:int :color :src :src :trg :trg :token :tokens "red":string :color 1:c1 2:c1 3:c1 l g m l i g e v o lu ti o n m ig ra ti o n r1=has, c2=container figure 3: co-transformation example: insertion of a container for places the upper layer shows the meta-model evolution where a new container for places is inserted. 3 / 13 volume 58 (gt-vmt 2013) well-formed model co-evolution with customizable model migration the lower layer shows the migration of a specific petri net model (introduced in figure 2) where one container is inserted for all its places. note that graph mappings are encoded in graph element names: strings before “@” indicate graph mappings within one layer while strings after “@” and before ’‘:” of meta-model elements as well as strings after “:” of instance model elements are used to indicate the typing of instance model elements (i.e. graph mappings between layers). evolution rule (given) migration multi-rule migration multi-rule (generated) model-independent migration scheme kernel-rule (user defined) model-independent migration scheme (customized) migration multi-rules model-specific migration scheme for example petri-net customization (manual) application tl ti c2:class r1:ref c1:class tl c1:class prio 1 l i 2:c2 :r1 1:c1 l 1:c1 1 l i 5:r1 1:c14:c2 l 1:c1 1 kernel-rule i 4:c2 l l1'l i 2:c2 l 1' l i 6:r1 2:c14:c2 l 2:c1 2 l i 7:r1 3:c14:c2 l 3:c1 3 prio 1 l i :c2 :r1 1:c1 l 1:c1 1 1 1 1 1 1' 1' 1' 1' 1 1 22 3 3 figure 4: migration schemes for adding a new model element since migration rules have to specify all model changes, they are model-specific and typically grow with increasing model sizes. therefore, we are looking for a model-independent solution to specify model migrations. this leads us to migration schemes. an example migration scheme for the insertion of a new class is shown in figure 4 in the lower left corner. it just consists of one basic migration rule to be applied multiple times , hence it is called a multi-rule. migration rules are typed by evolution rules. in this example, the migration rule is isomorphic to its evolution rule. the rule specifies the basic action during migration: insertion of a new element connected to the old one. applying this multi-rule as often as possible to all places in a petri net would give us a new container for each match of the rule. this is not exactly what we want to have. actually, the new element should be the same for all matches. therefore, we customize the migration scheme to this special need and add a so-called kernel rule specifying that all new elements shall be glued to one. (see the migration scheme in the middle of figure 4.) this customization suits well to the first evolution step where a new container (and only one) is inserted for all places. on the right, we see a migration scheme being specific for model g in figure 3 where three places occur. therefore, three copies of the multi-rule are in that scheme and each one is applied exactly once. gluing all these rules at the kernel rule yields the migration rule in figure 3. since the connection of elements to an existing container can be handled similarly to its insertion, it is left out here, due to space limitations. the third step is considerably different and discussed in the following. figure 5 shows an evolution rule for moving an attribute from one class to another one. the corresponding default migration scheme contains 6 multi-rules: we start with an isomorphic copy of the evolution rule. to ensure that all elements typed by the evolution rule are matched, we need to add sub-rules for each connected component of the rule. in this case, each sub-rule is an identity rule, hence we only show their left-hand side. we priproc. gtvmt 2013 4 / 13 eceasst oritize the rules based on their inclusions. the one with the highest priority is an exact copy of the evolution rule. all others are identity rules and have lower priorities. their purpose is to complete the scheme such that also parts of t l can be identified for migration and potentially deleted. for example, rule r3 being the identity on l3, is needed to identify all old attributes to be removed (although not moved to another class but deleted by default). rules with higher priority are matched first. all rules in one priority class can be matched in parallel. and furthermore, a rule is matched only if its match is not already completely covered by a previous match. applying this scheme to petri nets, the color attribute may be moved from “place” to “token” and is removed from places even without connected “token”-element to remain well-typed. e v o lu ti o n r u le m ig ra ti o n m u lt ir u le s tl tr prio 1 id l i 1:c1 4:r1 5:a1 3:d1 2:c2 :a2 l 1:c1 4:r1 5:a1 3:d1 2:c2 1 1 1 prio 3 l6 ti c1:class r1:ref a2:attr d1:datatype c2:class a1:attr tl c1:class r1:ref a2:attr d1:datatype c2:class trr1:ref c1:class d1:datatype c2:class a1:attr 3:a1 2:d1 1:c1 1:c1 id prio 2 ll2 3 3:r1 2:c2 id l4 1:c1 1:d1 1:c2 id l5 id model-independent migration scheme figure 5: migration rule derivation 3 meta-model evolution with model migration by co-transformation first, we recall the basic definitions of co-span transformations and co-transformations as defined in [ehp09, tml12, mtl12]. co-span transformations are analog to usual dpo transformations with the exception that they use co-spans instead of spans, i.e. additions are performed before deletions. co-transformations are the formal framework we use to formulate model co-evolution. we choose the usual category of graphs and graph morphisms as the underlying category (for details see [eept06]). definition 1 (graph) a graph g = (gv ,ge,srcg,trgg) consists of a set gv of vertices (or nodes), a set ge of edges (or arrows), and two maps srcg,trgg : ge →gv assigning the source and target to each edge, respectively. e : x → y denotes an edge e with srcg(e) = x and trgg(e) = y. definition 2 (graph morphism) a graph morphism g : g → h consists of a pair of maps gv : gv → hv , ge : ge → he preserving the graph structure, i.e., for each edge e : x → y in g we have an edge ge(e) : gv (x)→ gv (y) in h with gv ◦srcg = srch ◦ge and gv ◦trgg = trgh ◦ge . as mentioned before, the migration procedure constructs migration schemes that rely heavily on connected components. 5 / 13 volume 58 (gt-vmt 2013) well-formed model co-evolution with customizable model migration definition 3 (connected component) given a graph h, we define an equivalence relation on vertices ≡⊆ hv ×hv where ≡ is the transitive closure of ∼ with v1 ∼ v2 ⇐⇒ ∃e : v1 → v2 ∈ he or ∃e : v2 → v1 ∈ he . let [v]≡⊆ hv denote an equivalence class of ≡. a complete subgraph g v h over [v]≡ is called a connected component. note that each vertex (and edge) belongs to exactly one connected component. note further that injective morphisms are denoted by “�”, surjective morphisms by “�”, bijective morphisms by their combination, and inclusions by “↪→”. definition 4 (co-span transformation rule) a co-span transformation rule p = l l→ i r � r consists of graphs l (left-hand-side), i (interface), and r (right-hand-side) and two jointly surjective morphisms l and r where r is injective. if r is bijective a rule p is called non-deleting and can be written as l = l → i. in the case of non-deleting rules we also call i right-hand-side. definition 5 (co-span transformation) given a co-span transformation rule p = l l→ i r � r together with an injective morphism m : l � g, called match, rule p can be applied to g if a co-span double-pushout exists as shown in the diagram on the right. t : g p,m =⇒ h is called a co-span transformation. l �� m �� l // (po1) i �� i �� (po2) r �� m′ �� ooroo g g // u hoo h oo the co-span double pushout exists if the co-span gluing condition holds (see [ehp09, mtl12] for more details). note that morphism l is allowed to be non-injective which means that graph elements may also be glued during evolutions. co-span transformations are used to define cotransformations formalizing meta-model evolutions and their corresponding model migrations in a rule-based manner. definition 6 (co-transformation rule) a co-span rule t p = t l tl→ t i tr � t r together with a co-span rule p = l l→ i r � r form a co-transformation rule (t p, p), if there are graph morphisms tl : l → t l,ti : i → t i and tr : r → t r such that both squares in the diagram on the right commute. in such a cot l tl // = t i = t rootroo l l // tl oo i ti oo roor oo tr oo transformation rule (t p, p), rule t p is called an evolution rule while rule p is called a migration rule wrt. t p. we also say that migration rule p is well-typed wrt. t p. definition 7 (match of co-transformation rule) a match (tm,m) of a co-transformation rule (t p, p) is given by two corresponding matches tm : t l � t g of the evolution rule t p and m : l � g of the migration rule p so that the matches together with the typing morphisms tl : l → t l and tg : g → t g construct a commuting square: tm◦tl = tg ◦m. if g m � l tl→ t l is a pullback then the match is called complete. t l // tm // t g = l // m // tl oo g tg oo definition 8 (co-transformation) a co-transformation (tt,t) is defined by two graph transformations tt : t g t p,tm =⇒ t h and t : g p,m =⇒ h that apply a co-transformation rule (t p, p) via match (tm,m) simultaneously to type graph t g and its instance graph g, so that there are graph morphisms tu : u → t u and th : h → t h such that all faces of figure 6 commute. in such a co-transformation (tt,t), the type graph transformation tt : t g t p,tm =⇒ t h is called an evolution proc. gtvmt 2013 6 / 13 eceasst while the instance graph transformation t : g p,m =⇒ h is called a migration wrt. tt. t g t l t u t i t h t r po1tt po2tt tm tl tr g l u i h r po1t po2t m l r tg tl ti tr figure 6: co-transformation an example of a co-transformation is given in section 2 illustrated by figure 3. since the example co-evolution step does not delete anything, the right cube is the identity. therefore, the left cube is shown only. 4 migration schemes and automatic model migration in the following, we present a model-independent solution to specify model migrations by socalled migration schemes. the concept of migration scheme builds up on interaction schemes used to specify amalgamated graph transformation as presented in e.g. [tae96]. for a better understanding, we recall basic definitions of kernel and multi-rules and interaction schemes, here for non-deleting rules. thereafter, model-independent and later model-specific migration schemes are defined as special interaction schemes. migration schemes cover the insertion and gluing of graph elements only, while their deletion is done by a pullback construction. the reason for this design decision is the observation that deletions in meta-model evolutions have to be completely reflected by their model migration while this is not true for insertions and gluings. new meta-model elements, for example, need not cause any changes in models but they may. hence, we define a default migration scheme for a given evolution rule and allow that it may be customized under certain conditions (see section 5 for allowed customizations). in the following, we distinguish multi-rules to be applied as often as possible from kernel rules that are needed to glue newly inserted elements such that they are only inserted once for several multi-rules matches overlapping in the left-hand-side of the kernel rule. definition 9 (kernel morphism for non-deleting rules) given non-deleting rules l1 : l1 → i1 (called kernel rule) and l2 : l2 → i2 (called multi-rule), a kernel morphism k : l1 → l2 is a pair (a,b) of morphisms a : l1 → l2 and b : i1 → i2 such that (1) is commuting. l1 l1 // (1)a �� i1 b �� l2 l2 // i2 definition 10 (interaction scheme of non-deleting rules) given a set k of non-deleting kernelrules, a set m of non-deleting multi-rules and a set km of kernel morphisms k : lk → lm from k to m with lk ∈ k and lm ∈ m. an interaction scheme of non-deleting rules is a triple (k,m,km). three examples for interaction schemes of non-deleting rules are given in figure 4. these are 7 / 13 volume 58 (gt-vmt 2013) well-formed model co-evolution with customizable model migration the model-independent migration schemes on the left and in the middle of the figure as well as the model-specific one on the right. in the following, we construct special interaction schemes for model migrations, so-called migration schemes. given an evolution rule t l → t i, a default migration scheme is constructed by defining multi-rules for all connected subgraphs of t l and their extensions by connected parts in t i. we consider connected graphs due to the assumption that they define model parts that belong together. including multi-rules over all subgraphs of connected components ensures that also partial patterns are recognized and adequately migrated in model-specific migration rules. in addition, loop edges in meta-models may have instances not being loops. those cases also have to be covered by migration rules. kernel rules are considered to be all empty by default. definition 11 (default migration scheme) given a non-deleting evolution rule t p : t l → t i, the default migration scheme (k,m,km)t p for rule t p is constructed by the following steps: 1. construct a set ml of multi-rule left-hand sides by creating all possible connected subgraphs of t l. for each loop in t l, a left-hand-side is added containing a graph that has only one unfolded edge: ml :={l v t l | l is connected} ∪ mlloop mlloop :={le ={e : v1 → v2},lv ={v1,v2}∀e ∈ t l with srct l(e) = trgt l(e)} in addition, prio : ml →n defines the priority function with prio(li) > prio(l j) if li a l j. 2. construct a set of non-deleting multi-rules: first construct ∀ l ∈ (ml\mlloop) a graph il with: ilv = t iv \tl(t lv \tl(lv )) ile ={e ∈ t ie \tl(t le \tl(le)) | src t i(e)∈ ilv ∧trg t i(e)∈ ilv} il completes tl(l) by the new elements of t i. t l tl // t i l l // ?� tl oo = il ?� ti oo m :={ll : l → π(tl(l),il) | l ∈ (ml\mlloop) and ll = tl|li} ∪ mloop mloop :={idl : l → l | l ∈ mlloop} where π(u,h) denotes the connected component of h that contains uv if u v h. 3. ∀ l : l → i ∈ m : ∃inl : l ↪→ t l and ini : i ↪→ t i being the typing morphisms. 4. set k ={/0 : /0 → /0} contains the empty kernel rule /0 as default. 5. km ={/0l : /0 → l | ∀l ∈ m} is the default set of kernel morphisms. given a default migration scheme, a meta-model evolution, and an instance model, the modelspecific migration rule is constructed by matching all multi-rules as often as possible such that matches are not completely covered by other matches. computing the intersection for each two matches, applications of multi-rules can be synchronized by common kernel rules. if available, a proc. gtvmt 2013 8 / 13 eceasst suitable kernel rule is selected from the given migration scheme. otherwise, it is constructed by epi-mono-factorization. this means that the intersection graph is taken as left-hand side and its potential gluing in its multi-rules is reflected in the right-hand side of its kernel rule. the result of this construction is a model-specific migration scheme containing multi-rules as often as they can be matched. for an example, consider the scheme on the right of figure 4. definition 12 (model-specific migration scheme for graphs) let (k,m,km)t p be a default migration scheme over evolution rule t p = (t l tl→ t i tr � t r) and let tt : t g t p,tm =⇒ h be an evolution step. furthermore, let g be a graph typed by t g, i.e.tg : g → t g: 1. match all multi-rules lu : lu → iu ∈ m to g and construct match set mm =: {mi : li � g | 1 ≤ i ≤ n} such that: ∀li with 1 ≤ i ≤ n =⇒ ∃lu : lu → iu ∈ m, li = lu and @ m j ∈ mm with mi(li)v m j(l j) t g t lootmoo g oo = lioo mioo oo tli oo l joo @m j ^^ `` `` pp tl j bb 2. let li ai j � li j a ji � l j be the pullback of li mi � g m j � l j, ∀1 ≤ i < j ≤ n. ∀li j with 1 ≤ i < j ≤ n: (a) if ∃ ls : ls → is ∈ k with li j = ls and ∃(a : ls → lu,b : is → iu)∈ km and ai j = a, li = lu. =⇒ ki j = (ai j,bi j) ∈ km with bi j = b and li j : li j → ii j with ii j = i s be in k. (analogously for k ji). (ki j,k ji)∈ km ls l s // �� ���� = �� auv �� is �� ���� �� buv �� li j li j // �� =ai j �� = ii j �� bi j= �� li li // ii lu l u // oo oooo = iu oo oooo (b) otherwise generate a kernel rule: construct (ii j, li j : li j → ii j, bi j : ii j → ii) by epi-monofactorization of li ◦ ai j. in this case, li j : li j → ii j ∈ k and ki j = (ai j,bi j). (analogously for k ji ∈ km). then, (ki j,k ji)∈ km li j li j // �� ai j �� li◦ai j ii j �� bi j �� li li // ii this yields the model-specific migration scheme (k,m,km)tt,g. remark 1 note that the epi-mono-factorization of li ◦ai j yields the same li j : li j → ii j as that of l j ◦a ji does. remark 2 it is obvious that both kinds of migration schemes are interaction schemes of nondeleting rules. having a model-specific migration scheme at hand, it can be glued by so-called star gluings yielding its model-specific migration rule. the basic idea is to glue all multi-rules along their kernel rules. such a gluing diagram can be a kind of star in general. therefore, we re-call the star gluing of graphs. it is shown in [tae96] that the star gluing is a special form of co-limit construction. 9 / 13 volume 58 (gt-vmt 2013) well-formed model co-evolution with customizable model migration definition 13 (star gluing) 1. given a set of graph morphism spans s = (gi gi j ← gi j g ji → g j)1≤i< j≤n, a gluing relation is is the equivalence relation generated by the relation is ={(gi j(x),g ji(x))|x ∈ gi j,1 ≤ i < j ≤ n}. 2. given a set of graph morphism spans s = (gi gi j ← gi j g ji → g j)1≤i< j≤n with its gluing relation is, the star gluing graph g is defined by g = (]1≤i≤ngi)/ims , the quotient set of the disjoint union of all gi. the maps gi : gi → g for all 1 ≤ i ≤ n send each element of gi to its equivalence class in g. the pair (g,{gi|1 ≤ i ≤ n}) is called the star gluing of s. gi j ~~ gi gi !! = g j g j}} g definition 14 (model-specific migration rule) given a model-specific migration scheme (k,m,km)tt,g with match set mm =: {mi : li � g | 1 ≤ i ≤ n} over evolution tt : t g t p,tm =⇒ t h as defined in definition 12. let g be a graph typed by t g, i.e tg : g → t g: 1. take all ai j and a ji as well as bi j and b ji for 1 ≤ i < j ≤ n and construct the star gluings (l,{ai|1 ≤ i ≤ n}) and (i,{bi|1 ≤ i ≤ n}) of morphism stars sl = (li ai j � li j a ji � l j)1≤i< j≤n and si = (ii bi j � ii j b ji � i j)1≤i< j≤n with induced morphism l : l → i. match m of model-specific migration rule l is the induced morphism m : l � g over mm =: {mi : li � g | 1 ≤ i ≤ n}. 2. finally, construct the right-hand side r of the model-specific migration rule as pullback i r � r tr→ t r of i ti→ t i tr � t r (see figure 6). r is the induced morphism of pullback i r � r tr→ t r. the figure on the right shows the double cube of figure 6 using a migration scheme to construct the non-deleting part of model-specific migration rules. morphism r : i � r of the migration rule is constructed by a pullback deleting all instances that cannot be typed over t r. this new construction of migration rules fits to our earlier work in [tml12, mtl12] as shown in the next propositions. hence, a model migration constructed in such a way, is applicable and migrates a model “correctly” (i.e. in a well-typed manner) and in a unique way. t l t i t r t g li l j t u ii i j t h li j ii j g u h l i r tl tr li j l r li l j tg tl ti tr tm m proposition 1 a model-specific migration rule is typed over its evolution rule. proof sketch: since all multi-rules of migration schemes are well-typed (see definition 11) and l and i are star gluing graphs, their typing morphisms tl and ti are induced morphisms. in addition, we have ti ◦ l = tl ◦tl, due to uniqueness of induced morphisms. the existence of tr and ti ◦r = tr◦tr holds due to the pullback construction. proc. gtvmt 2013 10 / 13 eceasst proposition 2 the construction of model-specific migration rules results in complete matches only, i.e. t l tl← l m � g is the pullback of t l tm � t g tg← g (see figure 6). proof sketch: all multi-rule matches in mm induce a unique morphism m : l � g. since the default migration scheme contains a multi-rule for each connected subgraph of t l, all elements of t l that have occurrences in g are matched by multi-rules. hence, the star gluing graph of the left-hand sides of a model-specific migration scheme covers at least the pullback graph. since the overlapping of each two multi-rule matches has to be a pullback, the star gluing graph cannot be larger than the pullback graph. 5 migration scheme customizations although constructed along reasonable design decisions, default migration schemes do not always define desired model migrations. as mentioned in section 2, the insertion of new connected elements have to be limited in some cases, e.g. in case that a singelton class are specified. sometimes they should be glued as in this example, sometimes they should be inserted in certain contexts only. similarly, the gluing of meta-model elements can lead to retyping or gluing of model elements during migration but do not have to. hence variations in migration strategies are possible and it is essential that migration schemes are customizable. however, we want to make sure that such customized migration schemes still satisfies proposition 1 and proposition 2. this means that the set of multi-rules is complete so that it can amalgamate every possible l and that the resulting migration rules are always well-typed over their evolution rules. given a default migration scheme, the following customizations are possible: 1. a multi-rule may be deleted if its lhs can be amalgamated by lhss of other multi-rules. 2. a non-deleting multi-rule may be added if its l and its i are typed over t l and t i, respectively as long as the multi-rule is not conflicting with any other rule. a conflict between two rules occurs if two elements of l are preserved by one rule and merged by the other. 3. graph i of a multi-rule may be extended if its extension is still typed over t i. 4. a kernel rule k : lk → ik with kernel morphism to at least one multi-rule may be added. this means that ik v im if lk v lm with m : lm → im being the corresponding multi-rule. an example for a customized migration scheme is given in the middle of figure 4. here, a new kernel rule with kernel morphism to the existing multi-rule are added. 6 related work co-evolution of structures has been considered in several areas of computer science such as for database schemes, grammars, and meta-models [li99, läm01, sk04]. especially database schema evolution has been a subject of research in the last decades. recently, research activities have started to consider meta-model evolution and to investigate the transfer of schema evolution concepts to meta-model evolution (see e.g. [hbj09]). herrmannsdoerfer et al. provides an overview of approaches in [hvw10] that considers the coupled evolution of meta-models and 11 / 13 volume 58 (gt-vmt 2013) well-formed model co-evolution with customizable model migration models. inspired by the achievements for databases, current approaches for meta-model evolution use libraries and catalogs for co-evolution operations. however, meta-model evolution researchers have realized that a fixed set of co-evolution operators is not sufficient and allow therefore to extend or adapt the default migration transformations. there are several tools around that consider the co-evolution of eclipse modeling framework (emf) models. cope (now:edapt) [hbj09] provides a rich set of co-evolution operators that implement evolution and migration definitions. if the required migration is not available, a modeling language designer has to add the migration strategy as a groovy/java program. epsilon flock [rkpp10] is another tool that is able to migrate emf models. in contrast to cope, flock does not provide migration operations. instead, it uses a “conservative copy” strategy that automatically copies as much as possible to a migrated version of the model. however, migration scripts have to be written if model elements shall be moved and not forgotten, while pull up and push down attribute are correctly migrated by the conservative copy strategy. emf migrate [emf] is another migration tool for emf. it supports not only on model migration but also the migration of other meta-model-dependent artifacts such as atl transformations. for model migration, emf migrate provides migration libraries that can be customized and extended. our work differs from this related work in the sense that we consider correctness criteria on a formal level to be applied to show correctness of co-transformations in general as well as for user adaptations. furthermore, we develop a strategy for deriving model migration schemes that are not only working for pre-defined migration operations but allow user-defined meta-model evolution rules with deduced migration schemes. the closest work to ours is the one by könig et al. [kls11]. they also consider correctness criteria for model co-evolution based on a categorical framework. however, they do not work with algebraic graph transformation and do not provide customizable rule schemes for model migration. 7 conclusion and future work the evolution of meta-models along well-defined transformation steps does not always yield meaningful model migrations automatically. while default migration schemes can be automatically deduced from evolution rules, it is up to language designers to customize them to their specific needs. in this paper, we clarify how migration schemes can be defined and how they may be customized to still yield well-defined co-transformations of models and meta-models. model-specific migration rules are shown to be automatically constructible from a migration scheme, a meta-model evolution, and an instance model. in the future, we want to extend this work on model migration schemes to more powerful forms of graphs and rules taking especially node type inheritance, application conditions and constraints into account. furthermore, we want to consider further co-evolution examples to evaluate available forms of supported model migration schemes and their customization facilities. moreover, we started to a prototype implementation of our co-evolution approach being very close to its formal foundation and hence, supporting well-formed model migrations. proc. gtvmt 2013 12 / 13 eceasst bibliography [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer, march 2006. [ehp09] h. ehrig, f. hermann, u. prange. cospan dpo approach: an alternative for dpo graph transformation. eatcs bulletin 98:139–149, 2009. [emf] emf migrate. project web site. http://www.emfmigrate.org. [fow10] m. fowler. domain-specific languages. addison-wesley professional, 2010. [hbj09] m. herrmannsdoerfer, s. benz, e. jürgens. cope automating coupled evolution of metamodels and models. in drossopoulou (ed.), ecoop 2009. lncs 5653, pp. 52–76. springer, 2009. [hvw10] m. herrmannsdoerfer, s. vermolen, g. wachsmuth. an extensive catalog of operators for the coupled evolution of metamodels and models. in malloy et al. (eds.), sle 2010. lncs 6563, pp. 163–182. springer, 2010. [jen03] k. jensen. coloured petri nets. springer, 2003. [kls11] h. könig, m. löwe, c. schulz. model transformation and induced instance migration: a universal framework. in silva simão and morgan (eds.), sbmf 2011. lncs 7021, pp. 1–15. springer, 2011. [läm01] r. lämmel. grammar adaptation. in oliveira and zave (eds.), fme 2001. lncs 2021, pp. 550–570. springer, 2001. [li99] x. li. a survey of schema evolution in object-oriented databases. in tools 1999. pp. 362–371. ieee computer society, 1999. [mtl12] f. mantz, g. taentzer, y. lamo. co-transformation of type and instance graphs supporting merging of types with retyping: long version. technical report, department of mathematics and computer science, university of marburg, germany, september 2012. www.uni-marburg.de/fb12/forschung/berichte/berichteinformtk. [rkpp10] l. rose, d. kolovos, r. f. paige, f. a. c. polack. model migration with epsilon flock. in tratt and gogolla (eds.), icmt 2010. lncs 6142, pp. 184–198. springer, 2010. [sk04] j. sprinkle, g. karsai. a domain-specific visual language for domain model evolution. journal of visual languages and computing 15(3–4):291–307, 2004. [tae96] g. taentzer. parallel and distributed graph transformation: formal description and application to communication-based systems. phd thesis, technical university of berlin, 1996. [tml12] g. taentzer, f. mantz, y. lamo. co-transformation of graphs and type graphs with application to model co-evolution. in ehrig et al. (eds.), icgt 2012. lncs 7562, pp. 326–340. springer, 2012. 13 / 13 volume 58 (gt-vmt 2013) http://www.emfmigrate.org www.uni-marburg.de/fb12/forschung/berichte/berichteinformtk introduction evolution scenario meta-model evolution with model migration by co-transformation migration schemes and automatic model migration migration scheme customizations related work conclusion and future work scalable software testing and verification for industrial-scale systems: the challenges electronic communications of the easst volume 77 (2019) interactive workshop on the industrial application of verification and testing, etaps 2019 workshop (interavt 2019) scalable software testing and verification for industrial-scale systems: the challenges anila mjeda and goetz botterweck 7 pages guest editors: anila mjeda, stylianos basagiannis, goetz botterweck eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst scalable software testing and verification for industrial-scale systems: the challenges anila mjeda∗ and goetz botterweck† lero–the irish software research centre university of limerick limerick, ireland name.surname@lero.ie abstract: in this position paper, we argue that more collaborative research is needed to increase the use of research-led verification and testing techniques in industrialscale projects. we focus on the a) practical applicability and scalability of verification and testing techniques in industrial projects, and b) to autonomous systems. we identify the challenges involved and bring forward some initial suggestions. keywords: testing; verification; industrial-scale systems 1 introduction modern verification and testing techniques are highly relevant for industrial software-intensive systems. while recent technological trends increase the need for industrial-scale robust approaches, issues such as education of practitioners, insufficient tools, and specifics of the industrial environment [6] create barriers for the application of modern verification and testing techniques in industrial practice. we direct our focus on two areas: the practical applicability and scalability of verification and testing techniques in realistic industrial projects and the application of verification and testing to autonomous systems. in this position paper, we (1) argue that to overcome such barriers more collaborative research is needed and (2) identify research areas that show potential on this regards.we conclude the paper with an overview of the current challenges aiming to sketch potential areas for collaborative future work. 2 scalability and practical applicability in this section, we focus on the scalability of verification and testing techniques and applicability to industrial projects. in particular, we are looking at (1) model-based testing, (2) the integration of model-checking and testing, and (3) metaheuristic approaches. model-based testing (mbt). mbt approaches typically rely on a specification-based model of the system under test. the model is used to generate tests according to some previously ∗ supported, in part, by science foundation ireland grant 13/rc/2094. † supported, in part, by science foundation ireland grant 13/rc/2094. 1 / 7 volume 77 (2019) scalable software testing and verification for industrial-scale systems: the challenges specified test generation and selection criteria. mbt is reportedly cost-effective; it provides a platform for repeatable and traceable results which link tests to the requirements (one of the key needs for certification); and, can be used to automatically generate tests to achieve coverage criteria (such as mc/dc). mbt approaches can be distinguished by the kind of model they employ (e.g., deterministic/non-deterministic, discrete/continuous/hybrid, etc.); the test generation technology (e.g. graphs search algorithms) and test selection criteria (e.g., structural model coverage); the test execution options (e.g., mil, sil, hil); and, the test evaluation approach (e.g., signal-feature based) [23]. for a review on mbt see [29]. integration of model-checking and testing. model checking (mc) ’reasons’ in terms of the states a system can be in, with state-space explosion as a fundamental challenge. mitigation strategies typically aim to (i) consider only a subset of all possible states (e.g., probabilistic mc) or (ii) raise the level of abstraction for the state representation (e.g., symbolic mc). callahan et al. [4] and engels et al. [8] were the first to suggest deriving tests from counterexamples found by a model checker, e.g., generate a test that drives the system towards a known property violation (see the survey in [13]). such approaches can be broadly categorised into: (i) ones where the test criteria/test objectives are mutated into their logical complement (also called trap properties [13]); and, (ii) ones where the model-under-analysis is mutated [13] (e.g., by reversing the logic of transition guards in a statechart). there are a number of industrial evaluations for test generation via mc (e.g., [10]), nevertheless, it is still difficult to scale up for testing complex systems. bounded model checking [3] and directed model checking [7] have been proposed as promising approaches in the field of test generation [12]. metaheuristic search and optimization. metaheuristic approaches mitigate the scalability problem by translating testing or verification into (automated) search and optimization techniques [5, 22, 17, 1]. quite often the optimization problems are too complex, they could be np-complete or np-hard, for which optimal solutions would be impractical to compute. metaheuristics are a subset of techniques (such as evolutionary algorithms, particle swarm optimization) that solve optimization problems via the use of non-exhaustive search algorithms; and while they do not provide guarantees to find the best solution, they return a good nearly-optimal solution at a reasonable computational cost. for an overview of the field see [17]. 3 testing and verification of autonomous systems the correct behaviour of autonomous systems requires automated correct decisions taken in real time. the decision-making is typically driven by a machine learning technique such as neural networks where the ’learning’ phase mimics empirical learning based on a set of training data. these systems tend to be opaque to humans, e.g. a human typically cannot read or deduce the decision rules that have been learned by a fully trained neural network [19]. the classic testing approaches of these systems typically revolve around randomly selected test inputs and scenario simulations and can leave corner-case behaviours completely untested (e.g. autonomous driving in poor visibility). metamorphic techniques and new coverage metrics – metamorphic testing of autonomous behaviour is pursued by a number of researchers, such as [24]. pei et al. interavt 2019 2 / 7 eceasst propose using neuron coverage (defined as the number of unique neurons that get activated for given inputs over the total number of neurons [25]) as a new testing metric applicable to neural networks. tian et al. [28] use neuron coverage for guiding test generation and metamorphic relations to identify erroneous behaviours. adversarial techniques– a number of techniques use adversarial examples such as the introduction of small distortions or noise in the inputs to detect possible erroneous behaviour in some corner cases (e.g., image distortion) [11, 20]. verification– katz et al. [18] propose using an smt solver to verify safety properties in deep neural networks and are working to improve on the scalability of their technique for real-world systems. 4 high-potential industry-academia’ collaborations a large and growing body of literature has reported on the need for more collaboration between industry and academia and has analysed the solutions needed to address it. n o n -t ri v ia l c h a ll e n g e s (s c ie n ti fi c r ig o r, c o m p le x it y) needed in practice (relevancy) inn ovation with little impact feasible, but trivial projects easy, but not n eeded nirvana very hard to re ach tendency o f academic research tendency o f industry target for high-potential collaborations 1 2 3 figure 1: conflicting objectives. for example, bertolino [2] analysed the discordance between the state of practice and state of art in testing and argued for the need of more empirical research in industrial software testing. garousi et.al [15] conducted a systematic literature review on the challenges of industry-academia collaborations and concluded that different focus areas are the key impediment to better collaboration. whereas, engström et. al. [9] proposed a taxonomy for supporting industry-academia collaboration and gorschek at. al. [16] proposed a model for technology transfer to happen in practice. comparative evaluation t2t1 integration t2t1 t3results t1 application use case results figure 2: models of collaboration. yet, this industry-academia viewpoint’ divide remains and its current span damages both ’parties’. one could discuss, whether there is an inherent conflict between addressing challenges that are attractive for both academic research and industry. typically, academic researchers tend to be attracted by scientifically challenging complex problems [14] (illustrated by 1 in figure 1); can often use artificial examples when validating the (albeit complex) research; and, can often focus on generic problems while not addressing the domain constraints [26]. whereas, industry tends to be interested in challenges that could be scientifically trivial but tangibly relevant and feasible for them (e.g. improve effectiveness and efficiency of testing) and not particularly interested in scientifically challenging techniques that are too complex to implement in practice [14] 3 . here, collaborative projects [21] could serve as a motivation to leave one’s comfort zone and tackle problems that are both scientifically novel and relevant in practice 2 while industry could benefit from access to novel techniques and innovation potential. the collaboration can follow a number of different models such as (1) comparative evaluations of techniques, (2) integration of 3 / 7 volume 77 (2019) scalable software testing and verification for industrial-scale systems: the challenges techniques, or (3) the application of novel techniques in a realistic setting (figure 2). this calls for joined efforts throughout the stages of scientific collaboration (e.g, foundation, formulation, sustainment, conclusion [27]). in collaborations, the involved can learn from each other, boost innovation, and enrich their own knowledge by relating different world-views. 5 challenges and conclusions scalable testing and verification. a close analysis of the state-of-the-art identifies a gap in addressing the formal testing and verification of industrial-scale software systems. the majority of the proposed solutions are based on a number of assumptions on the system under test, which can prove too restrictive for real-world systems. moreover, the sometimes different world-views of researchers and industry and unfamiliarity of practitioners with prototype tools proposed by researchers create a real or perceived barrier to industry application. even though there are some industrial evaluations on model checking for test generation (e.g., [10]) there remain many issues when attempting to scale up these approaches for testing complex systems. at the core of the issues remains the fact that model checkers have not been originally designed for test generation [12] and the state-explosion problem that typically accompanies model-checking. scalability remains one of the biggest challenges and the main conclusions to take on board are: (1) scalability analysis should be considered in early stages of any project’s design; (2) currently, the most direct route is to aim for combinations of testing and verification approaches that complement each other, i.e., mitigate each other’s shortcomings; and, (3) collaborate to understand each other’s world view, to compare or combine techniques, and to apply and evaluate techniques in practice. testing and verification of autonomous systems. the complex nature of autonomous systems translates into developing methods of testing the unknown and the unpredictable. some promising emerging techniques include neuron coverage used as a classic black-box testing technique (testing the unknown)[25], grey-box test generation led by a neuron-coverage metric and oracle generation via metamorphic testing techniques [28], leveraging adversarial techniques to detect erroneous behaviour [11, 20]; and, using solvers to verify (all be it not very rich) safety properties [18]. collaborative research. in this position paper, we argue that, to overcome barriers to the application of verification and testing techniques in industry, we need more collaborative research which is both scientifically novel and relevant in practice (figure 1). this calls for joined efforts throughout the stages of scientific collaboration which could follow cooperation models such as (1) comparative evaluations of techniques, (2) integration of techniques, or (3) the application of novel techniques in a realistic setting (figure 2). researchers could use this to avoid an over-emphasis of internal validity (e.g., experiments that are easy to run but irrelevant) and mitigate bias towards selecting evaluations that artificially confirm their techniques and all the involved can learn from each other, boost innovation, and interavt 2019 4 / 7 eceasst enrich their own knowledge by relating different world-views. last but not least, many current challenges require interdisciplinary approaches and, hence, collaborations. bibliography [1] shaukat a., l. c briand, h. hemmati & r. k. panesar-walawege (2010): a systematic review of the application and empirical investigation of search-based test case generation. tse 36(6), pp. 742–762. [2] antonia bertolino (2004): the (im) maturity level of software testing. acm sigsoft software engineering notes 29(5), pp. 1–4. [3] armin biere, alessandro cimatti, edmund m. clarke, ofer strichman & yunshan zhu (2003): bounded model checking. advances in computers 58, pp. 117–148. [4] john callahan, francis schneider, steve easterbrook et al. (1996): automated software testing using model-checking. in: proc. of 1996 spin workshop, 353. [5] j. clarke, j. j. dolado, m. harman, r. hierons, b. jones, m. lumkin, b. mitchell, mancoridis et al. (2003): reformulating software engineering as a search problem. iee proc.sw. 150(3), pp. 161–175. [6] j. a. davis, m. clark, d. cofer, a. fifarek, j. hinchman, j. hoffman, b. hulbert, s. p. miller & l. wagner (2013): study on the barriers to the industrial adoption of formal methods, pp. 63–77. springer, berlin. [7] stefan edelkamp, alberto lluch lafuente & stefan leue (2001): directed explicit model checking with hsf-spin. in: proc. of 8th spin workshop on model checking of software, springer, pp. 57–79. [8] andré engels, loe feijs & sjouke mauw (1997): test generation for intelligent networks using model checking. tools and algorithms for the construction and analysis of systems, pp. 384–398. [9] emelie engström, kai petersen, nauman bin ali & elizabeth bjarnason (2017): serp-test: a taxonomy for supporting industry–academia communication. software quality journal 25(4), pp. 1269–1305. [10] eduard p. enoiu, a. čaušević, t. j. ostrand, e. j. weyuker, d. sundmark & p. pettersson (2016): automated test generation using model checking: an industrial evaluation. stt 18(3), pp. 335–353. [11] ivan evtimov, k. eykholt, e. fernandes, t. kohno, bo li, a. prakash, a. rahmati & d. song (2017): robust physical-world attacks on machine learning models. arxiv preprint arxiv:1707.08945. [12] gordon fraser, franz wotawa & paul ammann (2009): issues in using model checkers for test case generation. journal of systems and software 82(9), pp. 1403–1418. 5 / 7 volume 77 (2019) scalable software testing and verification for industrial-scale systems: the challenges [13] gordon fraser, franz wotawa & paul e. ammann (2009): testing with model checkers: a survey. software testing, verification and reliability 19(3), pp. 215–261. [14] vahid garousi, michael felderer, marco kuhrmann & kadir herkiloğlu (2017): what industry wants from academia in software testing?: hearing practitioners’ opinions. in: proceedings of the 21st international conference on evaluation and assessment in software engineering, acm, pp. 65–69. [15] vahid garousi, kai petersen & baris ozkan (2016): challenges and best practices in industry-academia collaborations in software engineering: a systematic literature review. information and software technology 79, pp. 106–127. [16] tony gorschek, per garre, stig larsson & claes wohlin (2006): a model for technology transfer in practice. ieee software 23(6), pp. 88–95. [17] mark harman (2007): the current state and future of search based software engineering. in: 2007 future of software engineering, ieee computer society, pp. 342–357. [18] guy katz, clark barrett, david l dill, kyle julian & mykel j kochenderfer (2017): reluplex: an efficient smt solver for verifying deep neural networks. in: cav 2017, springer, pp. 97–117. [19] alex krizhevsky, ilya sutskever & geoffrey e hinton (2012): imagenet classification with deep convolutional neural networks. in: advances in neural information processing systems, pp. 1097–1105. [20] alexey kurakin, ian goodfellow & samy bengio (2016): adversarial examples in the physical world. arxiv preprint arxiv:1607.02533. [21] satoshi masuda (2017): software testing in industry and academia: a view of both sides in japan. in: 2017 ieee international conference on software testing, verification and validation workshops (icstw), ieee, pp. 40–41. [22] phil mcminn (2004): search-based software test data generation: a survey. software testing, verification and reliability 14(2), pp. 105–156. [23] anila mjeda (2013): standard-compliant testing for safety-related automotive software. ph.d. thesis. [24] anh nguyen, jason yosinski & jeff clune (2015): deep neural networks are easily fooled: high confidence predictions for unrecognizable images. in: proc. of the cvpr 2015, pp. 427–436. [25] kexin pei, yinzhi cao, junfeng yang & suman jana (2017): deepxplore: automated whitebox testing of deep learning systems. in: proc.of the 26th symp. on operating systems principles, acm, pp. 1–18. interavt 2019 6 / 7 eceasst [26] rick rabiser, klaus schmid, martin becker, goetz botterweck, matthias galster, iris groher & danny weyns (2018): a study and comparison of industrial vs. academic software product line research published at splc. in: proceeedings of the 22nd international conference on systems and software product line-volume 1, acm, pp. 14–24. [27] diane h sonnenwald (2007): scientific collaboration. annual review of information science and technology 41(1), pp. 643–681. [28] yuchi tian, kexin pei, suman jana & baishakhi ray (2018): deeptest: automated testing of deep-neural-network-driven autonomous cars. in: proc. of icse’18, acm, pp. 303– 314. [29] mark utting, alexander pretschner & bruno legeard (2012): a taxonomy of model-based testing approaches. software testing, verification and reliability 22(5), pp. 297–312. 7 / 7 volume 77 (2019) introduction scalability and practical applicability testing and verification of autonomous systems high-potential industry-academia' collaborations challenges and conclusions model extraction of legacy c code in sccharts electronic communications of the easst volume 74 (2017) 7th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2016 model extraction of legacy c code in sccharts steven smyth, stephan lenga, and reinhard von hanxelden 20 pages guest editors: anna-lena lamprecht eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst model extraction of legacy c code in sccharts steven smyth, stephan lenga, and reinhard von hanxelden department of computer science faculty of engineering kiel university abstract: with increasing volumes of developed software and steadily growing complexity of these systems, software engineers struggle to manually maintain the vast amount of legacy code. therefore, it is of interest to create a system which supports the documentation, maintenance, and reusability of software and its legacy code. the approach presented here automatically derives sccharts models from c code. these models can be used as visual documentation. by applying focus and context methods important parts of the model can be highlighted and may grant a better understanding of the overall software. additionally, the models can be used as a source to create new state-of-the-art code for various languages and platforms, such as c code or vhdl, using code generators. keywords: model extraction, model-based engineering, sccharts, documentation, code generation 1 introduction as the development rate of software in nearly every sector of the industry is reaching new highs, software engineers struggle to manually maintain the vast amount of legacy code. seacord et al. labeled the alarming development that new software is outpacing the ability to maintain it the legacy crisis [spl03, chapter 1.3]. therefore, it is of interest to create a system which supports the documentation, maintenance, and reusability of software systems and in particular of its legacy code. model-driven software development (mdsd) is an approach which besides other goals aims to support software modernization. initially, it was created to develop new software, but recently it is also used for maintaining existing software systems [im14]. mdsd makes use of graphical models to provide a clear overview of general concepts, core functionality, and structural composition of software. the represented models are created with the help of modeling languages. modeling languages are visual programming languages which specialize in the specification of the requirements, the structure, the control flow, or the data flow of software systems. this is achieved by using a high level of abstraction. sophisticated mdsd tools do not only enable the user to manually create models but also provide means for extracting models from source code [sch06]. sccharts the sequentially constructive statecharts (sccharts) language [hdm+14] is a visual synchronous modeling language which is specialized in specifying safety-critical systems. 1 / 20 volume 74 (2017) model extraction of legacy c code in sccharts int main(int a, int b) { if (a < b) { return 0; } while (a <= 0.5 ∗ b) { a = a + 1 } return a; } (a) c code that serves as source model (b) example extraction of the c code depicted in listing 1a figure 1: sccharts extraction example the language uses a statechart notation [har87] and follows a synchronous model of computation (moc) that provides determinate concurrency. while sccharts contains various extended language features, which allow a compact representation of complex models, we here focus on the core features of the language, namely the interface, states, transitions, and hierarchy. to support the notion of concurrency, each state is divided into regions which can conceptually be seen as threads. however, since the approach presented here does not yet look into concurrent programs, all states include only one implicit control flow region. additionally, states may contain actions. for instance, an entry action is executed whenever the state is entered. figure 1b shows an example of a possible sccharts representation of the c program shown in listing 1a. it consists of a root state named main. input and output variables are always displayed below the name. the state main contains five other states namely checkcondition, returnzero, while, do and returna. checkcondition is the initial state of its region, which can be recognized by the bold black border. transitions between states, which are indicated by arrows, show the possible control flows. the trigger of a transition needs to be fulfilled in order to enable the transition. it may be followed by a forward slash and one or multiple actions that are executed in sequential order if the transition is enabled. a transition without a specified trigger is always enabled. in this case, the transition label may directly begin with the slash and the action list. if a state has multiple outgoing transitions, priorities show the order in which the triggers of these transitions are checked. they are illustrated by a number in front of the trigger of the transition. the lower the number, the higher the priority. time in synchronous languages is discretized into logical clock ticks. solid-lined arrows represent delayed transitions. they are disabled in the tick in which the source state got entered and, hence, consume a logical tick. dashed arrows depict immediate transitions, which do not consume time. a final state, which marks the end of the enclosing region, is characterized by a double-line border. further information on all sccharts features can be found elsewhere [hdm+14]. in figure 1b, checkcondition is the initial state. the control flow of the program starts in this state. since the priority of the upper transition is higher than that of the lower transition, it is checked first whether a is less than b. in this case, the final state returnzero is entered, the entry action return = 0 is executed. additionally, the superstate main terminates. otherwise, the isola ds 2016 2 / 20 eceasst lower transition is taken because the empty trigger condition is always true. this leads to the while state. here, a is incremented as long as a is less than or equal to half of b. finally, if this condition is not satisfied anymore, the final state returna is entered and the output variable return is set to the value of a. all diagrams of models in this work are created and automatically layouted with the kiel integrated environment for layout eclipse rich client (kieler). kieler is a research project which is developed by the real-time and embedded systems group at kiel university. the primary objective is the enhancement of the model-based design of complex systems. by arranging graphical components with the help of automatic layout algorithms, and consequently freeing the user from redundant tasks, it improves the development process and maintainability [ssh13]. besides being a platform and framework for researching and prototype development, kieler also includes an sccharts editor and compiler. contributions the approach presented allows to create visual representations of legacy c code automatically. on the one hand, one can take advantage of visual clues to help understand complex software, and on the other hand this integrates well into projects where some parts are already modeled in a graphical language. especially in the automotive sector it is common to have for example a mix of simulink models and c code. therefore, i) meaningful and understandable patterns to describe c programs must be found. the goal here is to enhance the overview and understandability of legacy systems. the presented transformation ii) generates sccharts models, a novel statechart dialect, especially developed for safety-critical systems. these models can be used for documentation and to generate new code for various platforms. hence, the main application targets for, but is not limited to, legacy c code programs. we show iii) how we use the existing code generator of the kieler sccharts implementation to generate code for different platforms, such as c or hardware circuits, from the extraced models. various other target platforms such as java or vhdl, are also possible. outline section 2 describes the model extraction mechanism. in particular, it shows how the various language features of c are mapped to the language features of sccharts. since the suitability of these mappings depends on the use case, we also discuss alternative ways of depicting the program in the abstract model. thereafter, section 3 presents the possibilities of the existing code generators and depicts preliminary results. we discuss related work in section 4 and conclude in section 5. 2 model extraction in the first step, we evaluate the suitability of sccharts to serve as model for c programs. therefore, the c programs have to be parsed to create an abstract syntax tree (ast) (see section 2.1). the model extraction prototype uses model-to-model transformation techniques according to the single-pass language-driven incremental compilation approach (slic) [msh14] in section 2.2. additionally, a few changes to the sccharts visual language are adapted to the c programming language to facilitate understandability of the extracted models. 3 / 20 volume 74 (2017) model extraction of legacy c code in sccharts (b) ast of the program shown in listing 2a int main(int a, int b) { if (a < b) { a = a + b; } return a; } (a) c code example figure 2: abstract syntax tree (ast) example 2.1 parsing c programs since kieler is an eclipse framework, the eclipse c development tooling (cdt)1 is available. the cdt is an eclipse project which serves as a fully functional ide for developing applications in c/c++. it provides a fully featured editor and additional services such as source code navigation, static code analysis, debugging and unit tests. the cdt can parse files of c projects that are created or imported into the eclipse environment. the cdt parser creates an abstract syntax tree. the ast serves as the source model of the transformation. commonly, each node of an ast represents a construct occurring in the source code. for example, when the c program in listing 2a is parsed by the cdt, the ast in figure 2b is generated. first, the root node functiondefiniton defines the main function. it contains the functiondeclarator and its compoundstatement. the functiondeclarator holds the name of the function, here main, and its parameter declaration. each parameterdeclaration defines one parameter of the function. in this example, the declarators a and b are present. a compoundstatement represents a code block surrounded by curly brackets. the main function contains one compound statement, which includes an if statement and a return statement. both have corresponding nodes in the ast. the subtree of the ifstatement node also contains a compound statement and the binary expression that is used for evaluating the if statement. in all expressions, idexpressions reference declared variables. the complete overview of possible nodes in the ast generated by 1 https://eclipse.org/cdt isola ds 2016 4 / 20 eceasst int main() { int a; int b = 4; b = 7; a = b − 1; if (a == 3) { a = a + 1; } int c = 2; int d = a; return d; } (a) c program illustrating declarations & assignments (b) extracted scchart of the c program depicted in listing 3a figure 3: declarations and assignments the cdt can be found in the cdt manual1. as mentioned before, the ast serves as the source of the subsequent model transformation to sccharts. its structure and the provided information is used to identify the necessary model components and their positioning within the sccharts model. therefore, the different nodes of the ast are converted one after another by traversing the tree in depth-first order. each node represents a model component that needs to be created. after every node has been visited, the text-to-model transformation process is complete. the resulting scchart is a semantically equivalent visual representation of the original source code. 2.2 transforming c code to sccharts there may be several ways to represent the source program. thus, the representations presented in the following subsections may in parts only be suggestions. to find a viable solution, several questionnaires were handed out to university staff and students. the provided answers were considered in the first prototype [ols16]. however, we fine-tuned the representation of both the extracted abstract model and the visual representation of the source program to maximize overview and understandability. nevertheless, sccharts is a relatively new modeling language and still evolves in terms of language semantics, syntax and also compilation approaches. if the sccharts language becomes more powerful, we expect that the number of c programs that we can transform automatically will increase. this will be an ongoing process and we anticipate that some the representations will change in the future. further suggestions for improvements are discussed in section 5. 2.2.1 functions every function of a c program is represented by a root state in the extracted scchart. as described in section 1 all states in our approach only use one implicit control flow region. these regions represent the compound statements of the functions and start with an initial state where 5 / 20 volume 74 (2017) model extraction of legacy c code in sccharts (a) simple assignment in data flow notation (b) calculation in data flow notation (c) combination of control and data flow figure 4: combining sccharts with data flow notation [uml15] the control flow starts as soon as the enclosing state becomes active. the control flow represents that of the c program. if the function includes further control structures with compound statements, e.g., an if statement, these are represented by further superstates. additionally, the arguments of the function are declared as input variables of the corresponding type. analogously, if the function is returning a return value, an appropriate output variable is created. local variable declarations of the function in c are also declared in the declaration interface of the scchart. they are neither marked as input nor output. 2.2.2 assignments there are different ways to assign values to variables in sccharts. to stay as close as possible to the original code, sccharts also uses initializations if the value is immediately assigned after the declaration. additionally, it is possible to assign values to variables as transition actions or as state actions, e.g., entry actions that are executed whenever a state is entered. if the assignments take place at the beginning of a state, bundling these assignments to entry actions facilitates the readability. this reduces the number of overall states of the scchart. contrary to the standard syntax of sccharts, which uses an extra keyword on entry actions, the entry keyword was omitted due to the fact that entry actions are the only actions that are used. this makes the visualization less verbose and increases the readability, because states with actions can be displayed in a more compact way than transitions with actions. consider that the entry actions are executed in their sequential order, but after the initialization part of a declaration. hence, dependencies between the assignments are preserved. in the function and declaration example in figure 3 you can see that the scchart displayed in figure 3b gets extracted from the program in listing 3a. hence, as described in section 2.2.1, the function main creates the corresponding root state main. the four variable declarations a, b, c, and d are all visible in the interface of the root state regardless of where they were declared in the c function. declarations with initialization part also preserve their initialization. furthermore, the assignment a = b 1 is executed immediately after the function is called. therefore, isola ds 2016 6 / 20 eceasst 1 int main(int a) { 2 int b = 10, c = 6; 3 if (a > 4) { 4 a = a − 1; 5 } else { 6 a = c + 3; 7 } 8 while (a <= b) { 9 a = a + 1; 10 if (a == c) { 11 a = b ∗ 2; 12 } 13 } 14 for (int i = 0; i < b; i = i + 1) { 15 a = i ∗ 2; 16 } 17 return a; 18 } (a) control statements example c code (b) extracted control statements from the c program shown listing 5a figure 5: control statements example the assignment is displayed as an entry action. the control of the region passes from the anonymous initial state to the if statement. here, the condition is checked before the control flow can proceed. after the compound statement of the if statement finishes, d and the return value are set. contrary to the assignment of 2 to c during the initialization, a cannot be assigned to d beforehand, because this would neglect the potential increment of a in the if statement. finally, the program terminates. one might argue that the different notations for assigning values might get confusing. we chose this approach to stay relatively close to the original code and also to keep the models small with respect to the space needed for the diagram. however, it is of course possible to only use one notation for reasons of clarity which might result in more verbose models. even in a control flow orientated approach it is possible to use data flow like assignment syntax if the reader is more familiar with this notation. this is not implemented in the current version, but umland [uml15] showed how data flow notations can be combined with classical sccharts (cf. figure 4). in figure 4a a simple assignment is depicted. the value in is written to out. figure 4b shows the equation out = (in + in2) ∗ in2. the combination of control and data flow semantics could happen on region level in sccharts as can be seen in figure 4c. the exact semantics of such combinations have yet to be defined. however, there already exist several examples of mixed semantics which can serve as models. some are discussed in the related work in section 4. 7 / 20 volume 74 (2017) model extraction of legacy c code in sccharts int main(int a, int b) { if (a < b) { a = b; } else if (a > b) { a = b ∗ 2; } else { a = a + b; } return a; } (a) if-then-else in c (b) extracted model of the c code listed in listing 6a figure 6: if-then-else example 2.2.3 control statements the control flow starts at the initial state of a compound statement and proceeds straightforwardly. to clarify the boundaries of control structures, every following control statement is embedded into its own superstate. hence, the extracted model is organized according to the control statement structure of the original model. if desired, the corresponding line numbers of the c code can be added to all statements. however, in our experience this seems to be superfluous, at least for small examples. moreover, user interactions with the graphical diagram can be configured such that the textual source of a specific element is selected automatically in the source code editor. the inner behavior of control structures, which is of no importance to the reader of the model, can be hidden by pressing the [-] symbol in the upper left corner of the region of the respective state. this can be of further benefit to understand the essence of the depicted function or program. also, all control statements share similar layouts. as before, in each superstate the control starts at the initial state. then, the body of the particular control statement follows and, finally, each structure has at least one final state. optionally, a control structure may also declare local variables and actions. control structures of the same type closely resemble each other in sccharts. here, only the enclosed components may differ, but can also be collapsed. as an introductory example for control statements, figure 5b presents an scchart visualizing the c code of listing 5a. again, the function and its declarations create a new sccharts root state. furthermore, the function contains several control statements which also include compound statements, namely if, while, and for. all of these get transformed to superstates with their own scope and are executed in sequential order. the while statement also comprises another if statement. you can see the nested states in the diagram in figure 5b. we will discuss the different control statements in detail in the following paragraphs. if-then-else statement the first embedded control statement in the scchart in figure 5b is the if-then-else statement. the path the control flow follows is determined by the condition in the statement. if the condition holds, the then branch is taken. otherwise, the control follows isola ds 2016 8 / 20 eceasst the else branch. therefore, in the scchart, the condition of the if statement is used as trigger of the first outgoing transition. this corresponds to the true branch. if the expression evaluates to true, the transition is taken. the second transition does not have an explicit trigger and is implicitly true. since it is has a lower priority than the first transition, it is always taken in the else case. the targets of both transitions are marked as final, so the control statement superstate is left immediately in both cases. figure 7: if-then-else alternative figure 6b shows the extracted diagram from the c code shown in listing 6a. here, the ifthen-else statement is extended by another elseif structure. this corresponds to another nested if statement. so, if the else branch is taken, the control switches to the nested if statement which is represented by another superstate. subsequently, the second if condition is checked and the control flow proceeds accordingly. as an alternative, figure 7 shows another ifelse variant. here, the nested superstates are flattened. the different if-else cases get transformed to transitions with priorities according to the order their conditions get tested. this demonstrates that you do not have to adhere to the structure of the ast in all cases. as the if-then-else alternative is usually more compact and also well readable, we prefer this depiction. while statement the while statement from the example in figure 5 also becomes a superstate. the condition of the while loop is checked in the initial state. if the condition evaluates to true, the loop continues. otherwise, the superstate is left immediately. in the while loop in listing 5a, a is incremented by one before the nested if statement, also represented by a superstate, is checked. if it would contain another nested control statement, the nesting would also continue in the scchart. remember that the user can hide inside behavior if desired. after the if superstate finishes, the control returns to the check of the while condition. the difference between the while statement and the do-while statement can be seen in figure 8b which is an sccharts representation of the c code listed in listing 8a. in the main function of the c code, two loops, one while loop and one do-while loop, are executed sequentially. the corresponding root state in the scchart consists of two embedded superstates for the two loops as described before. the difference between the two while loops, and the behaviors of their two superstates, is the point in time when the loop condition is checked. in the simple while loop the condition is checked immediately after the control enters the superstate. contrary to this, in the do-while loop, the body gets executed immediately and the condition is checked afterwards. in terms of the sccharts model, only the outgoing transition from the initial state decides whether or not the loop is a while loop or a do-while loop. for statement the last control statement shown in figure 5 is the for statement. the standalone variant is depicted in figure 9b. as in the other control statements, a for statement also becomes 9 / 20 volume 74 (2017) model extraction of legacy c code in sccharts int main(int a, int b) { while (a < b) { a = a ∗ 2; b = b − 1; } do { a = a + b; } while (a < 42); return a; } (a) while loops in c (b) extracted model of the c code depicted in listing 8a figure 8: while example int main(int a, int b) { for (int i = 1; i <= a; i++) { b = b + b; } return b; } (a) for loop in c (b) extracted model of the c code shown in listing 9a figure 9: for example a superstate and resembles a while loop. however, the for loop gets a dedicated counter variable which is declared at the beginning of the superstate and initialized with the corresponding value. the condition of the for loop is checked similarly to the condition of the while loop. additionally, the last assignment in the body of the for loop modifies the counter variable. again, the superstate is left as soon as the condition evaluates to false. switch statement the switch statement allows to combine cases of a conditional expression. however, due to the infamous fall-through semantics this is also a common c pitfall. single switch cases may be merged inadvertently if a break statement was forgotten. when extracting the c code presented in listing 10a in the actual approach, the sccharts representation is the one depicted in figure 10b. the fall-through from case 1 to case 2 becomes obvious. all other cases use the break statement to leave the switch at once. even if the example gets bigger with arbitrary break statements, this is a nice example how the automatic graphical representation of the program helps to understand the semantics of the legacy c code. isola ds 2016 10 / 20 eceasst int main(int a) { int b; switch(a) { case 1: b = 0; case 2: b = a; break; case 3: b = 1 break; default: b = 5; } return b; } (a) switch statement in c (b) extracted model of the c code depicted in listing 10a figure 10: switch example 2.2.4 function calls representing function calls in sccharts may depend on the compilation approach. consider the c program listed in listing 11a. a first straightforward approach performing a macro expansion is depicted in figure 11b. similar to the control statements presented before, the function call gets its own superstate. when the state of the called function add is entered, the arguments a and b are copied to local variables x and y. these variables are used for internal computations. after the sum of the two integer values is assigned to the local return variable, the value is copied to the variable sum. even though the visual feedback for the user shows the detailed behavior of the program, the approach leads to problems with multiple calls of the same function as each function call will be translated to its own superstate. all of these states would contain the same information which would lead to an inflated scchart. as a result, the generated c code from the scchart would also contain duplicated code blocks. consequently, this approach does not scale. also, the actual semantic information that a call to a function happened is lost in this representation. the second approach presented in figure 11c makes use of reference states. a reference state in sccharts references another scchart and becomes active under the usual rules. however, the selected compilation approach decides how the referenced state is handled in the downstream compilation. for example, referenced sccharts can also be expanded as explained before. nevertheless, if the selected compilation approach supports actual function calls (e.g., when generating code for software) then the code generation is also able to treat the called scchart as a separate function without duplicating its code. the function add is added as a second root state to the scchart as already suggested in section 2.2.1. the reference state call maps the arguments a and b to the input variables x and y of the referenced state. additionally, the variable 11 / 20 volume 74 (2017) model extraction of legacy c code in sccharts int main(int a, int b) { int sum; sum = add(a,b); return sum; } int add(int x, int y) { return x + y; } (a) example of a function call in c (b) function call included via macro expansion (c) referenced call notation in sccharts figure 11: function call example sum is mapped to the output return of referenced state add. here, we use the sccharts function call syntax, which resembles the call-by-reference syntax of c with the ampersand prefix (&). however, since sccharts uses explicit inputs and outputs in interfaces, the variable binding is determined by the parameter order. the ampersand prefix merely serves as visual hint. the return value of the function is also given back in this way. moreover, this solution does also support the expand/collapse features of common superstates. even though each function call still has its separate state, its inner behavior can be hidden if desired. hence, collapsing chains of function calls can also help to increase the overall overview. by default, sccharts generated programs do not acquire more memory dynamically at runtime. hence, this approach cannot handle arbitrary recursive function calls. however, if the recursive depth is obtainable statically or if the generated code is able allocate more memory during runtime, this approach works in principal. also, the visualization of referenced sccharts could be used to inspect such programs as can be seen in figure 12a. nevertheless, the recursive nature may be expanded infinitely. isola ds 2016 12 / 20 eceasst (a) possible recursive call visualization figure 12: example of a recursive function call 3 first results in the second step, we used the extracted models and the already existing kieler sccharts tool chain to automatically generate c code. to validate the feasibility of the approach, regression tests were executed and compared to the source models. section 3.1 briefly introduces the used code generation method. section 3.2 illustrates the approach based on a fibonacci program. 3.1 netlist-based code generation figure 13 illustrates the downstream netlist-based compilation approach [hdm+14, smh15] of the kieler sccharts implementation. when extracting the model from the ast example in listing 2a the existing code generation approach of the kieler sccharts implementation then generates a sequentially constructive graph (scg) which is a control flow graph representation of the given program. the scg is partitioned into basic blocks as can be seen in figure 13a. from these blocks a new netlist in form of an scg can be synthesized. the netlist of the example is depicted in figure 13b. the assignments in the black nodes correspond to the activating guards of the basic blocks, here g0, g1, and g2. go is the start signal of the program and is true in the first clock tick. the assignments that are guarded by the blocks are depicted as red nodes. the different colored arrows illustrate different kinds of dependencies. all dependencies enforce an order: the source of a link must precede the target. the colors decode the semantic reason of these orderings. brown colored links mean that this expression depends on the result of another expression. red colored links say that this node is guarded by the source of the link. blue colored links depict sequential control flow dependency. finally, when generating sequentialized code, a schedule obeying these dependency constraints can be found if the given program is sequentially constructive, meaning it does not have any causality issues under the sequentially constructive moc (sc moc) [hdm+14]. 13 / 20 volume 74 (2017) model extraction of legacy c code in sccharts (a) scg divided into basic blocks, each with separate guards (b) generated netlist in scg form (c) sequentialized scg figure 13: illustration of the netlist-based code generation approach of the kieler sccharts implementation. figure 14: generated circuit (optimized) the netlist-based approach can be used to synthesize software and also hardware [msh14, rsm+16]. the corresponding circuit can automatically be created and is displayed in figure 14. however, the netlist-based approach does not handle instantaneous loops, unlike the priority-based approach [hdm+14]. in fact, the size and structure of the model and the choice of target platform usually determine which compilation method promises best results. however, in the case of model generation, the choice of the compilation approach also determines parts of the model. for example, a loop may not be generated instantaneously if the target of the compilation chain is a circuit. here, the synchronous moc provides tools which allow us to create circuits, but it requires that at least one transition in the loop must be marked as delayed to consume time. for future sccharts versions we could imagine a dynamic transition type that decides if it is delayed or immediate during compile time after the compilation approach is set. 3.2 full example we validated the correctness of functionality within a discretized timing environment typical for synchronous languages [peb07]. we are able to generate (simulated) circuits out of c programs with the restriction that loops are not instantaneous. however, the transformation automatically marks transitions as delayed if required. this section discusses the extraction and code generation process to both, software and hardware. the c program in listing 15a calculates the nth fibonacci number. it was extracted according to the approach explained in section 2. the extracted scchart is shown in figure 15b. at first, the argument check is performed. if an argument is provided, the function calls the atoi system isola ds 2016 14 / 20 eceasst 1 int main(int argc, char∗∗ argv) { 2 int a, b; 3 if (argc>0) { 4 a = atoi(argv[0]); 5 } else { 6 a = 0; 7 } 8 b = fib(a); 9 return b; 10 } 11 int fib(int n) { 12 int fl = 0, fh = 1; 13 if (n<=1) { fh = n; } 14 else { 15 for (int i=2; i<=n; i++) { 16 int tmp = fh; 17 fh += fl; 18 fl = tmp; 19 }} 20 return fh; 21 } (a) fibonacci in c (b) extracted scchart of the fibonacci c program in listing 15a figure 15: full fibonacci example function and converts the string into an integer which is then stored in a. otherwise, a is set to 0. subsequent to the argument check, the fibonacci function fib is invoked. as described before, this reference is expandable and the structure of this function can be explored immediately. fib consists of an if statement and a for loop. as explained earlier in section 3.1, the transition in the for loop may be delayed or immediate depending on the selected compilation approach. eventually, the program returns the requested fibonacci number. following the code generation approach explained in section 3.1, a sequentialized netlist is generated for the fibonacci program. hence, two scgs for both functions, main and fib, are created. the netlist representation of both scgs can be seen in figure 16. the scg for the 15 / 20 volume 74 (2017) model extraction of legacy c code in sccharts figure 16: generated netlist of the extracted scchart depicted in figure 15b main function calls the scg of the fib function. as the netlist-based approach is designed for both, software and hardware, the computation is logically clocked, meaning that the actual computation of the fibonacci integer n requires n clock cycles. nonetheless, it is possible to create both new code (see figure 17a) and a circuit (see figure 17b) with the same approach. the clocked computation of the fibonacci example can be seen in figure 18. we chose c as target language, because we wanted to compare the source and the target code directly. of course, other languages are possible as well. additionally, if not interested in the hardware synthesis, the previously mentioned priority-based approach can also be used for code generation. usually, this code is more readable than the generated netlist. figure 18: clocked computation of the fibonacci number in the hardware circuit the guard expressions are enclosed in the same manner as the basic blocks in the scg. activated blocks enable the calculations of the assignments they guard. to preserve the values of the variables between clock ticks, values must be saved in registers. additionally, a static single assignment version of the scg has to be created for the circuit to allow multiple variable assignments within one clock tick. the different versions of a variable are indexed in figure 17b. the term is set to true permanently as soon as the calculation terminates. alternatively, it is also possible to only send the term signal for a single clock tick. this would require fewer hardware gates. as before in the sccharts visualization, the graphical diagram of the model also gets synthesized and layouted automatically instantaneously. isola ds 2016 16 / 20 eceasst 1 typedef struct { 2 char go; 3 char g7; 4 ... 5 } tickdata1; 6 7 void reset1(tickdata1 ∗d) { 8 d−>pg12 = 0; 9 d−> go = 1; 10 d−> term = 0; 11 } 12 13 void tick1(tickdata1 ∗d) { 14 ticklogic1(d); 15 d−> go = 0; 16 d−>pg12 = d−>g12; 17 } 18 void ticklogic1(tickdata1 ∗d) { 19 d−>g7 = d−> go; 20 if (d−>g7) { 21 d−>fl = 0; 22 d−>fh = 1; 23 } 24 d−> cg7 = d−>n <= 1; 25 d−>g8 = d−>g7 && d−> cg7; 26 if (d−>g8) { 27 d−>fh = d−>n; 28 } 29 d−>g13 = d−>pg12; 30 d−>g10 = d−>g7 && !d−> cg7; 31 if (d−>g10) { 32 d−> fib int local i = 2; 33 } 34 d−>g11 = d−>g13 || d−>g10; 35 d−> cg11 = 36 d−> fib int local i <= d−>n; 37 d−>g12 = d−>g11 && d−> cg11; 38 if (d−>g12) { 39 d−> fib int local tmp = d−>fh; 40 d−>fh = d−>fh + d−>fl; 41 d−>fl = d−> fib int local tmp; 42 d−> fib int local i = 43 d−> fib int local i + 1; 44 } 45 d−>g9 = d−>g11 && 46 !d−> cg11 || d−>g8; 47 if (d−>g9) { 48 d−>ret = d−>fh; 49 d−> term = 1; 50 } 51 } (a) generated c code of the netlist in figure 16 (excerpt of the fib function) (b) generated hardware circuit of the netlist in figure 16 figure 17: possible out-of-the-box compilation targets for the fibonacci example in figure 15 in the kieler sccharts tools 4 related work there are several model-based development or documentation tools that cover parts of our topic. the sccharts language, which is a dialect of harel’s statecharts [har87], was specifically developed for safety-critical systems. the kieler (kiel integrated environment for layout eclipse rich client) lets the user edit sccharts with a textual description, from which kieler then automatically creates a visual representation in the familiar statechart syntax. this auto17 / 20 volume 74 (2017) model extraction of legacy c code in sccharts matic layout allows the user to concentrate on the modeling problem without the need to handle tedious layouting tasks. the automatic layout is also an enabler for the model synthesis from c code presented here. the advanced simulation and control engineering tool (ascet)2 by etas gmbh is a product family for the model-based development of embedded automotive software. the main application area of ascet is the modeling of and the code generation for safety-critical systems such as electronic control units (ecus) for vehicles. the ehandbook3 also allows to extract visual models from c code and employs automatic layout for that. however, their representation is rather low level, data-flow oriented and based on a flat program dependence graph [fow87]. in comparison, our visualization based on sccharts is more control oriented and preserves highlevel control constructs such as loops by making use of sccharts hierarchy. doxygen4 is a tool for generating software reference documentation. doxygen can also produce graphs that give an overview of certain software aspects, such as call graphs and inheritance graphs. however, it cannot generate full models that capture the detailed software behavior. visual paradigm5 by visual paradigm international is a cross-platform modeling and management tool for it systems. its range of application reaches from modeling of software and databases to code generation and up to creating business process models. it also supports roundtrip engineering for java and c++ code which is also one of our goals. explorviz [fwwh13] is a monitoring tool for providing live trace visualization of the communication in software systems. it is able to give the user an overview of the flow of communications, but does not grant insight to the actual behavior of a function. a model-to-text code generation is not possible. hence, the model-based compilation of kieler is more suitable for maintaining the legacy code of a software system, rather than monitoring it. a number of modeling environments allow to synthesize code from visual models. the safetycritical application development environment (scade) suite6 product by esterel technologies is a model-driven software development tool for creating safety-critical embedded software. it is based on the formally defined synchronous data-flow programming language lustre [hcrp91] and offers both control-oriented and data flow modeling styles. scade offers a certified code generator. however, it cannot synthesize graphical models from textual code. ptolemy ii7 is an open-source software for developing and simulating actor-oriented models. actors are defined as software components. they execute concurrently and communicate with each other through message passing via interconnected ports. additionally, ptolemy ii enables c code generation from actor models. the .c-file is created by connecting specific template files for the different actors. the resulting c code serves as a template for further processing. edwards [edw05] presents a comprehensive overview of the challenges of synthesizing hardware from c and discusses a number of approaches. he also mentions the difficulty of handling loops. as discussed, the synchronous model of computation, as embodied by sccharts, allows to handle loops rather naturally by making use of the notion of a synchronous tick. in the absence of concurrency, we merely have to ensure that each control flow loop contains at least one delayed transition. 2 http:/www.etas.com/ascet 3 http:/www.etas.com/ehandbook 4 http://www.doxygen.org 5 https://www.visual-paradigm.com 6 http://www.esterel-technologies.com/products/scade-suite 7 http://ptolemy.eecs.berkeley.edu/ptolemyii isola ds 2016 18 / 20 eceasst 5 conclusion to summarize, the automatic extraction of c programs to models in a statechart notation is feasible. the extracted models can be used for technical documentation. however, finding “a best” visual representation for these models does not seem to be trivial even when considering only existing elements of the statechart dialect. even when only considering function calls, assignments, and a couple of control statements, there are many different possibilities to display the model. a good balance between compactness, overall overview, and simplicity has yet to be found and may be impossible in a general manner. nevertheless, extracted models of complex legacy code can help to understand and maintain these systems. we implemented a c extractor for the synchronous language sccharts. hence, besides using the automatically generated and layouted diagrams for documentation, the already existing code generation chain can be used to create new code of the legacy program for different platforms, including hardware circuits. again, deciding for one best-fit may not be possible and depends on the use case. this also influences the graphical notation of the statechart if one wants to preserve the semantics of the language as the different transition semantics of sccharts show. future work as future work, using alternative code generation approaches such as the prioritybased compilation approach of the kieler for software, the timing restrictions on loops should not be necessary anymore. however, this approach cannot be used to create hardware circuits [hdm+14]. additionally, at the moment supported c programs are limited to ansi c without pointers and structs. lifting these restrictions to process a significantly wider range of legacy c programs is work in progress. moreover, to validate the correctness and to evaluate the efficiency of our approach, we want to compare original c programs with their corresponding automatically generated counter-parts. therefore, we need to extend our code base and the kieler implementation to accept arbitrary test cases. furthermore, as the kieler tool suite and the included downstream compilation improves (e.g., more target platforms and improved language and development features), all advantages automatically become available for already extracted and yet to be extracted models. finally, to evaluate the graphical representation and the ability to serve as a suitable documentation language, further user case-studies must be conducted. especially when extracting larger programs, the readability of sccharts and the usability of the existing tools should be studied further. bibliography [edw05] s. a. edwards. the challenges of hardware synthesis from c-like languages. in proceedings of the conference on design, automation and test in europe volume 1. date ’05, pp. 66–67. ieee computer society, washington, dc, usa, 2005. [fow87] j. ferrante, k. j. ottenstein, j. d. warren. the program dependence graph and its use in optimization. acm trans. on programming languages and systems 9(3):319–349, 1987. [fwwh13] f. fittkau, j. waller, c. wulf, w. hasselbring. live trace visualization for comprehending large software landscapes: the explorviz approach. in proc. of the 1st ieee international working conference on software visualization (vissoft’13). pp. 1–4. sept. 2013. 19 / 20 volume 74 (2017) model extraction of legacy c code in sccharts [har87] d. harel. statecharts: a visual formalism for complex systems. science of computer programming 8(3):231–274, june 1987. [hcrp91] n. halbwachs, p. caspi, p. raymond, d. pilaud. the synchronous data-flow programming language lustre. proceedings of the ieee 79(9):1305–1320, sept. 1991. [hdm+14] r. von hanxleden, b. duderstadt, c. motika, s. smyth, m. mendler, j. aguado, s. mercer, o. o’brien. sccharts: sequentially constructive statecharts for safety-critical applications. in proc. acm sigplan conference on programming language design and implementation (pldi’14). acm, edinburgh, uk, june 2014. [im14] j. l. c. izquierdo, j. g. molina. extracting models from source code in software modernization. software and systems modeling 13(2):713–734, sept 2014. [msh14] c. motika, s. smyth, r. von hanxleden. compiling sccharts—a case-study on interactive model-based compilation. in proc. of the 6th international symposium on leveraging applications of formal methods, verification and validation (isola 2014). lncs 8802, pp. 443–462. corfu, greece, oct. 2014. [ols16] l. olsson. modellextraktion aus c code. bachelor thesis, kiel university, department of computer science, mar. 2016. http://rtsys.informatik.uni-kiel.de/∼biblio/downloads/ theses/leo-bt.pdf. [peb07] d. potop-butucaru, s. a. edwards, g. berry. compiling esterel. springer, may 2007. [rsm+16] f. rybicki, s. smyth, c. motika, a. schulz-rosengarten, r. von hanxleden. interactive model-based compilation continued – interactive incremental hardware synthesis for sccharts. in proc. of the 7th international symposium on leveraging applications of formal methods, verification and validation (isola 2016). lncs 8802, pp. 443–462. corfu, greece, oct. 2016. [sch06] d. c. schmidt. model-driven engineering. computer 39(2):25–31, feb. 2006. [smh15] s. smyth, c. motika, r. von hanxleden. a data-flow approach for compiling the sequentially constructive language (scl). in 18. kolloquium programmiersprachen und grundlagen der programmierung (kps 2015). pörtschach, austria, 5-7 oct. 2015. [spl03] r. c. seacord, d. plakosh, g. a. lewis. modernizing legacy systems: software technologies, engineering processes, and business practices. addison wesley, boston, massachusetts , usa, 2003. [ssh13] c. schneider, m. spönemann, r. von hanxleden. just model! – putting automatic synthesis of node-link-diagrams into practice. in proc. of the ieee symposium on visual languages and human-centric computing (vl/hcc’13). pp. 75–82. san jose, usa, 2013. [uml15] a. umland. konzept zur erweiterung von sccharts um datenfluss. diploma thesis, kiel university, department of computer science, mar. 2015. http://rtsys.informatik.uni-kiel. de/∼biblio/downloads/theses/aum-dt.pdf. isola ds 2016 20 / 20 http://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/leo-bt.pdf http://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/leo-bt.pdf http://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/aum-dt.pdf http://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/aum-dt.pdf introduction model extraction parsing c programs transforming c code to sccharts functions assignments control statements function calls first results netlist-based code generation full example related work conclusion revised gt-vmt-2008-camera-ready.dvi electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) a graph-based type representation for objects cong-cong xing 16 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 eceasst a graph-based type representation for objects cong-cong xing1 1 cmps-cx@nicholls.edu department of mathematics and computer science nicholls state university thibodaux, la, usa abstract: subtyping and inheritance are two major issues in the research and development of object-oriented languages, which have been traditionally studied along the lines of typed calculi where types are represented as a combination texts and symbols. two aspects that are closely related to subtyping and inheritance – method interdependency, and self type and recursive object type – have either been overlooked or not received sufficient/satisfactory treatments. in this paper, we propose a graph-based notation for object types and investigate the subtyping and inheritance issues under this new framework. specifically, we (1) identity the problems that have motivated this paper; (2) propose an extension to abadi-cardelli’s ς -calculus towards fixing the problems; (3) present definitions of object type graphs followed by examples; (4) define subtyping and inheritance using object type graphs; (5) show how the problems can be easily resolved under object type graphs; and (6) summarize the contributions of this paper. keywords: object type, graph transformation 1 introduction as pointed out by markku sakkinen in [sak05], although in recent years the emphasis of the research and development in object-oriented programming (oop) has shifted from programming languages (themselves) to larger entities such as components, environments, and manipulating tools, it does not mean that the existing object-oriented languages are perfect and no improvement is needed. in particular, typing is still a critical issue and a problem-prone area in the formal study of object-oriented languages, especially when type-related subjects, such as subtyping and inheritance, are considered. one aspect related to subtyping is object method interdependencies: the invocation relationship among methods. the failure of keeping track of this invocation structure in object types can cause elusive programming errors which will inevitably occur, undermine the program reliability, and burden the program verification. one aspect related to inheritance is self type vs. recursive object type: which one is the true type of the self variable (in the context of inheritance). the failure of not distinguishing these two types sufficiently can lead to some well-known fundamental problems. while the former aspect has been overlooked in the literature, the latter has not received sufficient attentions and/or satisfactory treatments, in either theoretical studies (e.g., [ac96, fhm94, lc96, liq98, bl95]) or mainstream practice (e.g., java and c++) of oop. in the next section, we present concrete examples to illustrate this point. 1 / 16 volume 10 (2008) a graph-based type representation for objects 2 motivations we present two problems that have motivated the writing of this paper. 2.1 method interdependency we call a rectangle free if its two sides (height and width) are independent, constrained otherwise. in conventional type systems, the type of a free rectangle and the type of a constrained rectangle are not distinguished. we show, in this subsection, that this type confusion opens the door to let the different semantics of free rectangles and constrained rectangles be mixed, which is serious enough to be able to cause a program not to perform to its specification and thus weakens its reliability. using abadi-cardelli’s first-order ς -calculus notation [ac96], we can construct a free rectangle frect, a constrained rectangle crect, and their types fr, cr as follows: fr def = µ(self )         h : int w : int mvh : int → self mvw : int → self geth : int getw : int         , frect def = ς (s : fr)         h = 1 w = 2 mvh = λ (i : int)(s.h⇐s.h + i) mvw = λ (i : int)(s.w⇐s.w + i) geth = s.h getw = s.w         , cr def = µ(self )         h : int w : int mvh : int → self mvw : int → self geth : int getw : int         , crect def = ς (s : cr)         h = 1 w = 2(s.h) mvh = λ (i : int)(s.h⇐s.h + i) mvw = λ (i : int)(s.w⇐s.w + i) geth = s.h getw = s.w         . informally, fr denotes the (data) type of the object frect (explained below) which contains the following fields/methods: h, w, mvh, mvw, geth, getw. also, the types of h, w, geth, getw are all int, signifying that when these fields/methods are called, they will return an integer. the types of mvh, mvw are both int → self , where the variable self is bound by the standard recursion binder µ . in other words, we can understand the types of mvh and mvw as int → fr, meaning that these methods take an integer and returns an object of type fr. the type cr can be understood similarly. (actually, we can see that fr and cr specify the same type here.) frect denotes an object which consists of fields/methods h, w, mvh, mvw, geth, getw. the values of h and w are 1 and 2 respectively. method geth, when being called, returns the value of h. (the symbol s in s.h represents the hosting object in such a way that we can regard s.h as this.h in java.) getw is similar to geth. method mvh is a function that takes an integer i, adds it to the current value of h, updates/overrides the current value of h by the sum, and returns the newly updated object. method mvw is similarly to mvh. while object crect works in a similar fashion to object frect, note their difference: in frect, the height (h) and the width (w) are independent, whereas in crect, the width depends on the proc. gt-vmt 2008 2 / 16 eceasst height (w = 2(s.h)). also note that f r = cr, that is, the types of these two rectangles are confused (in conventional type systems). now, suppose we would like to have a function with the following specification (contract): this function takes a rectangle and then doubles both its height and its width. with little effort, such a function can be written as: ds def = λ (r : f r)(r.mvh(r.geth)).mvw(r.getw). it is easy to check that ds will double its argument’s both sides when taking a free rectangle as argument. however, when ds takes a constrained rectangle as argument, for example ds(crect) (due to the fact cr = f r, crect will type-check), it will fail to do so, as it is supposed to (by the specification). in detail, ds(crect) = (crect.mvh(crect.geth)).mvw(crect.getw) = ς (s : cr)   h = 2 w = 6 . . . no change . . .   . clearly, the height of crect is doubled, but its width is tripled (not doubled)! the reason for this is the interdependency between the height and the width in crect: when the height of crect is changed to 2, its width is implicitly changed to 4 due to the width’s dependence on the height. considering that the widely-agreed notion of program reliability refers to (e.g. [seb07]) “program performs to its specification under all circumstances” and that the fact that ds does not live up to its specification when taking crect as its argument, we argue that the reliability of ds, in the environment of conventional type systems, is substantially low. furthermore, such elusive computation fault may be hard-to-detect when ds is embedded in large software systems. to resolve this problem effectively, ds should be written in such a way that it only takes free rectangles, that is, ds(crect) should be caught by the type checker. this observation calls for the separation of the type of free rectangles from that of constrained ones. 2.2 self type and recursive object type the notion of self type is coined to describe the type of the self variable in an object, especially when the object contains a self returning method. then the question is: what is the (semantics of) self type? is it just the (recursive) object type or something else? for example, using the notation of ς -calculus again, an object which consists of two methods, one returning the constant 1 and one returning the hosting object itself can be coded as a def = [l1 = 1, l2 = ς (s : x )s], where s is the self variable and x is the type of s – the self type. how do we interpret x ? one “natural” way is that x is just the object type itself (recursively defined), that is, x = µ(y )[l1 : int, l2 : y ]. as this interpretation works to some extent but runs into substantial problems (see, e.g., [ac96] for details), other explanations of the self type have been sought. for example, the second-order self quantifier [ac96] and the mytype [bru94] are proposed. nevertheless, no mater how self type is interpreted, an object type has always been managed to be a subtype of the associated 3 / 16 volume 10 (2008) a graph-based type representation for objects self type. this setup, combined with inheritance and dynamic dispatch of methods, leads to the well-known “method-not-found” error as illustrated below (adapted from [bru94]). pt def = ob jecttype(mytype){x : int, eq : mytype → bool} cpt def = ob jecttype(mytype){x : int, c : color, eq : mytype → bool} pt0 def = ob ject(self : mytype){x = 0, eq = f un(p : mytype)(p.x = self .x)} pt def = ob ject(self : mytype){x = 1, eq = f un(p : mytype)(p.x = sel f .x)} cpt def = inherited f rom pt with {c = red, eq = f un(p : mytype)[(p.x = sel f .x)∧(p.c = sel f .c)]} f def = f un(p : pt )(p.eq(pt0)) given these definitions, it is easy to check that pt0 : pt , pt : pt , and cpt : cpt . note that in the definition of f , we actually have assumed (as [bru94] does) that the type of pt0, pt , is a subtype of the self type associated with pt , mytype in this case, so that p.eq(pt0) typechecks. now, if inheritance implies subtyping (as we have been practicing in c++ and java), then cpt : cpt <: pt and f(cpt) will type check. however, f(cpt) will crash and produce a “method-not-found” error because cpt.eq(pt0) expects its argument, pt0 , to have a color field and uses that color field in the body of eq of cpt, but pt0 does not have the color field. traditionally, it is this kind of problem that has prompted us to claim that “inheritance is not subtyping” [chc90]. however, “inheritance implies subtyping” is a strongly desirable property in oop. without it, the software hierarchy build through inheritance will be much less useful since in this case a subobject (object from a subclass) cannot be regarded as having the same type with its superobject (object from the superclass), and cannot use any existing programs that have been written for superobjects. program reusability will thus be greatly reduced. towards keeping this hierarchy useful and resolving the method-not-found problem at the same time, we propose that an object type should not only be treated differently from its associated self type, but not be regarded as a subtype of its associated self type either. 3 enhancing object types in order to address the problems outlined in the previous section, we extend abadi-cardelli’s ς -calculus by adding a mechanism called links that capture the method interdependencies in objects, and by distinguishing (recursive) object types from their associated self types. the terms (m) and types (σ ) of this extended calculus are as follows. m ::= x | λ (x : σ ).m | m1m2 | m.l | m.l⇐ς (x : s (a))m′ | [li = ς (x : s (a))mi]ni=1 σ ::= κ | t | σ1 → σ2 | µ(t)σ | a | s (a) a ::= ι (t)[li(li) : σi]ni=1 li ⊆{l1, . . . , ln} for each i x, λ (x : σ ).m, and m1m2 are the standard λ -terms, where x is a variable, λ (x : σ ).m stands for a function with parameter x of type σ and body m, and m1m2 denotes the function application proc. gt-vmt 2008 4 / 16 eceasst (m1 is applied to m2). [li = ς (x : s (a))mi]ni=1 represents an object consisting of n methods, with names li and bodies mi for each i. ς is the self-binder. m.l means the invocation of method l in m. m.l⇐ς (x : s (a))m′ is the updating operation which evaluates to an object obtained by replacing method l in m by m′. (see section 2.1 for more detailed explanations.) κ , t, σ1 → σ2, and µ(t)σ are ground types, type variables, function types, and recursive types respectively. object types are represented by ι (t)[li(li) : σi]ni=1 where each method li has type σi, and li is the set of links of li (defined below). ι is the self-type binder. an alternative way to represent self type is s (a) which denotes the self type associated with the object type a. the two notations are related by a = ι (t)[li(li) : σi(t)]ni=1 = [li(li) : σi(s (a))] n i=1. terms that can be of a self type are restricted to self (variable) or a modified self (for the sake of self variable specialization during inheritance). definition 1 given an object [li = ς (s :s (a))mi]ni=1. the only terms that are of type s (a) are s or s.li⇐ς (s : s (a))m for some m. the set of links, which is a part of the newly proposed object types, is defined as follows. definition 2 (links) given an object a = [li = ς (s : s (a))mi]ni=1, (1) li is said to be dependent on l j(i 6= j) if there exists a m such that a.li and (a.l j⇐ς (s:s (a))m).li evaluate to different values. (2)the set of links of li in object a (or equivalently, of mi with respect to object a), denoted by la(li) (or equivalently, by la(mi)), contains exactly all such l j on which li is dependent. remarks: the idea behind “method li is dependent on method l j in object a” is the following: if we can make some change to the body of l j , and that change affects the evaluation of li (compared with the evaluation of li before the change is made to l j), then we say that “li is dependent on l j”. taking the collection of all such l j ’s on which li is dependent forms the set of links of li in object a — la(li). 4 object type graphs the notion of links introduces new structures into object types. object types are thus enriched but also become more complicated. to effectively analyze and reason about the structure of the new object types, we present a graph-based representation for object types – object type graphs (otg). 4.1 definitions definition 3 (directed colored graph) a directed colored graph g is a 6-tuple (gn , ga,c, sr,tg, c) consisting of: (1) a set of nodes gn , and a set of arcs ga; (2) a color alphabet c; (3) a source map sr : ga → gn , and a target map tg : ga → gn , which return the source node and target node of an arc, respectively; and (4) a color map c : gn ∪ga →c, which returns the color of a node or an arc. 5 / 16 volume 10 (2008) a graph-based type representation for objects definition 4 (ground type graph) a ground type graph is a single-node colored directed graph which is colored by a ground type. definition 5 (function type graph) a function type graph (s, g1, g2)(gn ,ga,c,sr,tg,c) is a directed colored graph consisting exactly of a starting node s ∈ gn , and two type graphs g1 and g2, such that, (1) c(s) =→; (2) there are two arcs associated with the starting node s, left arc l ∈ ga and right arc r ∈ ga, such that c(l) = in, c(r) = out; l connects g1 to s by sr(l) = sg1 , tg(l) = s, and r connects s to g2 by sr(r) = s, tg(r) = sg2 , where sg1 and sg2 are the starting nodes of g1 and g2, respectively; (3) g1 and g2 are disjoint; (4) if there is an arc a ∈ ga with c(a) = rec, then sr(a) = sgi , tg(a) = s, c(sgi ) =→, i = 1, 2. definition 6 (object type graph) an object type graph (s, a, r, l, s)(gn ,ga,c,sr,tg,c) is a directed colored graph consisting exactly of a starting node s ∈ gn , a set of method arcs a ⊆ ga, a set of rec-colored arcs r ⊆ga, a set of link arcs l ⊆ ga, and a set of type graphs s, such that (1) c(s) = self. (2) ∀a ∈ a, sr(a) = s, tg(a) = sf for some type graph f ∈ s, and c(a) = m for some method label m; c(a) 6= c(b) for a, b ∈ a, a 6= b. (3) ∀r ∈ r, c(r) = rec, tg(r) = s, sr(r) = sf for some f ∈ s, and c(sf ) = self. (4) ∀l ∈ l, sr(l) = sf , tg(l) = sg for some f, g ∈ s, and c(l) = bym for some method label m. remarks: directed colored graph is the foundation of graph grammar theory [eps73, ehr78, roz97]. object type graphs are adapted from directed colored graphs. ground type graphs are trivial. function type graphs are straightforward. they need to be defined because an object type graph may include them as subgraphs. the basic idea of object type graphs can be described as follows: for object type ι (t)[li(li): σi]ni=1, we use a designated node — the starting node s which is colored by self — to represent the self type; for each method li of type σi, we represent it by a li-colored arc that starts from s and ends at a node which (1) is colored by σi if σi is a ground type, or (2) is the starting node of a (sub-) type graph otherwise; for each link l ∈ li of li, we represent it by an arc which is colored by byl and goes from the end node of the arc representing l to the end node of the arc representing li. for the sake of brevity, we drop the subscripts in (s, g1, g2)(gn ,ga,c,sr,tg,c) and (s, a, r, l, s)(gn ,ga,c,sr,tg,c) whenever possible throughout the paper. 4.2 examples of otg we now provide some examples to illustrate the definitions introduced in the last section. throughout this section, if the type of an object a is represented by a graph a, we will say the type of a is a, and vice versa. example 1 in figure 1, a, b, and c are the type graphs for the three ground types int, real, and bool respectively. they are just a node colored by the appropriate ground types. d is the type graph for function type int → int. e is the type graph for (int → b) → int, where b is the object type in figure 2(a) which will be explained in the next example. example 2 in figure 2(a), graph a denotes the object type [x : int, y : int], where methods x and proc. gt-vmt 2008 6 / 16 eceasst int int in out in out d e x y self intint byx int in int out int int in out in out c e x y self intint byx int in int out real bool int b a figure 1: examples of ground type graphs and function type graphs. x y self s intint x y self s intint byx a b (a) a b self selfint x mvx self int byx a b c rec int in out bya byb (b) figure 2: example of object type graphs y are independent of each other. graph b denotes the type [x : int, y({x}) : int] where y depends on x. note that the direction of the link arc in b is from x to y (not from y to x), and that the link is colored by byx, signifying that changes made to method x will affect method y. for instance, an object of type a may be [x = 1, y = 2] (which is actually a record), and an object of type b may be [x = 1, y = ς (s : s (b))(s.x + 2)]. note also that although the presence of the link in b or the absence of the link in a serves as an extra condition (compared to conventional type systems) for selecting objects to be typed as a or b respectively, there are still infinitely many objects that are of type a or type b. for example, objects [x = m, y = n] with m, n ∈ n are all of type a; objects [x = n, y = ς (s : b)(a(s.x) + b)] with n, a, b ∈ n are all of type b. in this sense, otg is (still) an abstract specification of object behaviors. example 3 in figure 2(b), a is the type graph for ι (t)[x : int, mvx({x}) : int → t] which is the type of a simplified 1-d movable point [x = 1, mvx = ς (s : b)λ (i : int)(s.x⇐s.x + i)]. the facts that mvx depends on x and returns a modified self object are indicated by the byx-colored arc and the out-colored arc respectively. note the direction of the out-colored arc goes to the starting node of the type graph directly, indicating that this is a self type (as opposed to recursive objet type). graph b represents the type of the object[a = 1, b = p, c({a, b}) = ς (s : s (b))s] where p is some predefined object of type b. here, note that the fact that b is of recursive object type is depicted by a sel f -colored node and a rec-colored arc going from this node to the starting node of the graph; and that the fact that c is of self type is depicted by its method arc going directly 7 / 16 volume 10 (2008) a graph-based type representation for objects to the starting node of the graph. the difference between recursive object type and self type is clearly represented in object type graphs. 5 subtyping under otg given the definition of otg, we now investigate the issue of subtyping under otg. throughout the paper, we write aσ <: bτ iff σ <: τ where σ andτ are types and aσ and bτ are their type graphs. we first present the necessary definitions and then provide some subtyping examples. 5.1 definitions definition 7 (type graph premorphism) let φ be the set of ground types. given two type graphs g = (gn , ga,c, sr,tg, c) and g ′ = (g′n , g ′ a,c ′ , sr′,tg′, c′), a type graph premorphism f : g → g′ is a pair of maps ( fn : gn → g ′ n , fa : ga → g ′ a), such that (1) ∀a ∈ ga, fn (sr(a)) = sr′( fa(a)), fn (tg(a)) = tg ′( fa(a)), and c(a) = c ′( fa(a)); (2) ∀v∈gn , if c(v)∈φ, then c′( fn (v))∈ φ; otherwise c(v) = c′( fn (v)). definition 8 (base, subbase) given an object type graph g = (s, a, r, l, s). the base of g, denoted by ba(g), is the graph (s, a,t(a), l), where t(a) = {tg(a) | a ∈ a}. a subbase of g is a subgraph (s, a′,t(a′), l′) of ba(g), where a′ ⊆ a, l′ ⊆ l, t(a′) = {tg(a) | a ∈ a′}, and for each l ∈ l′ there exist a1, a2 ∈ a ′ such that sr(l) = tg(a1) and tg(l) = tg(a2). definition 9 (closure, closed) the closure of a subbase d = (s, a′,t(a′), l′) of an object type graph g = (s, a, r, l, s), denoted by cl(d), is the union d∪e1 ∪e2, where (1) e1 = {l ∈ l | ∃a1, a2 ∈ a ′ with tg(a1) = sr(l), tg(a2) = tg(l)}, and (2) e2 = {l, h, a,t(l) | l, h ∈ l, a ∈ a, a 6∈ a′, tg(l) = sr(h) = tg(a), and ∃a1, a2 ∈ a ′ such that tg(a1) = sr(l), tg(a2) = tg(h)}. a subbase d is said to be closed if d = cl(d). definition 10 (covariant, invariant) given an object type graph (s, a, r, l, s). let t(a) = {tg(a) | a ∈ a}. for each v ∈ t(a), if v is not incident with any links, or if v is the target node of some links but not the source node of any links, then v is said to be covariant; otherwise, v is said to be invariant. definition 11 (object subtyping) given two object type graphs g = (sg, ag, /0, lg, sg) and f = (sf , af , /0, lf , sf ). f <: g if and only if the following conditions are satisfied: (1) there exists a premorphism f from ba(g) to ba(f ) such that f (ba(g)) = cl( f (ba(g))). that is, f (ba(g)) is closed. (2) for each node v in f (ba(g)), let u be its preimage in ba(g) under f , fv ∈ sf be the type graph with v as its starting node, and gu ∈ sg be the type graph with u as its starting node. (i) if v is invariant, then fv is isomorphic to gu. (ii) if v is covariant, then fv <: gu. remarks: we now briefly explain the intuitive ideas behind these definitions. type graph premorphism is adapted from graph morphism which is a fundamental concept in algebraic graph grammars [eps73, ehr78, roz97]. it preserves the directions and colors of arcs and the colors of nodes up to ground types. the base of an object type graph singles the method interdependency proc. gt-vmt 2008 8 / 16 eceasst x y self intint x y self real int byx a b byx v (a) x y self intint x y self real pos byx a b byx v u u' (b) figure 3: examples of object subtyping information out of the entire object type graph so that the structure of the method interdependencies can be better studied. a subbase of a base is a subgraph of the base and this subgraph by itself forms a base (of another object type graph). the closure of a subbase captures the complete behavior of the subbase by including, in addition to all methods and links in the subbase, all necessary methods and associated links outside of the subbase. a subbase is closed if it coincides with its closure. the notions of covariance and invariance are used to characterize whether the change of a method can affect another method by checking the directions of links that are incident with the method. the subtyping relation of two object types is given by first checking the structures of the two object type graphs to ensure that they have the same kind of behaviors, and then checking the subtyping relations for their subtype graphs. 5.2 examples we now present some simple subtyping examples. example 4 given the two type graphs in figure 3(a), clearly we can find a premorphism f from base of a to base of b such that f (ba(a)) is closed; note also that node v in b is covariant. thus, b <: a. as an example, we can regard the object [x = 1, y = ς (s : s (b))(s.x + 1)] of type b as having type a. example 5 for the two type graphs in figure 3(b), we can also find a premorphism from the base of a to the base of b, and node v in b is also covariant. but, node u in b is invariant which requires the corresponding node u′ in a have the same color – pos (standing for positive integer) in order to have b <: a. but u′ is colored by int, hence, b 6<: a. as an example to justify that b 6<: a, let b = [x = 1, y = ς (s : s (b))(log(s.x) + 1)], it is easy to check b : b. if b <: a, then b : a, and in this case we can update the x field in b to a negative integer, say, -1, resulting an object like b = [x = −1, y = ς (s : s (b))(log(s.x) + 1)]. in this object, the invocation of method y will crash since log is not defined over negative integers. example 6 considering the graphs a and b in figure 4(a), it is easy to check (similar to the case of example 4) that b <: a. as an example for this subtyping, an object [x = 1, y = ς (s : s (b))(s.x + 1), z = 1]which is of type b, can clearly be regarded as having type a. example 7 let us revisit the two object types in figure 2(a). we have b 6<: a, since we cannot 9 / 16 volume 10 (2008) a graph-based type representation for objects x y self intint x y self real byx a b byx v z int int (a) h w mvh mvw byw getw geth int intself int int byh byw in out in out byh f int int h w mvh mvw byw getw geth int intself int int byh byw in out in out byh c int int byh (b) figure 4: examples of object subtyping find a premorphism f from ba(a) to ba(b) such that f (ba(a)) is closed. similarly, there exists no such a premorphism g from ba(b) to ba(a) such that g(ba(b)) is closed, so a 6<: b. one may wonder what kind of type (graph) can be of a subtype of a or b respectively. any subtype of a must not have a link between methods x and y; and any subtype of b must have a link going from x to y. this is the structural requirement in definition 11. as a result, object [x = 1, y = 1] cannot be regarded as having the same type with the object [x = 1, y = ς (s : s (b))(s.x + 1)], and vice versa. one may contend that this subtyping is too restrictive so that some “good” subtyping instances are not allowed by it; we argue that this is the trade-off in the sense that the strictness of this subtyping can block and prevent potential programming errors, as shown in the next example. example 8 as the last example, we show how the “free or constrained rectangles problem” described in section 2.1. the (new) types of the free rectangle frect and the constrained rectangle crect are depicted as f and c in figure 4(b). note that the independence between the height and the width in the free rectangle frect and their dependency in the constrained rectangle crect are faithfully shown by the absence and presence of a byh-colored link between methods h and w in f and c, respectively. it is easy to check that c 6<: f . so if we modify the function ds of section 2.1 by replacing its parameter type f r by the new type f in figure 4(b), then the call ds(crect) will be rejected under otg by the compiler since it does not type-check. 6 inheritance under otg we now turn to the issue of inheritance. some basic notions in graph grammar are needed before we can define inheritance formally. 6.1 definitions definition 12 (type graph production) a type graph production p is a pair of type graph premorphisms f : k → a1 and g : k → a2, where a1 is called the left side, a2 the right side, and k the interface. this is denoted as p = (a1 f ← k g → a2). proc. gt-vmt 2008 10 / 16 eceasst p b a k f po gf' g' p' i j h (a) graph gluing definition p hd s tk f g k po po1 2 (b) direct derivation definition figure 5: definitions of graph gluing and direct derivation definition 13 (type graph gluing) given two type graph premorphisms f : k → a and g : k → b. the gluing of a and b along k is the pushout of k f → a and k g → b in the category formed by type graphs together with type graph premorphisms (figure 5(a)). definition 14 (direct derivation) given type graphs p, d, h , a type graph production p = (s f ← k g → t ), and a premorphism k : s → p (called a context map). we say that h is directly derived from p via p by k, denoted by p (p,k) =⇒ h , if p is the result of gluing s and d along k and h is the result of gluing d and t along k (figure 5(b)). definition 15 (unfolding production and operation) a graph production u = (s f ←−k g −→ g) is called an unfolding production if (1) k is a graph consisting of two nodes v1 and v2, and c(v1) = c(v2) = sel f ; (2) s is a graph consisting of two nodes u1 and u2 and an arc t such that c(u1) = c(u2) = sel f , c(t) = rec, sr(t) = u2, and tg(t) = u1; (3) f (vi) = ui, i = 1, 2; g is a partial morphism with g(v2) = sg where sg is the starting node of g. given an unfolding production u = (s f ←− k g −→ g), an object graph f , and a premorphism i : s → f , we say f unfolds to p if f (u,i) =⇒ p. definition 16 (addition production and operation) a graph production a = (s f ←−k g −→g) is called an addition production, if (1) k consists of only one node v, and c(v) = sel f ; (2) s consists of only one node u, and c(u) = sel f ; (3) f (v) = u and g(v) = sg where sg is the starting node of g. given an addition production a = (s f ←− k g −→ g), an object graph f , and a premorphism j : s → f , we say that p is the result of adding g into f if f (a, j) =⇒ p. definition 17 (link production and operation) a graph production l = (s f ←− k g −→ g) is called a link production, if (1) g is a graph consisting of two nodes v1, v2 and an arc a connecting these two nodes. c(vi) (i = 1, 2) is either a ground type or a → or a sel f , and c(a) = bym, where m is the color of one of the methods in g; (2) k is a graph consisting of two nodes u1 and u2 with c(ui) is either a ground type or a → or a sel f , i = 1, 2; (3) s is isomorphic to k, that is, f is an isomorphism from k to s; g is an injection with g(ui) = vi, i = 1, 2; given a link production l = (s f ←− k g −→ g), an object graph f , and a premorphism k : s → f , we say that p is the result 11 / 16 volume 10 (2008) a graph-based type representation for objects x y self s intint byx b z self s c int v self s x y self s intint byx d int a f f' g' z v g (a) graph gluing self selfself self self self int rec rec p q f g u u s1 2 v1 v2 self self real p q gks i self self real rec p q s f self real p q self self real recp q s p r g f (b) unfolding operation figure 6: examples of graph gluing and unfolding operation of embedding g into f if f (l,k) =⇒ p. definition 18 (inheritance construction of object type graphs) given object type graphs f and g. f is said to be inherited from g if g can be transformed into f through a finite sequence of unfolding operations, addition operations, and link operations. definition 19 (inheritance) given object type graphs s and t , an object of type t can be constructed by inheritance from an object of type s if t is inherited from s. remarks: the central idea here is that inheritance of objects should be guided and guarded by object types. we devise, through some basic graph transformation techniques, an “inheritance” notion on object types, and then use this notion to judge whether an object can be built through inheritance from another object. specifically, type graph production, type graph gluing, and direct derivation are the standard graph grammar notions in the context of object type graphs. an object type graph can be inherited from another object type graph, if the second object type graph can be transformed into the first one through a sequence of combinations of three special productions: unfolding production, addition production, and link production. an object can be constructed from another object via inheritance if and only if the type of the first object can be inherited from the type of the second object. 6.2 examples we now give some examples to demonstrate the graph operation definitions in the last section. example 9 a graph gluing example is shown in figure 6(a), where f and g map the only node in a to the sel f -colored node in b and c respectively, and d is the result of gluing b and c along a. intuitively, this gluing operation entails the connection of b and c by identifying their starting nodes. proc. gt-vmt 2008 12 / 16 eceasst int x out eq p byx in bool self int x out eq byx in bool self color c self self self color c int x out eq byx in bool self int x out eq cp byx in bool self color byc c int x out eq byx in bool self color c color color color int x out eq byx in bool self color c byc p' p' figure 7: cp is inherited from p. example 10 figure 6(b) shows an unfolding operation. f (u,i) =⇒ p, where u = (s f ←− k g −→ g), f (vi) = ui, i = 1, 2, g(v2) = sg, i(u1) = sf , i(u2) = r. as we can see, p can be understood as constructed by deleting the rec-colored arc from f , and then glue the result with a copy of the original f by identifying the starting node of the former with the source node of the rec-arc of the latter. example 11 we finally show how the “colored point problem” addressed in section 2.2 can be resolved under otg inheritance and subtyping. the type of points pt and pt0 and the type of color point cpt are depicted as p and cp in figure 7 respectively. we can see that cp is inherited from p (through one addition operation and one link operation), which means that cpt can be constructed by inheritance from pt (or pt0). moreover, it is easy to check that cp <: p under otg subtyping, which indicates that inheritance and subtyping are congruent in this case. (note that this contrast with the “inheritance is not subtyping” slogan in the literature which is mainly motivated by this colored point example.) finally, the crash of f(cpt) is prevented since the function f , as defined in section 2.2 and in the literature, does not type-check under otg typing. note in its definition, f = f un(p : pt )(p.eq(pt0)), with pt = ob jecttype(mytype){x : int, eq : mytype → bool}, p.eq requires an argument of the self type associated with pt , s (pt ), but pt0 has type pt , and pt is neither the same as nor the subtype of s (pt ) under otg. 7 resolution of the problems as examples of otg subtyping and inheritance, we have demonstrated in the last section that the two problems outlined in section 2 can be successfully resolved under otg subtyping and inheritance mechanisms. here, we just summarize some major points. • otg subtyping takes into consideration the method interdependencies in objects. an object in which there is no dependence between two methods can never be regarded as having the same type with or a subtype of that of an object in which there is an interdependency between these two methods, and vice versa. the problem addressed in section 2.1 can be naturally resolved in otg since there is an interdependency between height and width in constrained rectangles, and there is no such interdependency in free rectangles. conse13 / 16 volume 10 (2008) a graph-based type representation for objects quently, these two kinds of rectangles have different types. • otg inheritance replies on basic graph derivations. the fundamental idea in this respect is that inheritance on objects should be regulated using type information of the relevant objects. an “inheritance” relation over object types is first defined using graph derivations and then used to determine whether an object can be constructed by inheritance from another one. • “inheritance is not subtyping” has been advocated in the literature for quite a while. despite that, the mainstream oop still adheres to the practice that “inheritance indicates subtyping”. one of the reasons for this is that without this practice, the software hierarchy built by inheritance would be almost useless. thus this practice is highly desirable. the“colored point problem” described in section 2.2 is one of the motivating examples that has prompted “inheritance is not subtyping”, because otherwise we will face some “method-not-found” error. under otg, we give this problem a new solution in the sense that “inheritance indicates subtyping” is retained and ”method-not-found” error is avoided. 8 related work representing object types as directed colored graphs and subsequently addressing the subtyping and inheritance issues by graph transformations is our original idea. it uniquely connects the type theory of object-oriented languages to algebraic graph transformation theory. the foundations of type theory can be found in [bar92, ac96, pie02], and the recent results and directions in type theory research are reflected in, for example, [prb07, che07, dhc07]. the origin of algebraic graph grammar and graph transformation can be traced back to [eps73, ehr78], and [roz97, eept06] present a comprehensive coverage of this research area. for current trends and developments in graph transformation, see for example, the proceedings of gt-vmt and icgt [eg07, cem+06]. incidentally, it is interesting to note that the phrase “type graph” has been used inconsistently in the literature. for example, it is used to denote the disjunctive rational trees in prolog type analysis and database query algebra [hcc93, sch01], to facilitate the investigation of quantification in type logical grammar [bs06], and to give types for (some other) graphs in graph transformation study [gl07, eept06]. none of these is the same as the (object) type graphs introduced in this paper. in particular, the notion of type graphs which is used frequently in the domain of graph transformations refers to the directed graphs which are designated to abstract the properties of other (more complex) graphs and thereby to render the type of those graphs; whereas the notion of the type graphs addressed in this paper refers to a graphical representation of the usual data types (e.g., primitive types, function types, object types, etc.). nevertheless, both notions are the abstraction of certain entities: the former is the abstraction of graphs and the latter is the abstraction of values. 9 final remarks subtyping and inheritance are two major issues in oop. although both issues have been studied extensively, problems still persist. two particular problems, method interdependencies and proc. gt-vmt 2008 14 / 16 eceasst “inheritance is not subtyping”, are identified and subsequently addressed by a graph-computing (otg) approach in this paper. it is demonstrated that both problems can be resolved effectively under otg subtyping and inheritance mechanisms. bibliography [ac96] m. abadi, l. cardelli. a theory of objects. springer-verlag, new york, 1996. [bar92] h. barendregt. lambda calculi with types. in s. abramsky (ed.), handbook of logic in computer science. volume 2, pp. 117–309. clarendon press, oxford, 1992. [bl95] v. bono, l. liquori. a subtyping for the fisher-honsell-mitchell lambda calculus of objects. in proc. of international conference of computer science logic. lncs 933, pp. 16–30. 1995. [bru94] k. bruce. a paradigmatic object-oriented programming language: design, static typing and semantics. journal of functional programming 4(2):127–206, 1994. [bs06] c. barker, c. chieh shan. types as graphs: continuations in type logical grammar. j. of logic, language and information 15(4), 2006. [cem+06] a. corradini, h. ehrig, u. montanari, l. ribeiro, g. rozenberg (eds.). proc. of icgt’06. lncs 4178, springer, 2006. [chc90] w. cook, w. hill, p. canning. inheritance is not subtyping. in proc. of popl. pp. 125–135. 1990. [che07] j. chen. a typed intermediate language for compiling multiple inheritance. in proc. of popl’07. pp. 25–30. 2007. [dhc07] d. dreyer, r. harper, m. chakravarty. modular type classes. in proc. of popl’07. pp. 63–70. 2007. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer, 2006. [eg07] k. ehrig, h. giese (eds.). proc. of gt-vmt’07. http://eceasst.cs.tu-berlin.de/, 2007. [ehr78] h. ehrig. introduction to the algebraic theory of graph grammars. in graphgrammars and their applications to computer science and biology. lncs 73, pp. 1–69. springer-verlag, 1978. [eps73] h. ehrig, m. pfender, h. j. schneider. graph grammars: an algebraic approach. in ieee conference of automata and switching theory. pp. 167–180. 1973. [fhm94] k. fisher, f. honsell, j. mitchell. a lambda calculus of objects and method specialization. nodic journal of computing 1:3–37, 1994. 15 / 16 volume 10 (2008) a graph-based type representation for objects [gl07] e. guerra, j. de lara. adding recursion to graph transformation. in proc. of gtvmt’07. 2007. [hcc93] p. v. hentenrck, a. cortesi, b. l. charlier. type analysis of prolog using type graphs. technical report, brown university, technical report cs-93-52, 1993. [lc96] l. liquori, g. castagna. a typed lambda calculus of objects. lncs 1179, pp. 129–141. sringer–verlag, 1996. [liq98] l. liquori. on object extension. in ecoop’98 object-oriented programming. lecture notes in computer science 1445, pp. 498–522. sringer–verlag, 1998. [pie02] b. pierce. types and programming languages. mit press, 2002. [prb07] p. permandla, m. roberson, c. boyapati. a type system for preventing data races and deadlocks in the java virtual machine language. in proc. of lctes’07. pp. 1–10. 2007. [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation. volume 1. world scientific, 1997. [sak05] m. sakkinen. wishes for object-oriented languages. in proc. of langages et modeles a objets (lmo 2005, invited talk). 2005. [sch01] k.-d. schewe. on the unification of query algebras and their extension to rational tree structures. in proc. of 12th australasian database conference. pp. 52–59. 2001. [seb07] r. sebesta. concetps of programming languages. addison wesley, 8th edition, 2007. proc. gt-vmt 2008 16 / 16 deriving barbed bisimulations for bigraphical reactive systems electronic communications of the easst volume 16 (2009) proceedings of the doctoral symposium at the international conference on graph transformation (icgt 2008) deriving barbed bisimulations for bigraphical reactive systems davide grohmann, marino miculan 15 pages guest editors: andrea corradini, emilio tuosto managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst deriving barbed bisimulations for bigraphical reactive systems davide grohmann1, marino miculan2 1 grohmann@dimi.uniud.it, 2 miculan@dimi.uniud.it department of mathematics and computer science, university of udine, italy abstract: we study the definition of a general abstract notion of barbed bisimilarity for reactive systems on bigraphs. more precisely, given a bigraphical reactive system, we define the corresponding barbs from the contextual labels given by the ipo construction, in a general and systematic way. these barbs correspond to observe which names on the interface are actually involved in reactions (and how). as examples, we apply this construction to the (bigraphical representation of the) π -calculus and of mobile ambients, and compare the resulting barbed equivalences with those previously known for these calculi. keywords: bigraphs, barbed bisimulations, π -calculus, mobile ambients. 1 introduction bigraphical reactive systems (brss) [12] have been proposed as a promising meta-model for concurrent, communicating, mobile systems. they have been successfully used for representing many calculi and models, e.g. ccs, π -calculus, petri nets, mobile ambients, fusion calculus among others [8, 11, 2, 5]. brss owe much of their expressivity to the fact that their states are bigraphs, semi-structured data which can represent at once both the (physical, logical) location and the connections of the components of a system. the dynamics of the system is represented by a set of rewrite rules on this semi-structured data. an important property of brss is that they support the systematic definition of labelled transition systems via so-called ipo construction [8], which identifies the labels for a given agent as the minimal contexts which trigger a transition. notably, the strong bisimilarity induced by this lts is always a congruence, and this has been extended also to weak bisimilarity [6]. in this paper, we continue this line of research by defining a general abstract notion of barbed bisimilarity for brss. barbed bisimilarity is interesting for many reasons; e.g., its definition does not rely on a lts, and usually barbed bisimilarity is coarser than strong bisimilarity. intuitively, barbed bisimilarity compares agents by looking only at the channels, or barbs, which they expose to the surrounding environment. this turns out to be sufficiently expressive, for calculi whose reactions are essentially triggered by names. however, there is no general and systematic way for identify which names of an agent have to be observed, and which is their role; instead, barbs are usually defined by means of some ad hoc intensional definition on the syntax of the calculus; e.g., in the π -calculus, barbs are the subjects of “active” prefixes; in mobile ambients, they are the names of top-level ambients. to overcome this problem, in this paper we propose a general, systematic approach to define barbs for a bigraphic reactive system. we aim to formalize the intuitive idea that “barbs are the 1 / 15 volume 16 (2009) mailto:grohmann@dimi.uniud.it mailto:miculan@dimi.uniud.it deriving barbed bisimulations for bigraphical reactive systems we have implemented the resulting algorithm in our bpl tool, which we briefly describe in section 6. we also present an example of a bigraphical reactive system, an encoding of the polyadic ! calculus, and show how it can be used to simulate a simple model of a mobile phone system. bigraphical reactive systems are related to general graph transformation systems; ehrig et al. [10] provide a recent comprehensive overview of graph transformation systems. in particular, bigraph matching is related to the general graph pattern matching (gpm) problem, so general gpm algorithms might also be applicable to bigraphs [11, 14, 20, 21]. as an alternative to implementing matching for bigraphs, one could try to formalize bigraphical reactive systems as graph transformation systems and then use an existing implementation of graph transformation systems. some promising steps in this direction have been taken [19], but they have so far fallen short of capturing precisely all the aspects of binding bigraphs. for a more detailed account of related work, in particular on relations between brss, graph transformations, term rewriting and term graph rewriting, see the thesis of damgaard [8, section 6]. the remainder of this paper is organized as follows. in section 2 we give an informal presentation of bigraphical reactive systems and in section 3 we present our matching algorithm: we first recall the graph-based inductive characterization, then we develop a term-based inductive characterization, which forms the basis for our implementation of matching. in section 4 we describe how our implementation deals with the remaining nondeterminism and in section 5 we discuss a couple of auxiliary technologies needed for the implementation of the term-based matching rules. in section 6 we finally describe the bpl tool and present an example use of it. we conclude and discuss future work in section 7. 2. bigraphs and reactive systems in the following, we present bigraphs informally; for a formal definition, see the work by jensen and milner [13] and damgaard and birkedal [9]. 2.1. concrete bigraphs a concrete binding bigraph g consists of a place graph gp and a link graph gl. the place graph is an ordered list of trees indicating location, with roots r0, . . . , rn, nodes v0, . . . , vk, and a number of special leaves s0, . . . , sm called sites, while the link graph is a general graph over the node set v0, . . . , vk extended with inner names x0, . . . , xl , and equipped with hyper edges, indicating connectivity. we usually illustrate the place graph by nesting nodes, as shown in the upper part of figure 1 (ignore for now the interfaces denoted by “ : · !· ”). a link is a hyper edge of the link graph, either an internal edge e or a name y. links bigraph g : "3, [{},{},{x0, x2}], x# ! "2, [{y0},{}],y # 0 1 2 y0 y1 y2 x0 x2 x1 e2 v0 v1 v2 v3 e1 x ={x0, x1, x2} y ={y0, y1, y2} place graph gp : 3 ! 2 roots: sites: r0 v0 v1 s0 v2 r1 v3 s2 s1 link graph gl : x ! y names: inner names: y0 y1 y2 v0 v1 v2 v3 x0 x2 x1 e1 e2 fig. 1. example bigraph illustrated by nesting and as place and link graph. 2 figure 1: a binding bigraph (picture taken from [1]). names of an agent, which are involved in reactions”, by using the contextual labels given by the ipo construction: for each agent, we examine only its ipo labels for finding out the names which are effectively used in reactions. this leads to two notions of barb, ipo barb and decorated ipo barb, which differ on the information about names we extract from ipo labels: in the decorated version, we take advantage of the link and place graphs of the ipo labels to observe also the “role” that each name has in reactions. notice that we use the ipo labels only for definining barbs, and not the bisimilarity itself which instead relies on the reaction relation only. in section 2, after having recalled the basic definitions about binding bigraphs, we introduce the two barbed bisimilarities for binding bigraphs (definitions 8 and 9). then, in sections 3 and 4 we apply this theory to the π -calculus and mobile ambients, respectively. for each calculus, we give its encoding as brs, calculate the ipo labels, and compare the resulting ipo barbed bisimilarity with the standard barbed bisimilarities of these calculi. it turns out that in the case of π -calculus, ipo barbed bisimilarity is finer than standard barbed bisimilarity, but ipo barbed congruence and standard barbed congruence coincide (proposition 5). on the other hand, in the case of mobile ambients, ipo barbed bisimilarities and congruence are finer than their standard counterparts; the reason is that ipo labels allow to observe names also used in capabilities, and not only names of top-level ambients. 2 barbed bisimilarities for binding bigraphs 2.1 binding bigraphs in this section we recall milner’s binding bigraphs1. intuitively, a binding bigraph represents an open system, so it has an inner and an outer interface to “interact” with subsystems and the surrounding environment, see figure 1. the widths of the interfaces describe the roots in the 1 binding bigraphs generalize pure bigraphs for dealing with calculi with binders such as π -calculus. the results presented in this papers hold also in the particular case of pure bigraphs, which suffice for e.g. mobile ambients. proc. doctoral symposium icgt 2008 2 / 15 eceasst outer interface (that is, the various locations where the nodes live) and the sites in the inner interface (that is, the holes where other bigraphs can be inserted). on the other hand, the names in the interfaces describes the free links, that is end points where links from the outside world can be pasted, creating new links among nodes. we refer the reader to [8, 9] for more details. let k be a binding signature of controls, and ar : k → n×n be the arity function. the arity pair (h, k) (written h → k) consists of the binding arity h and the free arity k, indexing respectively the binding and the free ports of a control. definition 1 a binding interface is 〈m, loc, x〉, where m is a finite ordinal (called width), x is a finite set of names, and loc : x → m]{⊥} is a locality map associating some of the names x with a site in m. if loc(x) = s then x is located at s, or local to s; if loc(x) = ⊥ then x is global. we shall some times represent the locality map as a vector ~x = (x0, . . . , xm−1) of disjoint subsets, where xs is the set of names local to s; thus x \~x are the global names. we call an interface local (resp. global) if all its names are local (resp. global). definition 2 a binding bigraph g : 〈m, loc, x〉→ 〈n, loc′,y〉 is defined as a (pure) bigraph gu : 〈m, x〉→〈n,y〉 satisfying certain locality conditions (see below). gu is defined by composing a place graph gp, describing the nesting of nodes, and a link graph gl, describing the (hyper-)links among nodes. gu = (v, e, ctrl, gp, gl) : 〈m, x〉→〈n,y〉 (pure bigraph) gp = (v, ctrl, prnt) : m → n (place graph) gl = (v, e, ctrl, link) : x →y (link graph) where v, e are the sets of nodes and edges respectively, ctrl : v → k is the control map, which assigns a control to each node, prnt : m]v → v ]n is the (acyclic) parent map, p = ∑v∈v π1(ar(ctrl(v))) is the set of ports and b = ∑v∈v π2(ar(ctrl(v))) is the set of bindings (associated to all nodes), and link : x ]p → e ]b]y is the link map. the locality conditions are the following: 1. if a link is bound, then its inner names and ports must lie within the node that binds it; 2. if a link is free, with outer name x, then x must be located in every region that contains any inner name or port of the link. definition 3 the category of binding bigraphs over a signature k (bbg(k )) has local interfaces as objects, and binding bigraphs as morphisms. given two local bigraphs g : 〈m, loc, x〉→〈n, loc′,y〉, h : 〈n, loc′,y〉→〈k, loc′′, z〉, the composition h ◦g : 〈m, loc, x〉→〈k, loc′′, z〉 is defined by composing their place and link graphs: 1. the composition of gp : m → n and h p : n → k is define as h p ◦gp = (vg ]vh , ctrlg ]ctrlh , (idvg ] prnth )◦(prntg ]idvh )) : n → k; 2. the composition of gl : x →y and h l : y → z is defined as h l ◦gl = (vg ]vh , eg ]eh , ctrlg ]ctrlh , (ideg ]linkh )◦(linkg ]idph )) : x → z. 3 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems an important operation about (bi)graphs, is the tensor product. intuitively, the tensor product of g : 〈m, loc, x〉→〈n, loc′′,y〉 and h : 〈m′, loc′, x′〉→〈n′, loc′′′,y ′〉, is a bigraph g⊗h : 〈m + m′, loc] loc′, x ]x′〉→〈n + n′, loc′′] loc′′′,y ]y ′〉 is defined when x ∩x′ = y ∩y ′ = /0 and it obtained by putting “side by side” g and h, without merging any root nor any name in the interfaces. it is easy to check that composition and tensor preserve the locality conditions. two useful variant of tensor product can be defined using tensor and composition: the parallel product ‖, which merges shared global names between two bigraphs, and the prime product |, that moreover merges all roots in a single one. due to lack of space, we refer the reader to [9]. 2.2 bigraphical reactive systems bigraphical reactive systems (brss) are reactive systems in the sense of [10], built over binding bigraphs [8]. a brs consists of a set of bigraphical rewrite rules, together with a definition of the contexts (i.e., bigraphs with holes), called active context, where rules redexes can be found in order to be rewritten. definition 4 controls of a signature are either active, passive or atomic. atomic controls cannot contain any node (and hence must be a leaf of the place and its binding arity is zero). a location (i.e., an element in the domain of prnt) is active if all its ancestors have active controls (the roots are active); otherwise it is passive. a context is active if all its holes are active locations. it is easy to check that active contexts form a compositional reflective sub-category of bigraphs, which we denote by a , the category of active contexts. definition 5 a bigraphical reactive system (brs) d(k , r) is formed by bbg(k ) equipped with the subcategory a of active contexts, and a set r of (parametric) reaction rules, that is pairs l, r : 〈m, loc, x〉→〈n, loc′,y〉 (usually written as l _ r). the reaction relation _ is the relation between ground bigraphs given by the following rule: for some a ∈ a , l _ r ∈ r, d ground : g = a◦l ◦d and h = a◦r◦d g _ h 2.3 minimal labels for brss in order to derive systematically labelled transition systems (ltss) from reactive systems, leifer and milner in [10] proposed to consider as labels the “minimal” contexts which can trigger a reaction. such minimality can be elegantly defined as a categorial universal property, i.e., introducing the relative pushouts (rpos) and idem pushouts (ipos). definition 6 given a span ( f0, f1) and an its bound (g0, g1) as shown in figure 2(1) 1. a candidate rpo is a triple (h0, h1, h) such that the diagram in figure 2(1) commutes. 2. an rpo (h0, h1, h) is a candidate rpo such that given any other candidate rpo (k0, k1, k) there exists a unique mediating arrow j such that the diagram in figure 2(2) commutes. 3. an ipo is an rpo having as the third component an identity (as in figure 2(3)). proc. doctoral symposium icgt 2008 4 / 15 eceasst f1f0 h1h0 g1g0 h f1f0 h1h0 g1g0 h j k1 k0 k f1f0 h1h0 g1g0 id (1) (2) (3) figure 2: a candidate rpo (1), an rpo (2) and an ipo (3). proposition 1 the category bbg has rpos, and hence ipos2. following [10], the labels of an agent are the ipos with respect to any reaction rule: definition 7 (ipo labels) let d(k , r) be a brs, and a : ε →〈m, loc, x〉 an agent. an ipo label for a (in d ) is a bigraph ` such that there exists a rule l _ r ∈ r, a parameter d and an active context d such that (`, d, id) is an ipo for (a, l ◦d). we will denote by ipo(a) the set of all ipo labels for a. 2.4 defining barbs from ipo labels in this section we give a way to define systematically barbs over bigraphs using the ipo labels. in general, a bigraphic barb is a predicate over ground bigraphs, observing some names on the interface. more precisely for a bigraph a : ε →〈m, loc, x〉, a bigraphic barb is a (possibly empty) subset x′ ⊆ x of the outer names of a; we denote it as a ↓ x′. the first family of barbs we define are ipo barbs. intuitively, a name of an agent is in the ipo barb if there exists an ipo label that interacts (non trivially) with the agent on such a name. definition 8 (ipo barbs) let d(k , r) be a brs, and a : ε →〈m, loc, x〉 a ground bigraph. for each ` ∈ ipo(a), the corresponding ipo barb (for a) is the set x′ ⊆ x defined as x′ = {x ∈ x | link`(x) = link`(p) for some p ∈ p̀ ](x \{x})}. we write a ↓i x′ for x′ is a ipo barb for a. in some cases we need to understand how each name is used by the agent. intuitively, the role of a name can be figured out by looking at the control it is connected to, in the ipo label; e.g., in the case of π -calculus (section 3), a name acts as an input channel when is connected to a “send” control in the ipo label. we can get this information by looking at the link graph of the label. in general, however, for a reaction to take place not only the names must be connected to the right controls, but these must be in the correct position within the ipo label. thus, we can say that the role played by the name is given by the control it is connected to, and its position in the label; the latter can be obtained from the place graph of the label. formally: definition 9 (decorated ipo barb) let d(k , r) be a brs, and a : ε →〈m, loc, x〉 a ground bigraph. for each ` ∈ ipo(a), the corresponding decorated ipo barb (for a) is a set of pairs x′ = {(x′0, t0), . . . , (x′n−1, tn−1)} such that {x′0, . . . , x′n−1} is the ipo barb for a corresponding to `, and for i = 0, . . . , n−1, ti is the set satisfying the following properties: 2 more precisely, rpos are constructed in the s-category ′bbg and then mapped down into the category bbg. 5 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems 1. 〈int〉∈ ti iff there exists x ∈ x \{x′i} such that link`(x) = link`(x′i) and loc(x) = ⊥; 2. 〈ctrl(wn), . . . , ctrl(w1), int〉∈ ti iff there exists x ∈ x \{x′i} such that link`(x) = link`(x′i) and loc`(x) = j, and there exist w1, . . . , wn ∈ v` and a root k such that prnt`( j) = w1, prnt`(wz) = wz+1 (z = 1, . . . , n−1), prnt`(wn) = k. 3. 〈ctrl(wn), . . . , ctrl(w1), ctrl(v)〉∈ti iff there exists v∈v` having a port p such that link`(p) = link`(x′i), and there exist w1, . . . , wn ∈v` and a root k such that prnt`( j) = w1, prnt`(wz) = wz+1 (z = 1, . . . , n−1), prnt`(wn) = k. we write a ↓di x′ to denote that x′ is a decorated ipo label for a. barbed bisimulations about reactive systems with nested and multiple locations, where the role of a control depends also on its position (like e.g. in the case of web services), could benefit from the information about position of controls. an example of a name connected to a nested control is given in the case of mobile ambients (label in3 in figure 10, section 4). in the following, we will omit 〈−〉 on unary lists, we will write the pairs (x′i, ti) as x′i(ti), and we will consider a set like ⋃n−1 i=0 xi(ti) also as the set defined as ⋃n−1 i=0 ⋃ t∈ti xi(t). definition 10 given a brs d(k , r) and ↓ be a predicate over bigraphical agents. a bigraphical barb bisimulation is a symmetric relation s , such that g s h then • if g ↓ x′ then h ↓ x′; • if g _ g′ then h _ h′ and g′s h′. the bigraphical barbed bisimilarity (∼) is the biggest bigraphical barbed bisimulation. the bigraphical barbed congruence (∼c) is the biggest congruence contained in bigraphical barbed bisimilarity. it can be defined by closing ∼ under all contexts, i.e., g ∼c h if for all contexts c, c◦g ∼c◦h. notice that the closure under all contexts is necessary, because in general bigraphical barbed bisimilarities are not congruences (as usual with barbed bisimilarities). 3 application: the π -calculus in this section we apply the theory of bigraphic barbed bisimilarity introduced in the previous section to the synchronous π -calculus. as a first step, we provide an encoding of the synchronous π -calculus as a brs. this is almost the same as in [8]. we refer the reader to usual literature for the technical details about π -calculus e.g. [14]. 3.1 π -calculus recall that the syntax of the (recursion-free) π -calculus is defined as follows: p, q ::= 0 | z(x).p | z̄x.p | p|q | ν x.p. proc. doctoral symposium icgt 2008 6 / 15 eceasst processes are taken up to the following structural equivalence (≡). p | 0 ≡ p p | q ≡ q | p (p | q) | r ≡ p | (q | r) ν x.0 ≡ 0 ν x.ν y.p ≡ ν y.ν x.p ν x.(p | q) ≡ p | ν x.q if x /∈ f n(p) ν x.z̄y.p ≡ z̄y.(ν x.p) if x /∈{z, y} ν x.z(y).p ≡ z(y).(ν x.p) if x /∈{z, y} the reduction semantics is defined by the following set of rules, closed under ≡: com z̄x.p|z(y).q → p|q{x/y} p → q p|r → q|r p → q ν x.p → ν x.q a barb is a predicate over processes, it is usually written as p ↓ a, read p commits to a, where p is a process and a a name. definition 11 let ↓ be a barb predicate. a barbed bisimulation is a symmetric relation s , such that if p s q, then • if p ↓ a, then q ↓ a; • if p → p′, then q → q′ and p′s q′. the barbed bisimilarity ( .∼) is the biggest barbed bisimulation. to obtain the biggest congruence, called barbed congruence ('c), contained into the barbed bisimilarity, we close .∼ under all contexts, i.e., p 'c q if for all c[−] c[p] .∼c[q]. in literature, two notions of barbs for the π -calculus have been introduced: definition 12 let p be a π -process, • (unsorted barbs) p commits to a (written p ↓π a) iff p ≡ a(b).q | r or p ≡ āb.q | r; • (sorted barbs) p commits to a (written p ↓π′ a) iff p ≡ a(b).q | r and p commits to ā (written p ↓π′ ā) iff p ≡ āb.q | r. we will denote with .∼π and 'cπ the barbed bisimilarity and barbed congruence for ↓π , respectively; and we will denote with .∼π′ and 'cπ′ the barbed bisimilarity and barbed congruence for ↓π′, respectively. the following result is well-known [14]: proposition 2 'cπ = 'cπ′ ⊂ .∼π′ ⊂ .∼π . 3.2 π -calculus as brs the signature for representing the π -calculus processes in binding bigraphs is kπ , {get : 1 → 1, send : 0 → 2} where get and send are both passive. notice that get has a binding port, representing the bound local variable. an example of the controls is given in figure 3. 7 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems y x gety(x) y z sendyz figure 3: the controls of the signature for the π -calculus. 0 y x0 z 1 0 y z x0 1 comπ : getz(x) | sendzy → y/(x) | z | id1 | id1 ρ = id figure 4: reaction rules rπ for the π -calculus. a π -process p is translated into a bigraph of bbg(kπ ) as follows: j0kx = 1 | x jp | qkx = jpkx | jqkx jν x.pkx = /x◦jpkx]{x} jz(x).pkx = getz(x)◦jpkx]{x} if z∈x jz̄x.pkx = sendzx ◦jpkx if z, x∈x the outer upward names represent free names; restricted names are encoded as edges; finally, input bindings are represented as binding ports localized in the get control. proposition 3 (syntax adequacy) let p, q be two π -processes and let x be a name set; then p ≡ q iff jpkx = jqkx . the set of reaction rules (rπ ) is shown in figure 4. notice that communication simply connects the links “stopped” by get to the resources provided by send. we denote this brs as dπ , d(kπ , rπ ), where the parametric rules can be instantiated with discrete bigraphs. proposition 4 (semantics adequacy) let p, q be two π -processes and let x be a name set; then p → q iff jpkx _ jqkx . 3.3 bigraphical barbed bisimilarity for π -calculus the ipo labels for the brs dπ are in figure 5, and in figure 6 we show the corresponding barbs (both bigraphic and decorated). recalling that bigraphic barbs identify names on the agent interface which are “effectively involved” in reactions, an intuitive explanation of these barbs is the following. the barb a ↓i {y} on the left-hand side, arises from the fact that the agent uses proc. doctoral symposium icgt 2008 8 / 15 eceasst agent (a : ε → x ) label conditions com1 /z ◦(sendyx ◦d | q) gety(z)◦c y ∈ x and c discrete with names not in x ∪z com2 /z ◦(gety(x)◦d | q) sendyz ◦c y ∈ x and c discrete with names not in x ∪z com3 /z ◦((sendy0x ◦d) | (gety1(z)◦c) | q) id | w/y0 | w/y1 y0, y1 ∈ x com4 /z ◦((sendyx ◦d) | (gety(z)◦c) | q) id figure 5: the set of labels for the π -calculus derived using the ipo construction. y xd q a ↓i {y} a ↓di {y(send)} a y z c` q y z c a ↓i {y} a ↓di {y(get)} y z xd y0 y1 z xd c q a ↓i {y0, y1} a ↓di {y0(int), y1(int)} w z figure 6: the barbs derived from the labels of figure 5. y as input channel, and the ipo label completes the transition by providing an output along the same name. the same barb arises also in the second case; in order to distinguish the two labels, we have to consider also how the name y is used. in fact, the decorated barbs differ in these two cases, because they carry also the linking information about y in the ipo label. finally, the third barb arises because the ipo label triggers a transition by unifying the channel names of the two controls; hence, in this case the two names are involved in an unification. notice that the name z in the agent interface does not take part to the reactions, and hence it does not appear in the barbs. we will denote with .∼iπ (resp. .∼diπ ) the ipo barbed bisimilarity (resp. decorated ipo barbed bisimilarity), and with 'ciπ and 'cdiπ the corresponding congruences. now we can state and prove some results on the derived barbed bisimilarities and congruences. proposition 5 'ciπ = 'cdiπ = 'cπ = 'cπ′ ⊂ .∼π′ = .∼diπ ⊂ .∼iπ ⊂ .∼π . proof. the equality 'ciπ = 'cdiπ = 'cπ = 'cπ′ is quite simple to prove. just notice that all the extra information you can see in .∼π′ (discriminates by a and ā), .∼iπ (can check if equating two names a process performs a communication), or .∼diπ (can check communication enabling, as .∼iπ , and besides it can see the nodes linked to the names inside the labels) w.r.t. .∼π are captured by the closure under all contexts. 9 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems the inclusion . . .'cπ′ ⊂ .∼π′. . . is trivially a consequence of proposition 2. for .∼π′ = .∼diπ , notice that every time a bigraph g g ↓di {x(int), y(int)}, then either g ↓di {x(send)} and g ↓di y(get) or g ↓di {x(get)} and g ↓di y(send). for the barbs x(send) and x(get) there is a one to one correspondence with the barbs x and x̄, respectively. .∼diπ ⊂ .∼iπ because the former can observe the controls of nodes linked to names. the inclusion is strict, in fact ja(x) | b̄zk .∼iπ jb(x) | āzk, but they are not decorated ipo barbed bisimilar. finally, .∼iπ ⊂ .∼π because there is a correspondence between the barb {x} used by .∼iπ and the barb x in .∼π . the strictness of the inclusion is given by the fact that a(x) | b̄z .∼π āx | b̄z, but ja(x) | b̄zk 6 .∼iπ jāx | b̄zk. ipo barbed bisimilarity is finer than (unsorted) bisimilarity due to the third barb in figure 6, allowing to observe when the agent can perform an input and an output on two different names, at once. on the other hand, the decorated barb arising from this case does not add any discriminating power with respect to sorted barbed bisimilarity .∼π′, because the sorted barbs allow to observe when the agent exposes both an input and an output name. finally, when we consider the contextual congruences of these bisimilarities, we get the same equivalence because any extra observations yielded by the (decorated) ipo barbs are recovered by suitable contexts. 4 application: mobile ambients in this section we analyze another application of the theory of barbed bigraphical bisimilarity, i.e., to the fragment of recursion-free mobile ambients. the encoding resembles mostly the one presented in [7]. see [4] for a detailed introduction to mobile ambients. 4.1 mobile ambients recall that the syntax of (our fragment of) mobile ambients is defined as follows: p, q ::= 0 | n[p] | p|q | ν n.p | in n.p | out n.p | open n.p. processes are taken up to the following structural equivalence (≡): p | 0 ≡ p p | q ≡ q | p (p | q) | r ≡ p | (q | r) ν n.0 ≡ 0 ν n.ν m.p ≡ ν m.ν n.p ν n.(p | q) ≡ p | ν n.q if n /∈ f n(p) ν m.n[p] ≡ n[ν m.p] if m 6= n ν n.in m.p ≡ in m.ν x.p if n 6= m ν n.out m.p ≡ out m.ν n.p if n 6= m ν n.open m.p ≡ open m.ν x.p if n 6= m the reduction semantics is defined by the following set of rules, closed under ≡: in n[in m.p | q] | m[r] → m[n[p | q] | r] out m[n[out m.p | q] | r] → n[p | q] | m[r] open open n.p | n[q] → p | q p → q p|r → q|r p → q ν x.p → ν x.q p → q n[p] → n[q] as for π -calculus, we give a notion of barb for mobile ambients. it is defined as follows. proc. doctoral symposium icgt 2008 10 / 15 eceasst n ambn n inn n outn n openn figure 7: the controls of the signature for the mobile ambients. definition 13 let p be an ambient process. p commits to n (written p ↓a n) iff p ≡ n[q] | r; we denote with .∼a and 'ca the barbed bisimilarity and barbed congruence for ↓a, respectively. 4.2 mobile ambients as brss the signature for representing the mobile ambients in binding bigraphs is ka , {amb : 0 → 1, in : 0 → 1, out : 0 → 1, open : 0 → 1} where amb is active and in, out, open are passive. an example of the controls is given in figure 7. an ambient process p is translated into a bigraph of bbg(ka) as follows: j0kx = 1 | x jp | qkx = jpkx | jqkx jν x.pkx = /x◦jpkx]{x} jn[p]kx = ambn ◦jpkx if n ∈ x jin n.pkx = inn ◦jpkx if n ∈ x jout n.pkx = outn ◦jpkx if n ∈ x jopen n.pkx = openn ◦jpkx if n ∈ x the outer upward names represent free names; restricted names are encoded as edges. proposition 6 (syntax adequacy) let p, q be two ambient processes and let x be a name set; then p ≡ q iff jpkx = jqkx . the set of rules ra is shown in figure 8. the first rule moves an ambient inside another one following the in capability; the second one moves an ambient outside another one by means of the capability out; finally the third rule open the ambient linked to the open capability. we denote this brs as da(ka, ra), whose parametric rules can be instantiated with discrete bigraphs. proposition 7 (semantics adequacy) let p, q be two ambient processes and let x be a name set; then p → q iff jpkx _ jqkx . 4.3 bigraphical barbed bisimilarity for mobile ambients analogously to the π -calculus case, the set of labels derived by applying the ipo construction are shown in figure 9; then, the derived barbs are shown in figure 10. 11 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems 0 n m 0 1 2 0 n m 0 1 2 ina : (ambn ◦(inm | id1)) | ambm → (ambm ◦(ambn ◦(id1 | id1) | id1)) ρ = id 0 n m 0 1 2 0 n m 0 1 2 outa : (ambm ◦(ambn ◦(outm | id1) | id1)) → (ambn ◦(id1 | id1)) | ambm ρ = id 0 n 0 1 0 n 0 1 opena : openn | ambn → id1 | id1 ρ = id figure 8: reaction rules ra for the mobile ambients. barbs in3 and open1 let us to observe that n is the name of a top-level ambient (which can be entered, or opened, by a parallel agent). on the other hand, barbs in4, out3 and open3 arise from the ipo labels which trigger a reaction by unifying two names; notice that these names can be used at any position in the agent, not only at top level. barbs in1 and in2, instead, arise when n is used by a “in” capability in the agent; in the first case, this capability is contained by an ambient at top-level, whilst in the second case the capability is directly exposed at top-level. interestingly, this topological difference is not observable in either kinds of ipo barbs. a similar situation holds for out1 and out2. finally, open2 arises when n is a name used by an “open” capability at the top-level in the agent. we will denote with .∼ia (resp. .∼dia) the ipo barbed bisimilarity (resp. decorated ipo barbed bisimilarity), and with 'cia and 'cdia the corresponding congruences. we can prove the following proposition 8 1. .∼dia ⊂ .∼ia ⊂ .∼a; 2. 'cdia = 'cia ⊂'ca; 3. .∼dia 6⊂'ca and 'ca 6⊂ .∼ia; proc. doctoral symposium icgt 2008 12 / 15 eceasst agent (a : ε → x ) label conditions in1 /z ◦(ambm ◦(inn ◦ p | q) | d) (ambn ◦c) | id n ∈ x and c discrete with names not in x∪z in2 /z ◦(inn ◦ p | q) ambn ◦ c | ambm ◦id n ∈ x , c discrete with names not in x ∪z and m /∈ x ∪z in3 /z ◦(ambn ◦d | c) ambm ◦ (inn ◦ p | q) | id n ∈ x , p, q discretes with names not in x∪z and m /∈ x ∪z in4 t ◦(ambm ◦(inn0 ◦ p | q) | ambn1 ◦d) id | n/n0 | n/n1 n0, n1 ∈x and t active in5 t ◦(ambm ◦(inn ◦ p | q) | ambn ◦d) id t active out1 /z ◦(ambm ◦(outn ◦ p | q) | d) ambn ◦(c | id) n ∈ x and c discrete with names not in x∪z out2 /z ◦(outn ◦ p | q) ambn ◦ ambm◦(c | id) n ∈ x , c discrete with names not in x ∪z and m /∈ x ∪z out3 t ◦ambn0 ◦(ambm ◦(outn1 ◦ p | q) | d) id | n/n0 | n/n1 n0, n1 ∈x and t active out4 t ◦ambn ◦(ambm ◦(outn ◦ p | q) | d) id t active open1 /z ◦(ambn ◦ p | q) openn ◦c | id n ∈ x and c discrete with names not in x∪z open2 /z ◦(openn ◦ p | q) ambn ◦c | id n ∈ x and c discrete with names not in x∪z open3 t ◦(openn0 ◦ p | ambn1 ◦q | d) id | n/n0 | n/n1 n0, n1 ∈x and t active open4 t ◦(openn ◦ p | ambn ◦q | d) id t active figure 9: the set of labels for mobile ambients derived using ipo construction. proof. 1. the first inclusion is justified by the fact that decorated ipo barbs are the same as the ipo barbs, but the former barbs have some extra information, so they are able to distinguish more than the latter ones. it is strict, consider in n and n[] as shown in figure 6, jin nk ↓i {n} and jn[]k ↓i {n}, but jin nk ↓di {n(amb)} and jn[]k ↓di {n(〈amb, in〉)}. the second inclusion holds because the set of barbs of ba is a subset of the set of ipo barbs. to prove the strictness consider open n and open m, open n .∼a open m because they do nothing, but jopen nk 6 .∼ia jopen mk because jopen nk ↓i {n} but jopen mk ↓i {m}. 2. the equality is justified by the fact that the closure by all contexts catch all the extra information added by the decoration of ipo barbs. the inclusion is a direct consequence of point 1. it is strict, consider ν n.n[open m | k[]] and ν n.n[], they are barbed congruent, but not ipo barbed bisimilar, indeed jν n.n[open m | k[]]k ↓i {k, m} and jν n.n[]k 6↓i {k, m}. 3. .∼dia 6⊂'ca is trivial, consider m[n[]] and m[k[]]: their encodings under j−k are decorated ipo bisimilar, but they are not barbed congruent. for 'ca 6⊂ .∼ia consider again ν n.n[open m | k[]] and ν n.n[]: they are barbed congruent, but not ipo barbed bisimilar, indeed jν n.n[open m | k[]]k ↓i {k, m} and jν n.n[]k 6↓i {k, m}. intuitively, ipo barbed bisimilarity is finer than barbed bisimilarity because ipo barbs can 13 / 15 volume 16 (2009) deriving barbed bisimulations for bigraphical reactive systems rule ipo barb decorated ipo barb in1 {n} {n(amb)} in2 {n} {n(amb)} in3 {n} {n(〈amb, in)〉} in4 {n0, n1} {n0(int), n1(int)} out1 {n} {n(amb)} out2 {n} {n(amb)} out3 {n0, n1} {n0(int), n1(int)} open1 {n} {n(open)} open2 {n} {n(amb)} open3 {n0, n1} {n0(int), n1(int)} figure 10: the barbs derived from the labels in figure 9. observe names of ambients together with names in capabilities, which may be not at the top level of the agent; these barbs arise from the fact that an unification of these names will trigger a reaction; see e.g. the counterexample given in the proof of proposition 8.2. notice that the contextual closures of these bisimilarities still do not coincide, because there is no ambient context which can observe inside a restricted ambient, like in the example above. 5 conclusions in this paper we have presented a general notion of barb and barbed bisimilarity for bigraphical reactive systems. intuitively, barbs are the names in the interfaces of an agent which are effectively involved in reactions. we have shown how these names can be found by looking inside the contextual labels of the agent given by the ipo construction. also, a finer notion of barb (called “decorated”) can be defined by observing also how the names are used by the agent. the role played by a name can be figured out by looking at the controls it is connected to, in the ipo label. as example applications of this new notion of bisimilarity, we have considered the ipo barbed bisimilarities for the (brs encodings of) π -calculus and mobile ambients. for π -calculus, ipo barbed bisimilarity is finer than standard barbed bisimilarity, but decorated ipo barbed bisimilarity coincides with sorted bisimilarity, and ipo barbed congruence coincides with standard barbed congruence. for mobile ambients, ipo barbed bisimilarities and congruence are finer than their standard counterparts. this is because ipo labels allow to observe also names used in inner capabilities and ambients, and not only names of top-level ambients. the problem of providing an abstract definition of barbs has been faced also in [13]. there, a general definition of barb is given around a notion of closure of an agent, that is, a minimal set of processes which offer an immediate interaction with the agent. although this notion of closure seems related to the ipo construction used in the present work, their development is carried out in the quite different setting of biorthogonality. a future work will be to compare the ipo bigraphical barbs and those coming from the biorthogonality framework. another interesting application of the ipo construction to barbed bisimilarities has been inproc. doctoral symposium icgt 2008 14 / 15 eceasst vestigated in [3], where the notion of barbed semisaturated bisimulation is introduced. although it turns out to be finer than usual barbed congruence, this bisimulation is a congruence without the need of contextual closures, and moreover it can be characterized using the minimal labels defined by the ipo construction. however, [3] does not specify any particular notion of barb, and hence it can be seen as an complementary research with respect to our work. finally, we plan to apply this theory to other calculi, such as fusion calculus and those for security aspects (such as spi-calculus). to this end, the bigraphical barbed bisimilarity can be extended easily to directed bigraphs [5], which allow to represent also calculi with fusions. bibliography [1] l. birkedal, t. c. damgaard, a. j. glenstrup, and r. milner. matching of bigraphs. electr. notes theor. comput. sci., 175(4):3–19, 2007. [2] l. birkedal, s. debois, e. elsborg, t. hildebrandt, and h. niss. bigraphical models of context-aware systems. in proc. fossacs, volume 3921 of lncs, pages 187–201. springer, 2006. [3] f. bonchi, f. gadducci, and g. v. monreale. reactive systems, barbed semantics, and the mobile ambients. in proc. fossacs, lncs. springer-verlag, 2009. [4] l. cardelli and a. d. gordon. mobile ambients. in proc. fossacs, pages 140–155. springer-verlag, berlin germany, 1998. [5] d. grohmann and m. miculan. reactive systems over directed bigraphs. in proc. concur, volume 4703 of lncs, pages 380–394. springer-verlag, 2007. [6] o. h. jensen. bigraphs and weak bisimilarity. talk at dagstuhl seminar 04241, june 2004. [7] o. h. jensen. mobile processes in bigraphs. phd thesis, university of aalborg, 2008. [8] o. h. jensen and r. milner. bigraphs and transitions. in proc. popl, pages 38–49, 2003. [9] o. h. jensen and r. milner. bigraphs and mobile processes (revised). technical report ucam-cl-tr-580, computer laboratory, university of cambridge, 2004. [10] j. j. leifer and r. milner. deriving bisimulation congruences for reactive systems. in proc. concur, volume 1877 of lncs, pages 243–258. springer, 2000. [11] j. j. leifer and r. milner. transition systems, link graphs and petri nets. mathematical structures in computer science, 16(6):989–1047, 2006. [12] r. milner. bigraphical reactive systems. in proc. 12th concur, volume 2154 of lncs, pages 16–35. springer, 2001. [13] j. rathke, v. sassone, and p. sobocinski. semantic barbs and biorthogonality. in proc. fossacs, volume 4423 of lncs, pages 302–316. springer, 2007. [14] d. sangiorgi and d. walker. the π -calculus: a theory of mobile processes. cup, 2001. 15 / 15 volume 16 (2009) introduction barbed bisimilarities for binding bigraphs binding bigraphs bigraphical reactive systems minimal labels for brss defining barbs from ipo labels application: the -calculus -calculus -calculus as brs bigraphical barbed bisimilarity for -calculus application: mobile ambients mobile ambients mobile ambients as brss bigraphical barbed bisimilarity for mobile ambients conclusions refactoring of uml models using agg electronic communications of the easst volume 8 (2008) proceedings of the third international ercim symposium on software evolution (software evolution 2007) refactoring of uml models using agg alessandro folli1, tom mens 15 pages guest editors: tom mens, ellen van paesschen, kim mens, maja d’hondt managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 1 this paper reports on work that has been carried out by the first author in the context of a masters thesis supervised by the second author in the context of an erasmus exchange programme. http://www.easst.org/eceasst/ eceasst refactoring of uml models using agg alessandro folli2, tom mens service de génie logiciel, université de mons-hainaut, belgique abstract: model refactoring is an emerging research topic that is heavily inspired by refactoring of object-oriented programs. current-day uml modeling environments provide poor support for evolving uml models and applying refactoring techniques at model level. as uml models are intrinsically graph-based in nature we propose to use graph transformations to specify and apply model refactoring. more in particular, we use a specific graph transformation tool, agg, and provide recommendations of how agg may be improved to better support model refactoring. these recommendations are based on a small experiment that we have carried out with refactoring of uml class diagrams and state machines. keywords: uml, model refactoring, agg, graph transformation 1 introduction model-driven engineering (mde) is a software engineering approach that promises to accelerate development, to improve system quality, and also to enable reuse. its goal is to tackle the complexity of developing, maintaining and evolving complex software systems by raising the level of abstraction from source code to models. the mechanism of model transformation is at the heart of this approach, and represents the ability to transform and manipulate models [sk03]. model transformation definition, implementation and execution are critical aspects of this process. the challenge goes beyond having languages to represent model transformations. the transformations also need to be reused and to be integrated into software development methodologies and development environments that make full use of them. the term refactoring was originally introduced by opdyke in his seminal phd dissertation [opd92] in the context of object-oriented programming. martin fowler [fow99] defines this activity as “the process of changing a software system in such a way that it does not alter the external behaviour of the code, yet improves its internal structure”. current-day refactoring techniques focus primarily on the source code level and do not take into account the earlier stages of design. a need exists for refactoring tools that enable designers to better manipulate their model, not just their source code. furthermore, there is a need to synchronise and maintain consistency between models and their corresponding code; source code refactorings may need to be supplemented with model-level refactoring to ensure their consistency. this article will focus on the problem of model refactoring, which is a particular kind of model transformation. the unified modeling language (uml) [obj05] is the industry standard used to specify, visualize, and document models of software systems, including their structure and design. therefore, 2 this paper reports on work that has been carried out by the first author in the context of a masters thesis supervised by the second author in the context of an erasmus exchange programme. 1 / 15 volume 8 (2008) refactoring of uml models using agg the goal of this article is to explore the refactoring of uml models. we use graphs to represent uml models, and graph transformations to specify and apply model transformations. this choice is motivated by the fact that graphs are a natural representation of models that are intrinsically graph-based in nature (e.g., class diagrams, state machine diagrams, activity diagrams, sequence diagrams). graph transformation theory has been developed over the last three decades as a suite of techniques and tools for formal modelling and very high-level visual programming [roz97, eekr99, ekmr99]. it allows to represent complex transformations in a compact visual way. moreover, graph transformation theory provides a formal foundation for the analysis and the automatic and interactive application of model transformations. among others, it provides the ability to formally reason about such graph transformations, for example to analyse parallel and sequential dependencies between rules. in this article, we argue that the use of graph transformations for the purpose of model refactoring is both possible and useful. as a proof of concept, we implement a number of complex model refactorings in agg3 [tae04]. it is a rule-based visual programming environment supporting an algebraic approach to graph transformation [em93]. agg may be used as a general-purpose graph transformation engine in high-level java applications employing graph transformation methods. agg is also one of the rare tools that incorporates mechanisms such as critical pair analysis for formally analysing graph transformations, which can be very useful for analysing refactoring rules [mtr07, men06]. based on our experience, we provide recommendations on how the agg tool, and graph transformation tools in general, may be improved. 2 motivating example in the field of software engineering, the unified modeling language (uml) defined by the object management group (omg) [obj05] is the de facto industry standard specification language for modelling, specifying, visualising, constructing, and documenting software-intensive systems. uml provides a standardized graphical notation to create abstract models of a system, referred to as uml models. these models must be conform to the uml metamodel which describes the syntax and semantics. as an example, figure 1 shows the metamodel of uml state machine diagrams. model refactoring is a special kind of model transformation that aims to improve the structure of the model, while preserving (certain aspects of) its behaviour. like the process of source code refactoring, the process of model refactoring is a complex activity. a definition of refactoring has been introduced by opdyke in his phd dissertation [opd92]. he defines refactorings as program transformations containing particular preconditions that must be verified before the transformation can be applied. in [fol07] we have discussed eight primitive model refactorings for uml class diagrams and uml state machine diagrams. this clearly shows that it is possible to formalise the specification and execution of model refactoring using graph transformation rules. table 1 shows the list of model refactorings that we have discussed and implemented. each model refactoring was 3 http://tfs.cs.tu-berlin.de/agg/ proc. software evolution 2007 2 / 15 http://tfs.cs.tu-berlin.de/agg/ eceasst figure 1: uml metamodel of state machines formalised, explained and motivated using a concrete example. a detailed explanation of when it should be used and how it can be realised precedes a discussion of the list of mechanisms to accomplish the refactoring itself. in this article, we explore the introduce initial pseudostate model refactoring in more detail in order to explain and illustrate the main concepts.4 as suggested by the name, it adds an initial pseudostate to a composite state, or region. the introduce initial pseudostate refactoring is used to improve the structure of a state machine diagram. in general, it is a good convention not to cross boundaries of a composite state. figures 2 and 3 show a simple example of using this kind of refactoring. an initial pseudostate 4 for reasons of simplicity, the representation of uml state machines used for this article does not consider the actions attached to states, such as do, entry and exit actions. 3 / 15 volume 8 (2008) refactoring of uml models using agg uml class diagram uml state machine diagram pull up operation introduce initial pseudostate push down operation introduce region extract class remove region generate subclass flatten state transitions table 1: list of model refactorings has been added to the active composite state. the target of the transition that initially referred to the ready state has been redirected to its enclosing region. an automatic transition has been defined between the initial pseudostate and the ready state. the ready state has thus become the default initial state of the active region; a transition whose target is the active state will lead the state machine to the ready state. when the refactoring is used to introduce a final state as well, similar changes to the transitions involved in the composite state will need to take place. figure 2: uml state machine diagram before refactoring figure 4 shows the control flow of this model refactoring that is composed of more primitive refactoring actions. the notation of uml interaction overview diagrams has been used to formally depict the control flow and to specify in which order the action must be executed. the interaction occurrence frames that compose the diagram indicate activities or operations to be invoked. for the purpose of defining model refactoring, they have been associated to graph transformation rules. some custom notations have been added to enrich the diagram with all necessary information. in particular, input and output parameters for each atomic step have been specified. in order to apply the refactoring, it is necessary to provide two input parameters r and s. the parameter r specifies which composite state, or region, will be modified by the refactoring. the parameter s specifies which will be the default state of the region. before applying the refactoring it is necessary to verify that the composite state does not contain an initial pseudostate; this check proc. software evolution 2007 4 / 15 eceasst figure 3: uml state machine diagram after refactoring figure 4: introduce initial pseudostate model refactoring, specified as uml interaction overview diagram will be implemented as a precondition. if the precondition is respected, the refactoring proceeds by creating the initial pseudostate inside the composite state. subsequently, the refactoring changes the target of all transitions pointing to the default state. the new target state of those transitions will become the composite state that contains the region r. for technical reasons, a final cleanup phase is needed in order to remove auxiliary elements 5 / 15 volume 8 (2008) refactoring of uml models using agg that have been added during the transformation process. 3 formal representation as graph transformation uml models can be represented as a graph-based structure, and graphs must conform to the corresponding type graph, much in the same way as models must conform to their metamodel. a type graph corresponding to the uml metamodel is required to formally represent the uml models as graphs and to formally define the uml model refactoring. 5 for the purpose of this article, we have chosen to take into account a subset of the concepts defined by the uml metamodel. in particular, we focus on uml state machine diagrams only. figure 5 shows the type graph corresponding to the uml metamodel of figure 1. this type graph has been created using the agg graph transformation tool. figure 5: uml state machine diagram – type graph agg offers many concepts that are useful to define a type graph very similar to the corresponding uml metamodel. agg allows enrichment of the type graph with a generalisation relation between nodes, and each node type can have one or more direct ancestors (parents) from which it inherits the attributes and edges. moreover, it is also possible to define a node type as an abstract type, thereby prohibiting creation of instance nodes of this abstract type. the primitive refactoring actions shown in figure 4 can be implemented by means of graph transformation rules. transformation rules are expressed mainly by two object structures: the left-hand side (lhs) of the rule specifies a subgraph to search for, while the right-hand side (rhs) describes modifications generated by the transformation. the lhs and the rhs of a rule are related by a partial graph morphism. the applicability of a rule can be further restricted by 5 for a detailed account on the relation between refactoring and graph transformation, we refer to [men06]. proc. software evolution 2007 6 / 15 eceasst additional negative application conditions (nacs). the lhs or a nac may contain constants or variables as attribute values, but no java expressions, in contrast to an rhs. in order to link all these primitive refactoring actions together (as specified in figure 4), we need to ressort to some kind of controlled (or programmed) graph transformation mechanism. tools like fujaba offer this possibility by relying on the notion of so-called story diagrams [gz04]. agg, unfortunately, does not support controlled application of graph transformation rules, so we were forced to implement such a mechanism ourselves, as will be explained in section 4. the first primitive refactoring, named create initial pseudostate is shown in figure 6. it contains a nac to ensure that the region does not contain an initial pseudostate. the state s provided as input parameter (node number 3 in the figure) will become the default state of the region. the strname variable used in the rule is not an input parameter but is needed in order to define the name of the initial pseudostate. the state s provided as input parameter must be part of a composite state otherwise application of this kind of refactoring is no longer possible. if the precondition is respected, the transformation rule marks the default state with an auxiliary “refactoring” node in order to recognize it during the execution of the subsequent steps. figure 6: introduce initial pseudostate create initial pseudostate input parameters r : region ⇒ node1; s : state ⇒ node3 the second primitive refactoring step, named move incoming transition, is shown in figure 7. it takes into account the transitions which have the default state defined as target (the auxiliary “refactoring” node is used to identify the default state). the transformation rule replaces the target edge of a transition by one pointing to the composite state. for this transformation rule a nac has been added in order to ensure that only the transitions that are defined outside the region will be modified. the rule must be repeated as long as possible (i.e., until no further match can be found). the last step, named remove temporary reference is shown in figure 8. it removes the auxiliary “refactoring” node that has been attached to the default state during the execution of the first rule. 7 / 15 volume 8 (2008) refactoring of uml models using agg figure 7: introduce initial pseudostate move incoming transition figure 8: introduce initial pseudostate remove temporary reference 4 tool support in this section, we illustrate the feasibility of developing model refactoring tools using graph transformations. for this purpose, we have developed a prototype application in agg. the choice of agg was motivated by its good support for formal analysis techniques. based on our experience with implementing this prototype, we will discuss the current limitations of agg and graph transformation in general in section 5. the agg graph transformation engine is delivered together with an api (application programming interface) that allows to integrate the internal graph transformation engine into other environments. we used this api to develop our prototype application. this allowed us to specify the graph transformation rules of section 3, as well as the control flow specified in figure 4. figure 9 shows the graphical user interface of the model refactoring application that we developed in java by making use of the agg api. the application internally loads a file containing the model refactoring specifications and the necessary graph transformation rules. it then allows to open files containing the uml models to be refactored that respect the type graph. using the “refactoring” context menu, the user can apply the different model refactorings. when necessary the user will be prompted to enter the input parameter values and possibly to supply a match if the model refactoring can be applied to different parts of the uml model. the representation of the control flow explained in figure 4 has been a crucial point for the implementation of the prototype application. the control flow describes the order in which the individual graph transformation rules of each model refactoring have to be executed. at the moment, the agg tool does not provide a satisfactory solution for organizing and combining rules, and the supplied mechanisms were not sufficient for describing model refactorings. the proc. software evolution 2007 8 / 15 eceasst figure 9: model refactoring application prototype application avoids the underlying problem by using a custom control structure that represents the control flow of model refactorings. based on the uml interaction overview diagram syntax, we have represented the control flow as a graph structure, which is used to drive the application of graph transformation rules. figure 10 presents the type graph that we have defined in agg in order to represent this control flow. when the prototype application needs to apply a model refactoring, it first loads the corresponding graph representing the control flow. it searches the starting point and walks through the graph to determine which graph transformation rules have to be applied. it continues exploring the graph until it reaches a final point, and reports the result to the user. figure 11 shows the control flow we have implemented for the introduce initial pseudostate refactoring. it corresponds to the uml interaction overview diagram reported in figure 4. the prototype application has been enriched with an interpreter in order to evaluate the expression of decision points. that way, implementation of complex transformations is made possible. 5 discussion the main goal of this article was to present a practical study of the current limitations of graph transformation technology. seen in this light, we can use the insights gained during our experiments to discuss some of the limitations of agg, and of graph transformations in general. these suggestions may be used to advance the state-of-the-art in graph transformation tool support in the future. 9 / 15 volume 8 (2008) refactoring of uml models using agg figure 10: interaction overview diagram – type graph figure 11: control flow – introduce initial pseudostate 5.1 limitations of agg concerning the agg tool in particular, we encountered a number of limitations. agg does not allow to represent concepts like aggregation and composition used by the uml metamodel. therefore, the type graph needed to be simplified by using the more generic concept of association. moreover, agg does not have the notion of enumeration type. the property kind of the pseudostate element has been represented using a string value. the type graph also did not take into account ocl constraints imposed on the uml metamodel. these constraints typically proc. software evolution 2007 10 / 15 eceasst specify invariants that must hold for the system being modeled. ocl expressions need to be taken into account when specifying model refactorings in agg. this can be achieved by expressing them using so-called “graph constraints” in agg. trying to formalise ocl constraints as graph constraints, however, is a far from trivial task. agg does not provide a satisfactory control structure for organizing and combining rules, and the supplied mechanisms for composing rules were not sufficient to describe model refactorings. in order to reach our goal we needed to implement a notion of “controlled” graph transformation on top of agg. this is nothing new, in the sense that other graph transformation tools (e.g. progres, fujaba, great, viatra2) already support such mechanisms. agg also does not allow to specify optional patterns inside graph transformation rules. therefore, it is necessary to create similar graph transformation rules that take into account the different optional patterns. for example, the “guard” nodes may or may not be associated to a transition. in order to match transitions with an associated “guard” and transitions without “guard”, creation of two different graph transformation rules is necessary. again this limitation is not present in some of the other graph transformation tools around. another limitation of agg is that it does not support concrete domain-specific visual notation. this would be a nice feature, in order to be able to specify model refactorings using a notation that the designer is familiar with. as a solution to this problem, an eclipse plug-in called tiger is being developed for specifying domain-specific visual editors on top of agg [eetw06]. finally, in order to make model refactoring support acceptable to the community, it needs to be integrated in standard uml modeling environments. this could be realised, for example, by relying on the tiger emf transformation framework. it is a tool environment that allows to generate an eclipse editor plugin based on the eclipse modeling framework (emf) and the graphical editing framework (gef) using agg as underlying transformation engine [bek+06]. 5.2 limitations of graph transformation tools in general for the purpose of model refactoring, an important advantage of graph transformation is that rules may yield a concise visual representation of complex transformations. unfortunately, as identified by [dhj+06], the current state-of-the-art in graph transformation does not suffice to easily define model refactorings, so their expressive power needs to be increased. two mechanisms have been proposed by these authors: one for cloning, and one for expanding nodes by graphs. these are mechanisms that allow one to write more generic graph transformation rules. during our own experiments, we encountered the need for a reusability mechanism at the level of transformation rules. in our large set of transformation rules, there were many similarities among the rules, and we would like to have some mechanisms to capture these similarities, in order to write some of the rules in a more compact way, and also in order to be able to reuse (parts of) existing rules when specifying new ones. this reusability can take on many forms: the ability to share application conditions between different rules, the ability to call some rule from within another one (similar to subroutines and procedure calls), the ability to express multiple rules with the same lhs (resp. rhs) without needing to duplicate the lhs (resp. rhs) each time, to avoid redundancy, the ability to define a notion of specialisation between rules, and so on. in viatra2, for example, graph patterns can be decoupled and manipulated separately from the graph transformation rules themselves [bv06]. recently, an even more sophisticated 11 / 15 volume 8 (2008) refactoring of uml models using agg mechanism of recursive graph pattern matching has been introduced [vv07]. better modularisation mechanisms are also needed. whenever a large set of rules needs to be specified, we need to modularise them in some way. the layering or prioritisation mechanism offered by agg is too rudimentary for this purpose. other techniques for structuring transformations are therefore needed. one potentially useful approach could be the use of so-called transformation units [kk99]. other mechanism are available as well, and a detailed comparison of them has been made by [heet99]. integration of such mechanisms in graph transformation tools is starting to emerge. to give but one example, a new grouping operator has been introduced in the model transformation language great to enable the concise specification of complex transformations [bnn+07]. an important limitation of current graph transformation tools is that graphs and graph transformations are represented in a different way. ideally, graph transformations need to be treated as first class values. if graph transformations could be expressed as graphs, we would gain a lot of expressive power. for example, we could specify higher-order transformations, i.e., graph transformations that transform graph transformations. we could also use graph transformations to generate graph transformations from a graph specification (or vice versa). this could for example be very useful in the approach suggested in [ektw06] to generate an equivalent graph grammar specification for a given input metamodel. 5.3 alternative graph transformation tools many different tools for graph transformation exist. they all have their own specific reason of existence, and can be considered to be complementary in some sense. we already mentioned the progres [saz99] and fujaba tool6 [nz00] that offer built-in support for controlled graph transformation. viatra2 [bv06] and great [akn+06] are two other tools that perform sophisticated support for dealing with complex graph transformations. the moflon meta modeling framework7 [akrs06] is an extension of fujaba that additionally supports triple graph grammars [ks06], a technique that can be quite useful for synchronising different model views (such as class diagrams and state machines, for example). the moflon tool also offers a more standardised way to represent uml models, due to the similarities between the uml metamodel and the moflon concepts. atom3 is a domain-specific modeling tool based on graph transformation8. as such, it combines the virtues of visual concrete syntax with abstract graph transformations. we could continue our list by discussing other graph transformation tools such as motmot, groove, grgen, and so on. 6 conclusion [mt04] provided a detailed survey of research on software refactoring, and suggested model refactoring as one of the future challenges. in this article, we have shown how the formalism of graph transformation can be used as an underlying foundation for the specification of model 6 http://www.fujaba.de 7 http://www.moflon.org 8 http://atom3.cs.mcgill.ca proc. software evolution 2007 12 / 15 http://www.fujaba.de http://www.moflon.org http://atom3.cs.mcgill.ca eceasst refactoring. we have developed a prototype application in order to verify the feasibility of graph transformations for the purpose of model refactorings. the prototype application shows that it is possible to develop model refactoring tools this way. however, it is necessary to improve current graph transformation tool support in order to better support the specification of model refactorings. future work should formally explore the characteristics of model refactoring paying more attention on the preservation of the behaviour. model refactoring is a rather recent research issue and such definitions of behaviour preservation properties have not yet been completely given. there are some proposals about behaviour preservation but, in the context of the uml, such definitions do not exist because there is no consensus on a formal definition of behaviour. a uml model is composed of different diagrams that address different aspects of a software system. the application of model refactorings may generate inconsistencies between these uml diagrams. future work should explore the possibility to preserve the consistency among different kind of uml models after the application of model refactoring expressing inconsistency detections and their resolutions as graph transformation rules. mens, van der straeten and d’hondt [mvd06] propose to express inconsistency detection and resolutions as graph transformation rules, and to apply the theory of critical pair analysis to analyse potential dependencies between the detection and resolution of model inconsistencies. references [akn+06] a. agrawal, g. karsai, s. neema, f. shi, a. vizhanyo. the design of a language for model transformations. journal on software and system modeling 5(3):261–288, september 2006. [akrs06] c. amelunxen, a. königs, t. rötschke, a. schürr. moflon: a standardcompliant metamodeling framework with graph transformations. in rensink and warmer (eds.), model driven architecture foundations and applications: second european conference. lecture notes in computer science (lncs) 4066, pp. 361– 375. springer verlag, heidelberg, 2006. [bek+06] e. biermann, k. ehrig, c. köhler, g. kuhns, g. taentzer, e. weiss. graphical definition of in-place transformations in the eclipse modeling framework. in proc. int’l conf. model driven engineering languages and systems (models). lecture notes in computer science. springer-verlag, 2006. [bnn+07] d. balasubramanian, a. narayanan, s. neema, b. ness, f. shi, r. thibodeaux, g. karsai. applying a grouping operator in model transformations. in proc. applications of graph transformations with industrial relevance (agtive). pp. 406–421. wilhelmshöhe, kassel, germany, 2007. [bv06] a. balogh, d. varró. advanced model transformation language constructs in the viatra2 framework. in proc. 21st acm symposium on applied computing. pp. 1280– 1287. acm press, april 2006. 13 / 15 volume 8 (2008) refactoring of uml models using agg [dhj+06] f. drewes, b. hoffmann, d. janssens, m. minas, n. v. eetvelde. adaptive star grammars. in proc. int’l conf. graph transformation (icgt). lecture notes in computer science 4178, pp. 77–91. springer verlag, 2006. [eekr99] h. ehrig, g. engels, h.-j. kreowski, g. rozenberg (eds.). handbook of graph grammars and computing by graph transformation. volume 2: applications, languages and tools. world scientific, october 1999. [eetw06] c. ermel, k. ehrig, g. taentzer, e. weiss. object-oriented and rule-based design of visual languages using tiger. in proc. workshop on graph-based tools (grabats). electronic communications of the easst 1. 2006. [ekmr99] h. ehrig, h.-j. kreowski, u. montanari, g. rozenberg (eds.). handbook of graph grammars and computing by graph transformation. volume 3: concurrency, parallelism and distribution. world scientific, september 1999. [ektw06] k. ehrig, j. küster, g. taentzer, j. winkelmann. generating instance models from meta models. in 8th ifip international conference on formal methods for open object-based distributed systems (fmoods’06). lecture notes in computer science 4037, pp. 156–170. springer verlag, 2006. [em93] h. ehrig, michael löwe. parallel and distributed derivations in the single-pushout approach. theoretical computer science 109:123–143, 1993. [fol07] a. folli. uml model refactoring using graph transformation. master’s thesis, institut d’informatique, université de mons-hainaut, 2007. [fow99] m. fowler. refactoring: improving the design of existing code. addison-wesley, boston, ma, usa, 1999. [gz04] l. geiger, a. zündorf. statechart modeling with fujaba. electronic notes in theoretical computer science, 2004. [heet99] r. heckel, g. engels, h. ehrig, g. taentzer. classification and comparison of module concepts for graph transformation systems. pp. 669–689. world scientific publishing co., inc., river edge, nj, usa, 1999. [kk99] h.-j. kreowski, s. kuske. graph transformation units and modules. pp. 607–638. world scientific publishing co., inc., river edge, nj, usa, 1999. [ks06] a. königs, a. schürr. tool integration with triple graph grammars a survey. in heckel (ed.), proceedings of the segravis school on foundations of visual modelling techniques. electronic notes in theoretical computer science 148, pp. 113–150. elsevier science publ., amsterdam, 2006. [men06] t. mens. on the use of graph transformations for model refactoring. in ralf lämmel (ed.), generative and transformational techniques in software engineering. lecture notes in computer science 4143, pp. 219–257. springer, 2006. proc. software evolution 2007 14 / 15 eceasst [mt04] t. mens, t. tourwé. a survey of software refactoring. ieee trans. software engineering 30(2):126–162, february 2004. [mtr07] t. mens, g. taentzer, o. runge. analysing refactoring dependencies using graph transformation. software and systems modeling, pp. 269–285, september 2007. doi:10.1007/s10270-006-0044-6 [mvd06] t. mens, r. van der straeten, m. d’hondt. detecting and resolving model inconsistencies using transformation dependency analysis. in nierstrasz et al. (eds.), model driven engineering languages and systems. lecture notes in computer science 4199, pp. 200–214. springer-verlag, october 2006. [nz00] j. niere, a. zündorf. using fujaba for the development of production control systems. in nagl et al. (eds.), proc. applications of graph transformations with industrial relevance (agtive). lecture notes in computer science 1779, pp. 181–191. springerverlag, 2000. [obj05] object management group. unified modeling language: superstructure version 2.0. formal/2005-07-04, august 2005. [opd92] w. f. opdyke. refactoring: a program restructuring aid in designing objectoriented application frameworks. phd thesis, university of illinois at urbanachampaign, 1992. [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation. volume 1: foundations. world scientific, february 1997. [saz99] a. schürr, andreas winter, a. zündorf. the progres approach: language and environment. pp. 487–550. world scientific publishing co., inc., river edge, nj, usa, 1999. [sk03] s. sendall, w. kozaczynski. model transformation: the heart and soul of modeldriven software development. ieee software 20(5):42–45, 2003. special issue on model-driven software development. [tae04] g. taentzer. agg: a graph transformation environment for modeling and validation of software. in proc. applications of graph transformations with industrial relevance (agtive). lecture notes in computer science 3062, pp. 446–453. springerverlag, 2004. [vv07] g. varró, d. varró. recursive graph pattern matching. in proc. applications of graph transformations with industrial relevance (agtive). pp. 453–467. wilhelmshöhe, kassel, germany, 2007. 15 / 15 volume 8 (2008) http://dx.doi.org/10.1007/s10270-006-0044-6 introduction motivating example formal representation as graph transformation tool support discussion limitations of agg limitations of graph transformation tools in general alternative graph transformation tools conclusion on the resilience of classes to change electronic communications of the easst volume 8 (2008) proceedings of the third international ercim symposium on software evolution (software evolution 2007) on the resilience of classes to change rajesh vasa, jean-guy schneider, oscar nierstrasz and clinton woodward 11 pages guest editors: tom mens, ellen van paesschen, kim mens, maja d’hondt managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst on the resilience of classes to change rajesh vasa1, jean-guy schneider1, oscar nierstrasz2 and clinton woodward1 1 faculty of information & communication technologies swinburne university of technology p.o. box 218, hawthorn, vic 3122, australia rvasa@swin.edu.au, jschneider@swin.edu.au, cwoodward@swin.edu.au 2 institute of computer science university of bern bern, ch-3012, switzerland oscar@iam.unibe.ch abstract: software systems evolve over time incrementally and sections of code are modified. but, how much does code really change? lehman’s laws suggest that software must be continuously adapted to be useful. we have studied the evolution of several public domain object-oriented software systems and analyzed the rate as well as the amount of change that individual classes undergo as they evolve. our observations suggest that although classes are modified, the majority of changes are minor and only a small proportion of classes undergo significant modification. keywords: open-source, change, metrics. 1 introduction it is a well-established fact that software systems change and become more complex over time as they are used in practice [lb85]. however, it is less well-understood how change and complexity are distributed over time, and there has been little research conducted into understanding how change is distributed over the parts of object-oriented software systems. in previous work, we have studied typical growth and change patterns in open-source, objectoriented software systems and shown that although software grows and changes over time, the structure and scope of both growth and change is, in general, predictable rather than erratic or purely random [vswc05, vls07, vsn07]. this leads us to ask whether we can gain a more detailed insight into where change occurs, and the degree to which change can be expected. not only do we need a suitable distance measure to indicate how much a class or component changes, but we should also collect information about change both at a fine-grained level to gain insights into change of individual artefacts, and at a coarse-grain to gain insight into system-level change. this will then allow us to address questions such as: • what proportion of a release contains code that has never been touched since creation? • what is the probability that a class is modified after it is created? • how is modification frequency distributed for classes that do change? 1 / 11 volume 8 (2008) mailto:rvasa@swin.edu.au mailto:jschneider@swin.edu.au mailto:cwoodward@swin.edu.au mailto:oscar@iam.unibe.ch on the resilience of classes to change • does a class or component tend to change a lot or are most modifications minor adjustments? continuing our previous work, we have analyzed a number of open source applications that have evolved over at least 18 releases during a period of at least 28 months. for each of these applications we have collected information on the amount of change individual classes go through as they evolve over time. the key results of our studies show that: 1. most classes will be modified at least once during their lifetime, but a substantial proportion of classes stay unchanged during their entire history. 2. of the classes that are modified, the probability that a class is modified multiple times is quite low. 3. the amount of change that most classes undergo is also minimal. however, a small proportion of classes is modified significantly. the rest of this paper is organized as follows: in section 2 we provide an overview of our experimental method, and we justify the selection of the case studies. section 3 presents the results of our studies. in section 4 we suggest possible interpretations and consequences of our observations, followed by a discussion of some limitations of our approach in section 5. section 6 provides a brief overview of related work. we conclude in section 7 with some remarks about future work. 2 experimental method in this section, we briefly present the systems studied. next, we describe the means by which measurements are performed, followed by a discussion about the measures that we collected. finally, we illustrate the approach used to detect clones and measure change. 2.1 input data set selection as in our previous work [vswc05, vls07, vsn07], we have restricted our study to opensource software developed using the java programming language. the main reasons for selecting open source software are their availability, access to change logs (e.g., such as developer release notes), as well as licensing practices that allow access to both source and object code. the choice of the systems using the java programming language was influenced by its use in a variety of application domains, as well as by the availability of a suitable infrastructure to implement the necessary metrics tool. although there is a large pool of candidate systems, we have limited our selection to 12 representative systems (cf. table 1) for this study. our data set contains a total of 310 releases. all systems analyzed in this study have at least 18 releases and a development history of 28 months or more. a release sequence number (rsn) [cl66] is used to uniquely and consistently identify each release version of a given system. the first version of a system is numbered 1 and then each subsequent version increases by one. hence, rsns are universally applicable and independent of any release numbering schedule and/or scheme. proc. software evolution 2007 2 / 11 eceasst name releases time span initial size current size description axis 23 65 mo. 166 636 apache soap server azureus 21 41 mo. 103 4780 bittorent client castor 27 48 mo. 483 691 data binding framework checkstyle 26 75 mo. 18 309 coding standard checker findbugs 20 36 mo. 308 839 automated bug finding application groovy 20 38 mo. 170 886 dynamic language for jvm hibernate 47 73 mo. 120 1055 object-relational mapping framework jung 21 44 mo. 157 705 universal network/graph framework spring 42 43 mo. 386 1570 light-weight container struts 18 28 mo. 106 300 servlet/jsp framework webwork 20 36 mo. 75 473 web application framework wicket 25 30 mo. 181 631 web application framework table 1: systems under analysis for this study with size being the number of classes and interfaces. 2.2 extracting measures in order to perform the analysis, we developed a metrics extraction tool [vswc05], which analyzes java bytecode and extracts data to capture the degree of change of a system with respect to its size and complexity. java bytecode generally reveals almost as much about a system as its source code, and only some subtle changes to a software system cannot be detected using this approach (e.g., use of local variables). our metrics extraction tool takes as input the core jar files for each release of a system, and extracts metrics by processing the raw java bytecode. this approach allows us to avoid running a potentially complex build process for each release, and limits analysis to “code” that has been correctly compiled as the developers intended. for each class1 in a system under analysis, we extract simple measures such as the number of methods, fields, branches as well as the set of classes that this class depends upon, either as direct client or direct subclass. type dependency graph analysis [vcs02] can then be used to compute other measures such as fan-in [vsn07]. 2.3 software measures using the metrics extraction tool, we have extracted 43 different count measures for each class in each system analyzed. the names we have given to these measures are listed in table 2 and include, amongst others, fan-out and branch count (i.e., the number of branch instructions in the java bytecode), load instruction count (i.e., the number of load instructions), and store instruction count (i.e., the number of store instructions). a detailed discussion of all these measures is beyond the scope of this work. however, they naturally align with the most common instructions of the java bytecode as well as covering some basic structural relationships. furthermore, to support a more detailed comparison, we store the name of each class, its superclass name, all method names (including full signatures), field names and the name of all 1 to improve readability we will refer to “classes” when we mean “classes or interfaces”. we will only refer to “types” in the context of the formal measures. 3 / 11 volume 8 (2008) on the resilience of classes to change abstractmethodcount branchcount constantloadcount exceptioncount externalmethodcallcount fanoutcount fieldcount finalfieldcount finalmethodcount iloadcount incrementopcount innerclasscount interfacecount internalfanoutcount internalmethodcallcount isabstract isexception isinterface isprivate isprotected ispublic istorecount loadfieldcount localvarcount methodcallcount methodcount privatefieldcount privatemethodcount protectedfieldcount protectedmethodcount publicfieldcount publicmethodcount refloadopcount refstoreopcount staticfieldcount staticmethodcount storefieldcount superclasscount synchronizedmethodcount throwcount trycatchblockcount typeinsncount zeroopinsncount table 2: java bytecode measures extracted for analysis. other classes that a class depends upon. this information is then used in our clone detection method discussed in the next section. 2.4 detecting clones and measuring change in order to perform our analysis, in particular to detect clones and measure changes between versions of a given system, we consider the following information for each class under analysis: (i) the fully qualified class name, including its class modifier (i.e., public, private, protected, interface, final or abstract) (ii) the name of its direct super class, (iii) the name, types and class modifier(s) of all fields, (iv) the name, signature and class modifier(s) of all methods, and (v) the set of classes this class depends upon. additionally, we extract all 43 class level measures for each version of a class under investigation. for our analysis, we consider two classes to be clones of each other (we treat them as being identical) if all metrics for each class are identical (i.e., all 43 measures have the same value, same class name with the same modifiers etc.). furthermore, the distance between two classes is defined as the number of measures (out of the 43) that differ (i.e., if two of the 43 measures differ between two classes, then they have a distance of 2). note that even if two classes have a distance of 0, they may not be identical (e.g., the name of a field is modified). however, our analysis has revealed that this is only rarely the case and over all 310 versions we analyzed, at most 4% of modified classes have a distance of 0. finally, we consider the history of a system as the set of versions, ordered by rsn, whereas a version is the set of all classes contained in a particular release. we compare the final version of each system with all previous versions (i.e., over the entire evolutionary history) in order to compute the following information: • the proportion of classes in the final version that remain unchanged since creation as well as the proportion that are modified after being created. • the number of times a class has been modified since its creation. • the amount of modification that each class has undergone since its creation (i.e., modification amplitude). proc. software evolution 2007 4 / 11 eceasst the information gathered from the first point gives us an overall picture of the number of classes that stay unchanged over their lifetime. the last point indicates if changes are substantial, and can provide an indication of the distribution of small and large changes. 3 observations we now summarize our observations from analyzing the 12 systems listed in table 1. first, we analyze the percentage of classes that have not changed since being added into the respective system. we then consider the set of modified classes and analyze the number of times they have been modified. finally, we illustrate how much modified classes change over time. 3.1 probability of change at a class level, systems evolve by addition of new classes, modification of existing classes or removal of classes. hence, given an evolutionary history, for any given version we can identify three types of classes: new classes, classes that have been modified at some point in their life, and classes that have not changed since their creation. in our analysis, we use the last release of a given system as the base-line for comparison. we consider a class as being unchanged if it is a clone of its first release, i.e., the release in which it was first defined. any potential changes in between are not analyzed in our approach. similarly, we consider a class as having changed (at least once) if it is not identical to its first release. a class is considered to be new if it did not appear in any release before the last one. the results of our analysis are illustrated in figure 1. except for webwork and jung, the percentage of unchanged classes is lower than the percentage of modified classes. however, it is interesting to see that the percentage of unchanged classes ranges between 20% and 55%, depending on the system. the lower end of the range indicates that in general there is a certain proportion of classes that are never touched and the average, which is closer to 40%, suggests that there is a certain inherent resistance to change in many of the classes once they have been added. also, our analysis shows that the number of new classes introduced in the last release is small and generally tends to be under 5%. 3.2 rate of modification as noted in the previous section, only a small proportion of all classes undergoes some change. however, how often are these classes modified? what does the distribution of this modification look like? again, we use the last release as our base-line and only report on classes that are part of this release – any classes that have been removed before then are not considered. from our previous work [vsn07] we know that only about 2% to 5% of classes fall into this category. only considering classes that have been modified at some point in their life cycle and counting the number of times that they have been modified, we can observe that, on average, 50% thereof are modified less than 3 times. in jung, for example, 90% of modified classes are changed less than 3 times. furthermore, as shown in figure 2, all of the systems have a similar modification profile. due to the way we have charted the values using absolute modification count, axis and 5 / 11 volume 8 (2008) on the resilience of classes to change 0.0% 10.0% 20.0% 30.0% 40.0% 50.0% 60.0% 70.0% 80.0% 90.0% 100.0% st ru ts az ur eu s g ro ov y ax is hi be rn at e ca st or sp rin g ch ec ks ty le w ic ke t fi nd bu gs w eb w or k ju ng % c la s s e s unchanged modified new figure 1: proportion of new, unchanged, and modified classes using final version as base-line. jung show up as minor outliers. on average, 5% or less of all modified classes are changed more than 8 times in their life cycle. this suggests that the probability that a class is modified multiple times is quite low and that this probability reduces non-linearly, as is shown in figure 2. please note that only 0.01% of classes were modified more than 25 times. 3.3 distribution of the amount of change as software evolves, we have observed that there is a proportion of code that changes, but the number of modifications is in most cases minimal. but how much change does happen, i.e., how many measures do actually change? is there a typical profile for most systems, like the one we observe in the modification frequency? in order to detect the amount of change, we focus on the classes in the final version that have been modified at least once in their life cycle. we then compute the number of measures (out of the 43 possible) that have changed between the version the class was first defined and the final version. this high-level approach allows us to see if there is a common profile across the various systems, but does not indicate how big the changes in each of the 43 measures are. our observations for all systems under analysis are shown in figure 3. the reader may first notice that a few classes do not indicate a change in any of the measures at all. this is possible since the clone detection technique that we apply also takes into consideration method signatures, field names etc. (cf. section 2.4). however, there is a probability that some other measure that we do not collect has changed in such a situation. on average, in our data less than 4% of the classes fall into this category. when exploring the data for a profile, we observed that 6 systems are much more closely aligned than the other 6 systems, and one of the systems, groovy, has a substantially different profile. however, despite the broad range, much of the cumulative growth is fairly linear for 90% proc. software evolution 2007 6 / 11 eceasst 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 modification count % c la s s e s ( c u m u la ti v e ) axis azureus castor checkstyle findbugs groovy hibernate jung spring struts webwork wicket figure 2: cumulative distribution of the modification frequency of classes that have undergone a change in their lifetime. of the classes across multiple systems and only 10% of the modified classes have more than 23 measures modified. the cumulative growth for the remaining 10% is not linear any more and needs further analysis. the reader may note that as some of the measures are closely related (e.g., a store instruction is generally aligned with at least one load instruction), it can be expected that they change in a similar way. early analysis indeed suggests that the number of load instructions and the number of store instructions have a very close relationship. however, further analysis is required to clarify the correlation between the various measures. 4 interpretation probability of change: in all of the systems that we have studied, a good proportion of classes remained unchanged. this indicates that some abstractions tend to stay very stable after they are created. the range of values for different systems suggests that this stability depends on the domain and possibly the development approach as well as the architectural style that the team has adopted early in their life cycle. rate of modification: of the classes that have changed, most have been touched a few times – only a small proportion is modified several times. this modification profile is very similar in all systems under analysis, suggesting that most classes in a system tend to reach a stable state very quickly. combined with our earlier observation that a good proportion of code is never touched, this suggests that development teams tend to create a stable set of abstractions very quickly. our findings provide further support to a similar conclusion reached by kemerer et al. [ks97]. 7 / 11 volume 8 (2008) on the resilience of classes to change 0.0% 10.0% 20.0% 30.0% 40.0% 50.0% 60.0% 70.0% 80.0% 90.0% 100.0% 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 number of metrics modified % c la s s e s ( c u m u la ti v e ) axis azureus castor checkstyle findbugs groovy hibernate jung spring struts webwork wicket figure 3: number of measures that change for modified classes. distribution of the modifications: modifications are unavoidable as systems evolve. however, very few of the classes tend to experience a high level of modification (as computed by the number of measures that change). although our approach does not reveal the actual amount of code changed, it provides us a broad indicator which may serve as a starting point for further analysis. 5 limitations in order to place our study in context, we highlight some of the known limitations of our approach in addition to our findings. the clone detection method used in this work may pick up false positives since there may be changes to a class that our 43 metrics are unable to detect. we intend to improve this by adding further metrics and additional aspects like the method calls and the call sequence. furthermore, our distance measure compares the initial version of a class to the final version. this may miss edits where a class is modified and returned back to its original shape, as seen by the metrics. this limitation can be addressed by looking at distance incrementally. as a consequence, the analysis approach would have to be adjusted to take into consideration the way the metric information is being collected. our method of computing modification misses classes that have been renamed; they will be considered as a deletion and an addition. this is a weakness that we are addressing in future work by improving clone detection to accept a certain level of name changes (e.g., package name change). we have restricted our input data set to open-source software targeting the java vm. this limproc. software evolution 2007 8 / 11 eceasst its the ability to interpret our findings in other languages, since every language tends to promote a certain culture and a different language may have a different outcome. furthermore, commercially developed software systems, or systems that are substantially larger than those in our investigation, may reveal different patterns of stability and maintenance profiles. 6 related work kemerer and slaughter have studied the profile of software maintenance in five business systems at the granularity of modules. they conclude that very few modules change frequently, and those that do are considered to be strategic [ks97]. gı̂rba has noted that classes that have changed in the past are also those most likely to change in the future, but these classes are in the minority [gir05]. a number of researchers have studied methods of detecting existence of a class in previous versions (i.e., a clone) using a range of different techniques from string matching [?, joh94, rd03], abstract syntax trees [bym+98] and metrics-based fingerprinting [accd00, kdm+96]. in our study we detect clones by combining metrics as well as string matching. we collect string information to the extent possible by bytecode analysis (for example, method signatures and dependent type names). although definitions and methods to detect clones have been provided, a comprehensive study with an intention of understanding change and stability using clone detection has not previously been done. origin analysis [zg05] uses a semantic perspective of the context and usage of code in order to determine where, why and how changes have occurred. the technique also makes use of version control log data to determine the true origin of code components and changes. their technique is in contrast to metrics-based methods, such as our own and those proposed by demeyer et al. [ddn00] designed to identify specific components rather than origins. barry et al. [bks03] describe software volatility as a concept with 3 dimensions: amplitude (size of change), periodicity (frequency of change) and deviation (consistency of change). using a phase sequence analysis approach, they detected a distinct set of volatility patterns. their data set involved studying maintenance activity log from 23 different systems. in our approach, we have focused on information that can be collected automatically rather than by parsing log files. 7 conclusions and future work in this paper, we have investigated where change occurs within 12 open-source java systems that have evolved over a period of at least 2 years at the granularity of classes through bytecode analysis. our study shows that when we look at the latest version of a given system, around a third (or more) of the classes are unchanged since being added into the code base. of the modified classes, very few are changed multiple times, suggesting an inherent resistance to change. further analysis suggests that only a small minority of the classes tend to undergo substantial change. these findings show that maintenance effort, which is considered to be a substantial proportion of the development effort (post initial versions) is spent on adding new classes. furthermore, when existing classes need to be modified, the probability of large alterations is generally quite low. 9 / 11 volume 8 (2008) on the resilience of classes to change our work leads us to ask the following questions as possible future work: is there an inherent profile for classes that tend to change significantly? are there any factors that correlate with classes becoming stable? when changes are made, are large modifications made in a single version or do they tend to make these over multiple versions? when a class is modified a few times, are the changes minor? is there any strong correlation that suggests that either size or complexity play a role in the tendency for a class to be modified? can one characterize the nature of frequently occurring changes? acknowledgements: the authors would like to thank orla greevy for her comments on a draft of this paper. oscar nierstrasz gratefully acknowledges the financial support of the swiss national science foundation for the project “analyzing, capturing and taming software change” (snf project no. 200020-113342, oct. 2006 sept. 2008). bibliography [accd00] g. antoniol, g. canfora, g. casazza, a. de lucia. information retrieval models for recovering traceability links between code and documentation. in proceedings of the international conference on software maintenance (icsm 2000). pp. 40–49. 2000. doi:10.1109/icsm.2000.883003 [bks03] e. j. barry, c. f. kemerer, s. a. slaughter. on the uniformity of software evolution patterns. icse 00:106–113, 2003. doi:10.1109/icse.2003.1201192 [bym+98] i. baxter, a. yahin, l. moura, m. s. anna, l. bier. clone detection using abstract syntax trees. in proceedings of the international conference on software maintenance (icsm 1998). pp. 368–377. ieee computer society, washington, dc, usa, 1998. doi:10.1109/icsm.1998.738528 [cl66] d. cox, p. lewis. the statistical analysis of series of events. in monographs on applied probability and statistics. chapman and hall, 1966. [ddn00] s. demeyer, s. ducasse, o. nierstrasz. finding refactorings via change metrics. in proceedings of 15th international conference on object-oriented programming, systems, languages, and applications (oopsla ’00). pp. 166–178. acm press, new york ny, 2000. also appeared in acm sigplan notices 35 (10). doi:10.1145/353171.353183 [gir05] t. gı̂rba. modeling history to understand software evolution. phd thesis, university of berne, berne, nov. 2005. [joh94] j. h. johnson. substring matching for clone detection and change tracking. in proceedings of the international conference on software maintenance (icsm 94). proc. software evolution 2007 10 / 11 http://dx.doi.org/10.1109/icsm.2000.883003 http://dx.doi.org/10.1109/icse.2003.1201192 http://dx.doi.org/10.1109/icsm.1998.738528 http://dx.doi.org/10.1145/353171.353183 eceasst pp. 120–126. 1994. doi:10.1109/icsm.1994.336783 [kdm+96] k. kontogiannis, r. demori, e. merlo, m. galler, m. bernstein. pattern matching for clone and concept detection. journal of automated software engineering 3:77– 108, 1996. doi:10.1007/bf00126960 [ks97] c. f. kemerer, s. a. slaughter. determinants of software maintenance profiles: an empirical investigation. software maintenance: research and practice 9(4):235– 251, 1997. [lb85] m. lehman, l. belady. program evolution: processes of software change. london academic press, london, 1985. [rd03] f. v. rysselberghe, s. demeyer. reconstruction of successful software evolution using clone detection. in proc. of international workshop on principles of software evolution (iwpse). pp. 126–130. 2003. [vcs02] s. valverde, r. f. cancho, r. sole. scale-free networks from optimal design. europhysics letters 60(4):512–517, 2002. [vls07] r. vasa, m. lumpe, j.-g. schneider. patterns of component evolution. in lumpe and vanderperren (eds.), proceedings of the 6th international symposium on software composition (sc 2007). pp. 244–260. springer, braga, portugal, mar. 2007. [vsn07] r. vasa, j.-g. schneider, o. nierstrasz. the inevitable stability of software change. in proceedings of 23rd ieee international conference on software maintenance (icsm ’07). ieee computer society, los alamitos ca, 2007. to appear. [vswc05] r. vasa, j.-g. schneider, c. woodward, a. cain. detecting structural changes in object-oriented software systems. in verner and travassos (eds.), proceedings of 4th international symposium on empirical software engineering (isese ’05). pp. 463–470. ieee computer society press, noosa heads, australia, nov. 2005. doi:10.1109/isese.2005.1541855 [zg05] l. zou, m. godfrey. using origin analysis to detect merging and splitting of source code entities. ieee transactions on software engineering 31(2):166–181, 2005. doi:10.1109/tse.2005.28 11 / 11 volume 8 (2008) http://dx.doi.org/10.1109/icsm.1994.336783 http://dx.doi.org/10.1007/bf00126960 http://dx.doi.org/10.1109/isese.2005.1541855 http://dx.doi.org/10.1109/tse.2005.28 introduction experimental method input data set selection extracting measures software measures detecting clones and measuring change observations probability of change rate of modification distribution of the amount of change interpretation limitations related work conclusions and future work a framework for the formal verification of networks of railway interlockings application to the belgian railway electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) a framework for the formal verification of networks of railway interlockings application to the belgian railway christophe limbrée, charles pecheur 17 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst a framework for the formal verification of networks of railway interlockings application to the belgian railway christophe limbrée1, charles pecheur1 christophe.limbree|charles.pecheur@uclouvain.be université catholique de louvain, louvain-la-neuve, belgium abstract: modern railway stations are controlled by computerized systems called interlockings. in fact the middle size and large size stations usually require to use several interlockings, then forming a network of interlockings. much research propose to verify the safety properties of such systems by means of model checking. our approach goes a step further and proposes a method to extend the verification process to a network of interlockings. this process is known as compositional verification. each interlocking is seen as the component of a larger system (i.e., station) and interacts with its neighbours by means of interfaces. our first contribution comes in the form of a catalogue of elements that constitute the interfaces (as used in the belgian railways) and associated contracts. each interface can then be bound to a formal contract allowing its verification by the ocra tool. our second contribution comes in the form of an algorithm designed to split the topology controlled by a single interlocking into components. the verification of a large station can therefore be achieved by verifying its constituting components and their interaction thereby tackling the state space explosion problem while providing guarantees on the whole interlocking. keywords: interlocking, model checking, compositional verification, ocra, nuxmv, pdr, ic3 1 introduction interlocking system in the railway domain, an interlocking is an arrangement of systems that prevents conflicting train movements in a station. the main component of an interlocking is a safety-critical system relying on a generic software and application data in order to control the railway traffic in a station. figure 1.1 illustrates a toy station controlled by an interlocking. the application data are the configuration layer needed by the interlocking in order to control a specific station. in a route-based interlocking, the application data are organized in routes. for example, the route r c 043 is a path in the station shown in figure 1.1 granting passage to a train from signal c to track 043. the main elements/resources used by a route are: the points, the track circuits, the track, and the signals. a point is a mechanical installation enabling railway trains to be guided from one track to another. a track circuit is a simple electrical device used to detect the absence of a train on rail tracks. a track is a position on railway network where a route starts or ends. a signal is an electrical device used to pass information relating to the state of the route ahead to train drivers. a route takes different states: it goes from not set to set, to 1 / 17 volume 076 (2019) mailto:christophe.limbree$|$charles.pecheur@uclouvain.be a framework for the formal verification of networks of railway interlockings t t_04bm t_02am p_01a p_01b p_02b p_02b s_c 043 s_cx 044 r_cm_043 figure 1.1: interlocking a first toy example of station. proved, and returns to not set. in ”proved” state, the train is allowed to proceed on the route as the route origin signal shows green aspect. the resources allocated by the route are freed when the train runs through the route according to a specific sequence. the route is then released. 1 *q_r(c_043) 2 if r_c_043 xs 3 p_01a cfn, p_01b cfn, p_02ab cfr, p_02b cfr 4 u_ir(01a) f , u_ir(02b) f 5 then r_c_043 s 6 p_01a cn , p_01b cn , p_02a cr , p_02b cr , 7 u_ir(01a) l , u_ir(02b) l 8 u_cbspa(043) l listing 1: example of application data route first step. listing 1 shows an extract from the application data corresponding to the control of route q r(c 043) (line 1). the first part of the code holds the conditions that allow the route control (line 2 4). first the route is checked not being set yet (line 2). second (line 3) the points are checked to be movable to the position required by the route. for example, the point p 01a must be cfn meaning free to move to normal position. the last line (4) refers to the locking of the points. the second parts of the listing enumerates all the actions taken if the conditions are fulfilled. line 6, the points are controlled (e.g., p 01a is controlled left cn). second, the points locking variables are put in locked state (line 7). line 8 refers to the directional locking. indeed track 043 can be accessed from the left and from the right. thereby in order to avoid collisions, the interlocking shall not grant two routes in opposite direction to 043 at the same time. that’s the purpose of the u cbsp variable where the suffix a is used from left to right and the suffix b in the opposite direction. in our first paper [bcl+15], we presented the model-checking of the interlocking of a small station of the belgian network (namêche) by translating the ssi (solid state interlocking) application data into a nusmv model. in our case study, the bdd (binary decision diagram) algorithm provided in nusmv easily allowed to verify invariants whereas a special algorithm using pynusmv [bp13] was used to verify ctl formulas (computation tree logic). considering the fact that a verification process based on a monolithic model would not scale up to stations of larger size, we proposed a novel method based on compositional verification [lim16]. this approach used a compositional verification framework called ocra [cdt13, ct12, ocr18]. all the configuration (components and contracts) was done manually as opposed to our new contribution avocs 2018 2 / 17 eceasst where our algorithm retrieves both the components and contracts and produces the configuration files for ocra. in section 2 we provide the background for the compositional verification. in section 3, we introduce our catalogue of interface and contract definitions. in section 4, we propose an algorithm designed to split a station into smaller components in order to tackle the space state explosion problem. in our case study in section 5, we apply our algorithm and catalogue in order to verify the ”no-collision” safety property on a realistic size station of the belgian network. finally we conclude in section 6. 1.1 validation of interlocking the application data are prepared manually and are therefore subject to human errors. for example: conditions can be missing in a route control, such as a point condition. this kind of error could easily be discovered by a code review or by testing on a simulator (e.g., route by route). a much harder to find and malicious problem is that caused by concurrent actions (e.g., route or point requests). in this case, the combination of possible concurrent actions explodes quickly and testing all possible combinations manually is not tractable. currently the validation of the application data relies on the combination of different v&v activities such as functional tests, safety tests, and application data reviewing. the functional tests ensure that the system responds properly to the commands issued by the traffic controller. during safety tests, all the conditions that are supposed to impact the routes are tested in their restrictive states (e.g., a point in the wrong position shall not allow the origin signal of a route to go green). those tests are prepared and carried out by an independent tester. finally, the application data are reviewed by the technical manager in charge of the project. all anomalies are traced in a bug management tool and the engineer in charge ensures that they are all closed before the interlocking is commissioned. 1.2 formal verification of interlocking in their paper [ffm12], fantechi et al. clearly states that the future of model checking for interlocking lays in the sat solvers which is the direction that we have taken in our research by using the pdr/ic3 (property directed reachability/incremental construction of inductive clauses for indubitable correctness) algorithm in the nuxmv model checker [rob14]. recently fantechi et al. [a. 17] proposed a similar approach based on compositional verification by making assumptions on the interaction between the connected interlockings in order to ignore them. by opposition, we formalize the existing connections (interfaces) defined in our interlockings through our compositional framework (ocra) as they can’t be ignored. in their research [win01, win12], winter et al. propose to use abstract state machine to encode the application data before optimizing the ordering of the variables used in the bdd algorithm of nusmv. the same approach was used in our first case study [bcl+15] but didn’t permit to verify stations of significant size. haxthausen et al. use bmc and induction in order to verify interlocking data with the rt-tester tool-box [hpp14]. they also demonstrate how to model the sequential release process of the interlocking [hhp14]. the sequential release is used to increase the capacity of a railway network and is also implemented in our model whereas we only use bmc to verify liveness properties. 3 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings 2 compositional verification of interlockings in this section, we explain why we need to use the compositional verification for application data of interlocking. we also provide the reader with the theoretical basis underlying the proof system implemented in the ocra framework. 2.1 a justification for the compositional verification in the railway domain, the norm [cen02] defines the safety integrity level (sil) for the development of safety critical systems and imposes to use the highest level (4) for the interlocking. one of the consequences is that the interlocking must ensure the computation of its outputs and internal states within a given period of time which in terms restricts the number of objects that it can control. for example, a ssi (solid state interlocking) [f. 13] can control maximum 64 points, 128 signals, 256 tack-circuits, and 256 routes. on the other hand, we want to diminish the impact of an interlocking failure on the train traffic. that’s why, we wouldn’t never control a significant size station with only one interlocking but we would use several of them. all these arguments highlight the fact that an interlocking can’t be seen as an isolated system. in fact the railway network must be considered as a graph of interconnected interlockings with borders and interfaces. a border is a boundary between two control areas whereas an interface is a connection point where interlockings exchange data. those interfaces and the information that they carry must guarantee the safety of the railway traffic when trains are heading for a border. 2.2 compositional verification we use the ocra compositional verification framework in order to verify a connected interlocking graph. practically, ocra provides: 1) a formal framework to specify a system made of a hierarchy of connected components 2) a formal language to define the properties to be verified on the system, and 3) a set of verification tools. in ocra, the keyword system must be understood as a graph of interconnected interlockings (composite). a component represents an interlocking instantiated by its smv model (nuxmv) and is later called the leaf model. a component can also be a part of interlocking as it’s sometimes possible to split an interlocking model into smaller ones in order to tackle the state space explosion problem (section 4). the system and its components are described in othello language proposed by cimatti et al. [cim13]. othello allows for complex combinations of linear temporal operators, boolean connectives, regular expressions, over terms referring to the variables of components ([ct12]). the contracts-refinement proof system for component-based systems was proposed by cimatti et al. in the paper [ct15]. the verification of the whole system (graph of interlockings) takes place in three steps: 1. checking that the components contracts entail the system contract 2. checking that each component satisfies its contracts 3. checking that the environment of each component satisfies the assumption of that component avocs 2018 4 / 17 eceasst s c1 c2 figure 2.1: system represented as a hierarchy of components (c1 and c2) and contracts. the properties to be verified on a system (e.g., s in figure 2.1) are expressed by means of the high-level contracts. a contract c for a system s is an assume-guarantee pair of (ltl linear temporal logic) assertions 〈a,g〉 where [[a]] and [[g]] are sets of traces over the interfaces of s. a trace represents the observable part of a run of a component. it consists of the events and values of data ports (interface variables). the contract 〈a,g〉 applies to the system s and is refined by contract 〈a1,g1〉 for c1 and contract 〈a2,g2〉 for c2. in the first step, we verify that the component contracts entail the system contract (eq. 2.1). ((¬a1∨g1)∧(¬a2∨g2))→ (¬a∨g) (2.1) equa 2.1: components contracts must entail the system contract. in the second step, we verify that each component properly implements its contract. more formally we say that i is an implementation satisfying c iff i ∩ [[a]] ⊆ [[g]] (i |= a → g). in our example, it means verifying that i1∩ [[a1]] ⊆ [[g1]] and i2∩ [[a2]] ⊆ [[g2]]. i1 and i2 are respectively implementations for the c1 and c2 components. for the verification of the implementation, ocra calls nuxmv. in the last step, we must verify that the environment of each component satisfies its contract. more formally, we say that e is an environment satisfying c iff e ⊆ [[a]]. for our example in figure 2.1 it is verified by checking the validity of the following formulas 2.2: a∧(¬a2∨g2) → a1 a∧(¬a1∨g1) → a2 (2.2) equa 2.2: verification of the environment of each component. if the three steps of verification are valid, we say that the composition of c1 and c2 forming s satisfies the system property or more formally i |= a → g. to be complete, we provide list. 2 which is an example of contracts and interfaces definition in othello partially covering the toy example in figure 3.2. the high level contract (line 6-8) that we want to prove on the system s is: 5 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings train from xx to 10d → !train from yy to 10d (line 9). 10d is a location at the interface between interlockings xx and yy where a collision might happen. the property states that never a train coming from xx shall head for 10d at the same time as a train coming from yy. this contract is refined by two contracts at the xx (line 26-28) and yy component level. ud 10d b and ud 10d a are two variables shared among the components xx and yy. the interfaces and the connections between the components are defined in lines 14 and 15. the variables train from xx to 10d, ud 10d a, and ud 10d b are declared in the leaf model of xx and allow the verification of the contract at component level (step 2). our listing only shows the definition of the xx component. 1 component ath system 2 interface 3 output port train_from_xx_to_10d: boolean; 4 output port train_from_yy_to_10d: boolean; 5 -#2 top level contracts 6 contract train_10d 7 assume: always true; 8 guarantee: always (train_from_xx_to_10d -> !train_from_yy_to_10d ); 9 -#3 sub-components 10 refinement 11 sub ssixx : xx; 12 sub ssiyy : yy; 13 -#4 connections 14 connection ssixx.ud_10d_b := ssiyy.ud_10d_b; 15 connection ssiyy.ud_10d_a := ssixx.ud_10d_a; 16 -#5 contracts refinements 17 contract train_10d 18 refinedby vixlxx.train_10d, vixlyy.train_10d; 19 -#6 first component 20 component xx 21 interface 22 input port ud_10d_b: boolean; 23 output port ud_10d_a: boolean; 24 output port train_from_xx_to_10d: boolean; 25 -#7 contract refinement at component level 26 contract train_10d -27 assume: always true; 28 guarantee: always (train_from_xx_to_10d -> (!ud_10d_a & ud_10d_b )); listing 2: example of ocra configuration file. 3 catalogue of interfaces and contracts in this section, we describe our catalogue of interface and contract definitions which supports the automatic production of the ocra configuration file (e.g., list. 2) in order to perform the avocs 2018 6 / 17 eceasst compositional verification of graphs of interlockings. our catalogue is summarized in table 1 and holds five different types of interface. gig ig_2_3 is_intergrid version: 2 gig name: g_3 type: is_grid version: 1 gig name: g_2 type: is_grid version: 2 gig name: ig_1_2 type: is_intergrid version: 1 gig name: g_1 type: is_grid version: 1 figure 3.1: example of decomposition of a railway network into grids and inter-grids. first, we define the notion of grid and inter-grid. a grid is a part of the railway network where absolute signals (route origin signal), points, and treadles (wheel sensors installed on the rail) are found. three grids can be found in figure 3.1: g 1, g 2, and g 3. the inter-grids are found between the grids and don’t hold any points nor any absolute signals. in figure 3.1, there are two inter-grids: ig 1 2 and ig 2 3. in order to avoid train head-on collisions in an inter-grid, we use a mutual exclusion mechanism called directional locking (first three entries in table 1). to put it briefly, this mechanism ensures, as an example, that the interlocking controlling g 1 cannot send a train towards g 2 if the interlocking controlling g 2 is sending a train towards g 1 through ig 1 2 at the same time. t s_c s_cx s_kx s_k 043 044 10d 11d int.xx int.yy r_10d_044 r_cm_10d a b figure 3.2: sectioning point at the border between interlocking xx and yy (second toy example). second in order to better understand what a contract materialize, we provide a second toy example of a grid controlled by two interlockings separated by the blue line: int.xx and int.yy. at the border between the interlockings, we find two sectioning points (orange diamonds): 10d and 11d. an itinerary from signal c to track 044 requires to command two routes: r c 10d in int.xx and r 10d 044 in int.yy. an itinerary can involve several routes in different interlockings to form an end to end path in a station. the sectioning point has two ends: end a on its left side and end b on its right side. this translates in the application data by two variables: u 10d a and u 10d b. the first one is controlled by int.xx and the second one by int.yy. 7 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings these variables are used to formalize a contract between the components representing int.xx and int.yy guaranteeing that the two interlockings shall never command a route towards the shared sectioning point 10d (fourth entry in table 1). third, we apply conventions to the ocra configuration files. firstly we restrict the hierarchy of the connected components to two layers: the system (station) and the components (interlockings) as in figure 2.1. this saves forwarding the connections between different layers (system → component → sub-component). after we define the high level contracts as a ”no collision” property that, for our toy example, would be written as: !(train from xx to 10d & train from yy to 10d). the generic form is train from ccc to iii where ccc is the component and iii the interface point. the contracts at component level (column 3 in table 1) refine the top level contract and are verified on the smv model. the generic form of the interface is defined as ttt sss iii where ttt is the type of interface, sss the side/direction (a, b, or signal), and iii the interface name. we argue that our table covers all possible cases of interface used in the belgian signalling principles. table 1: catalogue of interfaces and contracts. type variable contract bsi u bsi[ab] iii train f rom ccc1 to iii →(¬u bsia iii∧ u bsib iii) train f rom ccc2 to iii →(¬u bsib iii∧ u bsia iii) bsp l bsp[ab] iii train f rom ccc1 to iii →(¬l bspa iii∧ l bspb iii) train f rom ccc2 to iii → (¬l bspb iii ∧l bspa iii) bsrm l vas iii, l vsd iii train f rom ccc to iii → (¬l vas iii ∧ l v sd iii) spoint u 10d [ab] train f rom x x to 10d → (¬u 10d a ∧ u 10d b) train f rom y y to 10d → (¬u 10d b ∧ u 10d a) dpoint u rsu iii [ab] train f rom ccc1 to iii → (¬u rsu iii a∧u rsu iii b) train f rom ccc2 to iii → (¬u rsu iii b∧u rsu iii a) the first three entries of table1 apply to the directional locking (i.e.,blocking) that comes in three varieties : bsi, bsp, and bsrm. the bsi applies to the platforms and is identified by the variable u bsi[ab] iii where [ab] gives the direction (→ or ←) and iii the name of the platform. the bsp applies to the tracks inside a grid where a level crossing is encountered for example. it’s identified by the variable u bsp[ab] iii where [ab] gives the direction and iii the name of the track. the bsrm is used between two stations. two variables are used: l vas and l vsd. as explained previously these three interfaces are used in the inter-grids. the last avocs 2018 8 / 17 eceasst two types of contracts are related the sectioning points (spoint as explained in the toy example) and the distribution point (dpoint). the distribution points are used for rail yards. their usage is very similar to that of the spoint except that the variable is u rsu. our catalogue is based on the belgian signalling principles but could be extended for other countries (e.g., france). it has the advantage of being readable by the railway experts. 4 an algorithm to split the interlocking topology the concept of compositional verification relies on 1) the definition of the components/interfaces and 2) the definition of contracts connecting the components through their interfaces. we define an algorithm that takes a railway grid data (as represented by ssi) and decomposes into components and interfaces with corresponding contracts. the algorithm relies on a collection of route objects holding their characteristics like their name (unique for an area), the origin signal, and a finite set of elements (resources used by the route). different types of elements are defined, such as: points, track-circuits, signals, and locking variables. those types are categorized into two subtypes: the internal resources used to set the route (e.g., points) and the interface elements which are typically encountered at the interface between components (e.g., directional locking). for the route r c 043 of figure 1.1, the internal resources are {p 01a, p 02b,u ir 01a, u ir 02b, s c, t 01, t 02} whereas {u bspa 043} is an external element preventing collision between the routes in opposite direction leading to the same destination point: track 043. two routes are said to be in opposite direction if one goes from left to right and the second one from right to left. the generation of the components can be automated following alg. 4.1 which takes the list of routes belonging to the grids of the station as input (line 1). the intermediate output comps has a map from component’s name → list of routes. for example, one entry of the resulting map could be: ”component 236” → list{r c 043, r c 044, r cx 043, r cx 044}. another intermediate map is used to map the routes to their component (e.g., compname entry: ”r c 043” → ”component 236”). the core of the algorithm is a nested loop (line 2-3) where the lists of routes are compared pairwise (rt1 and rt2 line 6). the method elements(rt) returns the internal elements of the route as defined previously. if the rt1 and rt2 are disjoint (line 19), the two routes are inserted into separated components, a new component is created if needed. if the element lists are not disjoint and if the two routes already belong to two different components, the two components are merged (line 11). otherwise if either rt1 or rt2 already belongs to a component, the other route is added to its routes list (lines 13-14). finally if neither rt1 nor rt2 belongs to a component, a new component is created and both routes are added to it (lines 15-18). in the second part of the algorithm, we process comps in order to produce the configuration file for ocra (lines 28-34). for each component (line 29) of comps and for each of their routes (line 30), we extract the interfaces in the elements list of the route. the interfaces are easily extracted as they were classified as interface elements. we attach a contract to each interface based on the mapping interface ↔ contract defined in our catalogue. for the example in figure 1.1, the algorithm would discover u bspa 043 as an interface of type bsp for route r c 043. the routes of a component can have different interfaces. for the example in figure 1.1, the algorithm would discover the interface u bspa 044 for the route r c 044. in the component definition, 9 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings algorithm 4.1: retrieve components and produce ocra config. file 1 data: rt route list 2 forall rt1 ∈ rt do 3 forall rt2 ∈ rt if rt2 6= rt1 do 4 comp1 = compname[rt1] 5 comp2 = compname[rt2] 6 if elements(rt1) ∩ elements(rt2) 6= ∅ then 7 if comp1 6=⊥ and comp2 6=⊥ then 8 if comp1 6= comp2 then 9 comp = new component 10 routes = comps[comp1] ∪ comps[comp2] 11 comps = comps -comp1 comp2 + comp → routes 12 compname[rt1] = compname[rt2] = comp 13 else if comp1 6=⊥ then comps[comp1] = comps[comp1] + rt2 14 else if comp2 6=⊥ then comps[comp2] = comps[comp2] + rt1 15 else create new component 16 comp = new component 17 comps[comp] = {rt1, rt2} 18 compname[rt1] = compname[rt2] = comp 19 else add rt1 and rt2 in components if needed 20 if comp1 6=⊥ then 21 comp = new component name 22 comps[comp] = {rt1} 23 compname[rt1] = comp 24 if comp2 6=⊥ then 25 comp = new component name 26 comps[comp] = {rt1} 27 compname[rt1] = comp 28 data: comps 29 forall comp ∈ comps do 30 forall rt ∈ comp do 31 interfaces = interfaces + externalelements[rt] 32 contracts = contracts + contractcatalogue[interfaces] 33 printcomponent(name, interfaces, contracts) 34 printhightlevelcontracts avocs 2018 10 / 17 eceasst we print its name, its list of interfaces and its contracts (line 33). we also collect all the interfaces and contracts of all the components (allcontracts and allinterfaces) and write the contract refinement at system level (line 34). after completion of alg.4.1, we get a file written in othello usable by ocra in order to perform the compositional verification of our graph of interlockings. another benefit of our algorithm is that it can split a large interlocking into smaller components. this means that we can perform the verification of a large interlocking though the verification of smaller components by applying the compositional verification. the splitting doesn’t happen for every interlocking but is more likely to happen on larger ones where the state space explosion problem is a major obstacle. an example of splitting is provided in our case study. 5 verification strategy and case study in this section, we briefly describe the generic complete verification process applied to the composition of interlocking components. we explain the results obtained after applying our algorithm to the station of ath on the belgium railway. 5.1 verification method the property verified in the framework of this paper is the ”no-collision” property. in order to verify a network of interlockings, we proceed in two steps. first we verify that no collision can happen at the interfaces between the components (i.e., interlockings or part of interlockings). this is illustrated by the i between c1 and c2 of figure 5.1. second we verify that no collision can happen inside each component c1 and c2. for the first step, we specify the ”no-collision” property by means of a contract: ”no train coming from c1 shall reach a position corresponding to the interface between c1 and c2 at the same time as a train coming from c2. this high level contract (i.e., system level) must be refined by component contracts at c1 and c2 level. the refinement is verified by means of ocra whereas the implementation is verified at the leaf level (i.e., implementation of each component in smv). each contract is taken from the catalogue defined in section 3 and automatically identified by our algorithm. second, in order to verify the ”no-collision” property inside each component, the smv interlocking modules are composed with two different instances of the same train module (e.g., c1‖ins11‖ins12 for c1). the train is also a smv module that is configured based on the topology of the station. when an origin signal of a route turns green (a.k.a.permissive aspect), the train starts in front of that signal and follows the topology of the railway by taking the points according to their commanded position. the train also actuates the track-circuits (a.k.a.track segments) which trigger the releasing of the route resources in a predefined sequence. the train module is extracted from the graffiti xml file that is a fork from the railml standard [rai15] developed by the belgian railways. this file holds the topology of the station as well as a description of all its resources (e.g., points, signals, . . . ). 11 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings c1 xx routes c2 yy routes i ii system train ins11 train ins12 train ins21 train ins22 figure 5.1: generic case of network of interlockings composed with train simulation. 5.2 case study application of the verification process our case study comes from a fairly large station of the belgian railway: the ath station. this station is controlled by three vixl: fty 7, fty 8, and fty 9 with respectively 48, 68, and 34 routes (fig 5.2). a vixl is a virtual interlocking running in a central interlocking (a.k.a.cixl). fty is the telegraphic identification of the station. fty_9 34 routes fty_7 48 routes fty_8 68 routes system 3 4 4 2 2 1 3 1 figure 5.2: ath station components breakdown structure according corresponding to the interlocking vixl structure. figure 5.3 shows the result of the splitting (decomposition) with our algorithm. fty 9 could not get decomposed further and remains one monolithic model. indeed the algorithm could not identify any interface defined in our catalogue. fty 8 was decomposed into five components (sub-interlocking modules): a, b, c, d, and e. however, we decide to keep two groups: a+b and c+d+e. this reduces the number of interfaces to be defined while allowing a substantial benefit in terms of the size of the models to be verified. the two sub-models are isolated from the original model of interlocking fty 8: one with 22 routes and a second one with 46 routes. finally fty 7 was split into two components. however, as the size of component fty 7b was not significant, the verification was achieved on the complete model. table 2 summarizes the performance of the two steps process of verification of our case study. the computer that we used was a hp elite i5-6200u 2.3ghz 4 processors 8gb running xubuntu 18.04. the verification of the refinement of the 12 contracts (e.g., lines 18-19 of list. 2) avocs 2018 12 / 17 eceasst fty_9 34 routes system 3 4 4 3 2 fty_8a 14 routes fty_8b 8 routes fty_8c 22 routes fty_8d 10 routes fty_8e 14 routes fty_8a+b fty_8c+d+e fty_7b 4 routes fty_7a 44 routes fty_7a+b figure 5.3: ath station components breakdown structure after refinement by the splitting algorithm. was performed in one run by ocra in a matter of seconds. the verification of the proper implementation of the contracts in the smv leaf components was achieved by nuxmv. the verification of the ”no-collision” property on the leaf components (step 2) was performed by four concurrent instances of nuxmv by means of the pdr/ic3 algorithm [bra11b, bra12, bra11a, sb11]. prior to the verification, we validated our model. first we seeded faults inside the application data and checked that the ”no-collision” property got violated. second we verify some liveness properties like: every route can be commanded and ran through by the train or each track-circuit can be occupied by a train. examples of traces can be provided on demand. table 2: duration of the verification process. steps verification duration 1.1 system contracts refinement 12 contracts 65.5 s 1.2 contracts implementation for fty 7a+b 5 contracts 24.6 s contracts implementation for fty 8a+b 8 contracts 79.2 s. contracts implementation for fty 8c+d+e 8 contracts 76.7 s. contracts implementation for fty 9 3 contracts 10.1 s. 2 no collision in fty 7a+b 42.85 h no collision in fty 8a+b 8.64 h no collision in fty 8c+d+e 37.61 h no collision in fty 9 36.21 h as can be seen from the result table, the verification of the leaf smv model is the hardest as it can take up to 43 hours to prove the ”no collision” property in the application data of an interlocking with 48 routes (fty 7 = 586 boolean variables). before splitting the interlocking fty 8, 13 / 17 volume 076 (2019) a framework for the formal verification of networks of railway interlockings we tried to verify the ”no collision” property on the monolithic model with nuxmv but it had not terminated after three (3) days. the decomposition with our algorithm allowed to performed its verification at the price of defining two components with their interfaces and contracts. as this process is automatic and quick (± 3 minutes) thanks to our algorithm and catalogue, we think that it’s a solution for the verification of fairly big stations. 6 conclusions medium and large stations are controlled by a network of interlockings due to the limitations of the current technology and due to some availability constraints. in this article, we have shown that the compositional verification is a perfect fit for the formal verification of such a network. this principle can be further used to split the interlocking entity thereby allowing to tackle the state space explosion problem. our contribution is twofold. first we proposed an algorithm that can automatically split an interlocking entity into smaller entities called components. second we proposed a catalogue containing an exhaustive list of interfaces/contacts allowing the compositional verification of all our graph of interlockings. this catalogue holds all the templates of the formal definitions needed to declare the interfaces and contracts binding the components. our algorithm thus produces the components, identifies the interfaces with other components, and infers the contracts ruling the interfaces. this output can then be directly used by the ocra tool to perform the compositional verification of the system (i.e., group of components/interlocking). in our case study, we demonstrated the benefits of the use of the algorithm on a realistic size station of the belgian railways controlled by three interlockings. we developed our two-steps process and showed that it allows to get the prove of the ”no-collision” property for the 150 routes station. references [a. 17] a. fantechi and a. e. haxthausen and m. b. r. nielsen. model checking geographically distributed interlocking systems using umc. in 2017 25th euromicro international conference on parallel, distributed and network-based processing (pdp). pp. 278–286. march 2017. doi:10.1109/pdp.2017.66 [bcl+15] s. busard, q. cappart, c. limbrée, c. pecheur, p. schaus. verification of railway interlocking systems. in proceedings 4th international workshop on engineering safety and security systems, esss 2015, oslo, norway, june 22, 2015. pp. 19–31. 2015. doi:10.4204/eptcs.184.2 http://dx.doi.org/10.4204/eptcs.184.2 [bp13] s. busard, c. pecheur. pynusmv: nusmv as a python library. in brat et al. (eds.), nasa formal methods 2013. lncs 7871, pp. 453–458. springer-verlag, 2013. avocs 2018 14 / 17 http://dx.doi.org/10.1109/pdp.2017.66 http://dx.doi.org/10.4204/eptcs.184.2 http://dx.doi.org/10.4204/eptcs.184.2 eceasst [bra11a] a. r. bradley. sat-based model checking without unrolling. in vmcai. lncs 6538, pp. 70–87. springer, 2011. [bra11b] a. bradley. sat-based model checking without unrolling. in jhala and schmidt (eds.), verification, model checking, and abstract interpretation. lecture notes in computer science 6538, pp. 70–87. springer berlin heidelberg, 2011. doi:10.1007/978-3-642-18275-4 7 http://dx.doi.org/10.1007/978-3-642-18275-4 7 [bra12] a. r. bradley. understanding ic3. in theory and applications of satisfiability testing – sat 2012. pp. 1–14. springer science + business media, 2012. doi:10.1007/978-3-642-31612-8 1 http://dx.doi.org/10.1007/978-3-642-31612-8 1 [cdt13] a. cimatti, m. dorigatti, s. tonetta. ocra: a tool for checking the refinement of temporal contracts. in 2013 28th ieee/acm international conference on automated software engineering (ase). institute of electrical & electronics engineers (ieee), nov 2013. doi:10.1109/ase.2013.6693137 http://dx.doi.org/10.1109/ase.2013.6693137 [cen02] cenelec. iec61508 functional safety of electrical/electronic/programmable electronic safety-related systems. 2002. [cim13] cimatti, alessandro and roveri, marco and susi, angelo and tonetta, stefano. validation of requirements for hybrid systems: a formal approach. acm trans. softw. eng. methodol. 21(4):22:1–22:34, feb. 2013. doi:10.1145/2377656.2377659 http://doi.acm.org/10.1145/2377656.2377659 [ct12] a. cimatti, s. tonetta. a property-based proof system for contract-based design. in 2012 38th euromicro conference on software engineering and advanced applications. institute of electrical & electronics engineers (ieee), sep 2012. doi:10.1109/seaa.2012.68 http://dx.doi.org/10.1109/seaa.2012.68 [ct15] a. cimatti, s. tonetta. contracts-refinement proof system for component-based embedded systems. science of computer programming 97:333–348, jan 2015. doi:10.1016/j.scico.2014.06.011 http://dx.doi.org/10.1016/j.scico.2014.06.011 [f. 13] f. m. spowart. ssi – solid state interlocking : basic guide. brochure, 2013. http://nremployee.yolasite.com/resources/ssi%20basic%20system%20notes% 20(pdf).pdf [ffm12] a. fantechi, w. fokkink, a. morzenti. some trends in formal methods applications to railway signaling. pp. 61–84. john wiley & sons, inc., 2012. 15 / 17 volume 076 (2019) http://dx.doi.org/10.1007/978-3-642-18275-4_7 http://dx.doi.org/10.1007/978-3-642-18275-4_7 http://dx.doi.org/10.1007/978-3-642-31612-8_1 http://dx.doi.org/10.1007/978-3-642-31612-8_1 http://dx.doi.org/10.1109/ase.2013.6693137 http://dx.doi.org/10.1109/ase.2013.6693137 http://dx.doi.org/10.1145/2377656.2377659 http://doi.acm.org/10.1145/2377656.2377659 http://dx.doi.org/10.1109/seaa.2012.68 http://dx.doi.org/10.1109/seaa.2012.68 http://dx.doi.org/10.1016/j.scico.2014.06.011 http://dx.doi.org/10.1016/j.scico.2014.06.011 http://nremployee.yolasite.com/resources/ssi%20basic%20system%20notes%20(pdf).pdf http://nremployee.yolasite.com/resources/ssi%20basic%20system%20notes%20(pdf).pdf a framework for the formal verification of networks of railway interlockings doi:10.1002/9781118459898.ch4 http://dx.doi.org/10.1002/9781118459898.ch4 [hhp14] l. v. hong, a. e. haxthausen, j. peleska. formal modeling and verification of interlocking systems featuring sequential release. in formal techniques for safetycritical systems third international workshop, ftscs 2014, luxembourg, november 6-7, 2014. revised selected papers. pp. 223–238. 2014. doi:10.1007/978-3-319-17581-2 15 https://doi.org/10.1007/978-3-319-17581-2 15 [hpp14] a. e. haxthausen, j. peleska, r. pinger. applied bounded model checking for interlocking system designs. in revised selected papers of the sefm 2013 collocated workshops on software engineering and formal methods volume 8368. pp. 205–220. springer-verlag new york, inc., new york, ny, usa, 2014. doi:10.1007/978-3-319-05032-4 16 http://dx.doi.org/10.1007/978-3-319-05032-4 16 [lim16] limbrée, christophe and cappart, quentin and pecheur, charles and tonetta, stefano. verification of railway interlocking-compositional approach with ocra. in international conference on reliability, safety and security of railway systems. pp. 134–149. 2016. [ocr18] ocra tool home page. may 2018. https://ocra.fbk.eu/ [rai15] the xml-interface for railway applications. march 2015. http://www.railml.org [rob14] roberto cavada and alessandro cimatti and michele dorigatti and alberto griggio and alessandro mariotti and andrea micheli and sergio mover and marco roveri and stefano tonetta. the nuxmv symbolic model checker. in computer aided verification 26th international conference, cav 2014, held as part of the vienna summer of logic, vsl 2014, vienna, austria, july 18-22, 2014. proceedings. pp. 334–342. 2014. doi:10.1007/978-3-319-08867-9 22 http://dx.doi.org/10.1007/978-3-319-08867-9 22 [sb11] f. somenzi, a. r. bradley. ic3: where monolithic and incremental meet. in proceedings of the international conference on formal methods in computer-aided design. fmcad ’11, pp. 3–8. fmcad inc, austin, tx, 2011. http://dl.acm.org/citation.cfm?id=2157654.2157657 [win01] k. winter. model checking abstract state machines. it, von der fakultat iv elektrotechnik und informatik der technischen universitat berlin, july 2001. [win12] k. winter. optimising ordering strategies for symbolic model checking of railway interlockings. in proceedings of the 5th international conference on leveraging applications of formal methods, verification and validation: applications and case studies avocs 2018 16 / 17 http://dx.doi.org/10.1002/9781118459898.ch4 http://dx.doi.org/10.1002/9781118459898.ch4 http://dx.doi.org/10.1007/978-3-319-17581-2_15 https://doi.org/10.1007/978-3-319-17581-2_15 http://dx.doi.org/10.1007/978-3-319-05032-4_16 http://dx.doi.org/10.1007/978-3-319-05032-4_16 https://ocra.fbk.eu/ http://www.railml.org http://dx.doi.org/10.1007/978-3-319-08867-9_22 http://dx.doi.org/10.1007/978-3-319-08867-9_22 http://dl.acm.org/citation.cfm?id=2157654.2157657 eceasst volume part ii. isola’12, pp. 246–260. springer-verlag, berlin, heidelberg, 2012. doi:10.1007/978-3-642-34032-1 24 http://dx.doi.org/10.1007/978-3-642-34032-1 24 17 / 17 volume 076 (2019) http://dx.doi.org/10.1007/978-3-642-34032-1_24 http://dx.doi.org/10.1007/978-3-642-34032-1_24 introduction interlocking system validation of interlocking formal verification of interlocking compositional verification of interlockings a justification for the compositional verification compositional verification catalogue of interfaces and contracts an algorithm to split the interlocking topology verification strategy and case study verification method case study application of the verification process conclusions controlling resource access in directed bigraphs electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) controlling resource access in directed bigraphs davide grohmann, marino miculan 21 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst controlling resource access in directed bigraphs davide grohmann1, marino miculan2 1 grohmann@dimi.uniud.it, 2 miculan@dimi.uniud.it department of mathematics and computer science, university of udine, italy abstract: we study directed bigraph with negative ports, a bigraphical framework for representing models for distributed, concurrent and ubiquitous computing. with respect to previous versions, we add the possibility that components may govern the access to resources, like (web) servers control requests from clients. this framework encompasses many common computational aspects, such as name or channel creation, references, client/server connections, localities, etc, still allowing to derive systematically labelled transition systems whose bisimilarities are congruences. as application examples, we analyse the encodings of client/server communications through firewalls, of (compositional) petri nets and of chemical reactions. keywords: bigraphs, reactive systems, (open) petri nets, graph-based approaches to service-oriented applications. 1 introduction bigraphical reactive systems (brss) are an emerging graphical framework proposed by milner and others [mil01, mil06] as a unifying theory of process models for distributed, concurrent and ubiquitous computing. a bigraphical reactive system consists of a category of bigraphs (usually generated over a given signature of controls) and a set of reaction rules. bigraphs can be seen as representations of the possible configurations of the system, and the reaction rules specify how these configuration can evolve, i.e., the reaction relation between bigraphs. often, bigraphs represent terms up-to structural congruence and reaction rules represent term rewrite rules. many process calculi have successfully represented as bigraphical reactive systems: λ -calculus [mil07], ccs [mil06], π -calculus [bs06, jm04], mobile ambients [jen08], homer [bh06], fusion [gm07b], petri nets [lm06], and context-aware systems [bde+06]. the advantage of using bigraphical reactive systems is that they provide general results for deriving a labelled transition system automatically from the reaction rules, via the so-called ipo construction. notably, the bisimulation on this transition system is always a congruence; thus, bigraphical reactive systems provide general tools for compositional reasoning about concurrent, distributed systems. bigraphs are the key structures supporting these results. a bigraph is a set of nodes (the controls), endowed with two independent structures, the place graph and the link graph (figure 1). the place graph is a tree over the nodes, representing the spatial arrangement (i.e., nesting) of the various components of the system. the link graph represents the communication connections, possibly traversing the place structure. a bigraph may be “not ground”, in the sense that it may have one or more “holes”, or sites (the gray boxes) to be instantiated; these holes are specific leaves of the place graph, where other bigraphs can be grafted, respecting the connection links. this notion of composition between bigraphs yields a categorical structure. 1 / 21 volume 10 (2008) mailto:grohmann@dimi.uniud.it mailto:miculan@dimi.uniud.it controlling resource access in directed bigraphs directed bigraph g : 〈3, ({r},{w, u})〉→〈2, ({x, z},{y})〉 0 v0 v1 v2 0 1 x y e0 w 1 v3 v4 2 e1 z ur place graph gp : 3 → 2 0 v0 v2 v1 1 0 1 v3 v4 2 directed link graph gl : ({r},{w, u}) → ({x, z},{y}) v0 v1 v2 x y e0 w v3 v4 e1 z ur figure 1: an example of directed bigraph, with negative ports. in milner’s “pure bigraphs” [mil06], connections are represented by hyper-arcs between nodes. this model has been successfully used to represent many calculi, such as ccs, and (with a small variant) λ -calculus, π -calculus. nevertheless, other calculi, such as fusion [pv98], seem to escape this framework. aiming to a more expressive framework, in previous work [gm07a, gm07b], we have introduced directed bigraphs. pure and directed bigraphs differ only on the link structure: in the directed variant, we distinguish “edges” from “connections”. intuitively, edges represent (delocalized) resources, or knowledge tokens, which can be accessed by controls. arcs are arrows from ports of controls to edges (possibly through names on the interfaces of bigraphs); moreover, in the version considered in the present paper, we allow arcs to point to other control’s ports (figure 1). outward ports on a control represent the capability of the control to access to (external) resources; insted, inward ports represent the capability of the control to “stop” or “govern” other node’s requests. the presence of both kinds of capabilities is common in distributed scenarios, such as client/server communications, firewalls, web services etc; for instance a system may ask to access to some data, but this attempt may be blocked, checked and possibly redirected by a guarding mechanism. moreover, controls with inward ports can represent localized resources, that is, resources with a position within the place hierarchy; this cannot be represented easily by edges, which do not appear in the place graph. notably, these extended bigraphs have relative pushout (rpo) and idem pushout (ipo) constructions, admit a notion of normal form, and a sound a complete axiomatization can be given. therefore, these bigraphs can be conveniently used for building wide reaction systems from which we can synthesize labelled transition systems, and whose bisimilarity is a congruence. due to lack of space, in this paper we can only skim over these theoretical results; we prefer to focus on some interesting applications of this framework. in section 2 we give the basic proc. gt-vmt 2008 2 / 21 eceasst definitions about directed bigraphs. general theoretical results (e.g., normal form, complete axiomatization, rpo construction, etc.) are presented in sections 3–5. then, section 6 is devoted to example applications. we apply this framework to the representation of distributed services and protocols (taking a three-tier architecture with a firewall as an example) and of chemical reactions. moreover, we consider the encoding of petri nets in greater detail; in particular, we show that the ipo bisimilarity is sound with respect to the η -bisimilarity of open petri nets. conclusions and direction for future work are in section 7. 2 directed bigraphs over polarized signatures in this section we introduce directed bigraphs, with inward (“negative”) ports on controls, extending [gm07a]. following previous developments about pure and directed bigraphs, we work in supported monoidal precategories; we refer to [jm04, §3] for an introduction. a polarized signature is a signature of controls, which may have two kind of ports: negative and positive. let k be a polarized signature; we denote with arn, ar p : k → n the arity functions of the negative and positive ports, respectively. thus, for k ∈ k , the arity function is ar(k) , (arn(k), ar p(k)). a control k is positive if it has only positive ports (i.e., arn(k) = 0); it is negative if it has only negative ports (i.e., ar p(k) = 0). definition 1 a polarized interface x is a pair of sets of names x = (x−, x +); the two components are called downward and upward interfaces, respectively. a directed link graph a : x → y is a = (v, e, ctrl, link) where x ,y are the inner and outer interfaces, v is the set of nodes, e is the set of edges, ctrl : v → k is the control map, and link : pnt(a)→lnk(a) is the link map, where ports, points and links of a are defined as follows: prt n(a), ∑ v∈v arn(ctrl(v)) prt p(a), ∑ v∈v ar p(ctrl(v)) prt(a),prt n(a)∪prt p(a) pnt(a) , x +]y−]prt p(a) lnk(a) , x−]y +]prt n(a)]e the link map cannot connect downward and upward names of the same interface, i.e., the following condition must hold: (link(x +)∩x−)∪(link(y−)∩y +) = /0; moreover the link map cannot connect positive and negative ports of the same node. directed link graphs are graphically depicted much like ordinary link graphs, with the difference that edges are explicit objects, and not hyper-arcs connecting points and names; points and names are associated to links (that is edges or negative ports) or other names by (simple, non hyper) directed arcs. an example are given in figure 1. this notation aims to make explicit the “resource request flow”: positive ports and names in the interfaces can be associated either to internal or to external resources. in the first case, positive ports and names are connected to an edge or a negative port; these names are “inward” because they offer to the context the access to an internal resource. in the second case, the positive ports and names are connected to an “outward” name, which is waiting to be plugged by the context into a resource. in the following, by “signature”, “interface” and “link graphs” we will intend “polarized signature”, “polarized interface” and “directed link graphs” respectively, unless otherwise noted. 3 / 21 volume 10 (2008) controlling resource access in directed bigraphs definition 2 the precategory of directed link graphs has polarized interfaces as objects, and directed link graphs as morphisms. given two directed link graphs ai = (vi, ei, ctrli, linki) : xi → xi+1 (i = 0, 1), the composition a1◦a0 : x0 → x2 is defined when the two link graphs have disjoint nodes and edges. in this case, a1 ◦a0 , (v, e, ctrl, link), where v ,v0 ]v1, ctrl , ctrl0 ]ctrl1, e , e0 ]e1 and link : x +0 ]x − 2 ]prt p(a0)]prt p(a1) → x−0 ]x + 2 ]e ]prt n(a0)]prt n(a1) is defined as follows: link(p) ,   link0(p) if p ∈ x +0 ]prt p(a0) and link0(p) ∈ x−0 ]e0 ]prt n(a0) link1(x) if p ∈ x +0 ]prt p(a0) and link0(p) = x ∈ x +1 link1(p) if p ∈ x−2 ]prt p(a1) and link1(p) ∈ x +2 ]e1 ]prt n(a1) link0(x) if p ∈ x−2 ]prt p(a1) and link1(p) = x ∈ x−1 . the identity link graph of x is idx , ( /0, /0, /0k , idx−∪idx + ) : x → x . it is easy to check that composition is associative, and that given a link graph a : x →y , the compositions a◦idx and idy ◦a are defined and equal to a. definition 1 forbids connections between names of the same interface in order to avoid undefined link maps after compositions. similarly, links between ports on the same node are forbidden, because these graphs cannot be obtained by composing an “unlinked” node and a context. it is easy to see that the precategory ′dlg is self-dual, that is ′dlg ∼= ′dlgop. the notions of openness, closeness, leanness, etc. defined in [gm07a] can be easily extended to the new framework, considering negative ports as a new kind of resources. moreover, the definition of tensor product can be derived extending to negative ports the one given in [gm07a]. finally, we can define the (extended) directed bigraphs as the composition of standard place graphs (see [jm04, §7] for definitions) and directed link graphs. definition 3 a directed bigraph with signature k is g = (v, e, ctrl, prnt, link) : i → j, where i =〈m, x〉 and j =〈n,y〉 are its inner and outer interfaces respectively. an interface is composed by a width (a finite ordinal) and by a pair of finite sets of names. v and e are the sets of nodes and edges respectively, and prnt, ctrl and link are the parent, control and link maps, such that gp , (v, ctrl, prnt) : m → n is a place graph and gl ,(v, e, ctrl, link) : x →y is a directed link graph. we denote g as combination of gp and gl by g = 〈gp, gl〉. in this notation, a place graph and a (directed) link graph can be put together iff they have the same sets of nodes. definition 4 the precategory ′dbig of directed bigraph with signature k has interfaces i = 〈m, x〉 as objects and directed bigraphs g = 〈gp, gl〉 : i → j as morphisms. if h : j → k is another directed bigraph with sets of nodes and edges disjoint from the respectively ones of g, then their composition is defined by composing their components, i.e.: h ◦g , 〈h p ◦gp, h l ◦gl〉 : i → k. the identity directed bigraph of i = 〈m, x〉 is 〈idm, idx〉 : i → i. proc. gt-vmt 2008 4 / 21 eceasst analogously, the tensor product of two bigraphs can be defined tensoring their components. it is easy to check that for every signature k , the precategory ′dbig is wide monoidal; the origin is ε = 〈0, ( /0, /0)〉 and the interface 〈n, x〉 has width n. hence, ′dbig can be used for applying the theory of wide reaction systems and wide transition systems as developed by jensen and milner; [jm04, §4, §5]. to this end, we need to show that ′dbig has rpos and ipos. since place graphs are as usual, it suffices to show that directed link graphs have rpos and ipos. theorem 1 if a pair ~a of link graphs has a bound ~d, there exists an rpo (~b, b) for ~a to ~d. as a consequence, ′dlg has ipos too. see section 4 for the direct construction for rpos in directed bigraphs with negative ports, extending the construction given in [gm07a]. actually, often we do not want to distinguish bigraphs differing only on the identity of nodes and edges. to this end, we introduce the category dbig of abstract directed bigraphs, which is constructed from ′dbig forgetting the identity of nodes and edges and any idle edge. more precisely, abstract bigraphs are bigraphs taken up-to an equivalence m (see [jm04] for details). definition 5 two concrete directed bigraphs g and h are lean-support equivalent, written g m h, if there exists an iso between their nodes and edges sets after removing any idle edges. the category dbig of abstract directed bigraphs has the same objects as ′dbig, and its arrows are lean-support equivalence classes of directed bigraphs. 3 algebra and axiomatization in this section, generalizing similar results for directed bigraphs, we describe the main classes of bigraphs and the elementary bigraphs which can generate all bigraphs according to a welldefined normal form. as main result we give a normalization theorem. we refer the reader to [gm08] for a detailed presentation of the notation used here. first, we introduce two distinct and complementary subclasses of bigraphs: wirings and discrete bigraphs, that are used in defining the normal form and the axiomatization. definition 6 a wiring is a bigraph whose interfaces have zero width (and hence has no nodes). the wirings ω are generated by the composition or tensor product of three elements: substitutions σ : ( /0, x +) → ( /0,y +), fusions δ : (y−, /0) → (x−, /0), and closures hnxy : ( /0, y) → (x, /0). definition 7 an interface is prime if its width is 1. often we abbreviate a prime interface 〈1, (x−, x +)〉 with 〈(x−, x +)〉, in particular 1 = 〈( /0, /0)〉. a prime bigraph p : 〈m, (y−,y +)〉→ 〈(x−, x +)〉 has a prime outer interface and the names in y +, x− are linked to negative ports of p. an important prime bigraph is mergem : m → 1, it has no nodes and maps m sites to one root. definition 8 a bigraph is discrete if it has no edges and every open link has exactly one point. the discreteness is well-behaved, and preserved by composition and tensor. it is easy to see that discrete bigraphs form a monoidal sub-precategory of ′dbig. 5 / 21 volume 10 (2008) controlling resource access in directed bigraphs y x hn x y : ( /0, y) → (x, /0) closure y x1 x2 . . . xn . . . myx : ( /0, x ) → ( /0, y) substitution x y1 y2 . . . ym . . . oyx : (x, /0) → (y, /0) fusion 1 : ε → 1 a barren root 0 1 merge : 2 → 1 joining 2 sites in 1 root 1 0 γ1,1 : 2 → 2 swapping 2 sites x−1 x − 2 . . . x−n x+1 x + 2 . . . x+m y +1 y + 2 . . . y +h y−1 y − 2 . . . y−h . . . . . . . . . . . . k(l) : 〈(~x−,~y +)〉→〈(~y−,~x+)〉 a discrete ion figure 2: elementary bigraphs over polarized signatures. definition 9 let k be any non atomic control with arity (k−, k+), let ~x−,~x+ be two sequences of distinct names, and let ~y +,~y− be two sequences of (possibly empty) sets of distinct names, such that: |~x−|+|~x+| = k+ and |~y−| = |~y +| = k−. for a k-node v, we define the discrete ion k(v, l) : 〈(~x−,~y +)〉→〈(~y−,~x+)〉 as the bigraph with exactly a node v and l is a pair of maps: an iso map l p : ~x−∪~x+ → prt p(v) describing the linking among positive ports and names in ~x− or ~x+, and another iso map ln : ~y−∪~y + → prt n(v) describing the linking among negative ports and sets of upward inner names (in ~y +) and sets of downward outer names (in ~y−). we omit v when it can be understood. for a prime discrete bigraph p with outer names in (z−, z+), we define a discrete molecule as: (k(l)⊗id(z−\~x−,z+\~y +))◦p. if k is atomic, we define the discrete atom, as an ion without the site k(l) : (~x−,~y +) →〈(~y−,~x+)〉. an arbitrary (non-discrete) ion, molecule or atom is formed by the composition of ω ⊗ id1 with a discrete one. often we omit . . .⊗idi in the compositions, when there is no ambiguity. figure 2 shows the algebraic signature, that is a set of elementary bigraphs which allow to define any other bigraph using solely composition and tensor product. before giving a formal result, we provide an intuitive explanation of the meaning of these elementary bigraphs. • the first three bigraphs build up all wirings, i.e. all link graphs having no nodes. all substitutions (fusions, resp.) can be obtained tensoring elementary substitutions myx (fusions o y x , resp.); the tensor products of singleton substitutions myx or singleton fusions oxy give all renamings. composition and tensor product of substitutions, fusions and closures give all wirings. • the next three bigraphs define all placings, i.e. all place graphs having no nodes; for example mergem : m → 1, merging m sites in a unique root, are defined as: merge0 , 1 mergem+1 , merge◦(id1 ⊗mergem). proc. gt-vmt 2008 6 / 21 eceasst notice that merge1 = id and merge2 = merge, and that all permutations π are constructed by composition and tensor product from the place symmetry γ1,1. • finally, for expressing any direct bigraph we need to introduce only the discrete ions k(l) : 〈(~x−,~y +)〉→〈(~y−,~x+)〉. in particular, we can express any discrete atoms as k(l)◦1. the following proposition shows that every bigraph can be expressed in a normal form, called discrete diagonal normal form (ddnf). we will use d, q and n to denote discrete, prime and discrete bigraphs, and discrete molecules respectively. theorem 2 1. a bigraph g on signature k can be expressed uniquely (up to iso) as: g = (ω ⊗idn)◦d◦(ω′⊗idm) (1) where d is a discrete bigraph and ω , ω′ are two wirings satisfying the following conditions: i. in ω , if two outer downward names are peer, then their target is an edge; ii. in ω′ there are no edges, and no two inner upward names are peer. 2. every discrete bigraph d : 〈n, z〉→〈m,w〉, may be factored uniquely (up to iso) on the width m in the following form: d = α⊗     (q0 ⊗χ out1,0⊗χ out 2,0 ⊗. . . )◦ (χ in0,1⊗ q1 ⊗χ out 2,1 ⊗. . . )◦ (χ in0,2⊗χ in 1,2⊗ q2 ⊗. . . )◦ . . . ( . . .⊗ qm−3 ⊗χ outm−2,m−3⊗χ out m−1,m−3)◦ ( . . .⊗χ inm−3,m−2⊗ qm−2 ⊗χ out m−1,m−2)◦ ( . . .⊗χ inm−3,m−1⊗χ in m−2,m−1⊗ qm−1)   ◦(π ⊗iddom(~q))   shortly: d = α ⊗(χ(q0, . . . , qm−1)◦(π ⊗iddom(~q))) (2) where α is a renaming, π is a permutation, each qi : 〈hi, (x−i , x + i )〉→〈(y − i ,y + i )〉 is prime and discrete, and χ outi,l (χ in i,l resp.) are the identities on the outer (inner resp.) names of qi at level l ∈{0, . . . , m−1}, which are not used by ql , . . . , qi−1 (qi+1, . . . , ql resp.). formally: χ out i,l , id〈(y−i \( ⊎i−1 j=l x − j ),y + i \( ⊎i−1 j=l x + j ))〉 for i > l χ in i,l , id〈hi,(x−i \( ⊎l j=i+1 y − j ),x + i \( ⊎l j=i+1 y + j ))〉 for i < l. 3. every prime and discrete q, may be factored uniquely (up to iso) in the following form: q = (mergen+p ⊗idcodom(~n))◦(idn ⊗χ(n0, . . . , np−1))◦(π ⊗iddom(~n)) (3) where χ is defined as in 2. 7 / 21 volume 10 (2008) controlling resource access in directed bigraphs 4. every discrete molecule n, may be factored uniquely (up to iso) in the following form: n = (k(l)⊗id(codom(q)\(~x−,~y +)))◦q. (4) furthermore, the expression is unique up to iso on the parts and reordering of ns in q. these equations can be used for normalizing any bigraph g as follows; first, we apply equations (1), (2) to g once, obtaining an expression containing prime discrete bigraphs q0, . . . , qm−1. these are decomposed further using equations (3), (4) repeatedly: each qi is decomposed into an expression containing molecules ni,0, . . . , ni,pi−1, each of which is decomposed in turn into an ion containing another prime discrete q′i, j. the last two steps are repeated recursively until the ions are atoms or have only holes as children. note that 1 is a special case of q when n = p = 0. notice that if the signature has only positive controls, then all the “qi layers” can be collapsed in a unique one, obtaining a normal form that is very similar to the milner’s dnf (see [mil06]). furthermore, a renaming is discrete but not prime (since it has zero width); this is why the factorization has such a factor. the uniqueness of that factorization depends on the fact that prime bigraphs have upward inner names and downward outer names linked to negative ports. in table 1 we give a set of axioms which we prove to be sound and complete. each of these equations holds only when both sides are defined; in particular, recall that the tensor product of two bigraphs is defined only if the name sets are disjoint. it is important to notice that for ions only the renaming axiom is needed (because names are treated positionally). theorem 3 let e0, e1 be two expressions constructed from the elementary bigraphs by composition and tensor product. then, e0 and e1 denote the same bigraph in dbig if and only if the equation e0 = e1 can be proved by the axioms in table 1. sharing products to conclude this section ,we define some variants of the tensor product, which allow the sharing of names. actually, these operators can be defined in terms of composition and tensor, but they turn out quite useful in the encoding of process calculi, where in the usual “parallel” p | q, processes p and q can share names. in directed bigraphs, this sharing can involve inner downward names and/or outer upward names, as described by the following definitions. definition 10 the outer sharing product ( ), inner sharing product (�) and sharing product (‖) of two objects x = (x−, x +),y = (y−,y +) and of two link graphs ai : xi →yi (i = 0, 1) are defined as follows: (x−, x +) (y−,y +) , (x−]y−, x +∪y +) (x−, x +)�(y−,y +) , (x−∪y−, x +]y +) a0 a1 , (v0 ]v1, e0 ]e1, ctrl0 ]ctrl1, link0 ]link1) : x0 ⊗x1 →y0 y1 a0 � a1 , (v0 ]v1, e0 ]e1, ctrl0 ]ctrl1, link0 ]link1) : x0 � x1 →y0 ⊗y1 a0 ‖ a1 , (v0 ]v1, e0 ]e1, ctrl0 ]ctrl1, link0 ]link1) : x0 � x1 →y0 y1 defined when interfaces are defined and ai have disjoint node and edge sets. proc. gt-vmt 2008 8 / 21 eceasst categorical axioms a◦id = a = id ◦a a◦(b◦c) = (a◦b)◦c a⊗idε = a = idε ⊗a a⊗(b⊗c) = (a⊗b)⊗c γi,ε = idi γj,i ◦γi,j = idi⊗j γi⊗j,k = (γi,k ⊗idj )◦(idi ⊗γj,k ) (a1 ⊗b1)◦(a0 ⊗b0) = (a1 ◦a0)⊗(b1 ◦b0) γi,k ◦(a⊗b) = (b⊗a)◦γh,j (where a : h → i, b : j → k) link axioms mxx = id( /0,x) o x x = id(x, /0) hn x y ◦m y z = hn x z o z x ◦hn x y = hn z y ox ◦hn x y ◦m y = idε mz(y]y)◦(id( /0,y )⊗m y x ) = m z (y]x ) (id(y, /0)⊗o x y )◦o (y]y) z = o (x]y ) z place axioms merge◦(1⊗id1) = id1 merge◦γ1,1 = merge merge◦(merge⊗id1) = merge◦(id1 ⊗merge) node axioms let k(l) : 〈(~x−,~y +)〉→〈(~y−,~x+)〉 (id1 ⊗α +⊗ζ−)◦k(l) = k(l′) with l′ = ((id~x−∪α +)◦l p, ((ζ−)op ∪id~y + )◦l n) k(l)◦(id1 ⊗α−⊗ζ +) = k(l′′) with l′′ = ((α−∪id~x+ )◦l p, (id~y−∪(ζ +)op)◦ln) where α + : ~x+ →~z+, α− : ~x− →~z− are renamings and ζ − : ~z− →~y−, ζ + : ~z+ →~y + are surjective fusions. table 1: axiomatization for the abstract directed bigraphs. the outer sharing product, inner sharing product and sharing product of two objects i = 〈m, x〉, j = 〈n,y〉 and of two bigraphs gi : ii → ji (i = 0, 1) are defined by extending the corresponding products on their link graphs with the tensor product on widths and place graphs: 〈m, x〉 〈n,y〉, 〈n + m, x y〉 〈m, x〉�〈n,y〉, 〈n + m, x �y〉 g0 g1 , 〈gp0 ⊗g p 1 , g l 0 g l 1〉 : i0 ⊗i1 → j0 j1 g0 � g1 , 〈gp0 ⊗g p 1 , g l 0 � g l 1〉 : i0 � i1 → j0 ⊗j1 g0 ‖ g1 , 〈gp0 ⊗g p 1 , g l 0 ‖ g l 1〉 : i0 � i1 → j0 j1. defined when interfaces are defined and gi have disjoint node and edge sets. it is simple to verify that , � and ‖ are associative, with unit ε . 9 / 21 volume 10 (2008) controlling resource access in directed bigraphs 4 construction of rpos we first give an idea of how the construction works. suppose d0 : x0 → z, d1 : x1 → z is a bound for a span a0 : w → x0, a1 : w → x1 and we wish to construct the rpo (b0 : x0 → x̂ , b1 : x1 → x̂ , b : x̂ → z). in the following we will denote a pair (a0, a1) by ~a and the link map of a simply by a. to form the pair ~b we truncate ~d by removing all the edges, nodes and ports not present in ~a. then in the outer interface of ~b, we create an outer name for each point unlinked by the truncation: the downward names connected to the same link (name, edge or negative port) must be “bound together”, i.e. we must consider all the possible ways to associate a downward name of a0 with one of a1 and vice versa; further we must equate an upward name of a0 with one of a1 if they are both connected to a point shared between a0 and a1. formally: construction 1 a relative pushout (~b : ~x → x̂ , b : x̂ → z), for a pair ~a : w →~x of link graphs relative to a bound ~d : ~x → z, will be built in three stages. since rpos are preserved by isomorphisms, we can assume the components of x0 and x1 disjoint. nodes and edges if vi are the nodes of ai (i = 0, 1), then the nodes of di are vdi = (vī \vi)]v2 for some v2. define the nodes of bi and b to be vbi ,vī \vi (i = 0, 1) and vb ,v2. edges ei and ports p p i , p n i of ai are treated analogously. interface construct the shared codomain x̂ = (x̂−, x̂ +) of ~b as follows: first we define the names in each xi = (x − i , x + i ), for i = 0, 1, that must be mapped into x̂ = (x̂ −, x̂ +): x′−i ,{x ∈ x − i | ∃y ∈ x − ī s.t. ai(x) = aī(y) or ai(x) ∈ (ei \eī)](p n i \p n ī )} x′+i ,{x ∈ x + i | di(x) ∈ (e2 ]p n 2 ]z +)}. let res ,w−](e0 ∩e1)](pn0 ∩p n 1 ). we define for each l ∈ res the set of names in x ′− i linked to l: x′−i (l) ,{x ∈ x ′− i | ai(x) = l} (i = 0, 1). now we must “bind together” names connected to the same link, so we create all the possible pairs between a name in x′−0 and a name in x ′− 1 . further we must add to x̂ − all the names in x′−i “not associable” to any name of x ′− ī . then the set of downward names of ~b is: x̂− , ⋃ l∈res x′−0 (l)×x ′− 1 (l)∪ ∑ i∈{0,1} ⋃ e∈(ei\eī)](pni \p n ī ) x′−i (e). next, on the disjoint sum x′+0 + x ′+ 1 , define ∼= to be the smallest equivalence for which (0, x0) ∼= (1, x1) iff there exists p ∈w + ](p p 0 ∩p p 1 ) such that a0(p) = x0 and a1(p) = x1. then define: x̂ + , (x′+0 + x ′+ 1 )/∼=. for each x ∈ x′+i we denote the equivalence class of (i, x) by î, x. proc. gt-vmt 2008 10 / 21 eceasst (w−,w +) (x−0 , x + 0 ) (x − 1 , x + 1 )(x̂ −, x̂ +) (ŷ−,ŷ +) (z−, z+) a0 a1 b0 b1 c0 c1 d0 d1 c b ĉ figure 3: construction of the unique arrow form the rpo to any other candidate. links define the link maps of bi as follows: for x ∈ x +i : bi(x) , { di(x) if x ∈ (x +i \x ′+ i ) î, x if x ∈ x′+i ; for p ∈ pp ī \ppi : bi(p) , { di(p) if aī(p) /∈ x + ī̂̄i, x if aī(p) = x ∈ x +ī ; for x̂ ∈ x̂− : bi(x̂) ,   x if x̂ = (x, y) and i = 0 y if x̂ = (x, y) and i = 1 x̂ if x̂ ∈ (x̂−∩x−i ) aī(x̂) if x̂ ∈ (x̂−∩x − ī ). finally we define the link map of b: for x̂ ∈ x̂ + : b(x̂) , di(x) where x̂ = î, x and x ∈ x +i ; for p ∈ pp2 ]z − : b(p) ,   di(p) if di(p) ∈ (e2 ]pn2 ]z +) dī(p) if di(p) ∈ (eī \ei)](pnī \p n i ) di(p) if dī(p) ∈ (ei \eī)](pni \p n ī ) (x, y) if d0(p) = x ∈ x−0 and d1(p) = y ∈ x − 1 . theorem 4 in ′dlg, whenever a pair ~a of link graphs has a bound ~d, there exists an rpo (~b, b) for ~a to ~d, and construction 1 yields such an rpo. proof. the proof is in two parts. first we have to check that (~b, b) is an rpo candidate; this is done by long and tedious calculations. next, for any other candidate (~c,c), we have to construct the unique arrow ĉ such that the diagram (in figure 3) commutes. this link graph ĉ can be 11 / 21 volume 10 (2008) controlling resource access in directed bigraphs constructed as follows: let be vc the nodes of c, for i = 0, 1 the set of nodes of ci is vci , (vī \vi)]v3, where v3 is such that v2 = v3 ]vc; edges eci and ports pci of ci are defined analogously. then ĉ has v3, e3 and p3 as sets of nodes, edges and ports respectively. its link map is defined as follows: for ĵ, x ∈ x̂ + : ĉ( ĵ, x) ,c j(x); for p ∈ pp3 ]ŷ − : ĉ(p) ,   ci(p) if ci(p) ∈ (e3 ]pn3 ]ŷ +) c0(p) if c0(p) ∈ (x̂−∩x−0 ) c1(p) if c1(p) ∈ (x̂−∩x−1 ) (x, y) if c0(p) = x ∈ x−0 and c1(p) = x ∈ x − 1 as an immediate consequence, since ′dlg is self-dual, we can calculate rpbs as well. as regards ipos, their existence is guaranteed by theorem 4. due to lack of space, we omit here a direct construction of ipos, which can be obtained by adapting the one presented in [gm07a] to the rpo construction given above. 5 directed bigraphical reactive and transition systems in this section we introduce reactive systems and transition systems over directed bigraphs over polarized signatures. for sake of simplicity, we will keep using the names directed bigraphical reactive systems and directed bigraphical transition systems respectively, as in [gm07b]. for the definitions about wide reactive systems over monoidal precategories, see [mil06]. definition 11 a ground reaction rule is a pair (r, r′), where r and r′ are ground with the same outer interface. given a set of ground rules, the reaction relation −→ over agents is the least, such that dr −→ dr′ for each active context d and each ground rule (r, r′). a parametric reaction rule has a redex r and reactum r′, and takes the form: (r : i → j, r′ : i → j) for any x and discrete d : i ⊗x , the parametric rule generates the ground rule: ((r⊗idx )◦d, (r′⊗idx )◦d). definition 12 a directed bigraphical reactive system (dbrs) over the polarized signature k , denoted by d(k , r) is the precategory ′dbig(k ) equipped with a set r of reaction rules. now we can prove the following important result: proposition 1 dbrss are wide reactive systems over a wide monoidal precategory this result ensures that dbrss inherit from the theory of wrss the definition of transition system based on ipos [mil06]. proc. gt-vmt 2008 12 / 21 eceasst definition 13 a transition for a dbrs d(k , r) is a quadruple (a, l, λ , a′), written as a l−→λ a′, where a and a′ are ground bigraphs and there exist a ground reaction rule (r, r′) ∈ r and an active context d such that la = dr, and λ = width(d)(width(cod(r))) and a′ l dr′. a transition is ipo if the (l, d) is an ipo for (a, r). definition 14 a directed bigraphical transition system (dbts) l for d is a pair (i , t ), where i is a set of interfaces; the agents of l are the ground bigraphs with outer interfaces in i ; t is a set of transitions whose sources and targets are agents of l . the full (ipo, resp.) transition system has all interfaces, with all (ipo, resp.) transitions. the following result follows from [mil06, theorem 4.6] and proposition 1 above. theorem 5 in any dbrs equipped with the ipo transition system, wide bisimilarity is a congruence. 6 applications 6.1 three-tier interaction with access control as mentioned before, directed bigraphs over polarized signatures allow to represent resource access control, by means of negative ports. this is particularly useful for representing access policies between systems, possibly in different locations; the edges can represent access tokens (or keys), which are global (although known possibly to only some controls). an example and quite common scenario is a client-server connection, where the access to the server is subject to authentication; after the request has been accepted, the server can route it to a back-end service (e.g., a dbms); see figure 4. the security policy is implemented by the firewall control, which allows a query to reach the server only if the client knows the correct key (rule auth). the server routes the query to the correct back-end service using rules like route; finally the backend service provides the data (rule get). an example computation is shown in figure 5. 6.2 compositional petri nets in this section we recall briefly what a petri net is and we give an encoding of these nets as directed bigraphs; to this end it is preferable to work with sorted links, as in [lm06]. notice that this encoding yields naturally a notion of composition between petri nets. definition 15 a place transition net (p/t net) is a 5-tuple (p, t, f, mi) (p∩t = /0), where: • p is the set of places; t is the set of transitions; • f is the multiset of arcs, linking places to transitions and vice versa: f , 〈(p×t )∪(t × p), f : (p×t )∪(t ×p) → n〉, with the constrain ∀t ∈ t. ∃p, q ∈ p. (p,t) ∈ f ∧(t, q) ∈ f ; • m : p → n is a marking, giving to each place a number of tokens, a place p is marked by m if m(p) > 0 and unmarked if m(p) = 0; mi is the initial marking. 13 / 21 volume 10 (2008) controlling resource access in directed bigraphs client query server firewall back-end service data x yk k′ . . . k′′ . . . auth x yk k′ . . . k′′ . . . z w route z w u get u figure 4: signatures and rules for three-tier architecture services through a firewall. u u u u figure 5: an example of client-server interaction through a firewall. we define •t ,{p | (p,t) ∈ f} to be the pre-multiset of the transition t, and t•,{p | (t, p) ∈ f} the post-multiset of the transition t. a transition t is enabled by a marking m if m marks every place in •t; a transition fires from a marking m to a marking m′, written m t→ m′, iff for all p ∈ p : m′(p) = m(p)−](•p) + ](p•), where ](•p) and ](p•) are the number of occurrences of p in •t, t•, respectively. notice that we allow multiple connections between a place and a transition, which is analogous to assign a weight to an arc representing the number of tokens to consume for firing the reaction. definition 16 let n = (p, t, f, m) and n′ = (p′, t ′, f′, m′) be two p/t nets, we say that n and n′ are isomorphic, if there exist two bijections α : p → p′ and β : t → t ′, such that: • (p,t) ∈ f iff (α(p), β (t)) ∈ f′; • (t, p) ∈ f iff (β (t), α(p)) ∈ f′; • m = m′◦α . we recall, as defined in [lm06], the definition of link sorting. proc. gt-vmt 2008 14 / 21 eceasst token x : i y : o x : i y : o i o placex,yx,y i i i ~x : i o o o ~y : o trans(|~x|,|~y|)~x,~y figure 6: signature for the encoding of compositional petri nets. definition 17 a link sorting is a triple σ = (θ, k , φ), where φ is a set of sorts, and k is a sorted signature (that is, a signature enriched with a sort to ports of each control). furthermore, each name in the interface (x−, x +) is given a sort, so the interfaces take the form ({x−1 : θ − 1 , . . . , x − n : θ − n },{x + 1 : θ + 1 , . . . , x + m : θ + m }). finally, φ is a rule on such enriched bigraphs, that is preserved by identities, composition and tensor product. we denote the precategory and category of, respectively, concrete and abstract σ-sorted directed bigraphs with ′dbig(σ) and dbig(σ). definition 18 a positive-negative sorting σ = (θ, k , φ) has sorts: θ = {θ1, . . . , θn}. the signature k assigns sorts to ports arbitrarily. the unique φ rule is: a point and a link (except of edges) can be connected if they are equally sorted. in order to define an encoding for compositional petri nets, we introduce a positive-negative sorting σpetri, having sort θpetri ,{i, o} and sorted signature: kpetri ,{token : (0, 0), place : ({1 : i, 1 : o}, 0), trans(h, k) : (0,{h : i, k : o})} where h, k > 0 where the controls token and trans are both atomic, while the control place is passive (i.e., no reactions can take place inside such a node). finally, the φ rule ensures that the linking is allowed only among ports having the same sort. an example of use of this sorted signature is shown in figure 6. the encoding function j·k is defined as follows: j(p, t, f, m)k = merge(|p|+|t|)◦ ( id|p|�op×{i,o}� ( � t∈t trans(|•t|, |t•|)(•t×{i}, t•×{o}) )) ◦( ∑ p∈p place(p,i), (p,o)(p,i), (p,o)◦(merge(|m(p)|+1)◦(m {(p,i), (p,o)}⊗( m(p) ∑ i=0 token)⊗1)) ) . (5) where, with an abuse of notation, trans(|•t|, |t•|)(•t×{i}, t•×{o}) means that if in the multisets there are some repetitions of places then the ports of trans are linked to the same downward inner name (i.e., (p, i) or (p, o)), an alternative definition is to link every port of trans to a different downward inner name and then (eventually) “equate” these names using fusions. proposition 2 let n, n′ be two p/t nets, n is isomorphic to n′ iff jnk = jn′k. we have a different reaction rule for any pair (h, k) associated to the control trans, in figure 7 we show the reaction rule for the pair (3, 2), that is a transition having 3 inputs and 2 outputs. 15 / 21 volume 10 (2008) controlling resource access in directed bigraphs x:i x:o y:i y:o z:i z:o w:iw:ou:i u:o x:i x:o y:i y:o z:i z:o w:iw:ou:i u:o figure 7: example of reaction rule in the case of 3 input and 2 output places. x:i x:o y:i y:o z:i z:o x:i x:o y:i y:o z:i z:o figure 8: example of reaction rule in the case of 2 input and 1 output places (with multiple arcs). moreover, we allow multiple connections between places and transitions, as in figure 8, and we can have transitions using some places as inputs and outputs, see figure 9. now we can show that the given translation is adequate. theorem 6 let (p, t, f, mi) be a p/t net, m t→ m′ iff j(p, t, f, m)k−→ j(p, t, f, m′)k. proof. (⇒) suppose m t→ m′, so m enable the transition t, then there exists a trans-node in j(p, t, f, m)k encoding the transition t, and the corresponding place-node of •t contain the necessary tokens to fire the transition (by translation of m), then we can apply the appropriate rule to perform the reaction reaching the configuration j(p, t, f, m′)k. (⇐) if j(p, t, f, m)k −→ j(p, t, f, m′)k, there exists a matching of a rule with a sub-bigraph of j(p, t, f, m)k, in particular the matched nodes have a counter part into the p/t net (p, t, f, m), so the marking m enables a transition t (corresponding to the trans-node), and then m t→ m′. in order to study the relation between the open petri nets, introduced in [bce+07], and our compositional petri nets, we need some definitions. definition 19 an open petri net is pair z = (nz , oz ), where nz is a p/t net and oz = (o+z , o − z )∈ 2p ×2p are the sets of input and output open places of the net. the notion of enabledness for transitions remains the same; besides the reactions produced by firing a transitions, we consider also the interactions with the environment, which are modelled by producing or removing a token in an open place p (denoted by +p and −p respectively). proc. gt-vmt 2008 16 / 21 eceasst x:i x:o x:i x:o figure 9: example of reaction rule in the case of 1 place used as input and output. the definition of the pre-multiset and post-multiset for the new events is the obvious one: •+p = /0, +•p = {p} and •−p = {p}, −•p = /0; moreover we can lift the firing of a transition to the new setting: m δ→ m′ iff ∀p ∈ p.m′(p) = m(p)−](•δ ) + ](δ•) (where δ ∈ t or δ = +p,−p). the encoding function for open petri nets is analogous to the previous one (5), the only difference is replacing op×{i,o} with o((p\o+)×{i})∪((p\o−)×{o}). this means “opening” the places in o, which is encoded by leaving an outer downward names linked to the i or o port of a place depending if it is an input or output open place. in this way, places can be accessed by the context. with an abuse of notation, we denote with j·k the new encoding function. now, we are ready to introduce a labelled transition system for open petri nets. definition 20 the firing lts associated to an open petri net z is the triple 〈m̄, λ, m̄,z〉, where the states are the markings m ∈ m̄, the set of label λ = {τ}∪{+p | p ∈ o+z }∪{−p | p ∈ o − z } and the transition relation m̄,z ⊆ m̄ ×λ×m̄ includes all transition m λ m̄,z m ′ iff m λ→ m′ and λ = +p,−p or there exists t ∈ t such that m t→ m′ and λ = τ . we shall often omit the transition relation subscripts when derivable from the context. the firing lts has the following associated bisimulation. definition 21 let z1, z2 be two open petri nets, and η : oz1 ↔ oz2 a correspondence between z1 and z2. a η -bisimulation between z1, z2 is a relation over markings r ⊆ m̄1 ×m̄2 such that if m1 r m2 then • if m1 l m′1, then there exists m ′ 2 such that m2 η(l) m′2 and m ′ 1 r m ′ 2; • the vice versa holds; where η(+p) = +η(p), η(−p) = −η(p) and η(τ) = τ . two open petri nets z1, z2 are η -bisimilar (denoted ∼η ) if η : o1 ↔ o2 is a correspondence and there exists a η -bisimulation r such that mz1 r mz2 , where mz1 , mz2 are the initial markings. z1, z2 are bisimilar (written ∼) if they are η -bisimilar for some η . in the rest of the section, when we compare η -bisimilarity and ipo bisimilarity, we consider η defined implicitly as follows. in order to study if two bigraphical agent are bisimilar, they must have the same outer interface; hence, the correspondence of places is defined by the downward 17 / 21 volume 10 (2008) controlling resource access in directed bigraphs x:i x:o y:o y:o plusx,y x:i x:o y:o y:o plusx,y y:iy:ox:o x:o minusx,y y:iy:ox:o x:o minusx,y figure 10: the labels representing the consuming or adding of tokens inside an open place. h e na e ce e e e oe e e e e e cle e e e e e e figure 11: example of atom encodings in directed link graphs. names in the outer interface. in other words, an open place p1 of z1 is in correspondence with an open place p2 of z2 iff in their encodings jz1k and jz2k, p1 and p2 are linked to the same names. in order to prove the soundness result, we need to identify the ipo labels representing the labels +p and −p of the firing lts. these labels are listed in figure 10, where denotes the identity over the downward names of the agent filling the context. the following results hold. lemma 1 given two open petri nets z1, z2, and let c[·] ∈{minusx,y ⊗ idjz1k, plusx,y ⊗ idjz1k} (where idjz1k = idjz2k), then c[jz1k] ∼ipo c[jz2k] iff jz1k∼ipo jz2k. theorem 7 the ipo bisimilarity is sound with respect to the firing bisimilarity. proof. we have to show that ∼ipo is a η -bisimulation. suppose jz1k∼ipo jz2k, and let mz1 λ m′z1 . we have to find a m ′ z2 such that mz2 λ m′z2 and jz ′ 1k∼ipo jz ′ 2k, where z ′ 1 and z ′ 2 are the encodings of z1 and z2 with the new markings. this can be proved by cases on λ . 6.3 chemical reactions a chemical reaction is a process describing the conversions of a chemical compositions. the chemical changes caused by a reaction always involve the motion of electrons in the forming or breaking of chemical bonds. for example, the octet rule says that atoms tend to gain, lose or share electrons so as to have eight electrons in their outer electron shell. in this section, we give an encoding of atoms into directed link graphs, as shown in figure 11, inspired by the well-known lewis structures. we describe the atoms as nodes, and those nodes have a number of positive ports equal to the number of valence electrons. each port is linked to an electron, represented as a node having a negative port (accepting incoming connections; for sake of simplicity we identify the node representing the electron with its port, that is, we proc. gt-vmt 2008 18 / 21 eceasst h e he 2h → h2 h e he h e o e e e e e e h e 2h + o → h2o h e o e e e e e e h e c e e e e c e e e e h e h e h e h e 4h + 2c → h4c2 c e e e e c e e e e h e h e h e h e figure 12: example of covalent bonds among atoms. do not force all incoming connections to be linked to a precise point of the node). moreover, some nodes can have extra ports, that are initially linked to edges, hydrogen and oxygen can be two examples, the idea is that such a configuration describes the aim of the atom to “capture” electrons to complete its external shell; e.g. an oxygen atom has two missing electrons, so it tries to share these two electrons with a pair of hydrogen atoms forming the water molecule. we apply this model describing the forming and breaking of bonds among atoms, here we deal with strong bonds, that is covalent and ionic bonds. some examples of covalent bonds are in figure 12. the first shows how two hydrogen atoms can share their electrons. the second one is well-know and describes how, in the generation of a water molecule, the oxygen shares one electron with each hydrogen; in this way it gets the two missing electrons in its external orbit, conversely each hydrogen atom completes its orbit sharing an electron with the oxygen. the latter describes a more complicate situation, where two carbon atoms (each needing four electron to complete its orbit) share two electron with the other carbon atom, and the total remaining four missing electrons are provided by two pairs of hydrogen. in figure 13, we show an example of ionic bond: given an atom of sodium and a chlorine one, it may happen (by octet rule) that the external electron of sodium is lost by the atom and “captured” by the chlorine, forming a sodium (positive) ion and a chlorine (negative) ion. these two ions attract each other by the electrostatic force caused by the electron exchange. finally the ions can be composed to form sodium-chloride molecule, that is the common salt. an interesting future work is representing weak bonds: hydrogen and van der waals bonds. 19 / 21 volume 10 (2008) controlling resource access in directed bigraphs na e cle e e e e e e na cle e e e e e e e na e cle e e e e e e na + cl → na+ + cl− → nacl figure 13: examples of ion bonds among atoms. 7 conclusions in this paper, we have considered directed bigraphs over polarized signatures, a bigraphical model for concurrent, distributed system with resources and controls. the main difference with previous versions of bigraphs is the capability of nodes (i.e., systems) to ask for resource access (via the “positive ports”) and to control other’s requests, providing access to own resources (via the negative ports). these bigraphs have rpo and ipo constructions, thus allowing to derive systematically labelled transition systems from reactive systems, as in [jm03, gm07b], such that the corresponding bisimilarities are always congruences. these directed bigraphs admit also a notion of normal form, and a complete axiomatization. we have exhibited the expressive power of this framework, by applying it some interesting cases: a three-tier interaction between client, server and back-end service through a firewall, the petri nets (for which the induced ipo bisimilarity is proved to be sound with respect to η bisimilarity of open petri nets), and chemical reactions. all these cases are faithfully encoded as directed bigraphs with polarized signatures (possibly with sorting). an interesting future work is to develop properly the treatment of web service interactions, extending the ideas shown in section 6.1. in particular, we would like to give a bigraphical semantics of some formal calculus for web services, such as scc or cc-pi [bbc+06, bm07]. another future development is to use this kind of bigraphs as a general framework for systems biology. some preliminary experiment about the representation of biochemical reactions, not shown in this paper due to lack of space, are promising: ions, electrons, chemical links can be represented as controls and arcs, and the place structure can be fruitfully used to represent nesting of chemical compounds. it would be interesting to encode in directed bigraphs some important formalism for systems biology, such as the κ -calculus [dl04]. along this line, also the possibility of adding quantitative aspects (i.e., reaction rates) sounds very promising. bibliography [bbc+06] m. boreale, r. bruni, l. caires, r. de nicola, i. lanese, m. loreti, f. martins, u. montanari, a. ravara, d. sangiorgi, v. vasconcelos, g. zavattaro. scc: a service centered calculus. in proc. ws-fm. lncs 4184, pp. 38–57. springer, 2006. [bce+07] p. baldan, a. corradini, h. ehrig, r. heckel, b. könig. bisimilarity and behaviourpreserving reconfigurations of open petri nets. in mossakowski et al. (eds.), proc. gt-vmt 2008 20 / 21 eceasst proc. calco. lecture notes in computer science 4624, pp. 126–142. 2007. [bde+06] l. birkedal, s. debois, e. elsborg, t. hildebrandt, h. niss. bigraphical models of context-aware systems. in proc. fossacs. lecture notes in computer science 3921, pp. 187–201. springer, 2006. [bh06] m. bundgaard, t. t. hildebrandt. bigraphical semantics of higher-order mobile embedded resources with local names. electr. notes theor. comput. sci. 154(2):7–29, 2006. [bm07] m. g. buscemi, u. montanari. cc-pi: a constraint-based language for specifying service level agreements. in proc. esop. lecture notes in computer science 4421, pp. 18–32. springer, 2007. [bs06] m. bundgaard, v. sassone. typed polyadic pi-calculus in bigraphs. in bossi and maher (eds.), proc. ppdp. pp. 1–12. acm, 2006. [dl04] v. danos, c. laneve. formal molecular biology. theor. compu. sci. 325, 2004. [gm07a] d. grohmann, m. miculan. directed bigraphs. in proc. xxiii mfps. electronic notes in theoretical computer science 173, pp. 121–137. elsevier, 2007. [gm07b] d. grohmann, m. miculan. reactive systems over directed bigraphs. in proc. concur 2007. lecture notes in computer science 4703, pp. 380–394. springer, 2007. [gm08] d. grohmann, m. miculan. an algebra for directed bigraphs. in mackie and plump (eds.), proceedings of termgraph 2007. electronic notes in theoretical computer science 203(1), pp. 49–63. elsevier, 2008. [jen08] o. h. jensen. mobile processes in bigraphs. phd thesis, university of aalborg, 2008. to appear. [jm03] o. h. jensen, r. milner. bigraphs and transitions. in proc. popl. pp. 38–49. 2003. [jm04] o. h. jensen, r. milner. bigraphs and mobile processes (revised). technical report ucam-cl-tr-580, computer laboratory, university of cambridge, 2004. [lm06] j. j. leifer, r. milner. transition systems, link graphs and petri nets. mathematical structures in computer science 16(6):989–1047, 2006. [mil01] r. milner. bigraphical reactive systems. in larsen and nielsen (eds.), proc. 12th concur. lecture notes in computer science 2154, pp. 16–35. springer, 2001. [mil06] r. milner. pure bigraphs: structure and dynamics. information and computation 204(1):60–122, 2006. [mil07] r. milner. local bigraphs and confluence: two conjectures. in proc. express 2006. electronic notes in theoretical computer science 175(3), pp. 65–73. 2007. [pv98] j. parrow, b. victor. the fusion calculus: expressiveness and symmetry in mobile processes. in proceedings of lics ’98. pp. 176–185. 1998. 21 / 21 volume 10 (2008) introduction directed bigraphs over polarized signatures algebra and axiomatization construction of rpos directed bigraphical reactive and transition systems applications three-tier interaction with access control compositional petri nets chemical reactions conclusions how accurate is coarse-grained clone detection?: comparision with fine-grained detectors electronic communications of the easst volume 63 (2014) proceedings of the eighth international workshop on software clones (iwsc 2014) how accurate is coarse-grained clone detection?: comparision with fine-grained detectors keisuke hotta, jiachen yang, yoshiki higo, and shinji kusumoto 18 pages guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst how accurate is coarse-grained clone detection?: comparision with fine-grained detectors keisuke hotta1, jiachen yang2, yoshiki higo3, and shinji kusumoto4 1 k-hotta@ist.osaka-u.ac.jp, 2 jc-yang@ist.osaka-u.ac.jp 3 higo@ist.osaka-u.ac.jp, 4 kusumoto@ist.osaka-u.ac.jp graduate school of information science and technology osaka university, japan abstract: research on clone detection has been quite successful over the past two decades, which produced a number of state-of-the-art clone detectors. however, it has been still challenging to detect clones, even with such successful detectors, across multiple projects or on thousands of revisions of code in limited time. a simple and coarse-grained detector will be an alternative of detectors using finegrained analysis. it will drastically reduce time required for detection although it may miss some of clones that fine-grained detectors can detect. hence, it should be adequate for a tentative analysis of clones if it has an acceptable accuracy. however, it is not clear how accurate such a coarse-grained approach is. this paper evaluates the accuracy of a coarse-grained clone detector compared with some fine-grained clone detectors. our experiment provides an empirical evidence about acceptable accuracy of such a coarse-grained approach. thus, we conclude that coarse-grained detection is adequate to make a summary of clone analysis and to be a starter of detailed analysis including manual inspections and bug detection. keywords: clone detection, software evolution, mining software repositories 1 introdution code clone, also called duplicated code, is known as a typical bad smell for software development and maintenance [fbb+99]. they recieve a considerable amount of attention from developers [ym13], which may be because code cloning is quite easy to do and almost unavoidable [kbln04]. such a background encourages researchers to develop a variety of techniques to cope with clone-related problems [kos08, zr12, kos06]. clone detection is one of the hottest topics in this research area since it plays a fundamental role for managing clones. research on clone detection has been quite successful because of great effort that many researchers have spent. as a result, a variety of clone detectors have been developed and used [rbs13, rc07, bak95, bylb98, kki02, mlm96, drd99, hjhc10, rc08, jmsg07]. nowadays, the success of clone detection research has let clone detection go well beyond a single state of code in a single project. it opened its own application area beyond both project and historical borders. more concretely, it has been applied not only in intra-project but also in inter-project, and it has been used to analyze clone evolution. 1 / 18 volume 63 (2014) mailto:k-hotta@ist.osaka-u.ac.jp mailto:jc-yang@ist.osaka-u.ac.jp mailto:higo@ist.osaka-u.ac.jp mailto:kusumoto@ist.osaka-u.ac.jp how accurate is coarse-grained clone detection? inter-project clone detection opens our eyes to find reusable code, and to detect plagiarism and license violations [kos13]. historical analysis of clones has provided a number of useful findings [ksnm05, gk11, kri08, hshk10, lw08, hg12, jdhw09] because historical data has rich information that the current states of projects do not have [hmk12, kmm+10]. however, these research areas suffer the following issues. time required for detection: although state-of-the-art detectors have been successful to detect clones in single projects, clone detection across multiple projects or on multiple revisions requires a huge amount of time. a huge number of clones: state-of-the-art detectors tend to report a number of clones even from a single state of code in a single software system. if we apply them to inter-project detection or historical analysis, the number of detected clones will become much larger. this may make it difficult to analyze the results in a limited time period. it should be an alternative of using state-of-the-art detectors to use simple and coarse-grained clone detectors [hhk13]. herein, “coarse-grained clone detection” means “clone detection on coarser units of code”. in this paper we suppose that finer unit of code means sequence of tokens, statements, or lines, and coarser units of code include blocks, methods, functions, classes, and files. in our defenition, fine-grianed detectors can find clones composed of a part of syntactic block, but coarse-grained detectors cannot find them. the main objective of this paper is to reveal the performance and the accuracy of such a coarse-grained detection. we have implemented a simple block-based detector and use it in our investigation. the most advantageous point of the coarse-grained approach should be in its performance. that is, it will drastically reduce time required for clone detection because it requires a fewer number of comparisons of code units. hence, it should be suitable for analyzing inter-project cloning or clone evolution. therefore, we investigate the performance of the coarse-grained detection as our first research question. rq1: is the coarse-grained detector much faster than fine-grained ones? in addition to that, coarse-grained detectors will report a fewer number of clones than finegrained ones. therefore, they may make it possible to analyze the results in limited time. hence, we are interested in the number of detected clones in the second research question. rq2: does the coarse-grained detector report a fewer number of clones? note that this research question considers only the number of detected clones. in other words, this research question is not interested in the correctness of detected clones. hence, it is unclear how many correct clones are detected and missed by the coarse-grained detector. the remaining research questions focus on the accuracy of the coarse-grained detector. the next research question is interested in the accuracy of the detection. we think the coarsegrained detection has high precision. this is because if there exists a pair of code fragments that is regarded as a clone pair with such a coarse-grained technique, the pair also will be regarded as a clone pair with a fine-grained approach. on the other hand, it might have low recall compared to fine-grained detectors. this is because it will report a fewer number of clones than fine-grained techniques on the same target software systems. this means that the coarse-grained approach misses some clones that fine-grained techniques can detect. proc. iwsc 2014 2 / 18 eceasst rq3: does the coarse-grained detector have high precision? rq4: does the coarse-grained detector have high recall? our experiment confirmed high scalability of the coarse-grained detection on multiple projects and multiple revisions compared with fine-grained ones. it also showed that the coarse-grained detector reported fewer numbers of clones than fine-grained detectors. in addition, the coarsegrained detector achieved high precision compared to other detectors. on the other hand, it had lower recall than other detectors, but it was not so low. based on these findings, we conclude that using such a coarse-grained clone detector as a starter of clone analysis should be an effective way to analyze across multipe projects or multiple revisions. for instance, suppose that we are about to analyze clones among thousands of projects, which requires a vast amount of time to be analyzed with fine-grained detectors. in this case, we can apply a coarse-grained detector to get an overview of clones in the dataset even though there exists a tight limit of time. with the coarse-grained detector, you may find that there are a number of clones in a particular pair of projects. however, we have to note that the coarsegrained detector has a little lower recall compared to fine-grained ones. hence, it is not sufficient using only coarse-grained detectors because it should miss some clones. therefore, we suggest a two-staged analysis using both of fine-grained and coarse-grained detectors. that is, at the first stage we use a coarse-grained detector to get a summary of clones and narrow down the analysis target with the results. after the first stage, we use a fine-grained detector to conduct more detailed analysis with the narrowed target. such a two-staged analysis should be effective for a huge dataset with limited time. the remainder of this paper is organized as follows. at first, we discuss related work in section 2. section 3 describes the coarse-grained detector used in this study. section 4 gives how to conduct the experiment, and section 5 shows the experimental results. section 6 discusses threats to validity of this research, and the final section, section 7, concludes this paper. 2 related work 2.1 clone detection across multiple projects koschke developed a technique to detect inter-system clones with a suffix-tree-based approach [kos13]. his technique is interested in clones between a subject system and a set of other systems. he achieved high scalability with some heuristics, including to generate suffix trees for either the subject system or the set of other systems, and to use a filter based on hashing. ossher et al. proposed a technique to detect file-level clones [osl11]. through an empirical study on a dataset that includes over 13,000 projects [lbjp], they revealed that approximately 10% of files were clones. furthermore, they found that file-level cloning tends to occur in cases of reusing whole of existing projects as a template of a new project. a similar work was conducted by sasaki et al. [syhi10]. they developed a tool named fcfinder to detect file-level clones. they applied fcfinder to freebsd ports collection, and they reported that 68% of files were file clones. 3 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? ishihara et al. proposed a technique to detect method-level clones for locating library candidates [ihh+12]. they conducted an empirical study on the dataset used in ossher et al.’s study, and their technique found approximately 2,900,000 cloned methods within four hours. keivanloo et al. conducted a set of empirical studies toward building real-time clone search system [krc11]. they adopted multi level hashing to detect clones in their study. although they were interested in clone search, they also reported the performance of their light weight clone detection approach on a code base that includes 1,500,000 java classes. the empirical study revealed that their approach could detect approximately 11 billion clone pairs in 21 minutes. keivanloo et al. proposed a framework to improve scalability of existing detectors for large datasets including multiple projects [krrc12]. their technique is compirising of shuffling, repetition, and random subset generation of the subject dataset. their approach is completely independent of detectors, and so it can be applied for any detectors without any modifications on them. the research was followed by a further experiment by svajlenko et al. on six existing clone detectors [skr13], and the experiment revealed the effectiveness of the framework. 2.2 analysis of clone evolution the pioneers of studies on clone evolution are kim and her colleagues [ksnm05]. they formulated clone genealogies and conducted an empirical study on clone genealogies. the empirical study revealed that most of clones were short-lived. göde and koschke investigated how many times clones were changed during their evolution [gk11]. they showed that most of clones were changed at most once, and changes on them did not cause severe problems in most cases. there exists some other studies to analyze evolution of clones, which includes analyzing evolution of type-1 clones [g0̈9], analyzing evolution of near-miss clones [baz12, srs11], and analyzing stability or changeability of clones [kri08, hshk10, lw08, hg12]. the results did not agree with each other, and so the research community still has a room for discussion about harmfulness of clones. it can be said that, however, there are both harmful clones and harmless ones. hence, managing clones is no longer considered a “hunt-and-kill” game [wg12] and we thus have to carefully select the clones to be managed to avoid unnecessary effort managing clones with no risk potential [gk11]. 2.3 comparison between clone detectors one of the benchmarks on clone detectors is the one conducted by bellon and his colleagues [bka+07]. it is quite difficult to make a correct set of clones due to the vagueness of definition of clones. hence, they made their correct set through a manual inspection. they collected clones with six detectors on eight open source projects, and looked them through to judge whether they should be really regarded as clones. the vast amount of collected clones made it impossible to investigate all of them, and so they randomly selected clones to be judged. roy et al. provided another benchmark from a different standpoint [rck09]. that is, they compared clone detectors with four distinct senarios on copy/paste/modify operations. their benchmark showed which tools are adequate for each senario. roy and cordy also provided another benchmark for evaluating clone detectors empirically proc. iwsc 2014 4 / 18 eceasst [rc09]. the key idea of their study is using mutation. their technique generates and injects mutants of code fragments, and evaluates detectors with them. a similar work to our study was conducted by ducasse et al. [dnr06]. they implemented a clone detector using simple string matching, which can be applied to a number of different languages including cobol, java, or c++. they confirmed that the inexpensive detector achieved high recall and acceptable precision. a major difference between their work and this study is in the granularity of clone detection. their work used a simple string matching to reduce time required for detection, which is a fine-grained detection technique. on the other hand, this study is interested in coarse-grained technique. the simple string matching reduces the cost of each comparison between two elements, but coarse-grained detection, by contrast, reduces not only the cost of each comparison but also the number of comparisons of elements. hence, coarsegrained technique will be faster than simple fine-grained ones, but it may miss some clones that finer techniques can detect. the objective of this research is to empirically reveal that. 3 coarse-grained clone detection this section describes the coarse-grained detector used in this study. it detects block-level clones from the given source files. it explains how to detect clones in a set of source files, followed by the description of incremental detection. 3.1 clone detection on a set of source files input and output the detector takes a set of source files as its input, and reports a list of clone pairs among them. currently, it targets only java because of the limitations of the implementation. procedure the detection procedure consists of the following four steps. • step1: parse given source files to detect blocks. • step2: normalize every detected block. • step3: calculate a hash value from each block. • step4: group the blocks based on their hash values. figure 1 shows an overview of the procedure. the followings describe each step in detail. step1: detect blocks the first step is to detect all the blocks from the given source files. herein, blocks include classes, methods, and block statements such as if or for statements. this step requires not only lexical analysis but also syntax analysis. our implementation uses java development tool (jdt) to perform the syntax analysis. 5 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? public class c1 { public int method(int x) { if (x <= 0) { return 0; } int result = 1; for (int i = 1; i <= x; i++) { result = result * i; } return result; } } public class c2 { public int anothermethod(int x) { int y = 1; for (int i = 1; i <= x; i++) { y = y * i; } return y; } } step1 & step2 public class c1 { public int method(int $) { if ($ <= $) { return $; } int $ = $; for (int $ = $; $ <= $; $++) { $ = $ * $; } return $; } } public class c2 { public int anothermethod(int $) { int $ = $; for (int $ = $; $ <= $; $++) { $ = $ * $; } return $; } } b1 b5 b2 b3 b4 b6 b7 hash value block 10 b1 20 b2 30 b3 40 b4, b7 50 b5 60 b6 step3 & step4 b4 & b7 compose a clone pair figure 1: overview of the detection procedure step2: nomalize blocks the next step is normalization for every block detected in the previous step. at first, it reformats every block with a regularized form. this procedure allows the detector to ignore differences of white-spaces or tabs. in addition to that, it replaces each variable name and each literal with a special token, which allows the detector to find type-2 clones. hence, the detector can find both of type-1 and type-2 clones, but cannot find type-3 clones. step3: calculate hash values the third step calculates hash values from texts of respective blocks. our implementation uses hashcode() of java.lang.string as the hash function. any other hash functions, however, can be used instead if they can generate a numerical value from a given string. step4: group blocks the final step is grouping blocks based on their hash values. two blocks have the same hash value if their text representations after normalized are equal to each other. hence, a block pair is regarded as a clone pair if the two blocks have the same hash value. the detector groups all the detected blocks and reports all the clone pairs. 3.2 incremental detection in addition to the function of clone detection for a single state of code, the detector has a function for detecting clones incrementally. the detector takes a subversion repository as its input for performing incremental clone detection, and reports clone pairs in every revision. the detector is motivated by the idea of the implementation from the literature [hhk13]. that is, it analyzes only files that were modified in a target commit. in other words, it reuses the results of analysis on the past commits of the target commit. suppose that the detector is about to analyze a commit cr, which is a commit between the revisions r−1 and r. the commit cr modified a source file fk, and the revision r has n source proc. iwsc 2014 6 / 18 eceasst files ( f1 ... fn). in this case, the detector has already finished analyzing all the commits before cr. hence, all the analysis results for files f1 ... fn except for fk can be used for analyzing cr because these files did not changed in cr. therefore, the detector newly performs step1, step2, and step3 only for fk, and it performs step4 on all the blocks in files f1 ... fn. 4 experimental setup 4.1 terms this study uses the benchmark of bellon and his colleagues [bka+07], which is a well-used benchmark in the research community. hereafter, this paper uses the following terms. reference: a reference is a clone pair that was judged as correct by bellon and his colleagues. candidate: a candidate is a clone pair that was reported by a clone detector. this study uses a metric named ok-value to judge whether a candidate matches a reference. this metric was defined and used in the original study of bellon et al.. before defining ok-value, we give the definition of contained(cf 1,cf 2) for a given code fragments cf 1 and cf 2 as follows. contained(cf 1,cf 2) = |lines(cf 1)∩lines(cf 2)| |lines(cf 1)| (1) where, lines(cf) indicates the set of all the lines of code in the code fragment cf . now we can define ok-value for a given pair of clone pairs cp1 and cp2. ok(cp1,cp2) = min(max(contained(cp1.cf 1,cp2.cf 1), (2) contained(cp2.cf 1,cp1.cf 1)), max(contained(cp1.cf 2,cp2.cf 2), contained(cp2.cf 2,cp1.cf 1))) where, cp.cf 1 and cp.cf 2 are the two code fragments of which the clone pair cp consists. it is regarded that a detector could detect a reference cr if it reported a candidate cc that satisfies the following condition. ok(cr,cc) >= threshold (3) this study uses 0.7 as the threshold, which is the same value used in the original work. furthermore, this paper uses the following metrics to evaluate the accuracy of detected clones for a given target software system p and a given detector t . precision(p,t) = |detectedrefs(p,t )| |cands(p,t )| (4) recall(p,t) = |detectedrefs(p,t )| |refs(p)| (5) where, 7 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? • detectedrefs(p,t ) refers to a set of references in p that were detected with t . • cands(p,t ) refers to a set of candidates that t reported from p. • refs(p) refers to the set of all the references in p, which is independent of detectors. we have to note that there exists another metric used in the original benchmark of bellon and his colleagues, which is named good value. good value is a stronger criterion than ok value. ok value becomes high in the case that a clone reference(candidate) subsumes a clone candidate(reference) sufficiently. on the other hand, good value becomes high in the case that a clone reference(candidate) sufficiently match a clone candidate(reference). in other words, good value becomes not high in the case that ok value becomes high if a large clone reference(candidate) subsumes a small clone candidate(reference). the reason why we have chosen the looser metric is that we suppose that the main use of the coarse-grained detection is to roughly analyze code clones on a huge data set. hence, we think that good metric is too strict for the purpose. 4.2 target software systems the expriment for rq2, rq3, and rq4 targets software systems used in bellon et al.’s work because there does not exist bellon et al.’s correct sets of clones on any other software systems. in addition, it omits c projects from the target due to the limitation of our implementation. therefore, there are four target systems for the expriment, which are shown in table 1. the experiment for rq1 needs another set of targets. this is because the main usage of such a coarse-grained detector should be reducing time required for detection. hence, it should be reasonable to use a corpus of many projects and historical repositories to answer rq1. the experiment uses a dataset called uci dataset [osl11, lbjp]. the dataset has approximately 13,000 java projects, which should be enough large for fine-grained detectors not to complete their tasks. more statistics are shown in table 21. 1 we ignored branches, tags, test cases, and not parsable files, which results different values from ones in [osl11, ihh+12] table 1: target software systems (for rq2, rq3, and rq4) name shortened loc # of references eclipse-ant ant 34,744 30 eclipse-jdtcore jdtcore 147,634 1,345 j2sdk1.4.0-javax-swing swing 204,037 777 netbeans-javadoc netbeans 14,360 55 table 2: overview of uci dataset # of .java files 2,092,739 # of projects 13,193 total loc of .java files 373,500,402 proc. iwsc 2014 8 / 18 eceasst the experiment also uses the historical code repository of dnsjava. we selected this repository because it has been used in some empirical studies on clone evolution and it has a reasonable length of histories. table 3 tells some statistics of the repository. 4.3 detectors used for the comparison our experiment uses seven detectors shown in table 4 as comparison targets. we chose four of them, dup, clonedr, ccfinder, and duploc, because they were used in the original work of bellon et al. and they can handle java. we omitted clan from the list of attendees in this experiment becanse it detects clones based on function metrics, which is categorized a coarsegrained detector in our definition. we add other two detectors, deckard and cdsw, that were developed recently because the four detectors used in the original work were developed over a decade ago. the other one, which is refered as ld (lightweight detector), was developed by ourselves based on the paper of hummel et al. [hjhc10]. it aims to detect clones in a short time period with lightweight analysis. the technique creates and uses indexes on n-grams of source lines, which gives it high scalability. although it uses a lightweight analysis, it is more fine-grained than the coarse-grained detector. hence, we think that coarse-grained analysis will be faster than it, but it is still unclear. this is a motivation that we use the detector in the experiment. in addition to that, it has a function of incremental clone detection. incremental clone detection is one of the way to cope with the issue of time required for clone detection on multiple revisions of code [gk09]. hence, this detector has high scalability for detecting clones on multiple revisions. this is the other reason that we use this detector as our target. table 3: overview of the repository of dnsjava the revision number of the latest revision 1,670 # of commits where at least one .java file was modified 1,432 # of files in the latest revision 7,362 total loc of .java files in the latest revision 1,237,336 table 4: detectors used as comparison targets tool taxonomy dup [bak95] token clonedr [bylb98] ast ccfinder [kki02] token duploc [drd99] text deckard [jmsg07] ast cdsw [mhh+13] other(statement) ld (based on [hjhc10]) text 9 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? 5 results this section provides the results of our experiment. it answers the four research questions, and gives a summary of the results. note that we reused the results of bellon et al.’s experiment of dup, clonedr, ccfinder, clan, and duploc, and so we did not run the five detectors on our own platform. 5.1 rq1: is the coarse-grained detector much faster than fine-grained ones? the answer is yes. we applied the coarse-grained detector and ld to uci dataset and the repository of dnsjava to compare the performance of the coarse-grained approach with fine-grained one. note that both of the two detectors can perform incremental clone detection and parallelized execution. each detector ran on an hp workstation z820 with two intel 64bit 2.4ghz cpus and 128gb ram. the workstation has an ssd that contains the whole of uci dataset and a copy of the repository of dnsjava. each detector used 32 threads to perform parallelized execution. table 5 shows the result of the comparison. coarse-grained in the table refers the coarsegrained detector described above, which detects clones in the block-level. note that ld could not finish its task on uci dataset within 24 hours, so we aborted it. as the table shows, the coarse-grained detector was faster than fine-grained one. we also applied ccfinder on the latest revision of the repository of dnsjava just for reference. the target has approximately 7,000 files with 1.2 million loc as shown in table 3. as a result, ccfinder took 42 minutes for the target. therefore, it should not be realistic to apply it on the whole of uci dataset or all the revisions of dnsjava due to the massive amount of time required for the detection. to summarize the comparison of performance of the two detectors, although ld completed its task in hours, the results show the high scalability of the coarse-grained technique. 5.2 rq2: does the coarse-grained detector report a fewer number of clones? the answer is yes. table 6 shows the number of detected clone pairs with each detector on each target. note that duploc could not finish its task on swing, and so the corresponding column is filled with n/a. as shown in the table, the coarse-grained detector reported fewer numbers of clones in most cases, except for the comparison with clonedr and cdsw. although the coarse-grained detector did not report the fewest number of clones, we can say that it found fewer numbers of clones. table 5: time elapsed for detection ld coarse-grained uci dataset (multiple projects) n/a 152 [m] dnsjava (multiple revisions) 212 [m] 17 [m] proc. iwsc 2014 10 / 18 eceasst 0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% ant netbeans swing netbeans dup clonedr ccfinder duploc deckard cdsw ld coarse-grained figure 2: the results of comparision (precision) 0.0% 20.0% 40.0% 60.0% 80.0% 100.0% ant jdtcore swing netbeans dup clonedr ccfinder duploc deckard cdsw ld coarse-grained figure 3: the results of comparison (recall) 5.3 rq3: does the coarse-grained detector have high precision? the answer is yes. figure 2 shows the results of comparison of precision. each bar in the graph indicates the value of precision with a detector on a target project. the bars are sorted in the descending order of the value of precision for each of the target projects. the black bar indicates the coarse-grained detector. the graph tells us that the coarse-grained detector achieved the highest precision in the case of jdt-core. in the other cases, it have the second highest precision. therefore, we conclude that the coarse-grained detector achieved high precision compared with others. table 6: the number of detected clone pairs tool ant jdtcore swing netbeans dup 245 11,589 7,220 344 clonedr 42 3,593 3,766 33 ccfinder 950 26,049 21,421 5,552 duploc 162 710 n/a 223 deckard 319 22,353 25,415 414 cdsw 222 5,247 1,703 1,344 ld 662 44,294 19,253 1,360 coarse-grained 70 5,398 3,922 57 11 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? 0 0.05 0.1 0.15 0.2 0.25 ant jdtcore swing netbeans dup clonedr ccfinder duploc deckard cdsw ld coarse-grained figure 4: the results of comparision (f-measure) 5.4 rq4: does the coarse-grained detector have high recall? the answer is no. figure 3 shows the values of recall. this graph has the same fashion of the graph shown in figure 2 except for the difference of represented values. we can see that the coarse-grained detector could not achieve the highest recall in all the targets. hence, we conclude that the coarse-grained detector cannot achieve high recall. however, please note that the coarse-grained detector did not have the lowest recall in all the cases. therefore, it could detect a ceartain amount of, not so few, clones. 5.5 summary of the results our experimental result confirmed the high scalability of a coarse-grained technique on interproject and multi-revision clone detection. furthremore, it showed that the coarse-grained detection technique achieved high precision with fewer numbers of clones detected, but it could not achieve high recall. in general, the values of precision and recall are in trade-off. the clone detector that have high recall tend to have low precision and vice verse. to evaluate the total accuracy, we compared the values of f-measure, which is the harmonic average of precision and recall. a high f-measure means that the values of precision and recall are highly balanced. the formal definition of fmeasure is shown below. f−measure(p,t ) = 2∗precision(p,t )∗recall(p,t ) precision(p,t )+ recall(p,t ) (6) figure 4 shows the values of f-measure in the similar fashion of figures 2 and 3. this graph shows that the coarse-grained detector achieved the highest f-measure on two out of four target projects. this result indicates that it has highly balanced precision and recall, and it is no longer a poor detector. based on the findings, we recommend it as a choice to use such a coarse-grained detection to get an overview of clones. it has been claimed that a large software system has a considerable number of clones, and it is difficult and not effective to look through all of them. therefore, we think that using such a coarse-grained technique at first must be helpful to analyze clones effectively. after that, it is necessary to use fine-grained state-of-the-art detectors to get more detailed information of clones. this is because the coarse-grained approach tends to have less recall than fine-grained ones. using a fine-grained detector will cover the disadvantage of the proc. iwsc 2014 12 / 18 eceasst coarse-grained one because it can retrieve clones that the coarse-grained one misses. we will need to narrow down our investigation target due to limitations of resources to use a fine-grained detector. in this case, a coarse-grained technique will help us narrow down the investigation target. 6 threats to validity configurations of detectors this study used a particular configuration for each detector, but the configurations have not small effect on the results of detection. there exists an automated way to find a adequate configuration for a given situation with the search based approach [whjk13]. if we search a better configuration for each detector with such a technique, the results might be different from this study. different core paradigms of detectors this study compared the accuracy of a coarse-grained clone detector with other detectors. however, the detectors adopt different core paradigms and heuristics. hence, such differences except for granularity might affect the results of comparison. it is impossible, however, to compare the detectors with the same paradigm because the detection granularity plays an important role on the paradigm of clone detection. hash collision we are threaten by the possibility of hash collision as long as we use hash values for comparing two elements of code. for the ease of implementation, we adopted a simple hash function provided by java standard libraries. however, keivanloo et al. revealed that the 32-bit hash function is enough strong with an experiment on a huge data set [krc11]. we used the same hash function that was used in the experiment conducted by keivanloo et al., and so we believe that the hash function is enough strong in this experiment. target software systems the limitation of our implementation enfourced us to target only java projects. hence, it is necessary to conduct more experiments on other programming languages to generalize our findings. references of clones as long as we used the benchmark of bellon et al., we suffered from threats to validity of their study. that is, the references were built on only a part of collected clones. hence, it is possible that a clone pair that did not match to any references is actually a correct clone. this threat especially affects precision. the benchmark might inadequately shows low values of precision because of this limitation. however, the randomness of judged clones should reduce the bias of this threat. 13 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? in addition, we have to mention that the references were built from the results of 6 detectors used in bellon et al.’s benchmark. the results of any other detectors used in this study, including the ones developed by ourselves for this study, were not considered for building the references. for fairer comparision, it is necessary to rebuild the clone references with considering all the results of all the clone detectors attending the competition. a fairer way of compaison will be sampling each detector’s output and making judgements whether they are true clones. however, we are afraid that we make judgements that are better for coarse-grained detectors. hence, we decide to use bellon et al.’s benchmark. types of clones the two detectors that we have implemented for this study do not consider the types of clones. however, the references judged by bellon et al. have been labeled with their types. hence, some other findings may be produced if we take into account types of clones. in addtision, most of clone detectors are not very good at detecting type-3 clones. therefore, it has been still unclear whether the coarse-grained approach is useful in the case that type-3 clones are taken into account. however, it is difficult for the simple and coarse-grained approach to detect type-3 clones. nicad, which is one of the well-used clone detectors in the research community, can detect type-3 clones at the block level. the granurality of detection of nicad is the block level as well as the coarse-grained detector that is used in this study. however, nicad compares token sequences created from each block with the algorithm to detect longest common subseqneuces. in other words, it requires a fine-grained analysis to detect type-3 clones. from this aspect, as well as the issue of low recall, it is not sufficient to use only coarse-grained clone detectors for detail analysis. the issue of type-3 clones can be resolved by using type-3 clone detector in the second stage of clone analysis. 7 conclusion this paper evaluated the accuracy of coarse-grained clone detection compared to other finegrained clone detectors. we implemented a simple coarse-grained clone detector, and we compared precision and recall of the detection results of it with bellon et al.’s benchmark. our experimental results showed that the coarse-grained detector achieved high precision compared to other seven detectors, with the number of detected clones reduced. they also showed that it could not achieve high recall. however, although such a coarse-grained detector missed some of correct clones, our experimental results indicate that it is not a poor detector. in addition, we confirmed that the coarse-grained approach drastically reduced the time required to complete its clone detection. we adapted it to a corpus of over 13,000 java projects, and we confirmed that it completed the detection task on the dataset in 152 minutes. furthermore, we used it on multiple revisions, and confirmed that it completed the task in 17 minutes for over a thousand revisions. based on these findings, we conclude that such a coarse-grained detection is adequate as a first step of clone analysis. it can detect clones in a short time period and it reports fewer clones proc. iwsc 2014 14 / 18 eceasst than fine-grained detectors, which enables its users to analyze the results easily. however, it will miss some of clones, and so it is necessary to use other fine-grained detectors to perform more detailed analysis after the lightweight analysis. in such a case, the lightweight analysis helps us to narrow down the analysis target to achieve effective analysis of clones. acknowledgements: this study has been supported by grants-in-aid for scientific research (s) (25220003), grant-in-aid for exploratory research (24650011), grant-in-aid for jsps fellows (25-1382) from jsps, and grand-in-aid for young scientists (a) (24680002) from mext. bibliography [bak95] b. baker. on finding duplication and near-duplication in large software systems. in wcre’95. pp. 86–95. 1995. [baz12] s. bazrafshan. evolution of near-miss clones. in scam’12. pp. 74–83. 2012. [bka+07] s. bellon, r. koschke, g. antniol, j. krinke, e. merlo. comparison and evaluation of clone detection tools. ieee trans. on software engineering 31(10):804–818, oct. 2007. [bylb98] i. baxter, a. yahin, m. a. l. moura, l. bier. clone detection using abstract syntax trees. in icsm’98. pp. 368–377. 1998. [dnr06] s. ducasse, o. nierstrasz, m. rieger. on the effectiveness of clone detection by string matching. journal of software maintenance and evolution: research and practice 18(1):37–58, 2006. [drd99] s. ducasse, m. rieger, s. demeyer. a language independent approach for detecting duplicated code. in icsm’99. pp. 109–118. 1999. [fbb+99] m. fowler, k. beck, j. brant, w. opdyke, d. roberts. refactoring: improving the design of existing code. addison-wesley professional, 1999. [g0̈9] n. göde. evolution of type-1 clones. in scam’09. pp. 77–86. 2009. [gk09] n. göde, r. koschke. incremental clone detection. in csmr’09. pp. 219–228. 2009. [gk11] n. göde, r. koschke. frequency and risks of changes to clones. in icse’11. pp. 311–320. 2011. [hg12] j. harder, n. göde. cloned code: stable code. journal of software : evolution and process, mar. 2012. doi: 10.1002/smr.1551. [hhk13] y. higo, k. hotta, s. kusumoto. enhancement of crd-based clone tracking. in iwpse’13. pp. 28–37. 2013. 15 / 18 volume 63 (2014) how accurate is coarse-grained clone detection? [hjhc10] b. hummel, e. juergens, l. heinemann, m. conradt. index-based code clone detection: incremental, distributed, scalable. in icsm’10. pp. 1–9. 2010. [hmk12] h. hata, o. mizuno, t. kikuno. bug prediction based on fine-grained module histories. in icse’12. pp. 210–220. 2012. [hshk10] k. hotta, y. sano, y. higo, s. kusumoto. is duplicate code more frequently modified than non-duplicate code in software evolution?: an empirical study on open source software. in iwpse/evol’10. pp. 73–82. 2010. [ihh+12] t. ishihara, k. hotta, y. higo, h. igaki, s. kusumoto. inter-project functional clone detection toward building libraries an empirical study on 13,000 projects. in wcre’12. pp. 387–391. 2012. [jdhw09] e. juergens, f. deissenboeck, b. hummel, s. wagner. do code clones matter? in icse’09. pp. 485–495. 2009. [jmsg07] l. jiang, g. misherghi, z. su, s. glondu. deckard : scalable and accurate tree-based detection of code clones. in icse’07. 2007. [kbln04] m. kim, l. bergman, t. lau, d. notokin. an ethnographic study of copy and paste programming practices in oopl. in isese’04. pp. 83–92. 2004. [kki02] t. kamiya, s. kusumoto, k. inoue. ccfinder: a multi-linguistic token-based code clone detection system for large scale source code. ieee trans. on software engineering 28(7):654–670, july 2002. [kmm+10] y. kamei, s. matsumoto, a. monden, k. matsumoto, b. adams, a. e. hassan. revisiting common bug prediction findings using effort-aware models. in icsm’10. pp. 1–10. 2010. [kos06] r. koschke. survey of research on software clones. in duplication, redundancy, and similarity in software, dagstuhl seminar. 2006. [kos08] r. koschke. frontiers on software clone management. in icsm’08. pp. 119–128. 2008. [kos13] r. koschke. large-scale inter-system clone detection using suffix trees and hashing. journal of software: evolution and process, 2013. doi: 10.1002/smr.1592. [krc11] i. keivanloo, j. rilling, p. charland. internet-scale real-time code clone search via milti-level indexing. in wcre’11. pp. 23–27. 2011. [kri08] j. krinke. is cloned code more stable than non-cloned code? in scam’08. pp. 57–66. 2008. [krrc12] i. keivanloo, c. k. roy, j. rilling, p. charland. shuffling and randomization for scalable source code clone detection. in iwsc’12. pp. 82–83. 2012. proc. iwsc 2014 16 / 18 eceasst [ksnm05] m. kim, v. sazawal, d. notkin, g. c. murphy. an empirical study of code clone genealogies. in esec/fse’05. pp. 187–196. 2005. [lbjp] c. lopes, s. bajracharya, j.ossher, p.baldi. uci source code data sets. http:// www.ics.uci.edu/∼lopes/datasets/. [lw08] a. lozano, m. wermelinger. assessing the effect of clones on changeability. in icsm’08. pp. 227–236. 2008. [mhh+13] h. murakami, k. hotta, y. higo, h. igaki, s. kusumoto. gapped code clone detection with lightweight source code analysis. in proceedings of the 21st international conference on program comprehension (icpc 2013). pp. 93–102. may 2013. [mlm96] j. mayrand, c. leblanc, e. merlo. experiment on the automatic detection of function clones in a software system using metrics. in icsm’96. pp. 244–253. 1996. [osl11] j. ossher, h. sajnani, c. lopes. file cloning in open source java projects: the good, the bad, and the ugly. in icsm’11. pp. 283–292. 2011. [rbs13] d. rattan, r. bhatia, m. singh. software clone detection: a systematic review. information and software technology 55(7):1165–1199, july 2013. [rc07] c. k. roy, j. r. cordy. a survey on software clone detection research. school of computing technical report 2007-541, queen’s university 115, 2007. [rc08] c. k. roy, j. r. cordy. nicad: accurate detection of near-miss intentional clons using flexible pretty-printing and code normalization. in icpc’08. pp. 172–181. 2008. [rc09] c. k. roy, j. r. cordy. a mutation/injection-based automatic framework for evaluating clone detection tools. in mutation’09. pp. 157–166. 2009. [rck09] c. k. roy, j. r. cordy, r. koschke. comparison and evaluation of code clone detection techniques and tools: a qualitative approach. science of computer programming 74(7):470–495, may 2009. [skr13] j. svajlenko, i. keivanloo, c. k. roy. scaling classical clone detection tools for ultra-large datasets: an exploratory study. in iwsc’13. pp. 16–22. 2013. [srs11] r. k. saha, c. k. roy, k. a. schneider. an automatic framework for extracting and classifying near-miss clone genealogies. in icsm’11. pp. 293–302. 2011. [syhi10] y. sasaki, t. yamamoto, y. hayase, k. inoue. finding file clones in freebsd ports collection. in msr’10. pp. 102–105. 2010. [wg12] w. wang, m. w. godfrey. we have all of the clones, now what? toward integrating clone analysis into software quality assessment. in iwsc’12. pp. 88–89. 2012. 17 / 18 volume 63 (2014) http://www.ics.uci.edu/~lopes/datasets/ http://www.ics.uci.edu/~lopes/datasets/ how accurate is coarse-grained clone detection? [whjk13] t. wang, m. harman, y. jia, j. krinke. searching for better configurations: a rigorous approach to clone evaluation. in esec/fse’13. pp. 455–465. 2013. [ym13] a. yamashita, l. moonen. do developers care about code smells? an exploratory survey. in wcre’13. pp. 242–251. 2013. [zr12] m. f. zibran, c. k. roy. the road of software clone management: a survey. technical report, university of saskatchewan, 2012. proc. iwsc 2014 18 / 18 introdution related work clone detection across multiple projects analysis of clone evolution comparison between clone detectors coarse-grained clone detection clone detection on a set of source files incremental detection experimental setup terms target software systems detectors used for the comparison results rq1: is the coarse-grained detector much faster than fine-grained ones? rq2: does the coarse-grained detector report a fewer number of clones? rq3: does the coarse-grained detector have high precision? rq4: does the coarse-grained detector have high recall? summary of the results threats to validity conclusion microsoft word campus08 preface electronic communications of the easst volume 11 (2008) guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the first international discotec workshop on context-aware adaptation mechnaisms for pervasive and ubiquitous services (campus 2008) preface romain rouvoy, mauro caporuscio, michael wagner 3 pages eceasst 2 / 4 volume 11 (2008) preface there is a huge market potential for mobile applications in europe today. most people already carry a mobile device of some sort wherever they go, and an increasingly diverse set of devices (pdas, smart phones, gps, etc.) are becoming widely available. recently, serviceorientations (e.g., osgi) have evolved to address these highly dynamic environments. however, it is still technically difficult, using existing method and tool supports, to create such services-oriented applications. for example, the very large range of devices, types of infrastructure, ways in which it can change, situations in which users can find themselves, and the functions they want, introduce great complexity and pose considerable technical challenges. to overcome these difficulties, and promote the development and widespread deployment of innovative mobile applications, more and more projects are addressing the development of context-aware adaptation mechanisms for leveraging the development of mobile applications. these projects aims at providing simple but powerful integrated approaches to support the development of applications interacting in pervasive and ubiquitous environments. thus, the campus workshop will focus on the promising approaches in the domain of context aware adaptation mechanisms supporting the dynamic evolution of the execution context (e.g., network/device/service failures). this volume contains the proceedings of the first workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services, held in oslo, norway, june 3, 2008. the campus workshop is jointly organized by the music and plastic ist projects. it provides a forum for scientists and engineers in academia and industry to present and discuss their latest research. the focus of the conference is the design, implementation, deployment, and evaluation of adaptive platforms and architectures for context-aware environments. this year, we had 20 submissions from 11 different countries, among which the top 7 technical papers and 5 position papers were selected for inclusion in the technical program of the workshop. all papers were evaluated by at least three reviewers with respect to their originality, technical merit, presentation quality, and relevance to the workshop themes. the selected papers present the latest results and breakthroughs on middleware research in areas of automotive systems, ubiquitous environments, pervasive environments, ambient computing, multimedia computing. we would like to express our deepest appreciation to the authors of the submitted papers, to all program committee members for their diligence in the paper review and selection process, and to all external reviewers for their help in evaluating submissions. may, 2008 romain rouvoy mauro caporuscio michael wagner preface proc. campus 2008 3 / 4 organization steering committee frank eliassen university of oslo, norway kurt geihs university of kassel, germany svein hallsteinsen sintef ict, norway geir horn sintef ict, norway valérie issarny inria, france organizing committee program chair: romain rouvoy university of oslo, norway publicity chair: mauro caporuscio inria, france publication chair: michael wagner university of kassel, germany program committee luciano baresi politecnico di milano, italy gordon blair lancaster university, uk mauro caporuscio inria, france licia capra university college of london, uk denis conan intitut telecom, sudparis, france vittorio cortellessa uda, italy geoff coulson lancaster university, uk schahram dustdar vienna university of technology, austria frank eliassen university of oslo, norway kurt geihs university of kassel, germany svein hallsteinsen sintef ict, norway manuele kirsch pinheiro k.u.leuven, belgium joseph loyall bbn technologies, massachusetts per håkon meland sintef ict, norway hassine moungla inria, france nearchos paspallis university of cyprus, cyprus roland reichle university of kassel, germany romain rouvoy university of oslo, norway ulrich scholz european media laboratory gmbh, germany lionel seinturier university of lille 1, france roberto speicys-cardoso inria, france giovanni toffetti carughi usi, switzerland massimo tivoli uda, italy nalini venkatasubramanian university of california, irvine michael wagner university of kassel, germany referees vidhya balasubramanian university of california, irvine mikaël beauvois university of oslo, norway paul grace lancaster university, uk danny hughes lancaster university, uk daniel massaguer university of california, irvine eceasst 4 / 4 volume 11 (2008) contents integration of ontological scene representation and logic-based reasoning for context-aware driver assistance systems simone fuchs, stefan rass and kyandoghere kyamakya towards self-evolving context-aware services marco autili, paolo di benedetto, paola inverardi and damien andrew tamburri survey: agent-based middlewares for context awareness nabil sahli reactive context-aware programming stijn mostinckx, andoni carreton lombide and wolfgang de meuter share whatever you like sebastian boehm, johan koolwaaij and marko luther enhancing planning-based adaptation middleware with support for dependability: a case study romain rouvoy, roman vitenberg and frank eliassen divide and conquer organizing component-based adaptation ulrich scholz and romain rouvoy context-aware adaptation of mobile multimedia presentations diana weiss, johannes martens and stefan helas model-driven adaptation of ubiquitous applications carlos parra and laurence duchien feature interaction in pervasive computing systems yu liu and rene meier learning-based coordination of distributed component deployment yves vanrompay, yolande berbers and peter rigole "instantsocial" implementing a distributed mobile multi-user application with adaptation middleware luís fraga, svein hallsteinsen and ulrich scholz firewall-as-a-service for campus networks based on p4-sfc electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) firewall-as-a-service for campus networks based on p4-sfc marco häberle, benjamin steinert, michael menth 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst firewall-as-a-service for campus networks based on p4-sfc marco häberle1, benjamin steinert2, michael menth3 1marco.haeberle@uni-tuebingen.de 2benjamin.steinert@uni-tuebingen.de 3menth@uni-tuebingen.de university of tuebingen, chair of communication networks, tuebingen, germany * abstract: taking care of security is a crucial task for every operator of a campus network. one of the most fundamental security-related network functions that can be found in most networks for this purpose are stateful firewalls. however, deploying firewalls in large campus networks, e.g., at a university, can be challenging. hardware appliances that can cope with today’s high data rates at the border of a campus network are not cost-effective enough for most deployments. shifting the responsibility to run firewalls to single departments at a university is not feasible because the expertise to manage these devices is not available there. for this reason, we propose a cloud-like infrastructure based on service function chaining (sfc) and network function virtualization (nfv) that allows users to deploy network functions like firewalls at a central place while hiding most technical details from the users. keywords: service function chaining, software defined networking, firewall 1 introduction in recent years, network function virtualization (nfv) gained traction among internet service providers and operators of campus networks and data centers. nfv aims to reduce cost and improve flexibility by replacing hardware-based network functions with virtual equivalents, virtual network functions (vnf), that are run on commercial off-the-shelf servers. nfv is worked on actively by both academia and standardization bodies [ywl+18]. network traffic is often steered through vnfs with the help of service function chaining (sfc). the sfc architecture standardized by the ietf in rfc 7665 consists of classifiers, service functions, and service function forwarders. service functions are single network functions, e.g., firewall or nat appliances. these service functions may be vnfs. the classifier is the entry point to an sfc-enabled domain and assigns every packet to a service function path consisting of service functions that the packet needs to traverse. this path is encoded into the packet, e.g., by using the network service header or by pushing an mpls label stack. similar to nfv, sfc is worked on by academia and standardization bodies [bjse16]. in this work, we propose to use sfc and nfv to secure campus networks of universities in a flexible, yet simple to manage way. an easy-to-use self-service portal enables individual departments to define service function chains and configure service functions without the need ∗ this work was supported by the bwnet2020+ project which is funded by the ministry of science, research and the arts baden-württemberg (mwk). the authors alone are responsible for the content of this paper. 1 / 4 volume 080 (2021) mailto:marco.haeberle@uni-tuebingen.de mailto:benjamin.steinert@uni-tuebingen.de mailto:menth@uni-tuebingen.de firewall-as-a-service for campus networks based on p4-sfc to operate expensive and hard to configure network appliances. instead, service functions are deployed as nfvs in a local sfc cloud that is run in a central data center in the campus network. a prototype of the self-service portal and the sfc infrastructure is available at github1. in the following section, we give an overview of the local sfc cloud. in section 3, we describe the self-service portal. in section 4, we conclude our work. 2 local sfc cloud in the following, we give an overview of the setup of the local sfc cloud and explain how it can be integrated in an existing campus network with minimal changes. 2.1 sfc cloud infrastructure the infrastructure is largely based on p4-sfc [shhm20]. service function chaining is realized using mpls segment routing similar to [cxf+20]. the components are shown in figure 1(a). ingress switch orchestrator forwarder vnf 11 ... vnf 12 vnf 13 vnf 01 ... vnf 02 vnf 03 vnf 21 ... vnf 22 vnf 23 (a) sfc cloud components. campus network data center department internet sfc cloud (b) integration: routing campus network data center department internet sfc cloud (c) integration: tunnel figure 1: the setup of the sfc cloud and options to integrate it into a campus network. incoming traffic is classified by an ingress switch implemented in p4. classification is done according to the service function chain configured in the self-service portal. the classified traffic is then sent to the vnf hosts by service function forwarders. these forwarders may be any traditional off-the-shelf switches with support for mpls segment routing. several vnf hosts run the vnfs that have been configured in the self-service portal. the vnfs themselves are executed either in a dedicated lxc container or in a dedicated kvm virtual machine. the mpls router module of the linux kernel of the vms or containers serves as an sfc proxy for sfc-unaware vnf applications. a central orchestrator transforms the settings taken in the self-service portal into an appropriate network configuration and deploys the requested vnfs on the vnf hosts. hereby, mpls 1 https://github.com/uni-tue-kn/p4-sfc-faas netsys 2021 2 / 4 https://github.com/uni-tue-kn/p4-sfc-faas eceasst labels are assigned to the vnfs and the label stack for each service function chain is configured on the ingress switch for classification. 2.2 traffic classification in p4 p4 provides the ability to execute a single data plane definition on different software and hardware platforms. so far, p4-sfc supports the intel tofino switching asic and the software-based bmv2 switch for traffic classification. the intel tofino supports up to 64 100g ethernet ports, its successor up to 32 400g ethernet ports. on this platform, traffic classification happens in line speed. while this high performance is highly future-proof, a more cost-effective solution with less performance may be desirable for some use-cases. the bmv2 is an open-source software switch that provides an easy way to run p4 programs. however, it is not production-ready and is intended for development of p4 programs only. in a virtual machine with 8 virtual cpus and 15 gib of ram, it achieves a throughput of only around 1 gb/s when forwarding packets between two hosts [bmv]. 2.3 integration into campus networks the sfc cloud is deployed in a data center inside the campus network. depending on the structure of the campus network and the requirements of the departments that use the sfc cloud, several options exist to integrate it into existing infrastructure. the most straight forward option is to modify the routing of all traffic going to departments that use the sfc cloud. this option is shown in figure 1(b). while this results in minimal technical overhead, the administrative overhead may be cumbersome when deploying the system. alternatively, departments that want to use the sfc cloud may use the approach shown in figure 1(c). the traffic that enters and leaves the network of the department is tunneled to the sfc cloud. this approach needs modifications of the network configuration at the department only without modifying any other parts of the campus network. however, even lightweight tunneling protocols like gre have a protocol overhead that should not be ignored. as a consequence, this approach is suitable for departments with a low traffic volume only. 3 self-service portal the self-service portal is the central point to configure service function chains and vnfs. it features a user and permission model that allows to delegate responsibility for specific traffic classes, e.g., traffic to and from an individual department. defining traffic classes and template vnfs, as well as managing user rights is done by administrators of the sfc cloud system. users with delegated rights for specific traffic classes are able to define service function chains easily. a sample chain configuration is shown in figure 2(a). when configuring a service function chain, users can simply drag-and-drop vnfs from a vnf inventory. the vnf inventory contains vnfs that are predefined by administrators, as well as vnfs that have been configured by the user himself. for this purpose, the self-service portal provides configuration wizards for selected vnf types. an example, configuring a firewall vnf, is shown in figure 2(b). 3 / 4 volume 080 (2021) firewall-as-a-service for campus networks based on p4-sfc (a) sfc configuration with drag and drop. (b) configuration of firewall vnf. figure 2: self-service portal. 4 conclusion securing campus networks, e.g. at universities, becomes more and more difficult, complex, and expensive with increasing network traffic. service function chaining in combination with network function virtualization can help in solving these issues. in this work, we presented a cloud-like infrastructure that enables users in a campus network, e.g. single departments at a university, to deploy virtual network functions like firewalls at a central point in the network. a self-service portal enables users to easily configure these functions. references [bjse16] d. bhamare, r. jain, m. samaka, a. erbad. a survey on service function chaining. journal of network and computer applications 75:138 – 155, 2016. [bmv] performance of bmv2. https://github.com/p4lang/behavioral-model/blob/master/ docs/performance.md. accessed 26-10-2020. [cxf+20] f. clad, x. xu, c. filsfils, d. bernier, c. li, b. decraene, s. ma, c. yadlapalli, w. henderickx, s. salsano. service programming with segment routing. internetdraft draft-ietf-spring-sr-service-programming-03, internet engineering task force, sept. 2020. work in progress. [shhm20] a. stockmayer, s. hinselmann, m. häberle, m. menth. service function chaining based on segment routing using p4 and sr-iov (p4-sfc). in isc high performance international workshops. pp. 297–309. 2020. [ywl+18] b. yi, x. wang, k. li, s. k. das, m. huang. a comprehensive survey of network function virtualization. computer networks 133:212 – 262, 2018. netsys 2021 4 / 4 https://github.com/p4lang/behavioral-model/blob/master/docs/performance.md https://github.com/p4lang/behavioral-model/blob/master/docs/performance.md introduction local sfc cloud sfc cloud infrastructure traffic classification in p4 integration into campus networks self-service portal conclusion electronic communications of the easst volume 081 (2022) guest editors: sven jörges, anna-lena lamprecht, anila mjeda, stefan naujokat eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 9th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2021 (isola ds 2021) the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. stephen ryan 16 pages eceasst 2 / 16 volume 081 (2022) the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability stephen ryan university of limerick and confirm abstract: with reference to smart manufacturing and industry 4.0 in general, a digital thread connects the data and processes for smarter products, smarter production, and smarter integrated ecosystems. while the tangible goods (products and production lines) are understood as needing a digital twin as an executable model, i.e. an in-silico entity on which to virtually explore design, production, quality, and lifetime maintenance, the immaterial goods like software and analytics artefacts are not yet treated on par. for the new digital thread paradigm to enter the mainstream, models need to be coupled with ai, ml and data analytics capabilities, to provide an integrated platform for automatic transformations, generations, and analyses that take advantage of the formalized knowledge about the immaterial and material entities. the formalized knowledge needs to include a variety of models together with domain specific languages that use semantic types at their core. the objective of this overall work is to develop a high-level architecture for a serviceoriented domain specific language (dsl) platform for knowledge management (km-dsl) especially concerning sustainability and risk management. this paper will examine two strands of that work looking at business logic and understanding along with knowledge harvesting that concentrate on two case studies that will underpin future research to create the aforementioned dsl platform for knowledge management. keywords: business model canvas, requirements, sustainability, domain specific languages, knowledge platform. 1 introduction in the new digital age of smart manufacturing especially in the context of industry 4.0, there is a clear need for an effective description and formalisation of standards associated with the sustainable development goals (sdgs) (sdg nd) along with risk standards and risk integration into an organisations approach to business. understanding how it can be adapted into the organisations’ early planning stage is also extremely important. it is true that there are set frameworks for organisations in manufacturing to follow in terms of the sdgs and risk standards and theoretical guidance on how to implement them, but these standards are only frameworks and overview models and merely act as a guidance for the thinking and approach that is required. they also are very simplistic as these frameworks alone cannot guide the organisation to anticipate the developments of technology and society which are evolving at a rapid pace which the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 3 / 16 change the relevant sdgs and risk metrics that are important for the organisation to consider at a specific time. sdgs and risks that are relevant to an organisation at the beginning may differ once the firm has fully established as a business. the method purposed to alleviate these constraints is to adapt the current business model canvas (bmc) by integrating sdgs and risk into the planning process for businesses. our research examines the opportunities for organisations to have the capability of using this extended bmc that overlays blocks such as value propositions with sustainability goals and utilise these within a domain specific language (dsl) platform. this combined with an integrated risk system into the business organistaion can alter the status quo currently seen. the idea is to identify and understand the main attributes that are important in the dsl architecture for companies to integrate sdg goals and risks and monitor these goals and risks through the lifetime of the company. this research demonstrates how the business model canvas can be used to identify relevant sdgs and also showcases how a risk integrated model can be used effectively in organisations. this analysis allows us to establish the important aspects that are needed in creating such a platform for users to increase opportunities to implement sustainable thinking and risk understanding along with monitoring these aspects through the lifetime of the company. this can be considered a form of the circular economy for business practises which is becoming very prominent in all industries. since the bmc by osterwalder was published in 2010 (osterwalder and pigneur, 2010), it has supported companies with a strategic framework for brainstorming activities and thus has received increasing attention across the business sector. these activities have transformed how companies and organisations approach a new opportunity and guide the user to fulfil the project in a timely and coherent fashion by providing high level insights and strategies for management to consider. one of the fundamental drawbacks of the bmc is that if it is not fully understood by the participants, it can actually hinder rather than support business development. outlined by (casadesus-masanell and ricart, 2010), when a business model is fully understood it supports competitiveness and can align high level strategies with the goals of the organisation. a variety of key aspects can be contributed to a well organised bmc and these have been outlined by (chesbrough, 2010; osterwalder, 2004) as follows: 1. how key components, functions or parts are integrated to deliver value to the customers. 2. how those parts are interconnected within the organization and throughout its supply chain and stakeholder networks; and 3. how the organization generates value, or creates profit, through those interconnections. as the so-called 4th industrial revolution is changing the overall landscape of many industries, it is essential that the business model canvases continue to evolve in order to provide benefit to such companies and organisations. this key issue has been investigated and potentially solved by the creation of a framework named the global organization alignment & decision framework (gold) (steffen and boßelmann, 2018). this frameworks outlines “a multiperspective framework to support organizations in analysing their business context at multiple levels and discuss technological requirements as well as challenges for the development of modelling tools that support hierarchical integration of analyses and models as well as different eceasst 4 / 16 volume 081 (2022) perspectives to converge on an organization-wide aligned business strategy” (steffen and boßelmann, 2018). examining such a multilevel perspective approach in connection with a bmc provides businesses with the opportunity to enhance their current thinking in order to include other frameworks within their own approach to modelling their organisation. as regulations and fundamental corporate thinking are changing at a rapid pace, two key areas affected is sustainability and the ability to measure and examine risk. this can be quite evidently seen throughout the world by initiatives such as the 17 sustainable development goals (sdgs) and how they are being implemented by various states throughout the world (sdgs n.d.). it is important that businesses understand that debating whether to incorporate sustainability into their business strategy is no longer an option. this is clear especially when considering a valuedriven approach to developing business strategies which can be vital to the long-term success for that company (chladek, 2019). in order for this seamless integration to actually occur, we examine the high level architecture that would be needed for a tool-based support system for sustainability. this tool would guide and assist companies who begin their first steps in actually implementing some of the initiatives that have been outlined in the sdgs. we show that the sustainability prospective and framework that is currently stand alone can be integrated into a system that companies currently use, such as a bmc. our current hypothesis is that by providing assistance to small and medium size enterprises (smes) and helping them to understand and adapt to sustainable opportunities by providing a step by step guidance system may lead to the sdgs being implemented within those organisations at a faster rate. we choose smes because they can be the most exposed to sustainability considerations, both internally and externally by their customers, and at the same time the most likely to have difficulty in analysis and adoption as it is the case for most best practices within organisations (ifac 2013). our analysis and case study may suggest that making a guidance tool available to the organisations, ideally a tool which can be embedded in their current bmc, would provide precious assistance in adapting their organisation to become more sustainable. the same approach can be taken from a risk perspective. this can be seen from our previous paper where we examined how a new integrated tool support to allow for holistic and educated decision-making that is currently not available could be essential in future organisations where we showed its usefulness through a swot and risk analysis in manufacturing supply chains. (steffen et al 2021). this paper essentially examined of how tools enable the proposition of rulebased frameworks, guided processes, and the connection of interlinkages between several frameworks and process steps. this systematic support allows for transparency and explicit alignment, which in turn support educated decision-making. the effect is to accelerate the learning curve for the specific canvases of choice, and to enable their agile modifications even in uncertain environments. in the paper it was demonstrated how the shortcomings of today’s common single framework/single method analyses do not trigger the consideration of all the important known factors, and thus leave major blind spots. it is important to understand that two main areas of work are being examined which are expanding or creating new easy to follow frameworks for risk and sustainability and gaining an understanding of how a multi perspective approach and canvas based approach for implementing these new or altered frameworks is needed. currently it is a fair assumption to say that a companies or organisations are failing in actioning sustainability as there is no plan and the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 5 / 16 framework in place within the organisation (morfaw 2014). this is seen most frequently in sustainability projects and alignment where for example a business tackles one area of sustainability, often by introducing a recycling program, switching to led lights or installing solar panels and then consider themselves done and the objective ticked off. for the purpose of this paper, we will call such an approach the “one and done approach”. it is also important to underpin how this relates to the broader research at the confirm research centre (confirm) which can be observed in figure one below (margaria et al 2021). the integration and interoperability among all these entities is a key challenge for the success of industry 4.0 and this can be organised into three levels according to margaria et al (2021): 1) physical integration, handling the connectivity and communication among devices. 2) an application integration, dealing with the coordination and cooperation among different software applications and data stores. 3) business integration, covering the collaboration between different functions, processes and stakeholders. figure 1: confirm hub cps – the reprogrammable factory vision (margaria et al 2021) this paper and its research sit at the intersection of point three (business integration) and business logic. this is the first area that needs to be addressed in the overall supply chain environment seen in figure one. with this in mind and now working along the gold paradigm introduced by steffen and boßelmann (steffen and boßelmann 2018), we look at the interdisciplinary collaboration landscape in industry 4.0 as an instance of global organization eceasst 6 / 16 volume 081 (2022) alignment and decision making. this is the basis for our research in terms of a qualitative approach. examining the quantitative approach and in order for the above to become mainstream, a dsl high level architecture will need to be created and analysed so organisations can have a tool-based approach guidance system at their disposal. to change the culture seen in organisations and provide assistance to help them adapt to a more circular economy as figure one depicts will in theory prove difficult to achieve. we want to change this approach not only in sustainability frameworks but to all business activities so they can essentially integrate a circular economy approach to everything they do within the organisation. a dsl is an approach that could help this issue but first and foremost and understanding and investigation into how sustainability and risk is currently completed by organisations is essential. this information and research will be gathered through case studies and recent paper publications. once this is complete, we have an overall guidance approach to be implemented into a dsl knowledge platform for organisations to actually use. 2 case study – sustainability and risk – canvas based approach to a dsl two main areas are going to be examined in this case study approach. risk will be examined briefly with reference to a previous paper completed by us and sustainability in more detail from a canvas based approach. these case studies will be used as preliminary evidence of why a dsl platform is critical for all organisations to succeed in current industry 4.0 levels of practise and provide us with valuable information that will be used to create the high level view of the dsl. in regard to risk and the qualitative approach of the research outlined, we can see how a new and integrated tool support that allows for holistic and educated decision-making can be instrumental in the decision making process for a business (steffen et al 2021). this showcased a method of how to alleviate risk shortcomings by complementing the swot analysis for the purpose of managing and identifying risks continuously, which will be executed by utilizing a risk management system and approach within the canvas itself, which becomes a living tool which is constantly up to date and constantly consulted (steffen et al 2021). “the concrete workshop results showed that each additional step led to additional inputs and reflections, and thus stimulated the participants to engage with areas that they would not have considered if guidance had not been given” (steffen et al 2021). this was showcased through a canvas based approach and outlined how that approach will be able to mirror that in a dsl methodology. this will in the end reduce the need for expensive business consultants to conduct workshops or large organisations being brought in as they will have at hand an integrated tool support system that will do this automatically for them that follows a pre-defined framework which is very important. this same approach can be mirrored in the sustainability sector for companies, and we will outline in detail how this can be achieved by extending a previous research paper that was published in this area by the same author and outline how this can be mirrored in a dsl setting. previously examined in an imc paper and conference we have shown in a case study example that there was a clear need for an effective description and formalisation of standards associated with the sustainable development goals (sdgs) and the need for these to be adapted into the the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 7 / 16 organisations early planning stage (ryan and margaria 2021). it was shown how an in-depth analysis of the sdgs can easily be integrated into the companies’ planning operations by providing a step by step approach for this integration and how this integration can be utilised by using a tool based approach. our research also showcased how opportunities can be established in organisations by using such a bmc that overlayed blocks such as value propositions with sustainability goals and how these can be intertwined for business success. it also outlined how an in-depth analysis allows the user to establish effective opportunities to implement sustainable thinking right through the lifetime of the company. examining in more detail, we want to extend this research to showcase how this approach can be mirrored and used in a dsl setting in order to help organisations in sustainable thinking and actions and move away from the one and done approach previously mentioned. there are a variety of general frameworks available for sustainability, but none are comprehensive enough or provide any fundamental guidance for implementation. the same can be said with regard to the sustainable development goals (sdgs, n.d.) which can be seen in figure two. the goal of this framework was to provide organisations and the general public with seventeen different segments that they can contribute to. it has been outlined that this has led to a tick box method that once a company achieves some form of sustainable action in one or two of the segments, it effectively checks out of the sustainable program that the united nations has developed. what our research wants to achieve is to create a high level framework that fulfils a circular approach to this thinking. figure 2: un sustainable development goals: 1 – 17 in order to gather some preliminary data to consider, the paper first completed a 1st iteration of the business model canvas on a sme which can be seen in figure three. this outlined key areas that the organisation has under a group of different headings. eceasst 8 / 16 volume 081 (2022) figure 3: business model canvas – 1st itteration (source: ryan and margaria et al 2021) once this was completed and a preliminary dataset produced, a second iteration of the canvas was created which can be seen in figure four. the areas in pink were the sustainable areas that were identified from analysing the 1st iteration for sustainable contributions. we found that the new goals contributed to over 25% of the new business model canvas and provided new areas of business that had not been identified or understood before the workshop. figure 4: business model canvas – 2nd itteration with sustainabality prespective (source: ryan and margaria et al 2021). the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 9 / 16 once this had been completed, a third and final itteration was produced which can be observed in figure five. this bmc has a much more integrated sustainability dimension than the original standard bmc. this third and final canvas is called the sustainability model canvas (sbc) and it is the final product of the workshop (ryan and margaria 2021). figure 5: sustainability model canvas (sbc) (source: ryan and margaria et al 2021) 3 high level architecture of the dsl platform according to visser (2008), “the goal of a dsl is to increase the productivity of software engineers by abstracting from low-level boilerplate code. introduction of dsls in the software development process requires a smooth workflow for the production of dsls themselves. this requires technology for designing and implementing dsls, but also a methodology for using that technology. that is, a collection of guidelines, design patterns, and reusable dsl components that show developers how to tackle common language design and implementation issues. organisations are the domain experts so for them the ability to create a circular framework that works best for them is critical important for their business success. eceasst 10 / 16 volume 081 (2022) now that risk and sustainability case studies have been completed in a business setting, the learnings that can be taken from these need to be extracted and analysed so that a high level architecture can be created. from consultation with the case study participants during the workshop, five independent circular approaches have been selected that we feel are critical for a successful adoption of such a circular process and we will examine in detail each segment. 1) business logic and understanding: in general, business logic / domain logic is a very important area to consider as it encompasses the correct business rules that organisations need to address and to a point if delivered correctly can determine how data and data ontologies are created, stored and altered as the organisation changes throughout its lifetime. business logic can be understood in many different ways by various stakeholders and that it why it is important that a dsl methodology is completed. the general understanding from a software developer standpoint is that it is part of the solution that can execute user stories using domain objects as varying inputs and outputs. the domain is normally the problem space while the solution space contains the business logic, business rules, domain logic and domain knowledge which will come from a variety of stakeholders. 2) knowledge harvesting this level will focus on the macroscopic aspects of production ecosystems, including business models, collaboration networks and supply chains to name just a few. in general, this part is going to be critical for automatically constructing large high knowledge bases from internal sources that the company processes. taxonomic knowledge is already a huge asset for applications like search and analytics (weikum et al 2019). rules is another key element for advancing the intelligent behaviour of machines to capture invariants over certain kinds of facts in the form of logical rules (weikum et al 2019). for example, a rule about a new product and their customers could state that the customer buying the new product actually purchased it as an early adopter in the life cycle – for it to be considered a new customer when the product was launched. this will make the data more accurate when collecting it and further down when analysing. 3) analysis this level considers the situated needs addressing the individual project in the context of the knowledge and risks as well as sustainability provisions and actions. taking the data from the previous section of knowledge harvesting and analysing it through a business lens is imperative for the successful venture of a project being undertaken. in many businesses settings data analysis and the discussion of it can be skipped over far too quickly (hair et al 2007). in order for this to be altered and for organisations to adapt to a more circular approach and understanding, the dsl will be integrated under the confirm project outlined in figure one. even though the main aim of that larger project was to target the application domain of advanced manufacturing including manufacturing analytics, the same approach can be taken for any other industry specific domain. combining external data analysis languages such a r and integrating the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 11 / 16 them for organisation to use within a dsl purpose built platform for their specific domain will change the status quo currently presiding in such companies and sectors. 4/5) decision support and decision making decision support and decision making: this level will combine the use of advanced tools in operations research, ai, planning, diagnosis and recommender systems to generate schedules and advice to key stakeholder users. these supports will be able to guide organisations in risk and sustainability planning and examine best scenario practises and approaches to consider before implementing it in real time form a business procedure point of view. with these specific segments in mind, figure six is essentially the layout that the dsl knowledge management platform will have for organisations to utilise. these 5 segments are interchangeable and once the circular approach is complete it can restart in order to keep updated and not form a one and done approach as previously mentioned. figure 6: dsl layout examining figure six, we can observe at the centre of the figure is dime which is a graphical integrated modelling environment (boßelmann et al 2016) which the dsl knowledge management platform will be created on. this combined with the gold framework previously mentioned and cited along with the gold tool itself (steffen and boßelmann 2018) will be the main tools used for the overall project. this will cover the qualitative aspects by means of a modified multi-level strategy modelling scheme based on the gold framework. as a starting point, gold in fact incorporates the most important frameworks and models used in businesses, e.g. porter’s five forces, the business model canvas, and the value proposition canvas. it also connects them in a consistent fashion throughout the organization’s vertical and horizontal levels, supporting a system-of-systems approach that seems suitable for the situations we face. eceasst 12 / 16 volume 081 (2022) these modelling elements could be transformed in a dsl for industry 4.0 and then used to address at a concrete level a number of the questions that are addressed at a consulting level by the fraunhofer platform the confirm centre is going to roll out in ireland. this combined with the current work being executed in our group at the confirm centre which can be seen in figure seven will also be utilised for overall data analytics and in general utilising the process model and data model with an overall interface (gui) will provide an enhanced dsl platform to organisations to leverage from the knowledge platform. (margaria et al 2021). this figure showcases how the quantitative aspects could be dealt with by using data analytics methods such as r and if needed they could be complemented by the application of appropriate ai and machine learning techniques for aggregation of the requirements and constraints in a comprehensive ontology. this will provide analysis and visualization for adequate just-in time modelling support and feedback to decision makers regarding sustainability and risk within an organisation. figure 7: architecture overview of dime and custom dsls (margaria et al 2021) now that the overall high level architecture has been produced, the three canvases produced from the earlier paper can essentially be created and mirrored in a dsl approach for organisations to use. instead of a workshop scenario, a dsl platform that conforms to such a framework outlined in ryan and margaria (2021) can be used to first prompt the user (organisation) to input the relevant details like the workshop did and then have the capabilities the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 13 / 16 to use the dsl to analyse the data along with more complex data that the organistaion might like to add in order to produce a circular approach to decision support and decision making. outlining how it can be achieved is depicted in figure eight with the various inputs and outputs showcased which can be utilised as guidance for the creation of a dsl to replace current workshop structures in place for sustainability. this figure examines two strands which are business logic and knowledge harvesting. as depicted, the model of canvas one along with the sustainability goals will be used as an input and as the process concludes the output will be the third canvas as per our workshop. figure 8: logic and understanding updated 4 results and discussion the paper addresses the need to understand how the high level architecture will be structured to create a dsl platform for knowledge management. from analysis completed during the workshop, five important segments have been identified as critical for the successful adoption of such a process. the 5 segments as identified and discussed in the previous chapter have been portrayed to ensure the circular approach that organisations need to adopt will be utilised. these segments will essentially encompass vast amount of data which is critically important to consider. this combined with shaping how a workshop scenario could be depicted in a dsl setting were important goals delivered in this paper. as we can see from these developments, there is a clear need for an effective description and formalization of data within a dsl platform if companies wish to utilise such a platform correctly. just having the dsl and frameworks available to the company will not be enough as in order to actually make correct decisions it will be important for the data to be correctly collected, organised and then analysed. the data needs to be relational to each other to be understood correctly and most cases should produce ideally one or more ontologies at different granularities for companies to understand and analyse (margaria and ryan 2022). generating eceasst 14 / 16 volume 081 (2022) the data that is needed will depend on a multitude of factors but will specifically be aligned with the extended bmc of sustainability that was outlined. the approach that was undertaken is very much how organisations currently examine any business plan with a simple pen and paper approach. now that an easy to follow framework has been created and the future of a dsl platform being examined, it will essentially aid in the adoption of a digitised approach for businesses to follow and reduce data loss as everything collected will be stored and analysed. 5 conclusion and outlook in this paper we have examined various aspects of the high level architecture of a domain specific language platform for knowledge management with emphasis on risk and sustainability. we introduced how industry 4.0 is changing the current landscape of organisations and how if they wish to continue to stay profitable and successful, a change in the status-quo currently effecting business planning and implementation needs to be addressed. we have showcased how the larger projects being developed under the confirm banner and research group in general in terms of smart factories can be tailored in specific areas to our problem at hand in this research. we also showcased how a problem like sustainability and in a smaller way risk is proving to be a large scale issue for all organisations in any sector especially sme’s from the case study and previous research outlined. we then outlined how a dsl platform could replace the current standard of consultants being asked to deliver workshops to companies who need expertise in this way while also showcasing how this can be delivered by utilising dime and other relevant areas of research currently in operation in the larger group. this along with examining the importance of data within such a platform was also introduced. by using this qualitative approach and case study as the motivation of why a dsl is needed by companies in this way, we will be able to show why our research has changed the way companies will approach planning and modelling in the future and that it was research that needed to be completed in order to provide an alternative and better approach to sustainable frameworks that currently were available and provide companies with a bespoke dsl that they can integrate easily within their organisation for a circular approach to business modelling that produces long and successful organisations. acknowledgements: this work was supported by the science foundation ireland grant 16/rc/3918 (confirm, the smart manufacturing research centre). the qualitative background of why a dsl knowledge based platform is needed in the context of sustainability. isola ds 2021 15 / 16 5 references boßelmann, s., frohme, m., kopetzki, d., lybecait, m., naujokat, s., neubauer, j., wirkner, d., zweihoff p., steffen, b.: dime a programming-less modelling environment for web applications. in: margaria, t., steffen, b (eds.) isola 2016. pp. 809-832. lncs 9953, springer international publishing, cham (2016) casadesus-masanell, r., ricart, j.e., 2010. from strategy to business models and onto tactics. long. range plan. 43 (2e3), 195e215. retrieved may 30, 2021 from https://www.sciencedirect.com/science/article/abs/pii/s0024630110000051. chesbrough, h., 2010. business model innovation: opportunities and barriers. long range plan. 43 (2-3), 354363. retrieved may 30, 2021from https://www.journals.elsevier.com/long-rangeplanning. chaudhary. a , margaria. t (2021). integration of micro-services as components in modelling environments for low code development. in syrcose software engineering colloquium, may 2021. chladek, n., (2019) retrieved july 01, 2021, from https://online.hbs.edu/blog/post/businesssustainability-strategies. confirm: confirm smart manufacturing science foundation ireland research centre. https://confirm.ie/ hair, j.f., money, a.h. samouel, p. and page, m. (2007), “research methods for business”, education + training, vol.49 no. 4, pp. 336-337. https://doi.org/10.1108/et.2007.49.4.336.2 ifac (2013) sustainability: challenges and opportunities for smps and smes, available: https://www.ifac.org/news-events/2013-04/sustainability-challenges-and-opportunities-smpsand-smes [accessed on 07/03/2022] margaria t. and ryan s (2022) chapter 8 – data and data management in the context of digital twins. currently in print. margaria, t., chaudhary, h.a.a., guevara, i., ryan, s., schieweck, a. (2021) the interoperability challenge: building a model-driven digital thread platform for cps. proc. isola 2021 int. symposium on leveraging applications of formal methods, verification and validation. lncs vol 13036, pp 393-41. springer, cham, 2021 morfaw, j. (2014). fundamentals of project sustainability. paper presented at pmi® global congress 2014—north america, phoenix, az. newtown square, pa: project management institute. naujokat, s., lybecait, m., kopetzki, d., & steffen, b. (2018). cinco: a simplicity-driven approach to full generation of domain-specific graphical modelling tools. international journal on software tools for technology transfer, 20(3), 327-354. https://www.journals.elsevier.com/long-range-planning https://www.journals.elsevier.com/long-range-planning https://online.hbs.edu/blog/post/business-sustainability-strategies https://online.hbs.edu/blog/post/business-sustainability-strategies https://confirm.ie/ https://www.ifac.org/news-events/2013-04/sustainability-challenges-and-opportunities-smps-and-smes https://www.ifac.org/news-events/2013-04/sustainability-challenges-and-opportunities-smps-and-smes eceasst 16 / 16 volume 081 (2022) osterwalder, a., 2004. ‘the business model ontology e a proposition in a design science approach’. retrieved july 05, 2021 from at: http://www.hec.unil.ch/aosterwa/phd/ . osterwalder, a., pigneur, y., 2010. business model generation: a handbook for visionaries, game changers, and challengers. john wiley & sons. sdgs (n.d.). sdgs united nations. retrieved july 05, 2021, from https://sdgs.un.org/goals. ryan. s and margaria. t: business model canvases and sustainability – a case study on a sme. presented at imc-37, the 37th international manufacturing conference athlone, ireland, sept 2021. steffen. b , ryan. s and margaria. t: towards living decision-making based on risk analysis in manufacturing supply chains. presented at imc-37, the 37th international manufacturing conference athlone, ireland, sept 2021. steffen b., boßelmann s. (2018) gold: global organization alignment and decision towards the hierarchical integration of heterogeneous business models. in: margaria t., steffen b. (eds) leveraging applications of formal methods, verification and validation. industrial practice. isola 2018. lecture notes in computer science, vol 11247. springer, cham. https://doi.org/10.1007/978-3-030-03427-6_37. visser, e. (2008). webdsl: a case study in domain-specific language engineering. in: lämmel, r., visser, j., saraiva, j. (eds) generative and transformational techniques in software engineering ii. gttse 2007. lecture notes in computer science, vol 5235. springer, berlin, heidelberg. https://doi.org/10.1007/978-3-540-88643-3_7 weikum, g., hoffart, j., suchanek, f. (2019). knowledge harvesting: achievements and challenges. in: steffen, b., woeginger, g. (eds) computing and software science. lecture notes in computer science(), vol 10000. springer, cham. https://doi.org/10.1007/978-3-31991908-9_13 https://sdgs.un.org/goals https://doi.org/10.1007/978-3-030-03427-6_37 https://doi.org/10.1007/978-3-540-88643-3_7 modelling clustering of wireless sensor networks with synchronised hyperedge replacement electronic communications of the easst volume 16 (2009) proceedings of the doctoral symposium at the international conference on graph transformation (icgt 2008) modelling clustering of wireless sensor networks with synchronised hyperedge replacement mohammad hammoudeh, robert newman, and sarah mount 14 pages guest editors: andrea corradini, emilio tuosto managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst modelling clustering of wireless sensor networks with synchronised hyperedge replacement mohammad hammoudeh, robert newman, and sarah mount {m.h.h, r.newman, s.moutn}@wlv.ac.uk, http://www.wlv.ac.uk/ school of computing and it university of wolverhampton, wolverhampton, uk abstract: this paper proposes synchronised hyperedge replacement (shr) as a suitable modelling framework for wireless sensor networks (wsns). shr facilitates explicit modelling of wsns applications environmental conditions (that significantly affect applications performance) while providing a sufficiently high level of abstraction for the specification of the underling coordination mechanisms. because it is an intractable problem to solve in distributed manner, and distribution is important, we propose a new nutrient-flow-based distributed clustering (ndc) algorithm to be used as a working example. the key contribution of this work is to demonstrate that shr is sufficiently expressive to describe wsns algorithms and their behaviour at a suitable level of abstraction to allow onward analysis. keywords: synchronised hyperedge replacement, wireless sensor networks, clustering 1 introduction a successfully large-scale wireless sensor network (wsn) deployment necessitates that the design concepts are analysed before they are mapped onto specific hardware platforms. developing, testing, and evaluating network protocols and supporting architectures and services for wsns are typically undertaken through test-beds or simulation. the substantial cost of deploying and maintaining large-scale wsns and the time needed for setting up the network for experimental goals makes simulation invaluable in developing reliable and portable applications for wsns. for instance, test-beds implementation is not always viable because it does not easily scale to large number of nodes. nonetheless, simulation in wsns has its own set of problems. some simulators are acknowledged to be difficult to use [cur] (e.g., ns-2 [ns-07]), platform dependent (e.g., tossim [llwc03]), containing inherent bugs (e.g., ns-2), distributed under commercial licenses (e.g., opnet [inc07]), etc. we contend that abstract models can provide cost effective methods for analysing wsns algorithms before deployment. it can, for example, help in assessing the scalability of algorithms independently from target hardware platforms and with a certain degree of accuracy; or else, it may simplify the software development process for wsns applications. one of the main difficulties in modelling wsns lays in their intrinsic interdependency with the environment in which they operate. it had been observed that wsns applications are characterised by the tasks involved in a particular application. wsns applications attribute integration of communication, computation, and interaction with the physical environment. 1 / 14 volume 16 (2009) mailto:\protect \t1\textbraceleft m.h.h, r.newman, s.moutn\protect \t1\textbraceright @wlv.ac.uk http://www.wlv.ac.uk/ modelling clustering of wsns with synchronised hyperedge replacement this inherent environment-application mutuality suggests that a reasonable model for wsns has to encompass the environmental conditions affecting the performance of wsns systems. to the best of our knowledge, a suitable abstract model encompassing those peculiarities of wsns is still missing. available models, like those defined in [gbt+04, geow04, cg04] neglect the environmental issues. we contend that a modelling framework for wsns to cover this concerns is required. in [tuo05], a first attempt to specify such a model has been tried showing how synchronised hyperedge replacement (shr) can suitably represent several aspects of wsns mechanisms in a unique formal framework. this paper advocates the use of graph transformations as a suitable modelling framework for wsns. specifically, we suggest using shr to formally specify various coordination aspects of wsns applications and applications environments at different abstraction levels. we show how shr can explicitly model very low level aspects, such as wireless communications, along with abstract ones, such as sensors spatial distribution. we also propose a new wsns clustering algorithm called nutrient-flow-based distributed clustering (ndc) which generates balanced clusters. ndc is used as a working example because it is a challenging problem to solve in a distributed manner. shr separates the coordination aspects of algorithms, such as ndc, from the data-related aspects. in fact, the metrics used to balance the clusters are parametric with respect to the shr productions describing sensors coordination. this makes our approach suitable for studying a wide range of algorithms classes obtained by varying the metric criteria. 2 related work in wsns, clustering is the process of grouping nodes into disjoint and homogeneous groups called clusters. low energy adaptive clustering hierarchy (leach) [hcb02] is one of the most promising routing algorithms for wsns. however, leach has been based on a number of unrealistic assumptions which in the authors’ opinion limit its effectiveness in a number of applications. these assumptions are listed in [hkg07]. mumhr [hkg07] is an improvement over leach. mumhr provides solutions to some of the limitations of leach. similar to leach, mumhr does not generate balanced clusters. the balanced clustering algorithm proposed in [gsys02] studies the theoretical aspects of the clustering problem in wsns with application to energy optimisation. since the linear separability principle does not hold in balanced problems, this algorithm is not suitable for the optimal balanced clustering. in the balanced clustering algorithm, every node should have knowledge about all other nodes in the cluster. moreover, this algorithm does not consider the transmission range of nodes. finally, using their defined diameter metric instead of the distance between the nodes and their cluster heads could result in energy inefficient clustering. a variety of process algebras to model wireless communications have been recently proposed such as [ms09, god08, god07, lt05]. in the authors’ opinion, there is no one model that is universally suitable. practical choice of a modelling approach depends on the application as well as on the availability of tools for developing, editing, and debugging rewriting approaches. important features include the readability and logical manageability of rewrite rules, formal properties, and effectiveness of rule application. the limited availability of development tools limit the practical use of those approaches. in proc. doctoral symposium icgt 2008 2 / 14 eceasst the future, it will become clearer which model is most suitable as the creation new tools and improving the available tools will allow researchers to understand and collect more experience with executable modelling systems. 3 nutrient-flow-based distributed clustering the aims of the nutrient-flow-based distributed clustering (ndc) algorithm are: (1) to equalise, so far as is possible, the diameter of the clusters. (2) to equalise, so far as is possible, the membership of the clusters. the distributed model described here is based around a metaphor of nutrient flow supporting some life-form, such as a mould. the concept is to provide a limited supply of nutrient, and allow the nodes to ally themselves with a cluster head which will provide the largest nutrient supply. if properly regulated, this should lead to clusters broadly equalising their membership. in order to minimise the radius of a cluster, it is arranged that some of the supply of nutrient is lost in transit between nodes the further the distance travelled, the more is lost. it is important that some advantage be given to nodes the join in a cluster, rather than communicating directly with the sink. for this reason, it is necessary to provide some advantage associated with clustering, as opposed to direct communication. the simplest way to do this is to make the loss of nutrient super-proportional to the distance of a link. given that in real life, radio propagation obeys an inverse square law, it seems reasonable to make the loss of nutrient proportional to the square of the distance travelled. like many distributed route discovery algorithms, this one operates in distinct phases or epochs, with the network reconfiguring itself from epoch to epoch. during each epoch, nodes try to improve the amount of nutrient available to them. they do this by contacting a local node at random and, if clustering with that node will offer a better supply than that which is currently available, then the node changes allegiance. nodes receiving requests for nutrient from other nodes make an offer back to that node, giving an estimate of the nutrient that would have been available had that node been a member of its cluster. the estimate depends both on the amount of nutrient available, and the number of nodes dependent on that cluster head. another consideration is that the algorithm has to give encouragement for clusters to grow, that is that the amount of nutrient available becomes greater as nodes join the network. to effect this, in each epoch the sink has available an amount of nutrient proportional to the total number of connected nodes. the starting conditions are as follows: (1) some initial store of nutrient available at the sink, nsink (2) current state of all other nodes is to have no nutrient, nav = 0 from the initial state, some nodes (nc) will by chance have direct contact with the sink. these become the initial cluster heads, and each is given an equal share of the nutrient available nav = nsink |nc| , which is available to them as attenuated by the square of the distance from the sink. across the network the sequence of events in each epoch is as follows: i) each node transmits to its dependents (if any) the total amount of nutrient available to that cluster and the current number of members (including the cluster head) at that level of the hierarchy. each dependent calculates its share of nutrient, s, for this epoch, which is s = nm×k×d2 3 / 14 volume 16 (2009) modelling clustering of wsns with synchronised hyperedge replacement algorithm 1 ndc clustering algorithm. 1. nodes in nc contact the sink 2. nodes in nc become a cluster heads 3. the sink gives each cluster head nutrient share nav 4. each cluster head send its dependents the value of n and m 5. each dependent node does the following: 6. calculate s 7. forwarded current cluster head id and received n and m values 8. nodes receiving the forwarded message do the following: 9. calculate s′ 10. if s′ > s then 11. leave current cluster head 12. join the cluster head in the forwarded message 13. end if 14. all cluster head send there m value to the sink 15. the sink calculate nnext 16. the sink broadcast nnext value where n is the total nutrient available to the cluster, m is the number of members, k is a constant of proportionality for the distance adjustment and d is the distance of the node from the cluster head. ii) each node which has a supply of nutrient selects another node (or set of nodes, to speed up the evolution of the system) at random and forwards the above information, along with the identity of the cluster head. iii) the receiving node calculates the amount of nutrient, s′, it could have received in this epoch as a member of that cluster. if the amount is greater than its actual allocation in this epoch it communicates with the cluster head and joins the cluster (also communicates with its old cluster head to leave that cluster). iv) cluster heads propagate upwards through the network the number of members. the sink calculates the amount of nutrient available for the next epoch using the formula nnext = no×mn mo where nnext is the nutrient available for the next epoch, no is the nutrient available this epoch, mn is the number of members reported, mo is the number of members reported for the previous epoch. the operation of the ndc clustering is summarised in algorithm 1. 4 shr at a glance we briefly review the main concepts of shr. for an in-depth treatment of shr and related literature the reader is referred to [hir03, tuo03, fhl+05] and references therein. in the following, the set of tuples on a set x is denoted as x∗; a tuple of length n is written as 〈x1, . . . , xn〉 (〈〉 is the empty tuple); dom( f ) is the domain of the function f and f�s is the restriction of f to s, proc. doctoral symposium icgt 2008 4 / 14 eceasst namely f�s(x) = f (x) if x ∈ s, f�s(x) is undefined otherwise. a (hyper)graph consists of nodes, elements of a countably infinite set n ∗, and (hyper)edges connecting nodes and labelled with elements of a set of edge labels l . if l ∈ l , rank(l) is a natural number, called the rank of l, that expresses l’s attachment node (namely the nodes l insists on). a syntactic judgement specifies a graph. definition 1 (graphs as judgements). a judgement has form γ`g where (i) γ⊆n ∗ is a finite set of nodes (the free nodes of the graph), and (ii) g is a graph term generated by the grammar g ::= l(x1, . . . , xn) g | g | ν y g | nil where y, x1, . . . xn ∈ n ∗, l ∈ l , and rank(l) = n. also, the restriction operator ν is a binder; fng is defined as usual and we demand that fng ⊆ γ. edges are terms of the form l(x1, . . . , xn), | is the parallel composition operator of graphs, ν y is the restriction operator (with priority lower than |) of nodes and nil is the empty graph. condition fng ⊆ γ accounts for having free isolated nodes in g (e.g., x ` nill is graph with only the isolated node x). judgements are compactly written by dropping curly brackets from interfaces and writing γ1, γ2 for γ1 ∪γ2 whenever γ1 ∩γ2 = /0 (e.g., γ, x ` g = γ∪{x}` g, if x /∈ γ). example 1. the judgement u, z ` ν z′ l(u, z, z′) | l′(z) | l′(z′) represents a graph with three edges labelled by l (of rank 3) and l′ (of rank 1); u, z ∈ n are free and z′ is bound. the graph can be depicted as • z l′oo • u loo ◦ z′ l′oo where edges are drawn as labelled boxes and nodes are bullets (empty for bound nodes and solid for free nodes). a connection between a node and an edge is called tentacle. an arrowed tentacle indicates the first attachment node of the edge; the other nodes are determined by numbering tentacles clockwise (e.g., for l, u is the first attachment node, z the second and z′ the third). graph terms are considered up to structural congruence (not reported here; see [fhl+05]) that yields the usual rules for restriction and a monoidal structure with respect to parallel composition and nil as neutral element. the shr version used here adopts the so called “milner” synchronisation algebra with mobility [lan06] that relies on the notion of action signature. fix a set act of input actions with two distinguished actions τ and ε (used below to express synchronisation and idleness, respectively), and let actmil = act ∪act ∪{τ, ε} where act = {a : a ∈ act} is the set of output action. an action signature is a triple (actmil, ar, ε) where ar : actmil → ω is an arity function such that ar(ε) = ar(τ) = 0 and ∀a ∈ act : ar(a) = ar(a)). mobility is modelled through a synchronisation function λ : γ → (actmil ×n ∗) assigning, to each x ∈ γ, an action a ∈ actmil and a tuple 〈x1,, . . . , xn〉 of nodes sent to x such that ar(a) = n. we let actλx = a and nλ(x) = {x1,, . . . , xn} when λ(x) = (a,〈x1,, . . . , xn〉). finally, the set of communicated (resp. fresh) names of λ is n(λ) = {z : ∃x.z ∈ nλ(x)} (resp. γλ = n(λ)\γ). definition 2 (shr transitions with mobility). given an action signature actmil, a shr transition is a relation of the form: γ ` g λ,π −−→ φ ` g′ 5 / 14 volume 16 (2009) modelling clustering of wsns with synchronised hyperedge replacement where π : γ → γ is an idempotent substitution1 s.t. ∀x ∈ n(λ)∩γ. xπ = x and φ = γπ ∪γλ. substitution π induces equivalence classes on γ (i.e., [x]π = {y ∈ γ : xπ = yπ}, for x ∈ γ) and selects their representative element (idempotency). only representatives can be communicated by λ, while, by definition of φ, free nodes are never erased and new nodes are bound unless communicated. productions specify how edges should be rewritten: definition 3 (productions). let l ∈ l have rank n and g be a graph term. a production is a transition of the form: x1, . . . , xn ` l(x1, . . . , xn) λ,π −−→ φ ` g where x1, . . . , xn are all distinct. this production is idle if λ(xi) = (ε,〈〉) for each i, π = id and φ ` g = x1, . . . , xn ` l(x1, . . . , xn). for each l ∈ l , the set of productions of l are assumed to contain the idle production for l and to be closed under injective re-namings. the operational semantics of shr is omitted for brevity, here we just give an example of how shr productions are synchronised. example 2. if r and id,r are labels for cluster heads and sensors respectively, then (ignoring the communication between the sink and the cluster head) the productions for moving a node from a cluster to another at the beginning of a new clustering epoch may be given as namely, the cluster head orders the member id to migrate to h′ therefore, upon synchronisation, the sensor id moves its membership tentacle which models the migration to the cluster headed by another cluster head (the one represented by an edge r(_, h′)). let g be the graph obtained by removing the dotted tentacle from synchronising the previous productions in g, which yields the graph obtained by replacing the dashed with the dotted tentacle in g. the transition described in example 2 is obtained by (i) finding in the graph edges labelled by the lhs of each production we want to synchronise; (ii) remove those edges and (iii) replace them with the corresponding rhd of their productions; (iv) collapsing those node that are communicated. 1 as customary, substitution application is expressed by juxtaposition of the substitution function (e.g., xπ stands for π(x)). proc. doctoral symposium icgt 2008 6 / 14 eceasst 5 ndc modelling in shr following [tuo05], we give some basic shr productions aiming to model the environmental conditions of a wsn. we simplify the representation by considering only the geographical information necessary to the coordination among sensors and a sink. remarkably, extending the present model with further environmental conditions (e.g., obstacles forbidding or deteriorating wireless signals) requires just a few new productions amenable to be synchronised with those presented here. we shall use the labels r and id,r to respectively denote cluster head and sensor edges with transmission range r; the different states edges can reach (possibly changing their rank) shall be represented by ′ r and ′ id,r , etc. geographic information can be modelled in shr as a group of nodes representing geographical points (ranged over by l, l′, etc.) connected by edges representing the euclidean distance between points. example 3. a network where a sensor and a cluster head are respectively located at l and l′ separated by a distance d is described by the graph l, l′ ` id,r(l) | d(l, l′) | r(l′, h) depicted as in the above example, nodes l and l′ are physical “public” locations while node h is the membership node, namely the node where sensors joining the cluster headed by the attached cluster head edge will be connected. though there is no formal difference between location and membership nodes, we want to emphasise their different conceptual distinction. in order to show the suitability of shr as modelling framework for wsns, communications at two different levels of abstraction are considered. the lower level shows how wireless communications can be described; in fact, the environmental edges are the carrier of the signal emitted by the sensors or the sink. the higher level instead abstracts from the communication details and focuses on the logical interactions that sensors, cluster heads and sink must perform as prescribed by ndc. the distinction will be clear later, but considering the graph in the example 3, this can be explained as follows: on location nodes (l and l′), communications are mediated by the environmental edges while, on the membership nodes, they are assumed to be abstract communications. 5.1 forming clusters once selected, cluster heads signal their presence with the production namely, a cluster head emits a signal r carrying its transmission range r (explicitly represented in the label) and relevant physical signal information r (e.g., direction, signal strength, frequency,... not explicitly represented). the cluster head also communicates the node h to which perspective members have to connect to; afterwards, they move to a state where they wait for instructions from the sink or requests for membership from other sensors. in the state r,λ ′ , the cluster head records the list λ of the members of its cluster that is initialised to the empty list [] in the previous production. environmental edges propagate (or stop) signals emitted by sensors. this can be modelled by the following productions 7 / 14 volume 16 (2009) modelling clustering of wsns with synchronised hyperedge replacement in equation 2, when d detects the presence of a cluster head at distance x from l, it echoes on l′ the presence of the cluster head updated with the its distance from l′ computed by the (monotonically increasing) function δ which takes x, d and the physical attributes of the signal in input. notice that the forwarded information of the physical attributes can change depending on the geographical positions l and l′. production (3) symmetrically propagates the signal from l′ to l and, as production (2), it is supposed to be applied only if the residual strength of the signal (carried by x) is enough for the signal to cover d; on the contrary, the productions will stop the signal. noticeably, productions (2) and (3) are parametric with respect to the used metric (hidden in δ ). this shows how orthogonal aspects can be naturally kept separated in shr so that the model actually specify a class of algorithms (those obtained by instantiating different metrics) and can therefore be used to study and compare them. eventually, the presence of a cluster head can be detected by a sensor so that the latter can apply for membership to the former according to the production stating that a sensor in state ′ id,r,x records its distance x from the cluster head and connects to the membership node h over which a membership request can be issued: notice that in the request the sensor includes its position l. and by the cluster head adds the new member to its list on accepting the new member. a sensor can also decide to ignore a signal: during the cluster formation phase, further cluster heads can be detected by sensors. indeed, it may even happen that a device senses the presence of other cluster head after having already joined a cluster. hence, in order to optimise its energy a sensor can decide to leave its current cluster and join a geographically closer one. this can be obtained by the following two productions: proc. doctoral symposium icgt 2008 8 / 14 eceasst accordingly, cluster heads acknowledge migration with the production notice that the list of members is updated. 5.2 balancing clusters at this stage, cluster heads send their list of members to the sink: where signal lsλ carries position and membership node and is propagated through the environmental nodes (like signals). we now refine the productions in example 3. on reception of a message from the sink requiring a sensor to migrate to another cluster, a cluster head orders the device to move: and, correspondingly, the sensor migrates to the new cluster: observe that the sensor returns to the state where it has to apply for membership to its (new) cluster head. finally, sinks are labelled by sλ where λ is the list of nodes and their locations as transmitted by cluster heads; we assume that nodes(λ ) returns the set of nodes occurring in the list λ and λ ]λ ′ is the list obtained by appending λ ′ to λ . productions for sinks are: where λ ′ in the last production takes into account that sensor id will migrates to the cluster with membership node h. we remark that the metric criteria determining the choice of the migrating sensors are orthogonal to the coordination productions of the sink. hence, the shr model offers another dimension along which ndc can be parateterised. 5.3 a practical validation of the model in the identification of network properties, the issue of load balancing, in terms of communication, is of paramount importance. the discovery of the most utilised nodes in a large complex 9 / 14 volume 16 (2009) modelling clustering of wsns with synchronised hyperedge replacement figure 1: a 10 nodes random topology network. network is vital to deal with communication bottlenecks and energy depletion problems. in this example we show how shr can facilitate the ranking of nodes by quantifying their degree of utilisation, i.e. the degree to which they have direct relationships with other nodes in a graph. in particular, we define a measure of load, l, on nodes in a network to identify structurally important nodes. a node is said to be important if it has a relatively high rank. each node is associated to a sensor. an edge is defined between two nodes when the corresponding sensors can communicate with each other. individual communication links are associated with energy communication cost. assume that the size of all message types is constant; the exact values of these communication costs can be estimated according to the distance between the sensors. the amount of energy needed to transmit a message to a destination at distance d from the source can be calculated by the following formula: es = kdc where k and c are constants for a specific wireless system. while the amount of energy needed to receive a message is virtually constant (er). formally, for a graph g, the measure of load of a node z ∈v (g) is given by l (z) = (ni ×es) + (no ×er) where ni is the number of incoming tentacles and no is the number of outgoing tentacles connected with a node. the usefulness of l was checked in simulation. a random topology network, (figure 1), that consists of 10 nodes connected by 16 outgoing tentacles was deployed using the general wsn simulator [ste05]. all nodes has the same initial amount of energy. when a node detect a moving object it send this information to all nodes within its transmission range. using l, we predict that nodes have higher number of outgoing tentacles will be the first to die. this prediction was confirmed by the simulation where nodes with l = 5×es were observed to die first (es > er). proc. doctoral symposium icgt 2008 10 / 14 eceasst the number of tentacles also it reflects the congestion level at various parts of the network. 5.4 an example verification of a ndc property this subsection provides an example around which an analytical proof may be attempted. we theoretically verify that by performing the action mv, a node can join exactly only one cluster. in a typical wsn deployment, faulty behaviour can result in a node being a member of two or more clusters. for instance, a join cluster request message can be received by many cluster heads and only the one addressed in that message should respond by sending a notification message that carries the amount of nutrient. the cluster head id can be specified in action m of a signal edge as defined in the productions of signals in [tuo05]. if the notification message is lost, the sending node waits for a short period of time and joins the second ‘best’ cluster head. in this case, the node might be registered as a member in both clusters. another example is when a node leaves a cluster; it sends a message to the cluster head to be removed from its membership list. if that message is not received by the corresponding cluster head, the node might be registered as a member of the two clusters (previous and current). let id,r(l, h, ϒ) be a sensor node in a network that consists of k + 1 clusters. a node can only participate in the network iff it is a member of only one cluster at any time. id,r is endowed with a set of attributes, ϒ, containing the current clustering information, the amount of available energy amongst others. after a node joins a new cluster or renews its membership with the current cluster, it updates the information stored in ϒ. the new mv action is described with the transition id,r(l, ha, ϒ) mvid〈hb〉−−−−→ id,r(l, hb, ϒ′). mv has the following algebraic properties: non-commutative, transitive, and asymmetric. proposition 5.4.1 if id,r(l, ha, ϒ) hamvid〈hb〉−−−−−−→ id,r(l, hc, ϒ′) where a, b, c ∈ [1, k + 1] , then hb == hc. proof the base case is when the mv transition is derived by the application of the rule hmvid〈hi〉−−−−−→ in a network that consists of only one cluster (k = 1). in a single cluster network, ha is said to be identical to hb and hc. in this case, id,r is said to renew its membership with the current cluster it operates within. if id,r(l, ha, ϒ) hamvid〈hb〉−−−−−−→ id,r(l, h, ϒ′), then h = hb|hc. this transition can be derived by applying the rule mv where id,r(l, ha, ϒ) hamvid〈hb〉−−−−−−→ id,r(l, hb, ϒ′) or id,r(l, ha, ϒ) hamvid〈hb〉−−−−−−→ id,r(l, hc, ϒ′) the second transition holds only when hb = hc because the requirements of the mv transition are: 1. ha must synchronise with hb using lmvid〈hb〉hamvid〈hb〉−−−−−−−−−−−→ (see example 3). 2. the sensor node synchronises the join request, h 〈l〉, with the new cluster head add member h 〈l′〉 transition. 11 / 14 volume 16 (2009) modelling clustering of wsns with synchronised hyperedge replacement according to the productions for the environment defined in [tuo05], an environment edge must coordinate the device action mv and ask its neighbour environment in the direction it wants to move toward for the next node. the node will leave ha as this transition can be applied only if the actions on the external nodes synchronise with actions imposed by the productions of adjacent edges according to the adopted synchronisation policy in [tuo05]. this guarantees that the node will be removed from the membership list of the previous cluster ha. in ndc, the membership information (l, h) is kept at the sensor node. observe that after the synchronisation of the mv transition, the node returns to the initial state where it has to apply for membership to a new cluster head. also notice that the join request contains the sensor position l. when a notification message or remove node from cluster membership list message are lost, the cluster head removes, rm, the node from its membership list if it does not hear from the nodes by the following transition l, h ` r(l, h) lrm〈h〉 −−−→ l, h ` r,[]′(l, h) 6 acknowledgements many thanks to dr emilio tuosto for interesting discussions that helped improve this work. also we thank the anonymous reviewers for their valuable comments and suggestions. 7 final remarks this paper has presented an approach to modelling one of the major practical problems facing designers of large wsns. network configuration remains one of the most problematic tasks in wsn design. the largest practical networks so far have been “designed” that is, the hierarchy has been fixed and built in at design time. this approach has resulted in an inevitable vulnerability to poor surveying of the real environment of the network site and to subsequent equipment failures, which render the designed-in architecture non viable. for this reason, self configuration remains a vitally important area of research, and algorithms such as ndc are of great interest in finding a practical solution. however, it is very difficult to predict the behaviour of such decentralised protocols when scaled to a very large network. it is not unusual for unexpected behaviours to arise, and protocols must be designed to be resistant to these. as has been argued, the traditional approach of simulation can be limited, both due to the difficulty of building a simulation using current tools, and due to the computational resources needed to analyse a network of substantial size. also, a simulation is not an intellectually satisfying “proof” of good behaviour. the success of one simulation cannot be taken as indicative of satisfactory function in situations other than the one in which the simulation was performed. analytical examination of the network offers the possibility of proving at least some of its behaviours, and may therefore be able to reach where simulation can not. one major problem with this approach is finding a suitable modelling framework in which to describe the behaviour of the network. it is argued here that shr is suitable and appropriate for this type of problem, and this has been demonstrated by the modelling of the ndc clustering algorithm using it. proc. doctoral symposium icgt 2008 12 / 14 eceasst shr intuitive, visual, and mathematical precise modelling made it easy to specify and prototype the ndc algorithm by abstracting its intensive computation and clearly presenting communication and relations between different network objects. this made it simple to implement and simulate the algorithm with less errors. cluster balancing was chosen as a working example because it is an intractable problem to solve in a distributed manner. in proposing ndc, several tentative claims have been made for it. not all of these claims can be verified using simulation, in particular, the suitability for an arbitrary number of cluster heads and the open ended scalability may only be proved analytically. this paper provides a model around which an analytical proof may be attempted. in the process, it has been demonstrated that shr is sufficiently expressive to describe such a protocol, and can describe its behaviour at a suitable level of abstraction to allow onward analysis, simulation, and implementation. all parts of the protocol have been modelled, from cluster formation, to cluster balancing. these models lay the groundwork for future analysis of ndc and other protocols, and the prospect of implementation of systems which are genuinely scalable, efficient and reliable, by dint of the proof of those properties as part of the design process. this type of analysis will not replace simulation, but it does provide a means for obtaining the kind of open-ended guarantees that simulation cannot give. references [cg04] c. chiasserini, m. garetto. modeling the performance of wireless sensor networks. in twenty-third annualjoint conference of the ieee computer and communications societies. pp. –231. march 2004. [cur] d. curren. a survey of simulation in sensor networks. http://www.cs.binghamton. edu/kang/teaching/cs580s/david.pdf. [online; accessed 27-august-2007]. [fhl+05] g. ferrari, d. hirsch, i. lanese, u. montanari, e. tuosto. synchronised hyperedge replacement as a model for service oriented computing. in de boer et al. (eds.). volume 4111. 2005. [gbt+04] c. guestrin, p. bodi, r. thibau, m. paski, s. madde. distributed regression: an efficient framework for modeling sensornetwork data. in proceedings of the third international symposium on information processing in sensor networks. pp. 1–10. 2004. [geow04] d. gracani, m. eltoweissy, s. olariu, a. wadaa. on modeling wireless sensor networks. in parallel and distributed processing symposium. pp. 220–. 2004. [god07] j. godskesen. a calculus for mobile ad hoc networks (extended abstract). in coordination models and languages. pp. 132–150. 2007. [god08] j. godskesen. a calculus for mobile ad-hoc networks with static location binding. in proceedings of the 15th international workshop on expressiveness in concurrency. 2008. 13 / 14 volume 16 (2009) http://www.cs.binghamton.edu/kang/teaching/cs580s/david.pdf http://www.cs.binghamton.edu/kang/teaching/cs580s/david.pdf modelling clustering of wsns with synchronised hyperedge replacement [gsys02] s. ghiasi, a. srivastava, x. yang, m. sarrafzadeh. optimal energy aware clustering in sensor networks. in sensors magazine, mdpi. pp. 258–269. january 2002. [hcb02] w. heinzelman, a. chandrakasan, h. balakrishnan. energy efficient communication protocol for wireless microsensor networks. in proceedings of the 33rd hawaii international conference on system sciences (hicss-33). january 2002. [hir03] d. hirsch. graph transformation models for software architecture styles. phd thesis, 2003. http://www.di.unipi.it/̃ dhirsch. [hkg07] m. hammoudeh, a. kurtz, e. gaura. mumhr: multi-path, multi-hop, hierarchical routing. in international conference on sensor technologies and applications (sensorcomm2007). 2007. [inc07] o. t. inc. the acm international symposium on mobile ad hoc networking and computing (mobi-hoc). http://www.opnet.com/, 2007. [online; accessed 2-august2007]. [lan06] i. lanese. synchornisation strategies for global computing models. phd thesis, dipartimento di informatica, università di pisa, 2006. [llwc03] p. levis, n. lee, m. welsh, d. culler. tossim: accurate and scalable simulation of entire tinyos applications. in sensys ’03: proceedings of the 1st international conference on embedded networked sensor systems. pp. 126–137. acm press, new york, ny, usa, 2003. [lt05] i. lanese, e. tuosto. synchronized hyperedge replacement for heterogeneous systems. in coordination models and languages. volume 3454/2005, pp. 220– 235. 2005. [ms09] m. merro, e. sibilio. a timed calculus for wireless systems. in 3rd international conference on fundamentals of software engineering (fsen’09). 2009. [ns-07] ns-2. the network simulator. http://www.isi.edu/nsnam/ns/, 2007. [online; accessed 1-november-2007]. [ste05] d. stein. wireless sensor network simulator v1.0. http://www.djstein.com/ projects/wirelesssensornetworksimulator.html, 2005. [online; accessed 18march-2009]. [tuo03] e. tuosto. non-functional aspects of wide area network programming. phd thesis, dipartimento di informatica, università di pisa, may 2003. [tuo05] e. tuosto. tarzan: communicating and moving in wireless jungles. in cerone and di pierro (eds.), 2nd workshop on quantitative aspects of programming languages. volume 112, pp. 77–94. jan. 2005. proc. doctoral symposium icgt 2008 14 / 14 http://www.opnet.com/ http://www.isi.edu/nsnam/ns/ http://www.djstein.com/projects/wirelesssensornetworksimulator.html http://www.djstein.com/projects/wirelesssensornetworksimulator.html introduction related work nutrient-flow-based distributed clustering shr at a glance ndc modelling in shr forming clusters balancing clusters a practical validation of the model an example verification of a ndc property acknowledgements final remarks privacy-preserving and scalable authentication based on network connection traces electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) privacy-preserving and scalable authentication based on network connection traces david monschein, advised by oliver p. waldhorst 5 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst privacy-preserving and scalable authentication based on network connection traces david monschein1, advised by oliver p. waldhorst1 1 data-centric software systems (dss) research group at the institute of applied research karlsruhe university of applied sciences, karlsruhe, germany abstract: since password-based authentication is no longer sufficient for web applications, additional authentication factors are required. especially in the context of mobile devices and with regard to usability, there is an increasing focus on methods where the user’s behavior is used as authentication factor (e.g., touchscreen interactions or sensors). as this typically requires the processing of large amounts of sensitive data, issues related to privacy and scalability arise. our work addresses the issues by presenting a scalable and privacy-friendly approach for authenticating users of mobile applications based on information about their network connections. keywords: mobile applications, mobility patterns, machine learning 1 research problem and objectives web-based applications are increasingly being accessed from mobile devices, which offer a broad range of attack possibilities [wł20]. thus, sophisticated security measures such as a comprehensive authentication of users are indispensable to prevent the misuse of digital identities. the sole use of password-based authentication is no longer sufficient, as passwords can fall into the hands of third parties due to a multitude of potential attacks [blba12]. one common way to mitigate this problem is to make use of multi-factor authentication (mfa), which requires the user to provide several independent proofs (factors) to confirm his identity [obm+18]. examples of additional factors are codes sent via short message service (sms) or the use of key generators. however, many of these factors are not suitable with regard to mobile applications. on the one hand, confirmations via sms are pointless if an attacker has physical access to the device (e.g., in the case of theft), because he has also access to the received text messages. the same applies to key generators that are installed on the same device. on the other hand, an external key generator that users must carry with them poses a substantial threat to the usability. for these reasons, more and more approaches concentrate on factors which are specifically tailored to mobile devices and avoid additional effort for the user. in particular, the analysis of location data [tik+20], sensor data [amv+19] and touchscreen interactions [kpc+20] is considered. however, since these data sources reveal very sensitive user information, their processing is associated with significant privacy concerns. furthermore, establishing such analytics for a large number of users poses challenges in terms of resource consumption and scalability. so far, these issues have not been sufficiently addressed by existing works. therefore, we propose a privacy-preserving and scalable methodology for establishing an authentication factor based on analyzing traces of network attachment points of mobile devices. 1 / 5 volume 080 (2021) privacy-preserving and scalable authentication based on network connection traces in order to preserve the privacy of the users, the sensitive data is pre-processed directly on the user’s device in such a way that minimal information about the actual network connection and the corresponding location can be derived from it. subsequently, it is examined whether the preprocessed data is consistent with the behavior previously observed for the user. we argue that this can be achieved by training a single machine learning model which is applied for all users. as a result, the scalability is significantly improved compared to related work. 2 conception our approach enables the establishment of an additional authentication factor for conventional mobile applications that are based on the client-server principle. the basic idea is that the user’s mobile device (frontend) provides information about its network connection to the application server (backend). in order to avoid that the server can extract sensitive details, this information is encoded directly on the user’s device. after the data has been transferred to the backend, traces of transitions between different network attachment points are formed and compared with previously observed behavior of the user. the quantification of the deviations can then be used to make an authentication decision. figure 1 visualizes the main components of our approach. mobile application application server frontend backend privacy encoder baseline database authentication processor mobile network connection (4) encoded connection data (5) (3) network connection data (1) (6) (1) (1) (2) (2) figure 1: overview of the main components and data flows of our authentication strategy initially, the user’s device monitors its network connection and tracks transitions to other network attachment points. in particular, the type of network, the id of the network attachment point (e.g., base station id) and the amount of transmitted data are considered. as soon as the user initiates a request (1), the authentication procedure is started by the application server. the application server requests information about the user’s latest network connections (2). before the frontend responds with the requested data, it is pre-processed by the privacy encoder (3). the privacy encoder is responsible for masking sensitive information. in our case, this mainly concerns the id of the network attachment point, from which the user’s location can typically be determined with considerable accuracy. in order to prevent this, the client device selects a random key once, which is stored permanently and not revealed at any point in time. subsequently, this key is used by the privacy encoder to encrypt data. for data without an underlying order, netsys 2021 2 / 5 eceasst e.g., structureless identifiers, we use keyed-hashing [kbc97] and for ordered data, e.g., transmitted data, we apply order-preserving encryption (ope) [bclo09]. keyed-hashing ensures a higher level of security, as it is only susceptible to bruteforce attacks [kbc97]. ope, on the other hand, does not provide such strong security guarantees, but assuming that the attacker does not know the key and cannot map arbitrary encrypted (decrypted) values to the corresponding decrypted (encrypted) ones, the recovery of the raw data is unlikely [bclo09]. as in our case the backend neither has access to the key nor has access to the frontend on which the encryption takes place, both methods can be considered as very reliable in terms of privacy protection. after the data has been processed by the privacy encoder, the transformed network connection details are sent to the authentication processor (4). first, the authentication processor retrieves previous data points of the same user from the baseline database, referred to as history frame (5). the history frame is used as reference to evaluate whether the received data conforms to the expected user behavior. if no information about this user is known, our system cannot make an authentication decision yet. consequently, conventional procedures must be conducted as fallback. in contrast, if reference data is available, the history frame and the currently received information, also called observation frame, are used as input for a machine learning model. an attacker who does not know the client’s key is not able to generate a valid observation frame and even if the key was obtained (e.g., by stealing the device), the attacker would also need to know the user’s behavior to generate a valid observation frame, because we ensure that collected records about the network connections on the user’s device are periodically deleted. note that if the user’s device changes, the respective key changes as well and the data already collected can no longer be used as a reference for the affected user. nevertheless, as we expect that a user rarely changes his device, this is negligible. in our implementation, we applied gradient boosted decision trees [cg16] to decide whether the two frames are consistent. a fundamental aspect of our approach is that we train only a single model, which ensures scalability for high numbers of users. the training procedure is described in the course of our experimental analysis in section 3. based on the output of the model, an authentication decision can be made (6) and if approved, the contents of the observation frame are persisted in the baseline database. 3 preliminary results by means of an existing dataset, we investigated how well our approach performs in a real-world setting. it contains the network requests issued by 1000 different users when interacting with mobile applications [ylx+18]. all users were located in the same city during the observation period of one week. after removing users with an unusually high or low number of interactions, 783 users remained. we performed the training based on the data of 607 users and the remaining 176 were used for evaluation. from the network requests, we inferred transitions between base stations and assembled them to fine-grained network connection traces for each user. subsequently, we used the combination of an observation frame and a history frame as input for our authentication model as described in section 2. the size of the obervation frame was set to 5 and the size of the history frame was set to 25. in other words, the model should determine if the 5 passed network transitions (observation) originate from the same user as the given 25 ones (history), with each transition consisting of the associated base station ids and 3 / 5 volume 080 (2021) privacy-preserving and scalable authentication based on network connection traces the amount of data transmitted until the transition happened. the parameters reflect realistic values for deployment in practice, considering the dataset used. because we need two classes of training samples (valid and invalid), we first built valid pairs of observation frames and history frames (i.e., data within both frames comes from the same user) and then artificially added invalid pairs by recombining the history frames with observation frames from other users. by using this method, the authentication system can learn to distinguish between the behavior of different users. furthermore, we trained three different models, one that works on raw data, one that works on data that has been encrypted using ope, and finally a model that works on data that has been transformed using keyed-hashing. as usual for the evaluation of authentication methods, we used the equal error rate (eer) to assess the quality of the models, which is defined as the common value where the false acceptance rate equals the false rejection rate [amvf20]. figure 2 shows the eers for the individual users in the test set when applying different privacy protection methods. it can be seen that ope (average eer 17.04%) does not cause a significant 0.1 0.3 0.5 0.2 0.4 0.6 0.8 eer c d f raw data ope keyed-hashing figure 2: cumulative distribution function (cdf) of the eers of the individual users performance drop compared to the evaluation on raw data (average eer 15.78%), but keyedhashing does (average eer 27.82%). it can be concluded that the base station ids have an underlying order and because this structure is suppressed due to keyed-hashing, the accuracy is reduced. it can be noted that the average eers are low enough that the models can serve as an authentication factor [amvf20]. in addition, we investigate how this approach can be combined with other factors to establish a standalone continuous authentication setting [mw21], without relying on conventional strategies such as sms confirmation codes as fallback. 4 conclusion and outlook we presented a strategy to identify users based on information about their network connections. our approach combines a profound privacy protection with a special focus on scalability, which enables the establishment of a user-friendly additional factor for existing authentication systems. using an experimental analysis, we have shown that our methodology works as intended and evaluated the effect of the privacy protection measures on the accuracy of the authentication. the ultimate goal is to embed this strategy, along with other previous works [mw21], into a comprehensive framework to establish robust protection against various attack scenarios. acknowledgements: funded by the german federal ministry of education and research(bmbf), refnr. 16kis1142k netsys 2021 4 / 5 eceasst bibliography [amv+19] a. acien, a. morales, r. vera-rodriguez, j. fierrez, r. tolosana. multilock: mobile active authentication based on multiple biometric and behavioral patterns. in proc. 1st int. workshop on multimodal understanding and learning for embodied applications (mulea). p. 53–59. nice, france, 2019. [amvf20] a. acien, a. morales, r. vera-rodriguez, j. fierrez. smartphone sensors for modeling human-computer interaction: general outlook and research datasets for user authentication. in proc. 44th ieee annual computers, software, and applications conf. (compsac). pp. 1273–1278. madrid, spain, 2020. [bclo09] a. boldyreva, n. chenette, y. lee, a. o’neill. order-preserving symmetric encryption. in proc. 28th annual int. conf. on the theory and applications of cryptographic techniques (eurocrypt). pp. 224–241. cologne, germany, 2009. [blba12] y. bang, d.-j. lee, y.-s. bae, j.-h. ahn. improving information security management: an analysis of id–password usage and a new login vulnerability measure. int. journal of information management 32(5):409–418, 2012. [cg16] t. chen, c. guestrin. xgboost: a scalable tree boosting system. in proc. 22nd acm sigkdd int. conf. on knowledge discovery and data mining. p. 785–794. san francisco, california, usa, 2016. [kbc97] h. krawczyk, m. bellare, r. canetti. rfc2104: hmac: keyed-hashing for message authentication. usa, 1997. [kpc+20] t. karanikiotis, m. d. papamichail, k. c. chatzidimitriou, n.-c. i. oikonomou, a. l. symeonidis, s. k. saripalle. continuous implicit authentication through touch traces modelling. in 20th ieee int. conf. on software quality, reliability and security (qrs). pp. 111–120. 2020. [mw21] d. monschein, o. p. waldhorst. spcauth: scalable and privacy-preserving continuous authentication for web applications. in 2021 ieee 46th conference on local computer networks (lcn 2021). virtual, oct. 2021. [obm+18] a. ometov, s. bezzateev, n. mäkitalo, s. andreev, t. mikkonen, y. koucheryavy. multi-factor authentication: a survey. cryptography 2(1), 2018. [tik+20] t. p. thao, m. irvan, r. kobayashi, r. s. yamaguchi, t. nakata. self-enhancing gps-based authentication using corresponding address. in proc. ifip data and applications security and privacy xxxiv. pp. 333–344. 2020. [wł20] p. weichbroth, ł. łysik. mobile security: threats and best practices. mobile information systems 2020:8828078, dec 2020. [ylx+18] d. yu, y. li, f. xu, p. zhang, v. kostakos. smartphone app usage prediction using points of interest. proceedings of the acm on interactive, mobile, wearable and ubiquitous technologies 1(4):174, 2018. 5 / 5 volume 080 (2021) research problem and objectives conception preliminary results conclusion and outlook derivation languages of graph grammars electronic communications of the easst volume 61 (2013) selected revised papers from the 4th international workshop on graph computation models (gcm 2012) derivation languages of graph grammars nils erik flick 22 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst derivation languages of graph grammars nils erik flick1∗ 1 flick@informatik.uni-oldenburg.de carl von ossietzky universität, d-26111 oldenburg abstract: we investigate sequential derivation languages associated with graph grammars, as a loose generalisation of free-labeled petri nets and szilard languages. the grammars are used to output strings of rule labels, and the applicability of a special rule determines the acceptance of a preceding derivation. due to the great power of such grammars, this family of languages is quite large and endowed with many closure properties. all derivation languages are decidable in nondeterministic polynomial time and space o(n log n), by simulation of the graph grammar on a turing machine. keywords: derivation language, closure properties, graph grammars, double pushout 1 introduction graph grammars are well known and well studied [roz97]. this paper deals with their derivation languages: though a graph grammar is usually employed to generate graphs, we use it to output strings in an automaton-like fashion. the graph is thus the state of a nondeterministic machine and the labels of the rules used in the derivation are output symbols. the original motivation for this work is the extension of notions already known in some restricted contexts. petri nets are graph grammars with no edges [cor95, kkk06], and their languages of labeled transition sequences are well known [jan87]. graph grammars can also simulate string grammars, and results about their derivation languages exist [mäk98]. however, any description of the more derivation languages of graph grammars appears to be missing. this, by itself, would perhaps not be motivation enough to consider such a vast generalisation; yet we have found the subject to be intricate enough to justify further investigation. the language class, we have named l$, studied in this paper has a relatively concise description in terms of graph grammars, and it seems to be a fairly natural class with strong closure properties. some new techniques and non-trivial results arise from the definitions. recasting other known formalisms as special cases of graph grammars after forging some generic tools for understanding their languages can also be a motivation to deal with graph grammars; petri nets are sometimes too limiting from the modeling point of view. the dynamics of many kinds of systems, for instance modeled as high level petri nets, can be understood in terms of local operations on graph-like system state. edges are necessary, for instance, to ensure the coherent transport of a set of tokens which logically belong to a single modeled entity. we argue ∗ this work was supported by a university of hamburg (hmbnfg) doctoral fellowship. this work is supported by the german research foundation (dfg), grant grk 1765 (research training group – system correctness under adverse conditions). 1 / 22 volume 61 (2013) mailto:flick@informatik.uni-oldenburg.de derivation languages of graph grammars that understanding their languages, as a simple form of semantics, can lead to steps towards analysis, verification and possibly synthesis from behavioural specifications, of complex systems. the paper is structured as follows. section 2 reviews the basic definitions and introduces derivation languages. section 3 presents closure properties, constructively obtained via operations on graphs and grammars. we present a proof of l$ under letter-to-letter homomorphisms, expressing (ambiguous) rule relabelings. we use the closure properties to establish a first hierarchy result. in section 4 we present an upper bound on the nondeterministic complexity of the word problem for a derivation language. we show that a lot of questions about general derivation languages are undecidable, and application of deleting homomorphisms leads to the recursively enumerable languages. section 5 concludes with an overview of our results and an outlook. 2 graph grammars in this section, we introduce the notions of graphs, rules, grammars and derivation languages. we write − for set difference, x −y = {x ∈ x | x < y}, and f |y for the restriction of the function f : x → z to y ⊆ x. ◦ is function or relation composition. x + y denotes the union of the sets x and y when these are assumed to be disjoint. if a ⊆ x∩y , x +a y also denotes a union of x and y , with x −a and y −a assumed disjoint. assumption 1 let λ be a label alphabet. definition 1 (graphs and morphisms) a graph is a tuple g = (vg, eg, sg,tg,λgv,λge ) of two disjoint finite sets vg of nodes, eg of edges and four total functions, sg,tg : e → v , λgv : v → λ λge : e → λ called the source and target mappings and the label functions, respectively. a morphism f : g → h from a graph g to a graph h is a pair f = ( fv, fe ) of total functions fv : vg →vh and fe : eg → eh which preserves the connectivity and the labels: sh◦ fe = fv ◦sg, th ◦ fe = fv ◦tg, λhe ◦ fe = λge and λhv ◦ fv = λgv . f is called injective or an inclusion (usually denoted by f : g ↪→ h) iff both fv and fe are injective. an isomorphism is a morphism with bijective components. being related by isomorphisms is an equivalence relation denoted �. nodes and edges are collectively called items. when the meaning can be inferred from the context, we will denote both components fv and fe of a morphism f just by the symbol f . we write λg for both λgv and λge when it is convenient to do so. graphs is the set of all graphs. definition 2 (rule) a rule is a tuple % = (l ←↩ k ↪→ r) of graphs, where k is called the interface and is contained both in the left hand side graph l and in the right hand side graph r. a rule % is called identical and denoted by idk if l = k = r. definition 3 (direct derivation step) let % be a rule, g a graph and g : l ↪→ g an injective morphism. the dangling condition requires that for every node n ∈ vg in the range of ggv that is not the image of a node in k, every edge e ∈ eg with sg(e) = n or tg(e) = n is in the range of gge . if g satisfies the dangling condition, then g is called a match of l in g. a direct derivation step g %,g ⇒h from a graph g to a graph h with a rule % via a match g consists of a double pushout selected revised papers from gcm 2012 2 / 22 eceasst diagram l k r g d h (1) (2)g h where (1) d = g−g(l−k), (2) h = d + h(r−k). the equation (1) stands for vd = vg − gv (vl − vk ) and ed = eg − ge (el − ek ), (2) means vh = vd + hv (vr −kr) and eh = ed + he (er −kr). we may omit the match in the notation: g % ⇒h. given a set r of rules, a derivation g0 v ⇒∗ r gn is a sequence of derivation steps g0 %1 ==⇒ ... %n ==⇒ gn with v = %1 ...%n. definition 4 (graph grammars and derivation languages) a graph grammar, short grammar, is a tuple gg = (t,r,r,s) of an alphabet t of (rule) labels, a finite set of rules r, a surjective function r : t →r and a start graph s. we write g w ⇒∗ gg h for g r(w) ⇒∗ r h, where w = w1 ...wn and r : t∗→r∗ denotes the extension of r : t → r with r(w1 ...wn) = r(w1)...r(wn) for w = w1 ...wn ∈ t∗. the subscript may be omitted when gg can be inferred from the context. if g w ⇒∗ h and h r(t) ⇒j, we say that w may enable t from g. we will also use the terms rule application and applicability of a rule for a derivation step and the existence of a derivation step, respectively. the prefix-closed derivation language of gg is the set ld(gg) := {w ∈ t ∗ | s w ⇒ ∗ gg } of all sequences w of rule labels such that a derivation starting from s with the corresponding rules exists. the $-terminated derivation language of gg and $ ∈ t is the set of all strings over t −{$} in ld(gg) which may enable $: l$(gg,$) := { w ∈ (t −{$})∗ | w$ ∈ld(gg) } unless otherwise stated, the terminating character is $, and we simply write l$(gg). ld denotes the class of all languages ld(gg) for some grammar gg, l$ analogously. w1 · w2 · ... · wn g0 g1 g2 ... gn %1 ==⇒ %2 ==⇒ %n ==⇒ 7→ 7→ 7→ w1 ...wn ∈ld(gg) w1 · w2 · ... · wn g0 g1 g2 ... gn %1 ==⇒ %2 ==⇒ %n ==⇒ 7→ 7→ 7→ · $ 7→ %n+1 ⇒ gn+1 w1 ...wn ∈l$(gg) w1,...,wn , $ 3 / 22 volume 61 (2013) derivation languages of graph grammars for every derivation sequence there exist in general one or several rule label sequences. for every rule label sequence in t∗ there exist in general zero, one or several derivations. let us fix conventions for the graphical representation of graphs, rules and grammars. node colours and shapes shall represent labels. node inscriptions represent node names or labels, according to the legend given in the text. edges are also decorated (dashed or thick lines) according to their label. rules are represented with the left hand side, interface, right hand side in that order from left to right; the common items are placed at the same location relative to the bounding box in all three graphs of the rule. a special representation is introduced later to abstractly represent subgraphs. in two instances, a subgraph will be highlighted by rendering nodes and edges in bold and in bright colours. example 1 let the rules r of a grammar gg be a: ⊇ ⊆ c: ⊇ ⊆ b: ⊇ ⊆ $: ⊇ ⊆ then there is a derivation with the given start graph, a ⇒ a ⇒ b ⇒ b ⇒ c ⇒ c ⇒ $ ⇒ and the word aabbcc is a word of l$(gg). 3 closure properties and relation to other families this section presents several features of l$ in two subsections. in subsection 3.1, we constructively prove that l$ is closed under homomorphisms which assign only single letters (several letters may have the same image). for the purpose of language generation, it is possible to simulate such a non-injective relabeling of the rules with a modified grammar. the modification of the start graph and rules to this effect will be explained in detail and proved correct. the resulting theorem is a property of l$ not shared by the similar but less general mechanisms that had so far been investigated in the literature. it has non-trivial applications to the further development of the derivation language theory of graph grammars: in subsection 3.2, we use it as an ingredient for the proof of the inclusion of the context free languages cf in l$. from that proof the stronger statement of the proper inclusion cf ⊂l$ already follows, because l$ is closed under intersections and cf is not. we then demonstrate that all szilard languages are in l$, and finally provide another valuable example of a non-context-free language in l$. selected revised papers from gcm 2012 4 / 22 eceasst 3.1 closure under rule relabelings we start with a construction that serves to extend a graph with an extra node, which is connected to all nodes of the original graph. the construction is then extended to rules. because the extra node is given a special label, it cannot be confused with any other node, and the matches of the modified rule in the modified graph will correspond exactly to the matches of the original rule in the original graph. this construction, which we call suspension, may appear almost trivial but is essential in the sequel: the extra node can serve as a single gluing point to attach the whole graph to a specific place in a much larger graph. this, in turn, is essential for our approach to constructing a grammar that runs a simulation of another grammar such that the language of the simulating grammar is a homomorphic image of the language of the simulated grammar. definition 5 (suspension) given a graph g and a new label ∗ not in the range of λgv nor λge , the suspended graph gx is obtained from g by adding a new node x with label ∗, and edges from x to each node of v , also with label ∗. we will usually represent g graphically as a box, g ∗ given a morphism f : g → h, f x,y denotes the morphism from gx to hy, such that f x,y(u) = f (u) if u is an item of g, f x,y(x) = y and each new edge with target in gx is mapped to the corresponding new edge in hy. g h f g ∗x h ∗y f x,y we fix a label ∗ to be implicitly used as the new label for all suspensions in the rest of the paper, and assume it does not occur in any graph subjected to the construction. let %x denote the rule obtained by suspending the graphs of % on x. given a grammar gg, ggx denotes the grammar obtained by applying suspension to the start graph and the interfaces, left hand and right hand sides of the rules of gg. lemma 1 (suspension lemma) for every match g : l → g of a rule % in g, there is a match gx,y : lx → ly of %y in gy such that gy ⇒% x,gx,y hy if g ⇒%,g h. every match q : lx → gy of a rule %x in gy is of the form q = gx,y for some morphism g : l → g, and g is a match of % such that g ⇒%,g h if gy ⇒% x,gx,y hy. proof. g ρ,g ⇒h implies gy %x,gx,y =====⇒ hy: extend the match g, and h, to x to gx,y resp. hx,y. this results in a derivation because gx,y is again a match: the dangling condition is satisfied because nodes n to be deleted have a supplementary edge attached to them but that edge from gy to n is also present in the modified left hand side graph of the rule ρx. 5 / 22 volume 61 (2013) derivation languages of graph grammars gy ρx,gx,y =====⇒ hy implies g ρ,g ⇒h: since there is exactly one node labeled ∗ in gy and one edge from it to every node from g if there are any nodes in g, the images of the ∗ labeled node and edges of d in h are determined by the source and target consistency requirements for a morphism. the removal of all such ∗ labeled items from all graphs involved in the derivation step does not impose any new restrictions. � it is expedient to define gluing constructions for graphs and rules and to prove several properties that will allow us to use those definitions later in this section for the proof of the main theorem. definition 6 (gluing) the gluing of two graphs g and h along the graph a ⊆g, h is the graph denoted g +a h with node set (vg +va vh ) and edge set (eg +ea eh ), vg − va and vh − va assumed disjoint, similarly for the edges. if a has no edges, we simply write g +va h for g +a h, also omitting the set brackets if no confusion is possible, and g + h if va is empty. if a is a set of nodes which is not a subset of vg ∩vh , g +a h is an abbreviation for g +a∩vg∩vh h. definition 7 (parallel composition) given two rules %1 and %2 and a set a ⊆ vk1 ∩ vk2 of common nodes, the parallel composition of %1 and %2 as the rule %1 +a %2 := (l1 +a l2 ←↩ k1 +a k2 ↪→ r1 +a r2). if %2 = (l2 ←↩ k2 ↪→ r2) is identical (l2 = k2 = r2), then %1 +a %2 is called an enlargement of %1. we recall two properties of the parallel composition collectively known as the parallelism theorem (theorem 4.7 in [ehr79]). lemma 2 (parallel step lemma [ehr79]) if g1 %1 ==⇒ h1 and g2 %2 ==⇒ h2, then g1 +a g2 %1+a′%2 ======⇒ h1 +a h2 where a′ is the common preimage of a via both matches. lemma 3 (sequential decomposition [ehr79]) a derivation step g % ⇒h of the parallel composition of two rules % = %1 +a %2 can be decomposed sequentially into two derivation steps g %1 ⇒j %2 ⇒h, assigning the same image to the nodes of a in both matches. it will frequently become necessary in the subsequent constructions to transfer a rule application to a larger graph, or to restrict attention to a certain part of a derivation step. the next lemma allows under certain conditions to conclude that the graphs involved in derivation steps may be enlarged or shrunk without interfering with the derivation step. it is partly similar to the embedding and restriction theorems (theorems 6.14 and 6.18 in [eept06]) but additionally allows to enlarge and shrink rules, not just their contexts of application. lemma 4 (embedding lemma) let x be a graph, % a rule, a a subgraph of k, and %′ the enlargement % +a idx . then, for any match g : l → g, writing g′ for the enlarged version of g, and l′ for l +a x and so on, (1) g %,g ⇒h implies g′ %,g′◦l′ ⇒ h′. (2) g %,g ⇒h implies g′ %′,g′ ⇒ h′. selected revised papers from gcm 2012 6 / 22 eceasst conversely, (3) g′ %,g′◦l′ ⇒ h′ implies g %,g ⇒h. (4) g′ %′,g′ ⇒ h′ implies g %,g ⇒h. l k r l′ k′ r′ g′ d′ h′ l′ r′ g′ h′ proof. we notice that the presence of items of x in the graph to which the rule is applied does not influence the satisfaction of the dangling condition because all edges from x are attached to nodes of k, and those are not deleted. g %,g ⇒h implies g′ %,g′◦l′ ⇒ h′: the intermediary graph is constructed as d = g−g(l−k). since x is glued to nodes of k, the dangling condition is respected and the outer difference in d′ = (g−g(l−k))′ = (g′−g(l−k)) is a graph. completing the derivation step results in h′. g %,g ⇒h implies g′ %′,g′ ⇒ h′: the only difference to the first case is that now g(l−k) is replaced with g(l′− k′) and analogously r− k with r′− k′ when completing the derivation step. but l′−k′ = l−k and r′−k′ = r−k, so the enlarged rule has the same effect as the original rule. g′ %,g′◦l′ ⇒ h′ implies g %,g ⇒h: as argued before, gluing in x along a does not interfere with the dangling condition. one weakens the conclusion of the derivation step to obtain a proposition about g′−(x −a), d′−(x −a), h′−(x −a) only, which are indeed the graphs g, d and h. g′ %′,g′ ⇒ h′ implies g %,g ⇒h: one proceeds as in the third case and ignores what is known about the nodes and edges of x from the definition of the derivation step, to obtain a statement about a derivation step with (l′−(x−a) ←↩ k′−(x−a) ↪→ r′−(x−a)) = % from g′−(x−a) = g. the result of the first half of the derivation step is d′−(x −a) = d since (g′−g(l−k))−(x −a) is equal to (g′−(x−a)−g(l−k)) = d, and this is also a graph (no dangling edges) for the reason stated in the introductory remark. h is obtained as before, as h = (d + h(r−k)). � a comparison with petri net and szilard languages suggests the question whether the image of a derivation language under a non-injective relabeling of the rules (assigning ambiguous labels to some rules) is still a derivation language. in the cases of petri net [jan87] and szilard [hö75] languages, this increases the generative power. we devote the next pages to showing how a grammar gg can be modified such that the derivation language of the modified grammar ggh indeed simulates two distinct rules with the same label. two letters a1 and a2 used for rules in gg would be merged to a common image h(a1) = h(a2) = a, and ld(ggh) = h(ld(gg)) and l$(ggh) = h(l$(gg)). closure under arbitrary letter-to-letter homomorphisms then follows by repeated application of such mergers. since the effect of a rule is always the same, when simulating the effects of two different rules originally labeled a1, a2 with a single compound rule %a, it is impossible to choose between the two in a derivation step. both will necessarily be applied. but since one of the effects 7 / 22 volume 61 (2013) derivation languages of graph grammars is unwanted, the idea is to neutralise it by extending the graph of the simulated grammar with a specially constructed sandbox which contains the left hand side of the unwanted rule to guarantee its applicability, and then forcing the match of the unwanted rule into the sandbox, where it cannot interfere with the simulation. since the sandbox will be depleted after each usage, it must also be replenished by the compound rule. we now introduce three control graphs (control, control′ and control′′) that guide the application of the compound rule and the other rules in the simulation. roughly, a suspended copy of the simulated grammar’s current graph g will be glued to a node of control. the other nodes of control will serve as a sandbox, initialised by gluing to them the suspended left hand sides of a1 and a2 (as one does not know in advance which of a1 or a2 will be unwanted, both left hand sides must be available in the sandbox). we call the result of this construction an augmented graph g̃. it is the graph on which the modified grammar operates to perform the simulation. in the first control graph, the role of node 0 is to provide a handle for suspending the simulation state. control has no symmetry exchanging 0 with another node. the nodes 1 and 2 will serve as the sandbox to execute the unwanted rule, while 3 only collects garbage. control′, the control graph for unambiguously relabeled rules, has a node that can only match to 0 and this ensures the correct simulation of these rules. on the other hand, control′′ will be used for compound rules. this graph has two nodes (4 and 5) that can match to 0. the special construction of control′′ directs the match of the a1 part of the compound rule to the sandbox when the a2 part is matched on the graph of the simulated grammar and vice versa. construction 1 (control graphs for the simulation) the basic control graph control is defined as the graph with node set {0,1,2,3}, all nodes labeled ∗ and the edges shown: edges represented in dotted lines bear the label new and edges represented in thick lines have the label link. 0 1 2 3 the control graph control′ for unambiguously relabeled rules is defined as the graph with node set {8,9,10}, label ∗ for all three nodes and just two new edges: 8 9 10 the control graph control′′ for ambiguously relabeled rules is defined as the graph with node set {4,5,6,7}, label ∗ for all four nodes, and the edges shown. 4 5 6 7 selected revised papers from gcm 2012 8 / 22 eceasst we also assume that in the subsequent constructions, no other new and link labeled edges occur except those introduced with these three graphs. construction 2 (augmented graphs) given a grammar gg = (t,r,r,s), two letters a1,a2 ∈ t , r(a1) = %1, r(a2) = %2, and a label ∗ not occurring in any rule of r nor in s, for i, j ∈ {1,2}, let g̃(i j) := control + 0,1,2,3 ( g0 + ( l1 i + 1,2 l2 j )) , be the graph consisting of one copy of g suspended to the node 0 of control, and one supplementary copy of the left hand side of each one of the rules %1, %2 suspended either on 1 or on 2. all four possibilities (i, j) = (1,1), (1,2), (2,1) or (2,2) are represented in a schematic drawing; an actual g̃(i j) graph is obtained by choosing one l1 and one l2 copy and striking the other. 0 1 2 3 g l1 l2 l1 l2 g̃(1,2) and g̃(2,1) are isomorphic, and so are g̃(1,1) and g̃(2,2), but since we have chosen to consistently track the nodes of the control graph through a derivation sequence by their identities, there are four variants, not two. the role of i and j is as follows: since one does not know in advance whether the simulation requires a copy of l1 or a copy of l2 at a given step to neutralise the collateral effect, both must be “on stock”; however, just placing a new left hand side where the current one was consumed is not a solution, because one of the rule effects will be applied “for real” on the graph suspended on node 0. placing a new left hand side on 0, however, could interfere with the simulation. therefore, a more complicated scheme is necessary. our solution requires, for compound rules, an alternation between the cases i = j and i , j. unambiguously relabeled rules ignore the sandbox part and leave i and j unchanged after the derivation step. construction 3 (augmented rules, first case) a rule % = (l ←↩ k ↪→ r) is changed into %′ := ( control′ + 8 l8 ←↩ control′ + 8 k8 ↪→ control′ + 8 r8 ) . 8 9 10 l 8 9 10 k 8 9 10 r ⊇ ⊆ 9 / 22 volume 61 (2013) derivation languages of graph grammars lemma 5 (unique simulation step in the first case) if a rule % is transformed to %′ according to construction 3, and rest contains no ∗ labeled nodes or edges besides 1,2,3, there is a % derivation from g to h iff there is a corresponding %′ derivation between the augmented graphs: g % ⇒h iff∃rest ∈ graphs and i, j ∈ {1,2} such that ( g̃(i j) + 1,2,3 rest %′ ⇒ h̃(i j) + 1,2,3 rest ) . proof. g % ⇒h implies g̃(i j) + 1,2,3 rest %′ ⇒h̃(i j) + 1,2,3 rest: by lemma 1, g %,g ⇒h implies g0 %8,g8,0 =====⇒ h0, which in turn implies g̃(i j) %8,g8,0 =====⇒ h̃(i j) by lemma 4 (1), and g̃(i j) +1,2,3 rest %′,g′8,0 =====⇒ h̃(i j) +1,2,3 rest by lemma 4 (2), where %′ is obtained from rule % as in construction 3, and g′ is the enlargement of the match (as in lemma 4) by the graph control′, glued in along 8. g̃(i j) +1,2,3 rest %′ ⇒h̃(i j) +1,2,3 rest implies g % ⇒h: let q be the match used in the derivation step in the antecedent. the only possible image for the node 8 is the node 0 (no new ∗ labeled nodes nor control edges have been added, and there is only one morphism from control′ to control). this constrains the images of the nodes from l% to lie within g, because all edges e of l%′ with q(s(e)) = 0 in g̃(i j) +1,2,3 rest not labeled new are suspension edges from g0, by construction. rest + ∅̃(i j) is linked only to nodes of g(k), therefore an application of lemma 4 (3) with x = rest + ∅̃(i j) glued in along {1,2,3}, followed by the second proposition of lemma 1 to reverse the suspension, concludes the proof. � construction 4 (augmented rules, second case) from two rules r(a1) = %1 and r(a2) = %2, a rule %a is constructed by gluing along the ∗ nodes the following rules, in the sequel referred to as the sub-rules of %a, %14, %25, %add1 := (∅←↩∅ ↪→ l1) 7, %add2 := (∅←↩∅ ↪→ l2) 6, idcontrol′′: %a := ( %1 4 + %2 5 + %add1 + %add2 ) + 4,5,6,7 idcontrol′′. 4 5 6 7 l1 l2 4 5 6 7 k1 k2 4 5 6 7 r1 r2 l1l2 ⊇ ⊆ lemma 6 (essentially unique simulation step in the second case) if the rules %1 and %2 are transformed into %a according to construction 4, then if λ−1rest(∗) ⊆{1,2,3} and ∃i, j,k,l ∈ {1,2}, (g %1 ⇒h ∨ g %2 ⇒h) iff ( ∃rest,rest′ ∈ graphs : g̃(i j) + 1,2,3 rest %a ⇒ h̃(kl) + 1,2,3 rest′ ) . proof. g %1 ⇒h ∨g %2 ⇒h ⇒ ∃rest,rest′ ∈ graphs : g̃(i j) +1,2,3 rest %a ⇒h̃(kl) +1,2,3 rest′: assume first that g %1 ⇒h. due to the symmetrical construction of %a, the case of g %2 ⇒h is completely analogous. selected revised papers from gcm 2012 10 / 22 eceasst there is a match g such that g %1,g ===⇒ h. we apply the suspension lemma (lemma 1) to suspend %1 as %14 and the match as g4,0, g0 %1 4,g4,0 =====⇒ h0, and repeat the same with the derivation step l2 %2, f ===⇒ r2 to obtain l2 j %2 5, f 5, j =====⇒ r2 j. fix matches of the sub-rules %add1 and %add2 which assign 7 to 3 and 6 to 3− j (6 is mapped one of 1 and 2, but not the same as j). applying proposition (1) of the embedding lemma to each of the sub-rule derivations in turn results in a derivation of four steps. leaving the matches implicit, g̃(i j) +1,2,3 rest = ( control +0,1,2,3 ( g0 + (l1i +1,2 l2 j) )) +1,2,3 rest %1 4 ==⇒ ( control +0,1,2,3 ( h0 + (l1i +1,2 l2 j) )) +1,2,3 rest %2 5 ==⇒ ( control +0,1,2,3 ( h0 + (l1i +1,2 r2 j) )) +1,2,3 rest (∅←↩∅↪→l1) 7 =========⇒ ( control +0,1,2,3 ( h0 + (l1i +1,2 r2 j) )) +1,2,3 (rest +3 l13) (∅←↩∅↪→l2) 6 =========⇒ ( control +0,1,2,3 ( h0 + (l1i +1,2 r2 j) )) +1,2,3 ( rest +i,3 ( l13 + l23− j )) = ( control +0,1,2,3 ( h0 + (l1i +1,2 l23− j) )) +1,2,3 ( rest +i,3 ( l1 3 + r2 j )) ︸ ︷︷ ︸ rest′ here, k = i because the subgraph l1i is not used up and can be re-used as a constituent of the augmented graph h̃(kl). the new copy of l1 which has been suspended to 3 by the application of the sub-rule %add1 becomes part of rest ′. l = 2 when j = 1 and l = 1 when j = 2, because the subgraph l2 j has been used up and transformed into r2 j by the application of the sub-rule %25. the subgraph r2 j thus created becomes part of rest′. a new copy of l2 has instead been suspended to the node l by the rule %add2 . note that k = l if i , j and k , l if i = j. after applying the embedding lemma, forms (3) and (2), to enlarge the rules by the control graph control′′ (the image of control′′ in control is determined by the node mapping), this yields the desired derivation step by parallel composition (lemma 2), by the construction of %a. ∃rest,rest′ ∈ graphs : g̃(i j) +1,2,3 rest %a ⇒h̃(kl) +1,2,3 rest′ ⇒ g %1 ⇒h ∨g %2 ⇒h: we proceed again by case analysis. the following is true for any match q of %a in g̃(i j): by construction of control′′ and control, q must assign either 4 to 0 and 5 to j, or 5 to 0 and 4 to i. in the first case, we seek to arrive at the conclusion that g %1 ⇒h, the second case is again completely analogous and will, mutandis mutatis, lead to g %2 ⇒h. the derivation step using %a is equivalent to a parallel composition of the following two derivation steps: the first step is an application of an embedded form of %01 with a match mapping 0 to 4. the other step leaves unchanged the graph suspended on 0, but performs the rest of %a. by lemma 3, we can extract the first derivation step by sequential decomposition, with suitable matches both mapping 4,5,6,7 to 0, j,i,3 in that order. g̃(i j) + 1,2,3 rest %1 4 + 4,5,6,7 idcontrol′′ =============⇒ h̃(i j) + 1,2,3 rest %′′′ ==⇒ h̃(kl) + 1,2,3 rest′, 11 / 22 volume 61 (2013) derivation languages of graph grammars where rest′ = rest +1,2,3 ( r2 j + l13 ) , k = i, l = 3− j, %′′′ = ( (%25 + %add1 + %add2 ) + 4,5,6,7 idcontrol′′ ) , because from h̃(i j) +1,2,3 rest = (control +1,2,3,4 (h0 +1,2,3 (l1i +1,2 l2 j))) +1,2,3 rest, with the given information about the match, a derivation step %′′′ must yield (control +1,2,3,4 (h0 +1,2,3 (l1i +1,2 r2 j))) +1,2,3 (rest +3,i (l13 + l2i)). this can again be rearranged into the desired form h̃(kl) +1,2,3 rest′. an application of the embedding lemma (4) and (3) to the first step, followed by the suspension lemma, allows us to arrive at the conclusion g %1 ⇒h. � we have represented the graph g̃(21) schematically and highlighted a match of %a in blue, in the case g ⇒%1 h. the second drawing represents the situation after the derivation step induced by this match. we have highlighted the resulting subgraph h̃(22) and represented rest′ in gray. 0 1 2 3 ggg l2l2l2 l1 0 1 2 3 0 1 2 3 h r2 l1 l2 l1 0 1 2 3 construction 5 (merging two letters) given a homomorphism h : t∗ → t′∗, t′ = (t −{a}+ {a1,a2}), and a grammar gg = (t,r,r,s), let ggh := (t′,r′,r′,s̃(12)), r′(a) := %a built from r′(a1), r′(a2) according to construction 4, ∀b , a, r′(b) := r(b)′ according to construction 3. closure under strictly letter-to-letter homomorphisms is an operation on classes of languages often considered in the literature on formal languages and sometimes denoted by h1. theorem 1 (closure under letter-to-letter homomorphisms) l$ is closed under h1. proof. assume, w.l.o.g., that the homomorphism h merges two letters a1 and a2 to a single image a and maps each other letter to itself. any letter-to-letter homomorphism between finite alphabets can be factored into finitely many such elementary mergers. let l = l$(gg). we shall show that construction 5 results in a grammar ggh such that l$(ggh) = h(l$(gg)). we prove the proposition by induction over the length of a derivation, on the hypothesis that g⇒∗wgg h iff there are two graphs rest, rest′ such that g̃ +1,2,3 rest⇒∗ h(w) ggh h̃ +1,2,3 rest′, where g̃ is one of selected revised papers from gcm 2012 12 / 22 eceasst g̃(11), g̃(12), g̃(21), g̃(22) and h̃ is one of h̃(11), h̃(12), h̃(21), h̃(22). the induction step is already proven in lemmata 5 and 6, since the required property that the nodes labeled ∗ are precisely 0,1,2,3 is fulfilled by all graphs reachable in gg as no derivation step can introduce a label occurring neither in the graph being transformed nor in the rule. � 3.2 context free languages and beyond from formal language theory, we know that reg ⊂ cf ⊂ cs ⊂ re, where reg stands for the regular languages, cf for the context free languages, cs for the context sensitive languages and re for all recursively enumerable languages. to each of the four classes corresponds a type of grammar, known as type 3, 2, 1 and 0, respectively [hu79]. in this subsection, we locate l$ above the context free languages in a first hierarchy result, cf ⊆l$. this result will immediately exposed as being quite weak, because our proof already shows the closure of l$ under intersections, from which follows cf ⊂l$. we also establish that the szilard languages are a subset of l$, and provide a grammar for the language {a 2n | n ∈n}. we shall start with the inclusion reg ⊆l$, which is also useful subsequently. the construction for transforming a nondeterministic finite automaton a into a graph grammar gg whose derivation language l$(gg) is the language l(a) accepted by a is straightforward. lemma 7 (regular languages) every regular language is in l$: reg ⊆l$. proof. given a finite automaton a = (q,t,δ,q0, qf ) with state set q, one initial state q0 ∈ q, alphabet t , transition relation δ ⊆ q×t × q, final states qf ⊆ q, let sa : q → graphs be the function assigning to each state q̂ a graph sa(q̂) with edge set v = q ∪ δ ∪ {ma | a ∈ t} ∪ {m∗} ∪ {m$}, the union assumed disjoint. that is, every state of a, as well as every transition, becomes a node; besides, some auxiliary nodes are introduced. the edge set e = {eqma | (q,a,q ′) ∈ δ} ∪ {emaq′ | (q,a,q ′) ∈ δ} ∪ {e(q,a,q′)ma | (q,a,q ′) ∈ δ} ∪ {eqm$ | q ∈ qf} ∪ {eq̂m∗} with s(eab) = a and t(eab) = b attaches the state nodes to the transition nodes and to the special marker nodes m∗, m$ and the transition nodes to state nodes and alphabet nodes. the marker nodes are distinguishable: ∀a ∈ t ∪{∗,$} : λ(ma) = a, all other nodes obtain a nondescript label x < t : ∀v ∈ v −{ma | a ∈ t ∪{∗,$}} : λ(v) = x. all edges also have the same label, λ(e) = x. we have represented an automaton a and the graph sa(q0). q0start q1 a b a b (q0,a,q0) q0 (q0,b,q1) q1 m∗ m$ the rules are the same for every automaton. for each letter a ∈ t , let %a and %å be the rules (the latter being an identical rule): 13 / 22 volume 61 (2013) derivation languages of graph grammars q q′ (q,a,q′) mam∗ q q′ (q,a,q′) ma q q′ (q,a,q′) ma m∗ ⊇ ⊆ q (q,a,q) mam∗ the end rule %$ removes the nodes labeled $ and ∗ and the edges attached to them, when they are linked to a common node q. q m$m∗ q q ⊇ ⊆ it is easy to see that (q,a,q′)∈δ iff sa(q) r(a) ⇒ sa(q′) or sa(q) r(å) ⇒ sa(q′). by induction over the length of an accepted or generated word, the fact that the end rule is applicable in sa(q) iff q ∈ qf , and an application of theorem 1 with the homomorphism mapping å and a to a for each a ∈ σ, hence the languages of the automaton a and the grammar are equal. � the extended dyck language [okh12] over m pairs of parentheses [1]1 ...[m]m and n extra symbols x1 ... xn, d̂m,n, is the language generated by the context free grammar with variables v = {s}, terminal alphabet ⋃ i∈{1,...,m}{]i,[i} ∪ {x j | j ∈ {1,...,n}} and productions {(s,s s ),(s,�)} ∪ {(s,[is ]i) | i ∈ {1,...,m}} ∪ {(s, x j) | j ∈ {1,...,n}}. these are a building block for the context free languages. we show that every such language is the derivation language of a graph grammar. lemma 8 (extended dyck languages) the extended dyck languages are in l$. proof. let xn = {x j | j ∈ {1...n}}, σm,n = {[i]i | i ∈ {1...m}}∪xn. given an alphabet x, let g(w) denote the graph encoding the word w ∈ x∗ in the following manner: there is one node ma labeled a for each a ∈ x, one node v−1 and one node v|w|, and one node vi for each i ∈{0,..., |w|−1}. each node vi, i ∈ {−1,..., |w|−1} is linked with an edge to its successor vi+1, and if i > 0 also to the node ma such that the i-th letter wi = a. the edges and the nodes vi are all labeled •. as an example, we have represented the graph g([1[2[1[1[2). [1 [2 let ggm,n = (σm,n,r,r,s) be a grammar where s is the graph with m + n unconnected nodes ma, one for each opening bracket a ∈{[i| i ∈{1...m}} and two nodes v0 and v1 linked by a single edge. the end rule r($) is the rule (s ←↩∅ ↪→∅) that just deletes a connected component isomorphic to s. all rules r(x j) are identical rules that check for the existence of a single • labeled node. all rules r([i) and r(]i) are mirror images of each other, l[i = r]i , k[i = k]i , l]i = r[i . this is r([i), which extends a chain of nodes by one node linked to m[i , using the graph as a stack. r([i) pushes a symbol on the stack while r(]i) removes the top stack symbol: selected revised papers from gcm 2012 14 / 22 eceasst [i [i [i ⊇ ⊆ we use a well-known alternative characterisation of the dyck languages: dm := d̂m,0 is the equivalence class [�]∼m of � under the congruence ∼m induced by {([i]i,�) | i ∈ {1,...,m}} (see berstel [ber79]). this is easily extended to the extended dyck languages, the congruence ∼m,n now being induced by {([i]i,�) | i ∈ {1,...,m}}∪{(x j,�) | j ∈ {1,...,n}}. this relation can be used as a confluent rewriting system, and there is a unique reduced word wred ∈ [w]∼m,n for any word w ∈ σm,n and w ∈ d̂m,n iff wred = �. we show by induction over the length n of a word w that w ∈ld(ggm,n) implies s w ⇒∗ ggm,n g(wred ), and the derivation is uniquely determined by the word w. the statement is obvious for w = �; it is also true for w = ux j for any x j ∈ xn and u ∈ σ∗m,n of length n since the rules r(x j) do not modify the graph. it is also true for any u[i, [i∈ σm,n because an opening bracket does not create any new opportunity for applying a reduction to the string. it is also true for any u]i, since r(]i) can only be applied when the last rule was r([i) or any r(x j), j ∈n (which can again be shown by induction, examining the effects and applicability of the rules) and has a unique effect: ]i takes back the effect of the last [i, which is to extend the graph by one node encoding an opening bracket. l$(ggm,n) ⊆ d̂m,n: we have just shown that any derivation labeled w ends in state g(wred ). the end rule can be applied only to a graph having g(λ) as a connected component. this can clearly not occur until the stack is cleared again, therefore w ∈ d̂m,n. d̂m,n ⊆l$(ggm,n): any word w ∈ d̂m,n is related to λ by the relations introduced at the start of this proof. we show how to construct a derivation by applying these relations in any direction, by induction over the number of rules needed to go from λ to w. the induction step hinges on the fact that r(x j) rules are always applicable and have no effect on the graph, while any sequence [i]i can also be inserted at any position in a derivation because starting at any reachable graph (induction) it can be applied, uniquely corresponding to a derivation with no effect. � the next definition serves to show closure of l$ under intersections, after which we will be able to prove the inclusion of the context free languages. definition 8 (label-disjoint union) given two graphs g and h, let g ÷ h := g(0) + h(1), where x(i) denotes the graph x with λx (x) = (x,i). let this operation be extended to morphisms and rules: if f1 : g1 → h1 and f2 : g2 → h2, let f1 ÷ f2 be the morphism such that ( f1 ÷ f2)v(n,i) = (( f1)v(n),i) and likewise for edges. let it be extended to grammars by removing all rules which are not present in one of the grammars: given gg1 = (t1,r1,r1,s1) and gg2 = (t2,r2,r2,s2), gg1 ÷gg2 is the grammar with rule labels t1 ∩t2, rules %1 ÷%2 for any pair of rules %1 and %2 with the same label via r1 and r2, start graph s1 ÷ s2. in the illustration, the background colour is used to depict the alteration of the labels. it must be thought of as a contribution to the edge and node colours. 15 / 22 volume 61 (2013) derivation languages of graph grammars rules labeled a in the original grammars from gg1: ⊇ ⊆ from gg2: ⊇ ⊆ rule labeled a in the resulting grammar in gg1 ÷gg2: ⊇ ⊆ by forming such disjoint unions of graphs and rules, parallel steps combining the individual effects on the component graphs are possible. the disjointness of the label sets prevents spurious derivation steps. lemma 9 the definition of ÷ for morphisms establishes a bijective correspondence between the morphisms from g1 ÷g2 to h1 ÷ h2 and the pairs of morphisms from g to h1 and g2 to h2. proof. every morphism from g1 ÷g2 to h1 ÷ h2 assigns the items of (g1)0 to items of (h1)0 and those of (g2)1 to items of (h1)1, independently, determining two morphisms. likewise, every pair of morphisms from g to h1 and g2 to h2 determines one from g1 ÷g2 to h1 ÷ h2. � the ÷ constructions are now leveraged to build a grammar that simulates two grammars gg1, gg2 simultaneously. it can perform a parallel derivation step that corresponds to one step in gg1 and one step with the same label in gg2, whenever these are applicable individually. lemma 10 (intersection closure) l$ is closed under intersections k, l ∈l$ implies k ∩l ∈l$, and the operation ÷ provides a construction for (l∈{ld,l$}) l(gg1)∩l(gg2) = l(gg1 ÷gg2). proof. ld(gg1)∩ld(gg2) = ld(gg1 ÷gg2), because the existence of any morphism in the combined grammar is now tantamount by lemma 9 to the conjunction of the existence of one morphism in the first grammar and one in the second grammar, rule applicability and effects clearly being preserved under bijective relabelings. the same holds for the end rule, therefore also l$($,gg1)∩l$($,gg2) = l$($,gg1 ÷gg2). � selected revised papers from gcm 2012 16 / 22 eceasst closure under intersections with regular languages follows from lemmata 7 and 10. corollary 1 (regular intersection closure) l$ is closed under intersections with regular languages. theorem 2 (context free languages) the context free languages are properly contained in l$: cf ⊂l$. proof. the context free languages are characterised as the images under letter-to-letter homomorphisms of the intersection of an extended dyck and a regular language (theorem 3 in [okh12]). l$ contains the extended dyck languages and is closed under the letter-to-letter homomorphism by theorem 1 and regular intersection by corollary 1. the inclusion is proper by the closure under all intersections (lemma 10), which the context free languages lack. � we now go from the languages defined by chomsky grammars to the derivation languages of these grammars, the szilard languages [ms97]. definition 9 (szilard languages) the szilard language of a chomsky type 0 grammar g is the set of images of the terminal derivations of g under a bijective labeling of the productions. by mateescu and salomaa [ms97], it is known that all szilard languages are context sensitive. proposition 1 (szilard languages) the szilard languages are in l$: sz ⊂l$. proof. this proposition can be seen by encoding each word composed of terminals and nonterminals as a linearly shaped graph with two dummy nodes at the ends, a chain of nodes representing the positions in the currently derived word, which are linked to alphabet nodes: for each terminal or non-terminal a one node ma with λ(ma) = a, the links representing the letters at each position. it is the same encoding as in the proof of lemma 8. the start state for a grammar with non-terminals n = {s, a} and terminals t = {a,b} is shown in the following picture. s a a b each production as a rule replacing a fixed, known portion of the string by another sequence of terminals and non-terminals. a production aa → aa, for instance, gives the following rule: a a a a a a ⊇ ⊆ termination, that is derivation of a terminal word, can be recognised by using as the left hand side of the end rule a graph consisting of |n| nodes, one labeled with each non-terminal, and 17 / 22 volume 61 (2013) derivation languages of graph grammars deleting these. when no more nodes use these labels, a terminal word has clearly been derived, and only then there are no more edges inhibiting the application of the end rule. clearly, the szilard language of any given type 0 (or type 1, type 2) grammar is obtained in this way. � to finish the section, we demonstrate that another frequently seen non-context-free language is the derivation language of a graph grammar. proposition 2 (powers of 2) the graph grammar gg from the following construction 6 has the derivation language l$(gg) = {a 2n | n ∈n}. construction 6 (powers of 2) let gg be the grammar with rule alphabet {a,$}, start graph s and end rule as follows (node labels are indicated, white nodes are labeled •, as are edges): ∗ $ $ $ ∗ $ ∗ $ ∗ $ ⊇ ⊆ the rule r(a) moves the ∗ labeled node along an edge, deletes the edge and replaces it with a new node labeled • and two edges: ∗ ∗ ∗ ⊇ ⊆ proof. by inspection, the word aa corresponds to a single possible derivation sequence and enables $ at every step; it can be shown by induction over the length of a word that when the ∗ labeled marker has reached the cycle, it can only travel around the cycle, doubling its length every time it reaches the node linked to the $ labeled marker. the induction hypothesis is: hypothesis after n ≥ 2 derivation steps with the rule a, a unique graph is reached. in this state, the unique node m∗ labeled ∗ is connected with an edge to the node which is on a cycle of length n = 2k + j, 2k > j, and there are no outgoing edges from the cycle to • labeled nodes, and the node connected to m∗ is 2k − j mod 2k edges away in forward direction from the unique node on the cycle connected to a node labeled $, and 2 j edges in backward direction. therefore if j = 0, then the word ak has been read and the node connected with ∗ is also connected to a node labeled $ and so the end rule can be applied. otherwise, ak does not enable the end rule. the hypothesis is true for n = 2 by inspection; if it is true for n = 2k + j, then also for n + 1 because the cycle makes only one match of rule a possible, whose effect is to reduce the number of edges in the forward direction by one and increase the number of edges in the backward direction by two. the cycle structure is preserved, and the number of ∗ labeled nodes is not changed. the number of and edges connected to $ labeled nodes are not changed. � selected revised papers from gcm 2012 18 / 22 eceasst 4 limitations graph grammars provide a very powerful mechanism for the generation of string languages as derivation languages. in this section, we examine some of the limitations of this mechanism. we present an upper bound on the nondeterministic complexity for the recognition of a derivation language. we then use known results about the context free languages to show that many other questions about general derivation languages, such as the inclusion problem, are undecidable, and that applying deleting homomorphisms to them yields the recursively enumerable languages. proposition 3 (space and time bound) polynomial time and o(n log n) space bounds for the problem w∈?l$(gg) are attainable simultaneously with a nondeterministic turing machine: l$ ⊆ np, l$ ⊆ nspace(n log n) proof. a direct simulation of a derivation of length n of the grammar by a nondeterministic turing machine is possible in o(n log n) space and polynomial time. each finite graph with v nodes and e edges can be represented as a list of node identifiers and labels, followed by an adjacency list carrying also the edge labels. if node identifiers are numbers not exceeding v (or at least bounded by v times a constant factor), this takes o((v + e) log v) space. a potential match g of a rule % is represented by flagging |vl| nodes and |el| edges with an annotation: either a node or edge is not in g(l), or it is to be deleted, or preserved. the preimage via g is also in the annotation. since rules have constant size throughout the derivation, this takes only linearly more space over the bare graph representation. rule applicability comes down to checking the dangling condition, which is possible in polynomial time and very little space by searching for unflagged edges attached to nodes flagged for deletion. rule application involves adding at most |vr| new nodes (precisely c% = |vr|−|vl| new nodes) and |er| new edges, which may increase the space needed for node identifiers: therefore the turing machine first deletes the entries for the obsolete nodes and edges in polynomial time and no excess space, then calls a routine to increase the space allocated per node identifier to dlog v + c%e, for example in linear space and quadratic time by using a work tape to perform the operation while copying. then it adds the c% new nodes (for which space has been left blank at the end of the node list) and |er|− |el| new edges and clears all flags. looking up the source and target node labels for the new edges can be done in polynomial time by going through the annotations. the number of nodes and edges involved (added) in a derivation step is constant. so during and after the application of n rules, the length of the representation is increased to at most o((v + e) log v) with v and e linear in n. � undecidability of the termination of graph rewriting is already well known (see plump [plu98]). indeed, a graph grammar can simulate the workings of a turing machine, but only with a derivation sequence of length proportional to the length of the computation. if unlabeled steps are allowed, then the whole set of recursively enumerable languages is obtained: closure under arbitrary homomorphisms, which may also delete letters, is an operation on language classes often considered in the literature on formal languages, sometimes denoted by ĥ. 19 / 22 volume 61 (2013) derivation languages of graph grammars lemma 11 (the effect of deleting homomorphisms) the closure of the derivation languages l$ under deleting homomorphisms is the family of recursively enumerable languages: re = ĥ(l$). proof. we slightly modify the usual proof [hu79, kud04] of the fact that the emptiness problem for the intersection of two context free languages is undecidable, by simulating the elementary steps of any given turing machine with two context free languages, one producing sequences of correct steps at even positions (2i,2i + 1) and the other one doing so at odd positions (2i + 1,2i + 2). we refer to the literature and follow the proof in [hu79], modifying it to write out the input word in a special alphabet at the beginning of the computation. upon reaching a configuration where the turing machine halts in an accepting state, the derivation in the simulating grammar terminates with $. application of the deleting homomorphism to remove the whole subsequent calculation, however long it may be, then results in l ∈ ĥ(l$). on the other hand, all images under deleting homomorphisms of l$ languages are recursively enumerable: simulate the given graph grammar breadth-first, output the images (if any) under the homomorphism of the labels of the rules used, and accept once there is a valid match for the termination rule. � proposition 4 (undecidability) the following questions are undecidable for l$ languages given by grammars gg, gg′ in general: totality, equivalence, inclusion, regularity, emptiness. proof. decidability of the word problem follows from proposition 3. all questions undecidable [kud04] for context free languages (given as push-down automata or equivalently as context free grammars) are undecidable for l$ languages. because of lemma 10 there is furthermore an effective way of constructing a grammar outputting the intersection of two context free languages, but it is undecidable whether the intersection of two context free languages is empty. � the following table recapitulates the decidability results. question formal description decidable? word problem w ? ∈l$(gg) + totality l$(gg) ? = t∗ – equivalence l$(gg) ? =l$(gg ′) – inclusion l$(gg) ? ⊆l$(gg ′) – regularity l$(gg) ? ⊆reg – emptiness l$(gg) ? =∅ – 5 conclusion and outlook these are the relations of l$ and the chomsky families and the szilard languages: reg ⊂ cf ⊂ cs ⊂ re sz⊃l$h1(l$) ⊂ ⊂ ĥ(l$) = = ⊂ ⊂ selected revised papers from gcm 2012 20 / 22 eceasst for easy reference, we tabulate the main results of the paper and their dependencies. reference result dependencies theorem 1 l$ = h1(l$) lemma 7 reg ⊆l$ theorem 1 lemma 8 d̂m,n ∈l$ lemma 10 k, l ∈l$ ⇒ k ∩l ∈l$ theorem 2 cf ⊂l$ theorem 1, lemmata 7, 8, 10 proposition 1 sz ⊂l$ proposition 6 {a2 n | n ∈n} ∈l$ proposition 3 l$ ⊆ np,nspace(n log n) lemma 11 re = ĥ(l$) theorem 2, lemma 10 proposition 4 decidability issues theorem 2, lemma 10, proposition 3 further work in progress suggests a large array of closure properties, and the inclusion of several well studied supersets of the context free languages in l$. the comparison with petri net languages with various acceptance conditions has also been an object of our attention, since petri nets are an important subclass of graph grammars. several questions remain open. first of all, we do not know of a criterion like a pumping lemma to place a language outside of l$. also, answers to these questions are still missing: l ∈l$⇒(σ ∗−l) ∈l$? is l$ closed under complementation? l$⊆cs? are all derivation languages context sensitive? cs⊆l$? are all context sensitive languages derivation languages? the second question would be answered in the affirmative if the space requirements for recognition from proposition 3 could be reduced from o(n log n) to o(n). the statement of the third question should not be expected to hold, since then there would be a graph grammar whose derivation language is the pspace complete language of true quantified boolean formulae [hu79], highly unlikely in the light of proposition 3. if the language lp ∈ cs of all words from {a}∗ of prime length could be shown not to be a derivation language, the first and third questions would have a negative answer, since its complement {a}∗−lp is indeed a derivation language (although we have not shown it here). acknowledgements the author gratefully acknowledges the anonymous reviewers, whose comments helped greatly towards improving this paper. many thanks to annegret habel for providing valuable criticism at several readings. bibliography [ber79] j. berstel. transductions and context-free languages. teubner, 1979. [cor95] a. corradini. concurrent computing: from petri nets to graph grammars. volume 2, pp. 56–70. elsevier, 1995. 21 / 22 volume 61 (2013) derivation languages of graph grammars [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer, 2006. [ehr79] h. ehrig. introduction to the algebraic theory of graph grammars (a survey). lncs 73, pp. 1–69. springer, 1979. [hu79] j. e. hopcroft, j. d. ullman. introduction to automata theory, languages, and computation. addison-wesley, 1979. [hö75] m. höpner. eine charakterisierung der szilardsprachen und ihre verwendung als steuersprachen. in gl-4.jahrestagung. lncs 26, pp. 113–121. springer, 1975. [jan87] m. jantzen. language theory of petri nets. lncs 254, pp. 397–412. springer, 1987. [kkk06] h.-j. kreowski, r. klempien-hinrichs, s. kuske. some essentials of graph transformation. in recent advances in formal languages and applications. studies in computational intelligence 25, pp. 229–254. springer, 2006. [kud04] m. kudlek. context-free languages. in formal languages and applications. volume 148, pp. 97–116. springer, 2004. [mäk98] e. mäkinen. a bibliography on szilard languages. bulletin of the eatcs 65:143– 148, 1998. [ms97] a. mateescu, a. salomaa. aspects of classical language theory. in rozenberg and salomaa (eds.), handbook of formal languages, vol. 1: word, language, grammar. chapter 7. springer, 1997. [okh12] a. okhotin. non-erasing variants of the chomsky–schützenberger theorem. in developments in language theory. lncs 7410, pp. 121–129. springer, 2012. [plu98] d. plump. termination of graph rewriting is undecidable. volume 33(2), pp. 201– 209. ios press, 1998. [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformations, volume 1: foundations. world scientific, 1997. selected revised papers from gcm 2012 22 / 22 introduction graph grammars closure properties and relation to other families closure under rule relabelings context free languages and beyond limitations conclusion and outlook cotransforming grammars with shared packed parse forests electronic communications of the easst volume 73 (2016) graph computation models selected revised papers from gcm 2015 cotransforming grammars with shared packed parse forests vadim zaytsev 21 pages guest editors: detlef plump managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst cotransforming grammars with shared packed parse forests vadim zaytsev universiteit van amsterdam, the netherlands, vadim@grammarware.net abstract: sppf (shared packed parse forest) is the best known graph representation of a parse forest (family of related parse trees) used in parsing with ambiguous/conjunctive grammars. systematic general purpose transformations of sppfs have never been investigated and are considered to be an open problem in software language engineering. in this paper, we motivate the necessity of having a transformation operator suite for sppfs and extend the state of the art grammar transformation operator suite to metamodel/model (grammar/graph) cotransformations. keywords: cotransformation, generalised parsing, parse graphs 1 motivation classically, parsing consumes a string of characters or tokens, recognises its grammatical structure and produces a corresponding parse tree [asu85]. a more modern perspective is that parsing recognises structure and expresses it explicitly [zb14]. in many situations, trees appear to be unsatisfactory target data structures: they can express hierarchy easily, but any other structural commitments require special tricks and encodings, which are much less preferable than switching to graphs or pseudographs [sl13]. the most common scenarios include expressing uncertainty (e.g., in generalised parsing), maintaining several structural views (e.g., in the style of boolean grammars) or manipulating recursive structures (e.g., with structured graphs). generalised parsing algorithms (glr [tom85], sglr [vis97], gll [sj10a], riglr [sj05], etc.) differ from their classic counterparts in dealing with ambiguity [bsvv02, bv11]: instead of trying to avoid, ignore or report ambiguous cases, they are expressed explicitly in so called parse forests. formally, a parse forest is a set of equally grammatically correct parse trees. some of them may be semantically different, which makes such ambiguity significant and usually undesirable. in practice, such sets usually need to be filtered or ranked in order to make full use of the available tree-based approaches to program analysis and transformation. in boolean grammars [okh04] and conjunctive grammars [okh01], we can use conjunctive clauses in a grammar to explicitly specify several syntactically different yet equally grammatical views of the same input fragment — they can be semantically equivalent [sc15] or one branch strictly more expressive than the other [zay13]. parsing techniques can utilise such specifications to create special kinds of nodes in a parse tree whose descendant subtrees share leaves [okh13, ste15]. shared recursive structures are also facilitated by parametric higher-order abstract syntax [pe88, dps97, chl08]. it is an advanced method with high expressiveness, but it often requires similarly advanced techniques like multilevel metareasoning [ma03] and demands the use of automated theorem provers [dfh95, rhb01]. for now we will focus on the first two cases, since both kinds of structures defined by those two related approaches conceptually are parse forests. 1 / 21 volume 73 (2016) mailto:vadim@grammarware.net cotransforming grammars with shared packed parse forests this paper is an endeavour to advance the theory and practice of transformation of parse forests — specifically, coupled transformations (in short, cotransformations) of grammars as structural definitions of ambiguous languages and graphs representing sets of trees conforming to them. this domain of software language engineering is underdeveloped, which was pointed out as one of the major open problems in modern software language engineering by james cordy and explained in his recent keynote at the oopsle workshop [bz15, §3.1]. in the next section, we will provide some minimal background knowledge needed to appreciate the rest of the paper. then, in section 3 we will define the problem we can solve and its implications. section 4 is the main section which introduces the operator suite for grammar-based gardening and proposes a classification of its operators. section 5 contains links to related and future work, and section 6 concludes the paper. 2 background there have been various attempts in the past to represent parse forests. the earliest ones required a grammar to be in a chomsky normal form [cho59] — theoretically a reasonable assumption since any context-free grammar can be normalised to cnf, but ultimately we need a parse forest for the original grammar, not for the normalised one, which would require bidirectional grammar transformations [zay12] to be coupled with tree and forest transformations. such a setup is far from trivial and thus not practically feasible. the next attempt in representing parse forests revolved around tree merging [ear68]: such a parse forest representation would result in a tree-like dag with all the edges of all the trees in the forest. this is obviously an overapproximation of the forest (see figure 1), which requires additional information in order to be unfolded into a set of trees — in other words, in order for any sensible manipulation to happen. obviously, having a data structure that requires so much nontrivial postprocessing overhead, is highly undesirable. the best representation of a conceptual parse forest (a set of trees with equal lists of leaves) so far is a so-called shared packed parse forest [tom85, §2.4], sppf from now on: its components are merged from the top until the divergent nodes, and due to maximal sharing the leaves and perhaps even entire subtrees grouping leaves together, are also merged. an example of such a graph is given on figure 2. formally, an sppf is an acyclic ordered directed graph where each edge is a tuple from a vertex to a linearly ordered list of successors and each vertex may have more than one successor list. if v is a set of vertices, then edges are: e ={〈vi,(vi1,vi2,...,viki)〉|vi ∈v,vi j ∈v}⊆v ×v ∗ sppf-like structures are used nowadays both in software language toolkits that allow explicit ambiguities, such as rascal [ksv09], and those that allow explicit conjunctive clauses, such as txl [ste15]. for a detailed view on the implementation details we refer the readers to a paper on aterms [bjko00]. the theory of transformations of sppfs is underdeveloped — they work exactly like transformations on trees if no shared nodes are present around the transformation point, and are unreliable and unpredictable otherwise. we would like to improve the situation by providing a toolkit for forest migration — i.e., transformations of sppfs inferred from grammar evolution steps. selected revised papers from gcm 2015 2 / 21 eceasst e e 2 + 2 + 2 e e 2 + 2 2 + e e 2 + 2 +e 2 + 2 e e 2 + 2 +e 2 + 2 e 2 + 2 e ::= e + e; e ::= 2; 2+2+2 (a) (b) (c) (d) (e) (f) (g) figure 1: demonstration that the earley representation overapproximates parse forests: (a) a simple ambiguous grammar example; (b) a term with ambiguous parse; (c)&(d) correct parses; (e) the graph representation of the forest suggested by earley [ear68]; (f)&(g) incorrect parse trees that are well-formed according to the grammar (a) and covered by the parse tree representation (e), but not corresponding to the actual term (b). 3 transformation for many years trees have been the dominant data structure for representing hierarchical data in software language processing. they are remarkably easy to define, formalise, implement, validate, visualise and transform. there are many ways to circumvent data representation as graphs by considering a tree together with a complementary component such as a relation between its vertices that would have turned a tree into a cyclic graph, as well as many optimisations of graph algorithms that work on skeleton trees of a graph. take, for instance, traversing a tree — it can be done hierarchically from the root towards the leaves or incrementally from the leaves towards the root, each case guaranteed termination even if the traversal is not supposed to stop when a match is made. this naturally provides us with four traversal strategies found in metaprogramming: bottom-up-continue, bottom-up-break, top-down-continue and top-downbreak [vbt98, bhko02, ksv09]. more sophisticated and flexible traversal strategies exist but are less in demand — for powerful strategic programming frameworks and paradigms we refer the readers to stratego [vis01], strafunski [lv03], syb [lj04], cω [bms05], nuthatch [bl13], structure-shy programs [cv11], generic fp [jj97, hin00], etc. a detailed and only slightly outdated overview of visiting functions, strategic programming and typed/untyped rewriting can be found in the work of van den brand et al [bkv03] and the bibliography thereof. this section is focused on finding existing techniques that can be or are in fact sppf transformations. 3 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests e e 2 + 2 + 2 e e + 2 e e e e e e e1 e2 e3 e4 e5 e6 t1 t2 t3 t4 t5 t6 t7{ 〈e1,(e2,t6,t7)〉,〈e1,(e4,t4,e6)〉,〈e1,(t1,t2,e3)〉, 〈e2,(e4,t4,t5)〉,〈e2,(t1,t2,e5)〉,〈e3,(e5,t6,t7)〉,〈e3,(t3,t4,e6)〉, 〈e4,(t1,t2,t3)〉,〈e5,(t3,t4,t5)〉,〈e6,(t5,t6,t7)〉 } figure 2: one the left, an sppf graph resulted from parsing the input “2+2+2+2” with the grammar from figure 1 (a). on the right, there are five parse trees in a forest, which are packed in a triple ambiguity, two of subgraphs of which have double ambiguities. all of them share leaves and subtrees whenever possible. below the pictures we show its formal representation as an ordered directed graph. 3.1 disambiguation one of the relatively well-researched kind of sppf transformations is disambiguation — it is commonly practised with ambiguous generalised parsing because static detection of ambiguity is undecidable for context-free grammars [can62]. however, most of the time the intention of an average grammarware engineer is to produce one parse tree, so this line of research is mostly about leveraging additional sources of information to obtain a parse tree from a parse forest. there are three main classes of disambiguation techniques: • ordered choice, dynamic lookahead and other conventions aimed to prevent ambiguities altogether or avoid them. these are fairly static, relatively well-understood and widely used in txl [dcms02], antlr [pf11] and peg [for04]. • follow/precede restrictions, production rule priorities, associativity rules and other annotations for local sorting (preference, avoidance, priorities) that help to prune the parse forest during its creation. since these are algorithmic approaches in a sense that they modify the generation process of an sppf and thus are not proper mappings from sppfs to sppfs, we will not consider them in the rest of the paper and refer to other sources primarily dedicated to them [bsvv02, bv11]. • disambiguation filters that are run after the parsing process has yielded a fully formed selected revised papers from gcm 2015 4 / 21 eceasst sppf: their main objective is to reduce the number of ambiguities and ultimately to shave all of them off, leaving one parse tree. an example of this would be how processing production rules marked for rejection is done for sglr [bsvv02] and gll [bv11] — even though recursive descent parsers can handle an equivalent construct (and-not clause) during parsing without any trouble [sc15]. formally speaking, the first class never produces parse forests; the second class works with disambiguators (higher order functions that take a parser and return a parser that produces less ambiguous sppfs) [bsvv02]; the third class uses filters (functions that take an sppf and produce a less ambiguous sppf) [kv94]. in some sources approaches with disambiguators are called “semantics-directed parsing” and approaches with filters are called “semantics-driven disambiguation” [bkmv03], since both indeed rely on semantic information to aid in the syntactic analysis. disambiguation filters are still but a narrow case of sppf transformation, but they have apparent practical application and are therefore well-researched. 3.2 grammar programming grammar programming is like normal programming, but with grammars: there is a concrete problem at hand which can be solved with a grammar, which is then being adjusted until an acceptable solution emerges. a representative pattern here is working with a high level software artefact describing a language (we assume it to be a grammar for the sake of simplicity, but in a broad sense it can be a schema, a metamodel, an ontology, etc), from which a tool solving the problem at hand is inferred automatically. there are at least three common approaches to grammar programming: manual, semi-automated and operator-based. manual grammar programming involves textual/visual editing of the grammar file by a grammarware engineer. it is the easiest method in practice and is used quite often, especially for minor tweaks during grammar debugging. however, it leads to hidden inconsistencies within grammars (which require advanced methods like grammar convergence to uncover [lz11]), between changed grammars and cached trees (which demand reparsing) and between grammars and program transformations (which requires more manual labour). semiautomated grammar programming adds a level of automation to that and thus is typically used in scenarios when a baseline grammar needs to be adjusted in different ways to several tasks (parsing language dialects, performing transformations, collecting metrics, etc). usually the grammarware toolkit provides means to extend the grammar or rewrite parts of it — examples include txl [dcms02], gdk [klv02] and grk [lä05]. arguably the latter two of these examples also venture into the next category since they contain other grammar manipulation instruments like folding/unfolding. if we extend this arsenal with even more means like merging nonterminals, removing grammar fragments, injecting/projecting symbols from production rules, chaining/unchaining productions, adding/removing disjunctive clauses, permuting the order and narrowing/widening repetitions, we end up having an operator suite for grammar programming. the advantage of having such a suite lies in the simple fact that each of the operators can be studied and implemented in isolation, and the actual process of grammar programming will involve calling these operators with proper arguments in the desired order. examples of operator suites include fst [lw01], xbgf [lz11], ξbgf [zay12] and sleir [zay14b]. 5 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests 3.3 cotransformation we speak of cotransformations when two or more kinds of mutually dependent software artefacts are transformed together to preserve consistency among them: usually one changes, and others co-evolve with it [läm04]. naturally, the first cotransformation scenario we should think of, involves an sppf and a grammar that defines its structure. this change can be initiated from either side, let us consider both. assuming that we have a sequence of grammar transformation steps, we may want to execute them on the language instances (programs) as well, to make them compatible with the updated grammar. such a need arises in the case of grammar convergence [lz09], when a relationship between two grammars is reverse engineered by programming the steps necessary to turn one into the other, and a co-transformation can help to migrate instances obtained with one grammar to fit with the other. for example, we could have a grammar for the concrete syntax and a schema for serialisation of the same data — a transformation sequence that strips the concrete grammar from elements not found in the schema (typically terminals guiding the parsing process such as semicolons and brackets), could also be coupled with a transformation sequence that removes the corresponding parts from the graphs defined by them (e.g., a parse tree and an xml document). consider another scenario where we have the change on language instances and want to lift it to the level of language definitions. an example could be found in program transformation, a common software engineering practice of metaprogramming. if we want a refactoring like extracting a method, renaming a variable or removing a go-to statement, it is easy and practical to express it in terms of matching/rewriting paradigm: in spoofax [kv10], rascal [ksv09], txl [dcms02], atl [jab+06], xslt [kay07], etc. however, a correct refactoring should preserve the meaning of the program, and the first step towards that is syntactic correctness of this program. for non-refactoring transformations found in aspect-oriented development, automated bug fixing and other areas, we still want to ascertain the extent to which the language is extended, reduced or revised. in the case of strongly typed metaprogramming languages, they will not allow you to create any ill-formed output, but the development process can lead you to first specify a breaking transform and then cotransform the grammar so that it “fits” — which is what cotransformations are good for. 3.4 explicit versus implicit this was already mentioned before, but becomes a crucial point from now on: parse forests can arise from two different sources — conjunctive clauses in the grammar used for parsing and generalised parsing with ambiguous grammars. the latter case can be considered implicit conjunction, since it is present on the level of language instances but not on the grammar level. in that case, instead of a more cumbersome construction specifying a precise parse, we use a simpler grammatical definition which yields a forest. if a grammar is both conjunctive and ambiguous, this can lead to its both implicit and explicit conjunctive clauses to be found in sppfs — with no observable difference on an instance level. similarly, some of the transformations will “collapse” conjunctions, making one branch of a clause equal to another. formally, for an sppf node to have several branches means existence of several edges in the form 〈vi,(vi1,...,viki)〉, 〈vi,(v ′ i1,...,v ′ ik′i )〉, etc. when a transformation results selected revised papers from gcm 2015 6 / 21 eceasst language preserved language extended language reduced language revised sppfs preserved bypass eliminate introduce import vertical horizontal designate unlabel anonymize deanonymize renamel renames detour addv addh define sppfs preserved or fail removev removeh undefine sppfs refactored unfold fold inline extract abridge unchain chain massage distribute factor deyaccify yaccify equate rassoc lassoc renamen clone concatt splitt appear widen upgrade unite removec disappear abstractize project concretize permute renamet splitn sppfs refactored or fail addc narrow downgrade redefine replace reroot fail inject table 1: the xbgf operator suite designed for convergence experiments [lz09, lz11] and updated here to the latest version of the grammarlab. columns of the table refer to the effects of the operators on the string language generated by a grammar; rows classify coupled effects on the sppfs. in all vi j becoming equal to the corresponding v′i j, such edges merge in the set. if such conjunctions represent ambiguities, this is disambiguation; if they represent parse views, it merges the views and makes them undistinguishable. 4 grammar-based gardening xbgf (standing for “transformations of bnf-like grammar formalism”) was an operator suite for grammar programming originally developed for grammar recovery and convergence experiments [lz09, lz11] and used for various grammar maintenance tasks afterwards — e.g., for improving the quality and maturity of grammars in the grammar zoo [zay15a, zay15b]. it has operators like eliminate(n) that checks whether the given nonterminal n is referenced anywhere in the grammar, and if not, removes its definition harmlessly; or operators like removen(x,y) that ensures that the nonterminal x is found in the grammar while y is not, and subsequently renames x to y; or even operators like redefine(pk, p′k) which removes all production rules pk defining one nonterminal from the grammar and replaces them with rules p′k defining the same nonterminal differently. these operators are relatively well-studied so that we can always make a claim about the effect that a transformation chain has on the language generated/accepted by the grammar. originally [lz11] xbgf operators were classified according to their preservation, increase, decrease or revision of the language within two semantics: the string semantics and the term semantics. the contribution of this section is their classification according to the coupled effect of the operators on the sppfs — see table 1 for the overview. 7 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests 4.1 sppfs preserved the best kind of cotransformation is the trivial one where the initial transformation triggers no change in the linked artefacts. 4.1.1 language-preserving operators many operators that preserve the (string) language associated with the grammar, also preserve the shared packed parse forests of the instances of this language. consider, for instance, the eliminate(n) operator we have just introduced in the previous paragraph: essentially, it removes an unused construct. since such a construct is unused in other production rules, it can never be reached from the root symbol, so it can also never occur in the graphs representing grammatically correct programs. hence, any sppf which was correct for grammar before the transformation, is still correct for the grammar with the unused part eliminated. similarly, introducing a language construct that was not previously there and is not (yet) linked to the root, has no impact on the forests. the same argumentation holds for decorating operators that add/remove labels to/from rules of the grammar or their subexpressions, or rename them. the last two operators seen in this cell on table 1 are vertical(n) and horizontal(n) — they facilitate switching between a horizontal style of grammatical definitions (i.e., “a ::= b | c;”) and a vertical one (i.e., “a ::= b; a ::= c;”) — some grammatical frameworks distinguish between them, but never on an instance level, since a realisation of a disjunction commits to one particular branch. hence, these operators also have no impact on sppfs. 4.1.2 language-extending operators in the same way rearranging alternatives in production rules discussed in the previous section, has no impact on sppfs, strict language extension operators like addv(p) and addh(p) have no impact on the forests. since disjunctive clauses are not explicitly visible in sppfs, any tree or forest derived with the original grammar, also conforms to the transformed one — the coupled instance transformation is trivial. there is even one operator which is very invasive on a grammar level while being entirely harmless on the instance level — define(p) is a variant of introduce(p) that adds a definition of a nonterminal that is used in some parts in the grammar reachable from the top symbol. having such nonterminals (called “bottom nonterminals”) in a grammar is not a healthy practice and is in general considered a sign of bad quality since it signals incompleteness [lv01, sv00, zay15a]. however, if we assume for the sake of simplicity that the default semantics for an undefined nonterminal is immediate failure (or parsing, generation, recognition or whatever the goal we need the grammar for), we may view define(p) as a language-extending (not a language-revising) operator. thus, if we do somehow obtain a well-formed sppf for such a grammar, it means it was constructed while avoiding the bottom nonterminal in question — hence, introducing it is no different than adding any other unreachable part we have seen so far and as such has no effect on the sppfs. selected revised papers from gcm 2015 8 / 21 eceasst 4.2 sppfs preserved, if possible there are several cases when we do not know in advance whether the cotransformation of sppfs will be possible: when it is, it is trivial. 4.2.1 language-reducing operators the operators removev(p) and removeh(p) are the counterparts of addv and addh operators we have considered above, which remove alternatives instead of adding them. the effect of such a transformation on a given sppf is easy to determine: if the alternative which is being removed, is exercised anywhere in the graph, the (co)transformation fails; if it is not, then no update of the forest is required. note that since all branches of the conjunctive clause are present in a given sppf, their removal requires a (possibly failing) refactoring: hence, removec(p) is considered later in subsubsection 4.3.2. the undefine(n) operator takes a valid nonterminal (defined and used within the grammar) and turns it into a bottom nonterminal (used yet not defined). it is a language reducing operator since its effect is a strict decrease in the number of possible correct programs: any parse graph containing a note related to the nonterminal n, becomes invalid. hence, the cotransformation for it checks whether such a node is indeed found in the given sppf: if yes, the transformation fails; if not, it immediately succeeds without updating the sppf. 4.3 sppfs refactored in the next subsections we consider cases of less trivial cotransformations, when language instances have to change to preserve conformance. 4.3.1 language-preserving operators many transformation operators that preserve the language associated with a grammar, still have some impact on the parse graphs. when the impact is easy to calculate in advance and thus encode the cotransformations as sppf refactorings that are parametrised in the same way the grammar transformations are, we can run rewritings like extract(p) on both grammars and sppfs. consider figure 3(a). it shows a simple grammar of a language {anbncn |n > 0} with three conjunctive views: the first one (a+ b+ c+) being the most intuitive and hence the most suitable for expressing patterns to be matched on programs; the remaining two being used to parse the language (which is well-known to be context-sensitive, so we need the power of at least two conjuncts to recognise it precisely). in a sense, the last two conjuncts represent a recogniser and the first one specifies a parser [sj10b, sc15]. when a transformation command extract(ap::=a+;) is executed, the effect on the grammar is apparent: a new nonterminal is introduced and two occurrences of its right hand side are replaced with it. the effect on an sppf is also quite easy to calculate: the node with a+ is replaced with a chain of two nodes (ap and a+); the incoming edges of the old node are connected as the incoming edges to the first one in the chain; the outgoing edges of the old node become the outgoing ones of the last in the chain (shown on figure 3(b), changes in bold green). a slightly more complicated case 9 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests s ::= a+ b+ c+ & ab c+ & a+ bc; ab ::= a ab? b; bc ::= b bc? c; a b c a+ ab b+ bc c+ s s s ab? ε bc? ε (a) a b c a+ ab b+ bc c+ s s s ab? ε bc? ε abp a b c ap ab b+ bc c+ s s s ab? ε bc? ε a+ s ::= ap b+ c+ & ab c+ & ap bc; ab ::= a ab? b; bc ::= b bc? c; ap ::= a+; s ::= abp c+ & ab c+ & a+ bc; ab ::= a ab? b; bc ::= b bc? c; abp ::= a+ b+; (b) (c) figure 3: sppf transformations coupled with extraction of a new nonterminal definition: (a) the original grammar and an sppf of the term “abc”; (b) after applying extract(ap::=a+;); (c) after applying extract(abp::=a+ b+;). the case of extracting one symbol is easier because an sppf already has nodes for such derivations and they only need to be chained; when more than one symbol is present in the right hand side of a production rule being extracted, then a new node is introduced for all matched patterns of use. s ::= abc & ab c+ & a+ bc; ab ::= a ab? b; bc ::= b bc? c; abc ::= a+ b+ c+; (a) (b) a b c a+ ab b+ bc c+ s s s ab? ε bc? ε abc s ::= a+ b+ c+ & ab c+ & a+ bc; ab ::= a ab? b; bc ::= b bc? c; a b c a+ ab b+ bc c+ s s s ab? ε bc? ε figure 4: sppf transformations coupled with inlining a nonterminal definition: (a) the original grammar and an sppf of the term “abc”; (b) after applying inline(abc). the inlining is fairly straightforward: the node in question is removed, and any previously incoming edge is replaced with the list of previously outgoing edges. selected revised papers from gcm 2015 10 / 21 eceasst renamen(x,y); p1 ... pn x s1 sk... ⇔ p1 ... pn s1 sk... inline-extract(x ::= s1 ···sk;); unfold-fold(x ::= s1 ···sk;); p1 ... pn x s1 sk... ⇔ p1 ... pn s1 sk... y x chain-unchain(y ::= x;); yaccify-deyaccify(x ::= y; x ::= xy;); ... p1 ... pk x y y ⇔ y+ y... p1 ... pk x xy xy y yaccify-deyaccify(x ::= y; x ::= yx;); figure 5: graph transformations coupled to some of the language preserving grammar transformation operators: the graph on the left always represents a pattern being detected, the graph on the right defines the rewriting, dotted lines show correspondence between vertices that must not be broken by the transformation, so all incoming and outgoing edges around corresponding elements are to be preserved. renamen is very simple and intuitive: any node marked with x is replaced with a node marked with y while the node context is preserved. inline-extract shortcuts all incoming/outgoing edges to a node in question or introduces the node at their junction, depending on which direction we execute the cotransformation. unfold-fold works identically on the instance level, the differences are only observable on the grammar level. chain-unchain cuts a node in two, one of which inherits the incoming and the other one the outgoing edges. on the right, we show specifications for two ways of using yaccify-deyaccify to turn a flatter iteration-based sppf into its deeper recursive counterpart, with left recursion variant on top and right recursion variant on the bottom. other operators of this category from table 1 are specified in a similar fashion. 11 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests is shown on figure 3(c), where a new vertex needs to be created when we extract(abp::=a+ b+;) because a symbol sequence a+b+ did not correspond to any vertex in the old graph. for all vertices that had outgoing edges to both a+ and b+, they got replaced by one edge to the new node. figure 4 shows the opposite scenario of inlining a nonterminal in a grammar, coupled with “inlining” corresponding vertices in a graph by drawing edges through it. by reusing our previous results on bidirectionalisation of grammar transformation operators [zay12], we can significantly decrease the space needed for defining coupled instance transformations. in short, we know that if enough information is provided (e.g., the entire production rule being unfolded, not just a nonterminal name of its left hand side), then pairs of inverse operators can be treated as one bidirectional entity that allows forward and reverse applications. indeed, as we have seen from figure 3 and figure 4, the output of one transformation has strong resemblance to the pattern responsible for applicability of the inverse transformation. an appropriately abstracted graph transformations of inline-extract and some other operators from table 1 are shown on figure 5. conceptually the impact of applying these operators is hardly surprising: chain replaces a node with a chain of two nodes; fold does the same folding we have seen above with extract, but without introducing a new nonterminal and possibly in a limited scope; rassoc and lassoc replace an iterative production rule with a recursive right/left associative one and thus stretche a node with multiple children into an unbalanced binary subtree; concatt and splitt merge or unmerge leaves, etc. 4.3.2 language-extending operators above we have considered grammar transformation operators that add disjunctive clauses to the grammar, obviously extending the associated language. in the case of extended context-free grammars (regular right hand side grammars) that allow metasyntactic sugar like optionals (x? effectively meaning x|ε ) and regular closures (x+ for transitive and x∗ for reflexive transitive), the widen(e,e′) operator is used to transform x? to x∗ or x to x+, together with the appear(p) operator that transforms ε to x? (effectively injecting an optional symbol). the coupled graph transformations for these cases usually boil down to inserting new vertices in the right places in order to keep the structural commitments up to date with the changed grammar. an even less trivial case of language extension is called “upgrading” and involves replacing a nonterminal by an expression that can be reduced to it. for instance, in a ::= b c; d ::= b|e; we can upgrade b in a (underlined) to d. such a transformation increases the string language associated with a grammar, as well as rearranges the relations between nonterminals. the coupled transformation for sppf is still simple and inserts an extra vertex for d between a and b (e is still not present in the sppf). the removec(p) operator that eliminates a conjunct, formally also increases the underlying language since any extra conjunct is possibly an extra condition to be met, and dropping it makes the combination weaker. technically the coupled sppf transform that removes a conjunct is a disambiguation filter, but it is not useful to count it as such since the ambiguity being removed is explicit (recall subsection 3.4). the graph transformations shown on figure 6 define these coupled rewritings more formally. there are some interesting corner cases like partial coinciding of yi and z j which are outside the scope of this paper but should be researched in the future. selected revised papers from gcm 2015 12 / 21 eceasst ⇔x y1 yk... z1 zn... x y1 yk... z1 zn...s? ε appear-disappear(x ::= y1 ···yk s? z1 ···zn); x+ ⇔ x* unite(x, y); widen(x+, x∗); ⇔ y1 yk... z1 zn... x y1 yk... x x removec(x ::= z1 ···zn); figure 6: graph transformations coupled to language-extending/-reducing grammar transformation operators, in the same format as used on the previous figure. appear-disappear matches the entire production rule in question but includes correspondences for each vertex so none of them can be damaged; the only modification is the addition of a new vertex with an empty value inside. unite adds all production rules of one nonterminal to another nonterminal, so all we need to do on the instance level is replace old nonterminal occurrences with the new one. widen is also unidirectional but changes only the type of one node, so the graph transformation specification looks very small. finally, removec removes a conjunctive clause from both the grammar and the graph defined by it. the transformation coupled to upgrade is not shown because it is identical to extract or fold which were already considered. 4.3.3 language-reducing operators the disappear(p) operator is used to transform x? or x∗ to ε . the coupled transformation on sppfs for it exists, but is subtly different from the ones being considered so far: it is inherently irreversible since if the sppf in question actually contains the x? with x as a child node, then that x is removed and lost. this is contrasting to folding/unfolding vertices and rearranging the edges around them. 4.3.4 language-revising operators the operators abstractize(p) and concretize(p) eliminate and introduce terminals from production rules (a common practice when mapping abstract syntax to concrete syntax, hence the 13 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests ⇔x y1 yk... z1 zn... x y1 yk... z1 zn...t abstractize-concretize(x ::= y1 ···yk t z1 ···zn); (only right to left:) project(x ::= y1 ···yk t z1 ···zn); permute(x ::= y1 ···yk;, x ::= yn1 ···ynk ;); figure 7: graph transformations coupled to language-revising grammar transformation operators, in the same format as used on the previous figures. the transformation on top uses the same pattern that we used before for appear-disappear, which was justified back then by the empty contents of the node and now by the node in question being terminal and hence having no children. the permute operator shuffles children of one node but preserves them, which is perfectly easy expressible by the correspondence relation of the graph transformation. names). since the terminals are present explicitly in the arguments, we can easily implement our coupled sppf transformations by inserting leaves and connecting them to the appropriate places to the graph, or removing them. these transformations can have a big effect on the sppf and are therefore more similar to the cotransformation from the previous paragraph. the project operator is a stronger version of abstractize or disappear that works on any symbol, but the transformation coupled with it, is the same: locate all the parts being removed from the grammar, remove them from the graph. the rest of language revising operators are coupled with less invasive rearrangements of the parse graph: reordering edges (permute), updating the contents of the leaves (renamet) and splitting one nonterminal into several (splitn). we show two interesting graph transformations on figure 7; the remaining ones are focused on the application scope instead of actual graph manipulation (splitn) or are identical to ones shown before (renamet is the same as renamen in all aspects). 4.4 sppfs refactored, when possible cotransformations from the previous section were necessary but could never fail: they were applicable to all possible graphs. let us now move on to cotransformations that could seem successful on the grammar level but fail on the instance level (causing the combination to fail). selected revised papers from gcm 2015 14 / 21 eceasst 4.4.1 language-reducing operators the narrow operator (the reverse of widen discussed above) and the downgrade operator (the reverse of upgrade) become simple parse graph rearrangements, if the constructs in the sppf happen to correspond to the new grammar, and fail otherwise. for instance, if a “wider” option is found in the sppf, we have no automated way to update it. formally the graph transformation of narrow will look similar to the ones we have seen in widen, renamen, unite, etc, but to the best of our knowledge there is no graph rewriting framework that allows expressing the “if this pattern is matched, give up and report an error” which is the crucial other side of this cotransformation. the same holds for upgrade which is partially applicable folding. the addc operator, on the other hand, shows us yet another class of cotransformations: namely, the one requiring reparsing. indeed, if the first branch of the conjunctive clause of s from figure 3 were to be introduced as a transformation step, we would need to reconnect the left subnode of s to the appropriate children, which formally corresponds to parsing. in the current prototype implementation we reuse the existing parser — to the best of our knowledge, other frameworks like txl [dcms02] do the same — instead of exploring possibly more efficient alternatives. pure graph transformations do not seem to be the right solution here, because if we are confined by their use, parsers need to be propagated along some scenarios — which could certainly lead to curious exercises in combining continuation passing with pair grammars, but the idea looks over-engineered at first glance. 4.4.2 language-revising operators the most brutal among language revising operators: redefine that replaces an entire nonterminal definition with a different one; replace doing the same for arbitrary subexpressions; reroot that changes the starting symbol of the grammar, — all require reparsing as a part of their cotransformation steps. 4.5 cotransformations destined to fail interestingly, there is one particular operator that is always doomed: inject(p) that works like appear but can insert any symbol anywhere in the grammar. in order to construct a coupled sppf transformation for inject, we need to know how to connect the new node to its children, but this information is ultimately lacking from the operator parameters. the only cases where it could have worked, are already covered by other operators (e.g., injecting terminals is concretize, injecting possibly empty symbols is appear). 5 related and future work the disambiguation of context-free grammars is a problem that was claimed to be solved as early as 1995 [che95] and is still actively researched in the 2010s [sch10, bv11, vt13]. there is a lot of work on disambiguation, parse forest pruning and shaving, and it remains to be seen whether our approach can usefully complement similarly-minded techniques from that area such as van den brand et al.’s implementation of disambiguation filters with term rewriting [bkmv03]. with 15 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests the technology from this paper we can perform “co-disambiguation” of grammars with forests. the obvious advantage of such a setup is that the presence of ambiguity on the instance level is trivially detectable while posing a long standing challenge on the grammar level. partial models [fsc12] allow for explicit modelling of uncertainty, of which ambiguity is an example of. there are many techniques accumulated in this area, allowing for decision making [aafl96], clustering and classification [mptv10], application of normal logic rules [ls02] — all in the face of uncertainty. a deeper investigation is needed to make strong claims about (in)compatibility of such approaches to transformation of ambiguous forests. recent advancements in delta-lenses make them an attractive mechanism for this endeavour [depc16]. walking this path will at least broaden the classic ambiguous grammar problem from purging uncertainty to tolerating it. stevenson [ste15] and cordy [bz15] argue for 5 ways to approach the problem of transforming sppfs: (1) abandon well-formedness, (2) use disjunction transformation semantics for conjuncts, (3) transform all views at once, (4) always trigger full reparse, (5) seamlessly work on canonic representation. strictly speaking, there are also some methods to adjust the semantics of the grammar/metamodel itself — redefine what constitutes grammaticality; examples can be found in older literature, based on logical representation of ambiguous terms [rae97], specificity rules for productions [ken90], etc. as said before, we are not the only ones trying to use computation models based on graphs instead of trees in software language engineering. it remains to be seen whether systematically using abstract syntax graphs [sl13] and general purpose graph transformation frameworks would be much different. as stated in the introduction, we deliberately focused our attention on methods that do not use higher order abstract syntax [pe88, dps97, chl08]. our approach is closer to pair/triple grammars that are commonly used to define graph-to-graph rewritings [pra71, sch95]. we have noticed that in our case this way could have profited from an extension allowing to match separately on the incoming edges and the outgoing ones instead of matching the entire vertex, but we have not explored this option in full, since it seemed to fall in a somewhat unexplored space between established forms of node rewriting [er97] and (hyper)edge rewriting [dkh97]. the approach to couple instance transformations to grammar transformations and not vice versa, that we decided to pursue, has its counterparts in other technological spaces such as modelware [gfd05] or xml [ll01] or databases [hhth02], obviously with transformations of metamodels or schemata as the starting point. cotransformations in general have been re-explained to some extent in this paper, but there exists a much more detailed introduction [läm04]. grammar mutations [zay12, zay14b] are systematic generalisations of grammar transformations used for this paper. there does not seem to be any fundamental problem in combining that generalisation with our couplings, but the implementation of coupled mutations remains future work. the classification of coupled sppf transformations from table 1 corresponds to the two kinds of negotiated evolution: “adaptation through tolerance” when sppfs are preserved and “through adjustment” when they are refactored [zay14a]. selected revised papers from gcm 2015 16 / 21 eceasst 6 conclusion in this paper, we have considered cotransformations of grammars together with shared packed parse forests defined by these grammars. that is, given a grammar g and a collection of graphs {fi} conforming to it, we can specify its evolution into an updated grammar g′ such that the graphs are migrated to conform to g′: g evolves g′ {fi} conforms 6 migrated coupledwww� wwww {f′j} conforms 6 an implementation of a transformation operator suite was proposed. each grammar change was coupled to one of the following: (1) no change in the parse graphs; (2) rearranging the graphs, implemented in triple graph-style rewritings; (3) introducing new elements to graphs based on operator arguments; (4) reparsing; (5) imminent failure. this classification is complementary to the previously existing ones based on preserving, increasing, reducing or revising the semantics chosen for the grammar. the examples given in the paper mostly refer to concrete grammars in the context of parsing, but the research was done with software language engineering principles, which means that the contribution is applicable to co-evolution of grammars in a broad sense such as ontologies, api, dsls, graph schemata, libraries, etc. we have used boolean grammars as the underlying formalism due to their power to naturally represent non-context-free languages, ambiguous generalised parses and parse views in a uniform way. this is the first project involving coupled transformations of boolean grammars. the computation model proposed in this paper, can be used for formalisations and proofs of certain properties of transformation chains; for grammar-based convergence; for manipulating parse views and in general for tasks involving synchronous consistent changes to boolean grammars and shared packed parse forests of grammatical instances. this is an area of rapidly growing interest in the software language engineering community, and its limits, as well as the extent of its usefulness, remain to be examined. 17 / 21 volume 73 (2016) cotransforming grammars with shared packed parse forests bibliography [aafl96] b. awerbuch, y. azar, a. fiat, f. t. leighton. making commitments in the face of uncertainty: how to pick a winner almost every time. in stoc. pp. 519–530. acm, 1996. doi: 10.1145/237814.238000 [asu85] a. v. aho, r. sethi, j. d. ullman. compilers: principles, techniques and tools. addison-wesley, 1985. [bhko02] m. g. j. van den brand, j. heering, p. klint, p. a. olivier. compiling language definitions: the asf+sdf compiler. acm toplas 24(4):334–368, 2002. doi: 10.1145/567097.567099 [bjko00] m. g. j. van den brand, h. a. de jong, p. klint, p. a. olivier. efficient annotated terms. software: practice & experience 30(3):259–291, 2000. [bkmv03] m. van den brand, s. klusener, l. moonen, j. j. vinju. generalized parsing and term rewriting: semantics driven disambiguation. entcs 82(3):575–591, 2003. doi: 10.1016/s1571-0661(05)82629-5 [bkv03] m. g. j. van den brand, p. klint, j. j. vinju. term rewriting with traversal functions. acm tosem 12(2):152–190, apr. 2003. doi: 10.1145/941566.941568 [bl13] a. h. bagge, r. lämmel. walk your tree any way you want. in icmt. lncs 7909, pp. 33–49. springer, 2013. doi: 10.1007/978-3-642-38883-5_3 [bms05] g. m. bierman, e. meijer, w. schulte. the essence of data access in cω . in ecoop. lncs 3586, pp. 287–311. springer, 2005. doi: 10.1007/11531142_13 [bsvv02] m. van den brand, j. scheerder, j. j. vinju, e. visser. disambiguation filters for scannerless generalized lr parsers. in cc. lncs 2304, pp. 143–158. springer, 2002. doi: 10.1007/3-540-45937-5_12 [bv11] b. basten, j. j. vinju. parse forest diagnostics with dr. ambiguity. in sle. lncs 6940, pp. 283–302. springer, 2011. doi: 10.1007/978-3-642-28830-2_16 [bz15] a. h. bagge, v. zaytsev. open and original problems in software language engineering 2015 workshop report. sigsoft se notes 40(3):32–37, 2015. doi: 10.1145/2757308.2757313 [can62] d. g. cantor. on the ambiguity problem of backus systems. journal of the acm 9(4):477–479, 1962. [che95] b. s. n. cheung. ambiguity in context-free grammars. in sac. pp. 272–276. acm, 1995. doi: 10.1145/315891.315991 [chl08] a. chlipala. parametric higher-order abstract syntax for mechanized semantics. in icfp. pp. 143– 156. acm, 2008. doi: 10.1145/1411204.1411226 [cho59] n. chomsky. on certain formal properties of grammars. information and control 2(2):137–167, 1959. doi: 10.1016/s0019-9958(59)90362-6 [cv11] a. cunha, j. visser. transformation of structure-shy programs with application to xpath queries and strategic functions. scp 76(6):516–539, 2011. doi: 10.1016/j.scico.2010.01.003 [dcms02] t. r. dean, j. r. cordy, a. j. malton, k. a. schneider. grammar programming in txl. in scam. ieee computer society, 2002. doi: 10.1109/scam.2002.1134109 [depc16] z. diskin, r. eramo, a. pierantonio, k. czarnecki. introducing delta-lenses with uncertainty. in bx. 2016. in print. selected revised papers from gcm 2015 18 / 21 http://dx.doi.org/10.1145/237814.238000 http://dx.doi.org/10.1145/567097.567099 http://dx.doi.org/10.1016/s1571-0661(05)82629-5 http://dx.doi.org/10.1145/941566.941568 http://dx.doi.org/10.1007/978-3-642-38883-5_3 http://dx.doi.org/10.1007/11531142_13 http://dx.doi.org/10.1007/3-540-45937-5_12 http://dx.doi.org/10.1007/978-3-642-28830-2_16 http://dx.doi.org/10.1145/2757308.2757313 http://dx.doi.org/10.1145/315891.315991 http://dx.doi.org/10.1145/1411204.1411226 http://dx.doi.org/10.1016/s0019-9958(59)90362-6 http://dx.doi.org/10.1016/j.scico.2010.01.003 http://dx.doi.org/10.1109/scam.2002.1134109 eceasst [dfh95] j. despeyroux, a. p. felty, a. hirschowitz. higher-order abstract syntax in coq. in tlca. lncs 902, pp. 124–138. springer, 1995. doi: 10.1007/bfb0014049 [dkh97] f. drewes, h.-j. kreowski, a. habel. hyperedge replacement graph grammars. in handbook of graph grammars and computing by graph transformation. pp. 95–162. world scientific publishing co., inc., 1997. [dps97] j. despeyroux, f. pfenning, c. schürmann. primitive recursion for higher-order abstract syntax. in tlca. lncs 1210, pp. 147–163. springer, 1997. doi: 10.1007/3-540-62688-3_34 [ear68] j. earley. an efficient context-free parsing algorithm. phd thesis, carnegie-mellon, aug. 1968. [er97] j. engelfriet, g. rozenberg. node replacement graph grammars. in handbook of graph grammars and computing by graph transformation. pp. 1–94. world scientific publishing co., inc., 1997. [for04] b. ford. parsing expression grammars: a recognition-based syntactic foundation. in popl. pp. 111– 122. acm, 2004. doi: 10.1145/964001.964011 [fsc12] m. famelis, r. salay, m. chechik. partial models: towards modeling and reasoning with uncertainty. in icse. pp. 573–583. ieee, 2012. doi: 10.1109/icse.2012.6227159 [gfd05] t. gîrba, j.-m. favre, s. ducasse. using meta-model transformation to model software evolution. entcs 137(3):57–64, 2005. doi: 10.1016/j.entcs.2005.07.005 [hhth02] j. henrard, j.-m. hick, p. thiran, j.-l. hainaut. strategies for data reengineering. in wcre. pp. 211– 220. ieee computer society, 2002. [hin00] r. hinze. a new approach to generic functional programming. in popl. pp. 119–132. acm, 2000. doi: 10.1145/325694.325709 [jab+06] f. jouault, f. allilaire, j. bézivin, i. kurtev, p. valduriez. atl: a qvt-like transformation language. in oopsla. pp. 719–720. acm, 2006. doi: 10.1145/1176617.1176691 [jj97] p. jansson, j. jeuring. polyp — a polytypic programming language extension. in popl. pp. 470–482. acm press, 1997. doi: 10.1145/263699.263763 [kay07] m. kay. xsl transformations (xslt) version 2.0. w3c recommendation, 23 january 2007. http:// www.w3.org/tr/2007/rec-xslt20-20070123. [ken90] r. kennaway. the specificity rule for lazy pattern-matching in ambiguous term rewrite systems. in esop. lncs 432, pp. 256–270. springer, 1990. doi: 10.1007/3-540-52592-0_68 [klv02] j. kort, r. lämmel, c. verhoef. the grammar deployment kit — system demonstration. entcs 65(3):117–123, 2002. doi: 10.1016/s1571-0661(04)80430-4 [ksv09] p. klint, t. van der storm, j. j. vinju. rascal: a domain specific language for source code analysis and manipulation. in scam. pp. 168–177. ieee computer society, 2009. doi: 10.1109/scam.2009.28 [kv94] p. klint, e. visser. using filters for the disambiguation of context-free grammars. in proceedings of the asmics workshop on parsing theory. pp. 1–20. 1994. [kv10] l. c. l. kats, e. visser. the spoofax language workbench: rules for declarative specification of languages and ides. in oopsla. pp. 444–463. acm, 2010. doi: 10.1145/1869459.1869497 19 / 21 volume 73 (2016) http://dx.doi.org/10.1007/bfb0014049 http://dx.doi.org/10.1007/3-540-62688-3_34 http://dx.doi.org/10.1145/964001.964011 http://dx.doi.org/10.1109/icse.2012.6227159 http://dx.doi.org/10.1016/j.entcs.2005.07.005 http://dx.doi.org/10.1145/325694.325709 http://dx.doi.org/10.1145/1176617.1176691 http://dx.doi.org/10.1145/263699.263763 http://www.w3.org/tr/2007/rec-xslt20-20070123 http://www.w3.org/tr/2007/rec-xslt20-20070123 http://dx.doi.org/10.1007/3-540-52592-0_68 http://dx.doi.org/10.1016/s1571-0661(04)80430-4 http://dx.doi.org/10.1109/scam.2009.28 http://dx.doi.org/10.1145/1869459.1869497 cotransforming grammars with shared packed parse forests [lä05] r. lämmel. the amsterdam toolkit for language archaeology. entcs 137(3):43–55, 2005. doi: 10.1016/j.entcs.2005.07.004 [läm04] r. lämmel. transformations everywhere. scp 52:1–8, 2004. doi: 10.1016/j.scico.2004.03.001 [lj04] r. lämmel, s. l. p. jones. scrap more boilerplate: reflection, zips, and generalised casts. in icfp. pp. 244–255. acm, 2004. doi: 10.1145/1016850.1016883 [ll01] r. lämmel, w. lohmann. format evolution. in retis. volume 155, pp. 113–134. ocg, 2001. [ls02] y. loyer, u. straccia. the well-founded semantics in normal logic programs with uncertainty. in flops. lncs 2441, pp. 152–166. springer, 2002. doi: 10.1007/3-540-45788-7_9 [lv01] r. lämmel, c. verhoef. semi-automatic grammar recovery. software—practice & experience 31(15):1395–1438, dec. 2001. [lv03] r. lämmel, j. visser. a strafunski application letter. in padl. lncs 2562, pp. 357–375. springer, 2003. doi: 10.1007/3-540-36388-2_24 [lw01] r. lämmel, g. wachsmuth. transformation of sdf syntax definitions in the asf+sdf metaenvironment. in ldta. entcs 44. elsevier, 2001. [lz09] r. lämmel, v. zaytsev. an introduction to grammar convergence. in ifm. lncs 5423, pp. 246–260. springer, feb. 2009. doi: 10.1007/978-3-642-00255-7_17 [lz11] r. lämmel, v. zaytsev. recovering grammar relationships for the java language specification. sqj 19(2):333–378, mar. 2011. doi: 10.1007/s11219-010-9116-5 [ma03] a. momigliano, s. ambler. multi-level meta-reasoning with higher-order abstract syntax. in fossacs. lncs 2620, pp. 375–391. springer, 2003. doi: 10.1007/3-540-36576-1_24 [mptv10] n. r. d. matteo, s. peroni, f. tamburini, f. vitali. of mice and terms: clustering algorithms on ambiguous terms in folksonomies. in sac. pp. 844–848. acm, 2010. doi: 10.1145/1774088.1774262 [okh01] a. okhotin. conjunctive grammars. journal of automata, languages and combinatorics 6(4):519–535, 2001. [okh04] a. okhotin. boolean grammars. information and computation 194(1):19–48, 2004. doi: 10.1016/j.ic.2004.03.006 [okh13] a. okhotin. conjunctive and boolean grammars: the true general case of the context-free grammars. computer science review 9:27–59, 2013. doi: 10.1016/j.cosrev.2013.06.001 [pe88] f. pfenning, c. elliott. higher-order abstract syntax. in pldi. pp. 199–208. acm, 1988. doi: 10.1145/53990.54010 [pf11] t. parr, k. fisher. ll(*): the foundation of the antlr parser generator. in pldi. pp. 425–436. acm, 2011. doi: 10.1145/1993498.1993548 [pra71] t. w. pratt. pair grammars, graph languages and string-to-graph translations. journal of computer and system sciences 5(6):560–595, 1971. doi: http://dx.doi.org/10.1016/s0022-0000(71)80016-8 [rae97] i. raeva. semantic interpretation of ambiguous statements, represented in a logical form. in developments in language theory. pp. 529–537. aristotle university of thessaloniki, 1997. selected revised papers from gcm 2015 20 / 21 http://dx.doi.org/10.1016/j.entcs.2005.07.004 http://dx.doi.org/10.1016/j.scico.2004.03.001 http://dx.doi.org/10.1145/1016850.1016883 http://dx.doi.org/10.1007/3-540-45788-7_9 http://dx.doi.org/10.1007/3-540-36388-2_24 http://dx.doi.org/10.1007/978-3-642-00255-7_17 http://dx.doi.org/10.1007/s11219-010-9116-5 http://dx.doi.org/10.1007/3-540-36576-1_24 http://dx.doi.org/10.1145/1774088.1774262 http://dx.doi.org/10.1016/j.ic.2004.03.006 http://dx.doi.org/10.1016/j.cosrev.2013.06.001 http://dx.doi.org/10.1145/53990.54010 http://dx.doi.org/10.1145/1993498.1993548 http://dx.doi.org/http://dx.doi.org/10.1016/s0022-0000(71)80016-8 eceasst [rhb01] c. röckl, d. hirschkoff, s. berghofer. higher-order abstract syntax with induction in isabelle/hol: formalizing the π -calculus and mechanizing the theory of contexts. in fossacs. lncs 2030, pp. 364–378. springer, 2001. doi: 10.1007/3-540-45315-6_24 [sc15] a. stevenson, j. r. cordy. parse views with boolean grammars. scp 97(1):59–63, 2015. doi: 10.1016/j.scico.2013.11.007 [sch95] a. schürr. specification of graph translators with triple graph grammars. in 20th international workshop on graph-theoretic concepts in computer science. pp. 151–163. springer, 1995. doi: 10.1007/3-540-59071-4_45 [sch10] s. schmitz. an experimental ambiguity detection tool. scp 75(1-2):71–84, 2010. doi: 10.1016/j.scico.2009.07.002 [sj05] e. scott, a. johnstone. generalized bottom up parsers with reduced stack activity. computer journal 48(5):565–587, 2005. doi: 10.1093/comjnl/bxh102 [sj10a] e. scott, a. johnstone. gll parsing. entcs 253(7):177–189, 2010. doi: 10.1016/j.entcs.2010.08.041 [sj10b] e. scott, a. johnstone. recognition is not parsing — sppf-style parsing from cubic recognisers. scp 75(1-2):55–70, 2010. doi: 10.1016/j.scico.2009.07.001 [sl13] b. c. d. s. oliveira, a. löh. abstract syntax graphs for domain specific languages. in pepm. pp. 87– 96. acm, 2013. doi: 10.1145/2426890.2426909 [ste15] a. stevenson. source transformations with boolean grammars. phd thesis, queen’s university, 2015. [sv00] m. p. a. sellink, c. verhoef. development, assessment, and reengineering of language descriptions. in csmr. pp. 151–160. ieee computer society, 2000. [tom85] m. tomita. efficient parsing for natural language: a fast algorithm for practical systems. kluwer academic publishers, 1985. [vbt98] e. visser, z.-e.-a. benaissa, a. p. tolmach. building program optimizers with rewriting strategies. in icfp. pp. 13–26. acm, 1998. doi: 10.1145/289423.289425 [vis97] e. visser. scannerless generalized-lr parsing. phd thesis, uva, 1997. [vis01] e. visser. stratego: a language for program transformation based on rewriting strategies. in rta. lncs 2051, pp. 357–362. springer, 2001. doi: 10.1007/3-540-45127-7_27 [vt13] n. vasudevan, l. tratt. detecting ambiguity in programming language grammars. in sle. lncs 8225, pp. 157–176. springer, 2013. doi: 10.1007/978-3-319-02654-1_9 [zay12] v. zaytsev. language evolution, metasyntactically. ec-easst; bx 49, 2012. [zay13] v. zaytsev. modelling robustness with conjunctive grammars. in sattose. july 2013. [zay14a] v. zaytsev. negotiated grammar evolution. jot; xm 13(3):1:1–22, july 2014. doi: 10.5381/jot.2014.13.3.a1 [zay14b] v. zaytsev. software language engineering by intentional rewriting. ec-easst; sqm 65, mar. 2014. [zay15a] v. zaytsev. grammar maturity model. in me. ceur 1331, pp. 42–51. ceur-ws.org, feb. 2015. [zay15b] v. zaytsev. grammar zoo: a corpus of experimental grammarware. scp 98:28–51, feb. 2015. doi: 10.1016/j.scico.2014.07.010 [zb14] v. zaytsev, a. h. bagge. parsing in a broad sense. in models. lncs 8767, pp. 50–67. springer, 2014. doi: 10.1007/978-3-319-11653-2_4 21 / 21 volume 73 (2016) http://dx.doi.org/10.1007/3-540-45315-6_24 http://dx.doi.org/10.1016/j.scico.2013.11.007 http://dx.doi.org/10.1007/3-540-59071-4_45 http://dx.doi.org/10.1016/j.scico.2009.07.002 http://dx.doi.org/10.1093/comjnl/bxh102 http://dx.doi.org/10.1016/j.entcs.2010.08.041 http://dx.doi.org/10.1016/j.scico.2009.07.001 http://dx.doi.org/10.1145/2426890.2426909 http://dx.doi.org/10.1145/289423.289425 http://dx.doi.org/10.1007/3-540-45127-7_27 http://dx.doi.org/10.1007/978-3-319-02654-1_9 http://dx.doi.org/10.5381/jot.2014.13.3.a1 http://dx.doi.org/10.1016/j.scico.2014.07.010 http://dx.doi.org/10.1007/978-3-319-11653-2_4 motivation background transformation disambiguation grammar programming cotransformation explicit versus implicit grammar-based gardening sppfs preserved language-preserving operators language-extending operators sppfs preserved, if possible language-reducing operators sppfs refactored language-preserving operators language-extending operators language-reducing operators language-revising operators sppfs refactored, when possible language-reducing operators language-revising operators cotransformations destined to fail related and future work conclusion more on graph rewriting with contextual refinement electronic communications of the easst volume 71 (2015) graph computation models selected revised papers from gcm 2014 more on graph rewriting with contextual refinement berthold hoffmann 20 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ more on graph rewriting with contextual refinement berthold hoffmann fachbereich mathematik und informatik, universität bremen, germany abstract: in grgen, a graph rewrite generator tool, rules have the outstanding feature that variables in their pattern and replacement graphs may be refined with meta-rules based on contextual hyperedge replacement grammars. a refined rule may delete, copy, and transform subgraphs of unbounded size and of variable shape. in this paper, we show that rules with contextual refinement can be transformed to standard graph rewrite rules that perform the refinement incrementally, and are applied according to a strategy called residual rewriting. with this transformation, it is possible to state precisely whether refinements can be determined in finitely many steps or not, and whether refinements are unique for every form of refined pattern or not. keywords: graph rewriting – rule rewriting – contextual hyperedge replacement 1 introduction everywhere in computer science and beyond, one finds systems with a structure represented by graph-like diagrams, whose behavior is described by incremental transformation. model-driven software engineering is a prominent example for an area where this way of system description is very popular. graph rewriting, a branch of theoretical computer science that emerged in the seventies of the last century [eps73], is a formalism of choice for specifying such systems in an abstract way [medj05]. graph rewriting has a well developed theory [eept06] that gives a precise meaning to such specifications. it also allows to study fundamental properties, such as termination and confluence. over the last decades, various tools have been developed that generate (prototype) implementations for graph rewriting specifications. some of them do also support the analysis of specifications: agg [ert99] allows to determine confluence of a set of rules by the analysis of finitely many critical pairs [plu93], and groove [ren04] allows to explore the state space of specifications. this work relates to grgen, an efficient graph rewrite generator [bgj06] developed at karlsruhe institute of technology. later, edgar jakumeit has extended the rules of this tool substantially, by introducing recursive refinement for sub-rules and application conditions [hjg08]. a single refined rule can match, delete, replicate, and transform subgraphs of unbounded size and variable shape. these rules have motivated the research presented in this paper. because, the standard theory [eept06] does not cover recursive refinement, so that such rules cannot be analyzed for properties like termination and confluence, and tool support concerning these questions cannot be provided. our ultimate goal is to lift results concerning confluence to rules with recursive refinement. so we formalize refinement by combining concepts of the existing theory, on two levels: we define a grgen rule to be a schema – a plain rule containing variables. on the meta-level, a schema is refined by replacing variables by sub-rules, using meta-rules based on contextual more on graph rewriting with contextual refinement hyperedge replacement [dhm12]. refined rules then perform the rewriting on the object level. this mechanism is simple enough for formal investigation. for instance, properties of refined rules can be studied by using induction over the meta-rules. earlier work [hof13] has already laid the fundaments for modeling refinement. here we study conditions under which the refinement behaves well. we translate these rules into standard rules that perform the refinement in an incremental fashion, using a specific strategy, called residual rewriting, strategy, and show the correctness of this translation. the examples in this paper arise in the area of model-driven software engineering. refactoring shall improve the structure of object-oriented software without changing its behavior. graphs are a straight-forward representation for the syntax and semantic relationships of objectoriented programs (and also of models). many of the basic refactoring operations proposed by fowler [fow99] do require to match, delete, copy, or restructure program fragments of unbounded size and variable shape. several plain rules are needed to specify such an operation, and they have to be controlled in a rather delicate way in order to perform it correctly. in contrast, we shall see that a single rule schema with appropriate meta-rules suffices to specify it, in a completely declarative way. the paper is organized as follows. the next section defines graphs, plain rules for graph rewriting, and contextual rules for deriving languages of graphs. in sect. 3 we define schemata, meta-rules, and the refinement of schemata by applying meta-rules to them, and state under which conditions refinements can be determined in finitely many steps, and the replacements of refined rules are uniquely determined by their patterns. in sect. 4, we translate schemata and meta-rules to standard graph rewrite rules,and show that the translation is correct. we conclude by indicating future work, in sect. 5. the appendix recalls some facts about graph rewriting. 2 graphs, rewriting, and contextual grammars we define labeled graphs wherein edges may not just connect two nodes – a source to a target – but any number of nodes. such graphs are known as hypergraphs in the literature [dhk97]. definition 1 (graph) let σ = (σ̇,σ̄) be a pair of finite sets containing symbols. a graph g = (ġ,ḡ,att,`) consists of two disjoint finite sets ġ of nodes and ḡ of edges, a function att : ḡ → ġ∗ that attaches sequences of nodes to edges,1 and of a pair ` = ( ˙̀, ¯̀) of labeling functions ˙̀: ġ → σ̇ for nodes and ¯̀: ḡ → σ̄ for edges. we will often refer to the attachment and labeling functions of a graph g by attg and `g, respectively. a (graph) morphism m : g → h is a pair m = (ṁ,m̄) of functions ṁ : ġ → ḣ and m̄ : ḡ → h̄ that preserve attachments and labels: atth ◦m̄ = ṁ∗◦attg, ˙̀h = ˙̀g ◦ṁ, and ¯̀h = ¯̀g ◦m̄.2 the morphism m is injective, surjective, and bijective if its component functions have the respective property. if ġ ⊆ ḣ, ḡ ⊆ h̄, m is injective, and maps nodes and edges of g onto themselves, this defines the inclusion of g as a subgraph in h, written g ↪→ h. if m is bijective, we call g and h isomorphic, and write g ∼= h. 1 a∗ denotes finite sequences over a set a; the empty sequence is denoted by ε . 2 for a function f : a → b, its extension f∗ : a∗ → b∗ to sequences a∗ is defined by f∗(a1 ...an) = f (a1)... f (an), for all ai ∈ a, 1 6 i 6 n, n > 0; f ◦g denotes the composition of functions or morphisms f and g. selected revised papers from gcm 2014 2 / 20 eceasst c scc v c sb ve v bb e e e e e e m⇒ pum′ c scc v c sb ve v b b e e figure 1: two program graphs c c s c b v sb b v e e e e e e e e figure 2: a refactoring rule example 1 (program graphs) figure 1 shows two graphs g and h representing object-oriented programs. circles represent nodes, and have their labels inscribed. in these particular graphs, edges are always attached to exactly two nodes, and are drawn as straight or wave-like arrows from their source node to their target node. (the filling of nodes, and the colors of edges will be explained in example 2.) program graphs have been proposed in [vj03] for representing key concepts of object-oriented programs in a language-independent way. in the simplified version that is used here, nodes labeled with c, v, e, s, and b represent program entities: classes, variables, expressions, signatures and bodies of methods, respectively. straight arrows represent the syntactical composition of programs, whereas wave-like arrows relate the use of entities to their declaration in the context. for rewriting graphs, we use the standard definition [eept06], but insist on injective matching of rules; it is shown in [hmp01] that this is no restriction. we choose an alternative representation of rules discussed in [ehp09] so that the rewriting of rules in sect. 3 can be easier defined, see also in appendix a. definition 2 (graph rewriting) a graph rewrite rule (rule for short) r = (p ↪→b←↩ r) consists of graph inclusions, of a pattern p and a replacement r in a common body b. the intersection p∩r of pattern and replacement graph is called the interface of r. a rule is concise if the inclusions are jointly surjective. by default, we refer to the components of a rule r by pr, br, and rr. the rule r rewrites a source graph g into a target graph h if there is an injective morphism b →u to a united graph u so that the squares in the following diagram are pushouts: pr : b r g u h m m̃ the diagram exists if the morphism m : p → g is injective, and satisfies the following gluing condition: every edge of g that is attached to a node in m(p\r) is in m(p). then m is a match of r in g, and h can be constructed by (i) uniting g disjointly with a fresh copy of the body b, and gluing its pattern subgraph p to its match m(p) in g, giving u , and (ii) removing the 3 / 20 volume 71 (2015) more on graph rewriting with contextual refinement nodes and edges of m(p\r) from u , yielding h with an embedding morphism m̃ : r → h.3 the construction is unique up to isomorphism, and yields a rewrite step, which is denoted as g⇒mr h. note that the construction can be done so that there are inclusions g ↪→u ←↩ h; we will assume this wlog. in the rest of this paper. example 2 (a refactoring rule) figure 2 shows a rule pum′. rounded shaded boxes enclose its pattern and replacement, where the pattern is the box extending farther to the left. together they designate the body. (rule pum′ is concise.) we use the convention that an edge belongs only to those boxes that contain it entirely; so the “waves” connecting the top-most s-node to nodes in the pattern belong only to the pattern, but not to the replacement of pum′. the pattern of pum′ specifies a class with two subclasses that contain method implementations for the same signature. the replacement specifies that one of these methods shall be moved to the superclass, and the other one shall be deleted. in other words, pum′ pulls up methods, provided that both bodies are semantically equivalent. (this property cannot be checked automatically, but has to be verified by the user before applying this refactoring operation.) the graphs in figure 1 constitute a rewrite step g⇒mpum′ h. the shaded nodes in the source graph g distinguish the match m of pum′, and the shaded nodes in the target graph h distinguish the embedding m̃ of its replacement. (the red nodes in g are removed, and the green nodes in h are inserted, with their incident edges, respectively.) rule pum′ only applies if the class has exactly two subclasses, and if the method bodies have the particular shape specified in the pattern. the general pull-up method refactoring of fowler [fow99] works for classes with any positive number of subclasses, and for method bodies of varying shape and size. this cannot be specified with a single plain rule, which only has a pattern graph of fixed shape and size. the general refactoring will be specified by a single rule schema (with a set of meta-rules) in example 5 further below. we introduce further notions, for rewriting graphs with sets of rules. let r be a set of graph rewrite rules. we write g⇒r h if g⇒mr h for some match m of a rule r ∈ r in g, and denote the transitive-reflexive closure of this relation by ⇒∗r . a graph g is in normal form wrt. r if there is no graph h so that g⇒r h. a set r of graph rewrite rules reduces a graph g to some graph h, written g⇒!r h, if g⇒ ∗ r h so that h is in normal form. r (and ⇒r ) is terminating if it does not admit an infinite rewrite sequence go⇒r g1⇒r ..., and confluent if for every diverging rewrite sequence h1 ∗ r⇐g⇒ ∗ r h2, there exists a graph k with a joining rewrite sequence h1⇒∗r k ∗ r⇐h2. graph rewrite rules r can be used to compute a partial nondeterministic function fr from graphs to sets of their normal forms, i.e., fr(g) = {h | g⇒!r h}. the function fr is total if r is terminating, and deterministic if r is confluent. a set of graph rewrite rules, together with a distinguished start graph, forms a grammar, which can be used to derive a set of graphs from that start graph. such sets are called languages, as for string grammars. graph grammars with unrestricted rules have been shown to generate the recursively enumerable languages[ues78]. so there can be no general algorithms recognizing whether a graph belongs to the language of such a grammar. until recently, the study of restricted grammars with recognizable languages has focused on the context-free case, where the 3 even if r is not concise, the nodes and edges of b that are not in the subgraph (p∪r) are not relevant for the construction as they are removed immediately after adding them to the union. selected revised papers from gcm 2014 4 / 20 eceasst pattern of a rule is a syntactic variable (or nonterminal). two different ways have been studied to specify how the neighbor nodes of a variable are connected to the replacement graph. in node replacement [er97], this is done by embedding rules for neighbor nodes that depend on the labels of the neighbors and of the connecting edges. in hyperedge replacement [dhk97], the variable is a hyperedge with a fixed number of attached nodes that may be glued to the nodes in the replacement. unfortunately, the languages derivable with these grammars are restricted in the way their graphs may be connected: neither a language as simple as that of all graphs, nor the language of program graphs introduced in example 1 can be derived with a context-free graph grammar. to overcome these limitations, mark minas and the author have proposed a modest extension of hyperedge replacement where the replacement graph of a variable x may not only be glued to the former attachments of x, but also to further nodes in the source graph [hm10]. this way of contextual hyperedge replacement does not only overcome the restrictions of context-free graph grammars (both the languages of all graphs and of program graphs can be derived), but later studies in [dhm12, dh14] have shown that many properties of hyperedge replacement are preserved, in particular, the existence of a recognition algorithm. furthermore, they are suited to specify the refinement of rules by rules (in the next section). for the definition of these grammars, we assume that the symbols σ contain a set x ⊆ σ̄ of variable names that are used to label placeholders for subgraphs. x(g) = {e ∈ ḡ | `g(e) ∈ x} is the set of variables of a graph g, and g is its kernel, i.e., g without x(g). for a variable e ∈ x(g), the variable subgraph g/e consists of e and its attached nodes. graphs with variables are required to be typed in the following way: variable names x ∈ x are assumed to come with a signature graph sig(x), which consists of a single edge labeled with x, to which all nodes are attached exactly once; in every graph g, the variable subgraph g/e must be isomorphic to the signature graph sig(`g(e)), for every variable e ∈ x(g). definition 3 (contextual grammar) a rule r : (p ↪→ b ←↩ r) is contextual if the only edge e in its pattern p is a variable, and if its replacement r equals the body b, without e. with some start graph z, a finite set r of contextual rules forms a contextual grammar γ = (σ,r,z) over the labels σ, which derives the language l (γ) = { g | z⇒∗r g,x(g) = /0 } . the pattern p of a contextual rule r is the disjoint union of a signature graph sig(x) with a discrete context graph, which is denoted as cr. we call r context-free if cr is empty. (grammars with only such rules have been studied in the theory of hyperedge replacement [dhk97].) example 3 (a contextual grammar for program graphs) figure 3 shows a set p of contextual rules. variables are represented as boxes with their variable names inscribed; they are connected with their attached nodes by lines, ordered from left to right. (later, in sect. 3, we will also use arrows in either direction.) when drawing contextual rules like those in fig. 3, we omit the box enclosing their pattern. the variable outside the replacement box is the unique edge in the pattern, and green filling (appearing grey in b/w print) designates the contextual nodes within the box enclosing the replacement graph. the rules p in figure 3 define a contextual grammar pg = (σ,p,sig(cls)) for program graphs. the grammar uses four variable names; they are attached to a single node, which is labeled with c for variables named cls and fea, with b for variables named bdy, and with e for variables named 5 / 20 volume 71 (2015) more on graph rewriting with contextual refinement cls c fea 1 . . . . . . fea k c 1 cls . . . . . . . . . c n cls fea c v e fea c s v 1 . . . . . . v n fea c s b bdy bdy b e 1 exp . . . . . . e n exp exp e v e exp e v e exp exp s e e 1 exp . . . . . . e n exp classk,n att sign impl bodyn use assign calln figure 3: contextual rules p for generating program graphs c fea c c c fea e fea fea fea exp 2⇒ sig1 c fea c c c fea e s s v v fea exp ⇒ impl c fea c c c fea e s s v v b bdy exp body1⇒ call1 c fea c c c fea e s s v v b e e exp ⇒ use c fea c c c fea e s s v v b e e exp figure 4: snapshots in a derivation of a program graph exp. the c-node of the start graph sig(cls) represents the root class of the program, and the structure of a program is derived by the rules, considered from left to right, as follows. every class has features, and may be extended by subclasses. a feature is either an attribute variable, or a method signature with parameter variables, or a method body that implements some existing signature. a method body (or rather, its data flow) consists of a set of expressions, which either use the value of some existing variable, or assign the value of an expression to some existing variable, or call some existing method signature with expressions as actual parameters. actually, classk,n, sign, bodyn, and calln are templates for infinite sets of rule instances that generate classes with k > 0 features and n > 0 subclasses, signatures with n > 0 parameters, bodies with n > 0 expressions, and calls with n > 0 actual parameters, respectively. the instances of a template can be composed with a few replicative rules, so this is just a short hand notation, like the repetitive forms of extended backus-naur form of context-free string grammars. figure 4 shows snapshots in a derivation of a program graph. the first graph is derived from the start graph by applying four instances of the template classk,n, which generate a root class with two features and one subclass, which in turn has two features and two subclasses, whereof only one has a feature, and both do not have subclasses. the second graph is obtained by applying rule instance sig1 at two matches, deriving two signatures with one parameter each. applying rule impl yields the third graph, with the root of a body for one of the signatures. the fourth is obtained by applications of the instances body1 and call1, refining the body to a single call. then application of rule use derives the actual parameter for the call. four further derivation steps, applying rules impl and att to the remaining fea-variables, and rules body1 and then use to the resulting bdy-variable, yield the target graph of the rewriting step shown in figure 1. selected revised papers from gcm 2014 6 / 20 eceasst as for context-free string grammars, it is important to know whether a contextual grammar is ambiguous or not. unambiguous grammars define unique (de-) compositions of graphs in their language. parsing of unambiguous grammars is efficient as no backtracking is needed, and the transformation of graphs can be defined over their unique structure. this property will be exploited in lemma 1 further below. definition 4 (ambiguity) let γ = (σ,r,z) be a contextual grammar. consider two rewrite steps g⇒mr h⇒m ′ r′ k where m̃ : r → h is the embedding of r in h. the steps may be swapped if m′(p′) ↪→ m̃(p∩r), yielding steps g⇒m ′ r′ h ′⇒mr k. two rewrite sequences are equivalent if they can be made equal up to isomorphism, by swapping their steps repeatedly. then γ is unambiguous if all rewrite sequences of a graph g ∈ l (γ) are equivalent to each other; if some graph g has at least two rewrite sequences that are not equivalent, γ is ambiguous. example 4 (unambiguous grammars) the program graph grammar pg in example 3 is unambiguous. 3 schema refinement with contextual meta-rules refining graph rewrite rules means to rewrite rules instead of graphs. a general framework for “meta-rewriting” can be easily defined. we start by lifting morphisms from graphs to rules. definition 5 (rule morphism) for (graph rewrite) rules r and s, a graph morphism m : br → bs on their bodies is a rule morphism, and denoted as m : r → s, if m(pr) ↪→ ps and m(rr) ↪→ rs. graph rewrite rules and rule morphisms form a category. this category has pushouts, pullbacks, and unique pushout complements along injective rule morphisms, just as the category of graphs. as with graphs, we write rule inclusions as “↪→”, and let r be the kernel of a rule r wherein all variables are removed. definition 6 (rule rewriting) a pair δ : (p ↪→ b ←↩ r) of rule inclusions is a rule rewrite rule, or meta-rule for short. with δb we denote its body rule, which is a graph rewrite rule (bp ↪→ bb ←↩ br) consisting of the bodies of p, b, and r. consider a rule s, a meta-rule δ as above, and a rule morphism m : p → s. the meta-rule δ rewrites the source rule s at m to the target rule t, written s δ ⇓m t, if there is a pair of pushouts p b r s u t the pushouts above exist if the underlying body morphism mb : bp → bs of m satisfies the graph gluing condition wrt. the body rule δb and the body graph bs; the target rule t is constructed by rewriting bs to the body bt with the body rule δb, and extending it to a rule (pt ↪→ bt ←↩ rt). as for graph rewriting, we assume that the pushouts are constructed so that all horizontal rule morphisms are rule inclusions, i.e., s ↪→ u ←↩ t. 7 / 20 volume 71 (2015) more on graph rewriting with contextual refinement it is straight-forward to define general rule rewriting on the more abstract level of adhesive categories. however, this is not useful for this paper, as we will use concrete meta-rules that are based on the restricted notion of contextual hyperedge replacement. let us recall the outstanding feature of rules in the graph rewriting tool grgen [bgj06], the “recursive pattern refinement” devised by edgar jakumeit [jak08], which we want to model. • a rule may contain “subpatterns”, which are names that are parameterized with nodes of the pattern and of the replacement graph of the rule. (if some parameter really is of the replacement graph, the term “subrule” would be more adequate.) • the refinement of a subpattern is defined by a “pattern rule” that adds nodes and edges to the pattern and replacement graphs of a rule. pattern rules may define alternative refinements, and may contain subpatterns so that they can be recursive. • the refinements of different subpatterns must be disjoint, i.e., their matches in the source graph must not overlap. if a node shall be allowed to overlap with another node in the match, it is specified to be “independent”. we shall model subpatterns by allowing variables to occur in the body of a rule (but neither in its pattern, nor in its replacement); we call such a rule a schema. pattern rules are modeled by alternative meta-rules where the body rule is contextual. this supports recursion, since the body of the meta-rule may contain variables. rewriting with context-free meta-rules derives disjoint refinements for different variables in the context-free case; independent nodes can be modeled as the contextual nodes of contextual meta-rules. definition 7 (schema refinement) a schema s : (p ↪→ b ←↩ r) is a graph rewrite rule with p∪r = b. every schema s : (p ↪→ b ←↩ r) is required to be typed in the following sense: every variable name x ∈ x comes with a signature schema sigschema(x) with body sig(x) so that for every variable e ∈ x(b), the variable subgraph b/e is the body of a subschema that is isomorphic to sigschema(x). a meta-rule δ : (p ↪→ b ←↩ r) is contextual if p, b, and r are schemata, and if its body rule δb : (bp ↪→ bb ←↩ br) is a contextual rule so that the contextual nodes cδb are in pp ∩rp. in a less contextual variation δ ′ of a meta-rule δ , some contextual nodes are removed from bp, but kept in br. let ∆ be a finite set of meta-rules that is closed under less contextual variations.4 then ∆ ⇓ denotes refinement steps with one of its meta-rules, and ∆ ⇓∗ denotes repeated refinement, its reflexive-transitive closure. ∆(s) denotes the refinements of a schema s : (p ↪→ b ←↩ r), containing its refinements without variables: ∆(s) ={r | s ∆ ⇓∗ r,x(br) = /0} we write g⇒∆(s) h if g⇒r h for some r ∈ ∆(s), and say that the refinements ∆(s) rewrite g to h. note that the application of a refinement r ∈∆(s), although it is the result of a compound metaderivation, is an indivisible rewriting step g⇒r h on the source graph g, similar to a transaction 4 we explain in example 5 why these less contextual variations are needed. selected revised papers from gcm 2014 8 / 20 eceasst pumk : c bsc 1 . . . c k c . . . b . . . b b bdy0 . . . bdy0 bdy1 figure 5: pull-up method: schema b e 1 . . . e n bdy0 exp0 exp0 ··· e v exp0 exp0 e e 1 . . . e n s exp0 exp0 ··· exp0 e v e exp exp0 exp0 bdy0n use 0 call0n assign 0 figure 6: deleting meta-rules for method bodies b e 1 . . . e n b e 1 . . . e n bdy1 exp1 exp1··· e v e exp exp1 expi e e 1 . . . e n s e e 1 . . . e n exp1 exp1 ··· exp1 e v e exp exp1 exp1 bdy1n use 1 call1n assign 1 figure 7: replicating meta-rules for method bodies in a data base. note also that the refinement process is completely rule-based, and performs standard rewriting, just on rules instead of graphs. we illustrate schema refinement by two operations from fowler’s catalogue of basic refactorings [fow99]. example 5 (pull-up method) the pull-up method refactoring applies to a class c where all direct subclasses contain implementations for the same method signature that are semantically equivalent.5 then the refactoring pulls one of these implementations up to the superclass c, and removes all others. figures 5-7 show the schema pumk and the meta-rules that shall perform this operation. in schemata and meta-rules, the lines between a variable e and a node v attached to e get arrow tips (i) at e if v occurs in the pattern, and (ii) at v if v occurs in the replacement. (thus the line will have tips at both ends if v is both in the pattern and in the replacement. however, this occurs only in fig. 8 of example 6.) the pattern of the schema pumk (in fig. 5) contains a class with k + 1 subclasses, where every subclass implements a common signature, as they contain b-nodes connected to the same s-node. (actually, pumk is a template for k > 0 schemata, like some of the contextual rules in fig. 3. analogously to contextual rules, the instances of the schema template can be derived with two contextual meta-rules.) the variables specify what shall happen to the method bodies: k of them, those which are attached to a bdy0-variable, shall just be deleted, and the body attached to a bdy1-variable shall be moved to the superclass. the meta-rules can be mechanically constructed from the contextual 5 this application condition cannot be decided mechanically; it has to be confirmed by the user when s/he applies the operation, by a priori verification or a-posteriori testing. 9 / 20 volume 71 (2015) more on graph rewriting with contextual refinement rules m ={bodyn,use,calln,assign}⊆ p in fig. 3. the deleting meta-rules {r0 | r ∈ m} in fig. 6 delete all edges and all nodes but the contextual nodes of a method body from the pattern. the replicating meta-rules {r0 | r ∈ m} in fig. 7 delete a method body from the pattern, and insert a copy of this body in the replacement while preserving the contextual nodes. (meta-rules for making i > 1 copies of a method body can be constructed analogously.) a context-free metarule, like those for bdy0 and bdy1, applies to every schema containing a variable of that name. a contextual meta-rule (like the other six), however, applies only if its contextual nodes can be matched in the schema. so the meta-rules call0n and call 1 n apply to the schema pumk as it contains an s-node, but the others do not: neither does pumk contain any v-node, nor does any of the meta-rules derive one. this is the reason for including less contextual variations of a contextual meta-rule r. in our case, where the rules have one contextual node only, the only less contextual variation is context-free, and denoted by r̄. we do not not show them here, because the difference is small: just the green (contextual) nodes in figure 6 and 7 turn white. applying less contextual meta-rules to a schema adds the former contextual nodes to the interface of a schema, i.e., to the intersection of its pattern and replacement graphs. if ∆m is the closure of the meta-rules in figure 6 and 7 under less contextual variation, refinement of the schema pumk may yield method bodies with recursive calls to the signature in the schema, and calls to further signatures, and (read or write) accesses to variables in the interface. for instance, the rule pum′ in fig. 2 is a refinement of pumk with ∆m, i.e., pum′∈ ∆m(pumk). for deriving pum′, only the context-free variations of meta-rules have been used, adding the former contextual nodes (drawn in green in fig. 2) to the interface. the upper row in fig. 13 on page 15 below shows a step in the refinement sequence pumk ∆m⇓∗ pum ′; it applies the context-free variation assign 1 of the replicating meta-rule assign1 in fig. 7. example 6 (encapsulate field) the encapsulate field refactoring shall transform all non-local read and write accesses to an attribute variable by calls of getter and setter methods. figure 8 shows a schema ef, two meta-rule templates, and a refinement of the schema. the schema ef (on the left-hand side) adds a getter and a setter method definition for a variable to a ef = c s b b s v e e ev v readers writers readers sv e... e writers sv e... e ef′ = c s b b s v e e ev v e e e readers figure 8: the schema, the embedding meta-rules, and an instance of encapsulate field selected revised papers from gcm 2014 10 / 20 eceasst class, and introduces variables readers and writers that take care of the read and write accesses. the (context-free) embedding meta-rule templates (in the middle) then replace any number of read and write accesses to the variable by calls of its getter and setter method, respectively. if ∆e denotes the embedding meta-rules, the rule on the right-hand side of fig. 8 is a derivative ef′ ∈ ∆e(ef), encapsulating one read access and two write accesses. a single rewriting step with a refinement of pull-up method copies one method body of arbitrary shape and size, and deletes an arbitrarily number of other bodies, also of variable shape and size. refinements of encapsulate field transforms the neighbor edges of an unbounded number of nodes. this goes beyond the expressiveness of plain rewrite rules, which may only match, delete, and replicate subgraphs of constant size and fixed shape. many of the basic other refactorings from fowler’s catalogue [fow99] cannot be specified by a single plain rule, but by a schema with appropriate meta-rules. operationally, we cannot construct all refinements of a schema s first, and apply one of them later, because the set ∆(s) is infinite in general. rather, we interleave matching and refinement, in the next section. before, we study some properties of schema refinement. the following assumption excludes useless definitions of meta-rules. assumption 1 the set ∆(s) of refinements of a schema s shall be non-empty. non-emptiness of refinements can be reduced to the property whether the language of a contextual grammar is empty or not. it is shown in [dhm12, corollary 2] that this property is decidable. we need a mild condition to show that schema refinement terminates. definition 8 (pattern-refining meta-rules) a meta-rule δ : (p ↪→ b ←↩ r) refines its pattern if x(rr) = /0 or if pr 6∼= pp. a set ∆ of meta-rules that refine their patterns is called pattern-refining. theorem 1 for a schema s and a set ∆ of pattern-refining meta-rules, it is decidable whether some refinement r ∈ ∆(s) applies to a graph g, or not. proof. by algorithm 1 in [hof13], the claim holds under the condition that meta-rules “do not loop on patterns”. it is easy to see that pattern-refining meta-rules are of this kind. we now turn to the question whether the (infinite) set of graph rewrite rules obtained as refinements of a schema are uniquely determined by their patterns. definition 9 (right-unique rule sets) a set r of graph rewrite rules is right-unique if different meta-rules r1 : (p1 ↪→ b1 ←↩ r1),r2 : (p2 ↪→ b2 ←↩ r2) ∈ r have different patterns, i.e., p1 ∼= p2 implies that r1 ∼= r2. we define an auxiliary notion first. the pattern rule δp of a meta-rule δ : (p ↪→ b ←↩ r) is a contextual rule obtained from the body rule δb : (bp ↪→ bb ←↩ br) by removing all nodes and edges in bb\rb, and by detaching all variables in δb from the removed nodes. let ∆p denote the set of (contextual) pattern rules of a set ∆ of meta-rules. (the graphs in ∆p are typed as well, but 11 / 20 volume 71 (2015) more on graph rewriting with contextual refinement in the type graph sig(x) of a variable name x, all nodes that do not belong to the pattern of the signture schema sigschema(x) are removed.) lemma 1 (right-uniqueness of refinements) a set ∆(s) of refinements is right-unique if the pattern grammar (σ,∆p,ps) of their meta-rules ∆ is unambiguous. proof sketch. consider rules r1,r2 ∈ ∆(s) with p1 ∼= p2. then ps⇒∆p p1 and ps⇒∆p p2. the rewrite sequences can be made equal since ∆p is unambiguous. this rewriting sequence has a unique extension to a meta-rewrite sequence so that r1 ∼= r2. example 7 (properties of meta-rules) it is easy to see that the deleting and replicative metarules ∆m in figures 6-7 of example 5 satisfy assumption 1. because, it has been shown in [dhm12, example 3.23] that all rules of the program graph grammar in example 3 are useful. thus its language is non-empty. this property can easily be lifted to the meta-rules ∆m, in particular as they also contain context-free variations of the rules in p. it is easy to check that the rules in ∆m are also pattern-refining. the contextual rules p for method bodies in fig. 3 are unambiguous, and so are the rules m, which correspond to the pattern rules of the deleting and replicating meta-rules ∆m in figures 6-7 of example 5, so that ∆m is right-unique. the embedding meta-rules ∆e in fig. 8 of example 6 derive a non-empty set of rules, and are pattern-refining and right-unique as well. 4 modeling refinement by residual rewriting the refinement of a schema s with some meta-rules ∆ yields instances ∆(s), which are ordinary rules for rewriting graphs. however, the set ∆(s) is infinite in general. unfortunately, many analysis techniques, e.g., for termination, confluence, and state space exploration of graph rewriting, do only work for finite sets of graph rewrite rules. to make these techniques applicable, we translate each schema and every contextual meta rule into a standard graph rewrite rule: • we turn every schema into an ordinary rule that postpones refinement, by adding its metavariables to its replacement. • we turn every contextual meta-rule δ : (p ↪→ b ←↩ r) into an graph rewrite rule that refines the translated schema incrementally, by uniting its pattern rule r component-wise with the variable graphs of its body rule δb. the resulting rule set is always finite. definition 10 (incremental refinement rules) let s : (p ↪→ b ←↩ r) be a schema for metarules ∆. the incremental rule s̃ : (p ↪→ b ←↩ rs̃) of the schema s has the same pattern p and body b as s, and its replacement rs̃ = r∪{b/e | e ∈ x(b)} is obtained by extending r with the graphs of all variables in b. for a meta-rule δ = (p ↪→ b ←↩ r) in ∆, the incremental rule δ̃ : (p̃ ↪→ b̃ ←↩ r̃) is the component-wise union of its replacement rule r : (rp ↪→ rb ←↩ rr) with the variable graphs of its body rule δb : (bp ↪→ bb ←↩ br): selected revised papers from gcm 2014 12 / 20 eceasst c s b b s v e e ev v readers writers readers sv e... e writers sv e... e figure 9: incremental rules for encapsulate field in fig. 8 pumk : c bsc 1 . . . c k c . . . b . . . b b bdy0 bdy0 bdy1 assign 1 : exp1 e v e e e exp1exp figure 10: incremental rules for pull-up method in fig. 5 and fig. 7 (i) p̃ = pr ∪{bp/e | e ∈ x(bp)} (which equals bp ∪pr), (ii) b̃ = bb ∪{bb/e | e ∈ x(bb)} (which equals bb), and (iii) r̃ = rr ∪{br/e | e ∈ x(br)}. ∆̃ shall denote the incremental rules of the meta-rules ∆. example 8 (incremental refinement) figure 9 shows the incremental rule ef for the schema ef and of the meta-rules ∆e in fig. 8 of example 6. figure 10 shows how the schema pumk for the pull-up method refactoring in fig. 5 is translated into an incremental rule pumk, and how the context-free variation assign 1 of the meta-rule assign1 in fig. 7 is translated into an incremental rule assign 1 . (in the incremental rule pumk, red arrow and waves indicate edges that do not belong to the replacement.) if a schema s is refined with a meta-rule δ to a schema t, the composition s̃◦d δ̃ of its incremental rules (as defined in def. 12 of the appendix) equals the incremental rule t̃ (for a particular dependency d). lemma 2 consider a schema s = (p ↪→ b ←↩ r) and a meta-rule δ : (p ↪→ b ←↩ r). then s δ ⇓m t for some schema t iff there is a composition rd = s̃ ◦d δ̃ for a dependency 13 / 20 volume 71 (2015) more on graph rewriting with contextual refinement bp bb br b u b′ m figure 11: b⇒m δb b′ bp r{b/e | e ∈ x(b)}∪ b p o bp∪rp bb rr∪{br/e | e ∈ x(br)}j1 j2 pd rdbd m figure 12: rd = s̃◦d δ̃ d : (r← m bp → (bp ∪rp)) so that rd = t̃. proof sketch. let s, δ be as above, t : (p′ ↪→ b′ ←↩ r′), s̃ : (p ↪→ b ←↩ rs̃) with rs̃ = r∪{b/e | e ∈ x(b)}, and δ̃ : (p̃ ↪→ b̃ ←↩ r̃) with p̃ = bp∪pr, r̃ = rr∪{br/e | e ∈ x(br)}, and b̃ = bb, see def. 10. their composition according to the dependency d : (r← m bp → (bp∪rp) is constructed as in def. 12, and shown in fig. 12. consider the underlying body refinement b⇒m δb b′. (see fig. 11, where we assume that the lower horizontal morphisms are inclusions.) by uniqueness of pushouts, u ∼= bd . then (bb \ bp) = x(bp) since δb is contextual, and b′ = u \m̄(x(bp)). it is then easy to show that the body b′ δ̃ equals the body bd of the composed incremental rule, and an easy argument concerning the whereabouts of variables shows that t̃ = rd . example 9 (schema refinement and incremental rules) figure 13 illustrates the relation between schema refinement and the composition of their incremental rules established in lemma 2. as already mentioned in example 5, the upper row shows a step in the refinement sequence pumk ∆m⇓∗ pum ′ that applies the context-free variation assign 1 of the meta-rule assign1 in fig. 7. the original meta-rule does not apply to the source schema, as it does not contain a node labeled v. the less contextual rule does apply; the refined rule is constructed so that the v-node will be matched in the context when it is applied to a source graph. the lower row shows the composition of the corresponding incremental rule with the corresponding incremental refinement rule assign 1 , where the dashed box specifies the dependency d for the composition. the composed rule equals the incremental rule for the refined schema. using a refined schema has the same effect as applying its incremental rule, and the incremental rules of the corresponding meta-rules. this must follow a strategy that applies incremental rules as long as possible, matching the residuals of the source graphs, before another incremental rule is applied. we define the subgraph that is left unchanged in refinement steps and sequences. the track of g in h (via the match m of the rule r) is then defined as trmr (g) = (g∩h).6 for a rewrite sequence d = g0⇒m1r1 g1⇒ m2 r2 ...⇒ mn rn gn, the track of g in h is given by intersecting the tracks 6 recall that g ↪→u ←↩ h for the graphs and morphisms of a rewrite step. selected revised papers from gcm 2014 14 / 20 eceasst c bsc cc b b e ee exp0 exp1 exp1 e v e e e exp1 exp c bsc cc b b e e e ev e exp0 exp1 c bsc cc b b e ee exp0 exp1 ←− m ↓ e e exp1 d ◦d exp1 e v e e e exp1exp = c bsc cc b b e e e ev e exp0 exp1 figure 13: schema refinement and incremental composition of its steps: trd(g) = tr m1 r1 (g0)∩···∩tr mn rn (gn−1) the incremental rules have to be applied so that the patterns of the refinements of the original meta-rules do not overlap. definition 11 (residual incremental refinement) consider an incremental refinement sequence g0 m1⇒ δ̃1 g1 m2⇒ δ̃2 ... mn⇒ δ̃n gn with incremental rules δ̃i for meta-rules δi : (pi ↪→ bi ←↩ ri) (for 1 6 i 6 n). the step gi−1⇒mi δ̃i gi is residual if mi(pri) ⊆ tr m1...mi−1 r1...ri−1 (g). the sequence is residual if every of its steps is residual. residual steps and sequences are denoted as v and v∗, respectively. lemma 3 consider a schema s for meta-rules ∆ with incremental rule s̃ and incremental rules ∆̃. then a rule r : (p ↪→ b ←↩ r) is a refinement in ∆(s) if and only if p⇒s̃ p′ v! ∆̃ r. 15 / 20 volume 71 (2015) more on graph rewriting with contextual refinement proof. by induction over the length of meta-derivations, using lemma 2 and the fact that compositions correspond to residual rewrite steps. theorem 2 consider a schema s with meta-rules ∆ as above. then, for graphs g, h, and k, g⇒∆(s) h if and only if g⇒s̃ k v!∆̃ h. proof. combine lemma 3 with the embedding theorem [eept06, sect. 6.2]. 5 conclusions in this paper we have continued earlier attempts in [hjg08, hof13] to model graph rewriting with recursive refinement, which are the outstanding feature of rules in the graph rewriting tool grgen [bgj06]. the definition here is by standard graph rewriting—contextual hyperedge replacement on the meta-level and standard graph rewriting on the object level—and allows to specify conditions under which refinement “behaves well”, i.e., terminates, and yields unique refinements. it is simple enough so that it can be translated to standard graph rewriting rules that perform the refinement incrementally, using a strategy—residual rewriting—where matches do overlap only in contextual nodes (and in attached nodes of variables). related work has occurred with two respects. on the one hand, expressive rules allowing transform subgraphs of variable shape and size have been proposed by several authors: d. janssens has studied graph rewriting with node embedding rules [jan83]. the encapsulate field refactoring in example 6 could be defined in this way. d. plump and a. habel have proposed rules where variables in the pattern and the replacement graph can be substituted with isomorphic graphs [ph96]. there, variables could be substituted by arbitrary graphs, which is rather powerful, but difficult to use (and to implement). the author has later proposed substitutions with context-free (hyperedge replacement) languages [hof01]. this turned out to be too restricted so that we now decided to propose contextual hyperedge replacement. the pull-up method refactoring in example 5 is a candidate for substitutive graph rewriting. in [hof13] we have shown that embedding and substitutive rules are special cases of rules with contextual refinement. on the other hand, the core of standard graph rewriting theory [ceh+97], with its results on parallel and sequential independence, critical pair lemma [plu93] etc., has been extended considerably over the years. the framework now covers graph with attributes and subtyping, rules with positive and negative application conditions [eept06], and, as of recently, also nested application conditions [ehl+10, egh+12]. future work should attempt to integrate the extensions of the standard theory to rule refinement, as all these concepts are supported by the graph rewriting tool grgen [bgj06] as well. this should be straight-forward for attributes and subtyping. application conditions require more work, in particular when conditions shall be translated to incremental rules. obviously, application conditions are useful for modeling complex operations like refactorings: (i) the definition of program graphs in example 1 could be more precise if the choice of a contextual node could be subject to a condition. e.g., the rule impl should require that the signature being implemented is contained in a super-class of the body. (see [hm10] for a definition of program graphs using application conditions.) (ii) the pull-up method refactoring in example 5 should require that selected revised papers from gcm 2014 16 / 20 eceasst the method body to be pulled up does not access variables or methods outside the name space of the superclass. (iii) the encapsulate field refactoring in example 6 should be required to encapsulate all non-local accesses of a variable. for some of the conditions mentioned here, application conditions need to specify the (non)-existence of paths in a graph. this cannot be done by nested application conditions, but only if the conditions allow recursive refinement, as studied by h. radke in [hr10]. but this is not (yet?) integrated into the standard theory. our ultimate goal is to provide support for analyzing grgen rules, e.g., for the existence of critical pairs. the negative result shown in [hof13, thm. 3] indicates that considerable restrictions have to be made to reach this aim. our idea now is to restrict rewriting with contextual refinement to graphs that are shaped according to a contextual grammar like that for program graphs. acknowledgments. the author thanks annegret habel and rachid echahed for their encouragement, and the reviewers for their detailed constructive comments. bibliography [bgj06] j. blomer, r. geiß, e. jakumeit. grgen.net: a generative system for graphrewriting, user manual. www.grgen.net, universität karlsruhe, 2006. version 4.4 (29.07. 2014). [ceh+97] a. corradini, h. ehrig, r. heckel, m. löwe, u. montanari, f. rossi. algebraic approaches to graph transformation, part i: basic concepts and double pushout approach. in rozenberg (ed.), handbook of graph grammars and computing by graph transformation. vol. i: foundations. chapter 3, pp. 163–245. world scientific, 1997. [dh14] f. drewes, b. hoffmann. contextual hyperedge replacement. uminf report 14.04, institutionen för datavetenskap, umeaå universitet, 2014. 28 pages. [dhk97] f. drewes, a. habel, h.-j. kreowski. hyperedge replacement graph grammars. chapter 2, pp. 95–162 in [roz97]. [dhm12] f. drewes, b. hoffmann, m. minas. contextual hyperedge replacement. in schürr et al. (eds.), applications of graph transformation with industrial relevance (agtive’11). lecture notes in computer science 7233, pp. 182–197. springer, 2012. long version as uminf report 14.04, institutionen för datavetenskap,umeå universitet. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs. springer, 2006. 17 / 20 volume 71 (2015) http::/www8.cs.umu.se/research/uminf/index.cgi?year=2014&number=4 more on graph rewriting with contextual refinement [egh+12] h. ehrig, u. golas, a. habel, l. lambers, f. orejas. adhesive transformation systems with nested application conditions. part 2: embedding, critical pairs and local confluence. fundam. inform. 118(1-2):35–63, 2012. [ehl+10] h. ehrig, a. habel, l. lambers, f. orejas, u. golas. local confluence for rules with nested application conditions. in ehrig et al. (eds.), icgt. lecture notes in computer science 6372, pp. 330–345. springer, 2010. [ehp09] h. ehrig, f. hermann, u. prange. cospan dpo approach: an alternative for dpo graph transformations. bulletin of the eatcs 98:139–149, 2009. [eps73] h. ehrig, m. pfender, h. schneider. graph grammars: an algebraic approach. in ieee conf. on automata and switching theory. pp. 167–180. iowa city, 1973. [er97] j. engelfriet, g. rozenberg. node replacement graph grammars. chapter 1, pp. 1– 94 in [roz97]. [ert99] c. ermel, m. rudolf, g. taentzer. the agg approach: language and environment. in engels et al. (eds.), handbook of graph grammars and computing by graph transformation, vol. ii: applications, languages, and tools. chapter 14, pp. 551– 603. world scientific, singapore, 1999. [fow99] m. fowler. refactoring—improving the design of existing code. object technology series. addison-wesley, reading, ma, 1999. [hjg08] b. hoffmann, e. jakumeit, r. geiß. graph rewrite rules with structural recursion. in mosbah and habel (eds.), 2nd intl. workshop on graph computational models (gcm 2008). pp. 5–16. 2008. [hm10] b. hoffmann, m. minas. defining models – meta models versus graph grammars. elect. comm. of the easst 29, 2010. proc. 6th workshop on graph transformation and visual modeling techniques (gt-vmt’10), paphos, cyprus. [hmp01] a. habel, j. müller, d. plump. double-pushout graph transformation revisited. mathematical structures in computer science 11(5):637–688, 2001. [hof01] b. hoffmann. shapely hierarchical graph transformation. in proc. ieee symposia on human-centric computing languages and environments. pp. 30–37. ieee computer press, 2001. [hof13] b. hoffmann. graph rewriting with contextual refinement. electr. comm. of the easst 61:20 pages, 2013. [hr10] a. habel, h. radke. expressiveness of graph conditions with variables. elect. comm. of the easst 30, 2010. international colloquium on graph and model transformation (gramot’10). [jak08] e. jakumeit. mit grgen zu den sternen. diplomarbeit (in german), universität karlsruhe, 2008. selected revised papers from gcm 2014 18 / 20 eceasst [jan83] d. janssens. node label controlled graph grammars. phd thesis, antwerp, 1983. [medj05] t. mens, n. v. eetvelde, s. demeyer, d. janssens. formalizing refactorings with graph transformations. journal of software maintenance 17(4):247–276, 2005. doi:10.1002/smr.316 http://dx.doi.org/10.1002/smr.316 [ph96] d. plump, a. habel. graph unification and matching. in cuny et al. (eds.), proc. graph grammars and their application to computer science. lecture notes in computer science 1073, pp. 75–89. springer, 1996. [plu93] d. plump. hypergraph rewriting: critical pairs and undecidability of confluence. in sleep et al. (eds.), term graph rewriting, theory and practice. pp. 201–213. wiley & sons, chichester, 1993. [ren04] a. rensink. the groove simulator: a tool for state space generation. in nagl et al. (eds.), applications of graph transformation with industrial relevance (agtive’03). lecture notes in computer science 3062, pp. 479–485. springer, 2004. [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation, vol. i: foundations. world scientific, singapore, 1997. [ues78] t. uesu. a system of graph grammars which generates all recursively enumerable sets of labelled graphs. tsukuba j. math. 2:11–26, 1978. [vj03] n. van eetvelde, d. janssens. a hierarchical program representation for refactoring. electronic notes in theoretical computer science 82(7), 2003. a double-pushout rewriting the standard theory of graph rewriting is based on so-called spans of (injective) graph morphisms [eept06], where a rule consists of two morphisms from a common interface i to a pattern p and a replacement r. an alternative proposed in [ehp09] uses so-called co-spans (or joins) of morphisms where the pattern and the replacement are both included in a common supergraph, which we call the body of the rule. rewriting is defined by double pushouts as below: pr̂ : i r g c h m př : b r g u h m intuitively, rewrites are constructed via a match morphism m : p → g in a source graph g; for a span rule r̂, removing the match of obsolete pattern items p\i yields a context graph c to which the new items r\i of the replacement are then added; for a co-span rule ř, the new items b\p are added first, yielding the united graph u before the obsolete pattern items b\r are removed. the constructions work if the matches m satisfy certain gluing conditions. 19 / 20 volume 71 (2015) http://dx.doi.org/10.1002/smr.316 http://dx.doi.org/10.1002/smr.316 more on graph rewriting with contextual refinement d r1 b1 p1 o p2 b2 r2j1 j2 pd rdbd figure 14: sequential composition of graph rewrite rules the main result of [ehp09] says that ř is the pushout of r̂, making these rules, their rewrite steps, and gluing conditions dual to each other. therefore we feel free to use the more intuitive gluing condition for r̂ together with a rule ř. the following definition and theorem adapt well-known concepts of [eept06] to our notion of rules. definition 12 (sequential rules composition) let r1 : (p1 ↪→ b1 ←↩ r1) and r2 : (p2 ↪→ b2 ←↩ r2) be rules, and consider a graph d with a pair d : (r1 ← d → p2) of injective morphisms. 1. then d is a sequential dependency of r1 and r2 if d 6↪→ p1 (which implies that d 6= 〈〉). 2. the sequential composition r1 ◦d r2 : (pd ↪→ bd ←↩ rd) of r1 and r2 along d is the rule constructed as in the commutative diagram of fig. 14, where all squares are pushouts. 3. two rewrite steps g⇒r1 h⇒r2 k are d-related if d is the pullback of the embedding r1 → h and of the match p2 → o.7 proposition 1 let r1 and r2 be rules with a dependency d and a sequential composition rd as in def. 12. then there exist d-related rewrite steps g⇒r1 h⇒r2 k if and only if g⇒rd k. proof. straightforward use of the corresponding result for “span rules” [eept06, thm. 5.23] and of the duality to “co-span rules” [ehp09]. 7 a pullback of a pair of morphisms b → d ←c with the same codomain is a pair of morphisms b ← a →c that is commutative, i.e., a → b → d = a → c → d, and universal, i.e., for every pair of morphisms b ← a′ → c so that a′ → b → d = a′ →c → d, there is a unique morphism a′ → a so that a′ → a → b = a′ → b and a′ → a →c = a′ →c. see [eept06, def. 2.2]. selected revised papers from gcm 2014 20 / 20 introduction graphs, rewriting, and contextual grammars schema refinement with contextual meta-rules modeling refinement by residual rewriting conclusions double-pushout rewriting ``vehicular steganography''?: opportunities and challenges eceasst “vehicular steganography”?: opportunities and challenges martin cooney, eric järpe, alexey vinel school of information technology, halmstad university, 301 18 halmstad, sweden martin.daniel.cooney@gmail.com abstract: what if an autonomous vehicle (av) could secretly warn of potential threats? “steganography”, the hiding of messages, is a vital way for vulnerable populations to communicate securely and get help. here, we shine light on the concept of vehicular steganography (vs) using a speculative approach: we identify some key scenarios, highlighting unique challenges that arise from indirect perception, message generation, and effects of perspective–as well as potential carrier signals and message generation considerations. one observation is that, despite challenges to transmission rates and robustness, physical signals such as locomotion or sound could offer a complementary, currently-unused alternative to traditional methods. the immediate implication is that vs could help to mitigate some costly safety problems–suggesting the benefit of further discussion and ideation. keywords: autonomous vehicles, steganography 1 introduction within the area of secure communications, this extended abstract focuses on the nascent topic of ”vehicular steganography” (vs), the hiding of messages by an autonomous vehicle (av). conducive qualities of avs for steganography include their many behavioral modalities, opaqueness due to high complexity, and emerging state of technological readiness that could allow for occasional odd behavior to be overlooked. some work has started to research vs as an extension to traditional network steganography. for example, de fuentes et al. explored steganography in vehicular ad hoc networks (vanets) [fbgg14]. such studies focus on methodology, but value could also emerge from identifying useful scenarios from a design perspective. also, given the ”security arms race”, alternatives can be explored; although one recent study examined how an underwater vehicle could mimic animal sounds [jxf+18], studies exploring physical signals for vs appear to be rare. to gain insight into the lay of the land, a speculative scenario-building approach was adopted, which seeks to provoke thought by constructing concrete ”memories” of a potential future reality via rapid ideation and discussion sessions. this allowed us to explore the ”big picture”, as well as carriers, message generation strategies, and constraints for physical steganography, as in fig. 1.1 1 we expect that various other questions and scenarios also exist. 1 / 4 no \volume defined! “vehicular steganography”?: opportunities and challenges a) b) horn, music speakers (fake engine noise) convertible tops, windows locomotion, lights platoon, av + environment message! 010101110... m= m1, ..., mn av recipient other (1) ? (2) (3) c) sensitive area bank $$$ ambushcrowd vs send: ”threat!” x emergency barrier crowd bank border military ambush adversary v2v v2i v2h figure 1: basic concept: (a) motivation, (b) unique properties, (c) carriers 2 motivation when could an av help humans by transmitting secret messages? traffic safety and crime prevention appear to be crucial: traffic accidents are the leading cause of death in young persons aged 5-29 years, involving millions of fatalities and injuries each year around the world2, and crimes are speculated to cost trillions annually [del16]. within this context, vs could deter a broad range of illicit activity: reckless or drunk driving, violent crime (hit-and-run, battery, homicide, rape), robbery and carjacking, and trafficking (drugs or humans). in the scenarios we formed, an adversary (an individual, small group, or representative of an oppressive state) displays threatening behavior while travelling inside an av to some sensitive area such as a crowded street, bank, border, military zone, or secluded site where an ambush could take place. indications of threat could include appearance (being armed and masked without a clear reason) or behavior (e.g. medicine non-adherence, with depression or sleep deprivation; hiding something; or potentially engaging in risky driving in manual mode, such as speeding, weaving, tailgating, and failing to yield or signal). the av could use steganography to warn in a case where (1) the adversary might detect an unconcealed message3 and (2) the av is not sure about the threat and requires another opinion. these warnings could be sent to avs or platoon members (v2v), human security (v2h), or protective infrastructure such as anti-tire spikes (v2i). the ideation sessions also indicated some ”unique” properties of vs not evident in traditional steganography: (1) (generation) no human composes the messages; the av itself must form a message based on inference from what it has sensed. (2) (indirection) in physical steganography through motion or sound, information is perceived indirectly through sensing, which could be slow and noisy. (3) (perspective) anisotropic messages could be sent to only an intended recipient at some specified angle and distance via motion or ”sound from ultrasound”, or to only young recipients via high frequency sounds. 2 https://www.who.int/publications/i/item/9789241565684 3 using only encryption is not enough to hide that messages are being sent (and some public-key algorithms could also be vulnerable to quantum attacks by a technically-advanced, future adversary) netsys 2021 2 / 4 eceasst 3 carriers in a situation where a message should be sent, steganography usually involves making small changes to little-used, redundant parts of a carrier signal (e.g. least significant bits (lsb), parity bits, or certain frequencies). carriers are typically digital, such as network communications (communicated frames/data packets), digital text, visual media (image, video), and audio (music, speech, sounds) [zms14]–but avs can also use physical carriers: visually, motion involving varying position and orientation (paths or trajectories), velocity, or acceleration, could be used to encode messages that could be detected via communicated gps, videos, or odometry. (lights, and opening or closing of windows and convertible tops could also be used.) aurally, fake engine sounds4, or even music players or horns could be used. more complex approaches could use multimodal signals from platoons, drone swarms, the environment (e.g., like birds flying in relation to an av’s motion) or rare modalities such as heat–which modalities are used when, and how signals are amplified, ordered, or delayed, could also be considered. 4 signal generation given a carrier, codes like ascii, morse, or polybius squares can be used to encode messages, but it was unclear how messages can be (1) formed and (2) embedded into a physical signal. (1) assuming a message comprises 1 to n short propositions mi, of varying importance vi (representing e.g. the nature of the emergency, location, or names) and time required to send ti, we propose that message generation can be formulated as an unbounded knapsack problem max ∑ vi f (xi) s. t. t∗ = ∑tixi ≤ t, xi ≥ 0, and f (2) < 2 f (1) (1) where xi stipulates if a proposition i will be included, t is the max time available for transmission, and f is a function that rises swifty from zero then slows (e.g. f ∼ e−(1/x) for x 6= 0, f (0) = 0), which expresses the higher likelihood of a proposition being received if it is repeated.5 (2) assuming a simplified locomotive scenario using sideways drifting to encode morse signals, t , the time available for sending messages can be computed by dividing d, the distance from an av to its next interruption (e.g., an intersection) by the velocity v0 and multiplying by α , the intended rate of message to non-message in the signal, related to encoding density (e.g. 1 : 10). then the av’s motion could be calculated by extending a social force model, with forces relating to goal-directed motion, environmental influences, and a steganographical message. table 1 summarizes practical constraints related to frequency, accuracy, and potential challenges.6 4 https://www.core77.com/posts/79755/cars-are-now-so-well-built-manufacturers-pipe-in-fake-engine-soundslisten-here 5 such a formulation could be useful as knapsack problems are greedily-solvable and have been abundantly studied, in similar combinatorial optimization contexts featuring values and costs. 6 1cm is our estimate based on a typical dashcam and 10m distance, and 1mm is reported for an indoors situation with markers: https://www.manufacturingtomorrow.com/article/2018/01/industrial-robots-encoders-for-tool-center-pointaccuracy/10867/ 3 / 4 no \volume defined! “vehicular steganography”?: opportunities and challenges table 1: some practical considerations for potentially useful carriers. 1 gps 5-10hz 5m (direct) 30-50 cm (dgps), 2cm (rtk) [psgu12] how to get data (cam)? 2 video 30 fps >1cm (relative), 1mm (markers) weather 3 audio onset 40hz f1= 0.817 [baks12] noise 5 discussion thus, the contribution of this paper lies in presenting some considerations for an av to send covert messages to help people, which we refer to as vehicular steganography (vs). a speculative approach revealed applications to traffic safety and crime prevention; three unique qualities of vs relating to indirection, message generation, and perspective; potential carriers; initial ideas for message generation and motion steganography; and some practical constraints. future challenges include steganalysis, perception of danger, ethics, and watermarking steganography to improve authenticity; our design process also revealed considerations for another kind of technology, socially interactive robots, which will be addressed in a separate paper, also with more technical details. by shining light on such topics, the aim is to help bring in a fresh perspective on the possibilities for avs to create a better, safer society. acknowledgements: funding was received from the swedish knowledge foundation through the safesmart synergy project, ”safety of connected intelligent vehicles in smart cities”. bibliography [baks12] s. böck, a. arzt, f. krebs, m. schedl. online real-time onset detection with recurrent neural networks. in proceedings of digital audio effects conference. 2012. [del16] m. delisi. measuring the cost of crime. the handbook of measurement issues in criminology and criminal justice, pp. 416–33, 2016. [fbgg14] j. m. de fuentes, j. blasco, a. i. gonzález-tablas, l. gonzález-manzano. applying information hiding in vanets to covertly report misbehaving vehicles. international journal of distributed sensor networks 10(2):120626, 2014. [jxf+18] j. jia-jia, w. xian-quan, d. fa-jie, f. xiao, y. han, h. bo. bio-inspired steganography for secure underwater acoustic communications. ieee communications magazine 56(10):156–162, 2018. [psgu12] m. perez-ruiz, d. c. slaughter, c. gliever, s. k. upadhyaya. tractor-based realtime kinematic-global positioning system (rtk-gps) guidance system for geospatial mapping of row crop transplant. biosystems engineering 111(1):64–71, 2012. [zms14] e. zielińska, w. mazurczyk, k. szczypiorski. trends in steganography. communications of the acm 57(3):86–95, 2014. netsys 2021 4 / 4 introduction motivation carriers signal generation discussion interaction nets: programming language design and implementation electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) interaction nets: programming language design and implementation abubakar hassan, ian mackie and shinya sato 16 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst interaction nets: programming language design and implementation abubakar hassan, ian mackie and shinya sato 1 department of informatics, university of sussex, falmer, brighton bn1 9qj, uk 2 lix, cnrs umr 7161, école polytechnique, 91128 palaiseau cedex, france 3 himeji dokkyo university, faculty of econoinformatics, 7-2-1 kamiohno, himeji-shi, hyogo 670-8524, japan abstract: this paper presents a compiler for interaction nets, which, just like term rewriting systems, are user-definable rewrite systems which offer the ability to specify and program. in the same way that the λ -calculus is the foundation for functional programming, or horn clauses are the foundation for logic programming, we give in this paper an overview of a substantial software system that is currently under development to support interaction based computation, and in particular the compilation of interaction nets. keywords: interaction nets, programming languages 1 introduction the purpose of this article is to describe an on-going project to build a programming environment for interaction nets. we give an overview of the entire project, and then focus on the specific parts that are now complete: programming language design and implementation. interaction nets [7] are a graphical, visual, programming language. programs are expressed as graphs, and computation is expressed as graph transformation. they are a general graph rewriting system, where both the nodes of the graph (the signature) and the rewrite rules are user-defined; in a very similar way to how a term rewriting system would be defined. one key factor that distinguishes interaction nets from other forms of graph rewriting is that the rules are highly constrained, and in such a way to obtain confluence of rewriting by construction. from another perspective, interaction nets are a low level implementation language: we can define systems of interaction nets that are instruction sets for the target of compilation schemes of other programming languages (typically functional languages, based on the λ -calculus). they have proven themselves successful for application in computer science, most notably with the coding of the λ -calculus, where optimal reduction (specifically lamping’s algorithm [8]) has been achieved [6]. to facilitate the use of interaction nets, we need high quality, robust, implementations, and a programming language to support the programmer. although we can already program in interaction nets (they are after all turing complete) they lack the structure that we expect from modern programming languages. thus the first contribution in this paper is a programming language for interaction nets, which lifts them from the “pure” world to allow them to be used in practice. to give some analogies as to what we are doing, consider the following where we give for a 1 / 16 volume 10 (2008) interaction nets particular formalism (or model), some examples of languages that have been created for it: • λ -calculus: functional programming languages, such as haskell [12], standard ml [11], ocaml, etc. • horn clauses: logic programming languages, such as prolog. • term rewriting systems: obj, elan, maude [4]. • π -calculus: pict [13]. the first goal of this paper is to add interaction nets to this list by providing a corresponding programming language that we call pin. in the list above, the programming language on the right is there to provide not only some syntactical sugar, but also to provide features that the theory does not offer. for instance, if we look in detail at the analogy with the λ -calculus and functional programming languages, functional languages allow the definition of functions such as: twice f x = f(f x), which is a significant improvement over λ f x. f ( f x) as a programming language, as programs can be reused for instance. in addition languages provide a module system, data-types (built-in and a mechanism for user-defined data-types), input/output, etc. the language pin can be considered as an object language for (interaction net) tools such as inblobs [2]. we can write programs in this language, but consider that it shares the same advantages/disadvantages of assembly language. as a diagram, we can see how the whole programming system comes together: l1 ... ln xml pin am @ @r � �� here, l1, . . . , ln are graphical tools that emit an xml [3] representation of the nets. we translate the xml file into the pin language, then compile it to our abstract machine (am) instruction set. when executed, the generated instructions will build the corresponding graph and execute it to normal form. the result of the computation is translated back into an xml file and visualised in the front end. we use xml as an intermediate language to keep pin and the tools li somewhat independent. the motivation for this line of compilation is that interaction nets have been implemented very efficiently (there are also parallel implementations [15]): by providing a compiler to interaction nets we potentially obtain parallel implementations of programming languages (even sequential ones) for free. however, this is not reported in the current paper: we are simply setting up the foundations and the framework for this development. to summarise, the paper contains three main contributions: we define a programming language for interaction nets, we define an abstract machine for interaction nets, and we define a compiler for interaction nets. proc. gt-vmt 2008 2 / 16 eceasst we have implemented this language, and we report on this at the end of the paper. in particular, we show that the new techniques developed for implementing interaction nets improve upon existing implementations. we also remark that the ideas used in this paper could be extended to work with other rewriting systems through translations to interaction nets. finally, we remark that this is the first attempt in this area, there is now a need to develop tools and optimisation techniques for this paradigm. related work. there are several implementations of interaction nets in the literature: a graphical one [9] and a textual, parallel one [15]. these are interpreters for interaction nets and the goal of those works was to investigate interaction nets: our focus is on explicitly extending interaction nets to a rich programming language. structure. the rest of this paper is structured as follows. in the next section we recall some background information about interaction nets. in section 3 we define a programming language for interaction nets. in section 4 we define an abstract machine for interaction nets (iam) and give the compilation schemes in section 5. section 6 gives details of the implementation. finally, we conclude the paper in section 8. 2 background an interaction net system is a set σ of symbols, and a set r of interaction rules. each symbol α ∈ σ has an associated (fixed) arity. an occurrence of a symbol α ∈ σ is called an agent. if the arity of α is n, then the agent has n + 1 ports: a distinguished one called the principal port depicted by an arrow, and n auxiliary ports labelled x1, . . . , xn corresponding to the arity of the symbol. we represent an agent graphically in the following way: �� �� α ? @ � ··· x1 xn y if n = 0 then the agent has no auxiliary ports, but it will always have a principal port. we represent agents textually as: y ∼ α(x1, . . . ,xn), and we omit the brackets if the arity of an agent is zero. a net n built on σ is a graph (not necessarily connected) with agents at the vertices. the edges of the net connect agents together at the ports such that there is only one edge at every port, although edges may connect two ports of the same agent. the ports of an agent that are not connected to another agent are called the free ports of the net. there are two special instances of a net: a wiring (a net with no agents) and the empty net. a pair of agents (α, β ) ∈ σ × σ connected together on their principal ports is called an active pair, which is the interaction net analogue of a redex. an interaction rule ((α, β ) =⇒ n) ∈ r replaces an occurrence of the active pair (α, β ) by a net n. the rule has to satisfy a very strong condition: all the free ports are preserved during reduction, and moreover there is at most one rule for each pair of agents. the following diagram illustrates the idea, where n is any net built from σ. 3 / 16 volume 10 (2008) interaction nets �� �� α �� �� β-� @ � � @ ... ... x1 xn ym y1 =⇒ n ... ... x1 xn ym y1 figure 1 shows an example of a system of interaction nets, which is an append operation of two lists. net �� �� nil �� �� app �� �� cons @� � � �� �� app � � @ � @ � � � �� �� cons 6 @� �� �� app @@�� =⇒ =⇒ �� �� nil �� �� app � � @ � �� �� nil @i figure 1: example net and rules an implementation of this rewriting process has to create the right-hand side of the net, and make all the connections (re-wirings). although it may not be the most trivial computation step, it is a known, constant time operation. it is for this reason that interaction nets lend themselves to the study of cost models of computation. all aspects of a computation are captured by the rewriting rules—no external machinery such as copying a chunk of memory, or a garbage collector, are needed. interaction nets are amongst the few formalisms which model computation where this is the case, and consequently they can serve as both a low level operational semantics and an object language for compilation, in addition to being well suited as a basis for a high-level programming language. we refer the reader to other papers on interaction nets for properties and additional theory. an example: encoding the integers. many simple examples of systems of interaction nets can be found in the literature, for instance the encoding of arithmetic expressions, etc. however, interaction nets are well suited for alternative representations of data-structures and algorithms. any integer n can be represented (non-uniquely) as a difference of two natural numbers: p − q. using this idea, we can represent integers in the following way: �� �� i �� �� s �� �� s �� �� s �� �� s 6 6 6 6 6 ... ...p     q proc. gt-vmt 2008 4 / 16 eceasst here, the agent s (of arity 1) is interpreted as successor. a linear chain of s agents of length n is used to give a representation of a natural number n. the representation of an integer simply takes two chains of length p and q, and connects them together as shown, using the agent i (of arity 2). although this representation is not unique, we can talk about canonical forms when p = 0 or q = 0 (or both), and there are interaction rules that can compute this. the integer zero is a net where p = q, in particular when p = q = 0: we can encode addition, subtraction and negation, for which we need several interaction rules. we just detail the encoding of addition. if n1 and n2 are the net representations of z1 = (p1 − q1) and z2 = (p2 − q2) respectively, then we can use the following configuration to encode the addition: �� �� i 6 �� �� i∗ �� �� i∗ ? ? n1 n2 the interaction rules for the agents are: �� �� i �� �� i∗ 6 ? � @ @ � =⇒ �� �� s �� �� s 6 ? =⇒ to see how this works, there will be two interactions between the agents i (of nets n1 and n2) and i∗ which concatenate the two chains. if z1 and z2 are both in canonical form and moreover both positive (or both negative) then the addition is completed with the two interactions. otherwise there will be an additional min{q1, p2} interactions between two s agents to obtain a net in normal form. 3 programming language following [5], an interaction net system can be described as a configuration c = (σ, ∆, r), where σ is a set of symbols, ∆ is a multiset of active pairs, and r is a set of rules. a language for interaction nets needs to capture each component of the configuration, and provide ways to structure and organise the components. starting from a calculus for interaction nets we build a core language. a core language can be seen both as a programming language and as a target language where we can compile high-level constructs. drawing an analogy with functional programming, we can write programs in the pure λ -calculus and can also use it as a target language to map high-level constructs. in this way, complex high-level languages can be obtained which by their definition automatically get a formal semantics based on the core language. 5 / 16 volume 10 (2008) interaction nets nets are written as a comma separated list of agents, corresponding to a flattening of the graph. there are many different (equivalent) ways we could do this depending on the order we choose to enumerate the agents. using the net on the left-most side of figure 1 as an example, we can generate a representation as the following list: x ∼ app(r,a), a ∼ nil, x ∼ nil this can be simplified by eliminating some names: app(r,nil) ∼ nil in this notation the general form of an active pair is α(. . .) ∼ β (. . .). we assume that all variable names occur at most twice. if a name occurs once, then it corresponds to one of the free ports of the net (r is free in the above). if a name occurs twice, then this represents an edge between two ports. in this latter case, we say that a variable is bound. the limitation on at most two occurrences corresponds to the requirement that it is not possible to have two edges connected to the same port in the graphical setting. we represent rules by writing l =⇒ r, where l consists of two agents connected at their principal ports. therefore rules can be written as α(..) ∼ β (..) =⇒ n, and as such we replace the ‘∼’ by ‘><’ so that we can distinguish an occurrence of a rule from an occurrence of an active pair. the two rules on the right of figure 1 (append) can be represented as: app(r,y) >< nil =⇒ r ∼ y app(r,y) >< cons(v,u) =⇒ r ∼ cons(v,z),u ∼ app(z,y) the names of the bound variables in the two nets must be disjoint, and the free variables must coincide, which corresponds to the condition that the free variables must be preserved under reduction. under this assumption, these two rules can be simplified to: app(y,y) >< nil =⇒ app(cons(v,z),y) >< cons(v,app(z,y)) =⇒ in this notation we observe that the right-hand side of the rule can always be empty. in this case we will omit the ‘=⇒’ symbol. this notation therefore allows sufficient flexibility so that we can either write nets in a compact way (without any net on the right of the ‘=⇒’) or in a more intuitive way where the right-hand side of the net is written out in full to the right of the arrow. during compilation, all rules are transformed into this compact notation. in figure 2, we give the syntax for the core language discussed above. language extensions. the core language allows the representation of the three main components of an interaction net system: agents, rules and nets. the language is very attractive for theoretical investigations: it is minimal yet computationally complete. the price for this simplicity is programming comfort. here, we give an overview of some practical extensions that enhance the usability of interaction nets. details and examples of these extensions can be found in [1]. proc. gt-vmt 2008 6 / 16 eceasst 〈pin〉 ::= { 〈ruledef 〉 | 〈netdef 〉 } 〈ruledef 〉 ::= 〈agent〉 ‘><’ 〈agent〉 [ ‘=>’ 〈ruleequation〉 { ‘;’ 〈ruleequation〉 } ] 〈ruleequation〉 ::= 〈term〉 ∼ 〈term〉 〈netdef 〉 ::= 〈equation〉 { ‘;’ 〈equation〉} 〈equation〉 ::= 〈agent〉 ∼ 〈agent〉 〈term〉 ::= 〈agent〉 | 〈var〉 〈agent〉 ::= 〈agentname〉 [ 〈ports〉 ] 〈ports〉 ::= ‘(’ 〈term〉 [ ‘,’ 〈term〉 ] ‘)’ 〈agentname〉 ::= 〈name〉 〈var〉 ::= 〈name〉 figure 2: syntax of the core language modular construction of nets. we allow nets to be named so that they can be built in a modular way. named nets contain as their parameters a list of the net’s free ports. using this mechanism, we can build a new net by instantiating a named net with some argument nets. as an example, we can represent the example net in figure 1 as: append x,r,a : app(r,a) ∼ x applist r : append nil,r,nil agent variables. some rules have the same structure and only differ in the agent names used. agent variables act as a place holder for agents in the rules. an instance of a rule with a set of agent variables a will create a new rule with elements of a replaced by the actual agents. in the example below, templ has agent variables a1,a2. the instance of this rule creates app(x,x) >< nil where the agent variables have been replaced with app, nil appropriately. templ a1,a2 : a1(x,x) >< a2 templ (app,nil) further extensions. we have designed a module system and a set of built-in agents and rules that perform input/output and arithmetic operations—these are reported in [1]. 4 the abstract machine here we describe the interaction net abstract machine (iam) by giving the instructions operating on a machine state. we first set up some notation used in the description of the machine. 7 / 16 volume 10 (2008) interaction nets definition 1 (memory model) let adr ⊆ n be a set of memory locations. agents of an interaction net system are agent = name × arity ×w , where arity ∈ n, name is an identifier, and w models connectivity between agent ports: w = {((l, p), (l′, p′)) | l, l′ ∈ adr, p, p′ ∈ n}. an element ((l1, p1), (l2, p2)) in the set w is ordered if either l1 < l2 or l1 = l2, p1 < p2. if an agent stored at location lk has it’s auxiliary port pi connected to the port p j of some agent at location lm, then ((lk, pi), (lm, p j)) ∈ w . we next define two functions to operate on the machine state: definition 2 • la : adr ×n → adr returns the location l ∈ adr pointed to by a given port of some agent: la(lk, pi) = lm such that ((lk, pi), (lm, p j)) ∈ w . • lp : adr × n → n returns a port number that is connected to a port of some agent node: lp(lk, pi) = p j such that ((lk, pi), (lm, p j)) ∈ w . we define the function ϒ : name × name → inst that given a pair of names for an active pair (α, β ) of a rule (α, β ) =⇒ n, returns a sequence of iam instructions that will build and rewire the net n. the mappings in ϒ are constructed during the compilation of a rule. machine configuration components. the iam machine consists of rules that transform configurations. a configuration is given by a 5-tuple 〈c, ς , f, a, h〉 where c is a sequence of instructions, ς is a stack of frames. each frame has an array of local variables and an operand stack. f is a set of pointers to the variable agents of the net, a is a stack of active pair agents, and h is the heap. an iam program c is a sequence of instructions that we summarise in figure 3. we write ‘−’ for the empty sequence and i, v, p, ar ∈ n. the component ς is a stack of frames. each frame f = (l, s) where l is a partial function with a finite domain of definition, mapping memory locations to their contents. if l is defined, then l[i 7→ l] means that l(i) = l. s is an operand stack produced by the grammar: s := − | v : s where v is any value representing a constant or a memory location, and − is the empty stack. the component f is a mapping from identifiers to a pair of natural numbers defined by: f(x) = (l, p). intuitively, it is used to hold the interface of the net. the heap h : adr → agent returns an agent node given some location l ∈ adr. the special token next is used to hold the next free location l ∈ dom(h). intuitively, h is a memory area filled with agent nodes. whenever a new node is put into the heap, the unused area marked by next is updated. figure 4 gives the iam instructions as a set of transition rules. each transition rule takes the form: ϒ ` 〈c, ς , f, a, h〉 ⇒ ϒ ` 〈 c′, ς ′, f′, a′, h′ 〉 which indicate how the components of the machine are transformed. we abbreviate (l, s) : ς to (l, s) in a configuration with only one frame in ς . initial and final states. the machine initialises the components c and ϒ giving the initial configuration: ϒ ` 〈c,−, [],−, []〉. the machine stops successfully when the instruction halt proc. gt-vmt 2008 8 / 16 eceasst is executed with the configuration ϒ ` 〈−,−, f,−, h〉 or prematurely if a pre-condition of an instruction is not satisfied. in this case, the final configuration is the one obtained after the last instruction that has been executed successfully. the evaluation mechanism. the evaluation of the net is started by executing the eval instruction. this instruction is appended at the end of the code sequence for the start active pair or initial expression. thus, before the evaluation of the net, there is at least one active pair in the machine’s active pair stack a. the pair in the stack a is examined and the code sequence of the rule for the pair is appended to the code component c of the machine (see semantics of eval in figure 4). the code for a rule will load one of the active agents into the stack s using the instruction loadactive, then start to build and rewire the right hand side net of the rule to the auxiliary agents connected to the interacting agent in the stack. the instruction pop pops the active agent from the component a. evaluation is terminated when a is empty and execution jumps to the instruction sequence after eval. instruction description enter push a new frame into the stack ς return remove the top frame from ς dup duplicate the top element on the stack s pop remove the top element on the active pair stack a load i push the element at index i of l onto the stack s. store i remove the top element of s and store it in l at index i. ldc v push the value v onto the stack s. fstore x store the top 2 elements at the top of s onto index x in f . fload x push the elements at index x of f onto the stack s. mkagent ar α allocate (unused) memory for an agent node of arity ar and name α in the heap h. mkvar x allocate memory for a variable node of arity 2 and name x in the heap getconnection p i push the agent a and the port number of a that connects at the auxiliary port p of the agent stored in local variable i loadactive α push the active agent α from active pair stack connectports pop two agents and two port numbers and connects the ports of the agents. if both ports are 0 (active pair) push an agent to a eval evaluate the active pair on top of the active stack. halt stop execution. figure 3: summary of iam instructions 9 / 16 volume 10 (2008) interaction nets ϒ ` 〈enter : c, ς , f, a, h〉 ⇒ ϒ ` 〈c, ([],−) : ς , f, a, h〉 ϒ ` 〈return : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈c, ς , f, a, h〉 ϒ ` 〈dup : c, (l, v : s), f, a, h〉 ⇒ ϒ ` 〈c, (l, v : v : s), f, a, h〉 ϒ ` 〈pop : c, (l, s), f, l : a, h〉 ⇒ ϒ ` 〈c, (l, s), f, a, h〉 ϒ ` 〈load i : c, (l[i 7→ v], s), f, a, h〉 ⇒ ϒ ` 〈c, (l[i 7→ v], v : s), f, a, h〉 ϒ ` 〈store i : c, (l, v : s), f, a, h〉 ⇒ ϒ ` 〈c, (l[i 7→ v], s), f, a, h〉 ϒ ` 〈ldc v : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈c, (l, v : s), f, a, h〉 ϒ ` 〈fstore x : c, (l, p : l : s), f, a, h〉 ⇒ ϒ ` 〈c, (l, p : l : s), f[x 7→ (l, p)], a, h〉 ϒ ` 〈fload x : c, (l, s), f[x 7→ (l, p)], a, h[la 7→ (n, a,{((la, pl ), (l, p))}∪ w)]〉 ⇒ ϒ ` 〈c, (l, p : l : s), f, a, h[la 7→ (n, a, w)]〉 ϒ ` 〈mkagent ar α : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈c, (l, l : s), f, a, h[l 7→ (α, a, /0)]〉 where l = next ϒ ` 〈mkvar x : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈c, (l, 1 : l : s), f, a, h[l 7→ (x, 2, /0)]〉 where l = next ϒ ` 〈getconnection p i : c, (l[i 7→ l], s), f, a, h〉 ⇒ ϒ ` 〈 c, (l[i 7→ l], lp(l, p) : la(l, p) : s), f, a, h 〉 ϒ ` 〈loadactive α : c, (l, s), f, l : a, h[l 7→ (n, a, w)]〉 ⇒ i f (n = α) ϒ ` 〈c, (l, l : s), f, la(l, 0) : a, h[l 7→ (n, a, w)]〉 else ϒ ` 〈c, (l, la(l, 0) : s), f, l : a, h[l 7→ (n, a, w)]〉 ϒ ` 〈connectports : c, (l, p1 : l1 : p2 : l2 : s), f, a, h[l1 7→ (n1, a1, w1), l2 7→ (n2, a2, w2)]〉 ⇒ i f (p1 + p2 = 0) ϒ ` 〈c, (l, s), f, l2 : a, h[l1 7→ (n1, a1, w1 ∪{((l1, 0), (l2, 0))}), l2 7→ (n2, a2, w2 ∪{((l1, 0), (l2, 0))})]〉 else ϒ ` 〈c, (l, s), f, a, h[l1 7→ (n1, a1, w1 ∪{((l1, p1), (l2, p2))}), l2 7→ (n2, a2, w2 ∪{((l1, p1), (l2, p2))})]〉 ϒ[(α, β ) 7→ c] ` 〈eval : c, (l, s), f, l1 : a, h[l1 7→ (α, a1, w1 ∪{((l1, 0), (l2, 0))}), l2 7→ (β , a2, w2 ∪{((l1, 0), (l2, 0))})]〉 ⇒ ϒ[(α, β ) 7→ c] ` 〈c : eval : c, (l, s), f, l1 : a, h[l1 7→ (α, a1, w1), l2 7→ (β , a2, w2)]〉 ϒ ` 〈eval : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈c, (l, s), f, a, h〉 ϒ ` 〈halt : c, (l, s), f, a, h〉 ⇒ ϒ ` 〈−,−, f,−, h〉 figure 4: iam instructions proc. gt-vmt 2008 10 / 16 eceasst 5 compilation the compilation of pin into iam instructions is governed by the schemes: cpin compiles a program, ca compiles an agent, ct compiles a term, cn compiles a net and cr compiles a rule. for correctness purposes, the list of functions generated during compilation must be unfolded in the following ordered way: if c1; . . . ; ck are the schemes generated by cpin, then the next function to be unfolded is ci such that all functions cp, p < i, have already been unfolded. the compilation of a program generates the following code: cpinj(σ,〈u1 ∼ v1, . . . un ∼ vn〉, r)k = cnju1 ∼ v1, . . . , un ∼ vnk;eval;halt; crjr1k; . . . crjrnk; where r1, ..., rn = r are instances of rules. σ is a set of symbols and each ui ∼ vi is an active pair. the compilation scheme cnju ∼ v, . . . , un ∼ vnk compiles a sequence of active pairs. we use the scheme crjrik to compile a rule ri ∈ r: crjrik = inst = crjα(t1, . . . ,tn) >< β (u1, . . . , un)=>u1 ∼ s1, . . . , un ∼ snk, ϒ[(α, β ) 7→ inst, (β , α) 7→ inst]. compilation of a rule creates a mapping from active agent names to the instruction sequence inst generated in the rule table ϒ. figure 5 collects together the compilation schemes cn and cr, that generate code for the input source text. the schemes use a set n of identifiers to hold all free variables of the net. compiling a variable that already exists in n means that the variable is bound. the auxiliary function ar(α) returns the arity of the agent α ∈ σ. we end this section with a concrete example of compilation, and give the code generated for the simple system given below: eps >< eps eps ∼ eps this system contains just one agent and one rule, and the net to be compiled is an instance of that rule. the output of the compiler is given below. enter mkagent 0 eps ldc 0 mkagent 0 eps ldc 0 connectports eval halt enter loadactive eps store 0 loadactive eps store 0 pop return the first and second columns are the code sequence for the active pair and rule respectively. the abstract machine loads the program into memory then sequentially executes the byte codes for the active pairs. the instruction eval calls the execution of the code block for the corresponding rule. the rule table ϒ is examined to determine the start and end address of the code sequence for the rule. below we give a snapshot of the execution trace. 11 / 16 volume 10 (2008) interaction nets ct jxk =   i f (x ∈ n ) fload x; n \{x} else fstore x; mkvar x; n ∪{x} ct jα(t1, . . . ,tn)k =   mkagent ar(α) α ; for 1 ≤ i ≤ n cp jtik i; ldc 0; crjα(t1, . . . ,tn) >< β (v1, . . . , vk) =>u1 ∼ s1, . . . , um ∼ smk =   enter; crt jα(t1, . . . ,tn)k; crt jβ (v1, . . . , vk)k; for 1 ≤ i ≤ m cejui ∼ sik; pop; return; crt jα(t1, . . . ,tn)k =   loadactive α ; store 0; for 1 ≤ i ≤ n crrjtik i 0; cejt ∼ sk =   ct jtk; ct jsk; connectports; crrjtk j i =   getconnection j i; ct jtk; connectports; cnju ∼ v, . . . , un∼vnk =   enter; ceju∼vk; ... cejun∼vnk; cpjtk j =   dup; ldc j; ct jtk; connectports; figure 5: compilation schemes • represents the active pair stack a of the machine. • top represents the stack s. • n0 ... represents the local variable array l. the state after execution of each instruction is shown. components that do not contain any value are omitted. note that this net contains no interface, thus the interface list f does not appear in the execution trace. refer to the transition rules in figure 4 for details on how these configurations are obtained. proc. gt-vmt 2008 12 / 16 eceasst mkagent 0 e ps eps ldc 0 eps 0 mkagent 0 e ps 0 eps eps ldc 0 0 0 eps eps connectports eps eps loadactive e ps eps eps store 0 n0 ... eps eps loadactive e ps n0 ... eps eps store 0 n0 ... eps eps pop n0 ... eps eps return eps eps observe that after the execution of connectports, a pointer to the newly created active pair is pushed into the stack a. since the rule for this active pair contains an empty right hand side net, there is no re-wiring that is performed. after evaluation, the active pair stack becomes empty. after the last instruction return of the rule, remaining active pair agents in the heap are unreachable from any of the machine’s components, and can be garbage collected or reused. we do not address the issues of heap garbage collection or agent reuse in this paper. 6 the implementation here we give a brief overview of the pragmatics of the language. we have implemented the compiler, and here we show example programs, the use of the system, and also some benchmark results comparing with other implementations of interaction nets. the prototype implementation of the compiler and abstract machine can be downloaded from the project’s web page. the compiler reads a source program and outputs an executable with the extension ‘.pin’. the pin file can then be executed by the abstract machine. various examples and instructions on how to compile and execute a program are provided on the webpage. the table below shows some benchmark results that we have obtained. we compare the execution time in seconds of our implementation (pin) with amine [14] an interaction net interpreter, and sml [11] a fully developed implementation. the last column gives the number of interactions performed by both pin and amine. the first two input programs are applications of church numerals where n = λ f .λ x. f nx and i = λ x.x. the encodings of these terms into interaction nets 13 / 16 volume 10 (2008) interaction nets are given in [10]. the next programs compute the ackermann function defined by: a(m, n) =   n + 1 if m = 0 a(m − 1, 1) if n = 0 and m > 0 a(m − 1, a(m, n − 1)) if m > 0 and n > 0 the following rules are the interaction net encoding of the ackermann function: pred(z) >< z, dup(z,z) >< z, pred(x) >< s(x), dup(s(a),s(b)) >< s(dup(a,b)), a(r,s(r)) >< z, a1(pred(a(s(z),r)),r) >< z, a(a1(s(x),r),r) >< s(x), a1(dup(pred(a(r1,r)),a(y,r1)),r) >< s(y), and a(3,8) means computation of a(s(s(s(s(s(s(s(s(z)))))))),r) ∼ s(s(s(z))). input pin amine sml interactions 322ii 0.002 0.006 2.09 383 245ii 0.016 0.088 1355 20211 a(3,8) 3 16 0.04 8360028 a(3,10) 51 265 0.95 134103148 we can see from the table that the ratio of the average number of interactions/sec of pin to amine is approximately 3 : 1. interaction nets are by definition very good in sharing computation thus more efficient than sml in the first two programs. however, interaction nets do not perform well in computations that benefit from sharing data interacting agents are consumed. our short term goal is to extend interaction nets with data sharing mechanisms. 7 acknowledgment we thank our anonymous referees and all our colleagues at the workshop for their helpful comments. 8 conclusions in this paper we have given an overview of a programming language design and compilation for interaction nets. experience with the compiler indicates that the system can be used for small programming activities, and we are investigating building a programming environment around this language, specifically containing tools for visualising interaction nets and editing and debugging tools. current research in this area is focused on richer programming constructs and higher level languages of interaction that do not burden the programmer with some of the linearity and pattern matching constrains. the compiler presented in this paper is a first attempt to compile interaction nets, and issues such as compiler optimisations are very much the subject of current research. there are well-known translations of other rewriting formalisms into interaction nets: the compiler presented in this paper can consequently be used for these systems. current work is investigating the usefulness of this approach. proc. gt-vmt 2008 14 / 16 eceasst bibliography [1] http://www.informatics.sussex.ac.uk/users/ah291/. [2] j. b. almeida, j. s. pinto, and m. vilaa. a tool for programming with interaction nets. in j. visser and v. winter, editors, proceedings of the eighth international workshop on rule-based programming. elsevier, june 2007. to appear in electronic notes in theoretical computer science. [3] j. berstel and l. boasson. xml grammars. in mathematical foundations of computer science, pages 182–191, 2000. [4] m. clavel, f. durán, s. eker, p. lincoln, n. martı́-oliet, j. meseguer, and j. quesada. a maude tutorial. sri international, 2000. [5] m. fernández and i. mackie. a calculus for interaction nets. in g. nadathur, editor, proceedings of the international conference on principles and practice of declarative programming (ppdp’99), volume 1702 of lecture notes in computer science, pages 170– 187. springer-verlag, september 1999. [6] g. gonthier, m. abadi, and j.-j. lévy. the geometry of optimal lambda reduction. in proceedings of the 19th acm symposium on principles of programming languages (popl’92), pages 15–26. acm press, jan. 1992. [7] y. lafont. interaction nets. in proceedings of the 17th acm symposium on principles of programming languages (popl’90), pages 95–108. acm press, jan. 1990. [8] j. lamping. an algorithm for optimal lambda calculus reduction. in proceedings of the 17th acm symposium on principles of programming languages (popl’90), pages 16–30. acm press, jan. 1990. [9] s. lippi. in2 : a graphical interpreter for interaction nets. in s. tison, editor, rewriting techniques and applications (rta’02), volume 2378 of lecture notes in computer science, pages 380–386. springer, 2002. [10] i. mackie. yale: yet another lambda evaluator based on interaction nets. in proceedings of the 3rd international conference on functional programming (icfp’98), pages 117– 128. acm press, 1998. [11] r. milner, m. tofte, r. harper, and d. macqueen. the definition of standard ml (revised). mit press, 1997. [12] s. peyton jones. haskell 98 language and libraries. cambridge university press, 2003. [13] b. c. pierce and d. n. turner. pict: a programming language based on the pi-calculus. technical report 476, indiana, 1997. 15 / 16 volume 10 (2008) http://www.informatics.sussex.ac.uk/users/ah291/ interaction nets [14] j. s. pinto. sequential and concurrent abstract machines for interaction nets. in j. tiuryn, editor, proceedings of foundations of software science and computation structures (fossacs), volume 1784 of lecture notes in computer science, pages 267–282. springerverlag, 2000. [15] j. s. pinto. parallel evaluation of interaction nets with mpine. in a. middeldorp, editor, rta, volume 2051 of lecture notes in computer science, pages 353–356. springer, 2001. proc. gt-vmt 2008 16 / 16 introduction background programming language the abstract machine compilation the implementation acknowledgment conclusions microsoft word angyaletal.doc electronic communications of the easst volume 8 (2008) guest editors: tom mens, ellen van paesschen, kim mens, maja d’hondt managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the third international ercim symposium on software evolution (software evolution 2007) novel techniques for model-code synchronization lászló angyal, lászló lengyel, and hassan charaf 14 pages eceasst 1 / 13 volume 8 (2008) novel techniques for model-code synchronization lászló angyal, lászló lengyel, and hassan charaf budapest university of technology and economics {angyal, lengyel, hassan}@aut.bme.hu abstract: the orientation of the current software development practice requires efficient model-based iterative solutions. the high costs of maintenance and evolution during the life cycle of the software can be reduced by using tool-aided iterative development. this paper presents how model-based iterative software development can be supported through efficient model-code change propagation. the presented approach facilitates bi-directional synchronization between the modified source code and the refined initial models. the backgrounds of the synchronization technique are three-way abstract syntax tree (ast) differencing and merging. the ast-based solution enables syntactically correct merge operations. omg's model-driven architecture describes a proposal for platform-specific model creation and source code generation. we extend this vision with the synchronization feature to assist the iterative development. furthermore, a case study is also provided. keywords: mda, mic, model-based iterative development, three-way ast differencing, ast merging. 1 introduction the current model-based development approaches emphasize the use of models at all stages of software development. models are used to describe all artifacts of the system, i.e., user interfaces, interactions, and properties of all the components that comprise the system. the mda [1] approach separates the platform-independent application specification from the platform-dependent constructs and assumptions. a complete mda application consists of a definitive platform-independent model (pim) and one or more platform-specific models (psm) on those platforms that the application developer decides to support. the platformindependent artifacts are mainly unified modeling language (uml) [2] and other software models containing enough specification to generate the platform-dependent artifacts automatically by model compilers. uml is a widespread general purpose modeling language that is too general to support efficient source code generation. closely focusing on a specific problem domain, domain-specific languages (dsl) cover a narrow domain-specific area in a high abstraction level. therefore, greater part of the source code generation can be covered by domain-specific model processors. model-integrated computing (mic) [3] provides a framework for software production using both metamodeling environments and model interpreters. the domain-specific concepts of mic are similar to mda. mic supports the flexible creation of modeling environments by metamodeling basics, and helps tracking the changes of the models. using mic technique the domain-specific models can be converted into another format such as executable code. novel techniques for model-code synchronization proc. software evolution 2007 2 / 13 one of the most important challenges of model-based development is round-trip engineering [4]. almost every existing modeling tool supports generating the code skeletons, and synchronization of the skeleton with the models. however, it is insufficient in most cases. usually, the generated source code does not contain enough logic to be used effectively without further manual programming. the current reverse engineering tools mostly focus on the inter-procedural calls or pattern recognition, and there is lack of tool support for the statement-level handling of method bodies, but it is also important. the method bodies cannot be supported without the comprehension of their logic. textual-based solutions are unable to extract enough information, therefore an ast-based approach is required. in order to support model-driven iterative development, software models and the source code should be kept synchronized. this work provides a three-way ast difference analysis and merge-based software model-code synchronization solution. the remainder of the paper is organized as follows. the next section discusses the motivation. section 3 provides background information and related work, section 4 describes our model-code synchronization approach and a concrete platform-specific solution with a case study. finally, conclusions and future work are elaborated. 2 motivation our motivation is to support automatic, iterative application generation and synchronization with the same platform-independent model set for different platforms, e.g. for different mobile phone platforms (fig. 1). clas s mobile { public int i; public void e{ system.out... } } java clas s mobile { public: void e{ cout<<“ax” } } c++ clas s mobile { public int i; public void e{ c ons ole.wr... } } c# model space code space abstraction level psmspims source code model transformation 1 sync 1 r esource diagram state 1 state 4 state 3 state 2 dynamic diagram s java symbian window s mobile model transformation 2 model transformation 3 sync 2 sync 3 fig. 1. motivation principles the model space consists of the platform-independent models (pims) and the platformspecific models (psms). the pims are composed of static resource and other dynamic models (fig. 1), which describe the user interface and the behaviour of the application. a psm represents a concrete implementation of the pims in a selected platform. several development platforms are available for mobile phones e.g. symbian [5], java micro edition [6], windows mobile [7]. eceasst 3 / 13 volume 8 (2008) generally, any psms can be produced from the pim using graph rewriting-based [8] model transformations. psms are constructed to facilitate source code generation. visual modeling and transformation system (vmts) [9] is an n-layer metamodeling environment which supports visual editing of models according to their metamodels, and allows specifying object constraint language (ocl) constraints in model transformation rules. both the models and the transformation rules are represented internally as directed, labeled graphs stored in the vmts’s database. also, vmts is a model transformation system, which transforms models using graph rewriting techniques and supports code generation from models. vmts facilitates an efficient and simple way to define model transformations visually. the relations between the ast elements can be considered the metamodel of the language and its instance model as a concrete ast of a source code that is written in that language. according to [10], an ast metamodel is powerful, because the manipulation of programs became universal. the regeneration of the code from an ast model is possible via model traversal and parsed source code can be stored in that model. thus, choosing an ast model as psm can be advantageous. both pims and the source files generated from the psms can be modified by the developers. the model and the source code are modified independently of each other over the time. to solve the synchronization problem, this paper introduces how vmts supports modelbased iterative software development. in order to avoid the error-prone manual change propagation, the synchronization feature between these states is essential. the bi-directional non-destructive model-code change propagation enables iterative and incremental software development (iisd). the nondestructive way means that the previously committed changes in both sides will be saved. the whole development process can be split into iterations instead of sequential phases. after each iteration, developers have executable software to use and to draw conclusions from it, and to incorporate the observations into the next iteration of the project. initial model updated model user updated source code manual modification bi-directional non-destructive synchronization code generation user updated source code second iteration updated model model and code are consistent manual modification bi-directional non-destructive synchronization original source first iteration initial state fig. 2. iterative model-based development fig. 2 depicts a typical scenario of iisd. in the beginning of the first iteration, we generate code from a model. the development affects both the model and the code. at the end of each novel techniques for model-code synchronization proc. software evolution 2007 4 / 13 iteration, before the start of the next one, we should bring the model and the code into a consistent state. in model-driven iterative development the synchronization between psms and source code should be supported. due to the incremental synchronization, the model is always up to date, developers can choose between further source code modifications and additional model refinements. this paper describes a possible solution to model-based iisd. 3 background and related work considerable research was conducted in the subject of source code differencing and merging in the past 30 years. software development projects are typically based on teamwork, where the team mates work on many kinds of common files. the methods of the source code comparing and merging were and will always be an actual problem. the comparison of two files as sequences is originated in string operations, like finding the longest common subsequence (lcs) [11] or the longest common substring [12]. the two algorithms cover different matching approaches. the traditional file comparing tools usually use modified versions of the longest common subsequence searching algorithms. the difference analysis of two strings (s1, s2) or trees (t1, t2) produces an edit script [11]. an edit script contains the operations needed to transform s1 into s2 or t1 into t2. the analysis first matches the common parts then generates the script that contains as few operations as possible, such as a minimal list. for example, the popular unix diff utility [13] finds the longest common subsequence of the lines of the two files, then creates a sequence of insert and delete operations. diff works well on general text files, but in several cases when differencing source code files, diff can produce useless edit scripts, because diff does not know the specific features of the programming languages. to compare two pieces of source code correctly, the algorithm must take the grammar of the language into consideration. these algorithms work on the parse trees of the files and use different approaches. hierarchical structures such as trees cannot be handled as such simple sequences. [14] provides an algorithm for change detection in hierarchically structured information that has linear time complexity. this approach is supposed to be used on ordered trees with large amount of data. fastmatch and editscript algorithms are provided for the two subproblems of the change detection problem. the fastmatch uses some heuristic solutions e.g. equality comparison of two labeled nodes containing a value for computing the unique maximal matching. the algorithm editscript supports the insert/delete/update and the complementary move operations. the refined versions of the algorithms have been adopted in our proof-of-concept implementation that is mentioned later. the improved versions [15] of these algorithms work on unordered trees and allow copy/glue operations, as well. merge performs reconcile of changes in some revisions of a software artifact. merge firstly applies the comparison of the files in order to detect the incorporated changes to be propagated. distinction can be made between the numbers of artifacts e.g. files processed by the merge. the two-way approach works on two revisions (a1 and a2) of the same software artifact. typically this is error-prone and requires human intervention and verification, because this is unable to unambiguously detect the modifications. therefore, this technique is rarely used in practice. according to the three-way merge approach, the common ancestor (a0) of two modified artifacts (a1 and a2) is used, to detect and resolve more conflicts, e.g. two-way merge is unable to distinguish insert and delete operations. the change propagation is eceasst 5 / 13 volume 8 (2008) performed after the difference analysis between a1 and a2, which takes account of a0. this approach can unambiguously detect the changes, therefore, this is the most reliable in practice. the three-way comparison with automatic conflict resolution allows automated merge. however, in several cases, human validation of the conflict management is still required to obtain source code that compiles. the best-known tool that uses three-way merge approach is diff3 [16]. further information can be found about other software merging techniques in [17]. merge tools that work on parse trees have to output the reconciled source code from the tree. pretty-printing [18] is a technique that makes an internal structure human readable. it traverses the ast and visits every node while printing the output. it facilitates the source code generation from an ast. the tokens belonging to the nodes are printed in order. the inserted white spaces and blank lines make the output pretty. it is also known as code beautifier, which makes a code well-indented. [19] addresses the conflicts during three-way merge of hierarchically structured documents. the possible eleven combinations of operations on the pairs of child nodes during merge are enumerated. 3dm [20] and deltaxml [21] are tools for performing differencing and three-way merging of xml files. 3dm applies heuristic tree matching between trees. this performs node similarity measurements i.e. content similarity and child list similarity when no exact matches exist. the tree matching of deltaxml uses an optimized longest common subsequence (lcs) algorithm, which matches the nodes at each level on the trees, and then the differences are reconciled. syntactic merge techniques using trees or graphs as underlying data structure. [22] proposes a program merging system that consist of a syntax-based comparator, a synchronous pretty-printer, and a merging editor. the synchronous print simultaneously traverses the trees that is previously matched by the comparator, and produces an intermediate merged file that can be edited further with the merging editor, the differences are coloured in the editor to the user can verify the merge. there is an other interesting approach in [23], where a graph-based software merging using a category theory approach is presented. the proposed approach does not depend on any specific programming language. the programs are represented as graphs and the approach uses categorical formalisms. the novelty of this work is the combination of three-way tree differencing, edit script controlled tree patching (merge) and model-driven development approach to achieve the synchronization of the model and code spaces. most of the tools and cutting edge researches in the field of synchronization focus on differencing and merging between the same kinds of artifacts (mostly xml data files and source code). 4 contributions first of all, in this section, a novel psm-code synchronization approach is elaborated, that can perform a syntactically correct three-way merge. that is followed by a concrete platformdependent solution of vmts with a case study. the elaboration of such model transformations that can synchronize the pim-psm is not in the scope of this paper. novel techniques for model-code synchronization proc. software evolution 2007 6 / 13 4.1 the general synchronization method the following method is based upon the assumption that the structure of the psm and the ast built by the parser are conformable or at least very similar. the synchronization method depicted in fig. 3 is based on ast differencing. the files containing the source code (s0, s1) are parsed into asts. in the model space the psm (m1) describes the concrete implementation in a concrete platform. the pims, omitted from fig. 3, and psms are stored in the model database. in our case the psm is an ast model that can contain directly the ast representation of the platform-specific code. this makes easier to match and then merge the two different representations. obviously, the complex ast model (psm), which is based on model containment hierarchy, is not editable directly by the developer. due to the large number of nodes and the absence of the layout, it is nearly impossible to visualize it. psms that contain ast representation are modified indirectly via model transformations or model-code synchronization. our solution uses three-way approach starting from the persistently stored artifacts (s0, s1, m1). the four phases of our synchronization method are (i) the auxiliary tree building phase, (ii) the edit script generation phase applying tree differencing, (iii) edit script transformation phase, and finally (iv) the three-way tree merge phase. the last synchronized ast model (m0) is logically equal to the common ancestor (s0) that reflects the last synchronization state. it is important that both of them contain the same implementation state, but in different representations. parser clas s mobile { public int i; public void e{ c ons ole.wr... } } pretty printer parser d iffd if f modified code r efined ast m odel next synchronized ast model next synchronized ast ast of the last com mon ancestor modified ast code space model space (database) m od if y m od if y last synchronized ast m odel m1 a0 m0 m2 clas s mobile { public int i; public void e{ c ons ole.wr... } } last c om mon ancestor s0 s1 a1 clas s mobile { public int i; public void e{ c ons ole.wr... } } synchronized code s2 a2 in-memory ast node ast node in model m er ge m 0 d0 d1 m m 1 p2 p1 p0 fig. 3. block diagram of the model-code synchronization both the model and the code can be edited independently and the synchronization means change propagation between them. the resulting artifacts of the merge are s2, and m2. the modified code (s1) and the refined model (m1) will be overwritten by the synchronized ones (s2 and m2). the others are temporary memory objects (a0, a1, a2). the difference analysis (d0, d1) between the two modified software artifacts (s1 and m1) and the common ancestor (s0) finds and identifies the applied edit operations. since the underlying eceasst 7 / 13 volume 8 (2008) data structures are trees, these are atomic tree node operations. the source files (s0, s1) are parsed (p0, p1) into abstract syntax trees (a0, a1), and the psm (m1) is already an ast structure. the differencing (d0, d1) produces the merge instructions, which are used during the merge phase (m). then using the pretty-printing technique (p2) source code (s2) can be generated i.e. the in-memory ast is serialized. the model (m2) is updated directly, no other operations are needed. in order to provide further details related to the presented method, fig. 4 illustrates a detailed version of the synchronization process depicted in fig. 3. trees denoted by a0, a1, a2 are in the code space, while m1, m2 are in the model space according to fig 2, but t0, t1 are temporary trees for helping the difference analysis. the first phase of the synchronization builds two auxiliary trees (t0, t1) from the two different representations of the implementation using the visitor pattern [24] and model traversal. in the second phase, the modifications made on the source code and the model refinements are identified, and edit scripts (ε1 and ε2) are produced. the differencing algorithm (d0, d1) works on the auxiliary trees, instead of comparing directly the ast in the memory and the psm in the database. the homogeneous auxiliary tree representation is designed to fit the tree matching algorithm. the heterogeneous structure of an ast is difficult to traverse using a general algorithm, because the different types of nodes are not comparable. the advantage of this method is that it hides the concrete way of storage of the ast and model traversals: the differencing (d0, d1) and the edit script processing algorithms (a0, a1) are the same for arbitrary programming languages. d iff er en ci ng d ifferencing ins del transform scripts edit scripts apply edit scripts syntactically equals ast of the last com mon ancestor r efined ast m odel next synchronized ast model modified ast next synchronized ast a2 a1 a0 m1 m2 in-memory auxiliary trees tree diff t1 t0 d 0 d 1 a 0 a 1 !1 !2 ! 1 ' !2 ' fig. 4. the details of synchronization supported edit operations in our method are the following: (i) moving a subtree, (ii) insert, (iii) delete, and (iv) update a node, because they are the typical ast modification operations. since the model representation is in a database, therefore, recognizing subtree movements can keep the number of executed row inserts/deletes low during the synchronization. a node update occurs e.g. when the name of a method or the return type is changed. reordering two statements in a method body causes a subtree move operation. each operation refers to exactly novel techniques for model-code synchronization proc. software evolution 2007 8 / 13 one tree node that is affected by the operation, which can be a root of a subtree, its parent node and its index, as well. a merged edit script should be created from the two already existing scripts (εm=ε1+ε2). this script could be executed later on the common ancestor (a0) and the result is a synchronized ast that contains all modifications. in our case there is no representation of a0 in each space, since it is stored only as a file (s0). therefore, instead of using εm, we produce two transformed edit scripts (ε1 ′ and ε2 ′ ) in order to execute them on the opposite side (a1 or m1) to create the synchronized artifacts denoted by a2 and m2. this does not require storing the ancestors in both spaces, only a file in the code space. while transforming the edit scripts, it is important that the operations from different edit scripts can affect on each other. since operations store positions, and inserting/deleting a node shifts the indices of the children of a parent node, positions should be maintained to be suitable for the application on the opposite ast. the conversion of the edit scripts (i) updates the positions of the contained operations if necessary, (ii) removes the overlapping delete operations and (iii) resolves the conflict between two edit operations. the conflict resolution needs labeling one side as master side. since from the model-based development point of view the model representation is the more relevant, by default, models are the primary artifacts. class seminar { private int number; } class seminar { private string name; private int number; } class seminar { private int number; public void setnumber(int n) {} } class instructor { public string name; } revision a (code) revision b (model) common ancestor s 0 s 1 m 1 fig. 5. a small example to illustrate the edit script correction phase, we introduce a small example in fig. 5. revision b represents the rendered view of the ast model. the matching finds the correspondence between the two pairs of trees. the edit scripts, derived from the non-matched nodes, are listed in table 1 and table 2 (the affected nodes got informative names). operation affected node type index parent node ins name_private_system.string memberfield 0 seminar table 1. the difference (ε1) between revision a and common ancestor the index of the edit operation that inserts method setnumber into revisionb has to be increased, because under class node seminar in the first position the declaration node of the name attribute is inserted that shifts the positions. the correct indices of the nodes are name: 0, number: 1, and setnumber: 2. eceasst 9 / 13 volume 8 (2008) operation affected node type index parent node ins setnumber_public_system.int32 membermethod 1 seminar ins in_n_system.int32 parameterdeclexpr 0 setnumber_public_system. int32_parameters ins instructor typedeclaration 1 global_types ins name_public_system.string memberfield 0 instructor table 2. the difference (ε2) between revision b and common ancestor after the script conversion, in the merge phase the updated edit scripts are applied to both sides, which performs the change propagations. in this approach the edit scripts are used as inputs by the merging algorithms to control the merge. the merge can be considered as tree patching, it executes the modifications described by the edit operations. formally, s2=s1+ε2 ′ and m2=m1+ε1 ′. the model in the database (m2) and the ast in the memory (a2) have to contain the same elements both syntactically and semantically. this synchronized state (s2) is stored as a common ancestor for the next iteration. it is also important to note that the synchronization works for round-trip engineering as well. for instance, if the model m0 in fig. 3 is not defined, and, consequently, the ast model (m1) is empty, the difference algorithm detects that the whole model m2 must be built from scratch during the synchronization, and this should also work in the opposite direction (i.e. code generation). 4.2 a platform-specific solution one of the platforms supported by vmts is windows mobile that solution is presented in fig. 6. vmts uses the codedom technology [25] as a language independent model representation of the source code, and this means that the code generation is just a syntax tree composition. c# parser clas s mobile { public int i; public void e{ c ons ole.wr... } } clas s mobile { public int i; public void e{ c ons ole.wr... } } c# parser d iff d if fc om mon ancestor c # file modified c# file r efined c odedom m odel synchronized c odedom m odel synchronized c odedom tree c odedom tree of the comm on ancestor modified c odedom tree code space model space c odedom code generator clas s mobile { public int i; public void e{ c ons ole.wr... } } synchronized c# source file m er ge fig. 6. synchronization in the windows mobile platform novel techniques for model-code synchronization proc. software evolution 2007 10 / 13 [26] introduces how vmts generates source code using model transformation methods and codedom metamodel. pims are transformed by model processors into codedom instance models. the code generation technology of codedom has several internal pretty-printers i.e. for c#, vb.net, and c++ languages, but it can be extended to support other languages. we have created a demonstrative proof-of-concept implementation of the proposed approach. the open source c# parser nrefactory [27] is used, that is capable of parsing, tokenizing, and building abstract syntax tree. the codedom object tree in memory is built by an ast visitor class provided with nrefactory. the codedom tree and the codedom model (psm) in the database are traversed and ordered, labeled trees are built from them, which are easy to process due to their homogeneous structure. the labels of the nodes are the types of the ast elements to help the matching. each node wraps an element from the parsed codedom tree or from the model. the tree can be traversed in a general way, each special attribute of an ast class are explicated as node children. the tree differencing and edit script computing are currently performed by the algorithm contributed in [14], because it was easy to implement and allows using heuristics (node similarity) during the matching, but we work on an algorithm that is more suitable for our requirements for ast matching. the edit scripts are transformed by our algorithm that works as mentioned previously. there are two different edit script execution units in the merger: one patches the codedom object tree and the other handles the codedom model in the database. these execution units are explicitly controlled by edit scripts. reliability criterias of the merging approach can be the following: (i) all changes must be detected, (ii) all must be propagated to the other side, (iii) syntactical correctness is ensured, (iv) there are no compile errors after the merge i.e. semantical correctness, (v) model consistency remains (vi) program (business) logic is unharmed, (vii) proper conflict handling e.g. automatic decision making, overlapping changes, identical changes (duplication) detection and solution, reorder the newly inserted nodes. criteria iv, vi and some of vii have not been addressed yet. general limitations of syntactical-based techniques are that they are unable to detect undeclared variables, since the code is still syntactically correct. some object-oriented behaviour i.e. the dynamic binding cannot be resolved by only syntactical approaches. certain techniques and related problems are enumerated in [17]. we tried the synchronization on a source code, which was auto-generated by vmts plugin [28] generator. the source file contained 2100 lines of code, 55 classes, its size was 104 kb, and the number of the tree elements affected by the differencing was above 7000. we made two copies of that file to create the common ancestor and the two revisions. some changes were made to the revisions without making a conflict: a method body was removed and an extra class, with a method and several statements in it, was added. currently one file is generated directly from a psm in vmts. we also tested the synchronization of the ast model with the generated file. to simulate the changes of the pim, for example a class diagram, the changes in the ast model and in the file affected the attributes, the methods, and method parameters. after the synchronization, the changes were propagated bi-directionally. during these simple studies, all criteria have been met. the expected results were that the edit scripts exactly reflect the incorporated changes, and all of them were propagated. further studies require more complex examples with the pim-psm model synchronization, which is currently a subject of our research. eceasst 11 / 13 volume 8 (2008) 4.3 limitations and shortcomings the drawback of reading source code into ast to manipulate is that the subsequent serializing looses the formatting and comments unless the parser, the pretty-printer and the ast take care of formatting information and comments. although codedom contains comment node, only namespace, class and class member nodes handle the comments. fortunately the chosen parser reads the comments but stores them separately from the ast nodes. however, a complete synchronization approach should deal with the changes in the comments as well. this depends on the parsing technology and the design of the ast. codedom has some other limitations; it does not support all of the language elements introduced by c#. using code snippet nodes the need of the unsupported elements can be bypassed. it works well on files, which are generated from domain-specific models by vmts. these limitations hardly reduce the applicability of our solution, because the model-driven development mainly relies on the models and not on the generated code. the changes are typically performed in the model, but the developer has the opportunity to carefully modify the code, as well. distinction can be made between the conflicts: there are low-level syntactical (e.g. order of ast nodes) or simple semantic (e.g. conflicts derived from variable renaming) conflicts and high level semantic conflicts. to resolve high-level semantic conflicts, knowledge of a developer is essential, for example, when the same logic is incorporated into both artifacts and deciding which one should be omitted. the reliable automation of the presented approach cannot be fully achieved until the higher level intentions behind them are not extracted. the correct conflict resolution requires human validation or in case of automation, the result should be validated before use. 5 conclusions and future work the presented synchronization involves structural model-code differencing and three-way tree merging. the main advantage is that in contrast to typical code generation approaches, it permits modifying the generated code and instead of losing the changes, they will be synchronized back to the models. the incremental approach is more effective and keeps the previous modifications within both sides. the modular design allows the model-model and in addition the code-code synchronization. codedom models are applied as psms, which enables easy code generation. the illustrated method with some minor changes can be a solution to the synchronization challenge of other platforms as well. we separated the specific algorithms from the general ones, the differencing and the edit script transformation algorithms that contain the core logic of the synchronization are reusable. for instance, to support java platform, a parser to java language has to be written, which is capable of building codedom tree in memory or a converter is required that creates codedom tree from the ast of a java source. code generation for java can be performed by the j# code provider [29] of codedom. obviously any other language dependent or independent code syntax scheme can be used as psm instead of codedom. vmts facilitates effective modeling with easy domain-specific modeling language definition and the dependent customizable domain-specific visualization. the introduced model-code synchronization method affects not only the higher level parts of the classes i.e. methods and attributes, but also the whole source code space including statements. in the codeto-model direction, this approach is useless without model transformations, because the novel techniques for model-code synchronization proc. software evolution 2007 12 / 13 complex codedom model has to be transformed into domain-specific models in order to make the approach useable in the practice. one drawback is that if the granularity of the transformation rules is not fine enough, some small changes in the code will not affect the pims directly. the prevention of information loss during the model transformations bridging different levels of abstraction should be facilitated by tracing the transformations. in contrast to text-based approaches, syntactical correctness is ensured, since the change propagation works on the asts of the selected language and the elements of an ast are based on the grammar of the language. semantically correct synchronization and supporting more software platforms are the subject of our future work. acknowledgements the fund of “mobile innovation centre” has supported in part, the activities described in this paper. this paper was supported by the jános bolyai research scholarship of the hungarian academy of sciences. the c# source code parsing into codedom is performed by the free open source nrefactory parser [27]. references [1] omg, mda guide version 1.0.1, document number: omg/2003-06-01, http://www.omg.org/docs/omg/03-06-01.pdf [2] omg uml 2.0 spec., http://www.omg.org/uml/ [3] j. sprinkle, “model-integrated computing”, ieee potentials, 23(1), 2004, pp. 28-30. [4] r. kollman, p. selonen, e. stroulia, t. systä, and a. zundorf, “a study on the current state of the art in tool-supported uml-based static reverse engineering”, ninth working conference on reverse engineering, washington, 2002, pp. 22-34. [5] c. enrique ortiz, “introduction to symbian os for palm os developers”, http://www.metrowerks.com/pdf/introsymbianosforpalmdevelopers.pdf [6] sun, java 2 platform, micro edition (j2me), http://java.sun.com/j2me/index.jsp [7] microsoft windows mobile, http://www.microsoft.com/windowsmobile [8] g. rozenberg (ed.), handbook on graph grammars and computing by graph transformation: foundations, vol.1 world scientific, singapore, 1997. [9] vmts web site, http://vmts.aut.bme.hu [10] p. newcomb, “abstract syntax tree metamodel standard astm tutorial”, omg’s second annual architecture-driven modernization workshop, alexandria, usa, 2005. [11] e. w. myers, “an o(nd) difference algorithm and its variations”, algorithmica, 1(2), 1986 pp. 251-266. [12] w. f. tichy, “the string-to-string correction problem with block moves”. acm transactions on computer systems, 2(4), november 1984, pp. 309-321. [13] unix diff manual, web site: http://unixhelp.ed.ac.uk/cgi/man-cgi?diff [14] s. chawathe, a. rajaraman, h. garcia-molina, and j. widom, “change detection in hierarchically structured information”, in proceedings of the acm sigmod international conference on management of data, 25(2), montreal, quebec, june 1996, pp. 493-504. [15] s. chawathe and h. garcia-molina, “meaningful change detection in structured data”, proceedings of the 1997 acm sigmod international conference on management of data, 26(2), may 1997, pp. 26-37. eceasst 13 / 13 volume 8 (2008) [16] s. khanna, k. kunal, and b. c. pierce.” a formal investigation of diff3”, manuscript, university of pennsylvania, 2006. [17] t. mens, “a state-of-the-art survey on software merging”, ieee transactions on software engineering, 28(5), may 2002, pp. 449-462. [18] d.c. oppen, “prettyprinting” acm transactions on programming languages and systems, 2(4), 1980, pp. 465-483. [19] u. asklund, “identifying conflicts during structural merge”, proceeding of the nordic workshop on programming environment research '94, lund university, 1994, pp. 231-242. [20] t. lindholm, “a three-way merge for xml documents”, proceedings of the 2004 acm symposium on document engineering, october 28-30, 2004, milwaukee, wisconsin, usa, pp. 1-10 [21] r. la fontaine, “merging xml files: a new approach providing intelligent merge of xml data sets”, in proceedings of xml europe 2002, barcelona, spain, 2002. [22] w. yang, “how to merge program texts”, journal of systems and software, vol. 27, no. 2, 1994, pp. 129-135. [23] n. niu, s. easterbrook, and m. sabetzadeh “a category-theoretic approach to syntactic software merging”. 21st international conference on software maintenance (icsm'05), budapest, hungary, sept. 2005. pp 197-206. [24] e. gamma, r. helm, r. johnson, and j. vlissides, “design patterns”, addison-wesley, massachusetts, 1994. [25] microsoft’s codedom web site, http:// msdn2.microsoft.com/en-us/library/system.code dom.aspx [26] l. lengyel, t. levendovszky, g. mezei, b. forstner, h. charaf, “metamodel-based model transformation with aspect-oriented constraints”, electronic notes in theoretical computer science, vol. 152, pp. 111-123. [27] #develop web site: http://sharpdevelop.net/ [28] g. mezei, t. levendovszky, h. charaf, “a presentation framework for metamodeling environments”, workshop in software model engineering, montego bay, jamaica, 2005. [29] visual j# code provider web site: http://msdn2.microsoft.com/en-us/library/w5e3ax1a (vs.80).aspx electronic communications of the easst volume 59 (2013) special issue of the first workshop on patterns promotion and anti-patterns prevention (ppap 2013) analysing anti-patterns static relationships with design patterns fehmi jaafar, yann-gaël guéhéneuc, sylvie hamel, and foutse khomh 26 pages guest editors: aminata sabané, wei wu managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 eceasst analysing anti-patterns static relationships with design patterns fehmi jaafar, yann-gaël guéhéneuc, sylvie hamel, and foutse khomh fehmi jaafar school of computing, queen’s university, ontario, canada sylvie hamel diro, université de montréal, québec, canada yann-gaël guéhéneuc and foutse khomh dgigl, école polytechnique de montréal, québec, canada abstract: anti-patterns are motifs that are usually thought to be good solutions to some design or implementation problems, but back-fires badly when applied. previous studies have reported that anti-patterns make object oriented systems hard to maintain. anti-patterns motifs usually have dependencies with other classes in the system. in this paper, we propose to analyse these dependencies (with in particular design patterns) in order to understand how developers can maintain programs containing anti-patterns. to the best of our knowledge, no substantial investigation of anti-pattern dependencies with design patterns has been done before. this paper presents the results of a study that we performed on three different systems, argouml, jfreechart, and xercesj, written in java, and of size ranges from 1,191 to 3,325 classes, to analyse the static relationships between anti-patterns and design patterns. we found that these relationships (1) exist, but (2) are temporary and (3) classes participating in such relationships are more change-prone but less fault-prone than other anti-pattern classes. keywords: anti-patterns, design patterns, static relationships, change-proneness, fault-proneness, software evolution, mining software repositories. 1 context and problem software systems continuously evolve in order to incorporate ever changing customers’ requirements, performance improvements, and bug fixes. without proper knowledge, developers may introduce anti-patterns in the system. in theory, anti-patterns [web95] are “poor” solutions to recurring problems. in practice, an anti-pattern is a literary form that describes a bad solution to recurring design problems that leads to negative effects on code quality [bmmm98]. opposite to anti-patterns, design patterns [ghjv94] are “good” solutions to recurring design problems, conceived to increase reuse, code quality, code readability and, above all, maintainability and resilience to changes. large, long-lifespan systems often have both design patterns and antipatterns and, consequently, anti-patterns and design patterns may have some relationships, i.e. the classes participating to some design patterns may be in relation with those participating to some anti-patterns. the static relationships among classes are typically use, association, aggregation, and composition relationships [ga04]. 1 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns research problem most previous work agree that anti-patterns render the maintenance of systems more difficult [kpga12, akga11] and that design patterns can serve as guide in program exploration and, thus, ease maintenance [vok04, acc+07]. however, there are few previous work about the relationships between anti-patterns and design patterns. yet, understanding these relationships can help developers to better understand and maintain software systems. contribution the contribution of this paper is three-fold. first, we extend the existing empirical knowledge by an empirical study that demonstrates that anti-patterns and design patterns can have static relationships in systems. second, we provide knowledge about the evolution of these relationships. finally, we present the results of an empirical study on the impact of such static relationships on change proneness and fault proneness. indeed, in the study reported in this paper we observe that anti-patterns do have static relationships with design patterns, but that these relationships are temporary. yet, anti-pattern classes participating in such relationships are more change-prone but less fault prone than other anti-pattern classes. therefore, it seems that developers sometimes use design patterns as a temporary fix for anti-patterns (since both the anti-patterns and the relationships to design patterns) are removed later from the systems. the fix seems to be working since the fault-proneness of anti-patterns are reduced. detecting and analysing static relationships of anti-patterns is important from the points of view of both researchers and practitioners. in fact, we bring evidence to researchers that (1) anti-patterns do statically relate to some design patterns, that (2) some anti-patterns have more relationships with design patterns than others, and that (3) these relationships indicate specific trends for the evolution of classes in term of fault-proneness and change-proneness. organisation section 2 relates our study with previous work. section 3 presents our method. section 4 describes our empirical study. section 5 presents the study results, while section 6 discusses them, along with threats to their validity. finally, section 7 concludes the study and outlines future work. 2 related work several work studied the detection and the analysis of anti-patterns and design patterns. for lack of space, we only cite some relevant work, the interested readers can find more references in our previous work [mgdl10] and [ga08]. anti-patterns definition and detection code smells and anti-patterns both describe re-occurring software problems. code smells are symptoms of problems existing in the source code [mgdl10]. code smells are related to the inner workings of classes while anti-pattern include the relationships among classes and are more situated on a micro-architectural level. concretely, code smells give warnings to software developers that the source code has some problems, while antipatterns provide software managers, architects, designers, and developers a common vocabulary for recognizing possible sources of problems in advance. the first book on “anti-patterns” in object-oriented development was written in 1995 by webster [web95]. in this book, the author proc. ppap 2013 2 / 26 eceasst reported that an anti-pattern describes a frequently used solution to a problem that generates ineffective or decidedly negative consequences. riel [rie96] defined 61 heuristics characterising good object-oriented programming to assess a program quality manually and improve its design and implementation. these heuristics are similar and–or precursor to code smells. brown et al. [bmmm98] discussed 40 anti-patterns, which are often described in terms of lower-level code smells. these books provide in-depth views on heuristics, code smells, and anti-patterns aimed at a wide academic audience. they are the basis of all the approaches to detect anti-patterns. the study presented in this paper relies on anti-patterns detection approach proposed in [mgdl10]. however several other approaches have been proposed in the past. for example, van emden et al. [em02] developed the jcosmo tool. this tool parses source code into an abstract model (similar to the famix meta-model). it uses primitives and rules to detect the presence of smells and anti-patterns. the jcosmo tool can visualize the code layout and anti-patterns locations. the goal of jcosmo is to help developers assess code quality and perform refactorings. the main difference compared with other detection tools is that jcosmo tries to visualize problems by visualizing the design. marinescu et al. developed a set of detection strategies to detect anti-patterns using metrics [rdgm04]. they later refined their detection strategies by adding information collected from the documentation of problematic structures. they showed how to detect several anti-patterns, such as god classes and data classes. settas et al. explored the ways in which an anti-pattern ontology can be enhanced using bayesian network [scf12]. their approach allow software developers to quantify the existence of an anti-pattern using bayesian network; based on probabilistic knowledge contained in an anti-pattern ontology regarding relationships of anti-patterns through their causes, symptoms and consequences. the integrated platform for software modeling and analysis (iplasma) described in [lm06] can be used for anti-patterns detection. this platform calculates metrics from c++ or java source code and applies rules to detect anti-patterns. the rules combine the metrics and are used to find code fragments that exceed some thresholds. design pattern definition and detection the first book on “design patterns” in object-oriented development was written in 1996 by gamma et al. [ghjv94]. since this book, several workshops and conferences have emerged to propose new patterns. many papers have been published studying the use, impact of patterns. the study presented in this paper relies on design patterns detection approach proposed in [ga08]. however several other approaches have been proposed in the past. for example, one of the first papers about detecting design patterns was written by kramer et al. [kp96] in 1996. they introduced an approach detecting design information directly from c++ header files. this information is stored in a repository. the design patterns are expressed as prolog rules which are used to query the repository with the extracted information. their work focused on detecting five structural design patterns: adapter, bridge, composite, decorator, and proxy. recently, an approach based on similarity scoring has also been proposed [tcsh06], which provides an efficient means to compute the similarity between the graph of a design motif and the graph of a system to identify classes participating to a design motif. iacob [iac11] presented a method that aims at identifying proven solutions to recurring design problems through design workshops and systems analysis. indeed, during a design workshop, a team of 3-5 designers is asked to design a system and the design issues they address 3 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns are collected. moreover, a set of systems are analysed in order to identify in what measure the design issues discussed during the workshops are considered in the implementation of existing solutions. candidates for being documented as design patterns are the most recurring design issues in both the workshops and the systems analysis. anti-patterns and design patterns static relationships analysis there are few papers analyzing the relationships among anti-patterns and design patterns. vokac [vok04] analyzed the corrective maintenance of a large commercial program, comparing the defect rates of classes participating in design motifs against those that did not. he found that the observer and singleton motifs are correlated with larger classes; classes playing roles in factory method were more compact, less coupled, and less defect prone than other classes; and, no clear tendency exists for template method. their approach showed correlation between some design patterns and smells like largeclass but do not report an exhaustive investigation of possible correlations between these patterns and anti-patterns. pietrzak and walter [pw06] defined and analysed the different relationships that exist among smells and provide tips about how they could be exploited to alleviate the detection of anti-patterns. the authors performed an experiment to show that the use of knowledge about identified smells in jakarta tomcat code supports the detection process. they found examples of several smell dependencies, including aggregate relationships. the certainty factor for those relations in that code suggests the existence of correlation among the dependent smells and applicability of this approach to anti-patterns detection. rather than focusing on the relationships among code smells and anti-patterns, our study focuses on analysing anti-patterns relationships with design patterns. yamashita et al. [ym13] reported that the interactions between code smells affect maintenance. they investigated the interactions amongst 12 code smells and analyzed how those interactions relate to maintenance problems. they revealed how smells that were co-located in the same artifact interacted with each other, and affected maintainability. indeed, they found that code smell interactions occurred across coupled artifacts, with comparable negative effects as same-artifact co-location. anti-patterns and design patterns evolution and impact bieman et al. [bsw+03] explored whether the relative stability of design pattern classes compared to other classes were being empirically realized. the authors showed that large classes were found to be the most change-prone and that pattern-based classes were more change-prone. vokac [vok04] found significant differences in the fault-proneness of different design patterns in a study of a large c ++ industrial system. in the same direction, gatrell et al. [gch09] showed that pattern-based classes are more change-prone than non-pattern classes. on the other hand, olbrich et al. [ocbz09] analysed the historical data of lucene and xerces over several years and concluded that blob classes and classes subjected to shotgun surgery have a higher change frequency than other classes; with blob classes featuring more changes. similarly, chatzigeorgiou and manakos [cm10] studied the evolution of long method throughout successive versions of two open-source systems and concluded that a significant percentage of these smells are introduced during the addition of new methods to the system. they also found that this anti-pattern persists in systems and that their removal is often a side effect of proc. ppap 2013 4 / 26 eceasst adaptive maintenance rather than the result of targeted refactoring activities. using azureus and eclipse, khomh et al. [kpga12] investigated the impact of code smells on the changeproneness of classes and showed that in general, the likelihood for classes with code smells to change is very high. khomh et al. [kpga12] also investigated the relation between the presence of anti-patterns and the changeand fault-proneness of classes. they detected 13 anti-patterns from 54 releases of argouml, eclipse, mylyn, and rhino, and analyzed the likelihood that a class with an anti-pattern will change in the future, in particular to fix a fault. they concluded that classes participating in anti-patterns are significantly more likely to be subject to changes and to be involved in fault-fixing changes than other classes. khomh et al. [kpga12] also investigated the kind of changes experienced by classes with anti-patterns. their study focused on two types of changes: structural and non-structural changes. structural changes are changes that would alter a class interface while non-structural changes are changes to method bodies. they concluded that structural changes are more likely to occur in classes participating in anti-patterns. deligiannis et al. [dsrs03] proposed the first quantitative study of the impact of anti-patterns on software development and maintenance activities. they performed a controlled experiment with 20 students on two systems. the experiment aimed to understand the impact of blob classes on the understandability and maintainability of systems. the results of their study suggest that blob classes affect the evolution of design structures and the subjects’ use of inheritance. however, deligiannis et al. did not assess the impact of anti-patterns static relationships on subjects’ understandability and ability to perform the tasks successfully. yamashita and moonen [ym12] investigated the extent to which code smells reflect factors affecting software maintainability and observed that using code smells definitions alone, developers cannot fully evaluate the overall maintainability of a software system. they conclude on the need to combine different analysis approaches in order to achieve more complete and accurate evaluations of the overall maintainability of a software system. taba et al. [sn13] argue that anti-patterns can tell developers whether a design choice is “poor” or not. they explored the use of anti-patterns for fault prediction, and strive to improve the accuracy of fault prediction models by proposing various metrics based on anti-patterns. they considered the history of anti-patterns in files from their inception into the system. they observed that files participating in anti-patterns have higher fault density than other files and that their proposed anti-pattern-based metrics can provide additional explanatory power over traditional metrics and improve fault prediction models. they suggest that developers use their proposed metrics to better improve fault prediction models and better focus testing activities and the allocation of support resources. we share with all the above authors the idea that anti-patterns detection is a powerful mechanism to assess code quality, in particular indicating whether the existence of anti-patterns and the growth of their relationships makes the source code more difficult to maintain. summary: these previous works raised the awareness of the community towards the impact of anti-patterns and design patterns on software development and maintenance activities. in this paper, we build on these previous works and analyze the existence and evolution of antipatterns static relationships with design patterns. we aim to understand if the negative effects of anti-patterns can transit to other classes through static dependencies and if design patterns can mitigate these negative effects. we also analyze the evolution and impact of relationships 5 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns between anti-patterns and design patterns in terms of fault proneness and change proneness. 3 approach this section describes the steps of our data collection process. we use two previous approaches decor[mgdl10] to detect anti-patterns, and demima[ga08] to detect design patterns. 3.1 step 1: detecting anti-patterns we use the defect detection for correction approach decor[mgdl10] to specify and detect anti-patterns. decor is based on a thorough domain analysis of anti-patterns defined in the literature, and provides a domain-specific language to specify code smells and anti-patterns and methods to detect their occurrences automatically. it can be applied on any object-oriented system through the use of the padl [ga08] meta-model and pom framework. padl is a meta-model to describe object-oriented systems [ga08]. pom is a padl-based framework that implements more than 60 metrics. indeed, decor proposes a domain-specific language to specify and generate automatically design defect detection algorithms. a domain-specific language offers greater flexibility than ad hoc algorithms because the domain experts, the software engineers, can specify and modify manually the detection rules using high-level abstractions, taking into account the context, environment, and characteristics of the analysed systems. moreover, the language allows specifying defect detection algorithms at a high-level of abstraction using key concepts found in their text-based descriptions, not in the underlying ad hoc detection framework, as in previous work. moha et al. [mgdl10] reported that decor current anti-patterns’ detection algorithms achieve 100% recall and have a precision greater than 31% in the worst case, with an average precision greater than 60%. 3.2 step 2: detecting design patterns we use the design motif identification multilayered approach (demima)[ga08] to specify and detect design patterns. demima ensures traceability between motifs and source code by first identifying idioms related to binary class relationships to obtain an idiomatic model of the source code and then, by using this model, it can identify design motifs and generate a design model of the system. indeed, demima makes it possible to recover two kinds of design choices from source code: idioms pertaining to the relationships among classes and design motifs characterizing the organization of the classes. demima depends on a set of definitions for unidirectional binary class relationships. the formalizations define the relationships in terms of four language-independent properties that are derivable from static and dynamic analyses of systems: exclusivity, type of message receiver, lifetime, and multiplicity. demima keeps track of data and links to identify and ensure the traceability of these relationships. demima also uses explanation-based constraint programming to identify microarchitectures similar to design motifs. this technique makes it possible to identify microarchitectures similar to a model of a design motif without having to describe all possible variants explicitly. we also use demima to detect motifs’s relationships. in fact, demima distinguishes use, association, aggregation, and proc. ppap 2013 6 / 26 eceasst composition relationships because such relationships exist in most notations used to model systems, for example, in uml. gueheneuc and antoniol [ga08] reported that demima can detect design patterns with a recall of 100% and a precision greater than 34%. while, for the detection of relationships among classes, the demima approach ensures 100% recall and precision. 3.3 step 3: analysing motifs static relationships table 1 summarizes anti-patterns considered in this paper. to perform the empirical study, we choose to analyse the relationships of the well known anti-patterns and six design patterns belonging to three categories: creational patterns (factory method and prototype), structural patterns (composite and decorator), and behavioral patterns (command and observer). thus, we choose these motifs because they are representative of problems with data, complexity, size, and the features provided by classes. we choose, also, these motifs because they have been used and analysed in previous work [mgdl10] and [kpga12]. definitions and specifications are outside of the scope of this paper and are available in [ghjv94] and [kpga12]. we assume that a design pattern p has a static relationships with the anti-pattern a if at least one class belonging to p has a use, association, aggregation, or composition relationships with one class belonging to a. 3.4 step 4: analysing the evolution of motifs and their static relationships our analysis goes as follows: we detect all static relationships between anti-patterns and design patterns in the first studied version of a system. then, we investigate whether these relationships persist in the following versions. we hold that a relationship will be ignored by our approach if the classes playing roles in anti-patterns in the first studied version are restructured and corrected and, thus, they do not belong to anti-patterns any more in the next versions. to analyse the evolution of static relationships between anti-patterns and design patterns, we need to detect class renamings, class changes, and fault fixing. if we considered only class name to identify classes in different versions, then a same class in two different versions is considered as two different classes if it is renamed. to overcome this issue, we use the structure-based and text-based similarities to identify class renamings in programs. concretely, we use previous approaches: advise [hghg12] and macocha [jgha11]. advise identifies class renamings using structure-based and text-based metrics, to assess the similarities between original and renamed classes, as follows: 3.4.1 structure-based and text-based similarities the structure-based similarity (strs), between a candidate renamed class ca and a target class cb, is defined as the percentage of their common methods, attribute types, and relationships. we compute the text similarity, between a candidate renamed class ca and each of the target classes cbi i ∈ [1,n], using a camel similarity (camels), and the normalized levenshtein edit distance (nd). the camels similarity between ca and cb represents the percentage of their common 7 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns tokens. the normalized edit distance (nd) between ca and cb is defined as: nd(ca,cb) = levenshtein(ca,cb) sum(length(ca),length(cb)) ∈ [0,1] let s(ca) (respectively s(cb)) be the set of methods, attributes, and relationships of ca (respectively cb). the structure-based and the text-based similarities of ca and cb are computed by comparing s(ca) to s(cb) using the jaccard index of similarity [rv96]. in fact, when we compare the similarities of a candidate renamed class ca to many target classes {cb1,...,cbn}, we first compare their structure-based similarity strs. we select the set of target classes having the highest strs value. then, we compute their textual similarities (nd and camels). finally, we combine nd and camels to compare the text similarity between names of the candidate class and the target class, because nd and camels assess to two different aspects of string comparison: nd is concerned with the difference between strings but cannot tell if they have something in common, while camels focuses on their common tokens but cannot tell how different they are. advise reports the s(cb) with the highest camels and the lowest nd scores as the class renamed from s(ca). the score combined of nd and camels is equal to: s = camelsnd we also use macocha [jgha11] to identify the set of changes performed on each class by mining version-control systems as follow: 3.4.2 analysing the change proneness and the fault proneness we explore whether classes belonging to an anti-pattern and related to a design pattern are less change prone than other anti-pattern classes. indeed, macocha mines version-control systems (cvs and svn), to detect changes committed in each class. a commit contains several attributes: the changed class names, the dates of changes, the name of the developer who committed the changes. macocha takes as input a cvs/svn change log and creates a profile that describes the evolution of each class. first, using fisher’s exact test [she07] and odds ratios (or), we investigate whether static relationships between anti-pattern and design pattern are significantly correlated to a higher class’s change-proneness. we present more details about this investigation in section 4. second, we compute the fault-proneness of a class by relating fault reports and commits to the class. indeed, fault fixing changes are documented in textual reports that describe different kinds of problems in a program. we parse the svn/cvs change logs of our subject systems and apply the heuristics by sliwersky et al. [szz05] to identify fault fix locations. we parse commit log messages using a perl script and extract bug ids and specific keywords, such as “fixed” or “crash” to identify fault fixing commits. from each fault fixing commit, we extract the list of files that were changed to fix the fault. this list of files tells us which classes where changed to fix the faults. 4 study definition and design the goal of our study is to analyse the existence, the evolution and the impact of the static relationships between anti-patterns and design patterns in software systems. the quality focus is proc. ppap 2013 8 / 26 eceasst argouml jfreechart xercesj # of classes 3,325 1,615 1,191 # of antisingleton 3 38 24 # of blob 100 49 12 # of cdsp 51 3 6 # of complexclass 158 52 7 # of longmethod 336 75 7 # of longparameterlist 281 76 4 # of messagechains 162 59 8 # of refusedparentbequest 123 5 7 # of spaghetticode 1 2 6 # of speculativegenerality 22 3 29 # of swissarmyknife 13 26 29 table 1: descriptive statistics of the object systems (cdsp: classdatashouldbeprivate) related to the quality of systems and to the evolution of classes participating in anti-patterns. the perspective is detecting the impact of relationships between anti-patterns and design patterns on class change-proneness and fault-proneness. the context of our experiment is three open-source java programs: argouml, jfreechart, and xercesj. 4.1 system under analysis we apply our approach on three java systems: argouml1, jfreechart2, and xercesj3. these systems can be classified as large, medium, and small systems, respectively. we use these systems because they are open source, have been used in previous work, are of different domains, span several years and versions, and have between hundreds and thousands of classes. table 1 summarises some statistics about these systems. argouml is an uml diagramming system written in java and released under the open-source bsd license. for anti-patterns dependencies analysis, we extracted a total number of 4480 snapshots from release 0.26 to release 0.34, in the time interval between september 27th, 2008 and december 15th, 2011. jfreechart is a java open-source framework to create charts. for macro co-change analysis, we considered an interval of observation ranging from june 15th, 2007 (release 1.0.6) to november 20th, 2009 (release 1.0.13 alpha). in such interval we extracted 2010 snapshots. xercesj is a collection of software libraries for parsing, validating, serialising, and manipulating xml. it is developed in java and managed by the apache foundation. for anti-patterns dependencies analysis, we extracted a total number of 159196 snapshots from release 1.0.4 to release 2.9.0, in the time interval between october 14th, 2003 and november 23th, 2006. 1 http://argouml.tigris.org/ 2 http://www.jfree.org/ 3 http://xerces.apache.org/xerces-j/ 9 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns 4.2 research questions we break down our study into three steps: first, we perform a preliminary study to verify the existence of relationships between anti-pattern and design pattern classes. next, we study the evolution of these relationships. finally, we analyse the fault proneness and the change proneness of classes containing anti-patterns and related to design patterns: • rq1: are there static relationships between anti-patterns and design patterns? • rq2: are the static relationships between anti-patterns and design patterns casual? • rq3: do static relationships between anti-patterns and design patterns impact change proneness and fault proneness? in the first question, we check if static relationships between anti-patterns classes and classes playing roles in design patterns exists. rq1: is a preliminary study and its results present an initial evidence for the other research questions. in the second question, we verify if these relationships are persistent during the evolution of the software systems. the third research question is designed to check whether classes participating in such relationships are more change-prone and fault prone than other anti-pattern and design patterns classes. to answer the third research question, we test the following null hypotheses: • h10 : the proportion of classes changed at least once between two releases is not different between anti-pattern classes participating or not in a static relationship with at least one design pattern. • h20 : the proportion of classes undergoing at least one fault-fixing change between two releases does not differ between anti-pattern classes participating or not in a static relationship with at least one design pattern. if we reject the null hypothesis h10 , we explain the rejection as: • h11 : the proportion of classes changed at least once between two releases is different between anti-pattern classes participating or not in static relationship with at least one design pattern. if we reject the null hypothesis h20 , we explain the rejection as: • h21 : the proportions of faults carried by anti-patterns classes which have static relationships with design patterns and faults carried by other anti-pattern classes are not the same. then, we check whether anti-patterns have effects transitive via static dependencies, i.e. we are attempting to compare the fault proneness and change proneness across the following groups of classes: (1) classes belonging to a design pattern and related to an anti-pattern and (2) classes belonging to a design pattern and not related to an anti-pattern. we test the following two null hypotheses: proc. ppap 2013 10 / 26 eceasst • h30 : the proportion of classes changed at least once between two releases is not different between design pattern classes participating or not in a static relationship with at least one anti-pattern. • h40 : the proportion of classes undergoing at least one fault-fixing change between two releases does not differ between design pattern classes participating or not in a static relationship with at least one anti-pattern. if we reject the null hypothesis h30 , we explain the rejection as: • h31 : the proportion of classes changed at least once between two releases is different between design pattern classes participating or not in static relationship with at least one anti-pattern. if we reject the null hypothesis h40 , we explain the rejection as: • h41 : the proportions of faults carried by anti-patterns classes which have static relationships with design patterns and faults carried by other anti-pattern classes are not the same. 4.3 analysis method the analysis reported in section 5 have been performed using the r statistical environment4. we use the contingency tables to assess the direction of the difference of fault proneness and change proneness across different group of classes. in statistics, a contingency table is a table in a matrix format that displays the frequency distribution of the variables. we use fisher’s exact test [she07], to check whether the difference is significative between anti-pattern classes having static relationships with design patterns and other anti-pattern classes in term of change proneness and fault proneness. fisher’s exact test is a statistical significance test used in the analysis of contingency tables. although in practice it is employed when sample sizes are small, it is valid for all sample sizes. the test is useful for categorical data that result from classifying objects in two different ways. it is used to examine the significance of the association (contingency) between the two classifications. we also compute the odds ratio [she07] that indicates the likelihood for an event to occur. the odds ratio (or) is defined as the ratio of the odds p of an event occurring in one sample, e.g. the odds that anti-patterns having static relationships with design patterns are identified as fault-prone, to the odds q of the same event occurring in the other sample, i.e. the odds that the rest of anti-pattern classes are identified as fault-prone. an odds ratio greater than 1 indicates that the event (i.e. a fault) is more likely in the first sample (i.e. anti-patterns having static relationships with design patterns), while an odds ratio less than 1 indicates that it is more likely in the second sample. the odds ratio is calculated as follows: or = p/(1−p)q/(1−q) . 4 http://www.r-project.org 11 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns 5 study results we now present the results of our empirical study. we use data collected from the three programs and some external sources (e.g. bug reports) to answer our three research questions and to discuss typical examples of our findings as follows: rq1: are there static relationships between anti-patterns and design patterns? yes table 2 shows that, for the majority of anti-patterns, we detect static relationships with design patterns. on the one hand, we notice that different anti-patterns can have different proportions of static relationships with design patterns. this observation is not surprising because these systems have been developed in three unrelated contexts, under different processes. thus, they have different complexities and different usages of design motifs. consequently, they have different number of static relationships among their design motifs. on the second hand, the design pattern that has the most relationships with anti-patterns is the command design pattern. for example, we noted that 50% of static relationships among speculativegenerality and design patterns in argouml, are with the command design pattern. in xercesj, we observe that 41% of relationships among classdatashouldbeprivate was with the command design pattern. no clear tendency exists for complexclass and refusedparentbequest. for example, complexclasses have static relationships with six analysed design patterns with equivalent proportions in argouml, jfreechart, and xercesj. but.. in the three systems, if a class participates in a design pattern, it does not have a relationship with the spaghetticode anti-pattern, as shown in table 2. in fact, in all three systems, we do not detect any class playing a role in a spaghetticode and having static dependencies (use, association, aggregation, and composition relationships) with one of the six design patterns (command, composite, decorator, factorymethod, prototype, and observer). we discuss these observations in details in 6. relevance design patterns are naturally geared to improve adaptability and maintainability. each design pattern aims to make specific changes easier [jy01]. for example, in xercesj, the class org.apache.xerces.validators.common.xmlvalidator is an excessively complex class interface. the developer attempts to provide for all possible uses of this class. in her attempt, she adds a large number of interface signatures to meet all possible needs. the developer may not have a clear abstraction or purpose for org.apache.xerces.validators.common.xmlvalidator, which is represented by the lack of focus in its interface. thus, we claim that this class belongs to a swissarmyknife anti-pattern. this antipattern is problematic because the complicated interface is difficult for other developers to understand and obscures how the class is intended to be used, even in simple cases. other consequences of this complexity include the difficulties of debugging, documentation, and maintenance. we detect that this class has a use-relationship with the class org.apache.xerces.validators.dtd.dtdimporter, which belongs to the command design pattern. using command classes makes it easier to delegate method calls without knowing the owner proc. ppap 2013 12 / 26 eceasst table 2: proportion of the relationships between anti-patterns and design patterns, in each first version of our analysed systems (sr: static relationship among anti-patterns and design patterns) anti-patterns systems # of sr antisingleton argouml 68 jfreechart 92 xercesj 83 blob argouml 161 jfreechart 72 xercesj 42 classdatashouldbeprivate argouml 83 jfreechart 31 xercesj 44 complexclass argouml 182 jfreechart 84 xercesj 66 longmethod argouml 212 jfreechart 290 xercesj 142 longparameterlist argouml 290 jfreechart 188 xercesj 204 messagechains argouml 192 jfreechart 94 xercesj 77 refusedparentbequest argouml 146 jfreechart 72 xercesj 48 spaghetticode argouml 0 jfreechart 0 xercesj 0 speculativegenerality argouml 20 jfreechart 34 xercesj 67 swissarmyknife argouml 35 jfreechart 84 xercesj 86 13 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns of the method or the method parameters. thus, developer can correct org.apache.xerces.validators.common.xmlvalidator, by using the related command pattern, to represent and encapsulate all the information needed to call a method at a later time. this information includes the method name, the object that owns the method, and values for the method parameters. thus, by using the relationships of an anti-pattern with a specific design pattern, we explain how developers maintained the anti-pattern classes while reducing its influence on the system. an external information from the changelog file support this idea (see section 6). in conclusion, we observed as an initial evidence, that the majority of anti-pattern analysed share static relationships with some design patterns. rq2: are the static relationships between anti-patterns and design patterns casual? no in rq2, we observed that static relationships between anti-patterns and designs patterns exist in all versions of our analysed systems. figure 1 illustrates that static relationships are continuously growing. indeed, each new version contains more design patterns, more anti-patterns (which was observed in previous work in [acc+07] and in [kpga12]) and also contains more static relationships between these motifs. but. we observe that even if the static relationships continue to exist between anti-patterns and design patterns (detected in the first version), the classes playing roles in anti-patterns are refactored, restructured and fixed in future versions. anti-patterns are removed from the majority of anti-patterns classes that had a static relationship with a design pattern. figure 2 illustrates that, in the three analysed systems, static relationships detected in the first version disappear with the realization of each new release, following refactoring operations and maintenance tasks. this fact does not mean that such static relationships are casual. first, a class that belong to an anti-pattern x in the release s could appear as a part of an anti-pattern y in the next release. as a concrete example, we observe that the class .documenttypeimpl.java was detected in the version 1.0.4 of xercesj as blob class. in the next version, this class was changed and detected as a part of another anti-pattern, longparameterlist. second, the fact that these dependencies have short life-spans can explain the main motive of introducing such relationships by the developers. indeed, in cases where the anti-pattern class is corrected (i.e., the class is not part of an anti-pattern anymore), this may suggest that developers use design patterns as ’temporary fix’ for the negative impact of the anti-patterns, and later on refactoring such anti-patterns to remove design smells. thus, future work includes conducting an empirical study to analyse the evolution of antipattern classes across the different release of each system to explain how an anti-pattern class could evolve to be a ”normal” class or to belong to another anti-pattern. indeed, classes participating in anti-patterns are more subject to changes impacting their structure and, thus, possibly their states (i.e. the anti-pattern can be removed). this observation confirm, also, previous results reported in [kpga12]. in fact, while studying the relation between kinds of anti-patterns and changeand fault-proneness, khomh et al. also studied the kinds of changes impacting classes participating in anti-patterns. they reported that structural changes proc. ppap 2013 14 / 26 eceasst figure 1: evolution of the number of static relationships between anti-patterns and designs patterns. 15 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns figure 2: the persistence of static relationships detected in the first software version between anti-patterns and designs patterns. occur more often on classes participating to anti-patterns than other changes. relevance the development and maintenance of a system include repairing anti-pattern classes. indeed, a common perception of maintenance is that it merely involves fixing defects as antipatterns. we detected that changes performed on anti-pattern classes are usually motivated by the removal of code smells using some good recognized solution such as design patterns. for example, we detect seven longmethod anti-patterns in the first analysed version of xercesj. these antipatterns were corrected in following versions through refactoring of the source code using design patterns such as strategy pattern which encapsulates alternative strategies, or approaches, in separate classes so that each implements a common operation. developers also used such design pattern to transform longmethod anti-patterns into a new form that behaves the same as before but that no longer “smells”. in fact, for a long routine, one or more smaller subroutines can be extracted, encapsulated separately from the validating object without code duplication. for duplicated routines, the duplication can be removed and replaced with one shared function. there are two general categories of benefits of using design patterns to fix anti-pattern classes during program evolution: (1) improving the maintainability because the source code become easier to read and to understand, and (2) improve the extensibility because it is easier to extend defective classes if developers use recognizable design patterns which provide some flexibility where none may have existed before. we conclude that static relationships between anti-patterns and designs patterns exist in all versions of our analysed systems, but they are temporary. proc. ppap 2013 16 / 26 eceasst table 3: change-proneness odd ratios of the fisher’s exact test for anti-pattern classes related to design patterns argouml jfreechart xercesj version or version or version or 0.26 5.16 1.0.6 4.66 1.0.4 5.49 0.26.2 2.48 1.0.7 2.3 1.1.0 4.2 0.28 2.12 1.0.8 1.64 1.2.1 4.38 0.28.1 0.86 1.0.9 2.86 1.2.3 2.86 0.30 1.44 1.0.10 1.88 1.3.0 3.4 0.30.1 1.94 1.0.11 1.62 1.4.0 3.26 0.32 1.63 1.0.12 6.48 2.0.0 2.44 0.34 2.86 1.0.13 3.28 2.9.0 2.86 rq3: do static relationships between anti-patterns and design patterns impact change proneness and fault proneness? table 3 summarises ors obtained when testing h10 . each row shows, for each system, a version number and the ors of classes (1) participating in at least one anti-pattern, (2) having static relationship with a design pattern, and (3) exhibiting at least one change before the next version. table 4 summarises ors obtained when testing h20 . each row shows, for each system, a version number and the ors of classes (1) participating in at least one anti-pattern, (2) having static relationship with a design pattern, and (3) exhibiting at least one fault before the next version. table 5 summarises ors obtained when testing h30 . each row shows, for each system, a version number and the ors of classes (1) participating in at least one design pattern, (2) having static relationship with an anti-pattern, and (3) exhibiting at least one change before the next version. table 6 summarises ors obtained when testing h40 . each row shows, for each system, a version number and the ors of classes (1) participating in at least one design pattern, (2) having static relationship with an anti-pattern, and (3) exhibiting at least one fault before the next version. in all releases, except argouml 28.1, the fisher’s exact test indicates a significant difference of proportions of changes among classes participating and not participating in a relationships between anti-patterns and design patterns. odds ratios vary across systems and, within each system, across versions. while in few cases, ors are close to 1 (i.e. the odds is even that a class participating in a static relationship between an anti-pattern and a design patterns changes or not), in some pairs of systems/versions, such as argouml 0.26, jfreechart 1.0.12, or xercesj 1.0.4, ors are greater than 5. overall, ors for argouml are lower than those of other systems, by one or two orders of magnitude. the odd ratios of classes participating in static relationships between anti-patterns and design patterns are, in most cases, higher than those of other classes with anti-patterns and design pattern. we therefore conclude that, in most cases, there is a relation between the involvement in a static relationships between anti-pattern and design patterns, and change-proneness: a greater proportion of classes participating in these relationships change with respect to other anti-pattern 17 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns table 4: fault-proneness odd ratios of the fisher’s exact test for anti-pattern classes related to design patterns argouml jfreechart xercesj version or version or version or 0.26 0.42 1.0.6 0.49 1.0.4 0.56 0.26.2 0.89 1.0.7 0.63 1.1.0 0.49 0.28 0.67 1.0.8 0.96 1.2.1 0.46 0.28.1 0.94 1.0.9 0.69 1.2.3 0.48 0.30 0.23 1.0.10 0.43 1.3.0 0.39 0.30.1 0.44 1.0.11 0.29 1.4.0 0.52 0.32 0.29 1.0.12 0.37 2.0.0 0.90 0.34 0.76 1.0.13 0.46 2.9.0 0.44 or design patterns classes. the rejection of h10 and h10 , and the ors provide a posteriori concrete evidence of the impact of static relationships between anti-patterns and design patterns on change-proneness. in fact, we observe that classes involved in relationships between antipattern and design patterns are more change prone. we believe that this observation is an effect of change propagated through these motifs and that blends in perfectly with previous results on motif evolution stated (1) that anti-pattern classes are in general more change prone than other classes [kpga12] and (2) that design patterns are in general more change prone than other classes [gch09]. for fault proneness, in all systems, fishers exact test indicates that class participating in relationships between anti-patterns and design patterns are less fault-prone than other anti-pattern classes, but more fault-prone than other design pattern classes. odds ratios vary again across systems and, within each system, across versions. we notice that in few cases, ors are close to 1. however, in most cases, the odd ratios of classes participating in relationships between design patterns and anti-patterns are lower than other anti-pattern classes and higher than other design pattern classes. the rejection of hrq20 and hrq40,and the ors provide a posteriori concrete evidence of the impact of static relationships between anti-patterns and design patterns on fault-proneness. results suggest that being involved in a static relationship between design pattern and antipattern has an impact on the possibility of occurring faults and change in the class. 6 discussion this section discusses the results reported in section 5 as well as the threats to their validity. 6.1 observations from table 2, we note that many anti-patterns in argouml, jfreechart, and xercesj have relationships with design patterns. to the best of our knowledge, we are the first to report these relationships, thanks to our use of state-of-the-art detection algorithms, which detects occurrences proc. ppap 2013 18 / 26 eceasst table 5: change-proneness odd ratios of the fisher’s exact test for design pattern classes related to anti-patterns argouml jfreechart xercesj version or version or version or 0.26 3.22 1.0.6 2.12 1.0.4 2.83 0.26.2 3.40 1.0.7 2.18 1.1.0 3.5 0.28 3.18 1.0.8 2.14 1.2.1 2.6 0.28.1 2.61 1.0.9 1.96 1.2.3 2.46 0.30 3.02 1.0.10 1.38 1.3.0 3.2 0.30.1 2.69 1.0.11 1.42 1.4.0 1.99 0.32 1.87 1.0.12 3.23 2.0.0 1.86 0.34 2.36 1.0.13 1.89 2.9.0 1.25 table 6: fault-proneness odd ratios of the fisher’s exact test for design pattern classes related to anti-patterns argouml jfreechart xercesj version or version or version or 0.26 2.21 1.0.6 1.06 1.0.4 1.46 0.26.2 1.63 1.0.7 1.82 1.1.0 1.02 0.28 1.46 1.0.8 1.19 1.2.1 2.79 0.28.1 2.03 1.0.9 1.11 1.2.3 1.59 0.30 1.56 1.0.10 1.84 1.3.0 1.47 0.30.1 1.89 1.0.11 2.06 1.4.0 1.69 0.32 1.77 1.0.12 2.12 2.0.0 1.88 0.34 2.36 1.0.13 2.59 2.9.0 1.63 of 11 anti-patterns and six design patterns. moreover, we do not consider that an anti-pattern is necessarily the result of a “bad” implementation or design choice; only the concerned developers can make such a judgement. we do not exclude that, in a particular context, an anti-pattern can be practical ways to implement or design a (part of a) class. for example, automaticallygenerated parsers are often very large and complex classes. only developers can evaluate their impact according to the context: it can be perfectly sensible to have these large and complex classes if they come from a well-defined grammar. we observe, also, that the number of static relationships among anti-pattern classes and design patterns classes increases over time, following the increase of the complexity of each new version, although classes playing roles in these relationships are maintained, fixed and refactored. 6.2 potential explanations the majority of static relationships among anti-patterns and design patterns comes from the command pattern. this design pattern is implemented as a motif in which an object is used 19 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns to present and encapsulate all the information needed to call a method at a later time. thus, developers use this design pattern, possibly unintentionally, when there is a proliferation of similar methods and the user-interface code becomes difficult to maintain. this characteristic can explain, predominately, the static relationships of this design pattern with the following antipatterns: • classdatashouldbeprivate because commands must access the data of other objects to function, and developers may have used public instance variables to allow this access; • longmethod and longparameterlist because commands must access the functionalities provided by other classes, which typically can perform lots of processing, in long methods and-or with long parameter lists; • speculativegenerality because classes in relation to commands may have been engineered with extension in mind, but the command does not use it. spaghetticodes have no static relationships (use, association, aggregation, and composition) with design patterns. this observation is not surprising because a spaghetticode is revealed by classes with no structure, declaring long methods with no parameters, and using global variables for processing. a spaghetticode does not take the advantage of object-orientation mechanisms: polymorphism and inheritance. many object methods have no parameters, and utilize class or global variables for processing. thus, a spaghetticode is difficult to reuse and to maintain, and when it is, it is often through cloning. in many cases, however, code is never considered for reuse. the findings of our analysis indicate that no relation is detected between the different occurrence of spaghetticode anti-pattern and design patterns. however, it could be possible that they have no relations because they constitute deadcode. dead code means unnecessary, inoperative code that can be removed. it is a code in the program which can never be executed or a code that is executed but has no effect on the output of a program [krs94]. dead code analysis can be performed using live variable analysis, a form of static code analysis and data flow analysis [cgk98]. however, in large programming projects, it is sometimes difficult to recognize and eliminate dead code [dp98]. lanza et al. [ld02] presented an evolution matrix to display the evolution of the files of a program. the authors presented a categorisation of files based on the visualisation of different versions of a file. they reported that an idle file does not change over several versions and that can be explained by the fact that such file can present a dead code or a good design. thus, we decide to use this observation by mining version-control systems (concurrent versions system named cvs5 and apache subversion system named svn6), to identify, for example, which spaghetticode class were never changed after their introduction in the analyzed systems. we noted for example, that in argouml, more than 80% of classes were maintained three times at most. on the other hand, less than 1% of classes were maintained 50 times at least. based on change analysis, it is neither possible to conclude that spaghetticode classes have no relations with design patterns because they constitute deadcode nor is the opposite true. indeed, from 5 http://cvs.nongnu.org/ 6 http://subversion.apache.org/ proc. ppap 2013 20 / 26 eceasst the results of this case study it is impossible to definitely exclude the possibility that there is in fact no statistically relevant correlation between spaghetticode and deadcode. however, it could be true that the spaghetti code classes have no dependencies because of the lower number of instances in the analysed systems (9 instances). 6.3 outcome on the one hand, the notion of static dependency can be used to assess the architecture of a software system. in fact, we can assume that systems with more static relationships among design patterns and anti-patterns are more stable, since these relationships can be explained by developers making use of recognized and stable solutions (design patterns) to refactor and correct anti-patterns. for example, by mining software version-control systems, we found that the design pattern command described in section 5 and containing the class org.apache.xerces.validators.dtd.dtdimporter was created by the developer jeffreyr on 2000-0404 15:38:39, to factoring validators code implemented in org.apache.xerces.validators.common.xmlvalidator. from this result, we are working on combining static dependency with other quality attributes to improve the assessment of the code quality. on the other hand, in this paper we study correlations among collocated anti-patterns and design patterns because there might be an interaction effect that could explain the existence of such motifs. in fact, our results show that the presence of some anti-patterns (longmethod, longparameterlist, etc.) may increase the likelihood of the presence of a specific design pattern (command design pattern). while, the presence of spaghetti code do not have any direct correlation with the presence of design patterns. moreover, it would be desirable to use anti-patterns and their static relationships, other than metrics, to build more accurate/informative changeand fault-prediction methods. last, but not least, further investigation, devoted to mine change logs, mailing lists and issue reports, is desirable to seek evidence of cause effect relationships between the presence of anti-patterns static relationships, or the need to remove and refactor design defects, and the class changeand fault-proneness. 6.4 threats to validity we now discuss in details the threats to the validity of our results, following the guidelines provided in [yin02]. internal validity, in our context, they are mainly due to errors introduced in measurements. we are aware that the detection techniques used include some subjective understanding of the definitions of anti-patterns and design patterns. however, as discussed, we are interested in relating anti-patterns “as they are defined in decor” [mgdl10] with design patterns “as they are defined in demima” [ga08]. for this reason, the precision of the anti-patterns and design patterns detection is a concern that we agree to accept. however, threshold-based detection techniques such as decor do not handle the uncertainty of the detection results and, therefore, miss borderline classes, i.e., classes with characteristics of anti-patterns surfacing slightly above or sinking slightly below the thresholds because of minor variations in the characteristics of these classes. we also notice that sylversky method relies on heuristics so it can presents errors when 21 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns extracting faults. however, this method has been used successfully in previous studies. reliability validity threats concern the possibility of replicating this study. we attempted here to provide all the necessary details to replicate our study. moreover, both argouml, jfreechart, and xercesj source code repositories are available. finally, the data sets on which we computed our statistics are available on the web7. threats to external validity concern the possibility to generalise our observations. first, although we performed our study on three different, real systems belonging to different domains and with different sizes and histories, we cannot assert that our results and observations are generalisable to other systems and the facts that all the analysed systems are in java and open-source may reduce this generability. second, we used particular, yet representative, sets of anti-patterns and design patterns. different anti-patterns and design patterns could have lead to different results, which are part of our future work. 7 conclusions and future work in this paper, we provide empirical evidence of the relationships between anti-patterns and design patterns. we show that some anti-patterns are significantly more likely to have relationships with design patterns than other. this study raises a question, within the limits of the threats to its validity, about the conjecture in the literature that anti-patterns and design patterns have an impact on system quality. we provide a basis for future research to understand more precisely the causes and the consequences of the relationships between anti-patterns and design patterns, i.e. if developers use design patterns to encapsulate anti-patterns. the advantages of knowing these relations are (1) spotting how developers strive to maintain a system containing anti-patterns by using design patterns and (2) detecting correlations among collocated anti-patterns and design patterns to identify the causes of the co-existence of such motifs. this empirical study provided, within the limits of its validity, evidence that classes participating in static relationships between anti-patterns and design patterns are more change-prone and less fault-prone than classes not participating in such relationships. the study also provided evidence to practitioners that they should pay attention to systems with a high number of classes participating in such relationships, because these classes are more likely to be the subject of their change efforts. more specifically, managers and developers can use these results to guide maintenance activities: for example, they can recommend their developers to use command design pattern as a temporary fix (when necessary) for some anti-patterns, since our results show that it can reduce the fault-proneness of the anti-patterns. future work includes (i) replicating our study on other systems to assess the generality of our results and (ii) analysing change propagation among anti-patterns and design patterns related by static relationships. we are also interested in studying the extend to which similar systems exhibit similar likelihood of having anti-patterns, and how they relate to systems’ change-/fault-proneness. we also plan to study the categorisation of classes as change-prone, error-prone, or none, and compute types i and ii errors to assess whether anti-patterns perform better than complexity metrics. 7 http://www.ptidej.net/download/experiments/eceasst13/ proc. ppap 2013 22 / 26 eceasst acknowledgements this work has been partly funded by a fqrnt team grant, the canada research chair in software patterns and patterns of software, and the tunisian ministry of higher education and scientific research. bibliography [acc+07] l. aversano, g. canfora, l. cerulo, c. del grosso, m. di penta. an empirical study on the evolution of design patterns. in proceedings of esec-fse ’07. pp. 385–394. acm press, new york, ny, usa, 2007. [akga11] m. abbes, f. khomh, y.-g. guéhéneuc, g. antoniol. an empirical study of the impact of two antipatterns, blob and spaghetti code, on program comprehension. in proceedings of the 15th european conference on software maintenance and reengineering. pp. 181–190. ieee computer society, washington, dc, usa, 2011. [bmmm98] w. brown, h. mccormick, t. mowbray, r. malveau. antipatterns: refactoring software, architectures, and projects in crisis. wiley press, 1998. [bsw+03] j. m. bieman, g. straw, h. wang, p. w. munger, r. t. alexander. design patterns and change proneness: an examination of five evolving systems. in proceedings of the 9th international symposium on software metrics. pp. 40–50. ieee computer society, washington, dc, usa, 2003. [cgk98] y.-f. chen, e. r. gansner, e. koutsofios. a c++ data model supporting reachability analysis and dead code detection. ieee transaction software engineering 24(9):682–694, sept. 1998. [cm10] a. chatzigeorgiou, a. manakos. investigating the evolution of bad smells in object-oriented code. in proceedings of the seventh international conference on the quality of information and communications technology. pp. 106–115. ieee computer society, washington, dc, usa, 2010. [dp98] f. damiani, f. prost. detecting and removing dead-code using rank 2 intersection. in selected papers from the international workshop on types for proofs and programs. pp. 10–32. springer-verlag, london, uk, uk, 1998. [dsrs03] i. deligiannis, m. shepperd, m. roumeliotis, i. stamelos. an empirical investigation of an object-oriented design heuristic for maintainability. journal system software 65(2):127–139, feb. 2003. [em02] e. v. emden, l. moonen. java quality assurance by detecting code smells. in in proceedings of the 9th working conference on reverse engineering. ieee computer. pp. 97–107. society press, 2002. [ga04] y.-g. guéhéneuc, h. albin-amiot. recovering binary class relationships: putting icing on the uml cake. in proceedings of the 19th conference on object-oriented 23 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns programming, systems, languages, and applications (oopsla). pp. 301–314. acm press, 2004. [ga08] y.-g. guéhéneuc, g. antoniol. demima: a multi-layered framework for design pattern identification. transactions on software engineering (tse), pp. 667–684, 2008. [gch09] m. gatrell, s. counsell, t. hall. design patterns and change proneness: a replication using proprietary c sharp software. reverse engineering, working conference on, pp. 160–164, 2009. [ghjv94] e. gamma, r. helm, r. johnson, j. vlissides. design patterns – elements of reusable object-oriented software. addison-wesley, first edition, 1994. [hghg12] s. hassaine, y.-g. guéhéneuc, s. hamel, a. giuliano. advise: architectural decay in software evolution. in 16th european conference on software maintenance and reengineering. pp. 267–276. acm, 2012. [iac11] c. iacob. a design pattern mining method for interaction design. in proceedings of the 3rd acm sigchi symposium on engineering interactive computing systems. eics ’11, pp. 217–222. acm, 2011. [jgha11] f. jaafar, y.-g. guéhéneuc, s. hamel, g. antoniol. an exploratory study of macro co-changes. in working conference on reverse engineering (wcre). pp. 325–334. 2011. [jy01] d. jain, h. j. yang. oo design patterns, design structure, and program changes: an industrial case study. in proceedings of the ieee international conference on software maintenance. pp. 580–590. ieee computer society, 2001. [kp96] c. kramer, l. prechelt. design recovery by automated search for structural design patterns in object-oriented software. in proceeding of the 3rd working conference on reverse engineering. pp. 208–215. ieee computer society press, 1996. [kpga12] f. khomh, m. d. penta, y.-g. guéhéneuc, g. antoniol. an exploratory study of the impact of antipatterns on class changeand fault-proneness. empirical software engineering. 17(3):243–275, june 2012. [krs94] j. knoop, o. rüthing, b. steffen. partial dead code elimination. in proceedings of the acm sigplan 1994 conference on programming language design and implementation. pp. 147–158. acm, 1994. [ld02] m. lanza, s. ducasse. understanding software evolution using a combination of software visualization and software metrics. in in proceedings of lmo 2002 (langages et modeles objets). pp. 135–149. lavoisier, 2002. [lm06] m. lanza, r. marinescu. object-oriented metrics in practice. springer-verlag, 2006. proc. ppap 2013 24 / 26 eceasst [mgdl10] n. moha, y.-g. guéhéneuc, l. duchien, a.-f. le meur. decor: a method for the specification and detection of code and design smells. transactions on software engineering (tse) 36(1):20–36, 2010. [ocbz09] s. olbrich, d. s. cruzes, v. basili, n. zazworka. the evolution and impact of code smells: a case study of two open source systems. in proceedings of the 3rd international symposium on empirical software engineering and measurement. pp. 390– 400. ieee computer society, washington, dc, usa, 2009. [pw06] b. pietrzak, b. walter. leveraging code smell detection with inter-smell relations. proceedings of the 7th international conference on extreme programming and agile processes in software engineering, pp. 75–84, 2006. [rdgm04] d. ratiu, s. ducasse, t. gı̂rba, r. marinescu. using history information to improve design flaws detection. in proceedings of the eighth euromicro working conference on software maintenance and reengineering. pp. 223–233. ieee computer society, 2004. [rie96] a. j. riel. object-oriented design heuristics. addison-wesley, 1996. [rv96] r. real, j. vargas. the probabilistic basis of jaccard’s index of similarity. systematic biology 45(3):380–385, 1996. [scf12] d. settas, a. cerone, s. fenz. enhancing ontology-based antipattern detection using bayesian networks. expert systems with applications, pp. 9041–9053, 2012. [she07] d. j. sheskin. handbook of parametric and nonparametric statistical procedures. chapman & hall/crc, 2007. [sn13] a. e. h. seyyed ehsan taba, foutse khomh ying zou, m. nagappan. predicting bugs using antipatterns. in proceedings of the 29th ieee international conference on software maintenance (icsm). pp. 122–131. ieee computer society, washington, dc, usa, 2013. [szz05] j. sliwerski, t. zimmermann, a. zeller. when do changes induce fixes? sigsoft software engineering notes, pp. 1–5, 2005. [tcsh06] n. tsantalis, a. chatzigeorgiou, g. stephanides, s. halkidis. design pattern detection using similarity scoring. transactions on software engineering 32(11):896– 909, 2006. [vok04] m. vokac. defect frequency and design patterns: an empirical study of industrial code. ieee tranaction software engineering 30(12):904–917, december 2004. [web95] b. f. webster. pitfalls of object oriented development. m & t books, first edition, february 1995. [yin02] r. k. yin. case study research: design and methods third edition. sage publications, london, 2002. 25 / 26 volume 59 (2013) analysing anti-patterns static relationships with design patterns [ym12] a. f. yamashita, l. moonen. do code smells reflect important maintainability aspects? in proceedings of the ieee international conference on software maintenance. pp. 306–315. ieee computer society press, washington, dc, usa, 2012. [ym13] a. yamashita, l. moonen. exploring the impact of inter-smell relations on software maintainability: an empirical study. in proceedings of the international conference on software engineering. pp. 682–691. ieee press, piscataway, nj, usa, 2013. proc. ppap 2013 26 / 26 timed automata for mobile ransomware detection electronic communications of the easst volume 079 (2020) interactive workshop on the industrial application of verification and testing etaps 2020 workshop (interavt 2020) timed automata for mobile ransomware detection fabio martinelli, francesco mercaldo and antonella santone 13 pages guest editors: stylianos basagiannis, goetz botterweck, anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst timed automata for mobile ransomware detection fabio martinelli1, francesco mercaldo2,1 and antonella santone2 fabio.martinelli, francesco.mercaldo@unimol.it, antonella.santone@unimol.it 1 institute for informatics and telematics, national research council of italy, pisa, italy 2 department of medicine and health sciences “vincenzo tiberio”, university of molise, campobasso, italy abstract: considering the plethora of private and sensitive information stored in smartphone and tablets, it is easy to understand the reason why attackers develop everyday more and more aggressive malicious payloads with the aim to exfiltrate our data. one of the last trend in mobile malware landascape is represented by the so-called ransomware, a threat capable to lock the user interface and to cipher the data of the mobile device under attack. in this paper we propose an approach to model an android application in terms of timed automaton by considering system call traces i.e., performing a dynamic analysis. we obtain encouraging results in the experimental analysis we performed exploiting real-world (ransomware and legitimate) android applications. keywords: ransomware, mobile, android, timed automaton, formal methods, model checking, security 1 introduction researchers discovered several cases of malware on the official android app store, and while all of the dangerous apps were taken down rapidly, they still managed to infect thousands of devices worldwide1. however, even more, severe mobile malware hides in applications downloaded from shady internet sources. for instance, the doublelocker, lokibot, ghostclicker, and sockbot malware families are just a few of examples that target android mobile users daily. the most worrying fact is that out of all 10 million shady android apps, the majority (77%) turned out to be malicious. the remaining 23% are potentially unwanted applications2. sophos security experts highlight that ransomware is a problem for android users3. mobile ransomware is a kind of malware afflicting mobile devices, for instance tablets and smartphones [aska16]. a cybercriminal can use mobile malware to steal sensitive data from a smartphone or lock a device, before demanding payment to return the data to the user or unlock the device. after the malware is downloaded onto a device, it will show a fake message accusing the victim of unlawful engagement before encrypting files and locking the phone. after the payment 1 https://www.techrepublic.com/article/malware-laden-apps-in-google-play-store-mine-cryptocurrency-from-mobile-victims/ 2 https://www.2-spyware.com/malware-forecast-for-2018-more-ransomware-android-mac-viruses 3 https://www.sophos.com/en-us/en-us/medialibrary/pdfs/technical-papers/malware-forecast-2018.pdf?la=en 1 / 13 volume 079 (2020) mailto:fabio.martinelli, francesco.mercaldo@unimol.it mailto:antonella.santone@unimol.it https://www.techrepublic.com/article/malware-laden-apps-in-google-play-store-mine-cryptocurrency-from-mobile-victims/ https://www.2-spyware.com/malware-forecast-for-2018-more-ransomware-android-mac-viruses https://www.sophos.com/en-us/en-us/medialibrary/pdfs/technical-papers/malware-forecast-2018.pdf?la=en timed automata for mobile ransomware detection timestamp system call t1 recv t2 recv t3 recv t4 read t5 futex table 1: a system call trace fragment. is processed, often via bitcoin, the ransomware will send a code to unlock the phone or decrypt the data [im07, qwr18]. ransomware writers leverage users fear from loosing valuable data to obtain the payment of ransoms [mmms18]. in particular, in the mobile device realm, as opposed to other threats that silently try to get into possession of data by copying them and leaking through network [cmn+18], ransomware denies access to data to the users either by encryption or simply by locking the device and scaring users (i.e., data are not encrypted, but the device is locked with a message that makes the user believe that data have been encrypted) [ams18]. in some cases even paying the requested ransom does not guarantee that the access to the data will be restored [mns16]. usually android malware writers modify some existing malware, merging together parts of different existing malicious codes [xzm+17]. this explains also why android malware is usually grouped in families: in fact, given this way of generating android malware, the malware belonging to the same family shares common parts of code and behaviors [mmm17]. in this paper an approach to model android applications in terms of timed automata is proposed, with the aim to dynamically discriminate between legitimate and ransomware applications. 2 the method the proposed approach consists in two main phases: the formal model creation and the formal model verification. the formal model creation phase output is the formal model representing the android application under analysis. in this step a timed automaton from the system call traces is generated. whether in the system call trace the same system call is repeated between consecutive temporal instances the automaton will contain a loop. to better understand how the proposed method build the automaton from the system calls let us consider the system call trace fragment depicted in 1 as shown from the example in table 1, the system call traces exhibit for three consecutive timestamp the recv system call, subsequently it exhibits the read and the futex system calls. from the system call trace frament in table 1 in figure 1 we show the relative automaton. the automaton generated from the recv system call will contain a loop for the t1, t2 and t3 time intervals (whether it is repeated three times in the system call trace). the exit condition from the loops is guaranteed by a guard, while the entering one is guaranteed from an invariant. in detail, interavt 2020 2 / 13 eceasst 1 x2 ≤ 1 2 3 4 y1 > 3 recv := recv + 1 y1 < 3 write := write + 1 s! s! read := read + 1 s! f utex := f utex + 1 figure 1: an example of automaton generated from a system call trace. two different clocks are considered for each automaton: the first one (i.e., x) to respect the loop entering condition, while the second one (i.e., y) to respect the exit one. the formal model verification receives as input a timed automaton built in the previous phase and a set of timed temporal logic properties. in detail timed temporal logic properties are considered are aimed to detect whether an malicious behaviour is occurring. the set of logic properties is checked against the timed automata obtained using the uppaal model checker. whether the uppaal formal verification environment outputs true when is verifying a timed temporal logic property on a network of timed automata, it means that the proposed method labelled the formal model is belonging to the ransomware specified by the analysed formula. otherwise, the formal verification environment outputs false, meaning that the model under analysis is not belonging to the attacks described in the analysed formula. 3 experimental evaluation we performed an experiment aimed to evaluate the effectiveness of the proposed method. different applications, legitimate and ransomware, are considered. the aim of the experiment is to evaluate the effectiveness of the the proposed model based on timed automata to discriminate between ransomware and legitimate android samples. a dataset made of 100 legitimate and 100 ransomware android applications was collected: legitimate applications by several categories (call & contacts, education, entertainment, gps & travel, internet, lifestyle, news & weather, productivity, utilities, business, communication, email & sms, fun & games, health & fitness, live wallpapers, personalization) were downloaded from google play (and then controlled by google bouncer, a google service that checks each app for malicious behaviour before publishing it on the official market [cmv16]) from january to june 2019, while ransomware applications belonging to 10 widespread ransomware families were obtained through the virustotal api 4. all the applications were checked by means of 4 https://developers.virustotal.com/reference 3 / 13 volume 079 (2020) https://developers.virustotal.com/reference timed automata for mobile ransomware detection table 2: the android ransomware families involved in the evaluation with details related to the discovery year. family description cipher locker year doublelocker change the pin of the device x x 2017 fusob it demands to pay a fine from $100 to $200 usd x 2015 koler mobile version of reveton ransomware x 2014 locker it shows a ransom messages x 2014 lockerpin it is able to set a pin on the device x 2015 pletor mobile version of cryptolocker x 2014 porndroid it resets the screen-lock pin x 2015 simplelocker it encrypt sd cad file using the aes cipher x 2014 svpeng android banking malware x 2017 xbot it steals victims’ banking credentials x x 2016 table 3: experimental analysis result. precision recall f-measure 0.96 0.97 0.96 virustotal 5, a service that runs 57 different antimalware on the submitted applications. the analysis confirmed that our trusted samples did not contain any known malicious payload, while the malicious samples contained ransomware specific family payloads. table 2 shows the widespread android ransomware families evaluated in the study. we executed the android application in a simulated environment with the aim to collect the syscall traces. from the traces belonging to the considered 200 different applications (100 legitimate and 100 ransomware) we build the models representing the application under analysis. to evaluate the effectiveness of the proposed method in android ransomware detection, three different metrics are considered: precision, recall and f-measure. the precision has been computed as the proportion of the examples that truly belong to class x among all those which were assigned to the class. it is the ratio of the number of relevant records retrieved to the total number of irrelevant and relevant records retrieved: precision = t pt p+ f p , where tp indicates the number of true positives and fp indicates the number of false positives. the recall has been computed as the proportion of examples that were assigned to class x , among all the examples that truly belong to the class, i.e., how much part of the class was captured. it is the ratio of the number of relevant records retrieved to the total number of relevant records: recall = t pt p+ f n , where tp indicates the number of true positives and fn indicates the number of false negatives. the f-measure is a measure of a test’s accuracy. this score can be interpreted as a weighted average of the precision and recall: f-measure = 2 ∗ precision∗recallprecision+recall . the obtained results are shown in table 3. as shown from the experimental results, the proposed method obtains a precision equal to 5 https://www.virustotal.com/ interavt 2020 4 / 13 https://www.virustotal.com/ eceasst 0.96 and a recall of 0.97 confirming their effectiveness in android ransomware detection. 4 related work the main difference between ransomware and other widespread mobile malware types is in their behaviour: as demonstrated in [zj12a], android malware generally focuses on remaining hidden while gathering and sending to the attackers user sensitive and private information. ransomware, instead, leverages the knowledge of its presence by users to obtain the payment of a ransom. due to this, current methods proposed by the research community for the identification of malware are not necessarily effective in detecting ransomware, as the recent rise in ransomware attacks demonstrates. as also stated in [azm15], this ineffectiveness of traditional methods, when used alone, exposes more than a billion users to this threat. effective solutions for detection of ransomware on mobile devices are needed, but up to date, there are only a few works addressing this issue in the literature. the first method that introduced ransomware detection for android is heldroid [azm15]. this tool includes a text classifier based on nlp features, a lightweight smali emulation technique to detect locking strategies, and the application for detecting file-encrypting flows. this tool includes a text classifier based on nlp features, a lightweight smali emulation technique to detect locking strategies, and the application for detecting file-encrypting flows. the main weakness of heldroid is that it strongly depends on a text classifier: as a matter of fact, the authors trained it on generic threatening phrases, similar to those that typically appear in ransomware or scareware. from the performance point of view, they identify rightly 375 android ransomware on a dataset composed of 443 samples: 11 ransomware were not detected due to unsupported language (e.g., spanish, russian) with 9 out of 12,842 false positives. in [yyq+15], the authors propose a performance tool in order to help to understand what can be done to cope with android ransomware detection. however, this method remained at the level of a proposal, with no implementation. therefore, there are no results that can prove its effectiveness. song et al. [skl16] designed an approach with the aim of identifying mobile ransomware by using process monitoring. they consider features representing the i/o rate as well as the cpu and memory usage. they evaluate the proposed method with only one ransomware sample developed by the authors. this sample has the ability to encrypt the file by using aes. r-packdroid [mmg+17] implements an approach to detect android ransomware considering the api calls frequency. authors evaluated a real-world ransomware dataset, demonstrating that r-packdroid can detect novel ransomware only using previously released training samples. an approach based on formal methods that is able to detect android ransomware and to identify the malicious sections in the application code is described in [mnsv16, cmn+17]. starting from the payload behaviour definition, the authors formulate logic rules that are later applied to detect ransomware. the main weakness of the proposed method is represented by the human analyst effort required to build the logic rules. as a matter of fact the proposed method foresees the payload identification but the process rule building has to be done by hand, and as such, is a time consuming task. a hybrid static-dynamic approach is proposed in [gg17]. the static approach is based on 5 / 13 volume 079 (2020) timed automata for mobile ransomware detection text and image classification as well as on api calls and application permissions. the dynamic approach is based on sequences of api calls that are compared, with a periodicity of five minutes, against malicious sequences identified for each malware family. dynamic detection takes a minimum of five minutes to identify a ransomware sample. researchers in [fmm+17] propose a hybrid method able to effectively counter ransomware. the proposed method first examines applications to be used on a device prior to their installation (static approach) and then observes their behavior at runtime and identifies if the system is under attack (dynamic approach). to detect ransomware, the static detection method uses the frequency of opcodes while the dynamic detection method considers cpu usage, memory usage, network usage and system call statistics. the main difference between the discussed methods and the one we propose is represented by the adoption of a dynamic analysis to build a timed automaton. 5 conclusion remarks in this paper we propose to model android applications in terms of timed automata. we consider system call traces to build the proposed model. the experiment is aimed to demonstrate the ability to discriminate between legitimate and ransomware applications. we evaluate 200 real-world applications, obtaining an f-measure equal to 0.96. future works will consider to experiment the proposed method on an extended dataset of application and to apply the proposed method on applications developed for apple mobile environment. acknowledgments this work has been partially supported by miur secureopennets and eu sparta contract 830892, cybersane projects, and the eu project cybersure 734815. bibliography [add02] p. s. addision. the illustrated wavelet transform handbook: introductory theory and applications in science, engineering, medicine and finance. taylor & francis group, 2002. [akmp03] i. n. athanasiadis, v. g. kaburlasos, p. a. mitkas, v. petridis. applying machine learning techniques on air quality data for real-time decision support. in itee. 2003. [ams08] s. attaluri, s. mcghee, m. stamp. profile hidden markov models and metamorphic virus detection. journal of computer virology and hacking techniques 5(2):179–192, november 2008. [ams18] b. a. s. al-rimy, m. a. maarof, s. z. m. shaid. ransomware threat success factors, taxonomy, and countermeasures: a survey and research directions. computers & security, 2018. interavt 2020 6 / 13 eceasst [ash+14] d. arp, m. spreitzenbarth, m. huebner, h. gascon, k. rieck. drebin: efficient and explainable detection of android malware in your pocket. in annual network and distributed system security symposium (ndss). pp. 1–15. february 2014. [aska16] s. arshad, m. a. shah, a. khan, m. ahmed. android malware detection & protection: a survey. international journal of advanced computer science and applications 7(2):463–475, 2016. [azm15] n. andronio, s. zanero, f. maggi. heldroid: dissecting and detecting mobile ransomware. in international workshop on recent advances in intrusion detection. pp. 382–404. 2015. [bak15] an assembler / disassembler for android’s dex format. https://code.google.com/ p/smali/, last visit 26 january 2015. [bdp93] m. bowman, s. k. debray, l. l. peterson. reasoning about naming systems. acm trans. program. lang. syst. 15(5):795–825, november 1993. [bkk06] u. bayer, c. kruegel, e. kirda. ttanalyze: a tool for analyzing malware. in european institute for computer antivirus research annual conference. 2006. [bls13a] d. baysa, r. m. low, m. stamp. structural entropy and metamorphic malware. journal of computer virology and hacking techniques 9(4):179–192, 2013. [bls13b] d. baysa, r. m. low, m. stamp. structural entropy and metamorphic malware. journal of computer virology and hacking techniques 9(4):179–192, november 2013. [bor11] m. borda. fundamentals in information theory and coding. springer, 2011. [bou15] dissecting the android bouncer. https://jon.oberheide.org/files/ summercon12-bouncer.pdf, last visit 30 january 2015. [bra91] j. braams. babel, a multilingual style-option system for use with latex’s standard document styles. tugboat 12(2):291–301, june 1991. [ccp01] m. cannataro, a. cuzzocrea, a. pugliese. a probabilistic approach to model adaptive hypermedia systems. in in proceedings of the international workshop for web dynamics. pp. 12–30. 2001. [cfr13] a. cuzzocrea, g. fortino, o. f. rana. managing data and processes in cloudenabled large-scale sensor networks: state-of-the-art and future research directions. in 13th ieee/acm international symposium on cluster, cloud, and grid computing, ccgrid 2013, delft, netherlands, may 13-16, 2013. pp. 583–588. 2013. [cla91] m. clark. post congress tristesse. in tex90 conference proceedings. pp. 84–89. march 1991. 7 / 13 volume 079 (2020) https://code.google.com/p/smali/ https://code.google.com/p/smali/ https://jon.oberheide.org/files/summercon12-bouncer.pdf https://jon.oberheide.org/files/summercon12-bouncer.pdf timed automata for mobile ransomware detection [cmm+19] m. f. carfora, f. martinelli, f. mercaldo, v. nardone, a. orlando, a. santone, g. vaglini. a “pay-how-you-drive” car insurance approach through cluster analysis. soft computing 23(9):2863–2875, 2019. [cmn+17] a. cimitile, f. mercaldo, v. nardone, a. santone, c. a. visaggio. talos: no more ransomware victims with formal methods. international journal of information security, dec 2017. doi:10.1007/s10207-017-0398-5 https://doi.org/10.1007/s10207-017-0398-5 [cmn+18] a. cimitile, f. mercaldo, v. nardone, a. santone, c. a. visaggio. talos: no more ransomware victims with formal methods. international journal of information security 17(6):719–738, 2018. [cmv13] g. canfora, f. mercaldo, c. a. visaggio. a classifier of malicious android applications. in international conference on availability, reliability and security. pp. 607–614. 2013. [cmv16] g. canfora, f. mercaldo, c. a. visaggio. an hmm and structural entropy based detector for android malware: an empirical study. computers & security 61:1–18, 2016. [crte13] s. chakradeo, b. reaves, p. traynor, w. enck. mast: triage for market-scale mobile malware analysis. in acm conference on security and privacy in wireless and mobile networks (wisec). pp. 13–24. april 2013. [dlsv14] n. de francesco, g. lettieri, a. santone, g. vaglini. grease: a tool for efficient ”nonequivalence” checking. acm transactions on software engineering and methodology 23(3), 2014. [dlsv16] n. de francesco, g. lettieri, a. santone, g. vaglini. heuristic search for equivalence checking. software and systems modeling 15(2):513–530, 2016. [dms04] d. dagon, t. martin, t. starner. mobile phones ascomputing devices:the viruses are coming! pervasive computing, ieee 3(4):11–15, october-december 2004. [dnl14] l. deshotels, v. notani, a. lakhotia. droidlegacy: automated familial classification of android malware. in acm sigplan on program protection and reverse engineering workshop. 2014. [fada14] y. feng, s. anand, i. dillig, a. aiken. apposcopy: semantics-based detection of android malware through static analysis. in acm sigsoft international symposium on foundations of software engineering. pp. 576–587. 2014. [fgl+13] p. faruki, v. ganmoor, v. laxmi, m. s. gaur, a. bharmal. androsimilar: robust statistical feature signature for android malware detection. in international conference on security of information and networks. pp. 151–159. 2013. interavt 2020 8 / 13 http://dx.doi.org/10.1007/s10207-017-0398-5 https://doi.org/10.1007/s10207-017-0398-5 eceasst [fmm+17] a. ferrante, m. malek, f. martinelli, f. mercaldo, j. milosevic. extinguishing ransomware-a hybrid approach to android ransomware detection. in the 10th international symposium on foundations practice of security. 2017. [fra15] on the effectiveness of malware protection on android. http: //www.aisec.fraunhofer.de/content/dam/aisec/dokumente/publikationen/ studien techreports/deutsch/042013-technical-report-android-virus-test.pdf, last visit 21 january 2015. [fse15] mobile threat report. https://www.f-secure.com/documents/996508/1030743/ threat report h1 2014.pdf, last visit 7 february 2015. [gar15] gartner predicts by 2017, half of employers will require employees to supply their own device for work purposes. http://www.gartner.com/newsroom/id/ 2466615, last visit 21 january 2015. [gg17] a. gharib, a. ghorbani. dna-droid: a real-time android ransomware detection framework. in yan et al. (eds.), network and system security: 11th international conference, nss 2017, helsinki, finland, august 21–23, 2017, proceedings. pp. 184–198. springer international publishing, cham, 2017. [gsvv04] s. gradara, a. santone, m. villani, g. vaglini. model checking multithreaded programs by means of reduced models. electronic notes in theoretical computer science 110:55–74, 2004. [her93] m. herlihy. a methodology for implementing highly concurrent data objects. acm trans. program. lang. syst. 15(5):745–770, november 1993. [hh09] j. hühn, e. hüllermeier. furia: an algorithm for unordered fuzzy rule induction. data mining and knowledge discovery 19(3):293–319, 2009. [idc15] smartphone os market share, q3 2014. http://www.idc.com/prodserv/ smartphone-os-market-share.jsp, last visit 7 february 2015. [im07] n. idika, a. p. mathur. a survey of malware detection techniques. purdue university 48:2007–2, 2007. [iy04] h. ishibuchi, t. yamamoto. fuzzy rule selection by multi-objective genetic local search algorithms and rule evaluation measures in data mining. fuzzy sets and systems 141(1):59–88, 2004. [jc08] r. jensen, c. cornelis. a new approach to fuzzy-rough nearest neighbour classification. in international conference on rough sets and current trends in computing. pp. 310–319. 2008. [jc11] r. jensen, c. cornelis. fuzzy-rough nearest neighbour classification. in transactions on rough sets xiii. pp. 56–72. springer, 2011. 9 / 13 volume 079 (2020) http://www.aisec.fraunhofer.de/content/dam/aisec/dokumente/publikationen/studien_techreports/deutsch/042013-technical-report-android-virus-test.pdf http://www.aisec.fraunhofer.de/content/dam/aisec/dokumente/publikationen/studien_techreports/deutsch/042013-technical-report-android-virus-test.pdf http://www.aisec.fraunhofer.de/content/dam/aisec/dokumente/publikationen/studien_techreports/deutsch/042013-technical-report-android-virus-test.pdf https://www.f-secure.com/documents/996508/1030743/threat_report_h1_2014.pdf https://www.f-secure.com/documents/996508/1030743/threat_report_h1_2014.pdf http://www.gartner.com/newsroom/id/2466615 http://www.gartner.com/newsroom/id/2466615 http://www.idc.com/prodserv/smartphone-os-market-share.jsp http://www.idc.com/prodserv/smartphone-os-market-share.jsp timed automata for mobile ransomware detection [kf06] t. kinjo, k. funaki. on hmm speech recognition based on complex speech analysis. in annual conference on industrial electronics. pp. 3477–3480. 2006. [kin15] kindsight security labs malware report q4 2013. http: //www.tmcnet.com/tmc/whitepapers/documents/whitepapers/2014/ 9861-kindsight-security-labs-malware-report-q4-2013.pdf, last visit 21 january 2015. [kre15] who wrote the pincer android trojan? http://krebsonsecurity.com/2013/08/ who-wrote-the-pincer-android-trojan/, last visit 21 january 2015. [lam86] l. lamport. latex user’s guide and document reference manual. addisonwesley publishing company, reading, massachusetts, 1986. [ld14] s. liang, x. du. permission-combination-based scheme for android mobile malware detection. in international conference on communications. pp. 2301– 2306. 2014. [lh07] r. lyda, j. hamrock. using entropy analysis to find encrypted and packed malware. security & privacy, ieee 5(2):40–45, march-april 2007. [ll14] x. liu, j. liu. a two-layered permission-based android malware detection scheme. in international conference on mobile cloud computing, service, and engineering. pp. 142–148. 2014. [ltta14] e. lagerspetz, h. t. t. truong, s. tarkome, n. asokan. mdoctor: a mobile malware prognosis application. in international conference on distributed computgin systems workshops. pp. 201–206. 2014. [mca15] update: mcafee: cyber criminals using android malware and ransomware the most. http://www.infoworld.com/article/2614854/security/ update--mcafee--cyber-criminals-using-android-malware-and-ransomware-the-most. html, last visit 21 january 2015. [met15] metamorphic and polymorphic malware. http://searchsecurity.techtarget.com/ definition/metamorphic-and-polymorphic-malware, last visit 21 january 2015. [mmg+17] d. maiorca, f. mercaldo, g. giacinto, c. a. visaggio, f. martinelli. r-packdroid: api package-based characterization and detection of mobile ransomware. in proceedings of the symposium on applied computing. pp. 1718–1723. 2017. [mmm17] f. martinelli, f. marulli, f. mercaldo. evaluating convolutional neural network for effective mobile malware detection. procedia computer science 112:2372– 2381, 2017. [mmms18] f. martinelli, f. mercaldo, c. michailidou, a. saracino. phylogenetic analysis for ransomware detection and classification into families. in icete (2). pp. 732– 737. 2018. interavt 2020 10 / 13 http://www.tmcnet.com/tmc/whitepapers/documents/whitepapers/2014/9861-kindsight-security-labs-malware-report-q4-2013.pdf http://www.tmcnet.com/tmc/whitepapers/documents/whitepapers/2014/9861-kindsight-security-labs-malware-report-q4-2013.pdf http://www.tmcnet.com/tmc/whitepapers/documents/whitepapers/2014/9861-kindsight-security-labs-malware-report-q4-2013.pdf http://krebsonsecurity.com/2013/08/who-wrote-the-pincer-android-trojan/ http://krebsonsecurity.com/2013/08/who-wrote-the-pincer-android-trojan/ http://www.infoworld.com/article/2614854/security/update--mcafee--cyber-criminals-using-android-malware-and-ransomware-the-most.html http://www.infoworld.com/article/2614854/security/update--mcafee--cyber-criminals-using-android-malware-and-ransomware-the-most.html http://www.infoworld.com/article/2614854/security/update--mcafee--cyber-criminals-using-android-malware-and-ransomware-the-most.html http://searchsecurity.techtarget.com/definition/metamorphic-and-polymorphic-malware http://searchsecurity.techtarget.com/definition/metamorphic-and-polymorphic-malware eceasst [mmn+18a] f. martinelli, f. mercaldo, v. nardone, a. orlando, a. santone. cluster analysis for driver aggressiveness identification. in icissp. pp. 562–569. 2018. [mmn+18b] f. martinelli, f. mercaldo, v. nardone, a. orlando, a. santone. who’s driving my car? a machine learning based approach to driver identification. in icissp. pp. 367–372. 2018. [mns16] f. mercaldo, v. nardone, a. santone. ransomware inside out. in availability, reliability and security (ares), 2016 11th international conference on. pp. 628– 637. 2016. [mnsv16] f. mercaldo, v. nardone, a. santone, c. a. visaggio. ransomware steals your phone. formal methods rescue it. in international conference on formal techniques for distributed objects, components, and systems. pp. 212–221. 2016. [nfc15] using nfc? 3 security risks to be aware of. http://www.makeuseof.com/tag/ using-nfc-3-security-risks-to-be-aware-of/, last visit 21 january 2015. [pf05] t. plotz, g. a. fink. a new approach for hmm based protein sequence family modeling and its application to remote homology classification. in workshop on statistical signal processing. pp. 1008–1013. 2005. [pie04] m. piercy. embedded devices next on the virus target list. electronics systems and software 2(6):42–43, december-january 2004. [qczd11] z. qin, n. chen, q. zhang, y. di. mobile phone viruses detection based on hmm. in international conference on multimedia information networking and security. pp. 516–519. 2011. [qwr18] l. qiu, y. wang, j. rubin. analyzing the analyzers: flowdroid/iccta, amandroid, and droidsafe. in proceedings of the 27th acm sigsoft international symposium on software testing and analysis. pp. 176–186. 2018. [rcj13] v. rastogi, y. chen, x. jiang. droidchameleon:evaluating android anti-malware against transformation attacks. in acm symposium on information, computer and communications security. pp. 329–334. may 2013. [ros12] r. ramachandran, t. oh, w. stackpole. android anti-virus analysis. in annual symposium on information assurance & secure knowledge management. pp. 35– 40. june 2012. [ses+13] m. spreitzenbarth, f. echtler, t. schreck, f. c. freling, j. hoffmann. mobilesandbox: looking deeper into android applications. in international acm symposium on applied computing (sac). pp. 1808–1815. march 2013. [sh78] s. salas, e. hille. calculus: one and several variable. john wiley and sons, new york, 1978. 11 / 13 volume 079 (2020) http://www.makeuseof.com/tag/using-nfc-3-security-risks-to-be-aware-of/ http://www.makeuseof.com/tag/using-nfc-3-security-risks-to-be-aware-of/ timed automata for mobile ransomware detection [skl16] s. song, b. kim, s. lee. the effective ransomware prevention technique using process monitoring on android platform. mobile information systems 2016, 2016. [sma15] dalvik opcodes. http://pallergabor.uw.hu/androidblog/dalvik opcodes.html, last visit 26 january 2015. [sor11] i. sorokin. comparing files using structural entropy. journal of computer virology and hacking techniques 7(4):259–265, november 2011. [sym15] remote access tool takes aim with android apk binder. http://www.symantec. com/connect/blogs/remote-access-tool-takes-aim-android-apk-binder, last visit 21 january 2015. [uss+12] x. ugarte-pedrero, i. santos, b. sanz, c. laorden, p. g. bringas. countering entropy measure attacks on packed software detection. in the 9th annual ieee consumer communications and networking conference security and content protection. pp. 164–168. january 2012. [wh14] w.-c. wu, s.-h. hung. droiddolphin: a dynamic android malware detection framework using big data and machine learning. in conference on research in adaptive and convergent systems. pp. 247–252. 2014. [wkq+08] x. wu, v. kumar, j. r. quinlan, j. ghosh, q. yang, h. motoda, g. j. mclachlan, a. ng, b. liu, s. y. philip et al. top 10 algorithms in data mining. knowledge and information systems 14(1):1–37, 2008. [xlqz12] k. xin, g. li, z. qin, q. zhang. malware detection in smartphones using hidden markov model. in international conference on multimedia information networking and security. pp. 857–860. 2012. [xzm+17] x. xiao, s. zhang, f. mercaldo, g. hu, a. k. sangaiah. android malware detection based on system call sequences and lstm. multimedia tools and applications, pp. 1–21, 2017. [ysmm13] s. y. yerima, s. sezer, g. mcwilliams, i. muttik. a new android malware detection approach using bayesian classification. in international conference on advanced information networking and applications. pp. 121–128. 2013. [yy10] i. you, k. yim. malware obfuscation techniques: a brief survey. in international conference on broadband, wireless computing, communication and applications. pp. 297–300. november 2010. [yyq+15] t. yang, y. yang, k. qian, d. c.-t. lo, y. qian, l. tao. automated detection and analysis for android ransomware. in ieee 17th international conference on high performance computing and communications, ieee 7th international symposium on cyberspace safety and security, ieee 12th international conference on embedded software and systems. pp. 1338–1343. 2015. interavt 2020 12 / 13 http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html http://www.symantec.com/connect/blogs/remote-access-tool-takes-aim-android-apk-binder http://www.symantec.com/connect/blogs/remote-access-tool-takes-aim-android-apk-binder eceasst [zj12a] y. zhou, x. jiang. dissecting android malware: characterization and evolution. in security and privacy (sp), 2012 ieee symposium on. pp. 95–109. 2012. [zj12b] y. zhou, x. jiang. dissecting android malware: characterization and evolution. in ieee symposium on security and privacy (sp). pp. 95–109. may 2012. 13 / 13 volume 079 (2020) introduction the method experimental evaluation related work conclusion remarks verification of graph-based model transformations using alloy electronic communications of the easst volume 67 (2014) proceedings of the 13th international workshop on graph transformation and visual modeling techniques (gtvmt 2014) verification of graph-based model transformations using alloy xiaoliang wang, fabian büttner, yngve lamo 13 pages guest editors: frank hermann, stefan sauer managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst verification of graph-based model transformations using alloy xiaoliang wang1, fabian büttner2, yngve lamo1 1 xwa@hib.no,yla@hib.no bergen university college, norway 2 fabian.buettner@gmx.org école des mines de nantes-inria, france abstract: model transformations are fundamental in model driven development. thus, verification of model transformations is indispensable to ensure the quality and the reliability of transformation results. in this paper we focus on graph-based model transformation systems using the double-pushout (dpo) approach and study their correctness w.r.t. conformance. it means that, given a transformation system and a valid source model, any applicable sequences of model transformations will produce a valid target model. a procedure is presented to verify firstly if a model transformation system is correct w.r.t. conformance by checking the direct condition, i.e., each direct model transformation produces a valid target model from a valid source model. then, for systems not satisfying the direct condition, it checks the sequential condition, i.e., if a direct model transformation t produces an invalid target model from a valid source model, then there exists a sequence of direct model transformations succeeding the transformation t that produces a valid target model. the satisfiability of the latter condition cannot always promise correctness, but it ensures that, from every valid source model, a valid target model can be produced. the procedure uses a bounded verification approach based on first order logic (fol). the approach encodes a transformation system and the two conditions into a relational logic specification in alloy. then the specification is inspected by the alloy analyzer to check if the system satisfies the conditions. when it violates the conditions, the analyzer presents a counterexample, that may be used to redesign the system. an example is given to illustrate the bounded verification approach in the diagram predicate framework (dpf). keywords: model transformation system; conformance; alloy; verification 1 introduction in model driven engineering (mde), models are the basis for software development. they are used to specify the domain under study, to generate program code and for documentation purposes etc. ideally, a model in the next development phase can be automatically generated from a model in the previous phase by model transformations. such automation makes mde appealing by producing software with better quality at higher productivity. however, validation of model transformations should be ensured. without validation, errors in some transformations are propagated to subsequent phases, which may cause erroneous software at the end. 1 / 13 volume 67 (2014) mailto:xwa@hib.no,yla@hib.no mailto:fabian.buettner@gmx.org verification of graph-based model transformations using alloy in this paper, we focus on graph-based model transformations [eept06]. such model transformations are usually executed by applying model transformation rules on models. the rules tell how to execute a transformation and generate a target model from a source model. a model transformation system consists of a metamodel and a set of such rules along with a mechanism to control rule applications. our work aims to verify if a model transformation system is correct w.r.t. conformance. besides, for systems accepting invalid intermediate models in a sequence of model transformations, a weaker correctness condition is verified. we will present a procedure to verify firstly if a model transformation system is correct w.r.t. conformance by checking if it satisfies a direct condition. then, for systems not satisfying this strong condition, a weaker sequential condition is checked. the procedure utilizes a bounded verification approach based on first order logic (fol). the main idea is to encode automatically a model transformation system as a relational logic specification in alloy [all], a modelling language based on fol. then we resort to the alloy analyzer [all], which can generate instances or counterexamples of a model. to verify if the system satisfies the conditions the analyzer checks if the specification has any counterexamples within a user-defined bounded scope. to illustrate our approach, we present a running example in diagram predicate framework (dpf) [rrlw09]. dpf provides diagrammatic modelling of both structure and constraints based on category theory. besides, it also offers functionality to specify graph-based model transformations. we will present a dpf model transformation specification and show how it can be encoded as an alloy specification and verified with the alloy analyzer. the paper is organized as follows. section 2 firstly shows how to specify a model transformation system in dpf. then section 3 explains the verification procedure and the fol-based bounded verification approach. in section 4 we give a short introduction to alloy, explain the encoding process from model transformations to relational logic specifications. afterwards, in section 5 we present the result of the check of the direct condition and the sequential condition, before we discuss the given approach. section 6 compares our work with related research and finally section 7 concludes the paper and envisions some future research directions. 2 model transformation system in this section, we will show how to specify a model transformation system in dpf. a model transformation system [eept06] consists of a metamodel m and a set of model transformation rules. figure 1 and 2 show a variant of dijkstra’s algorithm for mutual exclusion [dij01] as a model transformation system in dpf. the algorithm ensures that a critical resource is exclusively accessed by one process each time. in dpf, the structural syntax of a model is represented by a directed graph and constraints as diagrammatic predicates on part of the graph. those predicates are denoted by [predicatename]. note that each predicate has a specific shape graph defining which kind of graphs the predicate can constrain. for more information about predicate in dpf, refer to [yxf+13]. figure 1 is the metamodel used in the example. because of space limitation, some constraints are not shown in the example. r is the resource which processes p can access. the node t tells which process that can access the resource. an arrow t → p means that the process p is eligible to access the resource r. the flags {f1,f2} and the states {nonactive,active,start,crit,check,setturn} are used to control access to the resource. an arrow proc. gtvmt 2014 2 / 13 eceasst [xor] 76540123f2 [0,1] ��❄ ❄❄ ❄❄ ❄❄ ❄❄ ❄❄ ❄❄ ❄❄ ❄ /.-,()*+p nonactive �� active start ;; crit mm check [[ setturn -[0,1] ==⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤⑤ [0,1] // 76540123f1 [0,1] ///.-,()*+r [xor] /.-,()*+t [surj][inj] [1] [1] ??⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧⑧ [1,1] aa❇❇❇❇❇❇❇❇❇❇❇❇❇❇❇❇❇ [nand] ❂ ✲ ✧ [nand] ✎ ✚ ★ ♥♥ ✏ ✏ ✎ ✚ ✲ ✧ ❃ ✹ ✱ ✾ ✰ ✦ ✄ ✑ ✜ ❘ ❏ ❂ ✴ ✪ ✢ ✗ figure 1: metamodel setf lag setturn1 setturn2 enter exit figure 2: transformation rules from a process to one of the two flags means that the process is tagged with such a flag. a reflexive arrow on a process p labeled with one of the six states means that the process is in such a state. moreover, the model needs to satisfy the following constraints: 1. there is exactly one resource in a model, which is ensured by the multiplicity [1] on r. a similar constraint also applies to t . 2. the states nonactive,active,start,crit,check,setturn should be [reflexive]. 3. every process should be in one of the states nonactive, active, and also in one of the states start, crit, check, setturn. this is ensured by the [xor] constraints between the nonactive and the active states, and among the start, crit, check, setturn states. 4. every process should only be in one of the state combinations {nonactive,start}, {active,crit}, {active,check} or {active,setturn}. 5. every process may be tagged with at most one of the flags {f1,f2}. this is ensured by the multiplicity constraints [0,1] on both arrows p → f1 and p → f2, along with a [nand] constraint between the two arrows. 6. each flag may have at most one arrow to r, which is ensured by the multiplicity constraint [0,1] on the respective arrows and a [nand] between the arrows. 7. t → r is bijective, this is ensured by [inj] and [surj] constraints. 8. it is at most one process in the system that is in state crit, is marked with the f2 flag and is eligible to access the resource. this constraint is ensured by [critical]. a metamodel m, including structural syntax and constraints, defines its valid instances which conform to m. the conformance states that an instance i should be typed by m, denoted as i : m. formally, it means that there is a graph morphism from the graph of i to the graph of m. moreover, it also states that i satisfies all the constraints defined on m, denoted as i ⊲ m. the following figures show several graphs. names of instance elements are omitted for brevity. for example, /.-,()*+p denotes p1 : p, an instance element p1 typed by p. figure 3 is a valid instance of figure 1 since it is well-typed and satisfies all the constraints; the others are not because p → t 3 / 13 volume 67 (2014) verification of graph-based model transformations using alloy causes type violation in figure 4; in figure 5 p is not in state active, which violates constraint 4. rp check t f1 active figure 3: an instance rp check t f1 active figure 4: an invalid model rp check t f1 figure 5: an invalid model based on the modelling framework, dpf also provides a framework to specify constraintaware model transformations[rrlw12], which means that the transformation rules may contain constraints. however, in this paper, we only consider metamodel constraints. in a model transformation rule {p : l l ←− k r −→ r}, l, k and r are the left-hand side, the gluing graph and the right-hand side, while the two graph morphisms l and r are injective. l and r are typed by m, but not necessary valid instances of m. the model transformation rules in the example are shown in figure 2. rule setf lag requests access to the resource. rule setturn1 and setturn2 assign t to one process depending on the context. rule enter enables the eligible process to access the resource, while rule exit releases the resource after access. l m �� k loo r // �� r n �� s doo // t figure 6: double-pushout diagram figure 7: a model transformation in this paper, the execution of model transformations follows the dpo approach [eept06]. for each transformation rule p, given an instance s, if there is a graph morphism m : l → s, we say that s has a match m of rule p. a direct model transformation is executed according to the morphisms l and r and the match m by completing the double-pushout diagram in figure 6. after the direct model transformation, a target model t is produced. for example, the rule enter changes the flag form check to crit, and the state of a process from f1 into f2. in the direct model transformation in figure 7, edge check and node f1 are deleted while edge crit and node f2 are added. other elements are preserved in the target model. 3 bounded verification of graph-based model transformation in this section we will present a procedure to verify graph-based model transformation systems, using a fol-based bounded verification approach. the procedure firstly verifies if a system is correct w.r.t conformance, i.e., given a valid source model, every sequence of direct model transformations from the model can produce a valid target model. this is performed by checkproc. gtvmt 2014 4 / 13 eceasst ing if the system satisfy the direct condition, i.e., every direct model transformation is valid. a direct model transformation is valid if it produces a valid target model from a valid source model. the direct condition is quite strong in the sense that, in a sequence of direct model transformation, no invalid intermediate model is allowed. however, some systems accept such intermediate models and only require that the final target model should be valid. in such a situation, we weaken the correctness condition by checking the sequential condition, i.e., for each counterexample s → t0, a sequence of direct model transformations t0 →···→ tn can produce a valid target model tn. if the condition is satisfied, we assure that, given any valid source model, a valid target model can be produced after some sequences of direct model transformations. it is weaker since it does not promise to produce a valid target model after every sequence of direct model transformations. in this procedure, a bounded verification approach based on fol is used to check if a graphbased model transformation satisfies the direct condition or the sequential condition. the idea is to encode a model transformation system into a relational logic specification. the encoding can be executed automatically. each component, metamodel (including structure and constraints) and model transformation rules, can be encoded in relational logic. the structure of a metamodel is encoded as functions and predicates, representing all the possible model instances typed by the graph. besides, the semantics of model transformations, or how to execute a transformation, is also considered in the approach. in each direct model transformation, according to the applied rule and the dpo approach, some elements in the source model are deleted while some elements in the target model are added. except those elements the rest of the source model is preserved in the target model. in this way, a direct model transformation can be encoded as the following two functions add : t → s and delete : s → t : add(e) = { null if e is added to t e otherwise delete(e) = { null if e is deleted from s e otherwise based on the direct model transformation encoding, a graph-based model transformation system, the direct condition(1) and the sequential condition(2) can be expressed as the following fol expressions (s → t denotes that s is transformed into t, while ⇒ is implication in fol): ∀s,t : s ⊲ m∧(s → t) ⇒ t ⊲ m (1) ∀s,t0 : (s ⊲ m∧s → t0 ∧¬(t0 ⊲ m)) ⇒ (2) ∃t1,...,tn : n−1 ∧ i=1 ¬(ti ⊲ m)∧tn ⊲ m∧ n−1 ∧ i=0 ti → ti+1 4 encoding of graph-based model transformation systems in this section, we will give the details about how to encode model transformation systems as a relational logic specification in alloy. before that, a brief introduction to alloy will be given. alloy consists of the alloy specification language, used to define specifications or models, and the alloy analyser, used to reason about specifications. it is developed at mit by a team led by daniel jackson [all]. the alloy specification language is a declarative language suited to describe complex model structures and constraints in a simple structural modelling language based 5 / 13 volume 67 (2014) verification of graph-based model transformations using alloy on relational logic. the alloy language defines a model structure as signatures. each signature defines a typed element in the structure, representing a set of instances of this type. relations among the typed elements are defined by the fields of the signatures. constraints on the structure can be defined as f acts while predicates as pred. the alloy analyser can find valid instances well-typed by the structure and satisfying its constraints by executing the run command. it can also verify some properties by calling the check command to find counterexamples. notice that alloy performs a bounded check, i.e., for each signature, a user-defined scope bounds the number of its instances. the alloy analyser performs the verification within a scope by running the command {constraint} f or scope. for example, run{} f or m is used to find a valid instance of a model specification within a scope containing at most m instances of each signature. assuming a specification contains n signatures, its instances contains at most m∗n elements. here we only mention the basic functionalities of alloy, please refer to [all] for more information. 4.1 encoding of metamodels sig graph{ sig nodei{}//1 ≤i≤m nodes:set node1+...+nodem, sig edge j{//1≤j≤n edges:set edge1+...+edgen src:one nodes,//1≤s≤m } trg:one nodet}//1≤t≤m fact{all g:graph|all e:edge j&g.edges|g.src in g.nodes and g.trg in g. nodes}//1≤j≤n in graph-based model transformation systems, metamodel structures are type graphs. a type graph, containing m nodes and n edges, is encoded as a graph signature with set fields nodes and edges, representing all the nodes and edges. nodes : set node1 + ···+ nodem means that each element of nodes can be typed by any node in the graph, where + is set union in alloy. this also applies to the field edges. each node is encoded as a node signature without any field while each edge as an edge signature with two fields src and trg of corresponding node types. both fields are declared with alloy multiplicity constraint one. this means that each edge have exactly one source node and one target node. besides, the fact constrains that every edge and its source and target nodes should be in the same graph (in is subset relation in alloy). besides structural information metamodels contain also constraints. constraints in dpf workbench are specified in java or ocl [lwm+12]. they are encoded as fol expressions in alloy. furthermore, the direct condition requires the precondition that the source model s is valid in every direct model transformation, while the sequential condition requires the precondition that in each verification step, for each sequence of direct model transformations s → t0 ···→ tk, the source model s is valid while the intermediate model ti is invalid for i ∈ (0,k). for convenience, a predicate pred valid[graph : graph] is used to tell if a model satisfies some constraints. the constraint 5 in the example is encoded as follows: pred valid[graph:graph]{ all n:(p&graph.nodes)|lone e:pf2&graph.edges|e.src=n all n:(p&graph.nodes)|lone e:pf1&graph.edges|e.src=n all n:(p&graph.nodes)|not ((some e:pf1&graph.edges|e.src=n) and (some e:pf2&graph.edges|e.src=n))} proc. gtvmt 2014 6 / 13 eceasst 4.2 encoding of direct model transformations 1 sig trans{rule:one rule,source,target:one graph, dnodes, anodes:set node1+...+nodem,dedges, aedges:set edge1+...+edgen} 2 all e:edge|((e.src in t.dnodes or e.trg in t.dnodes) implies edge in t.dedges) and ((e.src in t.anodes or e.trg in t.anodes) implies edge in t.aedges) 3 t.dnodes in t.source.nodes and t.dedges in t.source.edges 4 t.anodes in t.target.nodes and t.aedges in t.target.edges 5 t.source.nodes-t.dnodes=t.target.nodes-t.anodes 6 t.source.edges-t.dedges=t.target.edges-t.aedges 7 rule1[t] or ... or rulen[t] given a graph-based model transformation system, a direct model transformation trans : s p −→t is executed by applying a model transformation rule p = l l ←− k r −→ r with the dpo approach. a direct model transformation is encoded as a trans signature. in the signature, the rule field denotes the rule applied in a transformation, while the source and target fields represent the source and the target models. the other four fields represent the deleted elements and added elements. besides, a transformation trans satisfies some constraints: there is no dangling edge after the transformation; the deleted elements and the added elements should be subset of the source graph’s and the target graph’s elements, respectively; the source graph and the target graph should be the same except for the deleted and the added elements. trans.dnodes and trans.dedges denote the deleted elements in the transformation, while trans.anodes and trans.aedges the added elements. trans.source.nodes−trans.dnodes represents the preserved nodes in the source model while trans.target.nodes−trans.anodes the preserved nodes in the target model. according to the semantics of transformations, those two sets of preserved nodes are equal. a similar constraint applies also to arrows. these are encoded as the constraints on lines 5-6. besides the general properties of a transformation, for each rule p, a predicate pred rulep[trans] encodes if a rule p is applied to a transformation. without loss of generality, we enforce that a direct model transformation applies only one rule each time. 1. there is only one match m from l to s. during the transformation, the part m(l)\m(l(k)) of s is deleted. similarly, there is also only one "match" n from r to t and the part n(r)\n(r(k)) of t is added. one m:l → s|(all n:m(l(kn ))|n in t.source.nodes-t.dnodes) and (all e:m(l(ke ))|e in t.source.edges-t.dedges)and (all n:m(ln)\m(l(kn)) |n in t.dnodes) and (all e:m(le )\m(l(ke))|e in t.dedges) one n:r → t|(all n:n(r(kn))|n in t.target.nodes-t.anodes) and (all e:n(r(ke))|e in t.target.edges-t.aedges) and (all n:n(rn)\n(r(kn)) |n in t.anodes) and (all e:n(re)\n(r(ke))|e in t.aedges) 2. during a transformation, no element in s is deleted except the elements matched by l\ l(k). to fulfill this, a constraint restricts the number of deleted elements. for each type t having instances in l\l(k), the number of deleted elements typed by t in s equals to nt , the number of elements typed by t in l\ l(k). a similar constraint applies to the added 7 / 13 volume 67 (2014) verification of graph-based model transformations using alloy elements. in alloy, # calculates the cardinality of a set. trans.source.nodes&t contains elements in source typed by t where & is set disjunction in alloy. for example, only one edge of type t p is deleted in rule setturn0, encoded as the constraint on line 3. 1 #{n:t.source.nodes&t|n in t.dnodes}=nt 2 #{e:t.source.edges&t|e in t.dedges}=ne 3 #e:t.dedges&tp=1 3. all the elements in s typed by t having no instance in l\l(k) are unchanged. similarly, all the elements in t typed by t having no instance in r\r(k) are unchanged. for example, no node and edge typed by p and t → p is deleted or added when applying rule setturn2 to a transformation. the constraint is encoded as: no n:trans.dnodes&p no n:trans.anodes&p no e:trans.dedges&tp no e:trans.aedges&tp the encoding of rule setturn2 to a predicate is shown follows (part of the predicate is omit): 1 pred rule_setturn2[t:trans]{ 2 some t.rule&setturn2 3 one se_tp0:tp&(t.source.arrows-t.darrows),se_st0:setturn&t. darrows, se_tr0:tr&(t.source.arrows-t.darrows)|let sv_t0= se_tp0.src,sv_t0=se_tp0.trg,sv_r0=se_tr0.trg|(sv_p0=se_st0.src and sv_p0=se_st0.trg and sv_t0=se_tr0.src and sv_p0 in p&(t. source.nodes-t.dnodes) and sv_t0 in t&(t.source.nodes-t.dnodes ) and sv_t0 in r&(t.source.nodes-t.dnodes)) 4 ... 5 #setturn&t.darrows=1 #check&t.aarrows=1 6 no p&t.dnodes ... no r&t.dnodes 7 no p&t.anodes ... no r&t.anodes 8 no check&t.darrows ... no f2r&t.darrows 9 no crit&t.aarrows ... no f2r&t.aarrows} 5 result of verification after encoding a graph-based model transformation system to an alloy specification, the alloy analyzer is used to verify the system by finding counterexamples w.r.t. different conditions. 5.1 check direct condition when checking the direct condition, the alloy analyzer examines if some direct model transformations produce an invalid target model from a valid source model. for example, we use the following command to find a counterexample violating constraint [surj] on pf1 : p → f1: 1 check{all trans:trans}|all n:trans.target.nodes&f1|one e:trans.target .edges&pf1|e.trg=n}for 3 but exactly 1 trans, exactly 1 graph, exactly 1 rule, exactly 1 r, exactly 1 t, exactly 1 tr proc. gtvmt 2014 8 / 13 eceasst in the command, f o3 but ..., exactly 1 tr is the scope. it restricts the counterexample containing at most 3 instances of each signature. the scope is further restricted: since only direct model transformations are examined when checking the direct condition, for all systems, we enforce that there are exactly 1 transformation, 2 graphs and 1 rule. besides, we ensures exactly 1 r, 1 t and 1 tr for this example. the alloy keyword exactly implements these constraints. if a counterexample is found violating a constraint, the alloy analyzer visualizes it showing which rule is applied. we call such a rule a problem rule and say that the rule violates the constraint. the designer can utilize the information to fix the problem, e.g., adding more constraints to the metamodel or consider if some nacs are necessary for the problem rules. if no counterexample is found for any constraint, the system is verified correct within the scope. for the example, the alloy analyzer gives counterexamples when checking constraints 3 and 5 (multiplicity on p → f1 and [nand] between p → f1 and p → f2). part of a counterexample violating constraints 3 is given in fig 8. nodes with $ are elements violating the constraint. after trans ($tran) source graph0 target active0 aarrows f1r1 aarrows pf10 aarrows setturn0 aarrows f11 anodes nonctive darrows start darrows setflag rule arrows arrows f1r2 pf11 arrows f10 nodes p2 ($n) nodes arrowsarrows arrowsarrows nodes arrows arrowsarrows nodes nodesnodes src trg srctrg trgsrcsrc trgsrc trg src trgsrctrg trg srctrg figure 8: a counterexample analyzing the counterexample, we find that the following constraints are missing. after adding them, the alloy analyzer gives no further counterexamples, which indicates that the system is correct w.r.t. conformance. a process has no flag iff it is in {nonactive, start} state a process has f1 flag iff it is in {active,setturn} or {active,check} state a process has f2 flag iff it is in {active,crit} state 5.2 check sequential condition we also apply our approach to a revised version of an example from [lmrl13] which transforms object oriented systems (oo) into entity-relationship (er) models. the authors use rule amalgamation mechanism to perform transformations in their work; we verify the system using dpo approach without amalgamation. note that in this example, the source metamodel and the target metamodel are different. before applying the approach to such systems, we construct a joint metamodel containing the two metamodels and correspondences between elements. several constraints are considered to verify the system. for example, (c1) each class should be transformed into a table; (c2) each table should have a primary key. because of space consideration, we only briefly present the result here. when checking the direct condition, we found that both constraints are violated by some rules. after using the counterexamples to fix the system, c2 is 9 / 13 volume 67 (2014) verification of graph-based model transformations using alloy still violated by a rule. in the following, we show how to check the sequential condition. for c2, we first consider a path consisting of 2 direct model transformations in a sequence. the source model, trans0.source, is valid, as shown on line 2; the intermediate model, trans1.target, violates c2. for each model violating a constraint c, violation[c] generalize how the model violates the constraint, while f ix[v] generalizes the solution to fix the violation. for example, a violation for c2 is apparently that, some table has no primary key. while for the violation, the solution is to add a primary key for the table. removing the table is not considered since no deletion happens in the example. the violation and the correction are presented below on line 3: 1 sig path{t0,t1:trans}{t0.target=t1.source} 2 all tb:table&t0.source.nodes|some pk:pk&t0.source.edges|pk.src=tb 3 some tb:table&t0.target.nodes|(no pk:pk&t0.target.edges|pk.src=tb) and (some pk1:pk}&t1.aedges|pk1.src=tb) before checking the sequential condition, it should be assured that there exists a rule fixing such a violation. this is performed by executing command run{} but exactly 1 path, exactly 2 trans, exactly 3 graph, exactly 2 rule to see if such a path exists. if no instance is given, we can conclude that the system is not correct, i.e., from some valid source models, no model transformations can produce valid target models. otherwise, we continues to check the condition. the check is enforced by running the command check {all path : path| table_one_ pk[path.trans2.target]} with the same scope. if no counterexample is present, it is assured that each violation of a constraints can be fixed by some succeeding transformations. therefore, we verify that the sequential condition is satisfied. otherwise, a longer path should be checked. in the example, the sequential condition is satisfied with a path of length 2. 5.3 discussion in order to show the performance of our approach, the verification times of checking the direct condition for the example presented in section 2, is shown in table 1. all the cases are preformed in the alloy analyzer on a windows machine with a intel core i5-2410m processor and 4gb memory. the second line is for the scope f or 3 but ... (s3), while the third line is for the scope f or 4 but ... (s4). each column represents the time needed to verify a specific constraint. it shows that the constraints are verified in a reasonable time. the longest time is 2700ms and 2371ms when checking [xor] between the 4 states with the scope s4. because of the capacity of the alloy analyzer, the verification cannot be performed with the scope f or 5 but ... . table 1: verification times(ms) c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 s3 133 62 105 49 24 40 47 98 24 601 495 100 67 73 24 s4 258 136 418 126 56 171 131 442 80 2700 2321 489 204 289 144 we have shown that the approach helps to find defects in graph-based model transformations. but several limitations should be noticed. the alloy analyzer performs a bounded check within a state space determined by a user-defined scope. given a specification consisting of m signatures, a scope [s1,s2,...,sm] bounds the size of the ith signature to si. for a relation of arity proc. gtvmt 2014 10 / 13 eceasst n, the size of the state space containing all the possible instances is 2ˆ(∑mi=1 si) n. the analyzer searches exhaustively within the state space for instances or counterexamples of a specification. alloy uses some optimisation to decrease the state space, but the state space still grows superexponentially with the scope. in the approach, the transformations encoding introduces some relations with high arity. for example, rule enter is encoded as a relation with arity 5 (the largest number of the edges in the left and the right side). as a result, the approach will not scale well when applying to large systems or complex transformation rules. however, some optimisation can be deployed to apply the approach to larger systems. we verify systems by finding counterexamples violating a certain constraint. when a constraint is checked, some elements in the metamodels and rules are not affected. they could be removed from the scope. for example, in figure 2, arrow t → r is not added or deleted by any rules. when checking constraint 3 and 5, the arrow cannot affect the verification result. those unrelated elements could be removed during verification. this could also be used to simplify a counterexample, when it is too complex to analyse. pf2 and crit are not deleted or added by any transformation applying rule setflag and they do not affect the satisfiability of the constraint. they are unrelated elements and could be removed from the scope when verifying the constraints. a further restricted scope with 0 pf2, 0 crit, can simplify the counterexample. 6 related work different verification techniques have been applied to model transformation verification. the tool, groove [gdr+12], verifies graph-based model transformation using model checking. in this approach, the initial state must be given and it works only for finite state spaces. besides, it encounters the state space explosion problem similar to other model checking approaches. basil becker et al. [bbg+06] encode safety properties as inductive invariants and present algorithms to verify safety properties using model checking. the approach is largely dependent on the number and especially the complexity of the rules and invariants. similar to our approach no start state is required. in contrast, we also offer a procedure to verify properties along a sequence of model transformations. another verification technique, theorem proving, is also used in this area. simone et al. [cr12] uses relational structures to encode graph grammars and fol to encode graph transformations. in this way, they provide a formal verification framework to reason about graph grammars using mathematical induction. similarly, leila et al. [rdcd10] translate graph grammars into eventb specifications and use theorem provers available for event-b to analyze the reachable states. however, the approaches is not automatic and requires mathematical knowledge. in contrast, our approach offers an automatic procedure to verify the validity of produced models. automatic verification of model transformations is an evolving area of research; several methods have already been proposed. troya and vallecillo [tv11] provide a rewriting logic semantics for atl [jabk08] and use maude to simulate and verify transformations; büttner et al. [bec12] provide a first-order logic encoding for atl transformations and employ smt solvers to check their correctness. there are furthermore several verification approaches that use ocl constraints to capture or specify semantics of rule-based transformations (sometimes called transformation models), employing existing ocl model finders to check correctness prop11 / 13 volume 67 (2014) verification of graph-based model transformations using alloy erties [glw+13, ccgl10]. those approaches are specific to some transformation languages. while in our approach, we consider general cases to systems which conforms to the semantics of model transformation system. the works of anastasakis et al. [abk07] and baresi and spoletini [bs06] are closest to our contribution, as they also use alloy to analyze graph-based model transformation. they demonstrate, by example, the feasibility of representing such a model transformation in alloy. on the other hand, they specify a (bounded) sequence of transformation rules in alloy to check properties related to a sequence of model transformations, e.g., if a model can be produces after a sequence of model transformations. by contrast, we provides an automatic encoding of graph-based transformation systems to alloy specifications. besides, we address the checking of individual transformations: we verify that all direct model transformations produce a valid target model from a valid source model, which implies that the system is correct. furthermore, we also verify if, from every valid source model, a valid target model can be produced. 7 conclusion and future work model transformations are of great importance in mde, hence the correctness of model transformations should be ensured. we proposed an approach to verify static correctness (preservation of metamodel conformance) of graph-based model transformations. the verification is realized by automatically encoding systems into relational logic formulas which can be checked by alloy (given a bounded search space, using a sat solver). at the current stage, the examples show that our verification approach can check individual transformations and verify systems allowing intermediate instances in a sequences of transformations. but the approach is not restricted to the verification w.r.t. conformance. it also could be extended to verify safety proprieties and liveness proprieties. we will systematically study when this approach should be used. besides, much more work should established in the future, e.g., how to automatically derive the unrelated elements when verifying a constraint; currently, the counterexamples are visualized with alloy tools. how to present the result diagrammatically in dpf should be studied for a more user-friendly feedback. furthermore, the scalability problem should be addressed in the future. bibliography [abk07] k. anastasakis, b. bordbar, j. m. küster. analysis of model transformations via alloy. in modevva’2007, proceedings. 2007. [all] alloy. project web site. http://alloy.mit.edu/community/. [bbg+06] b. becker, d. beyer, h. giese, f. klein, d. schilling. symbolic invariant verification for systems with dynamic structural adaptation. in proceedings of the 28th international conference on software engineering. icse ’06, pp. 72–81. 2006. [bec12] f. büttner, m. egea, j. cabot. on verifying atl transformations using off-the-shelf smt solvers. in acm/ieee models 2012. lncs. 2012. proc. gtvmt 2014 12 / 13 http://alloy.mit.edu/community/ eceasst [bs06] l. baresi, p. spoletini. on the use of alloy to analyze graph transformation systems. in icgt. lncs 4178. 2006. [ccgl10] j. cabot, r. clarisó, e. guerra, j. de lara. verification and validation of declarative model-to-model transformations through invariants. jss 83(2), 2010. [cr12] s. a. da costa, l. ribeiro. verification of graph grammars using a logical approach. science of computer programming 77:480–504, 2012. [dij01] e. w. dijkstra. solution of a problem in concurrent programming control. in pioneers and their contributions to software engineering. 2001. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer. springer-verlag new york, inc., 2006. [gdr+12] a. h. ghamarian, m. j. de mol, a. rensink, e. zambon, m. v. zimakova. modelling and analysis using groove. international journal on software tools for technology transfer 14:15–40, 2012. [glw+13] e. guerra, j. de lara, m. wimmer, g. kappel, a. kusel, w. retschitzegger, j. schönböck, w. schwinger. automated verification of model transformations based on visual contracts. autom. softw. eng. 20(1), 2013. [jabk08] f. jouault, f. allilaire, j. bézivin, i. kurtev. atl: a model transformation tool. sci. comput. program. 72(1-2), 2008. [lmrl13] y. lamo, f. mantz, a. rutle, j. de lara. a declarative and bidirectional model transformation approach based on graph co-spans. in proceedings of the 15th symposium on principles and practice of declarative programming. acm, 2013. [lwm+12] y. lamo, x. wang, f. mantz, w. maccaull, a. rutle. dpf workbench: a diagrammatic multi-layer domain specific (meta-)modelling environment. in computer and information science 2012. volume 429, pp. 37–52. 2012. [rdcd10] l. ribeiro, f. l. dotti, s. a. da costa, f. c. dillenburg. towards theorem proving graph grammars using event-b. eceasst 30, 2010. [rrlw09] a. rutle, a. rossini, y. lamo, u. wolter. a diagrammatic formalisation of mofbased modelling languages. objects, components, models and patterns, 2009. [rrlw12] a. rutle, a. rossini, y. lamo, u. wolter. a formal approach to the specification and transformation of constraints in mde. jlap 81(4), 2012. [tv11] j. troya, a. vallecillo. a rewriting logic semantics for atl. journal of object technology 10, 2011. [yxf+13] l. yngve, w. xiaoliang, m. florian, b. øyvind, s. anders, r. adrian. dpf workbench: a multi-level language workbench for mde. in proceedings of the estonian academy of sciences. pp. 3–15. 2013. 13 / 13 volume 67 (2014) introduction model transformation system bounded verification of graph-based model transformation encoding of graph-based model transformation systems encoding of metamodels encoding of direct model transformations result of verification check direct condition check sequential condition discussion related work conclusion and future work electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) preface 1 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst preface the international workshop on automated verification of critical systems (avocs) is a forum to foster interaction and exchange of ideas among members of the international research community on tools and techniques for the verification of critical systems. the subject is to be interpreted broadly and inclusively. for example, the topics of avocs 2018 cover all aspects of automated verification, including model checking, theorem proving, sat and smt constraint solving, automated testing and verification, abstract interpretation, security analysis, model-based development, and refinement. these topics concern various types of critical systems which need to meet stringent dependability requirements: distributed databases and execution platforms, railways systems, mobile phone applications, embedded operating systems, and internet communicating applications. the 18th edition of avocs has been hosted by the department of computer science of university of oxford, during july 18-19, 2018. the event was affiliated to formal methods (fm) 2018 as part of the federated logic conference (floc) 2018, which included other conferences related with formal methods and automated verification, for example cav and ijcar. papers were solicited for avocs 2018 under two categories: regular papers describing fully developed work and complete results, and short papers describing research ideas, work in progress or preliminary results. the symposium received 15 full papers and 1 short paper, out of which were accepted 11 full papers for pre-proceedings publication of floc 2018. all these papers included as authors young researchers, usually master or phd candidates, which demonstrate the vitality of this domain. this volume contains 11 papers from the accepted ones, after a final review of the pre-proceeeding version. in addition to the referred papers, the symposium featured three invited presentations: “formal methods at amazon web services,” by michael tautschnig, software development engineer at aws, ; “automatic verification of concurrent objects,” by michael emmi, researcher at sri international; and “experiences with thread-modular static analysis of concurrent embedded systems by abstract interpretation,” by antoine miné, professor at sorbonne université. the organizers are grateful to the authors for submitting their work at avocs 2018 and to the invited speakers for sharing their experience and for interesting insights. avocs 2018 and the publication of this volume would not have been possible without the productive collaboration of the programming committee. we thanks the easst board for accepting the publication of these post-proceedings and for their support. the avocs 2018 website can be found at http://avocs18.irisa.fr. december 2018 david pichardie mihaela sighireanu 1 / 1 volume 076 (2019) microsoft word preface.doc electronic communications of the easst volume 58 (2013) guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gt-vmt 2013) preface matthias tichy and leila ribeiro iii pages eceasst ii / iii volume 58 (2013) preface matthias tichy1 and leila ribeiro2 1chalmers university of technology and university of gothenburg (sweden) 2universidade federal do rio grande do sul (brazil) this volume contains the proceedings of the international workshop on graph transformations and visual modeling techniques (gt-vmt 2013), held in rome, italy on 23rd-24th march 2013, as part of the european joint conferences on theory and practice of software (etaps 2013). gt-vmt 2013 is the twelfth workshop of a series that serves as a forum for all researchers and practitioners interested in the use of visual notations (especially graph-based), techniques and tools for the specification, modeling, validation, manipulation and verification of complex systems. the aim of the workshop is to promote engineering approaches that provide effective sound tool support for visual modeling languages, enhancing formal reasoning at the syntactic as well as semantic level (e.g., for model specification, model analysis, model transformation, and model consistency management) in different domains, such as uml, petri nets, graph transformation or business process/workflow models. this year's workshop has a special theme of the analysis of non-functional / extra-functional / quality properties like performance, real-time, safety, reliability, energy consumption. contributions have been sought in relation to: visual languages definition and syntax, static and dynamic semantics of visual languages, visual/graph-based analysis in software engineering, visual/graph constraints, model transformations and their application in modeldriven development, visual modeling techniques and graph transformation applied to patterns, visual modeling techniques and graph transformations for systems with quality properties, case studies and novel application areas, tool support and efficient algorithms. we received 21 abstract submissions and 19 paper submissions. the submissions were each reviewed by at least three members of the program committee. out of all submissions 13 papers were accepted for presentation and publishing in the workshop proceedings. the papers’ topics include theoretical foundations of graph transformations, verification and validation approaches, graphical editors, requirements specification, tool support, and case studies. we are happy that andrea corradini, university of pisa (italy), and holger giese, university of potsdam (germany), complement the topics with their keynote talks. the keynote by andrea corradini is part of a joint session with the termgraph workshop which in addition to the keynote includes one paper from each workshop. we wish to thank all authors for submitting papers to gt-vmt and presenting their papers at the workhop. we wish to thank the program commitee members and the additional reviewers for their indepth reviews of the submitted papers. the gt-vmt workshop would not be possible without the support of the etaps 2013 organizers. finally, we wish to thank tiziana margiara, julia padberg, and gabriele taentzer of eceasst for providing the opportunity to publish the proceedings. matthias tichy and leila ribeiro, march 2013 preface proc. gtvmt 2013 iii / iii program chairs: • leila ribeiro, universidade federal do rio grande do sul (brazil) • matthias tichy, chalmers university of technology and university of gothenburg (sweden) program committee: • paolo baldan, university of padova (italy) • steffen becker, university of paderborn (germany) • harrie jan sander bruggink, university of duisburg-essen (germany) • juan de lara, universidad autónoma de madrid (spain) • gregor engels, university of paderborn (germany) • claudia ermel, tu berlin (germany) • lars grunske, university of stuttgart (germany) • reiko heckel, university of leicester (uk) • ekkart kindler, technical university of denmark (denmark) • christian krause, hpi, university of potsdam (germany) • jochen küster, ibm research zurich (switzerland) • barbara könig, university of duisburg-essen (germany) • rodrigo machado, federal university of pampa (brazil) • mark minas, universität der bundeswehr münchen (germany) • istván ráth, tu budapest (hungary) • arend rensink, university of twente (netherlands) • andy schürr, tu darmstadt (germany) additional reviewers: • matthias becker • johannes dyck • masud fazal-baqaie • carsten gabriel • christian gerth • steffen hildebrandt • sonja maier • hanna schölzel • christian soltenborn • zoltán ujhelyi • dániel varró   electronic communications of the easst volume 77 (2019) interactive workshop on the industrial application of verification and testing, etaps 2019 workshop (interavt 2019) preface 3 pages guest editors: anila mjeda, stylianos basagiannis, goetz botterweck eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst preface this volume contains the proceedings of the first interactive workshop on the industrial application of verification and testing (interavt 2019) which was co-hosted with etaps 2019 and took place in the faculty of mathematics and physics building at charles university, prague on the 6th of april 2019. interavt aims to breach the barriers that hinder the application of modern verification and testing techniques in industrial practice. this years’ workshop focused on barriers and challenges such as the industrial scale and complexity of “real” systems, usability/feasibility of formal techniques in practice, new system paradigms, which make systems harder to model/analyse/verify/test (e.g., autonomous systems, machine learning), and domain-specific challenges and constraints, e.g., in safety-critical systems like automotive, aerospace, medical systems. arguably these challenges can only be tackled with increased communication and collaboration between academic researchers and industrial practitioners, hence, the interavt workshop focused on fostering communication between people working on similar problems and establishing new links and opportunities for collaboration between participants from different backgrounds. to maximize the interaction between participants and the resulting progress, the workshop incorporated a combination of interactive sessions which included short presentations, a “speeddating” session, in which participants engaged in a time-limited discussion with each other, and a collaboration session that focused on summarizing the identified key pain points facing the application of modern verification and testing techniques in industrial practice. the workshop included the invited talk “end-to-end verification of intelligent cyber-physical systems: progress and challenges” by nathan fulton (mit-ibm watson ai lab) and an industry presentation by stylianos basagiannis (united technologies research centre). we thank the authors for their contributions and also express our deep gratitude to all the members of the program committee for their insightful and rigorous work, which was essential to ensure high-quality content. anila mjeda lero-the irish software research centre, ie; stylianos basagiannis united technologies research centre, ie; goetz botterweck lero-the irish software research centre, ie 1 / 3 volume 77 (2019) preface interavt workshop organization organizing committee: stylianos basagiannis united technologies research centre goetz botterweck lero the irish software research centre and university of limerick anila mjeda lero the irish software research centre and university of limerick program committee: mathieu acher university of rennes 1, france alessandra bagnato softeam cinzia bernardeschi university of pisa dirk beyer lmu munich armin biere johannes kepler university linz jorg brauer verified systems jeremy bryans coventry university maxime cordy snt, university of luxembourg marco dinatale scuole santa anna alessandro fantechi university of florence alberto griggio fondazione bruno kessler klaus havelund nasa/caltech jet propulsion laboratory patrick heymans university of namur radu iosif verimag, cnrs, université grenoble-alpes mikoláš janota inesc-id, ist, ulisboa stefan leue university of konstanz tiziana margaria university of limerick and lero the irish software research centre anastasia mavridou nasa ames david parker university of birmingham ken pierce the university of newcastle interavt 2019 2 / 3 eceasst stavros tripakis northeastern university anthony ventresque lero and university college dublin tomas vojnar brno university of technology maurice ter beek istituto di scienza e tecnologie dell’informazione ”alessandro faedo” 3 / 3 volume 77 (2019) smart urban data space for citizen science electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) smart urban data space for citizen science heiko bornholdt, david jost, philipp kisters, michel rottleuthner, sehrish shafeeq, winfried lamersdorf, thomas c. schmidt, and mathias fischer 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst smart urban data space for citizen science heiko bornholdt, david jost, philipp kisters, michel rottleuthner, sehrish shafeeq, winfried lamersdorf, thomas c. schmidt, and mathias fischer*{ bornholdt,jost,kisters,shafeeq,lamersdorf,mfischer } @informatik.uni-hamburg.de universität hamburg, hamburg, germany{ michel.rottleuthner,t.schmidt } @haw-hamburg.de hamburg university of applied sciences, hamburg, germany abstract: in smart cities, the number of citizen-operated sensor devices continues to increase. this development multiplies the amount of collectible data about our urban environment. currently, many of those sensors are connected to proprietary cloud services with questionable effects on user privacy. simply avoiding interconnecting those devices misses out on opportunities to collectively use data as a shared source of information. the city of hamburg sponsored project smart networks for urban citizen participation (sane) aims at enabling citizens to connect existing sensors to create a city-wide data space while keeping control of devices and gathered data. interconnecting these sensors enables all citizens to generate higher value information and thus improve their urban environmental awareness. in this paper, we describe the demo of our sane architecture. the demo presents how citizens connect to the city-wide data space, how data can be collected, processed, and shared in a privately manner. keywords: smart city, internet of things, urban sensing, citizen science, distributed data processing, data governance 1 introduction as the number of privately owned sensors rises, so does the amount of data collected [bse21]. there are various kinds of sensors like home weather stations, smart home devices, smart gadgets, and smartphones. this collected data is currently not fully exploited; most data is only used in closed data spaces or only available via local access. data sent to a central server of the sensor provider is only shared with those who are part of provider’s network. by relying on a central entity, a single point of failure and trust is given. participants have no other option than to trust the central entity. in addition, these data spaces are usually limited to certain measurement types so that only specific queries can be made, making it challenging to link different information. sane [bjk+19] focuses on closing this gap by providing an open and fully decentralized city-wide data space. everyone can participate by collecting data, providing storage space or adding services that generate higher value information based on existing data. by opening this data space to the public, everyone can benefit from collected data: citizens without own sensor ∗ ahoi.digital 1 / 4 volume 080 (2021) smart urban data space for citizen science hardware interested in their surroundings, businesses needing specific information without the capacity to deploy their own sensor network, and city officials. while collected data is the foundation of the sane-network, own services can be developed and provided to process these data streams into higher-quality knowledge. with a hands-on demo, we would like to present on how simple it is to join and participate to the sane-network by adding new sensors. after the initial bootstrapping process of new sensors, we will show how participants can publish, process, and exchange collected data within the network. therefore, an intuitive user interface is shown to display collected data, communication between participants, and generated information. the following section 2 gives a short overview of the sane architecture. section 3 describes the presented demo. section 4 gives a short conclusion and provides an outlook for future work. 2 sane sane [bjk+19] establishes a city-wide and open data space1. citizens can participate by connecting their sensors and publishing collected data, creating data processing services, and providing storage space to cache existing data on their hardware. the sane framework provides interfaces to answer complex queries and explore existing data within the city. the sane architecture is partitioned into two main areas: field and network. the field consists of sensors contributing new data to the sane data space. for physical sensors, we provide a sane-compatible reference implementation using the open-source operating system riot [bgh+18]. additionally, sane integrates external providers, e.g., via their apis as virtual sensors, allowing them to connect existing data sources to the data space. the network consists of interconnected nodes of varying capabilities operated by citizens. nodes have multiple purposes, they connect to locally deployed sensors, act as gateways for collected data, and provide various services to the system and defining the functionalities of the sane middleware. these include data provisioning, data quality assessment and data processing, access control, and user interfaces. nodes may run any number of services, depending on their resources and user preferences. citizens can access the sane platform’s data via different interfaces, either tailored for visual user experience or direct machine communication. they allow for simple data exploration as well as complex queries connecting multiple data sources and measurement types. to achieve high accessibility, this will be as simple as browsing the www. 3 demonstration scenario our demonstration illustrates the sane approach from a citizen perspective by showing the most relevant aspects of our system in multiple combined example scenarios. the scenarios cover a practical interactive sensing application, intuitive and secure sensor device bootstrapping, integration of heterogeneous public data sources, and citizen-controlled data processing. to showcase the sensing aspect, we deploy ultrasonic and radar-based presence detection sensors in the rooms of the conference location. these sensors register when people move nearby 1 https://github.com/sane-city netsys 2021 2 / 4 https://github.com/sane-city eceasst observed room web-based interface reading sensor data to gather activity in room interactive data query creation with data visualization overlay network collecting and processing data, and providing services bootstrapping user-owned sensors local sensors local sane node remote sane node integrating external data repositories external sensors figure 1: demonstration setup showing locally deployed sensors, sensor bootstrapping, integration of external sensor data, and the interactive web interface to explore the sane data space. to indicate which rooms are occupied and how activity in different rooms changes over time. the sensors wirelessly connect to a sane node based on a raspberry pi. this node provides collected data to the network, consisting of other devices, like servers and laptops. the measured activity can be viewed through a graphical interface, querying the data from the sane middleware. it shows a heatmap of the activity in the rooms on a map of the area. in a hands-on experience with our sensors, shown in figure 1, we demonstrate how users are meant to securely add new devices that will later feed measurements into their digital data space. in this bootstrapping process, a sensor device provisioned with our sane-compatible riot os reference firmware is configured with initial parameters. the user may enter information like a custom name, location, etc., into a web form served by the node. upon finishing this, a prompt with an animated colored screen appears which is used as an out-of-band communication channel to transfer bootstrap meta-data and cryptographic key material from the computer to the constrained sensor device. the latter uses a low cost rgb light sensing peripheral to receive the emitted color signals and then decodes the original data. holding it up against the screen allows it to capture the data and configure itself accordingly to automatically and securely connect to the correct node. afterward, the web interface lists the newly added device together with its metadata and associated data sources. the data integration aspect is demonstrated by including data from publicly accessible external sources, like luftdaten.info and the klimabotschafter e.v.. these show sane’s versatility for data source abstraction, allowing us to benefit from already existing crowdsensing initiatives and thereby expanding the data space available to sane users. our concept of virtual sensors highlights how this external data integrates with our data processing layer so that users can transparently interact with it. for the user-facing component, we showcase a scenario that encompasses the interactive request and discovery of data via sane. the individual sane nodes autonomously discover each other and form an overlay network to orchestrate a distributed system. within this node pool, 3 / 4 volume 080 (2021) smart urban data space for citizen science each participant explicitly expresses trust towards other parties and shares data according to individual preferences. data shared by others is usable as a resource for individual purposes by each trusted participant. a web interface is presented to the user for creating complex queries and data processing steps matching for certain conditions. the user may then utilize these elements to interact with available data and ask the system for related information. we visualize the queries and communication messages sent between nodes in the network to show how sane triggers operations when interacting with it. 4 conclusion and future work with sane, citizens can easily take an active role in their smart city by participating in data collection and use. our approach provides an alternative to closed, commercial devices and data hogging cloud services by giving users full control of the devices that collect their data and the systems that process and share it. data collected from a user-operated sensor is consequently owned by the same user unless it is explicitly shared with others. sane uses virtual sensors to integrate individually shared and public data sources into a data space that can be combined with private data to serve as the foundation for custom data-driven applications and services. citizen participation is an important factor for the success of different smart city initiatives [bj16]. full control over devices, infrastructure, and data processing steps allows users to obtain first-hand experience and improves visibility of aspects that are commonly hidden from users. this additional level of active involvement is considered to eventually raise awareness and acceptance, which is needed for the broad adoption of a participatory distributed smart city infrastructure. for future work, we aim to focus on efficiently address existing information within our distributed network. here we are going to look at distributed complex event processing, fitting the event-based nature perfectly. furthermore, we are looking into improving data quality by evaluating incoming data and quantifying the trustworthiness of values to increase the confidence in information provided by sane’s open data space. references [bgh+18] e. baccelli, c. gündogan, o. hahm, p. kietzmann, m. lenders, h. petersen, k. schleiser, t. c. schmidt, m. wählisch. riot: an open source operating system for low-end embedded devices in the iot. ieee internet of things journal 5(6):4428–4440, december 2018. [bj16] l. berntzen, m. r. johannessen. the role of citizen participation in municipal smart city projects: lessons learned from norway. in smarter as the new urban agenda. pp. 299–314. springer, 2016. [bjk+19] h. bornholdt, d. jost, p. kisters, m. rottleuthner, d. bade, w. lamersdorf, t. c. schmidt, m. fischer. sane: smart networks for urban citizen participation. in proceedings of ieee 26th international conference on telecommunications. 2019. [bse21] a. bárdossy, j. seidel, a. el hachem. the use of personal weather station observations to improve precipitation estimation and interpolation. hydrology and earth system sciences 25(2):583–601, 2021. netsys 2021 4 / 4 introduction sane demonstration scenario conclusion and future work preface electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) preface claudia ermel, reiko heckel, juan de lara 2 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst preface gt-vmt 2008 is the seventh workshop of a series that serves as a forum for all researchers and practitioners interested in the use of graph transformation-based notations, techniques and tools for the specification, modelling, validation, manipulation and verification of complex systems. due to the variety of languages and methods used in different domains, the aim of the workshop is to promote engineering approaches that starting from high-level specifications and robust formalizations allow for the design and the implementation of such visual modeling techniques, hence providing effective tool support at the semantic level (e.g., for model analysis, transformation, and consistency management). the workshop gathers communities working on popular visual modelling notations like uml, petri nets, graph transformation and business process/workflow models. this year’s workshop has an additional focus on visualization, simulation, and animation of models as means of providing an intuitive representation of both their static semantics and for the validation of model behavior. for this purpose, two invited talks have been scheduled, one from industry and the other from academia. the first invited speaker is juha-pekka tolvanen, from metacase (finland), and his presentation is entitled “domain-specific modelling in practice”. the second invited speaker is hans vangheluwe from the modelling, simulation and design lab (mcgill university of montreal in canada), whose presentation will be on the subject “foundations of modelling and simulation of complex systems”. regarding scientific contributions, we had 41 submissions, from which 23 were accepted. the topics of the papers range a wide spectrum, including model integration, verification of model transformations, object oriented notations, visual language processing and grid computing. the accepted papers balance theoretical and applied concepts, including tool issues. the workshop program has been organized in six technical sessions, in two days: saturday, march 29, 2008 sunday, march 30, 2008 model transformations and queries dynamic reconfiguration distribution and semantics verification and programming analysis and visualization case studies and tools we would like to thank the members of the program committee and the secondary reviewers for their excellent work in selecting the papers of this workshop, they are listed below. we would also like to thank the organizing committee of etaps for their constant support. february 2008. claudia ermel, reiko heckel, juan de lara. pc chairs of gt-vmt 2008. 1 / 2 volume 10 (2008) preface programme chairs claudia ermel (tu berlin, germany) reiko heckel (university of leicester, uk) juan de lara (university autónoma of madrid, spain) programme committee paolo baldan (università degli studi di padova, italy) paolo bottoni (università di roma ”la sapienza”, italy) andrea corradini (università di pisa, italy) karsten ehrig (university of leicester, uk) gregor engels (universität paderborn, germany) claudia ermel (tu berlin, germany) holger giese (universität paderborn, germany) reiko heckel (university of leicester, uk) gabor karsai (vanderbilt university, us) jochen küster (ibm zürich research) juan de lara (universidad autónoma de madrid, spain) mark minas (universität der bundeswehr münchen, germany) francesco parisi-presicce (università di roma ”la sapienza”, italy) arend rensink (universiteit twente, the netherlands) andy schürr (universität darmstadt, germany) gabriele taentzer (universität marburg, germany) daniel varró (budapest university of technology and economics, hungary) martin wirsing (ludwig-maximilians-universität münchen, germany) albert zündorf (universität kassel, germany) external reviewers jan-christopher bals, luciano baresi, basil becker, clara bertolissi, enrico biermann, denes bisztray, florian brieler, roberto bruni, troels damgaard, ira diethelm, hartmut ehrig, alexander foerster, leif geiger, esther guerra, stephan hildebrandt, kathrin hoffmann, leen lambers, thomas maier, sonja maier, steffen mazanek, tony modica, stefan neumann, ulrike prange, carsten reckord, tim schattkowsky, andreas seibel, christian soltenborn proceedings gt-vmt 2008 2 / 2 thoughts about using constraint solvers in action electronic communications of the easst volume 078 (2019) 8th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium and industry day, 2018 thoughts about using constraint solvers in action malte mues, martin fitzke, and falk howar 19 pages guest editors: falk howar, anna-lena lamprecht eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst thoughts about using constraint solvers in action malte mues1, martin fitzke2, and falk howar3 1malte.mues@tu-dortmund.de 2martin.fitzke@tu-dortmund.de 3 falk.howar@tu-dortmund.de lehrstuhl für software engineering technische universität dortmund, germany abstract: smt solvers power many automated security analysis tools today. nevertheless, a smooth integration of smt solvers into programs is still a challenge that lead to different approaches for doing it the right way. in this paper, we review the state of the art for interacting with constraint solvers. based on the different ideas found in literature we deduce requirements for a constraint solving service simplifying the integration challenge. we identify that for some of those ideas, it is required to run large scale experiments for evaluating some of the ideas behind the requirements empirically. we show that the platform is capable of running such an experiment for the case of measuring the impacts of seeds on the solver runtime. keywords: smt solving, language integration 1 introduction cybersecurity is an emerging challenge for the it industry and society as a whole currently. protecting society from data breaches as for example the equifax data leak in 2017 that leaked personal data for 50% of the us citizens is an important challenge for politic and industry today. in contrast, the current talent gap of people working in the sector is expected to reach 3.5 million open position in 2021 according to cybersecurity ventures1. therefore, automation of security analysis is an important topic of ongoing research at universities and major companies (c.f. [coo18, bey19, god20]). most of them have to make at some point a decision as next step in the analysis algorithm used for security analysis. if the security of a program is analyzed, those decision problems are typically encoded as sat or smt problem (e.g. cbmc [ckl04], dart [gks05], jdart [ldg+16], klee [cde+08], psyco [grr12]). deciding satisfiability of non-trivial formulae is in most cases reducible in linear time to 3-sat and therefore np complete. the single exception are problems reducible in polynomial time to 2-sat as this problem class is solvable in polynomial time (e.g. with the algorithm presented by aspvall et al. [apt79]). traditionally, there is an agreement that an efficient algorithm should be implemented in polynomial time. given, that n is the input size of a problem, ideally, the worst-case complexity should be in o(n). anyhow, many algorithms generating values in the day to day business are not even close to this theoretical worst-case complexity. for example, the previously mentioned 1 https://cybersecurityventures.com/jobs/ 1 / 19 volume 078 (2019) mailto:malte.mues@tu-dortmund.de mailto:martin.fitzke@tu-dortmund.de mailto:falk.howar@tu-dortmund.de https://cybersecurityventures.com/jobs/ thoughts about using constraint solvers in action program analysis often uses some kind of constraint solver in the backend. those solvers apply heuristics to decide the potentially np complete problems in reasonable time frames and deliver monetary values with theoretically inefficient algorithms. in the remaining of the introduction, we will briefly describe the usage of constraint solvers, define constraint problems, have a short summary of the history of smt-lib, and conclude the section with architectural challenges during the integration of smt-lib into algorithm implementations. at the end, we give an outline of the remaining paper. constraint solvers. today, there is a broad bouquet of constraint solvers powering the development of decision procedures for source code analysis. the most prominent open source constraint solver is z3 [db08]. but there are various modern smt solvers available that are not less efficient (e.g. cvc4 [bcd+11], dreal [gkc13], princess [rüm08], mathsat5 [cgss13], smtinterpol [chn12], yices 2 [dut14], z3str3 [bgz17]). all of these constraint solvers have in common that they are capable to decide satisfiability of constraints. a major part of modern constraint solvers uses some kind of conflict driven clause learning (cdcl), which is a framework that has grown in a series of improvements over time to the dpll algorithm [dp60, dll62] for solving satisfiability problems. cdcl uses the backtracking similar to dpll and combines this with heuristics to determine the next search direction whenever a decision is required (cf. kroening et al. [ks16, chapter 2.4]). cdcl is not efficient from a theoretical point of view. nevertheless, due to the recent work in the area of constraint solving, many practical problem instances are solved in acceptable time windows. the smt solver community tracks the progress made regarding constraint solving at the smt competition called smt-comp.2 getting back to software analysis tools using smt solvers, we are able to observe a general architectural pattern: they collect logical constraints describing the current source code under analysis and feed them into a constraint solver at some point in the analysis. sometimes these constraints are further combined with verification conditions before passing them to a constraint solver. while some tools need to resolve one large constraint problem at the end of the analysis (e.g. cbmc, a bounded model checker for c) targeting an unsatisfiable result, other tools call repeatedly a constraint solver in the background as part of the analysis (e.g. jdart, a concolic execution engine for java). cbmc will only query the constraint solver more than once if analysis violation leads to satisfiability results. these repeated calls are required to generate models and explanations as counterexamples for the analysis target. each call excludes a violation of the verification property found before. jdart actually needs the interaction to continue exploring the search space during analysis. the advantage of repeatedly calling a constraint solver during analysis is that the solver might reuse some of the results computed in a previous decision. this methodology is called incremental constraint solving. constraint problems. in this paper, we use the term constraint problem to express any logical formula consisting of variables, eventual unary or binary operators valid in a theory associated with the type of the variables and logical combinators (and, or, xor, not, implies, and quantifiers). if we are speaking of a constraint problem encoded for a sat solver, the problem has been reformulated to a pure boolean variable problem which is decidable by a sat solver. whenever 2 https://smt-comp.github.io isola ds+is 2018 2 / 19 eceasst we refer to a constraint problem passed to the smt solver, we assume that the smt solver supports a fitting theory. as the concrete types and operations allowed in a constraint problem also depend on the type support of the used smt solver, we will not formalize this expression further. for the ideas presented in this paper, it should be sufficient to keep in mind that a constraint problem is always solvable by either a sat or a smt solver, depending on the context and required theory. the main difference is that smt constraints allow a higher-level description than sat constraints as more expressive theories than the boolean theory are allowed. the smt-lib language. the smt solver community recognized quite early that they need a common input language to all the different smt solvers. ranise and tinelli supposed the smt-lib in close collaboration with the smt-lib interest group in 2003 [rt03]. the original mission statement for the smt-lib was: “we believe that having a library of benchmarks will greatly facilitate the evaluation and the comparison of these systems, and advance the state of the art in the field [...]” [rt03, p. 1]. from the perspective of an smt solver’s user, the benchmarking focus has been important for pushing the solver’s capabilities further providing at the same time a bookkeeping of each solver’s capabilities. the more important aspect of smt-lib from a user’s perspective is that smt-lib has been developed towards the primary industry standard interface for interacting with smt solvers on command lines. smt-lib is a textual input format and solvers are often called by interprocess communication. as a consequence, the separation between the analysis and the source code becomes a problem. the analysis is no longer part of the programming language, but instead exists only in value assignments of variables. therefore, program analysis gets harder. for example, the smt-lib syntax of analysis rules is not checked during compile time, as the compiler does not consider the string values as part of the language. integration challenges. at the end of the 20th century, the term 4th generation language (4gl) has been coined for a new generation of languages. dsls aiming on solving a certain problem, as for example interacting with a database, are considered to be a 4gl. the hope was a productivity gain by reducing the program complexity in exchange for eventually more cpu and memory utilization (cf. the case study by lehner [leh90]). prominent members of the 4gl family are regular expressions for parsing strings and sql as a database interaction language. there has been drawn the conclusion recently that smt-lib has established in a similar way as smt solver frontend as sql is established as a database frontend language (cf. [kfb16, hjm19]). anyhow, we are convinced that it is not sufficient to establish smt-lib as a common interface format. sql is a fourth-generation language and such is smt-lib. both have in common that they are used in other programs written in 3rd generation languages (or more frequent referred to as high-level languages) as for example java or c++. this means, we keep most of the problems for integrating a fourth-generation language into programs with smt-lib. we have seen this for using regular expression in programming languages as well as for using sql in programs. especially for sql, it has not been sufficient to build an object representation for sql into a programming language as there remains the question how to serialize a complex object structure into a relational table. this problem is commonly known as the object-relational impedance mismatch. instead, higher abstraction levels for integration have been developed as for example hibernate3. another branch of research tried to integrate sql directly into the 3 http://hibernate.org 3 / 19 volume 078 (2019) thoughts about using constraint solvers in action language compiler (c.f s4j [rlo16] or scalaql [sz09]). smt-lib has a similar problem. while it is not required to serialize an object into a database, it is required to find a way for reasoning about the object in a given theory. once such a reasoning is defined, it is still required to express this as an smt-lib string and pass this string to a smt solver for processing. once the solver terminates, the result of the solver has to be deserialized into data structures useful to the program logic. while most decision problems encoded in a logic and passed to a solver are expected to be answered in a boolean yes or no style, most solver designer allow that the solver refuses solving a task and responds a do not know answer. this is a very simple example for what might be called a inter-theory impedance mismatch in the decision procedure world similar to the object-relational impedance mismatch in the database world. in addition, information provided in the answer model of the solver needs to be translated back into the original programming language to reuse them in later queries against the solver or make decision outside of the solver instance. especially, if the underlying theory is not easy representable with hardware data types, as for example decision results based on the real theory using real numbers. this introduces additional challenges for aligning the smt-lib world with the surrounding programming language not present for other 4gl languages. outline. in this paper, we will sketch out our perspective on the challenges for integrating smt-lib into industry grade programs. therefore, we will first point out in section 2 the state of the art of integrating constraint solvers into programs and current proposed solutions. in continuation, section 3 describes additional required steps from our point of view. we designed an experiment platform for addressing some of the question raised in section 3 empirically. this platform is described in section 4. section 5 presents some first results. finally, section 6 concludes the paper. 2 state of the art as smt solvers power various new research areas and restimulate research branches such as symbolic execution, there exist plenty of publications around algorithms for solving satisfaction problems and optimizing the decision procedures for special cases (cf. [bhm09]). in this paper, we will focus on the software engineering aspects of interacting with smt solvers in other analysis algorithms and therefore skip literature describing smt solver internals. the discussion about smt-lib and sql is not the only parallel in the comparison of the usage of smt solvers and database engines. databases are only able to deliver their optimal performance if chosen and configured appropriately for the problem at hand. each database system has a very different characteristic. this starts from the general design of data storage as a nosql, row-store or column-store database and ends with specific fine-tuning configuration options for each database system. once the right engine is chosen, defining the right database schema layout along with efficient caching indices is still crucial for the resulting overall performance. smt solver tackle a different challenge than databases, but many different groups have developed small improvements for speeding up a certain edge case of constraint solving just by improving the way how they interact with constraint solvers. we first present the two main ways of interacting with a 4gl engine in both domains: interprocess communication and language bindings. a subsection on access patterns for smt solvers concludes this section. isola ds+is 2018 4 / 19 eceasst 2.1 interprocess communication a popular way to communicate with smt solvers across processes is communication over pipes. often, a newly spawned thread executes the solver binary and exchanges the problem and the results using pipes with the main analysis thread. this is comparable to call a database using the database command line interpreter. the interpreter is a small binary capable of receiving strings on the standard input pipe and is therefore controlled by a string-based language. any result produced by the binary is then printed on the standard output pipe. due to the string based data transfer between processes, this communication pattern requires good serialization and deserialization support for the data at hand. most smt solvers support a smt-lib compliant frontend and are able to consume smt-lib constraints directly from the command-line or from a file, as smt-lib is the standard for textual constraint representation. serializing a higher-level object into a smt-lib string makes it impossible to reuse already available information in the constraint object for optimization. therefore, any potential optimization that uses domain specific information in the object structure of the constraint has to be integrated into the serialization method. the smt-lib frontend for each solver is comparable to the open database connectivity (odbc)4 interface for databases in the way that both approaches use a string based language for controlling the underlying technology. a downside of this approach is that some new features are not yet part of smt-lib. hence, some solvers, like smtinterpol [chn12], require new smt-lib commands for special features like calculating interpolants. they added get-interpolants as a valid command to the smt-lib query language of smtinterpol. this extends inter process communication using the smt-lib to extended features, at the cost of increasing the amount of smt-lib dialects that a state-of-theart smt parser has to maintain. otherwise, interprocess communication is not capable of using multiple different solvers to their full potential. for the case of get-interpolants, other solvers later adapted the same semantic underlining the need for a shared input language across solvers. cok introduced jsmtlib [cok11] as an abstraction layer for interacting with smt solvers in java. jsmtlib is an example using interprocess communication over pipes to access a solver. the tool consists internally of an abstract syntax tree (ast) as main data structure for representing constraints and a parser that converts between the textual representation in the smtlib format and the jsmtlib ast. the library does not provide any higher-level views or abstractions to the constraint problems. but it is designed to support different solvers and allows to address subtle divergence between a solver’s behavior and the smt-lib standard. therefore, jsmtlib allows the formulation of constraints by creating elements of the ast and combining these parts into the final query. this query is then passed to the solver and the answer parsed using the smt-lib parser suitable for each solver. the advantage of this approach is that any smt-lib compliant solver might be plugged in to a program at the cost of a slim adapter class for the solver. this adapter creates a process running the solver and takes care of the communication with the solver. once this adapter is available, the solver can be selected in the configuration as solver used for the jsmtlib instance. anyhow, it is still up to the user to select the right solver for the problem at hand. the official smt-lib website5 names six other tools for parsing smt-lib (supporting antlr, c99, haskell, ocaml and swi-prolog). 4 e.g. http://www.unixodbc.org, on of the state-of-the-art projects evolved form the sql cli standard [vp95] 5 http://smtlib.cs.uiowa.edu/utilities.shtml 5 / 19 volume 078 (2019) http://www.unixodbc.org http://smtlib.cs.uiowa.edu/utilities.shtml thoughts about using constraint solvers in action 2.2 language bindings using a language binding api of an smt solver is the other main way to interact with a solver. the advantage is that any decision data structure is directly mapped to data structures in the solver api. therefore, the serialization and deserialization step is no problem, avoiding also any trouble with smt-lib dialects. the downside is that the comfort of an universal exchange format in textual form like smt-lib is lost. using the complete available api and not only the exposed subset of functionality that is exported through an smt-lib frontend might nevertheless be desirable. therefore, different projects established a native connection to solvers using the corresponding language bindings. as most of the solvers are written in c++, a truly native connection might also be written in c++. smt kit6 provides a c++ library for interacting natively with z3, cvc4 and mathsat5. in the java world, jconstraints [hjm19] and javasmt [kfb16] are both developed as an intermediate java api towards constraint solvers. we compare them briefly. at the moment (may 2020), javasmt supports mathsat5, smtinterpol, z3, cvc4, boolector and princess according to its website7. jconstraints supports a slightly different subset of solvers. apart from z3 and smtinterpol, jconstraints supports dreal, coral and an implementation of the concolic walk algorithm [da14]. further, representing smt constraints in an expression tree structures of java objects is a shared idea between both libraries. this expression tree might be modified using visitors allowing a powerful way to modify expressions in a controlled way. the visitor also allow to implement domain specific optimizations on the constraint structures. nevertheless, jconstraints and javasmt have been developed with subtle different focuses. as described in detail in the javasmt paper [kfb16], karpenkov et al. aimed for a library allowing easy interaction with a constraint solver at optimal speed. to archive this, javasmt ships with its own jni-library for accessing the z3 binaries optimizing memory strategies [kfb16, section 4]. in addition, the configuration amount required to exchange a smt solver should be minimized. jconstraints main focus was an easy and efficient way to store and manipulate constraints and has been designed for speed in the second place. as it was designed initially along with jdart [ldg+16], the main focus was the constraint management during jdart’s analysis. to achieve the usability during java analysis, an evaluation model has been designed as part of jconstraints that models native type’s semantic in java. this evaluation model evaluates that a given constraint solver solution aligns with the java type semantic. this evaluation model is the core feature of jconstraints opening the field for decision procedures speeding up the decision using a problem relaxation before solving (cf. feal [hjm19]). pysmt [gm15] is a robust python frontend to various smt solvers combing the ideas behind jsmtlib, jconstraints, and javasmt in a single library. it creates some kind of dsl for integrating smt into python and allows a lot of constraint simplification and modeling support in python. the library supports interaction with z3, mathsat5, cvc4, yices, cudd, picosat and boolector using the python language bindings. in addition, there is a general-purpose communication support for an arbitrary smt-lib compliant smt solver comparable to the solver communication of jsmtlib. to do so, pysmt also provides a parser for smt-lib as one component. 6 http://ahorn.github.io/smt-kit/ 7 https://github.com/sosy-lab/java-smt isola ds+is 2018 6 / 19 eceasst additionally, pysmt allows portfolio solving. the idea of portfolio solving is running more than one solver in parallel on the same problem. based on the observation that different solvers have different weaknesses, but also strengths, the hope is that one solver returns faster than others and therefore speeds up the execution. the very same approach has been discussed as an idea for the solver layer of the symbolic execution solver in klee [pc13] which is a symbolic execution engine for llvm. they used the metasmt [rhf+17] framework for the realization of a portfolio solver. metasmt connects various different solvers to c++ applications using the native api of each solver. it provides a dsl for generating constraints in a solver independent way and translate them for each connected solver to the native api. up to this point, the described solutions are comparable to sql query builder libraries as for example jooq8 or querydsl9. next, we will shortly examine further ideas for solver interaction. 2.3 access patterns apart from the above described features pysmt also provides caching of constraint solutions. therefore, constraints are normalized and then stored with the corresponding solution in a store. klee [cde+08] has also built a constraint cache internally as a frontend to metasmt and demonstrated that caching queries instead of passing all of them directly to the smt solver speeds up analysis algorithms. for the java world, the green [vgd12] solver introduced the idea of constraint caching in a java library. it consists of a constraint representation that can be canonicalized. further, green defines a way for looking up previous result maintained for these canonicalized form in a cache. the framework has been used successfully in spf [pr10] as constraint cache and solver access layer. last but not least, clarke et al. [ckl04] introduced cbmc as a bounded model checker for c. it is a prominent tool using constraint satisfaction as part of their reasoning. during the symbolic execution of a program, cbmc collects constraints in its own internal representation. once the symbolic execution engine is done, the constraints are converted to fit a backend constraint solver and this solver is invoked to solve the decision problem instance resulting from the analysis. at the moment, mainly sat solvers are supported. the smt integration is currently under a rewrite. anyhow, they have a complete implementation of tseitin-transformation, allowing the conversion of their sat encoding into the conjunctive normal form (cnf) before passing it to the solver. it has not been demonstrated, whether this speeds up query time in general or not. to the best of our knowledge pysmt is the only library at the moment that is able to select the right solver based on a set of available solvers. this is the first step in the direction of an automated solving service that chooses automatically a solving strategy for a given constraint problem. therefore, it combines and selects solvers form the available smt solver bouquet using heuristics. this is comparable in the idea to an autonomous database manager that is able to work with different data bases deciding on its own which is optimal used for which purpose. we are convinced that the managed service for constraint solving might overcome a couple of problems managed services for databases are not able to solve due to consistency and persistence requirements. in the following section, we will derive some requirements for a full featured constraint solving service and motivate them from a software engineering point of view. 8 http://www.jooq.org 9 http://www.querydsl.com 7 / 19 volume 078 (2019) thoughts about using constraint solvers in action 3 requirements for a constraint solving service summing up the above described ideas, we already find evidence in the literature that investing into an easy to use constraint solving frontend is worth it. in addition, major software companies start adopting constraint solver-based tools for maintenance task in their infrastructure (e.g. [coo18]). z3 originates from microsoft research and is actively developed there until today. nevertheless, we have seen that especially pysmt is way more feature rich than the java and c++ libraries. we think that pysmt is the first step toward offering a constraint solving service instead of just a dsl for formulating constraint problems. from the above examples, we identify following points as an integral part of a constraint solving service to make it competitive with the state-of-the-art solver abstraction libraries: • support for close to all available smt solvers to catch up with all the different performance improvements and avoiding eventual solver lock-in with an application. • deserialization and serialization support for smt-lib in the most current version. • a constraint problem dsl that integrates well to the target programming language of the constraint solver service and allows the definition of constraint problems including a type semantic conversion for native types. • powerful standard manipulations of queries like establishing cnf, replacing variables, etc. • solver strategies and portfolio solver infrastructure allowing to push the complete constraint solver bouquet to its limit using all available hardware resources. • a caching framework for queries to reduce the number of solver invocations. this framework should further interact with eventual incremental solving stacks allowing to reuse a partial solution. the envisioned architecture is sketched out in fig. 1. a user should use the provided constraint dsl to formulate a constraint problem. this constraint problem is passed to a service manager. the service manager needs to support as much constraint solvers as possible, in order to select between them and to choose one that is capable to solve the problem at hand. the choice is made based on empirical evaluated auto configuration rules. cvc4 [bcd+11] already explains in the accompanying paper that there is more than one way to compile the binary allowing to use or suppress certain theorem proving behaviour. this is one example for a complicated solver configuration option. most likely, a single user will not invest the required time to finetune the solver interaction layer to interact with different compiled binary versions. it is also possible to configure and fine-tune some of z3 parameters. running z3 -p lists more than 400 configurable parameters influencing z3 and the integrated theorem engines. concentrating the solver configuration knowledge in a central place that is used across different projects allows the community to share the solver tuning knowledge. this implies that progress in solver speed is faster delivered across projects. depending of the constraint problem size, it might further be desirable to distribute the solver across different machines. therefore, a network interface between the solver and the manager isola ds+is 2018 8 / 19 eceasst constraint solving service manager constraint problem cv c4 z3... yices2 mathsat 5 solve response and ex planation : {sat /u nsat /don′t know} +cores and models figure 1: vision for a constraint solving service architecture. the user should only interact with a single service component demonstrated in the center. the constraint problems are passed to the central service manager and somewhen in the future, the manager answers with a response and additional resources if they are requested. all interaction with solvers is done by the manager. node will be required. we want to investigate this kind of workload distribution in the future to refine our solver platform idea. if the solver is expected to spend a few hours on the problem, it might be worth to pay the overhead for problem distribution and result collection. this might also allow analysis algorithms using the first result available for continuing computation while the slower solvers are running in the background. once all solvers terminate, the results can be compared later identifying potential mismatches. in case of a mismatch, the analysis might be spurious and the result might be persisted by the solver manager for further research. this way, new real-world examples of hard to solve problems for state-of-the-art solver might be collected. apart from the pure decision result, other artefacts have to be collected and provided to the user as well. these artefacts depend on the formulated request, but might consist of interpolants, satisfaction models, minimal unsatisfiable cores, or simplified formulas. the dsl used as input language must be flexible enough for also encoding these results in an easy to use way. independent of the result encoding, the developed dsl for formulating constraint problems should contain dsl primitives that already encode the default semantic for native datatypes in different high-level languages. for languages like java, where the semantic of a native type is well defined, a semantic mapping should be defined in the dsl definition. this mapping might later be used to create variables in the smt problem that allow to reason about the original source code variable. especially the design of source code analysis algorithms would benefit from such a mapping. for languages like c, where the semantic mapping allows some flexibility, a default should be defined. it is possible to select a standard architectural mapping of int, long, char, etc. 9 / 19 volume 078 (2019) thoughts about using constraint solvers in action 1 s t a t i c v o i d f o o ( 2 i n t a , i n t b ){ 3 i n t c = 8 4 i f ( a < 6 | | b > 4 ){ 5 c = a + 3 ; 6 } 7 a s s e r t c > 9 ; 8 } 1( a n d ( = c 0 8 ) 2( o r (< a 0 6 ) (> b 0 4 ) ) 3( = c 1 ( + a 0 3 ) ) 4(> c 1 9 ) ) figure 2: a small example and the cnf encoding of the happy path in the foo method. and make this easily configurable to other architectures if needed. this allows to start with a reduced configuration option for the initial architecture selection in the dsl layer and fine tune the exact semantic as needed. transforming normal sat problems with boolean variables into cnf is a well understood problem and for example cbmc supports this internally. so far, we haven’t found an implementation for a standard conversion to cnf in one of the constraint libraries. during the development of jstateexplorer which is used in psyco [hgmn18], we figured out that it is desirable to get this kind of transformations as an additional feature. some parts of constraint might be pruned, because they are created about variables in the original system that are no longer of interest after passing a certain point in the analysis. consider for example the constraint in the right side of figure 2. the constraint encodes the happy path for the method foo passing the assertion at the end of the method. the given representation makes it easy to reason about the subclauses leading to the contradiction between (< a0 6) and (> (+ a 0 3) 9). as a consequence, none of the successful execution does apply the value bound on a 0 in the if condition. hence, the left part of the or-clause can be removed. it is a small example, for an optimization that is easily conducted in the cnf format. we are convinced that there are more small optimizations that might reduce constraints and also variables in constraints over time. from our point of view, it is worth to discuss the right language for developing such a constraint solving service. as many solvers are written in c++ and some other solvers like smtinterpol are pure java libraries it is unclear what is a good main language. javasmt has already shown that it might be possible to came up with efficient java bindings using the java native interface (jni) but that it also might be worth to question the prebuild language bindings. as we are planning to continue the development of jconstraints as a solving service for jdart, we will stick with java for now. nevertheless, it would be interesting to see a feature equivalent c++ version for benchmarking purpose in the future. we mentioned in various points that it is required to make decisions for the right solver evaluation based on empirical results. such a decision requires the capability to run a large amount of experiments in an efficient way, comparable to batch-job processing. in the remaining of this paper, we will report on our approach for developing an experiment platform and try to answer the question, whether seeding z3 with different seeds might be a successful strategy for a portfolio solver or not. this question is one example for a potential optimization in a solving service, isola ds+is 2018 10 / 19 eceasst that need some empirical input. a design goal of z3 is stable seeding and robust implementations to minimize effects of seeding. anyhow, internally z3 uses heuristics that are influenced by randomness and therefore also effected by seeding. turning this design knowledge into runtime benefits by utilizing hardware more exhaustively requires to investigate the solver behavior empirically in upfront. next, we describe the design of a batch execution platform allowing such experiments for generating data about a solver. 4 a platform for running experiments in the cloud the general problem, we are trying to solve is running the same binary with different configurations passed on the command line. following the current trend for packaging and running applications, a docker image containing the experiment has been built. the docker image can be run and the configuration required passed as command line parameter to the docker image. further the docker daemon can be configured to enforce resource limits using dockers cgroup support. cgroups are a linux kernel technique for limiting the resources of a process and its children. this turns the execution of the experiment into running docker containers with resource limits and a set of command line parameters. in order to achieve some throughput, this should be managed across different machines. to the best of our knowledge, the only tool available offering this service of batch processing used to be aws batch 10 by end of 2018. as this is a closed source service behind a pay wall, it is not available for our experiments. during 2019 kubernetes introduced kubernetes tasks. a feature delivering the same benefit. but is has been released after we completed the experiments. we are aware, that using a docker image might not be the best available possibility for reproducibility of experiments in the future. using the benchexec framework provided by wendler et al. [wb19] might have resulted in a better reproducible measurement if we are only interested on the performance of a single parameter. hence, for the particular supposed experiment in this paper, a benchexec setting might have been better. beyer et al. [blw19] describe the ideas behind the benchexec approach in more detail. the main feature they point out, is pinning processes to dedicated cores avoiding effects in measurement due to cache misses. additionally, changing cpu frequencies due to workloads is disabled on their cpus by default for reducing the effects on the measurement. we will call the concept of changing cpu frequencies boost clock as every hardware manufacturer has a particular name for this technology. in addition, beyer et al. vote for not using hyperthreading (in the sense of simultaneous multithreading) as this might slow down the execution. instead of disabling hyperthreading on the bios level and therefore changing the actual cpu behavior, the operation system is used to ensure scheduling of work is only on one of two vcpus (or threads) bounded to a physical core. by design, hyperthreading is only expected to have a positive impact on i/o intensive workloads. as benchexec is designed to measure cpu-bound tasks, it would be more adequate to run it on cpus with disabled hyperthreading to make sure there are no side effects of the supposingly idle vcpu on out-of-order execution. while disabling boost clock makes an experiment more reliable, our focus is the overall wall clock time for the end user, and beyer et al. demonstrate clearly a significant performance 10 https://aws.amazon.com/batch/ 11 / 19 volume 078 (2019) https://aws.amazon.com/batch/ thoughts about using constraint solvers in action drop for disabling boost clock. hence, if a verification method is allowed to be running for example on 4 vcpus, which might be simulated by running a docker container with the –cpus flag, we want to see effects of using these cpu resources as efficiently as possible for lowering the overall wall clock time. that’s why we started to design the solving service as most stateof-the-art verification methods are backed by a solver and getting cpu time is still comparable cheap on modern multicore systems. docker uses standard linux cgroups in the background for limiting resource access. pinning tasks fix to always the same cpu core might not allow to use the complete thermal reserve while boosting the cpu. therefore, we are not supporting any approach for core pinning at the moment in our execution platform. nevertheless, docker has a –cpuset-cpus flag allowing a restriction of the vcpus of the host system used for running the container. in the same way, docker allows to setup cgroups in the background for limiting the memory usage. resource constraints are therefore enforced while running a docker image in the same way benchexec enforces them on a linux machine. in the future, running experiments for a solving component following the design in figure 1 is likely to communicate over a network with different parts of the architecture, unless everything is fitted in the same physical cpu. therefore, the planed future direction of the empiric measuring task is not fitting the target of the benchexec software right now. we observe more effects introduced by i/o bound interaction as accessing a network interface. from our point of view, running different solvers in different docker container and communicate between them within a virtual defined network as part of an integration test, seems easily doable with modern cluster orchestration engines for an end user. we are aware, that the results obtained are likely influenced by measurement inaccuracies due to effects in the cluster. nevertheless, we think this is a well-suited setup to detect general trends by repeating experiments and figure out whether there are single problem instances, which should be investigated in more detail in future work on a high precision measurement system for benefiting the solver development. in the meantime, we can use the improvements gained by the solving service running it on docker containers independently of eventual single solver improvements. given a cloud platform consisting of different machines for running the experiments, a platform running the docker containers utilizing the cloud hardware efficiently is required. as part of the reported work, a docker based experiment execution platform has been designed. as said, a single experiment consists of a docker image along with a set of configuration parameters passed on the command line. bundling the image in a description together with the command line parameter turns all the experiments into executable and isolated tasks. isolation is needed to prevent software dependencies from disturbing one another. to structure the experiment further, these tasks can be grouped into single jobs for the experiment execution platform. the bundling and configuration is done using docker compose files. these docker compose files can easily be run in a docker swarm as executor. with docker swarm we can run multiple containers each representing one sub experiment on one or more machines. in case images need to collaborate for the execution of the experiment, the docker compose file might be used to describe a stack of docker container collaborating together and how to wire a network between these containers. in the presented experiments one docker compose file describes all runs executed for a single benchmark file as a set. anyhow, docker compose files can be used in theory to describe arbitrary tasks as long as they are expressible as a docker compose stack. unfortunately, compose files alone are not sufficient to describe the required experiments. they do not cover all needed isola ds+is 2018 12 / 19 eceasst figure 3: platform architecture requirements as a maximum runtime and credentials for private docker repositories are not covered yet, but are required for pulling images from a private repository. therefore, the job file was designed that encloses the docker compose file and contains additional information. each container in a stack can be configured individually and those configuration options also include hardware requirements that are later enforced on each host machine by the docker layer below the docker swarm. docker takes care of setting up cgroups on each host to meet these hardware limits. the experiment execution platform designed takes care of bundling available machines into a docker swarm cluster. during this task, the hardware requirements in the docker compose files are respected to efficiently use the available hardware resources. once a job definition is received by the platform, a docker swarm of a suitable size is created and the compose file deployed to the docker swarm. a docker swarm consists of managers and workers. managers receive and process the compose files and distribute the tasks on their workers autonomously. a worker receives a task, pulls the needed container image, and runs it in a container. the platform designed uses rest calls for job submissions and result retrieval once the job is completed. between the docker swarm cluster and the rest endpoint, a component has been added that parses job files and takes care of credential handling and time limit enforcement. next, this additional component is described in more detail. it consists of two components, the management component and the node component as shown in figure 3. the management component controls and organizes the platform. user interaction is done through the management api and users can send jobs and manage the registered worker machine representing a node in the platform. when a job is received the platform adds it to a queue and schedules it for execution. the queue is worked off sequentially. for every job the management calculates which resources are needed in sum and tries to build a fitting sub cluster of machines from the available nodes. if the management node finds a suitable subset of machines in the cluster, it triggers the creation of a docker swarm on this sub cluster. once the new swarm is online, it sends the job to the swarm manager and marks all nodes of that cluster as unavailable for other jobs. the swarm runs the job to completion. once the job is completed, the results are pulled from the cluster node and made available for the users through the central management api. this is required to extract the results from the docker container so that the container can be destroyed. the swarm terminates leading to the release of all resources in the sub cluster. the management node marks them as free again. from now on, other jobs might claim these nodes for job execution. whenever sufficient resources are available for a job in the queue, the management repeats all those steps for computing the results leading to one swarm per job. the node component is responsible for running the jobs and therefore able to utilize the docker 13 / 19 volume 078 (2019) thoughts about using constraint solvers in action id problem same seed multi seed difference (same multi) sd mean sd mean mean sd 1 /45vars/v45 problem 2 008.smt2.slack.smt2 11.49 7149.0 5.08 7140.0 9.0 6.41 2 /size50/c50 problem 006.smt2.slack.smt2 9.22 253.0 7.50 238.5 14.5 1.72 3 /size100/c100 problem 004.smt2.slack.smt2 13.30 238.0 7.64 231.5 6.5 5.65 4 /size100/c100 problem 006.smt2.slack.smt2 9.78 184.5 2.55 181.0 3.5 7.23 5 /size60/c60 problem 006.smt2.slack.smt2 16.15 311.0 2.93 299.0 12.0 13.22 6 /size60/c60 problem 005.smt2.slack.smt2 13.54 7281.0 4.54 7274.5 6.5 9.01 7 /size80/c80 problem 005.smt2.slack.smt2 6.06 7349.0 3.20 7344.0 5.0 2.87 8 /size20/c20 problem 003.smt2.slack.smt2 5.95 183.0 4.16 173.0 10.0 1.79 9 /size20/c20 problem 004.smt2.slack.smt2 15.55 186.5 7.45 178.0 8.5 8.10 10 /size20/c20 problem 006.smt2.slack.smt2 10.46 258.5 5.69 250.0 8.5 4.78 11 /size10/c10 problem 006.smt2.slack.smt2 9.64 150.5 2.17 143.0 7.5 7.47 12 /size10/c10 problem 001.smt2.slack.smt2 5.32 53.5 4.29 52.5 1.0 1.03 13 /size10/c10 problem 004.smt2.slack.smt2 9.52 7146.0 1213.12 6435.0 711.0 -1203.60 14 /size10/c10 problem 002.smt2.slack.smt2 8.98 109.5 6.93 109.0 0.5 2.05 15 /size10/c10 problem 005.smt2.slack.smt2 9.37 193.0 12.45 182.0 11.0 -3.09 16 /size90/c90 problem 004.smt2.slack.smt2 7.24 206.0 6.89 198.0 8.0 0.35 17 /size90/c90 problem 005.smt2.slack.smt2 6.91 269.0 8.24 261.0 8.0 -1.33 18 /size90/c90 problem 002.smt2.slack.smt2 13.06 564.0 7.02 564.5 -0.5 6.04 19 /size30/c30 problem 003.smt2.slack.smt2 18.76 513.0 9.34 491.0 22.0 9.42 20 /size30/c30 problem 002.smt2.slack.smt2 8.90 253.0 6.63 246.0 7.0 2.28 21 /size30/c30 problem 006.smt2.slack.smt2 11.66 173.5 5.25 165.0 8.5 6.41 22 /45vars/v45 problem 001.smt2.slack.smt2 12.26 131.0 3.11 112.5 18.5 9.15 table 1: experiment-report: problems are taken from the qf lia8 category of the smt-lib benchmarks. we are reporting the standard deviation (sd) and mean for each experiment set. in addition, the difference between the same seed and the multi seed experiment is reported. client on the machine. on the sub clusters are, as already mentioned, docker swarms created that can be dynamically build and terminated by the management. the node api of the swarm manager receives the job and deploys it on the other nodes in the swarm. every task is distributed inside the swarm and executed in a container. after a task is done the manager node pulls the result from the worker node. after all workers finished their task, the results are bundled on the swarm management node and wait to be transferred to the central platform storage on the platform management node. in conclusion, the platform is able to run many jobs in parallel and automated. the number of parallel jobs depends on the available hardware and requested hardware requirements for a job. as a result, it is possible to automatically run a large set of experiments on a cloud infrastructure and keep the user interaction as minimal as possible, so that the focus can be kept on results and their evaluation, which we will describe next. 5 experiments and evaluation jsmtlib has been integrated into jconstraints as part of the reported work. this allows to evaluate solver timings empircally on smt-lib benchmarks running with jconisola ds+is 2018 14 / 19 eceasst -5 0 5 10 15 20 0 20 40 60 80 100 120 140 m e a n p e fo rm a n c e i m p ro v e m e n t (i n % ) number of experiments figure 4: the plot demonstrates the performance gain between the mean over 10 z3 invocations with different seed values compared to running the solver 10 times with the same seed. the performance improvement is reported in percent. it is visible that sometime the single seed is substantial better than the mixed seed set, if the experiment ended up on the left side, and there are other seed values improving the performance, if the experiment ended up on the right side. straints. for the experiments reported in table 1, we used smt problems located in the qf lia/20180326bromberger/more slacked/cav 2009 benchmarks/smt, qf lia/20180326bromberger/more slacked/cav 2009 benchmarks/coefsize/smt/ and qf lia/20180326bromberger/more slacked/cut lemmas/ folders of the qf lia11 benchmark. we packaged them along with the jconstraints-jar12 in a runner that accepts a seed value and a path to an smt problem instance. this runner is deployed as docker image. for this paper, we also included the jconstraints-z3 plugin to the docker image. in a first step, we have run each of the smt problems ten times with the same seed13, and ten times with different seeds14 using the z3 solver only. the seeds are selected randomly by a human being without any planed pattern. for each of the runs, 8 cores and 16 gb of ram has been provided. we used a cluster of 10 virtual machines hosting in total 400 cores and 700gb of ram to crunch through the tasks. these virtual machines are running on a 19 node cluster with 1216 cores (amd opteron 6272) and 4864 gb ram in total providing opennebula for vm management and kvm with a linux kernel as hypervisor. 11 https://clc-gitlab.cs.uiowa.edu:2443/smt-lib-benchmarks/qf lia 12 the source code is publicly available: https://github.com/mmuesly/jconstraints-runner 13 [1234] 14 [124, 1325, 14253, 164, 145308, 13257, 1325156126412, 142357, 732, 1234] 15 / 19 volume 078 (2019) https://clc-gitlab.cs.uiowa.edu:2443/smt-lib-benchmarks/qf_lia https://github.com/mmuesly/jconstraints-runner thoughts about using constraint solvers in action table 1 reports the range between the highest and lowest runtime in addition to the mean runtime across each set of 10 runs. it represents a randomly selected subset of the 131 benchmark problems we have run our experiment with. in the right column, we report in addition the difference between the mean runtime using one seed and the mean runtime using multiple seeds. a positive number means that the mean time using multiple seeds has been faster than the mean time using a single solver. but in addition to the difference in the mean times, also the span between the fastest and the slowest solver run is important. in case, we really observe an improvement based on a seeded heuristic, we expect this difference to grow too. the only case, where we observe the expected behavior is the problem with id 13. z3 further aims on stability in the heuristics. this means that the goal of the z3 developers is met, if seeding the solver has no substantial effect on the heuristic. that we have found at least one problem where seeding has an obvious influence on the solving performance motivates us to explore further this branch of experiments running the same setup with benchmarks from other theory categories in the future. we do not know yet, why z3 reacts in the way it does for different seeds on this single example. based on the initial evaluation presented in the table, seeding a single solver multiple times and use it in a portfolio does not seem to be a good strategy for reducing computation time. nevertheless, if we just look at the percental gain in solving time reported in figure 4 across all 131 experiments taken from the qf lia benchmark set, the result looks more promising. we can clearly identify examples, where computing the mean across 10 runs with different seeds beats the mean runtime of examples running with a single seed by more than 10 %. hence, extending the platform and experiment setup towards more solver and a broader theory support will be worth the effort for identifying slower and faster seeds for a problem. these seeds might be useful for evaluating the internal solver heuristics in the future. in the paper [hjm19], we observed more effects of seeding on the runtime of floating-point theory solver. therefore, we will conduct more experiments in the future to investigate the reasons in detail. independent of potential improvements for a single solver, the overall results are a promising indication that a solving service using a mixture of different constraint solvers and the same solver with different seeds might lead to substantial performance improvements for tools being slowed down by constraint solvers at the moment. 6 conclusion in this paper, we reported on general ideas for improving the integration of smt solvers into programs and deduced requirements for a solving service. we proposed to collect more data about smt solver profiling than the current smt-challenge does. we presented a platform for running large scale empirical experiments allowing to collect this additional data. in a preliminary evaluation of the platform, we collected some data for empirical testing z3 behavior after seeding. the data indicates, it might be worth running the same solver with different seeds to decrease solving times. those preliminary results motivate us to continue running experiments for profiling performance characteristics of the heuristics used within smt sovlers. we hope to be able to use those profiles for fine tuning smt solver configurations. in the future, we aim for a full solving service exploiting the profiling data and optimization potential for speeding up smt based analysis. isola ds+is 2018 16 / 19 eceasst bibliography [apt79] b. aspvall, m. f. plass, r. e. tarjan. a linear-time algorithm for testing the truth of certain quantified boolean formulas. information processing letters 8(3):121–123, 1979. [bcd+11] c. barrett, c. l. conway, m. deters, l. hadarean, d. jovanović, t. king, a. reynolds, c. tinelli. cvc4. in international conference on computer aided verification. pp. 171–177. 2011. [bey19] d. beyer. automatic verification of c and java programs: sv-comp 2019. in international conference on tools and algorithms for the construction and analysis of systems. pp. 133–155. 2019. [bgz17] m. berzish, v. ganesh, y. zheng. z3str3: a string solver with theory-aware heuristics. in 2017 formal methods in computer aided design (fmcad). pp. 55–59. 2017. [bhm09] a. biere, m. heule, h. van maaren. handbook of satisfiability. volume 185. ios press, 2009. [blw19] d. beyer, s. löwe, p. wendler. reliable benchmarking: requirements and solutions. international journal on software tools for technology transfer 21(1):1–29, 2019. [cde+08] c. cadar, d. dunbar, d. r. engler et al. klee: unassisted and automatic generation of high-coverage tests for complex systems programs. in osdi. volume 8, pp. 209–224. 2008. [cgss13] a. cimatti, a. griggio, b. schaafsma, r. sebastiani. the mathsat5 smt solver. in piterman and smolka (eds.), proceedings of tacas. lncs 7795. springer, 2013. [chn12] j. christ, j. hoenicke, a. nutz. smtinterpol: an interpolating smt solver. in international spin workshop on model checking of software. pp. 248–254. 2012. [ckl04] e. clarke, d. kroening, f. lerda. a tool for checking ansi-c programs. in international conference on tools and algorithms for the construction and analysis of systems. pp. 168–176. 2004. [cok11] d. r. cok. jsmtlib: tutorial, validation and adapter tools for smt-libv2. in nasa formal methods symposium. pp. 480–486. 2011. [coo18] b. cook. formal reasoning about the security of amazon web services. in international conference on computer aided verification. pp. 38–47. 2018. [da14] p. dinges, g. agha. solving complex path conditions through heuristic search on induced polytopes. in proceedings of the 22nd acm sigsoft international symposium on foundations of software engineering. pp. 425–436. 2014. 17 / 19 volume 078 (2019) thoughts about using constraint solvers in action [db08] l. de moura, n. bjørner. z3: an efficient smt solver. in international conference on tools and algorithms for the construction and analysis of systems. pp. 337– 340. 2008. [dll62] m. davis, g. logemann, d. loveland. a machine program for theorem-proving. commun. acm 5(7):394–397, july 1962. doi:10.1145/368273.368557 [dp60] m. davis, h. putnam. a computing procedure for quantification theory. j. acm 7(3):201–215, july 1960. doi:10.1145/321033.321034 [dut14] b. dutertre. yices 2.2. in international conference on computer aided verification. pp. 737–744. 2014. [gkc13] s. gao, s. kong, e. m. clarke. dreal: an smt solver for nonlinear theories over the reals. in international conference on automated deduction. pp. 208–214. 2013. [gks05] p. godefroid, n. klarlund, k. sen. dart: directed automated random testing. in acm sigplan notices. volume 40(6), pp. 213–223. 2005. [gm15] m. gario, a. micheli. pysmt: a solver-agnostic library for fast prototyping of smt-based algorithms. in smt workshop 2015. 2015. [god20] p. godefroid. fuzzing: hack, art, and science. communications of the acm 63(2):70–76, 2020. [grr12] d. giannakopoulou, z. rakamarić, v. raman. symbolic learning of component interfaces. in proceedings of the 19th international conference on static analysis. sas’12, pp. 248–264. springer-verlag, berlin, heidelberg, 2012. [hgmn18] f. howar, d. giannakopoulou, m. mues, j. a. navas. generating component interfaces by integrating static and symbolic analysis, learning, and runtime monitoring. in international symposium on leveraging applications of formal methods. pp. 120–136. 2018. [hjm19] f. howar, f. jabbour, m. mues. jconstraints: a library for working with logic expressions in java. in models, mindsets, meta: the what, the how, and the why not? pp. 310–325. springer, 2019. [kfb16] e. g. karpenkov, k. friedberger, d. beyer. javasmt: a unified interface for smt solvers in java. in working conference on verified software: theories, tools, and experiments. pp. 139–148. 2016. [ks16] d. kroening, o. strichman. decision procedures. springer, 2016. [ldg+16] k. luckow, m. dimjašević, d. giannakopoulou, f. howar, m. isberner, t. kahsai, z. rakamarić, v. raman. jdart: a dynamic symbolic analysis framework. in international conference on tools and algorithms for the construction and analysis of systems. pp. 442–459. 2016. isola ds+is 2018 18 / 19 http://dx.doi.org/10.1145/368273.368557 http://dx.doi.org/10.1145/321033.321034 eceasst [leh90] f. lehner. cost comparison for the development and maintenance of application systems in 3rd and 4th generation languages. information & management 18(3):131–141, 1990. [pc13] h. palikareva, c. cadar. multi-solver support in symbolic execution. in international conference on computer aided verification. pp. 53–68. 2013. [pr10] c. s. păsăreanu, n. rungta. symbolic pathfinder: symbolic execution of java bytecode. in proceedings of the ieee/acm international conference on automated software engineering. pp. 179–180. 2010. [rhf+17] h. riener, f. haedicke, s. frehse, m. soeken, d. große, r. drechsler, g. fey. metasmt: focus on your application and not on solver integration. international journal on software tools for technology transfer 19(5):605–621, 2017. [rlo16] k. richly, m. lorenz, s. oergel. s4j-integrating sql into java at compiler-level. in international conference on information and software technologies. pp. 300– 315. 2016. [rt03] s. ranise, c. tinelli. the smt-lib format: an initial proposal. in proceedings of the 1st international workshop on pragmatics of decision procedures in automated reasoning (pdpar’03), miami, florida. pp. 94–111. 2003. [rüm08] p. rümmer. a constraint sequent calculus for first-order logic with linear integer arithmetic. in international conference on logic for programming artificial intelligence and reasoning. pp. 274–289. 2008. [sz09] d. spiewak, t. zhao. scalaql: language-integrated database queries for scala. in international conference on software language engineering. pp. 154–163. 2009. [vgd12] w. visser, j. geldenhuys, m. b. dwyer. green: reducing, reusing and recycling constraints in program analysis. in proceedings of the acm sigsoft 20th international symposium on the foundations of software engineering. p. 58. 2012. [vp95] m. venkatrao, m. pizzo. sql/cli—a new binding style for sql. acm sigmod record 24(4):72–77, 1995. [wb19] p. wendler, d. beyer. sosy-lab/benchexec: release 2.0. july 2019. doi:10.5281/zenodo.3341460 https://doi.org/10.5281/zenodo.3341460 19 / 19 volume 078 (2019) http://dx.doi.org/10.5281/zenodo.3341460 https://doi.org/10.5281/zenodo.3341460 introduction state of the art interprocess communication language bindings access patterns requirements for a constraint solving service a platform for running experiments in the cloud experiments and evaluation conclusion about metrics for clone detection electronic communications of the easst volume 63 (2014) proceedings of the eighth international workshop on software clones (iwsc 2014) about metrics for clone detection — position paper — thierry lavoie, ettore merlo 5 pages guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst about metrics for clone detection thierry lavoie1, ettore merlo1 1 thierry-m.lavoie@polymtl.ca, ettore.merlo@polymtl.ca departement de genie informatique et logiciel ecole polytechnique de montreal montreal, canada abstract: this paper presents some results about some metrics and their possible impact on clone detectors. it also discusses some advantages of why we should use metrics instead of arbitrary measures. keywords: clones, metrics 1 introduction clone detectors rely on the concept of similarity and distance measures to identify cloned fragments. the choice of a specific distance function in a clone detector is arbitrary up to some extent. however, with a deeper knowledge of similarity measures, we can condition this choice to have some properties that can help improve scalability and quality of tools. this paper presents some interesting results, insights and questions about similarity and distance measures, including a somehow counter-intuitive result on the cosine distance. for a comprehensive survey of many distances and metrics, the reader is invited to read [cc10]. this paper covers the following topics: • a link between the jaccard measure on sets and the manhattan distance in euclidean space • limitations of the cosine distance on normalized vectors and approaches to overcome them • unanswered questions on some similarity detection techniques as a convention in this paper, we set rn+ = [0, ∞) n. 2 an equivalence of the jaccard metric and the manhattan distance sometimes it is useful to link two known metrics to get a desired behavior or a better understanding of one of the two. in our case, we link the jaccard metric on sets with the manhattan distance on the space rn+. our equivalence holds for arbitrary sets, but different representations in the space r⋉+ may be possible, which leads to different applications. we first prove the result, then we will explain how the result may be used. 1 / 5 volume 63 (2014) mailto:thierry-m.lavoie@polymtl.ca mailto:ettore.merlo@polymtl.ca about metrics for clone detection recall the jaccard measure on two finite sets u,v is defined as: j(u,v ) = |u ⋂ v | |u ⋃ v | and from this we define the jaccard metric as: δ (u,v ) = 1 − |u ⋂ v | |u ⋃ v | = |u ⋃ v |−|u ⋂ v | |u ⋃ v | which is known to satisfy all the metric axioms (see section 3 for a brief recall). the manhattan distance, noted l1, on two vectors 1 u, v from rn+ is: l1(u, v) = n ∑ i=1 |ui − vi| now, lets associate a unique integer 1 ≤ i ≤ |u ⋃ v | to every element µ in u and v . now, choose n = |u ⋃ v | and take u, v ∈ rn+ such as ui = 1 ↔ µi ∈ u otherwise ui = 0, and vi = 1 ↔ µi ∈ v otherwise vi = 0. from this, we draw: |u ⋃ v | = n ∑ i=1 max(ui, vi) |u ⋂ v | = n ∑ i=1 min(ui, vi) the min and max terms in the preceding equations are only equal if ui = vi, otherwise one of the two is ui and the other is vi and because |ui − vi| = |vi − ui| we must have: |u ⋃ v |−|u ⋂ v | = | n ∑ i=1 max(ui, vi) − n ∑ i=1 min(ui, vi)| = n ∑ i=1 |ui − vi| replacing the last two equalities in the original jaccard metric leads to: δ (u,v ) = |u ⋃ v |−|u ⋂ v | |u ⋃ v | = ∑ni=1 |ui − vi| ∑ni=1 max(ui, vi) with the numerator of the last term being the manhattan distance between u and v. this proves the existence of an equivalence between a normalization of the manhattan distance between certain vectors and the jaccard similarity between sets. it is easy to generalize this result to allow any positive integer for ui and vi instead of 0, 1. we simply need to project multiple elements of the sets u and v onto a single coordinate i. the proof is then almost identical to the one presented here. why is this result interesting ? in practice, clone detectors use a lot of similarity and distance measures on sets. most of them are not metrics (like the dice coefficient, the tanimoto distance, 1 actually, to define the manhattan distance , we do not need the full power of a vector space but only requires the n-tuples in rn+. however, it is now a custom to name everything in r n + a vector and we shall follow the custom. proc. iwsc 2014 2 / 5 eceasst etc.) and thus have a behavior less understood. moreover, metrics lead to known opportunity of optimizations in search spaces that arbitrary distances do not offer [cpz97]. thus, even if the choice is ultimately arbitrary, there exist some arguments that favor metrics over arbitrary distances and knowing the link between some of them can help making a better choice. in this case, a simple distance between vectors gives us a useful interpretation as a distance between sets. 3 properties of some angular distances we start by proving a result on the sine function. theorem 1 let x be a subset of rn+|x ∈ x → ||x|| = 1 . let θx,y be the angle between any two x and y ∈ x . finally, let δ : rn+ × r n + −→ r be defined as δ (x, y) = sin θx,y. then, δ is a metric on x . proof. we need to prove that δ satisfies the four properties of a metric. (non-negativity) δ (x, y) ≥ 0. this is true, since the all x, y have positive coordinates and the angle between such vectors must be in [0, π2 ]. (nullity) δ (x, y) = 0 ↔ x = y. this is true, since the sine of an angle restricted to [0, π2 ] is 0 if and only if that angle is 0, and the angle between x and y is 0 if and only if x = y. (symmetry) δ (x, y) = δ (y, x). this is true since the angle between x and y equals the angle between y and x. (triangle inequality) δ (x, y) + δ (y, z) ≥ δ (x, z). the property holds, but it is tricky to prove. first, observe that if the angle between x and y or the angle between y and z is greater than the angle between x and z, then the property must hold since the sine is monotonically increasing in [0, π2 ]. it remains to prove that it holds if the bigger angle is between x and z. now, clearly the sum of the angles θx,y and θy,z is greater or equal than θx,z. because sine is monotonically increasing in the considered interval, we now have: sin(θx,y) + sin(θy,z) ≥ sin(θx,y + θy,z) ≥ sin(θx,z) we develop the first two members of this inequality: sin(θx,y) + sin(θy,z) ≥ sin(θx,y + θy,z) = sin(θx,y) cos(θy,z) + sin(θy,z) cos(θx,y) subtracting the right member to the left leaves: sin(θx,y) − sin(θx,y) cos(θy,z) + sin(θy,z) − sin(θy,z) cos(θx,y) ≥ 0 because the cosine of these angles lies in [0, 1], we have sin(θx,y) − sin(θx,y) cos(θy,z) ≥ 0 sin(θy,z) − sin(θy,z) cos(θx,y) ≥ 0 3 / 5 volume 63 (2014) about metrics for clone detection and we conclude that the sum of the two must be greater than or equal to 0. the inequality between the first two members of equation 1 holds, and because of our definition of the second member, the inequality between the last two members already held. thus, we conclude that: sin(θx,y) + sin(θy,z) ≥ sin(θx,z) and the triangle inequality is satisfied. all four properties hold and we have secured the theorem. why is this result interesting ? first, even if the cosine distance is a very popular similarity measure on vectors, it is not a metric. to preserve the non-linearity of the cosine function, this results actually states that you need its dual function, the sine, to get a metric, under certain restriction. the sine is not as straightforward to compute as the cosine on vectors, but it has the advantage of being a metric on the first quadrant of rn. it is also worth questioning whether or not the non-linearity of the sine and cosine is a desirable property. the angle distance between two vectors is a metric (this fact is used in the above proof) and is linear on the arc distance between the vectors on a unit circle. it would be interesting to verify whether or not the cosine is actually better than the sine and the angular distance considering our arguments. in general, it would be safe to compare a measure with closely related one to assess which is better even if it means a small additional computational cost. 4 further questions and research: implicit distances, why should we recover them ? the previous sections dealt with special cases of distances that can be easily converted to a metric in order to use all the properties and knowledge we can draw from the vast literature on the subject. all these observations are interesting to ponder in the context of clone detectors explicitly based on a similarity or a distance measure. however, many tools only use implicit distances that are not properly defined as a mapping between a pair or a cluster of objects onto the real line r. what should be the course of action for these tools ? as hard as it can be, it should be possible in practice to recover the distance function. the mapping might be hard to express, or too many parameters may interact together to produce a long and complex formula, but these are only additional reasons to support the need to formalize implicit or hidden distance functions. complete understanding of clone detection technology is intertwined with our ability to encapsulate their behavior in mathematical formula: if this task proves to be tedious, what can we say of understanding their behavior or how can we even completely compare them ? the following questions are a starting point to help investigate the mathematical foundation of clone detection tools: • what distance function does the clone detector uses ? • how many parameters does the distance depends upon ? are some redundant ? are some useless ? proc. iwsc 2014 4 / 5 eceasst • if no mathematical formula seems possible to exist to encapsulate the distance used, why is it so ? • what key features does the tool use ? are there other tools using those features ? do those tools have a well-formulated distance ? • is there an already existing distance that approximates the tool’s implicit function ? how good is this approximation ? nevertheless, unanswered questions do not hinder performances and tools built around implicit distances can produce good results. to shed a deeper light on why they do have good results might however help the general understanding of clone detectors’ behavior. acknowledgement the authors wish to thank theotime menguy for his quick review of the proof in section 3. they would also like to thank mathieu merineau for providing the excellent reference [cc10]. bibliography [cc10] s. seok choi, s. hyuk cha. a survey of binary similarity and distance measures. journal of systemics, cybernetics and informatics, pp. 43–48, 2010. [cpz97] p. ciaccia, m. patella, p. zezula. m-tree: an efficient access method for similarity search in metric spaces. in proc. of 23rd international conference on very large data bases. pp. 426–435. morgan kaufmann publishers, 1997. 5 / 5 volume 63 (2014) introduction an equivalence of the jaccard metric and the manhattan distance properties of some angular distances further questions and research: implicit distances, why should we recover them ? federated user clustering for non-iid federated learning electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) federated user clustering for non-iid federated learning lucas pacheco, denis rosário, eduardo cerqueira, and torsten braun 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst federated user clustering for non-iid federated learning lucas pacheco1, denis rosário2, eduardo cerqueira2, and torsten braun1 1 university of bern, institute of computer science, communications and distributed systems group, 2 federal university of pará, institute of technology abstract: federated learning (fl) is one of the leading learning paradigms for enabling a more significant presence of intelligent applications in networking considering highly distributed environments while preserving user privacy. however, fl has the significant shortcoming of requiring user data to be independent identically distributed (iid) to make reliable predictions for a given group of users. we present a neural network-based federated clustering mechanism capable of clustering the local models trained by users of the network with no access to their raw data. we also present an alternative to the fedavg aggregation algorithm used in traditional fl, which significantly increases the aggregated models’ reliability in mean square error by creating several training models over iid users. keywords: federated learning, clustering, deep learning 1 introduction with the breakthrough of artificial intelligence (ai), we are witnessing a significant increase in ai-based applications, even in networking systems [xll+20]. the use of machine learning techniques for network management and optimization is a continuing trend that takes advantage of modern advances of both networking systems and ai techniques [kpt+20]. such trends, combined with advances in wireless communication technologies and the presence of computing capabilities at the edge of the network, have made it possible to perform distributed learning over connected users to forecast user mobility, bandwidth usage, channel conditions, and many more critical network conditions.while the majority of the events that impact network functioning are user-generated, such as user requests and mobility, collecting user data in order to train machine learning models at the network level raises privacy and scalability concerns, as training massive amounts of user data in a centralized manner may pose a limitation for the learning process [xll+20]. the distributed nature of computing power in modern networks (i.e., in edge servers, end devices, and remote datacenters) enables the rise of federated learning (fl) as a more reliable paradigm for learning. fl is a promising solution to providing reliable learning among many users’ data while preserving users’ privacy, as the users in fl are clients performing the training process. fl is a distributed machine learning paradigm based on each participating user in the network performing the training process over their data on a predefined architecture distributed by an aggregation entity. in this context, the training process is followed by an aggregation step, in which each user sends its trained weights, which are averaged at a central server, thus yielding a global neural network (nn) model. nn models aggregated in fl converge equivalently to ones trained in a centralized manner while maintaining user privacy and scaling more efficiently due to the distributed nature of the processing [whl+20]. 1 / 4 volume 080 (2021) federated user clustering for non-iid federated learning however, such aggregated models cannot be reliably used by network operators due to limitations on data distributions’ homogeneity across users. fl has limited capabilities to converge in the presence of such non-iid (independent identically distributed) data. data from different users can vary greatly and be based on many different random distributions, which may have different representations in the trained weights nns. thus, in the aggregation phase of fl, it is necessary to group users with similar statistical features such that different learned featured do not cancel each other when averaged. user clustering can help to make the distribution of the aggregated models uniform. however, clustering requires knowledge of the user’s raw data, which is not available in a federated environment [zll+18]. in this paper, we present nsim, a federated clustering technique for nn aggregation in federated environments capable of grouping together iid users with no knowledge of the underlying data. 2 related work zhao et al. [zll+18] show how the accuracy of fl models can decrease when trained with noniid data and how to create subsets of the training data with more similar models can mitigate this problem. however, this requires the aggregator to know data characteristics from the users that are not typically available in an fl environment. zhang et al. [zsgs09] also tackle the problem of training non-iid data in fl from the point of view of independence measures based on predefined kernels, which have been widely used in machine learning to assess the independencies between datasets and samples. several of these methods are available and can be used to establish a similarity measure between trained nn models. however, they cannot necessarily adapt to arbitrary architectures and data representations. kornblith et al. [knlh19] investigate the methods used to assess the similarity of trained nns based on the datasets used for training. the authors compare and investigate the efficiency of centered kernel alignment (cka) and cannonical correlation analisys (cca) methods for weight comparisons in nns, and conclude that cca is more appropriate as a nn similarity measure and that the layers closer to the output carry unique information about the user data that can be used for similarity comparisons. 3 neural-based federated user similarity & clustering 3.1 user similarity given that two users n and m possess data {dn,dm} with similar features, they converge to similar locally trained models. thus, we can compare the final nn generated by each user and assess how similar their training data is. several similarity measures have been introduced in the literature, such as the longest common subsequence (lcss). however, most similarity search techniques require the presence of raw user data. for instance, the lcss metric consists of finding the longest common sequence between two trajectories in terms of the data points constituting such trajectories within a certain radius. we propose a neural-based federated user similarity estimator for fl environments (nsim), which can take as input a given nn architecture and finds how each layer and its weights can learn features from the training datasets, and also estimates the similarity between the training datasets given the trained nn models. we denote the architectures given to users as au, and the user training data as du. to compute such an estimator, we take as input the format of the training user datasets for inputs and outputs (e.g., in the case of mobility data, we can have a sequence of past geographical coordinates as inputs and a pair of geographical coordinates as output). netsys 2021 2 / 4 eceasst the system then generates several synthetic data conforming to the given schema and trains nn models with architecture au using the given data sequences. the system builds one model for each synthetic user-created, each model denoted here as msynth. we compare the generated user data sequences pairwise with the lcss algorithm to obtain a ground truth similarity to train the similarity estimator. nsim consists of a nn which takes as inputs the weights from other thrained nns. the nsim model has trained to input the last layer of the msynth models trained. note that we input two models at a time, as it is a pairwise comparison. the output of nsim is the lcss value obtained for the pair of models input, and after a round of training over ground-truth lcss values, nsim can learn how similarity representations are encoded in a given architecture au. we obtain the architecture for the nsim similarity estimation through a grid-search step executed at the beginning of the process. we test the proposed similarity estimator’s efficiency in an lstm-based nn for trajectory prediction. mobility data is based on the real-world mobility dataset of monaco [ch18]. the user mobility prediction architecture consists of four lstm cells, three hidden layers with 20 neurons, each with a dropout rate of 0.2, and an output layer with two neurons. all dense layers use a leaky relu activation and random weights initializations. nsim has been trained with synthetic mobility data generated with a random walk model for 100 users and the respective lcss scores computed for such users. as shown in figures 2 and 3, experimental results find that even traditional kernel alignment techniques, such as cca and cka, which output a distance measure between two weights matrixes, cannot correlate the outputs of the last hidden layer of the user models with the actual lcss values obtained for given pairs of users, as seen by the low pearson correlation scores achieved. on the other hand, the nsim model achieves a pearson correlation of 0.96 for the predicted lcss similarity and the correct values based on the weights of the last hidden layer of the model. furthermore, the score is achieved with significantly less computing cost than directly comparing user datasets with the lcss algorithm. 0.0 0.2 0.4 0.6 0.8 1.0 predicted lcss 0.0 0.2 0.4 0.6 0.8 1.0 re al l cs s va lu e pearson correlation 0.96 trend data points figure 1: nsim 0.00 0.05 0.10 0.15 0.20 0.25 0.30 distance 0.0 0.2 0.4 0.6 0.8 1.0 l c s s pearson correlation 0.027 trend data points figure 2: cca 0.00 0.05 0.10 0.15 0.20 0.25 0.30 distance 0.0 0.2 0.4 0.6 0.8 1.0 l c s s pearson correlation 0.238 trend data points figure 3: cka nsim clustered fedavg0 200 400 600 800 1000 1200 1400 1600 m se (m et er s) figure 4: accuracy of nsim-clustered fl and fedavg 3.2 user clustering given an nsim estimator trained for the architecture of a group of n participant users, each participant user performs a local training in the traditional fl paradigm. however, we perform similarity comparisons among all participating users and obtain a similarity measure for all users. we assume using an existing clustering algorithm based on the computed similarities to form c clusters of users. since we do not know the number of clusters present beforehand, we chose the density-based spatial clustering of applications with noise (dbscan) algorithm, which labels each user in the network as belonging to one cluster. 3 / 4 volume 080 (2021) federated user clustering for non-iid federated learning after user clusters have been formed, the aggregator entity can perform the fedavg operation on subsets of users defined by the clusters found by dbscan. therefore, the final amount of nn models corresponds to the number of clusters formed. figure 4 compares the error distribution on a validation set of the monaco mobility trace in which each user trains a local model and models are aggregated based on nsim clustering results or based on traditional fedavg. 4 conclusions fl provides efficient learning models for connected users so that no raw user data must be sent, which can be intercepted or eavesdropped by malicious parties in the network. however, this approach falls into training a single model for possibly non-iid users, which compromises the final accuracy and applicability of the trained model for ia-based applications. we present a similarity estimator mechanism for arbitrary user data and architectures, which can detect similarity in user datasets to a high degree of confidence based on users’ locally trained models. we also present an alternative to the traditional fedavg algorithm, in which we first perform a federated clustering of users and aggregate models based on the clusters found. experimental results show the similarity estimator’s efficiency for federated clutering aggregation, significantly improving the aggregated models’ predictions. bibliography [ch18] l. codeca, j. härri. monaco sumo traffic (most) scenario: a 3d mobility scenario for cooperative its. in sumo 2018, sumo user conference, simulating autonomous and intermodal transport systems, may 14-16, 2018, berlin, germany. berlin, germany, 05 2018. [knlh19] s. kornblith, m. norouzi, h. lee, g. hinton. similarity of neural network representations revisited. 36th international conference on machine learning, icml 2019 2019-june:6156–6175, 2019. [kpt+20] l. u. khan, s. r. pandey, n. h. tran, w. saad, z. han, m. n. nguyen, c. s. hong. federated learning for edge networks: resource optimization and incentive mechanism. ieee communications magazine 58(10):88–93, 2020. [whl+20] x. wang, y. han, v. c. leung, d. niyato, x. yan, x. chen. convergence of edge computing and deep learning: a comprehensive survey. ieee communications surveys and tutorials 22(2):869–904, 2020. [xll+20] d. xu, t. li, y. li, x. su, s. tarkoma, t. jiang, j. crowcroft, p. hui. edge intelligence: architectures, challenges, and applications. arxiv e-prints, pp. arxiv–2003, 2020. [zll+18] y. zhao, m. li, l. lai, n. suda, d. civin, v. chandra. federated learning with non-iid data. arxiv preprint arxiv:1806.00582, 2018. [zsgs09] x. zhang, l. song, a. gretton, a. j. smola. kernel measures of independence for non-iid data. in advances in neural information processing systems. pp. 1937–1944. 2009. netsys 2021 4 / 4 introduction related work neural-based federated user similarity & clustering user similarity user clustering conclusions campus08_boehm_camera_ready_final electronic communications of the easst volume 11 (2008) guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) share whatever you like sebastian böhm, johan koolwaaij and marko luther 12 pages eceasst 2 / 13 volume 11 (2008) share whatever you like sebastian böhm1, johan koolwaaij2 and marko luther1 1docomo euro-labs, munich, germany 2telematica instituut, enschede, the netherlands abstract: to leverage proactive context-aware services for mobile handsets, an architecture for the management, aggregation and distribution of information is required. this work presents a framework that has been developed to realize an extensible infrastructure in which personal information can be shared with others while on the go. access control mechanisms restrict the distribution of data based on social relationships and the validity of context conditions. keywords: context management, distributed access control, mobile application, ontology reasoning, context aggregation 1 introduction the future of mobile services is meant to be context-aware. context-aware services have long been seen as the natural advancement of location-based services, which were introduced more than five years ago. at last, today’s mobile handsets are offering various features that place this progress within reach, being equipped with various sensors, sufficiently powerful computing resources and the possibility to manage all kinds of personal information. and yet, their most important asset may be their omnipresence. this circumstance quickens the interest in intelligent services, designed to adapt to the user’s current situation. here, a framework for context aggregation is needed to manage the distribution and combination of information from various sources. our context management framework (cmf) builds on initial work [1] accomplished within the ist-project mobilife1 [2]. today, the cmf represents an open network of distributed and highly interconnected components to gather, aggregate and further exchange context information proactively. it enables the transformation of quantitative context information into qualitative statements about a user’s given situation. share whatever you like reflects some of the cmf’s main requirements on context distribution and access control. sharing personal memories and experiences clearly involves a number of privacy issues that need to be carefully considered from the start. the cmf architecture tackles these constraints without compromising its open and extensible nature. iyouit2 is the reference implementation of the cmf and comes as a mobile client that allows users to share personal information while on the go and a web-based portal to stay in touch with the online community. iyouit’s mobile client runs on most nokia series 60 smartphones and succeeds its predecessor contextwatcher [3][4] by adding authentication and privacy protection mechanisms as well as lifting its system architecture to a flexible, broker-centric one. the general aim is to make it easy for an end-user 1 http://www.ist-mobilife.org 2 http://www.iyouit.eu share whatever you like proc. campus 2008 3 / 13 to automatically record, store, and use context information, e.g. for personalization purposes, as input parameter to information services or simply to share this information with others. the process of enriching gathered context data to qualitative information is exemplified in section ii. in section iii an overview of the underlying system architecture is provided and insights into several core components as well as the applied delegation-based authentication mechanism is given. access control mechanisms are discussed in section iv, focusing on the actual directive management, context filtering and the subsequent verification of the latter. iyouit is described in detail in section v and related work in the field of context-aware systems, access control mechanisms and their applications is described in section vi. concluding remarks can be found in section vii. 2 context aggregation the main objective of the cmf is to allow for developing context-aware (mobile) applications that gather context data from various sources. raw context data, e.g. sensor outputs like the currently visible cell id on a mobile phone do often not provide meaningful (human understandable) information right away. instead, the aggregation of such context data and the subsequent combination with other pieces of information is regarded as an essential process to enable the development of intelligent applications that make sense of the user’s surrounding. figure 1 illustrates a simplified context aggregation to resolve a user’s current location and to reason about his location traces recorded over time. the cell id obtained from the mobile phone is transmitted to the locationprovider, a networked cmf component, to be resolved into an actual address record. it stores all recorded location traces and applies clustering techniques to identify frequently visited places of the user, e.g. his home or office [5], while remaining independent of any concrete mobile network infrastructure. this simplified example already implies the need for a context management infrastructure to also facilitate authentication, access control, easy extensibility as well as the combination of and the reasoning about different context information. 3 system architecture the cmf has been designed as an open, distributed and extensible framework to allow other parties to join the network and to enrich existing services for mobile handsets. only a minimal set of components is regarded as being owned by the network operator and may have access to the users’ credentials. access control and authentication techniques allow for integrating address, place cell id cell id address location provider external data source mobile sensor inference engine location traces figure 1: simplified context aggregation eceasst 4 / 13 volume 11 (2008) external partners or data sources without the threat of malicious data abuse. to do so, several essential requirements of the cmf were identified. instant revocation: the user as well as the network operator needs to have the ability to revoke access rights to context information at any time from certain components or distinct users. secure authorization and delegation: the user’s credentials (his unique identifier and personal password) should not be propagated among uncontrolled components to prevent untrusted components from collecting personal information on behalf of the user without his explicit permission. abstraction and enrichment of context: historic context information is stored within the respective component to allow for clustering and further data mining to abstract from lower level data, as exemplified in figure 1. proactive requests: the user himself must not explicitly trigger the actual context retrieval. in addition, for answering a given context request, the number of components concerned cannot be predetermined. computations on gathered context information to gain more qualitative information may require several components to autonomously request context from other components. in general, the cmf architecture can be conceptually categorized in several groups of components that serve a distinct purpose. contextconsumers mainly retrieve context information from various sources, the contextbroker and the contextharvester provide means of easy context lookup and context gathering, whereas contextproviders (cp) aggregate contextual data to provide meaningful information for specific services. three management components are major constituent parts of the cmf to allocate basic functionalities that all components within the framework rely on. all other components that can be subsumed in a group of 3rd party applications act as external data source and may also provide additional context visualization techniques. a. management components the identitymanager maintains the list of all registered entities (components and users), represented by uniquely named principles (appid and entityid). each context retrieval request within the cmf is authorized by this central component to bar single components from collecting and distributing highly sensitive data without explicit permission. therefore we introduced an authentication scheme based on ticket verification, similar to the kerberos approach [6], to allow 3rd party integration without the need to disclose the users’ credentials to each component within the framework. this authentication scheme is described in more detail in figure 3, by means of a common context retrieval request. the relationmanager enables the representation and exchange of qualitative social data. explicit facts about social relationships between users (e.g. family members, friends or colleagues) are combined with the world knowledge encoded in an ontological model in order to apply logic based reasoning. these reasoning mechanisms ensure the consistency of the social data and allow for knowledge discovery techniques to complement the social network. as a result, groups of users can be formed dynamically, based on qualitative relationships managed by the relationmanager, further discussed in [7]. explicit or implicit social connections are made available for other cps to further enrich their context information. apart from a subject and object entity as well as the actual relation predicate, each relationship definition has additional attributes. the status of a relationship, for instance, describes if a share whatever you like proc. campus 2008 5 / 13 relation has been requested (the initial value for all relations suggested by the user), approved (which means the object entity has already confirmed) or inferred, indicating that this relation has been deduced. the complete set of relationships, including deduced relations, is stored within a database to reduce query response times. since the majority of requests are concerned with retrieving information rather than modifying data, the underlying knowledge base does not need to be involved. however, in case the set of approved relations has changed, either by adding a new relation or removing an existing one, all active relationships are transmitted to the inference engine to trigger the reasoning process. to model these qualitative social relationships we developed an ontology, specifically designed as a social knowledge base for the cmf. in contrast to most social networking services that only differentiate between buddy – or friendships, the social ontology with its 50 defined relationships allows for very detailed descriptions of all kinds of social connections between the users of the framework. for providing personalized (mobile) services and applications, access control is always an issue that needs to be considered. the privacymanager (pm) enables the definition of relation and context-based access control directives to ease the process of managing ones personal directives. our approach ensures both, the users’ demand for privacy control and ease of use. therefore directives do not have to be bound to concrete implementations or services in the framework but to abstract, general concepts of context. the user thus specifies a certain level of detail to be revealed per context category, without knowing which components are concerned with the actual execution and filtering of data. social relationships allow for defining simple group access directives to restrict the distribution of context information. for instance, the user may specify that colleagues should only know the current city, whereas family members are granted access to the detailed set of location information, e.g. up to the street level. further details on the proposed access control management can be found in section iv. b. context-broker, -harvester, -consumer and -provider the contextbroker and the contextharvester provide access to a repository of system elements on the level of cps (in the case of the contextbroker) or on the level of context elements (in case of the contextharvester). the contextbroker implements a registration and lookup service to enable the discovery of various cps, based on the schema provided within the cp advertisement. the contextharvester can be seen as a specialized cp that collects context information across a range of other cps. in supporting both, collections of context types and collections of entities, it can be used to obtain heterogeneous context information for various users or it may be used to obtain all personal information of a specific entity no matter where the information is stored or managed physically. the majority of components within the framework surely belong to the category of cps. at the time of writing more than ten cps have been developed to provide services like local weather forecasts, picture sharing facilities or sound recording, to name only a few. in principle, a cp first gathers a certain type of information (e.g. the user’s cell-id) from a sensor (for instance the mobile handset) or another cp to further process and enrich this information. this procedure of context aggregation is taking place within each cp and is essentially required for the subsequent (logical) combination of different context elements that, as a whole, describe the situation of an entity [8]. eceasst 6 / 13 volume 11 (2008) c. basic datatypes context aggregation and the later context combination across components is one important utilization of the cmf. therefore numerous datatypes have been defined to leverage the exchange and assessment of context data within the framework. context element: a context element is an elementary piece of context information that encapsulates the information obtained from a cp. a context element must at least include the cp’s unique id, an identifier of the owner of the respective piece of information as well as a number of parameters that hold the actual data values. figure 2 shows a context element as rendered in xml. parameter: a parameter object contains a name, a timestamp, a corresponding value and an extensible list of attributes further categorizing the parameter value (including the ontology reference and accuracy). context query: a context query request allows for retrieving distinct context elements that comply with certain constraints on the contents of context elements. the context query object contains a filter specified by simple and complex conditions. simple conditions specify a comparison operator on values and attributes to select distinct parameters of interest, while complex conditions combine simple conditions recursively via logical operators. applying a projection or summary operation further restricts the result set. contextprovider advertisement: the advertisement includes a cp’s unique id and a base url to this service. furthermore, it provides the data scheme in the form of a parameter hierarchy and a list of all featuring entities as well as options. each parameter has been assigned a certain privacy level that indicates the sensitivity of the data and additional attributes such as the type or the unit of measurement. since each cp may also provide software packages for the mobile client to make use of its public interface, the clientsoftware object indicates the availability of such software components. as soon as the mobile client has been identified and all constraints on downloading the package are fulfilled (e.g. the client’s platform or version number), the client software can be delivered or updated. figure 3: context retrieval sequence diagram figure 2: context element share whatever you like proc. campus 2008 7 / 13 d. authentication and component interaction to realize an open, distributed infrastructure and to allow 3rd parties to provide their own applications on top of the cmf’s core infrastructure, a corresponding authentication mechanism needs to be in place. two assumptions need to be considered that characterize some basic principles of how context is distributed and exchanged in a standard request-reply pattern, protected by common encryption techniques like https. all components that are not regarded as being controlled by the network operator (and thus entirely comply to the specification) are trusted in the sense that mandatory authentication and privacy mechanisms need to be implemented. components that violate these constraints, be it on purpose or due to implementation flaws, are regarded as un-trusted. furthermore, all communication paths need to be secure so that no request or reply messages could be intercepted and decrypted. in principle, two different types of authentication methods are applied within the cmf: user and application authentication. the request ticket that needs to be issued together with the actual context query is of the following form: . it includes an entityid, the requesting appid as well as two tokens. the entityid and the entitytoken are used for the user authentication to ensure that applications retrieving context on behalf of the user are only granted access to those pieces of information the user is allowed to see. this means that for each entity and each application (aka cp), a corresponding entitytoken exists. this token is issued by the identitymanager (in case valid application credentials are given) and needs to be verified on each request as illustrated in figure 3. besides, the application authentication controls inter-component communication and requires a valid appid and apptoken. so, for each combination of contextconsumer and cp, a corresponding apptoken exists, again issued and verified by the im. all tokens are valid as long as either the user or the network operator revokes former access rights to any context retrieval on behalf of the user or disallows any component interaction. instant revocation is given, since all context requests are explicitly authorized by the identitymanager. once the provided request ticket has been verified, the cp retrieves all appropriate access control directives from the privacymanager. 4 access control the data flow in-between services or components allows for much richer services that build up on the knowledge made available. however, the network operator needs to be able to control the data flow in order to prevent others from unchecked data storage and general data abuse. in addition, the users themselves should be able to mark certain applications as trusted or disallow access to personal information for unknown or unwished service providers as well as other users. the proposed access control mechanisms are based on the social relationships managed by the relationmanager and the subsequent logical combination with other context data. in principle, three types of access control directives can be identified. directives can either be defined for concrete users, groups of users (based on explicit or implicit social relationships) or certain context conditions. so besides role-based access control directives that build upon a social network of users and the underlying ontological model, context-dependent directives allow for directives that are bound to concrete context conditions (abstract descriptions of the user’s surrounding). these conditions can be assigned to certain access control directives in order to restrict the validity of directives to concrete situations. contextdependent access control directives are triggered in case certain conditions with respect to the eceasst 8 / 13 volume 11 (2008) current context of a user are fulfilled. for instance, access to a business schedule may only be granted to colleagues that are nearby, but only during office hours. in this case, context information is actually the prime condition for deciding about access to, again, context information. to further refine the type of information that is made available, we differentiate between various granularities of context data with respect to their up-to-dateness. this means that a user could forbid access to the last known context state (e.g. the current location), but grants access to older or “out-dated” and therefore less critical information. the other way round, granting access to only the latest information, and therefore concealing the context history, prevents others from exploring issued data to analyze certain user behaviors. the privacy decision point is realized in distributed components – the privacymanager (pm) and all concerned cps. the actual filtering of context information according to the directives (specified by the user) has to be accomplished by each cp. policy compliance according to the given access control directives is warranted because each component that processes a user’s context information must be granted access by the user and authorized by the identitymanager. hence, the filtering of context information (see figure 3) is accomplished by the respective component that knows the structure and the semantics of the data. even though it would be in principle possible to establish a policy enforcement mechanism for access control in a thoroughly trusted environment, this was never our original intention. instead, the cmf has been designed as a distributed, extensible framework that does provide certain means to verify the applied context filtering. a. directive management access control directives are defined by concrete context specifications, a subject entity, an object entity or a certain relation predicate and the actual privacy level. the privacy level defines to what extend a certain type of context will be made available. a seven-staged granularity allows for fine-grained access control directives, ranging from no access to full access. the context specification contains a unique identifier, a cp’s base url, the parameter path, an entity’s id and an ontology reference (optional). however, the user does not have to provide a specific cp id or parameter path as part of the request. general user-defined directives are automatically translated into concrete context specifications. to give an example, adding an access control directive to prevent disclosing one’s current whereabouts, the pm first retrieves all appropriate cp advertisements from the contextbroker that provide at least some spatial context information and computes all concrete parameter paths for the appropriate cps. the usage of context dependencies is restricted to non-dependent context data, which means that the validation of this condition must be directly answered by the corresponding cp. to do so, the pm gathers all context info exclusively via a specified interface (getcontext()) of the appropriate cp since all context dependencies are modeled as context queries. therefore, each cp has to implement this interface so that no additional requests to other cps are needed to compute the last known state. in principle, this would result in a loop, since each cp would, in turn, have to consult the pm again. to break the resulting loop, a cp is able to detect a request that has been issued by the pm by its unique appid and the corresponding apptoken. as highlighted in figure 3, the normal authentication scheme requires two distinct requests to the identitymanager. the first check authenticates the original request from a generic contextconsumer to the cp, the second time the request from the pm to the cp is verified. in order to prevent the second authentication request, the identitymanager automatically verifies share whatever you like proc. campus 2008 9 / 13 if the cp may also have access to the pm and eventually computes a secret token. this token is then passed to the pm to be verified in order to retrieve the appropriate access control directives. since a service infrastructure like the cmf undergoes frequent updates in terms of new services being introduced or existing services being modified, all existing access control directives must be adjusted dynamically. once the contextbroker has registered an update, the pm automatically verifies established directives and applies the corresponding modifications. in case a specific access control directive has been requested that has not been explicitly defined by the user, a more general directive will be returned that covers the given constraints. similarly, requesting a directive for a specific entity might result in a directive that has been defined for a certain relationship, if the requested entity is the role-filler of that relationship. also, the hierarchy of social relationships is considered, as represented within the social ontology. so, if no specific directive is given for the wife relationship, more general directives defined for all family members are returned. b. user interaction the privacymanager is regarded as a controlled component, which means that only the user may modify access control directives. applications (e.g. other cps) may only retrieve directives that are concerned with their verified appid. to support the user in managing personal directives, a management interface has been developed and integrated into iyouit’s internet portal. web-based user interface: this interface integrates most access control and social networking features into one compact and easy to use matrix-like interface, shown in figure 4. its principle design has been inspired by almer’s work on access control visualization techniques [9] during the mobilife project. in general, two main views on access control directives can be distinguished. the buddyview lists all approved contacts on the horizontal axis and the main context types on the vertical axis. similarly, the relationview allows for defining group directives and therefore shows all supported relationships in the horizontal menu. in case a certain context type on the left hand side is highlighted, more specific directives exist that can be revealed by clicking on the respective parameter, as shown in figure 4 for the context type weather and its sub-parameter weather/location. each main category of context information has its own symbol, whose actual size indicates the respective context level assigned and therefore the amount of data revealed. so, defining access control directives for the most common context types is a matter of clicking through the respective icon sizes with hardly any effort. the controls on the right hand side provide filter figure 4: privacymanager web-interface eceasst 10 / 13 volume 11 (2008) for the current view, e.g. to show only directives for a certain access level, to add distinct subcategories of interest and to save or discard changes. since access control directives can potentially overlap, the pm has to compute the most specific directive. for instance, having defined directives for all friends but also for one of your friends in particular would result in at least two overlapping directives (in this example the directive that has been assigned to this particular person would hold). within the pm web interface, all directives that have been derived from other facts are shown in grayscale, whereas colored icons represent explicit definitions for concrete buddies. context mirror: with the so-called context mirror, the user is able to verify the compliance with the given access control directives by inspecting (his own) personal data through the eye’s of someone else. this way, directives can be revised and access to context can be withdrawn from applications that do not apply the filtering of data according to the directives. the context mirror is reflected in a boolean value in the functional interface of a cp and an observer’s entity id, found in all context elements. whenever the context mirror is enabled, the corresponding access control directives are retrieved from the pm and subsequently applied to the user’s own context within the respective cp. the application of the context mirror within iyouit is described in the next section. 5 mobile client application iyouit is a research prototype that represents our prime implementation of the cmf to apply context-aware technologies and methodologies in practice (including ontology-based reasoning and access control techniques). in short, iyouit facilitates the following usage scenarios: real time context sharing for the exchange of qualitative information to keep track of friends and family members in an unobtrusive manner. contextual tagging of user generated media to describe the current context, to add automatically generated titles as well as descriptions to pictures, maps and sounds. storage and simplified retrieval of context data. different views and context visualization techniques assist the user in finding useful information. iyouit is a tab-based application, in which each tab either displays a certain type of context information or accumulates various pieces of information in a context overview. the me-tab is iyouit’s standard entry point and highlights all recently collected information. clicking on one of the entries, a more detailed view is provided within the respective tab. the buddy tab is the central place for all real-time context figure 5: iyouit's buddy tab share whatever you like proc. campus 2008 11 / 13 information of approved buddies, including their current whereabouts, latest activities, shared photos and so on. different views on context, various sorting orders and context-dependent adhoc groups help finding interesting or newly gathered information, as illustrated in the upper half of figure 5. so besides grouping buddies with similar context (e.g. the same city or weather condition), the friends of friends group lists all iyouit users that have been deduced as a rather close contact without being explicitly added by the user. this is a direct result of the applied social reasoning by the relationmanager, to support the user in completing his personal network of social contacts. also part of the buddy tab, the context mirror functionality has been implemented to verify the context filtering that has been applied in the respective cps. once the context mirror has been enabled (see lower screenshots in figure 5), different views on your own context are displayed to reflect the way buddies see one’s personal data. in general, iyouit is capable of sensing, aggregating, combining and distributing various types of context. amongst others, this includes the user’s location, photos, local weather data, nearby buddies or devices as well as personal experiences. here, especially the way spatial data is processed can be taken as an example for the context aggregation that is taking place in the cmf. the location estimation can either be based on raw gps coordinates, currently visible cell ids or triangulation. the final step in the process of spatial aggregation is the application of a location-clustering algorithm to automatically detect frequently visited places [5]. those places can be labeled as “home” or “office” and linked to a concept within the spatial ontology. those places of interest have a qualitative meaning that allows others to easily classify this information. 6 related work several computing infrastructures for managing context have been proposed to support the rapid development of context-aware applications. all approaches generally provide a suitable abstraction mechanism to separate the process of context gathering and distribution from the core application logic. the context toolkit (ct) [10] is a prominent server-based platform, which uses xml structures to represent contextual data and to hide sensor details. a query and notification interface provides a standardized access to the data. context providers and interpreters store historic context information and serve as a context abstraction layer. context harvesters combine context information as well as repositories of services and components that are currently available within the system. even though, in principle similar to our approach, the ct system only provides basic access control mechanisms for privacy protection. foreseen as one potential solution, context-dependent privacy rules are mentioned, without giving any more details. likewise, ct’s use of standard public-private key technology for authentication does not allow for instantly revoking access rights in combination with delegation. in contrast to the closed ct system, our target is to create an open context infrastructure as also proposed in [11] to securely integrate external components using delegated credentials. therefore, usage control [12] generally seems to conflict with our main aim to allow for further processing of context within trusted, external components. the aggregation and the logical combination of context is one of the main principles of the cmf to realize context-aware services. another related approach in terms of shifting resource intensive context manipulations from the mobile device to a service-oriented infrastructure is realized in the context distribution framework (cdf) [13]. similar to our parameter structure, a hierarchical representation of data elements is proposed to enable quality of context annotations. furthermore, the cdf facilitates ontology-based context representation and reasoning techniques to derive higher eceasst 12 / 13 volume 11 (2008) level data. however, this approach implicates severe scalability issues for expressive ontology languages if applied as the main representation format [14]. our attempt in making use of ontology technologies is considerably different. distinct higher-level data elements are annotated with ontology references, making them available for further ontology reasoning. this way, the overall scalability is not affected, while at the same time valuable reasoning results can be achieved. besides, the cdf does not address suitable mechanisms for privacy protection in its current version. the question whether or not the cdf can be regarded as a closed or extensible service infrastructure remains unclear, since no details on authentication are given. a context-driven evaluation of policies that describe the behavior of agents in a pervasive computing environment is described in [15]. similar to our context-dependent access control directives, context changes trigger the actual evaluation process of agent permissions. all policies are formalized in the web ontology language (owl) and consist of a context condition and a corresponding action. these policies do not allow for the specification of a subject, since policies are meant to be associated with context rather than subjects. even though this assumption is legitimate in a pervasive environment where interacting components are unknown, our application area is different in this respect. being able to identify components and users within the cmf is an axiomatic prerequisite. therefore, we consider context in addition to subjects as attributes within our access control directives. in [16], the authors focus on the exchange of spatial information and emphasize the distributed nature of access control when multiple context sources with different granularities are present. access to location information is based on a concept called service trust. trusted components may receive information only in case an authorized request has been forwarded and are thus required to sign all data returned to realize non-repudiation. however, it remains unclear how misbehaving services can actually be identified by an entity in practice. most context-aware mobile applications available today have a strong focus on uploading photos, including zonetag [17], merkitys-meaning3 or shozu [18]. categorizing photos and other media content on the mobile handset is typically achieved by letting the user tag those items. tag sharing or tag suggestions (as offered by zonetag) simplify this otherwise rather time-consuming and solely manual process. however, in terms of automatically adding tags, titles and descriptions to any user-generated content (including photos) based on the current context (not just the user’s location), iyouit is much more flexible and capable. jaiku4, which has recently been acquired by google, is a mobile application with a similar approach compared to iyouit in sharing presence information with others. through its connection to twitter, a popular location-based micro blogging site, jaiku became one of the most prominent mobile clients. with iyouit and the underlying cmf, our approach is to allow users to share personal information without the need to enter data manually, but to automatically sense, gather and process this information. 7 conclusion initial usage statistics recorded during the 9 months development time and experiences that we made with the former contextwatcher community point out the interconnected and lively nature of our system. up to now, our 35 test users sent more than 250.000 location update 3 http://meaning.3xi.org 4 http://www.jaiku.com share whatever you like proc. campus 2008 13 / 13 requests (on average one every 15 mins), took 2300 photos, visited over 2000 cities in 23 countries and updated their local weather forecast about 3500 times. based on those initial trials, the implementation of the cmf specification proved feasible in terms of scalability and practicability for managing context in a distributed architecture. more profound performance evaluations will follow as soon as a critical mass of users has been reached with the iyouit community. focusing on access control and authentication to meet our users’ obligations in terms of privacy protection without compromising the cmf’s overall extensibility through the integration of 3rd party applications was deemed necessary but clearly entailed the complexity of the overall system architecture. however, shifting expensive tasks and complex computations to server components in the network made it possible to realize a lightweight mobile client on the one hand, and rich services centered on qualitative context information on the other hand. the aggregation and meaningful combination of context from various sources through lower-level clustering or higher-level reasoning techniques can only be accomplished with high-performance computing resources as provided by server components in the network layer. iyouit and the cmf architecture will be constantly enhanced with new components and services to underline iyouit’s living test-bed character and to further verify research results with real context information. after all, sharing personal information in general and qualitative context information in particular is fun and helps you keeping track of your buddies. share whatever you like, but only what you would like to share – with iyouit. 8 references [1] p. floréen, m. przybilski, p. nurmi, j. koolwaaij, a. tarlano, m. wagner, m. luther, f. bataille, m. boussard, b. mrohs, and s. lau, “towards a context management framework for mobilife,” in mobile and wireless comm. summit, 2005. [2] m. klemettinen, ed., enabling technologies for mobile services. chichester, england: wiley & sons ltd., sept. 2007. [3] s. böhm, m. luther, j. koolwaaij, and m. wagner, “contextwatcher – connecting to places, people, and the world,” in demo proc. of the 5th int. semantic web conference (iswc’06), november 2006. [4] j. koolwaaij, a. tarlano, m. luther, p. nurmi, b. mrohs, a. battestini, and r. vaidya, “contextwatcher – sharing context information in everyday life,” in proc. of the int. conf. on web technologies, applications, and services (wtas’06), 2006. [5] p. nurmi and j. koolwaaij, “identifying meaningful locations,” in proc. of the 6th int. conf. on pervasive computing (pervasive’08), pp. 1–8, ieee computer society, july 2006. [6] b. neuman and t. ts’o, “an authentication service for computer networks,” ieee comm., vol. 32, pp. 33–38, sept. 1994. [7] s. böhm, m. luther, and m. wagner, “smarter groups – reasoning on qualitative information from your desktop,” in proc. of the workshop on the semantic desktop, pp. 276 –280, 2005. [8] m. luther, y. fukazawa, m. wagner, and s. kurakake, “situational reasoning for task-oriented mobile service recommendation,” the knowledge engineering review, vol. 23, no. 1, 2008. [9] d. almer, “mobilife – the privacy display widget,” master’s thesis, stockholm, sweden, 2006. [10] a. k. dey and g. d. abowd, “a conceptual framework and a toolkit for supporting the rapid prototyping of context-aware applications,” hci journal, vol. 16, no. 2-4, pp. 97–166, 2001. [11] m. wojciechowski and j. xiong, “towards an open context infrastructure,” in proc. of the workshop on context awareness for proactive systems (caps’06), pp. 125–136, 2006. [12] r. sandhu and j. park, “usage control: a vision for next generation access control,” in proc. of the workshop on math. methods, models, and architectures for computer network security, pp. 17–31, 2003. [13] p. pawar, a. t. van halteren, and k. sheikh, “enabling context-aware computing for the nomadic mobile user: a service oriented and quality driven approach,” in ieee wireless comm. & networking conf. (wcnc’07), pp. 2529–2534, 2007. [14] t. weithöner, t. liebig, m. luther, s. böhm, f. w. von henke, and o. noppens, “real-world reasoning with owl,” in proc. of the 4th european semantic web conference (eswc’07), pp. 296–310, 2007. [15] r. montanari, a. toninelli, and j. m. bradshaw, “context-based security management for multi-agent systems,” in proc. of the 2nd ieee sym. on multi-agent security and survivability (mas&s’05), pp. 75–84, 2005. [16] u. hengartner and p. steenkiste, “implementing access control to people location information,” in proc. of 9th acm sym. on access control models and technologies (sacmat’04), pp. 11–20, 2004. [17] s. ahern, m. davis, d. eckles, s. king, m. naaman, and m. spasojevic, “zonetag: designing context-aware mobile media capture to increase participation,” in proc. of the pervasive image capture and sharing workshop (pics’06), 2006. [18] m. ames and m. naaman, “why we tag: motivations for annotation in mobile and online media,” in proc. conf. on human factors in computing systems (chi’07), pp. 971–980, 2007 hacking planned obsolescense in robotics, towards security-oriented robot teardown electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) hacking planned obsolescense in robotics, towards security-oriented robot teardown vı́ctor mayoral-vilches1,3, alfonso glera-picón1, unai ayúcar-carbajo1, stefan rass3, martin pinzger3, federico maggi2, endika gil-uriarte1 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst hacking planned obsolescense in robotics, towards security-oriented robot teardown vı́ctor mayoral-vilches1,3, alfonso glera-picón1, unai ayúcar-carbajo1, stefan rass3, martin pinzger3, federico maggi2, endika gil-uriarte1 1 [victor|alfonso|unai|endika]@aliasrobotics.com alias robotics, venta de la estrella 3, pab. 130 vitoria, 01005 spain 2 federico maggi@trendmicro.com trend micro inc., italy 3 [stefan.rass |martin.pinzger |v1mayoralv ]@aau.at universität klagenfurt, universitätsstraße 65-67, 9020 klagenfurt, austria abstract: as robots get damaged or security compromised, their components will increasingly require updates and replacements. contrary to the expectations, most manufacturers employ planned obsolescence practices and discourage repairs to evade competition. we introduce and advocate for robot teardown as an approach to study robot hardware architectures and fuel security research. we show how our approach helps uncovering security vulnerabilities, and provide evidence of planned obsolescence practices. keywords: teardown, robotics, security, repair, safety 1 introduction robotics is the art of system integration [mhk+17]. a robot is a network of networks, with sensors, actuators, and dedicated computing resources, according to its application. a robotic manipulator, for instance, include the arm’s mechanics (which generally include actuators and sensors), the human-machine interface (hmi), the controller (the main compute substrate for reasoning), and any additional safety mechanism. most industrial robots of this kind range from tenths to hundreds of thousands of euros. accordingly, it is only reasonable to consider the need for repairing robots. unfortunately, most robot manufacturers follow planned obsolescence practices nowadays and organize approved distributors and integrators into private networks, providing repair parts only to certified companies. among the most recent examples we observe the case of teradyne, which robots are advertised as collaborative (i.e., designed to safely work in close contact with humans), while research unveils that they lack of safety measures [mjc+19] and a concerning cybersecurity [azg+18] landscape. given these premises, we promote robot teardown as a systematic process to repair robots, improve robot hardware and research its security. in the long run, we argue that the more researchers and practitioners will get used to systematically teardown robots, the more this practice 1 / 4 volume 080 (2021) mailto:@aliasrobotics.com mailto:federico_maggi@trendmicro.com mailto:@aau.at the eceasst document class will impact the quality assurance of hardware in robotics, putting pressure on manufacturers to produce robots with better hardware security measures, thereby safer. 2 robot teardown a robot teardown is the process of analyzing a robot’s hardware architecture to model its functional behavior and physical components, through systematic disassembling. we identify three key purposes in robotics: a) dissection and analysis to evaluate the status of a product, b) competitive benchmarking against similar products, and c) gain engineering experience and knowledge. we focus on a) and c) through three case studies on the robots from universal robots (ur) and mobile industrial robots (mir), which have tenths of thousands of units sold and operating in close contact with humans (as collaborative robots), and have been already shown lacking security measures [mjd+19] from these two manufacturers. due to space limitations, we leave the complete walk-through of these case studies to an extended version of this paper, focusing now only on the outcome. figure 1: teardown of three industrial collaborative robots: ur3 cb series (first three), ur3e e-series (fourth to sixth) and mir100 (last three). 2.1 case study 1: teardown of an industrial collaborative robot the safety logic of the ur3 cb-series collaborative robot runs on a nxp lpc4437jet256 microcontroller, which datasheet1 highlights that the microcontroller is not suitable for safetycritical systems according to the silicon vendor. this leads us to question the quality and reliability of the safety implementation within these robots. therefore, through teardown, we were able 1 https://www.nxp.com/docs/en/data-sheet/lpc435x 3x 2x 1x.pdf netsys 2021 2 / 4 https://www.nxp.com/docs/en/data-sheet/lpc435x_3x_2x_1x.pdf eceasst to identify and pinpoint hardware components that don’t meet the quality standards for the safety situations the robot may have to face, leading to an overall improved scenario for end-users. 2.2 case study 2: teardown of a next-gen industrial collaborative robot following the cb-series, we proceeded and disassembled one of the latest releases from universal robots, the ur3e, an e-series. while the external look remains similar, the internals have changed significantly: 1) the e-series controller integrates a single power supply unit (psu), while the cb-series had two, 2) while the cb-series presented two boards containing compute, power, and safety logic, the e-series presents only one single printed circuit board (pcb) featuring a xilinx artix-7 series field-programmable gate arrays (fpgas), widely used for implementing safety logic in a variety of automotive and control domains, 3) the base filter pcb—which helps interface power and rs485 communications from the controller (e-series) to the robot arm mechanics—is similar to the one present in the cb-series, 4) the arm’s mechanics connector changed in the e-series but the power and communications lines remain coherent (through the base filter board) and 5) the electronics within the arm’s mechanics do not present relevant changes from an interoperability perspective, which should facilitate re-purposing and reuse. 2.3 case study 3: teardown of a mobile industrial robot the mir-100 is a popular mobile robot manufactured by the danish mobile industrial robots (mir), also owned by the us teradyne. the first impression is that various components of the robot could be improved from a safety perspective. also, the teardown helped understand how this robot presents multiple (internal and external) networks and how each one of the sensors and actuators are connected across these networks, forming the data layer graph. the robot itself is powered by robot operating system (ros) [qgc+09] and gaining further understanding of the ros computational graph requires understanding also its underlying hardware mapping (from which one derives the data layer graph). the teardown exercise supplies exactly this and allows to produce a data layer graph represented in the form of a hardware schematic which can then be used in combination with the computational graph to gain further understanding of the robot. 3 teardown to research security and identify planned obsolescence teardown supports kerckhoffs’ principle in revealing all the details and weaknesses of a security system, excluding volatile secrets such as keys or credentials stored in memory. overall, the history of proprietary systems violating kerckhoffs’ principle by pursuing security-by-obscurity is rich of failure cases (with the military domain as the sole exception). as part of this research, our group identified more than 100 security flaws across the three robots described above over a period of two years. most of the flaws were cataloged as vulnerabilities and 17 obtained new cve ids, all of which was publicly disclosed at the robot vulnerability database (rvd) [mjd+19]. in most cases, these robots present few or no security measures, allowing adversaries to easily exploit the flaws of internal components (e.g. as demonstrated in rvd#2558, rvd#2561 or rvd#2562), so compromising the robot behavior or taking full control of it. we argue that robot teardown is key for security research, as proper knowledge of the hardware helps determine potential attack vectors and which additional elements can help mitigate security 3 / 4 volume 080 (2021) https://github.com/aliasrobotics/rvd/issues/2558 https://github.com/aliasrobotics/rvd/issues/2561 https://github.com/aliasrobotics/rvd/issues/2562 the eceasst document class issues when the manufacturer does not react. as an example, our group introduced an additional commercial off-the-shelf hardware firewall within mir’s internal network between the main controller and the sick’s safety plc mitigating rvd#2558, without having to modify any parts of the firmware. throughout this work, we found planned obsolescence particularly evident in the robots from universal robots. from an electrical point of view, these two robots present a similar layout for interfacing with the robot arm. the manufacturer however introduced subtle changes meant to make this particular intent harder. our work showed how through teardown, we learned how to bypass these limitations using commercial off-the-shelf components with a total bom price under 30 euros. 4 conclusions we are concerned about the growing trend in robotics to create private networks of certified groups, a common practice shown by manufacturers like mir or ur, both owned by teradyne. we presented robot teardowns as an approach to study robot hardware architectures, obtain repairing capabilities, uncover planned obsolescence, and research its security. we advocate for a ‘right to repair’ in robotics and encourage end-users to reflect their needs into their supply chains and into the original upstream robot manufacturers. bibliography [azg+18] l. alzola kirschgens, i. zamalloa ugarte, e. gil uriarte, a. muñiz rosas, v. mayoral-vilches. robot hazards: from safety to security. arxiv e-prints, june 2018. [mhk+17] v. mayoral-vilches, a. hernández, r. kojcev, i. muguruza, i. zamalloa, a. bilbao, l. usategi. the shift in the robotics paradigm—the hardware robot operating system (h-ros); an infrastructure to create interoperable robot components. in adaptive hardware and systems (ahs), 2017 nasa/esa conference on. pp. 229–236. 2017. [mjc+19] v. mayoral-vilches, l. u. s. juan, u. a. carbajo, r. campo, x. s. de cámara, o. urzelai, n. garcı́a, e. gil-uriarte. industrial robot ransomware: akerbeltz. arxiv preprint arxiv:1912.07714, 2019. [mjd+19] v. mayoral-vilches, l. u. s. juan, b. dieber, u. a. carbajo, e. gil-uriarte. introducing the robot vulnerability database (rvd). arxiv preprint arxiv:1912.11299, 2019. [qgc+09] m. quigley, b. gerkey, k. conley, j. faust, t. foote, j. leibs, e. berger, r. wheeler, a. ng. ros: an open-source robot operating system. in proc. of the ieee intl. conf. on robotics and automation (icra) workshop on open source robotics. kobe, japan, may 2009. netsys 2021 4 / 4 https://github.com/aliasrobotics/rvd/issues/2558 introduction robot teardown-0.5em case study 1: teardown of an industrial collaborative robot case study 2: teardown of a next-gen industrial collaborative robot case study 3: teardown of a mobile industrial robot teardown to research security and identify planned obsolescence conclusions electronic communications of the easst volume 080 (2021) guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrück, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 internal conference on networked systems 2021 (netsys 2021) discrete event simulation for the purpose of real-time performance evaluation of distributed hardware-in-the-loop simulators for autonomous driving vehicle validation christoph fundaa, reinhard germanb, kai-steffen hielscherb 5 pages eceasst 2 / 6 volume 080 (2021) internal discrete event simulation for the purpose of real-time performance evaluation of distributed hardware-in-the-loop simulators for autonomous driving vehicle validation christoph fundaa, reinhard germanb, kai-steffen hielscherb a zukunft mobility gmbh (a company of zf group), marie-curie-str. 5 /5a, 85055 ingolstadt, germany b university erlangen-nuremberg, department computer science, martensstr. 3, 91058 erlangen, germany abstract: hardware-in-the-loop test benches are distributed computer systems including software, hardware and networking devices, which require strict real-time guarantees. to guarantee strict real-time of the simulator the performance needs to be evaluated. to evaluate the timing performance a discrete event simulation model is built up. the input modeling is based on measurements from the real system in a prototype phase. the results of the simulation model are validated with measurements from a prototype of the real system. the workload is increased until the streaming source becomes unstable, by either exceeding a certain limit of bytes or exceeding the number of parallel software processes running on the cores of the central processing unit. to evaluate the performance beyond these limits, the discrete event simulation model needs to be enriched by a scheduler and a hardware model. to provide real-time guarantees an analytical model needs to be built up. keywords: distributed system, networks, hardware-in-the-loop simulation, hil, real-time performance evaluation, discrete event simulation, des, omnet++ 1 introduction autonomous driving functions are safety-critical and have to be tested thoroughly. the hardware-in-the-loop (hil)-based testing approach is an enabler for this and has been established in the automotive industry for years as an effective and efficient method of validating control units, interfaces, and functions. since the system under test works under hard real-time (rt) conditions, the hil test bench needs to be rt capable to enable the testing and be able to check the rt properties of the system under test. the focus here is on the usecase of the so-called open-loop reinjection [1], as streaming of measurement data to the device under test (dut) under strict rt constraints. the hil test system needs to be assessed regarding the rt capability of the whole streaming chain. although streaming tones down the rt requirements within the chain to soft rt and with the help of over-provisioning and prebuffering the design process can be eased, there are a lot of dimensioning issues for buffers and throughput left, for that purpose we have to analyze the system more deeply. 2 approach a hil is a distributed computer system, for which common methods from computer system performance evaluation can be applied to evaluate the rt performance. at first, a very simplified conceptual model has been developed to understand the system, set up requirements and be able to develop a model from it. short article title netsys 2021 3 / 6 internal the hil system under analysis consists of two distributed computer systems as depicted in figure 1 connected via network interface cards (nic) and an ethernet connection using the tcp-ip protocol. each computer has an application layer, a linux operating system (os) and a hardware layer (hw). additionally, the left pc has the robot operating system (ros) [2] as a middle layer between the application layer and the linux os with rt preempt patch [3]. the streaming application is running as a multi-threaded multi-processing ros application and it is instrumented at the user-code level in c++ to gain timing information when a process starts and when it is finished. the measurements from the system will be used for input modeling in the simulation model. figure 1: detailed conceptual model and software (sw) instrumentation. the streaming process starts at the far-left sw process, the ros replayer, that grabs the data from the ram disk and sends it, according to its timestamps, to the next node. the interprocess-communication is done via tcp/ip and the data is sent to a queue in the ros middle layer. this is done by every process until the data reaches the last node. then the data is sent over the tcp socket to the network stack of linux depicted in the kernel layer to the network interface card (nic). on the right pc, the process is similar, but starting from the nic to receive the tcp segments via interrupts over the kernel to the first application process in labview. within this first process, the segments are collected and reassembled or segmented to the original frame size, depending on the original frame size in relation to the maximum segment size (mss). when the original frame is restored, it will be sent to the next process until the last queue, before sending it out to the device under test (dut). this last queue has a very important function, which is the compensation of the delay and jitter introduced by the whole processing and queuing chain. to evaluate the performance of a computer system, according to [4] at least two of the following three methods are needed to validate each other: measurements, simulation and analytical modeling. if the system is physically available, measurements should be performed to understand the actual system behavior, and for practical purposes to recognize and correct malfunctions. in addition, a simulation or an analytical model should be generated to extrapolate the results to unavailable systems. the generated model should be validated with measurements. in the next step, a discrete-event simulation (des) model [7] must be built to gain a better understanding of the system. discrete event simulation is particularly suitable for evaluating the stochastic behavior of processes in computer and communication systems. [8] eceasst 4 / 6 volume 080 (2021) internal 3 discrete event simulation model the model is build up according to the conceptual model of figure 1 in omnet++ with standard servers, queues and delay elements and with the inet framework for the networking unit using the tcp/ip protocol implementation. for validation purposes, the model is fed with measurements, called trace-driven simulation [4]. then the simulation output is compared to the measurements. latency measurements are taken as service times of the servers in the model, and we compare these service times of the simulation output of the model and the measurements as depicted in figure 2. figure 2: example of process service times; from left to right: upper figures: scatter plot of simulation and measurement data, lower figures: boxplot of simulation and measurements, difference between simulation and measurements at each point over time. as can be seen from figure 2, the simulated and the measured data are highly comparable. from the boxplots, we can see that they are distributed equally. the last right plot shows the calculated differences between the simulation and measurement latency. this is in the range of 10-15 s for processing latency and 10-7 s in case of end-to-end latency. the conclusion is that the conceptual model of one data stream is representing the actual system in a very exact way. as the simulation results of the model are satisfying, a mapping of the stochastic process behavior with theoretical distribution functions can be started. this will bring independence of a specific trace and simulate the behavior over a longer period and with random state combinations. for distribution fitting from the measurement data, matlab is used to fit the data into different statistical distributions, which are supported by omnet++. in a further step, the distribution is truncated to the minimum and maximum measured values. then a goodness of fit analysis as described in [5] is performed. the distribution with the highest mean p-value is taken and feed into the model. as can be seen exemplarily in figure 3, the process latencies are lognormal distributed with a mean p-value of 37%, which met the requirement to be at least at 5%. short article title netsys 2021 5 / 6 internal figure 3: from left to right: histogram and distribution fit of ros process latencies, comparison between theoretical & empirical cumulative distribution function (cdf). the limits of the model can be seen in figure 4 compared to a nearly singular distributed stream on the right as a baseline. the influence of increasing the byte size of the workload can be seen in the left diagram. in the middle graph, we see the influence on the distribution when performing many streams in parallel, so that there are more processes than cpu cores available. figure 4: histogram plots of 40ms cycle-time measured stream; from left to right: 40mb single stream; 5mb stream with 16 other streams in parallel, 5mb single stream. 4 conclusions the simulation model is representing the real-world prototype in a good way, and it is valid until we reach the hw bottlenecks of the system with our workload. enrichment of the model with an os scheduler and a cpu model, a so-called sw&hw co-simulation as described in [10][10][12] will overcome these model limits including the coupling of network simulation as described in [13][14]. with this approach we can give at least soft rt guarantees within a given statistical confidence. the final goal is to make predictions about holding rt limits of our sw&hw system for multi-streaming purposes. the predictions will be based on a certain set of sensors with a payload and cycle times as sw parameters in combination with various hw parameters like cpu frequency and the number of cores as an optimization parameter. to give guarantees and a full proof of hard rt capability, an analytical model must be used. analytical models that are worthwhile to explore in more detail are the most used techniques under the hood of many performance engineering tools like layered queueing networks, process algebra, petri nets and scheduling theories of real-time systems like rate monotonic analysis.[15][16][17] eceasst 6 / 6 volume 080 (2021) internal 5 references [1] n. brayanov and a. stoynova, “review of hardware-in-the-loop -a hundred years progress in the pseudoreal testing”, 2019 [2] m. quigley et al., „ros: an open-source robot operating system“, 2009 [3] f. reghenzani, g. massari and w. fornaciari, „the real-time linux kernel: a survey on preempt_rt“,2019 [4] r. jain, “the art of computer systems performance analysis: techniques for experimental design, measurement, simulation, and modeling”, 1. edition. new york: wiley, 1991. [5] d. nurmi, j. brevik, and r. wolski: “modeling machine availability in enterprise and wide-area distributed computing environments”, 2005 [6] m. quigley, b. gerkey, k. conley, j. faust, t. foote, j. leibs, e. berger, r. wheeler, and a. ng, “ros: an open-source robot operating system,”, 2009 [7] j. banks, j. s. carson, b. l. nelson, d.m. nicol. “discrete-event system simulation”, 2000 [8] a. m. law, w. d. kelton. “simulation modeling & analysis”, 2000 [9] a. varga; r. hornig. “an overview of the omnet++ simulation environment”, 2008 [10] p. razaghi, a. gerstlauer, „host-compiled multicore rtos simulator for embedded real-time software development“, 2011 [11] p. razaghi, a. gerstlauer, „host-compiled multicore system simulation for early real-time performance evaluation“, 2014 [12] o. bringmann et al. „the next generation of virtual prototyping: ultra-fast yet accurate simulation of hw/sw systems“, 2015 [13] z. zhao, v. tsoutsouras, d. soudris, a. gerstlauer, „network/system co-simulation for design space exploration of iot applications“, 2017 [14] g. amarasinghe, m. d. de assunção, a. harwood, s. karunasekera, „ecsnet++ : a simulator for distributed stream processing on edge and cloud environments“, 2020 [15] u. herzog, “formal methods for performance evaluation”, 2001 [16] a. purhonen, “performance evaluation approaches for software architects“, 2005 [17] l. etxeberria “method for analysis-aided design decision making and quality attribute prediction”, 2010 towards scion-enabled ixps: the scion peering coordinator electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) towards scion-enabled ixps: the scion peering coordinator lars-christian schulz and david hausheer 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards scion-enabled ixps: the scion peering coordinator lars-christian schulz1 and david hausheer2 networks and distributed systems lab otto-von-guericke-university magdeburg, germany email: 1lschulz@ovgu.de, 2hausheer@ovgu.de abstract: internet exchange points (ixps) around the world bring thousands of isps together to form dense peering fabrics. since bilateral bgp peering sessions alone would result in large overhead, many ixps offer route servers enabling the exchange of routing information with the entire peering population over a single multilateral bgp session. route servers also perform rpki validation to combat the lack of authentication and security in bgp. scion is a novel inter-domain routing architecture addressing the security flaws of bgp by replacing it with a security and reliability centric clean-slate approach. we envision that operators of scion ases will be just as open to peering at internet exchanges as they are today with bgp. moreover, to fully utilize scion’s multipath capabilities scion as operators tend to deploy more different as numbers than in bgp, further increasing the potential number of unique peering links at an ix. since scion has no native multilateral peering support, we propose the scion peering coordinator, an ixp-hosted service automating scion peering link setup based on per as policies. as such, the scion peering coordinator provides an open peering platform similar to bgp route servers to scion. keywords: scion, ixp, peering, route server 1 introduction route servers at ixps solve two important problems. first, they improve bgp’s scalability by replacing densely meshed bilateral peering with hub-based multilateral peering. secondly, they filter out invalid prefix announcements and perform rpki validation to prevent network outages due to misconfigured border routers and malicious prefix hijacking. scion, which aims to replace bgp in a future internet, addresses the latter issue with its fully authenticated control plane, but does not provide a built-in solution to the scalability concerns of fully meshed peering. the notion of multilateral peering does not exist in scion. since scion’s control plane is designed to be very efficient, full mesh peering might not pose a scalability issue like it does in bgp, but multilateral peering at bgp route servers has another advantage. route servers offer instant connectivity to a large part of the ixp’s peering population to anyone joining [rsf+14]. scion lacks a mechanism to get connected quickly and easily at ixps. all peering links have to be manually negotiated and set up by human operators. the aim of our proposed peering coordinator is to provide an automatic as configuration service to scion ases joining a scion-enabled ixp. the peering coordinator accepts a set of policy rules, which are set by each connected as, and takes care of configuring the scion border routers to form rule conforming links. 1 / 4 volume 080 (2021) mailto:lschulz@ovgu.de mailto:hausheer@ovgu.de towards scion-enabled ixps: the scion peering coordinator the policies the peering coordinator supports are inspired by bgp prefix redistribution rules as made available by special bgp community attributes at some ixp route servers. with bgp communities, peers can limit the distribution of their prefixes to certain ases or geographical regions [dec, ams]. similarly, the peering coordinator can limit peering advertisements to certain ases or administrative domains. for ixps, scion with a peering coordinator offers two direct advantages over bgp. first, the need for rpki validation at the ixp is eliminated, because scion’s control plane is authenticated by default. second, scion is a native multipath protocol, whereas a bgp route server advertises only a single route per destination and peer. the ability to expose multiple paths through the ixp opens up unused internal link capacity, for example from backup links, increasing the bandwidth available to scion over bgp. 2 background and related work scion is an inter-domain network architecture aiming to improve the internet’s scalability, reliability and security [bcp+17]. it achieves isolation of administrative concerns on a large scale by grouping ases into isolation domains (isds), which fall under a common jurisdiction. an isd is administered by its core, a consortium of densely interconnected core ases. scion’s path discovery process based on flooding so called path-segment construction beacons (pcbs) through the network gives rise to three distinct inter-as link types. core links connect core ases of the same or different isds. peering links connect non-core ases of the same or different isds, but in contrast to core links do not carry beacons. finally, provider-customer links attach non-core ases to their non-core transit providers and ultimately the isd core. to enable peering irrespective of whether an as belongs to the core or not, the peering coordinator is able to negotiate all three types of links. core and peering links allow ases of the same type to peer, but are forbidden between ases of different types by the current scion specification. however, in the special case of peering between a core and non-core as within the same isd, a provider-customer link can substitute for a native peering link. operators of core ases connecting to a peering coordinator should keep in mind that peering in the core is transitive by default, and might want to implement a more restrictive peering policy than in non-core ases. originally, the peering coordinator was designed as an extension to the scionlab coordinator, which is a web service maintaining a central configuration repository for the scionlab research network [kgl+20]. we decided to fork the peering coordinator as a standalone application for the following reasons: (1) we expect that ixps want full control over their own coordinator instance. extending the scionlab coordinator would put control over the peering coordinator in the hands of the scionlab administrators. (2) the scionlab coordinator manages the configuration of all as-internal scion services. such deep access is unnecessary for the peering coordinator. (3) a separate peering coordinator should simplify deployment in private networks. 3 scion peering coordinator the peering coordinator is designed to alleviate the lack of multilateral peering in scion by automating the discovery of peers. upon joining an ixp, a connection to one or, for redundancy netsys 2021 2 / 4 eceasst reasons, multiple instances of the coordinator must be set up manually. after that, the coordinator will mediate the automatic creation of peering links between the connected ases. as operators can limit to which other ases links are formed by defining a set of filtering rules. more specifically, the peering coordinator manages two pieces of information about every connected as: (1) the set of ases the as in question offers peering to. (2) the ip address and udp port range reserved for peering links in the scion underlay of every border router connected to the ixp. the later piece of information is required for technical reasons since scion is currently implemented as an ip/udp overlay. for the actual link establishment, the peering coordinator’s only responsibility is to pick unused udp ports in the underlay at the two border routers forming the link’s endpoints, allowing for a fairly unsophisticated implementation. the set of ases to whom peering is offered is constructed from a set of peering rules installed at the coordinator by every as. in the common case of completely open peering like at a bgp route server, the only rule an as has to set at the start of its peering session is “peer with everyone”. peering rules in the coordinator both offer peering to other ases and accept offers from other ases, so an as with a default “peer with everyone” rule will have links to as many other ases participating at the peering coordinator as possible. in addition to open peering, the peering rules can express a limited set of selective peering policies. selective peering we define four kinds of accept/reject rules, with a scope of either any as (the default rule), all ases of an isd (often coincident with a geographical region), all ases owned by the same entity (company, etc.), or individual ases. more specific rules have precedence over less specific ones. we introduce rules based on the as owner, because scion as operators are likely to employ multiple logically distinct ases to better exploit the path control offered by scion. selecting potential peer ases grouped by the underlying administrative domain seems like an obvious use case for the coordinator’s filtering rules. however, scion itself does not provide owner information, so the mapping from as to owner must be maintained out-of-band. as policies b accept c } ⇒ c-b c accept b,�d d accept �c, e ⇒ d-e e reject g, h core as core link peering link provider-customer link a c f isd 1 b d e g h isd 2 owner policies f accept [f, g] } ⇒ f-g g accept [f, g] isd policies e accept isd 2 ⇒ d-e g accept isd 2 } ⇒ g-h h accept isd 2 figure 1: example topology. ases a to h all peer at an instance of the scion peering coordinator. the black links are fixed (e.g., private peering or non-ixp links). peering links negotiated by the peering coordinator and the corresponding as-, owner-, and isd-level rules are colored. as mentioned previously, open peering is achieved by setting the default rule to accept. assuming the default rules is set to reject instead, figure 1 illustrates a few example policies expressible in the coordinator. in the example, as e accepts peering with everyone in its own isd (isd 2), 3 / 4 volume 080 (2021) towards scion-enabled ixps: the scion peering coordinator but disallows peering with g and h, which are its customers. since as-level rules have higher priority than less specific isd-level policies, only the peering link to d (dashed) is created. as mentioned in section 2, due to limitations in scion’s current design, it is not possible to connect core and non-core ases from different isds like c and d, consequentially such pairs are ignored. implementation due to its legacy as an extension to the scionlab coordinator, the peering coordinator is a django web application [spc]. it provides a grpc api to the peering configuration client which is installed alongside all scion border routers connecting to the ixp. the purpose of the peering client is to perform the actual configuration changes needed to instruct the scion infrastructure services to establish or drop links. additionally, the coordinator serves a web interface for monitoring and management purposes. 4 preliminary conclusions and future work the scion peering coordinator brings the ease of public bgp peering at an ixp-hosted route server to scion’s clean-slate internet routing approach. it supports the basic use case of open peering as well as a set of selective peering rules modeled after the prefix distribution control offered by bgp communities. a remaining challenge with the peering coordinator is that it operates completely out-of-band. like the scionlab coordinator, the peering coordinator aims at getting scion interconnection started today, but is not integrated with the scion control plane. in future work, we will investigate the possibility of an in-band neighbor discovery protocol in scion which could supersede the peering coordinator. another topic of future interest are the questions posed to the economics of public peering by scion’s inherent path control and multipath capabilities. bibliography [ams] ams-ix route servers. https://www.ams-ix.net/ams/documentation/ams-ix-routeservers. [bcp+17] d. barrera, l. chuat, a. perrig, r. m. reischuk, p. szalachowski. the scion internet architecture. in communications of the acm. volume 60(6), pp. 56–65. 2017. [dec] de-cix: operational bgp communities. https://www.de-cix.net/en/resources/routeserver-guides/operational-bgp-communities. [kgl+20] j. kwon, j. a. garcı́a-pardo, m. legner, f. wirz, m. frei, d. hausheer, a. perrig. scionlab: a next-generation internet testbed. in ieee international conference on network protocols. 2020. [rsf+14] p. richter, g. smaragdakis, a. feldmann, n. chatzis, j. boettger, w. willinger. peering at peerings: on the role of ixp route servers. in proceedings of the internet measurement conference. pp. 31–44. acm, 2014. [spc] peering coordinator. https://github.com/netsys-lab/scion-peering-coordinator. netsys 2021 4 / 4 https://www.ams-ix.net/ams/documentation/ams-ix-route-servers https://www.ams-ix.net/ams/documentation/ams-ix-route-servers https://www.de-cix.net/en/resources/route-server-guides/operational-bgp-communities https://www.de-cix.net/en/resources/route-server-guides/operational-bgp-communities https://github.com/netsys-lab/scion-peering-coordinator introduction background and related work scion peering coordinator preliminary conclusions and future work deep reinforcement learning for smart queue management electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) deep reinforcement learning for smart queue management hassan fawaz, djamal zeghlache, pham tran anh quang, jérémie leguay and paolo medagliani 14 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst deep reinforcement learning for smart queue management hassan fawaz1, djamal zeghlache1, pham tran anh quang2, jérémie leguay2 and paolo medagliani2 1 hassan.fawaz, djamal.zeghlache@telecom-sudparis.eu télécom sudparis, institut polytechnique de paris, evry, france 2 phamt.quang, jeremie.leguay, paolo.medagliani@huawei.com huawei technologies ltd., paris research center, france abstract: with the goal of meeting the stringent throughput and delay requirements of classified network flows, we propose a deep q-learning network (dqn) for optimal weight selection in an active queue management system based on weighted fair queuing (wfq). our system schedules flows belonging to different priority classes (gold, silver, and bronze) into separate queues, and learns how and when to dequeue from each queue. the neural network implements deep reinforcement learning tools such as target networks and replay buffers to help learn the best weights depending on the network state. we show, via simulations, that our algorithm converges to an efficient model capable of adapting to the flow demands, producing thus lower delays with respect to traditional wfq. keywords: queue management, smart queuing, reinforcement learning, dqn 1 introduction traditional traffic management and network engineering techniques are struggling to keep up with the ever increasing demand for higher throughput values and lower delays. this necessitates novel approaches to queuing, load balancing, and any other aspect of network management that can sustain faster response times and maintain throughput demands. in the domain of queuing control, active queue management (aqm) has emerged as a smart networking tool to selectively transmit and receive packets. initial approaches to queuing and dequeuing packets, such as firstin-first-out (fifo), are passive and have been proven to be unstable [b+94]. aqm techniques use mechanisms such as priority queuing, packet marking, and packet dropping in order to fine tune the network to avoid congestion and minimize end-to-end delays. to this end, a plethora of state-of-the-art approaches exist, including controlled delay (codel) [nj12], random early detection (red) [fj93], and proportional integral controller enhanced (pie) [pnp+13] among many others. in the case of round-robin schedulers (e.g., wfq, drr) [bss12], the latency experienced by a flow depends on its arrival curve (burst size, rate, ...), the arrival curves of the flows it interferes with, and the service rates of queues it traverses. thanks to network calculus models, worst case estimations can be derived for the end-to-end latency of each flow. however, these models can be complex when deriving tight latency bounds and are facing a trade-off between complexity and tractability for the optimization of queuing parameters. 1 / 14 volume 080 (2021) mailto:hassan.fawaz, djamal.zeghlache@telecom-sudparis.eu mailto:phamt.quang, jeremie.leguay, paolo.medagliani@huawei.com deep reinforcement learning for smart queue management in our work, we aim to use reinforcement learning (rl), a subclass of machine learning, to further improve the efficiency of aqm algorithms. our goal is to improve decision-making when optimizing quality of service (qos). we design an algorithm, dqn-wfq, that leverages deep q-learning to improve decision-making in a smart queuing approach. we classify the majority of network flows into three classes: gold, silver, and bronze. each of these classes represents a set of throughput and delay requirements, which we aim to meet. the designed algorithm targets a weighted fair queuing (wfq)-based scheduler, to which we apply a deep q-learning network (dqn) to output the optimal weights in order to meet the sla requirements of each flow. at every set time interval, the dqn agent, placed on bottleneck links, receives an observation of the environment. the latter is made up of the throughput and delay values experienced by each flow class. following this observation, the agent takes a decision on either increasing, decreasing, or not adjusting the class weights. the objective it has is to maximize the reward that will be issued following its decision depending on the number of flow class requirements it met or violated. at the start of the training process, the agent’s choices are random. as the training proceeds, the agent learns how to best react to the environment and output the optimal weights at each step. finally, in order to improve the efficiency of the agent, we implement deep learning tools such as replay buffers and target networks. the rest of this paper is structured as follows. section 2 reviews the related works in the state-of-the-art. section 3 presents our deep learning approach to smart queuing. it introduces the wfq approach, the formulation of the problem at hand, and a detailed description of the implemented deep learning mechanism. section 4 shows our simulation results, and finally section 5 concludes this paper. 2 related works in what follows, we highlight three main areas where smart queuing and network management take advantage of machine learning to improve network performance: active queue management, traffic engineering and multi-path tcp (mptcp), and service management. in the context of aqm, authors in [ke19] propose an aqm mechanism to reduce queuing delay in fog and edge networks. it relies on deep rl to handle latency and trades-off queuing delay with throughput values. the proposed algorithm is compared to other aqm approaches, namely p-fifo, red, and codel. their proposal outperforms the other schedulers in terms of delay and jitter, while maintaining above-average throughput. the state in this work is related to the current queue length in packets, the dequeue rate, and the queuing delay. the action considered is to either drop or serve the packets. another interesting approach in the state-of-the-art is that of [ggc+18] which proposes, as scheduling schemes, a dynamic-weight-earliest-deadline first (dwedf) algorithm and a reinforcement learning approach, called dwedf-rl, to address the scheduling of heavy tailed and low tail flows while accounting for bursty traffic. they provide delay-bound-based fairness to flows having similar tail distributions in an intra-queue buffering process with dwedf. rl is shown to provide benefits dealing with flows whose behavior is hard to predict or characterize beforehand. the authors in [bfz20] use a deep neural network to dynamically learn the optimal buffer size per network flow. their proposal assigns the queue size depending on congestion control, delay and bandwidth. they show that they can reduce netsys 2021 2 / 14 eceasst queue sizes without any loss in throughput performance. finally, within the same context, an rl approach for bursty load management is proposed in [bat+20] to improve average wait times and manage over-saturation in the queues. for mptcp traffic control, in [ros19] a deep q-network is used for traffic management, wherein a dqn agent selects the optimal paths. this work illustrates the benefits of using a dqn approach to traffic scheduling and path selection problems. the work in [lzdx20] addresses scheduling of flows in mptcp, with a focus on short and long mptcp flows, and uses rl to improve performance compared with traditional traffic scheduling methods. the proposed ddpg-based deep reinforcement learning framework determines how to distribute the packets over multiple paths while decreasing the out-of-order queue size under such paths. the rl model is solved via an actor-critic framework and transformer encoders are used to process the states of dynamic sub flows for the neural networks. finally, in the domain of service management, [kmrw19] describes a deep reinforcement learning approach addressing the resource allocation problem in network slicing, accounting for both highly dynamic traffic arrival characteristics as well as job resource requirements (e.g., compute, memory and bandwidth resources). the authors demonstrate that their solution improves overall resource utilization and reduces latency in comparison to an equal slicing strategy. in our work, we seek to assist existing qos schedulers with a drl agent and deep reinforcement learning. the proposal in [ke19] is purely an aqm. the proposed drl algorithm is only concerned with making decisions on either dropping or serving packets. the algorithms in [ros19] and [lzdx20] use deep learning for optimal path selection in networks, and finally the approach in [bfz20] is concerned with buffer size optimization. our objective is to meet stringent demands for network flows belonging to a set of three classes: gold, silver, and bronze, by descending priority. this issue has not been addressed in the state-of-the-art using deep learning tools. we aim to use new tools to address a classic quality of service issue. in what follows, we present a deep q-learning weighted fair queuing-based approach to managing network flows. we want to determine the optimal scheduling weights per flow class depending on the network and traffic scenarios at hand. our model adapts to the variation in the traffic flows, always outputting the optimal weights in order to maintain the respective priority of the flows. 3 a deep reinforcement learning approach to smart queuing in this section, we discuss our deep q-learning approach for optimal weight selection in a wfqbased environment. we start by introducing the concept of weighted fair queuing and our implementation of it, and afterwards discuss our deep rl approach. 3.1 weighted fair queuing based aqm weighted fair queuing [bln99] is a state-of-the-art approach to network scheduling which constitutes a packet-based implementation of the generalized processor sharing algorithm [pg93]. in a classic wfq approach, each flow i ∈ n would achieve a general data rate equal to: ri = wi (w1 + w2 +....+ wn) r, (1) 3 / 14 volume 080 (2021) deep reinforcement learning for smart queue management where ri is the rate of flow i, r is the total link rate and wi is the weight associated with flow i. as such, the greater the weight of the flow, the better it is served. in our implementation, the classic wfq approach is installed above classic aqm algorithms. we chose wfq, instead of a strict priority scheduler, in order to ensure fairness. each flow, based on its priority, is enqueued in a different child queue, separated from the others and following either the same or different aqm approaches: red, fifo, codel, pie, etc. the algorithm would then dequeue packets from each queue in order depending on the associated weight. this means that on top of the packet queuing and dropping mechanisms, as well as the inter-class bandwidth sharing maintained by aqms, we have qos guaranteed by the wfq algorithm. in our approach, we assume that all flows in the network can, based on packet priority, be classified intro three classes, listed by order of importance: gold, silver, and bronze. each of these classes has throughput and end-to-end delay targets to meet. each flow is mapped into a corresponding queue based on its priority (flow type), and is thus associated with a certain qos. 3.2 deep q-learning network for optimal weights in this section, we introduce our dqn-wfq algorithm. we aim to utilize a deep reinforcement learning approach, specifically dqns, to create a model that is able to input the network state in terms of throughput and delay values and output the weights that would lead to satisfying the largest amount of flow classes’ throughput and delay requirements. in what follows, we highlight the main features of this dqn network. 3.2.1 formulation of the problem in order to properly construct our reinforcement learning network, we first need to model the problem as a markov decision process (mdp) [bel57]. the latter provides a mathematical framework to model decision-making in the learning environment. an mdp is represented by the tuple (s,a,p,r), where s represents the set of states, a is the set of possible actions, p(s1|s0,a0) is the probability of transitioning from a state s0 to a state s1 after taking an action a0 ∈ a, and r(a0,s0) is the reward issued for moving from state to another. our objective is to continuously find the optimal weights for the wfq algorithm. we use deep q-learning which is a value-based implementation of the markov process. it consists of taking actions based on eventual values known as q-values. in order to use a dqn, we must first define the set of possible states, actions and rewards in our scenario. 1. problem states: we define a state in our problem, at a given time t, as a sextuple of the current throughput and end-to-end delay values achieved by each class of flows: gold, silver, and bronze: st = {tg,dg,ts,ds,tb,db}, where tg is the throughput of the gold flows, dg is the delay of the gold flows i.e., the average delay of all flows classified as gold, and so on. since in theory this state space is infinite, we normalize and discretize the set of possible states. an increased state space would mean the algorithm has more room to explore for better solutions, but would incur a time penalty for convergence. 2. possible actions: the dqn agent is tasked with manipulating the weights of the wfq algorithm. as such the set of actions it can take on the weight of each type of queue netsys 2021 4 / 14 eceasst (gold, silver, or bronze) is to either increase it by a preset value (+x), decrease it by that same value (−x), or leave the weight unchanged (+0). the agent will take an action on the weights of all the flow classes simultaneously. the weights are then normalized to ensure their sum is always equal to one. the action on the gold class, for example, can be expressed as ag ∈ {−x,0,+x}, and as such the action of the agent at each step can be formulated as: at = (ag,as,ab). since the agent acts on all three class weights simultaneously, and since there are three possible options to adjust each weight, there exists a total of 27 possible actions. 3. action reward: the reward is issued for an agent depending on how its action has impacted the throughput and delay thresholds of each flow class. let ηi be the reward for meeting the throughput demand of flow class i, and φi the reward for meeting the delay requirement of class i. the total reward is computed as follows: rt = ω t g ·ηg + ω d g ·φg + ω t s ·ηs + ω d s ·φs + ω t b ·ηb + ω d b ·φb. (2) ω t i is a binary value that equal to -1 if the demand throughput for flow class i is not met and +1 if it is. similarly, ω di is equal to -1 if the delay requirement is not met for flow class i and +1 if it is. this means that the reward can be in the negative i.e., a penalty. finally, we define the delay reward/penalty in terms of the throughput reward/penalty: φg = κ·ηg. this enables tuning the reward to put more emphasis on the throughput or viceversa. in principle, ηg > ηs > ηb indicating that the agent is rewarded better and penalized harder for meeting, or failing to meet, the demands of the gold class than it is for the silver and bronze classes, respectively. these values can be fine-tuned to further improve the significance of one class over the other, but if the value of ηg, for example is too high, the agent will be incentivized to meet the demands of the gold flows while disregarding the others as it attempts to maximize its reward. 3.2.2 deep learning process deep q-learning builds on traditional q-networks which work as follows. in a q-network algorithm, the objective of the agent is to output a policy φ(a|s) which would dictate how the agent moves from one state to another and which actions to take in order to maximize the long-term reward [wd92]. once the q-values are defined, and when in any given state at a certain time t st ∈ s, a chosen action to improve the policy can be expressed as: at = arg max ∀a∈a q(st,at). (3) in order to find the optimal policy φ, the bellman equation can be used to compute the optimal value function starting from a state s as: v (st) = max ∀at∈a {r(st,at)+ γ · ∑ st+1∈s pr{st+1|st,at}·v (st+1)}, (4) where st+1 is the state following s after taking the action at and γ is the discount factor ∈ [0,1]. the discount factor quantifies how much weight we put on future rewards. the value in the 5 / 14 volume 080 (2021) deep reinforcement learning for smart queue management in pu t (s ta te ) in pu t (s ta te ) o ut pu t la ye r o ut pu t la ye r fully connected layers fully connected layers loss replay buffer o bs er va tio n renewing the parameters dqn agent ac tio n a re w ar d r st at e s s environment s' (s , a , r , s ') sample batch for training figure 1: dqn algorithm structure q-table is defined as: q(st,at) = r(st,at)+ γ · ∑ st+1∈s pr{st+1|st,at}·max at+1 q(st+1,at+1). (5) as such, the q-table can be updated following: qt+1(st,at) = qt(st,at)+ α(r(st,at)+ γ ·max at+1 qt(st+1,at+1)−qt(st,at)). (6) α is the learning rate ∈ [0,1], and at+1 is the action taken when in state st+1 based on the policy φ. the learning rate controls the speed with which the algorithm learns: if too low, the algorithm might never reach its objective, while if too high, the algorithm might oscillate around the objective. the problem with classical q-learning is that it requires a table entry for each possible stateaction combination. any simple realistic scenario would explode the amount of required memory to store the q-table. as such, when using q-learning with a deep neural network, we change the q-values completely, at each training step, instead of updating them with the increments. the learning rate α is also dropped as it is now accounted for within the back propagating optimizer as we detail in the following section. 3.2.3 target network and experience replay in q-learning, we are “updating a guess with a guess”. this becomes even harder when the target value we are chasing i.e., r(st,at)+ γ ·max at+1 qt(st+1,at+1) is moving. the two consecutive states netsys 2021 6 / 14 eceasst algorithm 1: training the dqn agent 1 initialize the main network q 2 initialize the target network q̂ 3 initialize the experience replay memory d 4 initialize the agent to interact with the environment 5 while not converged do /* sample phase for the replay buffer */ 6 ε ← set new epsilon via ε -decay 7 choose an action a from state s using policy ε -greedy(q) 8 agent takes action a, gets reward r and next state s′ 9 store transition (s, a, r, s′, done) in the replay memory d /* done indicates if the dqn agent reached its set target or not */ 10 if enough experiences in d then /* learning and training phase */ 11 sample a random minibatch of n transitions from d 12 for every transition in (si, ai, ri, s′i, donei) in minibatch do 13 if donei then 14 yi = ri 15 else 16 yi = ri + γ·max a′∈a q̂(s′i,a ′) 17 calculate the loss l = 1n ∑ n−1 i=0 (q(si,ai)−yi) 2 18 update q using the sgd algorithm by minimizing the loss l 19 every c steps, update q̂ using q’s weights gold silver bronze dqn agent observationnetwork control real-time traffic batch traffic enqueue dequeue wg ws wb figure 2: agent placement and decision making 7 / 14 volume 080 (2021) deep reinforcement learning for smart queue management st and st+1 have one step between them, they could be very similar and the neural network would not be able to distinguish between them. when the neural network’s parameters are updated to make q(s,a) closer to a desired value, the value for q(st+1,at+1), a different entry in the table, could be altered. this could make the training unstable. in order to avoid this situation, we utilize a target network in addition to the main neural network. this target network is a copy of the main one and we use it to keep the values of (st+1,at+1) [hs19]. the predicted q-values of this copy q-network are then utilized to backpropagate through and train the main q-network. the parameters of the target network are not trained, but regularly updated with the values of the main network. note that when moving from classical q-networks to deep q-networks, the learning rate is no longer used in the same capacity. it is accounted for within the optimizer used to minimize the loss. we use the default value of 0.001. in a deep neural network, we can learn through backpropagating and by using stochastic gradient descent (sgd) optimization. a fundamental requirement to do so is that the data we are training the model on is independent and identically distributed. if the agent is being trained on the data as it comes, the sequence of experience could be highly correlated. this can cause action values to oscillate and diverge. as a solution to this problem, we use a large buffer to store past experiences. these past experiences are tuples of the form (s,a,r,s′) i.e., they have the current state, the action taken, the reward issued, and the subsequent state. this experience replay buffer is then randomly sampled to train the model. this process of sampling batches from the replay buffer to learn is known as experience replay [zs17]. the agent learns by minimizing the loss. the structure of the dqn algorithm can be seen in figure 1. a pseudo-code of the process is shown in algorithm 1. in the referenced code, simplified notations are used with s referencing the current state, s′ referring the next state following the taken action a, and r being the issued reward. our model is trained on a certain network topology as the traffic varies. as long as there is not a major change in the topology, there would be no need to retrain the model. finally, in figure 2 we illustrate how the dqn agent is pushed on top of the bottleneck queues where it monitors the environment and calibrates the weights of each class accordingly. 4 simulation results in this section, we benchmark the performance of the proposed dqn-wfq based smart queuing algorithm by using the packet-level simulator ns3 [rh10]. the considered topology, illustrated in figure 3a, is composed by only one bottleneck link, in order to study the impact of the queue management proposal. this topology well represents some realistic scenarios such as a satellite link communication or the link between an access router and a leased line. we consider six origin-destination (od) pairs that can send data in only one out of three classes of services, i.e., gold, silver, and bronze. each two od pairs belong to one traffic class. to mimic diurnal time-varying traffic patterns, the origins generate traffic with a sinusoidal rate between 0.25 and 1.5 mbps. the bottleneck link bandwidth is 4 mbps and its propagation delay is 20 ms. in these results we consider only small transmission rates to speed up simulation duration. however we verified that the results remain the same even with larger link bandwidth and transmission data rates. our trained agent is place on the bottleneck link. the dqn agent is composed of an input netsys 2021 8 / 14 eceasst layer with six inputs representing the observation, and an output layer with a softmax activation function with 27 outputs, representing the possible action space (3x3x3). for each class (gold, silver, bronze), the agent is taking one out of the three possible actions, i.e., increase the weight, decrease it, or keep it the same. in between the input and output layers, there are two fully connected dense layers with 128 units each. the rest of the parameters are detailed in tables 1 and 2. we consider two different types of traffic, udp and tcp. in order to avoid having udp traffic starving out its tcp counterpart, we run the simulations assuming that all the nodes send the same type of traffic. table 1: scenario simulation parameters parameter value number of od pairs 6 sq implementation bottleneck on top of red aqm on other links fifo simulation duration / snapshot 10 sec transport protocol udp-tcp bottleneck link delay 10 ms bottleneck link bw 4 mbps traffic generation per node about 0.25 to 1.5 mbps weights wfq udp 0.5/0.33/0.16 & 0.6/0.25/0.15 weights wfq tcp 0.58/0.26/0.16 & 0.5/0.33/0.16 table 2: dqn simulation parameters parameter value activation function connected layers relu activation function output layer softmax no of fully connected layers 2 each with 128 units training batch size 32 ε decay x 0.99955 per episode discount factor γ 0.99 no of terminal steps to update target 5 reward relative to flows g/s/b 3x/2x/x delay to throughput relevance κ 0.8 no of training episodes 15,000 4.1 algorithm convergence we first illustrate how the exploration rate varies with each training iteration. ε starts at 1 (i.e., always explore a new solution) and is decayed by a factor of 0.99955 each time the model is trained, as shown in figure 3b. after 1500 episodes, it is a coin flip whether the algorithm explores or exploits. the minimum value for ε is set at 0.001 or a 1% chance that the algorithm decides to explore. this method of decaying ε ensures that the algorithm has enough iterations to explore the entire state space. if the total number of training iterations is to be reduced, the decaying could be accelerated by decreasing the value of the decay rate. as illustrated subsequently, the algorithm does not need as many iterations to converge (1500 iterations are enough). we verify that the algorithm is converging by looking at the cumulative rewards for sets of 15 episodes. we do this to smoothen the curve and root out any undesirable fluctuation. in figure 3 we track both the minimum and average rewards for these aggregated episodes. note that the episode’s reward is its total accumulated rewards until it reaches its goal (i.e., done = 1). we set the goal to be equal to zero for this simulation. this means the dqn agent is trained whenever the reward is positive. in figure 3c, we notice that the minimum reward fluctuates severely over the first 500 episodes. however it quickly starts to stabilize at around the value of 0. similarly, the average reward shown in figure 3d, starts to stabilize at around the mark of 1500 episodes afterwards reaching a positive reward almost every iteration. 4.2 case of udp traffic in order to highlight the advantages of using a dqn agent to choose the weights, we simulate our dqn-wfq algorithm and compare it against the traditional wfq. the requested qos for 9 / 14 volume 080 (2021) deep reinforcement learning for smart queue management aqm o1 o2 o3 o4 o5 o6 d1 d2 d3 p2p link (a) network topology 0 1500 3000 4500 6000 7500 9000 10500 12000 13500 number of training episodes 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 v a lu e o f th e e x p lo ra ti o n r a te (b) tracking epsilon 0 1500 3000 4500 6000 7500 9000 10500 12000 13500 number of training episodes -14000 -12000 -10000 -8000 -6000 -4000 -2000 0 r e w a rd v a lu e minimum reward (c) tracking the minimum reward 0 1500 3000 4500 6000 7500 9000 10500 12000 13500 number of training episodes -2000 -1500 -1000 -500 0 500 r e w a rd v a lu e average reward (d) tracking the average reward figure 3: minimum and average reward as a function of the number of episodes the classes of flows are: 2.4 mbps for gold flows, 1 mbps for silver, and 0.6 mbps for bronze. there are two ways to input the weights for the traditional wfq approach. the first consists of choosing the weights based on the rewards which we used to train the dqn (section 3.2.1), and the second following the demanded levels of services we input to the dqn as requested. note that in our simulation the traffic generated per flow does not depend on the class it belongs to. as such, there is no intuitive way to vary the weights on-the-fly for the traditional wfq approach. we assume that in the case of congestion on the bottleneck link, a minimum level of service must be guaranteed to each flow. for the delay, the qos requirement is to guarantee an average delay bounds of 0.3, 0.6 and 1 second for gold, silver, and bronze flows, respectively. we first look at the throughput result when the traffic sources generate udp traffic. figure 4a shows the throughput results for dqn-wfq compared to traditional wfq. the weights here for the traditional wfq algorithm are chosen based on the rewards used to feed the dqn i.e., gold weight is 2x the silver and 3x the bronze (table 1). the figure has cumulative distribution plots (cdf) for all types of flows for both algorithms. the dotted lines show the demanded values to maintain during congestion periods. the areas where the plot is a straight vertical netsys 2021 10 / 14 eceasst 500 1000 1500 2000 2500 throughput in kbps 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 c d f dqn gold dqn silver dqn bronze wfq gold wfq silver wfq bronze congestion s gb (a) impact on throughput gold silver bronze gold silver bronze dqn-wfq traditional wfq 0 0.5 1 1.5 2 2.5 d e la y i n s e c o n d s (b) impact on delay figure 4: performance in case of udp traffic. the dashed lines correspond to the required qos. 0 500 1000 1500 2000 2500 3000 throughput in kbps 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 c d f dqn gold dqn silver dqn bronze wfq gold wfq silver wfq bronze s gb (a) impact on throughput gold silver bronze gold silver bronze dqn-wfq traditional wfq 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 d e la y i n s e c o n d s g b s (b) impact on delay figure 5: performance in case of tcp traffic. the dashed lines correspond to the required qos. line indicate that congestion has occurred on the bottleneck. at small data rates i.e., around 0.25 mbps requested by each node, the bottleneck link is not congested, so it can transmit all the requested traffic. by looking at the congestion areas on the plot, we notice that wfq meets the throughput levels requested for both silver and bronze flows while it fails to meet the requirement for gold flows (2.12 mbps instead of 2.4). dqn-wfq, instead, meets the qos requirements for all the flows, providing a throughput of 2.405 mbps for the gold class flows, 1.06 mbps for the silver, and 0.615 mbps for the bronze. the dqn agent continuously learns how to update weights in order to maximize the reward, which is contingent on meeting all the flow throughput requirements. in figure 4b, we present the results in terms of the average delay experienced by the flow packets. we note that our algorithm can meet all the set delay values while traditional wfq, notorious for causing delay penalties, cannot guarantee any. furthermore, setting the weights for traditional wfq following the delay requirements does not yield any difference in performance 11 / 14 volume 080 (2021) deep reinforcement learning for smart queue management as the weights effectively remain unchanged from the current case. finally, if we run the traditional approach with the weights set proportional to demanded throughput levels, the traditional wfq algorithm would be able to meet the gold and bronze flow requirements while failing to meet the silver class demands (around 0.96 mbps). no significant changes can be noted in terms of delay targets. 4.3 case of tcp traffic we now study the performance of our model in case of tcp traffic, a protocol that differs from udp because of its innate congestion control mechanism. we lower the throughput requirement for the gold class flows to 2.2 mbps to count for the bandwidth taken by tcp acks. for wfq, we calculate the weights based on the requirements: for instance, as for the gold flows, we require to guarantee 2.2 mbps of throughput during congestion, its weight is calculated as 2.2/3.8 ' 0.58. the same approach is taken for the weights of the silver and bronze classes. similar to before, there is no benefit in varying this weight as the different classes are generating traffic with the same data rates. the cdf distribution of the achieved throughput is shown in figure 5a. as with the case of udp traffic, dqn-wfq is capable of meeting all the throughput requirements. for traditional wfq, the gold and silver qos requirements are met, but the bronze flow is starved and served at about 0.2 mbps during congestion, well below the requirement. this gold class outperforms and has throughput values higher than required. this effect is due to the congestion control mechanisms of tcp. because of the relatively high weights of the gold and silver flows, not a few packets are being sent or acknowledgments received for the bronze flow. this triggers the congestion control for the bronze flow, further lowering its capability of meeting the set requirements. the bandwidth is then dominated by the gold flows which get about 65% of the bandwidth instead of the 58% they were supposedly allotted by wfq. in figure 5b we highlight the performance of dqn-wfq in terms of delay. as in the case with udp traffic, traditional wfq fails to meet the delay requirements, while dqn-wfq achieves delay values well below the delay thresholds for all three flow classes, as the continuous weight adaptation carried out by dqn-wfq helps optimize bandwidth utilization. finally, we note that calculating the weights for traditional wfq using the rewards fed to the dqn, or relative to the delay requirements, results in no difference in which flow requirements are being met. 5 conclusion in this article, we proposed a deep reinforcement learning approach to help meet stringent demands of classified network flows. we implemented a dqn-wfq agent that learns the optimal weights for dequeuing different classes of network flows: gold, silver, and bronze. the agent implements drl tools such as replay buffers and target networks to help in convergence. we showed via simulation results that our proposal is efficient and helps fulfill flow requirements in terms of throughput and delay. in our concurrent and future works, we will implement a multi-agent reinforcement learning approach in a network with multiple bottlenecks. netsys 2021 12 / 14 eceasst bibliography [b+94] m. bramson et al. instability of fifo queueing networks with quick service times. the annals of applied probability 4(3):693–718, 1994. [bat+20] v. balasubramanian, m. aloqaily, o. tunde-onadele, z. yang, m. reisslein. reinforcing cloud environments via index policy for bursty workloads. in noms 20202020 ieee/ifip network operations and management symposium. pp. 1–7. 2020. [bel57] r. bellman. a markovian decision process. journal of mathematics and mechanics 6(5):679–684, 1957. [bfz20] m. bachl, j. fabini, t. zseby. lfq: online learning of per-flow queuing policies using deep reinforcement learning. in 2020 ieee 45th conference on local computer networks (lcn). pp. 417–420. 2020. doi:10.1109/lcn48667.2020.9314771 [bln99] v. bharghavan, s. lu, t. nandagopal. fair queuing in wireless networks: issues and approaches. ieee personal communications 6(1):44–53, 1999. [bss12] m. boyer, g. stea, w. m. sofack. deficit round robin with network calculus. in 6th international icst conference on performance evaluation methodologies and tools. pp. 138–147. 2012. [fj93] s. floyd, v. jacobson. random early detection gateways for congestion avoidance. ieee/acm transactions on networking 1(4):397–413, 1993. [ggc+18] m. guo, q. guan, w. chen, f. ji, z. peng. delay-optimal scheduling for heavytailed and light-tailed flows via reinforcement learning. in 2018 ieee international conference on communication systems (iccs). pp. 292–296. 2018. [hs19] j. f. hernandez-garcia, r. s. sutton. understanding multi-step deep reinforcement learning: a systematic study of the dqn target. arxiv preprint arxiv:1901.07510, 2019. [ke19] m. kim, b. eng. deep reinforcement learning based active queue management for iot networks. phd thesis, 2019. [kmrw19] j. koo, v. b. mendiratta, m. r. rahman, a. walid. deep reinforcement learning for network slicing with heterogeneous resource requirements and time varying traffic dynamics. in 2019 15th international conference on network and service management (cnsm). pp. 1–5. 2019. [lzdx20] b. liao, g. zhang, z. diao, g. xie. precise and adaptable: leveraging deep reinforcement learning for gap-based multipath scheduler. in 2020 ifip networking conference (networking). pp. 154–162. 2020. [nj12] k. nichols, v. jacobson. controlling queue delay. communications of the acm 55(7):42–50, 2012. 13 / 14 volume 080 (2021) http://dx.doi.org/10.1109/lcn48667.2020.9314771 deep reinforcement learning for smart queue management [pg93] a. k. parekh, r. g. gallager. a generalized processor sharing approach to flow control in integrated services networks: the single-node case. ieee/acm transactions on networking 1(3):344–357, 1993. [pnp+13] r. pan, p. natarajan, c. piglione, m. s. prabhu, v. subramanian, f. baker, b. versteeg. pie: a lightweight control scheme to address the bufferbloat problem. in 2013 ieee 14th international conference on high performance switching and routing (hpsr). pp. 148–155. 2013. [rh10] g. f. riley, t. r. henderson. the ns-3 network simulator. in modeling and tools for network simulation. pp. 15–34. springer, 2010. [ros19] m. m. roselló. multi-path scheduling with deep reinforcement learning. in 2019 european conference on networks and communications (eucnc). pp. 400–405. 2019. [wd92] c. j. watkins, p. dayan. q-learning. machine learning 8(3-4):279–292, 1992. [zs17] s. zhang, r. s. sutton. a deeper look at experience replay. arxiv preprint arxiv:1712.01275, 2017. netsys 2021 14 / 14 introduction related works a deep reinforcement learning approach to smart queuing weighted fair queuing based aqm deep q-learning network for optimal weights formulation of the problem deep learning process target network and experience replay simulation results algorithm convergence case of udp traffic case of tcp traffic conclusion open source certification and educational process electronic communications of the easst volume 20 (2009) proceedings of the third international workshop on foundations and techniques for open source software certification (opencert 2009) open source certification and educational process alexey khoroshilov 8 pages guest editors: luis barbosa, antonio cerone, siraj shaikh managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst open source certification and educational process alexey khoroshilov1 1 khoroshilov@ispras.ru, http://www.linuxtesting.org/ institute for system programming of the russian academy of sciences, moscow, russia abstract: this paper discusses possibilities to benefit software engineering and computer sciences educational process from involving students in open source software certification activities. on the other hand the open source certification community can take advantages of this involvement if it cooperates with educational one. the situation is considered in the context of russian higher institutes of education but the conclusions can be applicable to other institutes as well. keywords: open source software, software engineering education, verification 1 introduction open source software certification is an essential factor for success of open source within government and business organizations. at the moment, such certification is mostly carried out by commercial companies that offer open source based solutions to end users. there is repeatedly discussed need for community based certification process founded on rigorous, mathematically based, methods in software analysis and engineering by community and at the opencert workshop [ope07, ope08]. there were proposed approaches [cs08, km08, pb08b] that defined some feasible ways to enable the process. technically the initial steps are rather clear. but actually nothing is happened mostly owning to organizational question. there were considered the following possibilities for the process organization: • to start pure community project; • to involve teachers and students in the project; • to obtain funding from government or non-profit foundations. the community is not sufficiently interested in the process for various reasons [pb08a]. government and non-profit foundations have not yet shown interest in the activities. although it should be noted the massive program of the linux foundation [lft] to develop a serious test suite for conformance testing against the linux standard base (lsb) [lsb] standard, in which there has been developed more than 160000 tests for more then 26600 interfaces. under this project three different technologies are used to develop tests of different quality grades. and for the core functionality of the lsb model based testing technology is used, which provides the most thoroughly tests developed with involvement of mathematical methods. within the paper there is considered the possibility of attracting students to the organization of open source software certification in order to bring benefits to all parties: the students will get necessary skills and experience which can be useful in the future, while the open source 1 / 8 volume 20 (2009) mailto:khoroshilov@ispras.ru http://www.linuxtesting.org/ open source certification and educational process certification community will be able to start moving forward and to get a basis for more active development. in the next section, we will describe the features of the educational process in higher educational institutions of russia, to understand what opportunities exist for integration of open source certification into the educational process. then we will discuss what challenges the open source certification face. and finally, we will consider how to mutually benefit each other and what concrete steps can be done. 2 educational process in russia in higher educational institutions of russia the most common types of educational activities are as follows: • mandatory and special courses; • practical training; • special seminars; • course and diploma work. mandatory and special courses consist of lectures, seminars and workshops. lectures are the basis of theoretical training for students. their purpose is to provide a foundation of scientific knowledge on a subject, reveal problems, state of and prospects for progress in specific areas of science and technology. a course of lectures is a systematic problem statement, which consistently presents material on a subject. lectures are usually accompanied by various kinds of seminars, practical workshops and supplemented by homework. these exercises can be aimed at a thorough study of the most important topics of the course or to obtain practical skills on the subject. special courses differ from mandatory ones as they are not mandatory to visit by students. students have opportunity to choose between different special courses, so it is important to make special courses interesting and attractive. courses usually last one or two semesters and are concluded by assessment test on a fivepoint scale. assessment of practical work may be a part of assessment of the course or as an independent test. lectures are usually provided by one or a couple of lecturers. seminars and workshops are conducted for groups of 15-25 students by a trainer. the purpose of practical training is to consolidate and extend the knowledge gained by students in the learning process, to acquire knowledge, skills and practice necessary for profession. duration of practice may vary. for example, the most practical trainings at computer sciences department of lomonosovs moscow state university run for 12 weeks and 2 days a week, including two days at the end of practice devoted to preparation of a written report. each student gets a mentor from university and a mentor from the organization where the training occurs. responsibilities between mentors are defined in each case particularly. number of students per a mentor may vary from 3 to 40. special seminars are designed for detail study of the topic of students scientific expertise. teaching methods used at special seminars are determined by its scientific adviser and may proc. opencert 2009 2 / 8 eceasst include both theoretical and practical components. special seminars usually take about two hours a week. as a rule number of students per scientific adviser is limited by 3-7. term and diploma work is a self-teaching and research work of a student under the guidance of a scientific adviser. the purpose of it is to study methods of research work and to get new knowledge and skills. term work in software engineering combines research and practical components. the research component includes analysis of a problem and search of an appropriate solution. the practical component is implementation of the solution proposed. diploma is a qualification work in which students have to demonstrate professional knowledge of the theory and practice of the subject area, ability to solve specific tasks in this area. usually a scientific adviser for term and diploma work is the same as for a special seminar. 3 open source certification: goals and tasks the purpose of the open source certification community is to establish the quality assessment of open source software projects especially involving rigorous, mathematically based, methods in software analysis and engineering. we see the following directions that can be used for achieving this goal: • code review; • testing; • light weight verification; • heavy weight verification. code review is frequently used in open source projects. but in our context, this direction does not look too promising. first of all, code review is not very attractive to students. and secondly, benefits, such as skills of someone else’s code analysis, identification of common issues and successful design patterns, can be obtained within more interesting activities. in addition to code review itself there are other important tasks. for example, it would be useful to develop code review guidelines helping to detect different kinds of errors. testing is a huge area that provides great number of tasks. it is necessary to have tests of different kinds: • functional testing; • conformance testing; • regression testing; • stress testing; • load testing; • etc. 3 / 8 volume 20 (2009) open source certification and educational process and tests for components of different levels: • unit testing; • integration testing; • system testing. testing activities include: • new test development; • test execution and result analysis. testing activities allow to obtain various skills: test development itself, documentation analysis, source code analysis, reverse engineering, etc. lightweight verification includes various methods of static analysis and model checking. in this regard there are the following tasks: • identification of domain specific restrictions and typical bugs for automatic detection; • formal representation of the restrictions in terms of the tools used; • development of simplified models of target system to be used for automatic analysis; • automatic analysis of target source code with verification tools and investigation and classification of results. in addition, if verification tools are implemented using extensible architecture, it is possible to develop new verification techniques and to improve existing ones on base of experience of its application to open source software analysis. if lightweight verification allows to find only certain kinds of problems in the source code, heavyweight verification provides a more complete analysis of the properties of the target program. there are different approaches to heavyweight verification. for example, let us consider classical floyd-hoare methods of verification of sequential programs. first of all the method requires to formally describe requirements to the target function in the form of precondition and postcondition. moreover, all auxiliary functions used by the target ones should be specified in terms of precondition and postcondition as well. then, invariants and variants should be defined for all cycles of the target program. invariants describe restrictions on values of the program variables and memory when the control flow is in the given point of the program. variants define a function, which decreases throughout every pass of a cycle. after that verification tools automatically generate conditions in high order logic, a proof of which leads to a proof of full correctness of the target function against the given specification. proof of the conditions is usually conducted within interactive theorem provers such as pvs [pvs], coq [coq], isabella hol [hol]. accordingly, in this approach to verification the following tasks occur: • specification of auxiliary functions (library functions, operating system functions, etc.); • specification of target functions and invariant and variant development; • proof of lemmas generated in interactive provers. proc. opencert 2009 4 / 8 eceasst 4 how to mutually benefit each other let us discuss how to mutually benefit open source software certification community and educational process. seminars and practical workshops of courses can use open source certification tasks if a subject of a course has explicit intersection with testing or verification methods and tools, which are used in the open source certification community. however, workshops require small learning tasks and work with source code of real projects can be too difficult. that is why we believe the work in this direction seems not very promising. nevertheless testing tasks can be successfully used here under some conditions. practical training is rather long and allows to solve real and significant enough tasks. but its success requires a set of clearly defined goals, accompanied by a methodical material, as well as a mentor for each student, who will answer student questions regarding the methods and tools involved and the target software as well. if a representative of the educational institution can be a such mentor it is a very good situation. otherwise some responsibilities should be taken by a representative of the open source certification community. but in any case some participation of the community is required to consult students and mentors on complex issues. of course, the ideal situation is when a mentor of the university is an active member of the open source certification community as well. tasks for practical training, for example, can be of the following kinds: • to develop tests of certain types with certain quality using a certain technology for a particular component; • to apply a particular method of static analysis or model checking to a particular component and to analyse results; • to specify requirements for a particular function formally and to prove its correctness with respect to the specification. more concrete examples of the tasks are as follows: 1. analyze requirements of the given standard (documentation) to a particular group of functions and create a catalogue of elementary requirements to it. develop formal specification of the requirements to the functions in the form of preconditions and postconditions in the specification extension of the c programming language with traceability to the initial text of the standard. develop functional tests for these functions using model-based testing technology unitesk [uni]. estimate quality of the tests using the following test coverage metrics: coverage of elementary requirements, coverage of functionality branches as well as source code coverage. 2. analyze requirements of the given standard (documentation) to a particular group of functions and create a catalogue of elementary requirements to it. develop tests using the t2c testing technology [t2c] with traceability to the initial text of the standard. estimate quality of the tests using the following test coverage metrics: coverage of elementary requirements as well as source code coverage. 5 / 8 volume 20 (2009) open source certification and educational process 3. develop formal specification of requirements to a particular function in the form of preconditions and postconditions in ansi / iso c specification language [acs]. develop cycle invariant and variants in the same language. generate floyd-hoare verification, correctness and termination conditions using why software verification toolkit [why]. prove the conditions within one of the interactive theorem provers supported by why (pvs, coq). work at special seminars may have an intersection with the open source certification tasks if a student’s academic specialization has relevance to these tasks directly. it is possible if a scientific advisor is interested in software testing and verification techniques. but keeping in mind that students’ practical work at special seminars usually is either directly related to their term and diploma works or similar to practical workshops, discussion of this topic can be considered as a part of the discussion below. course and diploma work may also include a solution of significant problems as in the case of practical training, but in contrast to it course and diploma work should have a research component. therefore, either a target system for testing or verification should be interesting from research point of view or a task should be related to investigation and improvement of basic technology of testing or verification. for example, it can be development of automatic strategies for pvs prover, which simplify interactive proof of the conditions generated as a part of floyd-hoare verification methods. thus, there are two directions for implementing open source certification tasks within educational process: methodical and organizational ones. as a part of the methodical direction it is required to: • prepare an appropriate number of tasks to be assigned to students; • prepare methodical materials necessary to perform the work; • organize support for students and mentors during the educational process. within the organizational direction it is required to find representatives of universities who are interested in organization of student work on the proposed directions. they can be interested in it by the following reasons: • students will be able to get skills of application of advanced technologies to real life software; • results of the tasks are not thrown out, but benefit society (and it makes positive impact on motivation of students); • methodical materials and tasks are available. it may be useful to define a web resource where actual tasks and methodical materials are collected and discussed. case studies of using the materials within educational process and feedback of students and mentors can be collected at the same place. proc. opencert 2009 6 / 8 eceasst 5 conclusions we have described the possibilities to integrate open source certification tasks into practical work of software engineering and computer sciences students. we have demonstrated that it can be mutually benefit both educational process and the open source certification community. the initial steps, that can be done to prepare a basis for this integration, have been identified. in the institute for system programming of the russian academy of sciences we work a lot with students of computer sciences department of lomonosovs moscow state university and moscow institute of physics and technology and we are interested in discussion of this proposal with the open source certification community to identify the best ways to apply it within our educational process. if a consensus within the open source certification community is achieved, this approach will be able to be applied to more wide range of educational organizations across the world. bibliography [acs] acsl:ansi/isocspecificationlanguage. http://framac.cea.fr/download/acsl 1.4.pdf [coq] the coq proof assistant. http://coq.inria.fr/ [cs08] a. cerone, s. shaikh. incorporating formal methods in the open source software development process. in proc. of the second international workshop on foundations and techniques for open source software certification (opencert 2008). milan, italy, sept. 2008. [hol] the isabelle/hol proof assistant. http://isabelle.in.tum.de/ [km08] a. khoroshilov, v. mutilin. formal methods for open source components certification. in proc. of the second international workshop on foundations and techniques for open source software certification (opencert 2008). milan, italy, sept. 2008. [lft] lsb testing program. http://linuxfoundation.org/en/testing [lsb] linux standard base. http://linuxfoundation.org/en/lsb [ope07] proc. of the second international workshop on foundations and techniques for open source software certification (opencert 2008). braga, portugal, mar. 2007. http://opencert.iist.unu.edu/workshop-home-2007.html [ope08] proc. of the second international workshop on foundations and techniques for open source software certification (opencert 2008). milan, italy, sept. 2008. http://opencert.iist.unu.edu/workshop-home-2008.html 7 / 8 volume 20 (2009) http://frama‑c.cea.fr/download/acsl_1.4.pdf http://coq.inria.fr/ http://isabelle.in.tum.de/ http://linuxfoundation.org/en/testing http://linuxfoundation.org/en/lsb http://opencert.iist.unu.edu/workshop-home-2007.html http://opencert.iist.unu.edu/workshop-home-2008.html open source certification and educational process [pb08a] s. pickin, p. t. breuer. four compass points in the verification of the linux kernel. in proc. of the international workshop on foundations and techniques bringing together free/libre/open source software and formal methods (floss-fm 2008). milan, italy, sept. 2008. [pb08b] s. pickin, p. t. breuer. open source certification. in proc. of the second international workshop on foundations and techniques for open source software certification (opencert 2008). milan, italy, sept. 2008. [pvs] pvs specification and verification system. http://pvs.csl.sri.com/ [t2c] t2c test development technology. http://ispras.linuxfoundation.org/index.php/t2c framework [uni] unitesk model based testing technology. http://www.unitesk.com/ [why] why software verification toolkit. http://why.lri.fr/ proc. opencert 2009 8 / 8 http://pvs.csl.sri.com/ http://ispras.linuxfoundation.org/index.php/t2c_framework http://www.unitesk.com/ http://why.lri.fr/ introduction educational process in russia open source certification: goals and tasks how to mutually benefit each other conclusions toward a code-clone search through the entire lifecycle of a software product electronic communications of the easst volume 63 (2014) proceedings of the eighth international workshop on software clones (iwsc 2014) toward a code-clone search through the entire lifecycle of a software product — position paper — toshihiro kamiya 7 pages guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst toward a code-clone search through the entire lifecycle of a software product toshihiro kamiya1 1 kamiya@fun.ac.jp department of media architecture, school of systems information science, future university hakodate 116-2 kamedanakano-cho, hakodate, hokkaido, japan 041-8655 abstract: this paper presents a clone-detection method/tool currently under development. this tool is useful as a code-clone search through the entire lifecycle of a software product; the tool searches code examples and analyzes of code clones in both preventive and postmortem ways[lrhk10]. the approach is based on a sequence equivalence on execution paths[kam13] and extends the equivalence to include gaps, thus type-3[bka+07] clone detection. each of the detected clones is a sub-sequence of an execution path of a given program, in other words, a set of code fragments of multiple procedures (methods) which can be executed in a run of the program. the approach is relaxed in terms of adaptability to incomplete (not-yetfinished) code, but also makes use of concrete information such as types (including hierarchy) and dynamic dispatch when such information is available. keywords: code clone, code search, postmortem code-clone detection, preventive code-clone detection 1 introduction this paper presents a clone-detection method/tool under development. the tool will support searching a similar code at each stage of the entire lifecycle of a software product, that is, (1) a code example search will be executed even when no (or a very small volume of) code of a product has been written, (2) preventively (or instant)[lrhk10], i.e., in an automatic code-clone search to encourage code reuse by searching code fragments similar to the code written by a developer, and (3) postmortem[lrhk10]; i.e., in the code-clone search for a refactoring[bym+98][hkki04][zr11] or a consistent code modification[kri07]. a model of these stages is explained in sec. 2. the proposed method/tool is a kind of searching where both an input (query) and an output (search results) are code fragments. as for such kind of tools, codebroker[yfr00] and sniff[cjs09] search code fragments with a similarity of identifiers and text in comments. a tool strathcona[hm06] searches code fragments with a similarity of types (including the types that are related with the query code in terms of inheritance), or with methods directly called in the query code fragment. the essence of the search algorithm first identifies candidate code fragments with a similarity of names/values of types, literals, and director indirect-call of procedures, and then filters out 1 / 7 volume 63 (2014) mailto:kamiya@fun.ac.jp toward a code-clone search through the entire lifecycle of a software product figure 1: searching keywords in source code of jedit (or sorts) the candidate code fragments with a similarity as a sequence on an execution path; thus, a kind of structure. here an execution path represents a set of the code fragments that appear in distinct procedures, but are connected with procedure calls[kam13], and consequently, a type3[bka+07] (including arbitrary-size gaps) clone. a picture of the proposed search method is explained in sec. 3. ( the implementation is built on top of the code search method/tool[kam14]. figure 1 shows a sample run of the code search tool, where two keywords setforeground and getforeground were searched. here the former was called directly in a method body of initpainter and the latter called indirectly, via a method setstyles. in this latter case, the tool found such an example code of code fragments from distinct source files but connected by an execution path. ) note that this approach is opposite to approaches that find similarity in structures in terms of software architectures[bj05][teb12], data flow[dhj+08][pnn+09][acd+12], pdg(program dependence graph)[kri01][gjs08], ast(abstract syntax tree)[bym+98][kff06][jmsg07] [th12], and sequences of such as token[lhmi07][gk09], line [bak12][drd99], or byte code[dg10]. these approaches regard names/values as parameters of a structure, while the proposed approach finds similarity of names/values before structures. 2 development stages and available information figure 2 shows a model of the development stages. in an early stage of software development, a code search tool perhaps uses (as a query) only names/values of a code edited by a developer, because structures of such unfinished code will be incorrect or unstable. in the later stages, if a code being edited is stable enough and modifications on it are relatively few and small ones, its structures will be stable and a code search tool will use the structures as a query in addition to the names/values of the code. as for search targets, in an early stage of development (or when a product introduces a totally new feature and the product’s code base does not include any reference code in a practical sense), the tool is not able to use a product’s code base as a target. in such a case, the tool searches in code bodies of libraries (or frameworks) to be reused. in the later stage, the tool also searches in a code body of the product under development. an actual product would be a mix of these stages, especially in an incremental development process; some source files are matured and the others are immature or not-yet finished. in such a case, the proposed method/tool will be applicable in a seamless way, without develpers’ caring about which source files are at which stage. proc. iwsc 2014 2 / 7 eceasst (a) example search (b) preventive (c) postmortem figure 2: model of development stages and clone searching 3 / 7 volume 63 (2014) toward a code-clone search through the entire lifecycle of a software product figure 3: steps of clone-search method 3 steps of the searching method the proposed clone-code search consists of two steps. figure 3 shows a overall architecture of searching methods including these steps. 3.1 step 1. query information extraction for better precision of search results, more detailed information extraction is required; the tool has to extract names/values and structures (if possible) from a query code. at the same time, for applicability to a product at any stage, robustness is required; the tool has to be applicable to a query code incomplete in terms of semantic and syntactic structures. to balance the precision and the robustness, the tool at first tries to compile (and link) the code, then (if not successful) tries parsing the code, and tries lexical analysis at the end. table 1 shows an information extracted in each of these trials. if the code is successfully compiled and linked, as shown compilation/linking column in the table, extract names/values and structures including not only types, literals, and directly-called procedures the developer explicitly described in the code, but also types of “intermediate” values in expressions (such as a return value of a method call, which is passed to another method call as an argument without being assigned to a variable) or indirectly-called procedures. on the other hand, if the code is not finished yet and incorrect in terms of grammar of a programming language (e.g., unbalanced {}), the tool can extract only names (of something) or literals from such code fragment, as shown in proc. iwsc 2014 4 / 7 eceasst table 1: information extracted from a query code the “←” represents “the same items to the left cell”. the lexical analysis column in the table. 3.2 step 2. clone search in [kam14], a data structure named an and/or/call graph was introduced to represent (both innerand inter-method) execution paths of a given program in a compact form. the code-search algorithm finds the sub-graphs that include all keywords (of types, string literals, method signatures) and convert the sub-graphs into execution paths. the planned code-clone search algorithm will be an extension of the above algorithm in the following ways: (1) finding execution paths including many keywords (not all keywords are necessary) and (2) filtering or ranking execution paths with similarity of structures, in terms of order, distance, and frequency of appearances of these names/values on each execution path. 4 summary the paper has presented a code-clone search tool/method usable through the lifecycle of a software product. in such a development process, available information differs between development stages and the tool design should maximize applicability and precision at these stages. acknowledgements: this work was supported by jsps kakenhi grant number 24650013. bibliography [acd+12] m. alalfi, j. cordy, t. dean, m. stephan, a. stevenson. near-miss model clone detection for simulink models. in proc. iwsc 2012. pp. 79–79. 2012. [bak12] b. baker. on finding duplication and near-duplication in large software systems. in proc. wcre 1995. pp. 86–95. 2012. 5 / 7 volume 63 (2014) toward a code-clone search through the entire lifecycle of a software product [bj05] h. basit, s. jarzabek. detecting higher-level similarity patterns in programs. in proc. fse 2005. pp. 156–165. 2005. [bka+07] s. bellon, r. koschke, g. antoniol, j. krinke, e. merlo. comparison and evaluation of clone detection tools. ieee tse 33(9):577–591, 2007. [bym+98] i. baxter, a. yahin, l. moura, m. sant’anna, l. bier. clone detection using abstract syntax trees. in proc. icsm 1998. pp. 368–377. 1998. [cjs09] s. chatterjee, s. juvekar, k. sen. sniff: a search engine for java using free-form queries. in proc. fase 2009, lncs 5503. pp. 385–400. 2009. [dg10] i. davis, m. godfrey. from whence it came: detecting source code clones by analyzing assembler. in proc. wcre 2010. pp. 242–246. 2010. [dhj+08] f. deißenböck, b. hummel, e. jürgens, b. schätz, s. wagner, j.-f. girard, s. teuchert. clone detection in automotive model-based development. in proc. icse 2008. pp. 603–612. 2008. [drd99] s. ducasse, m. rieger, s. demeyer. a language independent approach for detecting duplicated code. in proc. icse 1999. pp. 109–118. 1999. [gjs08] m. gabel, l. jiang, z. su. scalable detection of semantic clones. in proc. icse 2008. pp. 321–330. 2008. [gk09] n. göde, r. koschke. incremental clone detection. in proc. csmr 2009. pp. 219– 228. 2009. [hkki04] y. higo, t. kamiya, s. kusumoto, k. inoue. refactoring support based on code clone analysis. in proc. profes 2004, lncs 3009. pp. 220–233. 2004. [hm06] r. holmes, g. murphy. approximate structural context matching: an approach to recommend relevant examples. ieee tse 32(12):952–970, 2006. [jmsg07] l. jiang, g. misherghi, z. su, s. glondu. deckard: scalable and accurate treebased detection of code clones. in proc. icse 2007. pp. 96–105. 2007. [kam13] t. kamiya. agec: an execution-semantic clone detection tool. in proc. icpc 2013. pp. 227–229. 2013. [kam14] t. kamiya. an algorithm for keyword search on an execution path. in proc. csmr-wcre 2014 (to appear). 2014. [kff06] r. koschke, r. falke, p. frenzel. clone detection using abstract syntax suffix trees. in proc. wcre 2006. pp. 253–262. 2006. [kri01] j. krinke. identifying similar code with program dependence graphs. in proc. wcre 2001. pp. 301–309. 2001. proc. iwsc 2014 6 / 7 eceasst [kri07] j. krinke. a study of consistent and inconsistent changes to code clones. in proc. wcre 2007. pp. 170–178. 2007. [lhmi07] s. livieri, y. higo, m. matsushita, k. inoue. very-large scale code clone analysis and visualization of open source programs using distributed ccfinder: dccfinder. in proc. icse 2007. pp. 106–115. 2007. [lrhk10] m.-w. lee, j.-w. roh, s. w. hwang, s. kim. a instant code clone search. in proc. fse 2010. pp. 167–176. 2010. [pnn+09] n. pham, h. nguyen, t. nguyen, j. al-kofahi, t. nguyen. complete and accurate clone detection in graph-based models. in proc. icse 2009. pp. 276–286. 2009. [teb12] u. tekin, u. erdemir, f. buzluca. mining object-oriented design models for detecting identical design structures. in proc. iwsc 2012. pp. 43–49. 2012. [th12] m. thomsen, f. henglein. clone detection using rolling hashing, suffix trees and dagification: a case study. in proc. iwsc 2012. pp. 22–28. 2012. [yfr00] y. ye, g. fischer, b. reeves. integrating active information delivery and reuse repository systems. in proc. fse 2000. pp. 60–68. 2000. [zr11] m. zibran, c. roy. a constraint programming approach to conflict-aware optimal scheduling of prioritized code clone refactoring. in proc. scam 2011. pp. 105– 114. 2011. 7 / 7 volume 63 (2014) introduction development stages and available information steps of the searching method step 1. query information extraction step 2. clone search summary enforce: a system for ensuring formal correctness of high-level programs electronic communications of the easst volume 1 (2006) proceedings of the third international workshop on graph based tools (grabats 2006) enforce: a system for ensuring formal correctness of high-level programs karl azab, annegret habel, karl-heinz pennemann and christian zuckschwerdt 12 pages guest editors: albert zündorf, daniel varró managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst enforce: a system for ensuring formal correctness of high-level programs karl azab, annegret habel, karl-heinz pennemann and christian zuckschwerdt carl v. ossietzky universität oldenburg, germany {azab,habel,pennemann,zuckschwerdt}@informatik.uni-oldenburg.de abstract: graph programs allow a visual description of programs on graphs and graph-like structures. the correctness of a graph program with respect to a preand a postcondition can be shown in a classical way by constructing a weakest precondition of the program relative to the postcondition and checking whether the precondition implies the weakest precondition. enforce is a currently developed system for ensuring formal correctness of graph programs and, more general, high-level programs by computing weakest preconditions of these programs. in this paper, we outline the features of the system and present its software framework. keywords: high-level programs, correctness, formal verification, weakest preconditions, weak adhesive hlr categories. 1 introduction graph transformation has many application areas in computer science, such as software engineering or the design of concurrent and distributed systems. it is a visual modeling technique and plays a decisive role in the development of growingly larger and complex systems. however, the use of visual modeling techniques alone does not guarantee the correctness of a design. in context of rising standards for trustworthy systems, there is a growing need for the verification of graph transformation systems. therefore, tools supporting formal verification of graph transformations will increase the attractiveness of this modeling technique and are in this sense important for its practical application. there exist several tools specifically concerned with graph transformation: engines for plain transformation, e.g., [bus04, gbg+06, mp06], general purpose tools with visual editors and debuggers for transformation systems like [tae04, swz99, bgn+04], and tools concerned with model checking or analysis of transformation systems properties, e.g., [tae04, kk06, sv03, kr06, bbg+06]. until now, most of these tools focus on transformation systems, instead of rule-based programs. programs featuring at least sequential composition and iteration are turing-complete and necessary to model transactions when dealing with an arbitrary number of elements. moreover, most tools are specifically concerned with a distinct kind of structure, let it be simple labeled, (typed) attributed graphs or hypergraphs. from a theoretical point of view, weak adhesive hlr categories [eept06] are an important effort to build a unified theory for transformation systems covering several kinds of structures, e.g., various kinds of (hyper-)graphs, place-transition nets and algebraic specifications. unfortunately, there do not exist tools designed to follow that idea, i.e., whose algorithms will work for more than just a specific kind of structure. 1 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs in this paper, we will present the main ideas of enforce, a suite of tools for ensuring the correctness of high-level programs. it is designed for weak adhesive hlr categories, exploiting the fact that necessary high-level algorithms can be based on a small set of structure-specific methods. structurally, enforce consists of applications (e.g., user interface), correctness tools and transformations (e.g., for proving the correctness of a program), engines (i.e., specific data structures and methods) and a core containing general high-level notions and methods, connecting these components. we plan to reuse existing engines, like graj. our efforts aim for a tool supplementary to existing tools such as [tae04, kk06, kr06, bbg+06], i.e., in terms of structures or functionality (see related systems). the paper is organized as follows. in section 2, we introduce programs for high-level structures like graphs and algebraic specifications and present a method for showing correctness for high-level programs. in sections 3 and 4, we present the system requirements and the system design. in section 5, we give an overview on related systems. a conclusion including further work is given in section 6. 2 correctness of programs in this section, we give an informal introduction to the main concepts of the paper, in particular into correctness of high-level programs based on all kinds of high-level structures such as graphs, place-transition nets, and algebraic specifications. the concepts are illustrated by a running example in the category of graphs. for more details refer to [eept06, hpr06]. assumption. we assume that 〈c , m〉 is a weak adhesive hlr category with a decidable set m , binary coproducts, epi-m -factorization, an m -initial object, i.e., there is an object i such that, for every object g in c , there exists a unique morphism from i to g in m , and a finite number of matches for each object, i.e., for every morphism l : k → l in m and every object g, there exist only a finite number of morphisms m : l → g such that 〈l, m〉 has a pushout complement. example 1 (access control graphs). for illustration, we consider the weak adhesive hlr category of all directed labeled graphs. we consider a simple access control for computer systems, which abstracts authentication and models user and session management in a simple way. the basic items are users , sessions , and computer systems with directed edges between them. an edge between a user and a system represents that the user has the right to access the system, i.e., establish a session with the system. every session is connected to a user and a system. the direction of the latter edge differentiates between proposed and established sessions, i.e., an edge from a session node to a system in the first case and a reversed edge in the latter. self-loops may occur in graphs during the execution of programs to select certain elements, but not beyond. an example of an access control graph is given in figure 1. the complete example is published in [hpr06]. figure 1: a state graph of the access control system proc. grabats 2006 2 / 12 eceasst we use a graphical notion of conditions to specify valid system and program states, as well as morphism. definition 1 (conditions). a condition over an object p is of the form ∃a or ∃(a, c), where a : p → c is a morphism and c is a condition over c. moreover, boolean formulas over conditions [over p] are conditions [over p]. additionally, ∀(a, c) abbreviates ¬∃(a,¬c). a morphism p : p → g satisfies a condition ∃a [∃(a, c)] over p if there exists a morphism q : c → g in m with q◦a = p [satisfying c]. an object g satisfies a condition ∃a [∃(a, c)] if all morphisms p : p → g in m satisfy the condition. the satisfaction of conditions [over p] is extended onto boolean conditions [over p] in the usual way. in the context of objects, conditions are also called constraints, in the context of rules, they are called application conditions. example 2 (access control conditions). the condition nosession = ∄( /0 → ) over the empty graph expresses that a selected user shall not have an established session, and the condition nouser = ∄( /0 → ) means that no user is selected. transformation rules form the elementary steps of our computing model. definition 2 (rules). a rule consists of a plain rule p = 〈l ← k → r〉, shortly denoted by 〈l ⇒ r〉, and a pair 〈acl, acr〉 of conditions over l and r, respectively. l is called the left-hand side, r the right-hand side, and k the interface. the conditions acl,acr are called the left and right application condition of p. l k r g d h m m∗(1) (2) a direct derivation through a plain rule p consists of two pushouts (1) and (2). we write g ⇒p,m,m∗ h , g ⇒p h , or short g ⇒ h and say that m is the match and m ∗ is the comatch of p in h . a direct derivation g ⇒p̂,m,m∗ h through a rule is a direct derivation g ⇒p,m,m∗ h through the underlying plain rule such that the match m satisfies the left application condition acl and the comatch m ∗ satisfies the right application condition acr. example 3 (access control rules). the rule selectu selects a user and the rule logoutu1 cancels an established session of a selected user. selectu: 〈 ⇒ 〉 logoutu1 : 〈 ⇒ 〉 sequential composition and iteration give rise to rule-based programs. definition 3 (programs). programs are inductively defined: skip and every rule p are programs. every finite set s of programs is a program. given programs p and q, then the sequential composition (p; q), the reflexive, transitive closure p∗ and the as long as possible iteration p↓ are programs. the semantics of a program p is a binary relation on c . programs of the form (p; (q; r)) and ((p; q); r) are considered as equal; by convention, both can be written as p; q; r. 3 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs example 4 (access control program). the program logout = selectu;logoutu1↓ selects a user and closes all of his established sessions. definition 4 (correctness). a program p with respect to a preand a postcondition is correct if, for all objects g satisfying the precondition holds: h satisfies the postcondition for every pair 〈g, h〉 in the semantics of p, there is some pair 〈g, h〉 in the semantics of p, and the program p terminates for g. concerning correctness, we are considering the following strategies: correctness by proof. a well-known method for showing the total correctness of a program with respect to a preand a postcondition is to construct a weakest precondition (wp) of the program relative to the postcondition and to prove that the precondition implies the weakest precondition. program postcondition precondition wp decide yes/no weakest precondition in [hpr06], we consider weakest preconditions for high-level programs similar to the ones for dijkstra’s guarded commands and show how to construct weakest preconditions for programs on weak adhesive hlr categories with a finite number of matches. in case of rules, the construction of a weakest precondition makes use of two known transformations [hw95, eehp06, hp05] from constraints to right application conditions, and from right to left application conditions, and additionally, a new transformation from application conditions to constraints [hpr06]. however, this method requires an algorithm for the implication problem for conditions, which may be able to decide the problem for a suitable class of conditions, and approximate the decision in the general case. moreover, the construction of weakest preconditions for programs with iteration relies on invariants, which in the general case requires an approximation or user intervention. example 5 (correctness by proof). consider the program logoutuser of example 4 and the conditions in example 2. one might verify the partial correctness of logoutuser with respect to the precondition nouser and the postcondition nosession. according to [hpr06], we construct the weakest liberal precondition wlp(logoutuser, nosession) = wlp((selectu;logoutu1↓), nosession) = wlp(selectu, wlp(logoutu1↓, nosession)). one has to show that wlp(logoutu1↓, nosession) = wlp(logoutu1∗, wlp(logoutu1, false)⇒ nosession) = wlp(logoutu1∗, ∀( /0 → , ¬appl(logoutu1)) ⇒ nosession) if wlp(logoutu1∗, ∄( /0→ )⇒ nosession) equivalent to true, hence wlp(logoutu, nosession) equivalent to true. obviously nouser implies true, hence logoutuser is correct with respect to the given conditions. for more examples, we refer to the long version of [hpr06]. correctness by transformation. given a program with preand postcondition, a correct program is derived from the input program by minimal semantical restrictions. the main idea is proc. grabats 2006 4 / 12 eceasst to insert assertions in form of applications conditions into rules within iterations of the program to enforce the invariance of postconditions. the construction is based on the integration of constraints into application conditions of rules. it makes use of the two known transformations from constraints to right application conditions (a), and from right to left application conditions (l) [hw95, hp05]. program postcondition precondition transformation correct program example 6 (correctness by transformation). consider the postcondition nosession. the program logoutuser = selectu;logoutu1↓ is transformed into a partial correct program p = assert(c);selectu;〈logoutu1, 〈ac, true〉〉∗, with constraint c = wlp(selectu, (wlp(p, false) ⇒ nosession)), and application condition ac = l(logoutu1, a(logoutu1, (wlp(p, false) ⇒ nosession))), and assert(c) = 〈〈i ⇒ i〉, 〈c, true〉〉 for any condition c over the m -initial object i. as observed in example 5, ((wlp(p, false) ⇒ nosession) is equivalent to true. a subsequent optimization step may be able to eliminate some superfluous application conditions. the strategies for ensuring correctness base on certain high-level transformations (see table 1) such as the transformations from constraints to right application conditions and from right to left application conditions. in a concrete weak adhesive hlr category, high-level transformations symbol description reference a from constraints to application conditions [hw95, hp05] l from right to left application conditions [hw95, hp05] c from application conditions to constraints [hpr06] ... table 1: high-level transformations may be applied by using a small set of elementary, structure-specific operations (see table 2) such as the constructions of pushouts and pushout complements, the set of all epimorphisms with a given domain g, the composition of two morphisms, and the m -test for morphisms. 3 system requirements the software framework should work on high-level programs, i.e., programs on high-level structures like graphs, place-transition nets, and algebraic specifications. for program specifications, i.e., programs with preand postconditions, there should be tools for correctness by proof and correctness by transformation. for the correctness strategies we identify a chain of algorithmic dependencies, see figure 2. in the figure, we exclude standard tools, e.g., checking whether a given object satisfies a given condition. the dependencies are organized in three layers; the 5 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs symbol description po construct a pushout along m -morphisms poc construct a pushout complement of two morphisms, if possible = check commutativity of two morphisms ◦ construct the composition of two morphisms initial construct morphism from initial object to input object matches find all m -matchings of one object in another epim construct an epi-m -factorization of a morphism epimorphisms construct all epimorphisms with a given domain (up to iso.) ism ? [isepi?] is the given morphism an m -morphism [epimorphism]? ... table 2: structure-specific operations correctness strategies (correctness tools) depending on high-level transformations of conditions that in turn depend on elementary structure-specific operations. for one transformation system working on graphs and for another on petri-nets, the structure-specific operations differ but the algorithms for transformation of conditions and the correctness tools remain the same. from a software engineering point of view, the components modeling correctness algorithms and weak adhesive hlr categories should therefore be loosely coupled and have as few dependencies on each other as possible. this ensures that the system can be easily extended with new weak adhesive hlr categories and high-level algorithms. � � � �correctnesstools� � � �transformations # " ! structure-specific operations correctness by proof correctness by transformation ··· al c ··· poc po matches epimorphismsinitial ism ? isepi? epim ◦ = ··· figure 2: levels in enforce 4 system design this section describes the basic software components of the enforce framework. basically, the system consists of five components: engines represent specific weak adhesive hlr cateproc. grabats 2006 6 / 12 eceasst gories, the core evaluates conditions and connects engines with the third component, transformations, that contain algorithms transforming conditions, and the application uses the four previous components to calculate the correctness results its user has requested. the components and their static dependencies are illustrated in figure 3 (a). core correctness tools transformations e n g in es application engines core transformations correctness tools application (a) (b) figure 3: (a) static dependencies and (b) runtime data flow engines. an engine is the combination of the structural implementation of a weak adhesive hlr category with a category specific implementation of the operations listed in table 2. e.g. graphengine, contains the data structures for directed labeled graphs and graph morphisms as well as the algorithms working exclusively on these structures. as enforce may have several engines the engine component is shown with a shadow. the core and transformations can use different (and new) engines without having to be modified or updated. correctness tools and transformations. these two components contain algorithms operating exclusively on weak adhesive hlr categories and can therefore be abstracted from the actual category in question. an example of algorithms working at this level is the chain of transformations from constraints to rightto left application conditions to weakest preconditions. pseudo code for the transformation from constraints to application conditions is shown in figure 4. correctness tools and transformations works on conditions, explaining their static dependency on the core. core. the core consists of two important parts: one contains data structures for programs and conditions. it also evaluates conditions with the help of operations in engines. the other part channels and controls the communication between transformations and individual engines at runtime. to facilitate communication, the core provides an interface for engine plug-ins and works as a dependency injector, explaining the runtime connection between transformations and engines. although of secondary concern, the core can execute high-level programs. most necessary parts are already implemented for other functionality: data structures modeling programs and conditions, evaluation of conditions, and the matching and pushout operation in the engines. application. this is the action initiating component of the system. the runtime data flow between the components is shown in figure 3 (b). the application contacts the core with orders 7 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs to connect the system with an engine and then uses one of the correctness tools. the application provides the graphical user interface (gui) and manages input/output for creation, saving and loading of data structures, e.g., rules, structures and morphisms. to create structures usable by an engine, the application must know the specifics of the data structures of the engine. this static dependency is illustrated in figure 3 (a). data: rule r, condition c result: the transformed result in c if c is existential or c is universal then r := r.righthandside p := c.morphism.domain b := createtupleset (initial (r), initial (p), false) if c is universal then j := new disjunction foreach (s, p) in b do j += new existential(s, subroutine (p, c)) end c := j else // c is existential j := new conjunction foreach (s, p) in b do j += new universal(s, subroutine (p, c)) end c := j end else foreach c1 in c.children do a(r, c1) end end algorithm 0: transformation a data: morphism p, morphism x, boolean check u result: the set of morphism tuples to a common codomain, in a a := new set() t, q := pushout (p, x) e := epimorphisms (t.codomain) foreach e in e do r := compose (q, e) // e o q if r in m then u := compose (t, e) // e o t if not check u or u in m then a += (u, r) end end end algorithm 0: createtupleset data: morphism p, condition c result: the transformed result in c if c is existential or c is universal then a := createtupleset (p, c.morphism, true) if c is existential then j := new disjunction foreach (u, r) in a do if c is basic then j += new existential(u) else j += new existential(u, subroutine (r, c.child)) end end else // c is universal j := new conjunction foreach (u, r) in a do j += new universal(u, subroutine (r, c.child)) end end c := j else // c is a boolean constraint foreach c1 in c.children do subroutine (p, c1) end end algorithm 0: subroutine figure 4: pseudo code for the transformation a from constraint to right application condition our current status enforce is a work in progress. a java based implementation of the core component is running. we have a working graphengine based on software from graj [bus04] and impleproc. grabats 2006 8 / 12 eceasst mentations of the transformations from constraints to rightto left application conditions. our plans include an application with a gui allowing users to experiment with the functionality promised by enforce. 5 related systems there are several related systems that may be distinguished functionally and methodically: e.g., one may distinguish between (e) transformation engines and (s) tools supporting model checking, verification or analysis (termination, confluence). tool abbreviation/synopsis reference agg attributed graph grammar system s [tae04] augur 2 analysis of hypergraph transformation system s [kk06] checkvml check visual modelling languages s [sv03] fujaba from uml to java and back s [bgn+04] groove graph based object-oriented verification s [kr06] progres programming with graph rewriting system s [swz99] graj graph programs in java e [bus04] grgen graph rewrite generator e [gbg+06] yam york abstract machine e [mp06] table 3: a selection of related systems agg [tae04] is a general development environment for attributed graph transformation systems written in java. it consists of a spo-based transformation engine, graphical editors, a visual interpreter/debugger and a set of validation tools. agg supports graph parsing, a transformation of (basic) constraints into equivalent left application conditions [hw95] and critical pair analysis, i.e., a test for confluency. augur 2 [kk06] is a tool for analyzing node-preserving hyperedge transformation systems by abstraction to so-called petri graphs: a node in a petri graph represents multiple hypergraph nodes, while token represent hyperedges. the system consists of approximating algorithms for the abstraction of hypergraph transformation system, a coverability as well as a planned reachability algorithm for deciding petri graph properties, and abstraction refinement algorithms in the case of a counterexample. checkvml [sv03] is a tool for model checking dynamic consistency properties of arbitrary visual modeling languages (e.g., uml, petri nets) by generating a model-level specification. such high-level specifications are translated into a tool independent abstract representation of transition systems defined by a corresponding meta-model. this intermediate representation is automatically translated to the input language of the back-end model checker tool spin. the fujaba tool suite [bgn+04] is primarily an uml case tool. implemented as a plugin within this framework is an approximative invariant checker [bbg+06] for conjunctions of negative existential graph conditions for transformation system with basic negative application 9 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs condition and priorities (spo with gluing condition). apart from the priorities, the method corresponds to the construction of a weakest precondition and the decision of the implication problem while ignoring the application conditions and the implicit gluing conditions of the rules (both correct approximations). graj [bus04] is a tool for executing graph programs. the system consists of a virtual machine, a compiler translating rules into graj machine code and a recently developed graphical user interface. the virtual machine provides primitives for manipulating graphs and storing the execution history of a program needed for implementing the non-deterministic behavior of programs. the graphengine of enforce will make use of graj. grgen [gbg+06] is a generative programming system for graph rewriting. it consists of a compiler for spo rules specified in a declarative language, a transformation engine called libgr written in c and a shell-like frontend for the transformation engine called grshell. grgen is aimed at attributed typed directed multigraphs, supporting various matching conditions and featuring attribute computation, relabeling and regular graph rewrite sequences comparable to graph programs. groove [kr06] is a set of (planned) tools for software model checking of object-oriented systems. it aims at directed edge-labeled graphs without parallel edges, a structure suitable for representing binary predicate logic. the groove simulator, consisting of a user interface and a spo-based transformation engine, may be used for state space generation of (finite) transformation systems. the state space is translated to a kripke structure for standard ctl model checking. progres [swz99] is a set of tools as well as a hybrid visual language for attributed graph transformation. the environment consists of graphical and textual editors supporting syntaxdirected editing of graphical specifications and incremental parsing of textual language elements, an interpreter/debugger with built-in constraint checking facilities for transformation specifications, and a compiler backend that translates graph transformations into c-code and generates a tcl/tk-based user interface for calling graph transformations and displaying manipulated graphs. yam [mp06] defines a stack-based abstract machine language for graph transformation, comparable to postscript for graphics. this includes low-level instructions as get node, get node/edge label, get source/target, add/delete/relabel node edge, to which graph transformations rules get translated to. the yam interpreter is written in c, while a compiler for translating graph rules and programs to yam code is still under development. enforce focuses on correctness of high-level programs with application conditions. its functionality will distinguish it from most tools presented here, e.g., from agg which is primarily concerned with confluency. tools concerned with correctness include augur 2, checkvml, groove and the fujaba invariant checker. due to its approximation technique, augur 2 is restricted to node-preserving hypergraph replacement system, while it will be able to check a certain fragment of monadic second order properties for hypergraphs (see [bckk04] for details). groove is a model checker tool and will be able to handle arbitrary edge-labeled graph transformation systems with application conditions once abstraction is added to its features, while the type of checkable properties depends on the used abstraction. the fujaba invariant checker is concerned with story patterns (= graph transformation rules with basic negative application conditions) and considers a small, decidable fragment of first-order logic. enforce aims at full first-order properties. proc. grabats 2006 10 / 12 eceasst 6 conclusion enforce is a suite of tools for ensuring the correctness of high-level programs. it is designed for weak adhesive hlr categories, exploiting the fact that necessary high-level algorithms can be based on a small set of structure-specific methods. structurally, enforce consists of applications (e.g., user interface), correctness tools (e.g., for correctness by construction), engines (i.e., specific data structures and methods for a weak adhesive hlr category) and a core containing general high-level notions and methods, connecting engines with the rest of the system. this separation allows us to include new categories with a minimum of effort and to develop new correctness tools and transformation which instantly work with any engine. while developing more efficient algorithms for a category, the ability to quickly exchange engines could be useful for comparing the performance. further topics could be the following: (1) engines for other weak adhesive hlr categories, like the categories of place-transition nets, hypergraphs, or typed attributed graphs. (2) adapters for other existing transformation engines like yam or grgen. adapters provide an interface and complete functionality, if necessary. (3) further correctness tools and transformations like semantic converters of conditions and rules, for switching the satisfiability and matching notions from arbitrary morphisms to m -morphisms and vice versa [hp06], or a tool for proving the conflictfreeness of specifications. (4) the construction of a correct program from a specification in form of a preand postcondition, e.g., see [lehs06]). acknowledgements: this work is supported by the german research foundation (dfg), grants grk 1076/1 (graduate school on trustworthy software systems) and ha 2936/2 (development of correct graph transformation systems). bibliography [bbg+06] b. becker, d. beyer, h. giese, f. klein, d. schilling. symbolic invariant verification for systems with dynamic structural adaptation. in proc. of the 28th int. conference on software engineering (icse’06). pp. 72–81. acm press, 2006. [bckk04] p. baldan, a. corradini, b. könig, b. könig. verifying a behavioural logic for graph transformation systems. in proc. of cometa ’03. entcs 104, pp. 5–24. elsevier, 2004. [bgn+04] s. burmester, h. giese, j. niere, m. tichy, j. p. wadsack, r. wagner, l. wendehals, a. zündorf. tool integration at the meta-model level: the fujaba approach. journal on software tools for technology transfer (sttt) 6(3):203–218, 2004. [bus04] g. busatto. graj: a system for executing graph programs in java. technical report 3/04, university of oldenburg, 2004. available at [uni]. 11 / 12 volume 1 (2006) enforce: a system for ensuring formal correctness of high-level programs [eehp06] h. ehrig, k. ehrig, a. habel, k.-h. pennemann. theory of constraints and application conditions: from graphs to high-level structures. fundamenta informaticae 74:135–166, 2006. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs of theoretical computer science. springer-verlag, berlin, 2006. [gbg+06] r. geiß, v. batz, d. grund, s. hack, a. m. szalkowski. grgen: a fast spo-based graph rewriting tool. in graph transformations (icgt’06). lncs 4178, pp. 383– 397. springer, 2006. [hp05] a. habel, k.-h. pennemann. nested constraints and application conditions for high-level structures. in formal methods in software and system modeling. lncs 3393, pp. 293–308. springer, 2005. [hp06] a. habel, k.-h. pennemann. satisfiability of high-level conditions. in graph transformations (icgt’06). lncs 4178, pp. 430–444. springer, 2006. [hpr06] a. habel, k.-h. pennemann, a. rensink. weakest preconditions for high-level programs. in graph transformations (icgt’06). lncs 4178, pp. 445–460. springer, 2006. a long version is available as technical report at [uni]. [hw95] r. heckel, a. wagner. ensuring consistency of conditional graph grammars — a constructive approach. in segragra’95. entcs 2, pp. 95–104. 1995. [kk06] b. könig, v. kozioura. augur 2 — a new version of a tool for the analysis of graph transformation systems. in proc. workshop on graph transformation and visual modeling techniques (gt-vmt’06). entcs. elsevier, 2006. to appear. [kr06] h. kastenberg, a. rensink. model checking dynamic states in groove. in model checking software (spin). lncs 3925, pp. 299–305. springer, 2006. [lehs06] m. lohmann, g. engels, r. heckel, s. sauer. model-driven monitoring: an application of graph transformation for design by contract. in graph transformations (icgt’06). lncs 4178. springer, 2006. [mp06] g. manning, d. plump. the york abstract machine. in proc. graph transformation and visual modelling techniques (gt-vmt’06). entcs. elsevier, 2006. to appear. [sv03] á. schmidt, d. varró. checkvml: a tool for model checking visual modeling languages. in proc. uml 2003: 6th international conference on unified modeling language. lncs 2863, pp. 92–95. springer, 2003. [swz99] a. schürr, a. j. winter, a. zündorf. the progres approach: language and environment. in handbook of graph grammars and computing by graph trans. volume 2, pp. 487–550. world scientific, 1999. [tae04] g. taentzer. agg: agraph transformation environment for modeling and validation of software. in proc. application of graph transformations with industrial relevance (agtive’03). lncs 3062, pp. 446–453. springer, 2004. [uni] http://formale-sprachen.informatik.uni-oldenburg.de/pub/eindex.html. proc. grabats 2006 12 / 12 introduction correctness of programs system requirements system design related systems conclusion uncertainty entangled; modelling safety assurance cases for autonomous systems electronic communications of the easst volume 079 (2020) interactive workshop on the industrial application of verification and testing etaps 2020 workshop (interavt 2020) uncertainty entangled; modelling safety assurance cases for autonomous systems anila mjeda and goetz botterweck 10 pages guest editors: stylianos basagiannis, goetz botterweck, anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst uncertainty entangled; modelling safety assurance cases for autonomous systems anila mjeda and goetz botterweck lero–the irish software research centre university of limerick limerick, ireland name.surname@lero.ie abstract: when designing and analysing autonomous systems and their environment it is necessary to consider uncertainty and multiple potential states (of the system and its environment). in this position paper, we explore the idea of notations and modelling tools that are based on ‘superpositions’ of states. more concretely, we present a treatment of uncertainty in autonomous systems inspired by quantum physics and propose an extension of the goal structuring notation (gsn), a common approach for the modelling of safety arguments, to model ’superposition’ and ’entangled’ nodes; and, incorporate guidelines of the emerging ul 4600 standard for autonomous systems. keywords: autonomous vehicles; uncertainty; safety assurance cases; gsn, ul 4600 1 introduction i am sitting with a philosopher in the garden; he says again and again ‘i know that that’s a tree’, pointing to a tree that is near us. someone else arrives and hears this, and i tell him: ‘this fellow isn’t insane. we are only doing philosophy. ludwig wittgenstein, on certainty in safety-critical systems, it is critical to give grounds for why the software can be trusted. current trends on autonomous vehicles (avs) heighten the challenge of assuring they are safe, especially in view that avs need to operate in unpredictable situations and to make real-time decisions which so far have been the remit of human drivers. part of the challenge stands with the fact that developing autonomous systems, entails designing for uncertainty [rjc12, fc19] which in turn exacerbates the need for uncertainty-aware software development methodologies [fc19]. one technique used by classic (not fully autonomous) safety-critical domains is the submission of a safety assurance case that provides a documented trail, which demonstrates that state of the art safety considerations have been followed and are traceable throughout the system. this, in essence, entails showing that the potential risks associated with using the safety-critical system 1 / 10 volume 079 (2020) uncertainty entangled; modelling safety assurance cases for autonomous systems in its intended domain have been identified and acceptably mitigated. it provides the grounds to convince the certification bodies (e.g. [rtc11, iso11, fa+10, iso19]) and other stakeholders that the system is acceptably safe [lev11, hhkm13, dp18]. using safety assurance cases in avs is still a new and brave frontier. that said, existing research of particular interest for the focus of this paper is the emerging standard1 for autonomous systems [und19] and research on treatments of uncertainty [fc19]. in this position paper, we take a multidisciplinary lens to the treatment of uncertainty. we draw ideas from quantum physics where uncertainty has been treated as a domain-native for decades to posit our ideas on modelling uncertainty for autonomous systems. we also build on previous work by [dp18] and [und19] and propose an extension to the goal structuring notation (gsn)2. the remainder of this paper is organised as follows: in section 2 we discuss safety assurance cases and the latest developments in this area. in section 3 we discuss the concept of uncertainty from a multidisciplinary point of view and present our position in the treatment of uncertainty and its implications for autonomous vehicles (including a running example in section 3.1). in section 4 we propose our ideas extending gsn to capture autonomous assurance cases and finally we draw conclusions in section 5. 2 assurance cases assurance cases are a technique used to argue that a system is safe for a given application in a defined environment. formally, the assurance case is a “reasoned, auditable artifact created for contention that its top-level claim (or a set of claims), is satisfied, including systematic argumentation and its underlying evidence and explicit assumption(s) that support the claim.” [iso19]. simply put, assurance cases are structured arguments backed by evidence on why a specific safety goal or claim is met. the typical anatomy of a safety case consists of (1) the safety goal (typically split into sub-goals) that needs be achieved; (2) the backing evidence for achieving this goal; and, (3) the structured argument, which establishes the systematic relationship between the evidence and the goals. both the arguments and the evidence can be somewhat informal. as such, the arguments can express some degree of confidence, while the backing evidence can take multiple forms such as results from model checking, testing, analysis, modeling, simulation; or, expert opinions. an in-depth analysis of assurance cases and exiting tool support for them can be found in [dp18]. while there is no particular notation required, the goal structuring notation (gsn) [scs18], is adopted widely. figure 1 provides an illustration of a safety argument in gsn notation constructed for the duckietown environment3. the nodes in gsn provide a simple description for the goals, strategies, assumptions, 1 the standard for safety for the evaluation of autonomous products, ul 4600 is being developed as a ul – underwriters laboratories standard by a standards technical panel (stp) composed from researchers and practitioners from industry and academia. it is projected to be ratified as a ul standard in the first half of 2020. 2 a graphical notation which is adopted widely to capture safety assurance cases 3 this simplified diagram is extracted from our work-in-progress research in safety arguments for autonomous vehicles where the duckietown environment (from an mit classroom started activity: www.duckietown.org) is used as a running example. interavt 2020 2 / 10 eceasst g1 vision-based line following behaviour is correct at all times g2 track illumination variability is compensated correctly s1 argue over reasons that cause lane following failures a1 assume that camera is working correctly a2 assume acceptable lighting conditions g3 illumination compensation req. uncertainties are mitigated g4 illumination compensation design uncertainties are mitigated g5 road markings are detected correctly g6 correct recall uncertainties are mitigated g7 false positive uncertainties are mitigated e2 simulation testing results g8 lane-relative estimation is correct at all times e1 illumination compensation req. spec. model s2 argue over uncertainty of prior belief in track illumination conditions s3 argue over uncertainty of correct recall s4 argue over uncertainty of false positives a3 assume a mean time failure of > 30 minutes is acceptable a4 assume a cross track error < = 1.5 cm is acceptable … safety requirements: the duckiebots follow lanes in a track built according to specification j1 prior belief uncertainty taxonomy (patterns to choose from) … … g1-n: goal s1-n: strategy a1-n: assumption j1-n: justification e1-n: evidence figure 1: a partial safety argument in gsn notation justifications and evidence and are meant as pointers to fully detailed artifacts. the aim is to trace all of the safety goals to credible evidence without gaps in coverage and where all assumptions are analysed vis-à-vis their validity. not surprisingly, assurance cases are especially useful in situations where the system is too complex to be ‘proven’ safe using formal verification approaches or more broadly when heavy-weight formal approaches are not feasible to be used. a promising development for the world of assurance cases is ul 4600 [und19] which aims to support a structured way to argue that autonomous vehicles are safe. its first version focuses in highly automated vehicles and looks at the challenges of av safety in the absence of human drivers and presence of non-determinism. it looks at all the different functionality provided by human drivers including fault recovery and expected misuse. the goal of ul 4600 is to provide guidance on adopting the required system-level engineering rigour and is meant to be used alongside the other standards that regulate the domain (e.g., iso 26262) [iso11]. that said, in contrast to, say, iso26262, instead of prescribing ‘how to do safety’, ul 4600 is goal-based and makes use of assurance cases to argue in a structured way that the system is acceptably safe [pk19]. typically the safety goal defines what acceptably safe means for the case in question and then it proceeds to argue how the av meets that definition. it does not prescribe any specific software engineering approaches but it requires the use of rigorous ones. for example, it does not prescribe how to do testing and verification, but it rather requires a sound argumentation that you have done sufficient testing and verification. its creators see it as a framework for systematically putting together all of the elements needed to create an acceptably safe av. it facilitates this task by providing reference lists, lists of safety case topics, prompts and epistemic defeaters (‘did you consider what happens in cases of black ice?’), reference lists of hazards and lists of techniques that can be used to identify hazards, good 3 / 10 volume 079 (2020) uncertainty entangled; modelling safety assurance cases for autonomous systems practices to follow and bad practices to avoid [pk19]. all the prompts provided by ul 4600 need to be considered but not necessarily adopted, and for guidance they are classified into: • mandatory – prompts that are required to be considered. • highly recommended – prompts that can be ignored or altered with non-trivial rationale. • examples – prompts that are meant as illustrative reminders and not required do be addressed exhaustively. • recommended –prompts that are entirely optional. 3 reasoning with uncertainty uncertainty has been studied in many disciplines and a significant amount of research has focused on analysing and interpreting it [hei27, ms58, laf, tk74, gps08, tk94, cw04, kni12]. in economics, typically uncertainty is treated as a stochastic or probabilistic situation [laf], where the frequency or outcome of an event is not known [gps08] including situations where it is not possible to specify definite numerical probabilities for a specific (desired) outcome [kni12]. treatments of uncertainty in economical studies often intersect with uncertainty in decision making and project management (e.g., [jaa01, pgw08]). in psychology, uncertainty is typically discussed against the backdrop of certainty and is conceptualized as a psychological state. wittgenstein posited that being ‘certain’ is not any ‘knowing’ but it rather is a matter of us feeling that ’we cannot imagine otherwise’4 [wav86]. this somewhat non-deterministic treatment of uncertainty resonates with quantum physics where what is commonly referred to as the ’uncertainty principle’ is one of the key concepts that brought forward a revolution on our understanding of the universe. uncertainty in quantum physics can be considered ’native’, and yet its meaning is subject to different schools of thought and interpretations. different conceptualisations of uncertainty include ontological interpretations (lack of knowledge by an observer) and, epistemic interpretations (e.g., measurement inaccuracy). in fact, even the terminology comprises a range of words such as indeterminacy, indefiniteness and, inaccuracy. at the heart of both the thought revolution; and, lack of consensus and generational debates brought forward by quantum theories is the issue of how (and whether) the measurement process affects the ontological state of an observed system (and in some interpretations the observer her/himself) and it has even entered common parlance as ‘the measurement problem’. for us, in dealing with uncertainty in autonomous systems, this struggle is mirrored in the somewhat ‘simpler’ struggle of developing a measure of uncertainty that we know how do deal 4 please note how wittgenstein’s thinking connects to nicolaus copernicus (1473–1543) and to the quantum physicist hugh everett iii (1930–1982) who gave us the multiverse quantum hypothesis (referred to as ‘the branching world’ below): “bryce dewitt, an american physicist who had edited the journal where everett’s thesis appeared, wrote a letter to him complaining that the real world obviously didn’t ‘branch’, since we never experience such things. everett replied with a reference to copernicus’s similarly daring idea that the earth moves around the sun, rather than vice-versa: ‘i can’t resist asking: do you feel the motion of the earth?’ dewitt had to admit that was a pretty good response.” – sean carroll, something deeply hidden interavt 2020 4 / 10 eceasst with operationally. borrowing from the quantum physics’ thought experiments we can posit that we can profitably reason about the behaviour of autonomous vehicles if we know a probability distribution of the likelihood that the av might be behaving in various ways. entanglement (in quantum physics), at its simplest, suggests that when two particles interact or share spatial proximity, their behaviour becomes intrinsically linked even after they are far apart. say two electrons were moving with equal opposite velocities and they bump onto each other. even though before their encounter they each had probabilities of travelling in certain paths which were completely unrelated to each other, after their encounter they will move in precisely opposite directions. we say that the electrons are entangled5. now let us draw our attention to the ’macro’ world of avs and conceptualise them as entities that have different probability distributions of the likelihood of behaving in various ways. we use the entangled uncertainties metaphor to posit that we should design for uncertainty by conceptualizing our design choices as superimposed ontological representations of reality. our overall design for uncertainty resembles a ‘solutions superposition-model’ 6. where, each solution taken (in other words the av’s behaviour at a specific time-step matches that particular solution), entangles the uncertainty in the av behaviour within at least the next time step (the length of the time step would depend on when the next interaction of the av will cause the uncertainties of its behaviour to become entangled with the environment (e.g., bumps into the next thing). hence the intuition is that if we have enough ’certain’ solutions designed in our ’solutions superposition-model’ we can draw upon the ’entanglement of uncertainties’ argument and collapse the problem-space into certain outcomes for the av behaviour. in more lay terms, this translates into arguing about narrowing down the all possible behaviours’ state-space into a subset of (designed for) acceptably safe behaviour by an av. while we characterise possible av behaviours as probability distributions, another point of frustration we need to clarify is the meaning we give to probability. one school of thought sees the concept of probability connected to the frequency of an event or outcome happening/occurring. that is perfectly satisfying for cases when we can wait to witness the same exact event reoccurring over and over for a large number of repetitions. how often do we get tails if a coin is tossed? but, how do we reason for cases when we are in reality dealing with epistemic probability, where what we already know is important to help us gauge the outcome. even more so in cases when waiting for a very large number of occurrences or experiments upon some events is not plausible. for example, what is the probability of the soccer team of ones’ own country will win the world championship? in these cases, we can reason in terms of attaching beliefs between zero and one hundred percent to the various possible outcomes where the total set of beliefs for the possible outcomes adds up to 100 percent7. next, let us consider some illustrative examples of uncertainties in an autonomous environment. 5 in the everettian view of quantum physics the entanglement (e.g., how do the two entangled electrons ‘know’ what the other is doing) is described via the universal wavefunction, in other words, positing that the quantum state of the whole universe in ’interlinked’ and can be ’captured’ in one wave function. 6 here the superposition-model plays on the quantum concept of superposition 7 in this regard, there are existing mathematical frameworks such as for example dempster-shafer theory which acknowledge the need for explicitly expressing and quantifying beliefs/confidence/lack of confidence into a certain outcome. 5 / 10 volume 079 (2020) uncertainty entangled; modelling safety assurance cases for autonomous systems 3.1 no duck left behind – uncertainty in duckietown duckietown [pta+17] is an environment that started at mit and is aimed at education and research in autonomous vehicles. duckieworld is comprised of avs (“duckiebots”) that autonomously drive their users (“duckies”) around their town (“duckietown”) that has roads, traffic lights, and obstacles. the duckiebots can follow lanes while abiding traffic lights and avoiding random obstacles and the duckie pedestrians. their only sensor is a monocular camera and all their on-board processing is done in a raspberry pi. one of the interesting aspects of the duckiebots for us is that they face a number of software and environment uncertainties (figure 1), that include: • prior beliefs on illumination conditions of the roads. • prior beliefs on road-markings colours (the duckiebots navigation depends on colour-coded markings). • errors in the estimation of fit quality that allows the system to detect road-marking detection failure. • false positives in road-markings’ detection. • errors in lane-relative estimation. in the following section, we use these uncertainties as our running example to illustrate our position in designing for uncertainty. 4 gsn entangled – designing for uncertainty we propose to extend gsn nodes with metadata (building on research by [dp18]) to: a) accommodate our vision of ‘solutions superposition-model’ to model autonomous systems; and, b) incorporate the extensive reference lists, different types of prompts and epistemic defeaters provided by the emerging ul 4600 standard as natural elements of our treatment of uncertainty (’entangled uncertainties’). specifically, to account for superposition-model nodes and our treatment of ‘entangled uncertainties’ we propose to extend the gsn node types with: • nodetype ::= classic | superposition | entangled note that when the node type is classic the node will look exactly as any other classic gsn node. to account for respectively the need to express beliefs in certain outcomes and ul 4600’s prompt classifications, we extend the parameter types of gsn nodes with: • belief ::= percentageindecimalnumber • prompttype ::= mandatory | highyrecommended | example | recommended | as discussed in the previous sections, these ideas hail from our treatment of uncertainty and more specifically from our thought experiments on ‘entangled uncertainties’. in figure 2 we illustrate these ideas via a partial assurance case that captures some of the software and environment uncertainties faced by the duckiebots (our running example of an autonomous environment). in here, the overall safety goal that ’duckiebots will not hit any types of duckies’, interavt 2020 6 / 10 eceasst g1 duckiebots will not hit any types of duckies [ 0.9 ] e1 results of analysis of coverage of different types of duckies a3 assume false positive uncertainties are mitigated g2 prompttype: mandatory duckiebots will stop or avoid collision with detected duckies g3_meta type: superposition identify and mitigate risks caused by difficult to detect duckies g4_meta type: entangledgoal belief: 0.9 all mitigations are identified and are sufficient g5_meta type: entangledgoal belief: 0.1 fault response and violation strategy include feedback to accident log a1 assume that camera is working correctly a2 assume acceptable lighting conditions e2 results of detect and avoid simulation testing g3_meta type: superposition prompttype: mandatory identify and mitigate risks caused by difficult to detect duckies [ 0.1 ]… … figure 2: partial assurance case illustrating uncertainties in extended gsn notation under the assumptions that duckies’ cameras are working correctly and they have to operate within acceptable lighting conditions8 is split into two sub-goals: 1) ’duckiebots will stop or avoid collision with detected duckies’; and, 2) ’identify and mitigate risks caused by difficult to detect duckies’. the later goal is modelled via a nodetype: superposition and both sub-goals have the parameter prompttype: mandatory in their metadata. the prompttype: mandatory parameter incorporates ul 4600 in gsn notation, while nodetype: superposition reflects our ideas on ‘entangled uncertainties’. we incorporate the concept of ‘entangled’ probability distributions by modelling the two ‘entangled’ nodes (’all mitigations are identified and are sufficient’ and, ’fault response and violation strategy include feedback to accident log’) that come out of the superposition node (’identify and mitigate risks caused by difficult to detect duckies’) by using the parameter type belief : percentageindecimalnumber. this (extended) gsn node’ metadata is expressed via a (real) decimal number (or probability), where all the entangled nodes’ beliefs that come out of a superposition type node add up to 1 (100%). this is particularly important since we believe that as the technology behind quantum computing progresses further we expect to benefit from the real power of notations and modelling tools that ‘think’ in terms of superpositions |ψ〉 of the two classical states |0〉 and |1〉 coded in quantum memory (for example in the same qubit): 8 naturally this would translate into accepted weather conditions’ in real-world scenarios. 7 / 10 volume 079 (2020) uncertainty entangled; modelling safety assurance cases for autonomous systems |ψ〉 := α |0〉+ β |1〉= ( α β ) ; where, |α|2 +|β|2 = 1. in here, the coefficients α and β are complex numbers9 and tie in nicely with our ‘entangled nodes’ with assigned probability beliefs, since in quantum theories |α|2 and |β|2 represent exactly the probability of a state being observed. finally, figure 2 illustrates examples of evidence (’results of analysis of coverage of different types of duckies’, and ’results of detect-and-avoid simulation testing’) that are used to back up the assurance case’s claims. 5 conclusions the current drive for autonomous systems will benefit from rigorous uncertainty-aware software engineering methodologies. we believe that software engineering could profitably build upon treatments of uncertainty from other disciplines that, in different capacities, have dealt for decades with uncertain environments, measurements, projections, occurrences, etc. the current safety assurance demands on autonomous systems could benefit from a paradigm shift towards ‘complex-state’ modelling. this, in conjunction with the gained momentum in quantum computing, could be fostered by notations and modelling tools that ‘think’ in terms of superpositions and make use of quantum memory (as in nodes conceptualised as quantum states |ψ〉 := α |0〉+ β |1〉= ( α β ) ; where, |α|2 +|β|2 = 1. and, |0〉 & |1〉 represent of the two classical states.) in this paper, we explore a conceptualisation of uncertainty in autonomous systems inspired by quantum physics which sees uncertainty as a native feature of a system. furthermore, we propose an extension of gsn (building on research by [dp18]) to: a) accommodate ‘superposition’ and ‘entangled’ nodes; and, b) incorporate the extensive reference lists, different types of prompts and epistemic defeaters provided by the emerging ul 4600 standard as natural elements of our treatment of uncertainty (‘entangled uncertainties’). in future work, we plan to focus on modelling and validating live feedback that drives the update of beliefs in probability distributions. acknowledgements this work was supported, in part, by science foundation ireland grant 13/rc/2094 and co-funded under the european regional development fund through the southern & eastern regional operational programme to lero the irish software research centre (www.lero.ie). bibliography [cw04] c. chapman, s. ward. why risk efficiency is a key aspect of best practice projects. international journal of project management 22(8):619–632, 2004. 9 in quantum mechanics they are the amplitudes of the wave function. interavt 2020 8 / 10 eceasst [dp18] e. denney, g. pai. tool support for assurance case development. automated software engineering 25(3):435–499, 2018. [fa+10] u. food, d. administration et al. guidance for industry and fda staff-total product life cycle: infusion pump–premarket notification. draft guidance (april 2010), 2010. [fc19] m. famelis, m. chechik. managing design-time uncertainty. software & systems modeling 18(2):1249–1284, 2019. [gps08] i. gilboa, a. w. postlewaite, d. schmeidler. probability and uncertainty in economic modeling. journal of economic perspectives 22(3):173–88, 2008. [hei27] w. heisenberg. uber den anschaulichen inhalt der quanten theoretischen kinematik und mechanik, zeit. für phys., 43, 172–198. available in english translation: goo. gl/fmq2j7, 1927. [hhkm13] r. hawkins, i. habli, t. kelly, j. mcdermid. assurance cases and prescriptive software safety certification: a comparative study. safety science 59:55–71, 2013. [iso11] iso. iso 26262: road vehicles-functional safety. international standard iso/fdis 26262, 2011. [iso19] iso/iec/ieee 15026: systems and software engineering — systems and software assurance . standard, iso/iec/ieee international organization for standardization, 2019. [jaa01] a. jaafari. management of risks, uncertainties and opportunities on projects: time for a fundamental shift. international journal of project management 19(2):89–101, 2001. [kni12] f. h. knight. risk, uncertainty and profit. courier corporation, 2012. [laf] j. laffont. j., 1989, the economics of uncertainty and information. [lev11] n. g. leveson. the use of safety cases in certification and regulation. 2011. [ms58] j. g. march, h. a. simon. organizations. wiley, 1958. [pgw08] o. perminova, m. gustafsson, k. wikström. defining uncertainty in projects–a new perspective. international journal of project management 26(1):73–79, 2008. [pk19] d. prince, p. koopman. ul 4600 technical overview. technical presentation at carnegie mellon university, oct 2019. https://users.ece.cmu.edu/∼koopman/talks/191010 ul4600 tech webinar.pdf [pta+17] l. paull, j. tani, h. ahn, j. alonso-mora, l. carlone, m. cap, y. f. chen, c. choi, j. dusek, y. fang et al. duckietown: an open, inexpensive and flexible platform for autonomy education and research. in 2017 ieee international conference on robotics and automation (icra). pp. 1497–1504. 2017. 9 / 10 volume 079 (2020) https://users.ece.cmu.edu/~koopman/talks/191010_ul4600_tech_webinar.pdf uncertainty entangled; modelling safety assurance cases for autonomous systems [rjc12] a. j. ramirez, a. c. jensen, b. h. cheng. a taxonomy of uncertainty for dynamically adaptive systems. in 2012 7th international symposium on software engineering for adaptive and self-managing systems (seams). pp. 99–108. 2012. [rtc11] rtca. do-178c, software considerations in airborne systems and equipment certification. rtca, 2011. [scs18] goal structuring notation community standard version 2. standard, 2018. [tk74] a. tversky, d. kahneman. heuristics and biases: judgement under uncertainty. science 185(4157):1124–30, 1974. [tk94] b. n. taylor, c. e. kuyatt. guidelines for evaluating and expressing the uncertainty of nist measurement results. 1994. [und19] underwriters laboratories. standard for safety for the evaluation of autonomous products, ul 4600 (draft). december 2019. https://edge-case-research.com/wp-content/uploads/2019/12/191213 ul4600 votingversion.pdf [wav86] l. wittgenstein, g. anscombe, g. von wright. on certainty/über gewissheit. harper collins, 1986. interavt 2020 10 / 10 https://edge-case-research.com/wp-content/uploads/2019/12/191213_ul4600_votingversion.pdf https://edge-case-research.com/wp-content/uploads/2019/12/191213_ul4600_votingversion.pdf introduction assurance cases reasoning with uncertainty no duck left behind – uncertainty in duckietown gsn entangled – designing for uncertainty conclusions interactive strategy-based validation of behavioral models electronic communications of the easst volume 58 (2013) proceedings of the 12th international workshop on graph transformation and visual modeling techniques (gtvmt 2013) interactive strategy-based validation of behavioral models ralf teusner, gregor gabrysiak, stefan richter, and stefan kleff 12 pages guest editors: matthias tichy, leila ribeiro managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst interactive strategy-based validation of behavioral models ralf teusner, gregor gabrysiak, stefan richter, and stefan kleff {firstname.lastname}@hpi.uni-potsdam.de hasso plattner institute for software systems engineering, university of potsdam, germany abstract: when behavioral models are derived automatically based on observed stakeholder interactions, requirements engineers need to validate whether the stakeholders agree with the synthesized behavioral models. allowing stakeholders to experience such models through simulation and animation allows them to comment on, amend to and correct these models. however, to ensure an efficient stakeholder validation, the simulation has to be guided instead of confronting the user with random situations over and over again. in this paper, we present a strategy-driven simulator capable of guiding the execution of behavioral models based on graph transformations. by analyzing either the overall structure of a partial state space (look ahead) or by performing an in-depth analysis of the states therein, the simulator is able to determine which transformations should be executed next to continue on the most promising path through the overall state space. the discussed implementation is illustrated with a case study. keywords: requirements simulation, stakeholder validation, simulation strategy 1 introduction capturing requirements and scenarios in formal models such as graph transformations introduces a communication barrier between requirements engineers and stakeholders. nevertheless, the latter have to understand what was elicited and specified to identify conflicts, find errors or provide feedback. especially in highly collaborative scenarios involving multiple stakeholders and their individual perspectives on what is to be accomplished, gathering knowledge about the stakeholders’ scenarios is inherently complex. in our earlier work, we presented a combined animation [ggs09] and simulation [ggs10, ghg12] approach capable of deriving graph transformations that represent observed activities (cf. generalization in [hec06]) within such collaborative scenarios. based on the differences between two succeeding states prior and after a stakeholder activity was observed, a behavioral specification is derived which encapsulates the changes associated with the activity. for this specification, story patterns [knnz00] are used. furthermore, these story patterns can later on be rearranged and replayed to simulate any stakeholder activities that were already observed. by executing the corresponding graph transformations of stakeholders, their actions and interactions can be simulated and visualized for stakeholders participating in the simulation. eventually, the activities of all stakeholders have been observed and captured in story patterns. then, the requirements engineers end up with story patterns which, when executed, can simulate the commonly agreed upon scenarios that can unfold for the stakeholders. 1 / 12 volume 58 (2013) interactive strategy-based validation of behavioral models being able to replay specific activities of any of the roles involved in the explored scenarios enables individual stakeholders to participate as one of the roles. as a participant, this stakeholder is then able to experience and validate, whether the behavioral models that are executed are correct, consistent from his point of view and complete, i.e. covering at least all of his known information for the considered scenario. to ensure that the paths chosen during the simulation of a scenario do not always lead to the same, already validated situations, the decisions of the simulator, i.e. of the individual roles that are simulated, need to be guided in different directions to provoke the participant to play-in alternative scenarios. by navigating through the state space, the simulator can specifically guide the stakeholder through a conflicted scenario. a scenario has to be considered as conflicted if it contains states which yield possibly wrong outcomes or unwanted effects. examples are traces leading to dead ends and situations that are impossible in reality such as having a negative amount of goods or inconsistencies such as an inquiry that is both accepted and rejected. thereby, unidentified constraints which the participants can point out afterwards are then be captured as “forbidden situations” that are avoided during future simulations. by generally avoiding dead ends, on the other hand, the simulator can ensure that the stakeholder experiences a scenario that can successfully terminate. such a scenario simulation can be guided more effectively if the consequences of the available decisions are known. if the complete state space, i.e. information about all possible states and the transitions between them, is explored, all eventually occurring consequences and their side-effects are known. however, it is not feasible to compute all possibilities beforehand, especially since the state space might be infinite. still, to avoid solely relying on impromptu or even random decisions, a limited preview of the state space (i.e. look ahead) is already helpful. moreover, the state space that can be explored depends on the story patterns which were already captured, i.e. played in by participants. thus, the state space supports a guided simulation only in cases in which the participant’s actions were known in the form of expected inputs for the simulation. since participants can interact with the simulation within their visualization, they can directly change the state of the simulation (cf. play-in [hm03]). in such cases, the simulator is confronted with inputs that were unexpected for the current state. still, such an input may be equivalent to a sequence of other activities which implies that the actual follow-up state of the simulation is already included in the state space. consequently, the participant played in an alternative which would result in a new transition within the state space. still, if the participant’s activity was new and without an equivalent sequence of other activities, then the simulator would be in a follow-up state which was not covered by any state space that might have been calculated beforehand. in such a situation, a feasible guidance of the simulation can only be provided, if a look ahead can be computed fast enough at runtime so that the simulation is still perceived as interactive for the participating stakeholders. the stakeholders’ perspective of the simulation is discussed in [ggs09]. this partial perspective on the simulation is not sufficient for the requirements engineer, who needs a more technical perspective on the simulation, so he should be supplied with an interactive visualization of not only the current state of the simulation, but also of its look ahead. the conceptual contribution of this paper is a bounded look-ahead for graph transformation systems which incorporates strategies and cost functions to explore the potentially infinite state space more effectively. the main contribution is an eclipse-based simulation environment, that supports engineers to interactively proc. gtvmt 2013 2 / 12 eceasst validate the requirements by automatically guiding the simulation. the concepts underlying the strategy-based simulation approach are presented in section 2. then, section 3 illustrates the implementation using a steelworks case study. afterwards, related work is discussed in section 4 which focusses on graph transformation approaches. finally, conclusions are drawn and future work is outlined in section 5. 2 concepts 2.1 navigation and reduction to fulfill the outlined requirements, several different concepts are employed. an interactive navigation is only feasible, for technical as well as user-interface reasons, if the graph-structure in scope is kept small enough so that the time for the computation of what to do next and the actual execution take less than one second. nevertheless, the regarded state space has to be complete and correct concerning the already established constraints. the user’s main focus of interest lies in all future states outgoing from the current one. since the amount of future states might be unlimited, possible future states are limited by the introduction of a maximal look ahead depth, after which the simulation of further states is simply aborted. another reduction is achieved by aborting the simulation behind states that violate predefined conditions as illustrated by s5 in figure 1a. despite that, the growth of states still correlates exponentially with the chosen look ahead depth. by merging two or more instances of an identical states into one, the exponential growth can at least be postponed (cf. figures 1b and 1c). this results in a potentially cyclic graph, but reduction of branches enhances lucidity and performance significantly. the effectiveness of this technique is determined by the depth, at which the merging takes place (the earlier the better). stakeholders should not encounter situations which are known to be impossible or invalid, e.g. situations in which a budget is exceeded or a time constraint is violated. usually, such situations can be specified as partial states or as a sequence of states which must not occur. to avoid these situations, the simulator has to check whether one of them can be matched in one of the states of the look ahead. if so, the corresponding path can be excluded, i.e. cut-off as early as possible [hhv10], from the options that are available to the stakeholder from the current state of the simulation onwards. sx s7 s1 s10 s8 s9 s11 s12 a b c c a f f s2 d s3 s13 s4 c a d d s5 b s6 c d (a) a look ahead (depth=3) which contains a forbidden state (s5) and the infinite state space sx s7 s1 s10 s8 s9 s11 s12 a b c c a f s2 d s3 s4 c a d (b) simplified look ahead with a depth of 3 sx s7 s1 s10 s8 s3 s11 a b c c f s2 ds4 c a d a (c) final look ahead after merging (s3,s9) and (s8,s12) figure 1: steps of reduction before scoring the look ahead 3 / 12 volume 58 (2013) interactive strategy-based validation of behavioral models 2.2 guidance and scores if the available story patterns are underspecified, they will be matched and executed more often than necessary. consequently, states with many available story patterns might imply that some of these patterns are underspecified and need to be revised. however, only a stakeholder can decide which of the patterns should match in the corresponding state and which patterns require a stricter precondition. to support a stakeholder in identifying such patterns, a strategy that scores the number of alternatives is required which chooses the path leading to the most alternatives for further execution. this can be determined based on the look ahead: by scoring the structure of the look ahead, e.g. by adding up the number of outgoing transitions of each of its states, the simulator can simply choose the sequence of transitions which provides the most alternatives. to enable a participating stakeholder to resolve a specific situation (e.g., what do you do if you are over-budget?), the simulator has to reach a corresponding state. the requirements engineer needs to create a strategy that scores the value of the corresponding resource, in this case “budget”, negatively which, in turn, favors all activities that decrease the value of this resource. scoring is based on increasing and decreasing amounts of resources, which are manipulated through actions, i.e. the application of story patterns. all scores of states in the look ahead are relative to the the simulation’s current state sx. by assigning a weight wi to each individual resource ri, the sum of all resources times their individual weight is a suitable scoring function for each state. this score is based on the value of the individual resources of the current state sx of the simulation. equation 1 illustrates this function for a state sy with rxi representing the value of resource ri in state sx. if, for instance, a resource r1 named “budget” would have a value of 5,000 in sx, a value of 3,000 in a potential follow-up state sy would be scored higher since it is 2,000 times w1 closer to the goal of the strategy. score(sx → sy) = |resources| ∑ i=1 wi ×(r y i −r x i ) (1) in the overall state space, only some specific paths represent valid, successful scenarios capturing how stakeholders interact to achieve their common goal. by looking at the complete (if not infinite) state space, the simulator can find all states in which this goal is satisfied. knowing these states, the simulator is able to choose the path that satisfies the stakeholders’ overall goal best. since computing capabilities are limited, the simulator has to decide which path is most likely to lead to success based on the feasibly available look ahead. 3 implementation and performance-evaluation the implementation of the discussed concepts is structured into three layers. all scoring, monitoring and decision-making is located on the topmost layer in the form of strategies. the second layer computes the look ahead, thereby reducing it in compliance with the aforementioned concepts of state-merging and pruning of states that violate the predefined constraints. such constraints can be expressed as forbidden states which have to be avoided by the simulator. additionally, these state specifications can also include ocl1 statements which have to hold. the 1 object constraint language (http://www.omg.org/spec/ocl/) proc. gtvmt 2013 4 / 12 http://www.omg.org/spec/ocl/ eceasst figure 2: screenshot of the eclipse perspective of the implementation bottom layer is responsible for matching and executing story patterns on specific states. for this task, it relies on giese et al.’s story diagram interpreter [ghs09]. further, this layer supplies caching algorithms and incremental transitions between states to speed up the most expensive part of the simulation, the computation of the look ahead. for the requirements engineers overseeing individual stakeholder sessions, the implementation offers an eclipse perspective (cf. figure 2). in this eclipse perspective, parameters of a simulation such as the depth of the look ahead or the scoring value of specific resources can be changed at run-time to adjust the strategy employed by the simulator. the engineers’ visualization of the look ahead and the proposed path through the look ahead are updated accordingly. to avoid repeated computations, the look ahead that was previously explored is cached and re-used, if an overlap between the old and the new look ahead exists. states that are located before the currently active state and are not part of the actual path taken to the active state (for example alternative states to sx after state s−1 in figure 2), are not cached to reduce memory consumption. the merging process uses a simple fingerprinting approach to reduce the necessary amounts of computation: the count of inner objects and relations of a state are multiplied by different prime numbers and summed up afterwards. a more detailed and expensive equals comparing individual objects is only executed if the fingerprints match. while we are aware that the fingerprinting algorithm could be more sophisticated to further improve the performance gains, this approach already suffices for our requirements. 5 / 12 volume 58 (2013) interactive strategy-based validation of behavioral models 3.1 example scenario: running a steelworks the aforementioned principles will be shown on a deliberately small example without distracting elements. to produce and sell steel, iron ore and coal are required. since both cost money, it is necessary to plan accordingly to be able to produce steel and sell it with a profit. in this case study, four story patterns are available: buy coal, buy iron ore, produce steel and sell steel. while both resources cost 10k$ for ten units each, selling the resulting steel yields 30k$. the domain model is illustrated in figure 3, figures 4 and 5 shows the story patterns which realize the process. role% ontology% element% worker% ironore%coal% actor% resource% money% resour cepoo l% machine% furnace%company% steel% workers% figure 3: metamodel of the case study figure 4: story patterns for buying coal and iron ore 3.2 strategies for a steelworks after the simulation was initialized using an initial state (sx in figure 8), the simulator computes a look ahead with a default depth of four to explore which transitions are possible. repeatedly buying only one resource leads to states in which nothing else can be bought and nothing can proc. gtvmt 2013 6 / 12 eceasst figure 5: story patterns for producing and selling steel be produced or be sold. consequently, these states (s3 and s13 in figure 8) are dead ends. since the order of purchases is irrelevant in this scenario, buying both resources once leads to identical states which can be merged (s6). after the look ahead is computed, all potential follow-up states and their paths can be scored to allow the simulator to choose the path most suitable to fulfill the goals of the current simulation strategy. the goal of the steelworks scenario is to maximize the profit, i.e. the amount of money they have. in this case, the user would set the parameters to assess the resources so that money is the only resource of interest (i.e. by giving it a weight of 1 and all other resources a weight of 0). thus, a weight can be assigned to each subclass of resource that is defined in the metamodel representing the domain (cf. fig. 3). the simulator chooses the transformations which maximize the score based on these weights. consequently, a sequence of buying only the required resources, producing and then selling the steel is the most promising one. although both buying actions are scored negatively, all paths containing sale of steel have an higher overall score than the starting state. in the simulated look ahead, s10 yields the highest score and is therefore proposed by the strategy. in more complex scenarios with more options available, the depth of the look ahead would have to be increased. since long sequences of actions might not pay off if their benefit is not covered within the look ahead, such sequences would never be started. the implemented eclipse perspectives (fig. 2) contains the following views for supervising the simulation: in the upper left view is an illustration of the sequence of the already visited states and the look ahead calculated from the current state (referred to as sx). in this view, the optimal path is highlighted in green. the requirements engineers can select transitions from the look ahead to inspect them in detail in the upper middle view which presents the current state of the simulation or any state of the look ahead from which this transition is triggered. in the lower left view, the rules that were already captured by observing stakeholders are listed. these can be included in any simulation session by dragging and dropping them into the upper right view under rules. also, forbidden situations and other variants, which are not within the scope of this paper, can be included for a simulation session. the simulation is initialized by providing an initial state, setting a depth of the look ahead, and an optional maximum number of simulation steps after which the simulator should stop. this 7 / 12 volume 58 (2013) interactive strategy-based validation of behavioral models is done in the lower right view, which also illustrates a list of all available strategies to choose from for the simulation session. to influence the selected strategy, the lower middle view shows all resources next to corresponding sliders which enable the requirements engineers to assign weights to the individual resources. figure 6: number of states for different look ahead values – with and without state merging figure 7: runtime of random rule execution compared to a strategy-based execution for different look ahead values – with and without state merging on a macbook pro (mac os 10.6) with a 2.4 ghz core2duo processor and 8 gb ram (jvm 1.6, eclipse 3.6.1), the computation of the look ahead illustrated in figure 8 took 0.135 seconds, its visualization needed 1.1 seconds.2 even the computation of a look ahead with a depth of 12, which includes 67 states, took only 0.374 seconds. without merging identical states, the same look ahead included 1272 states. while these unmerged states were computed in 3.22 seconds, it took the visualization code directly generated by emf3 and gmp4 another 120 seconds to draw and layout the resulting graph-structure. figures 6 and 7 show the linear 2 for each state, ten story patterns were evaluated. all presented values are averages of ten repeated measurements. 3 eclipse modeling framework (http://eclipse.org/modeling/emf/) 4 graphical modeling project (http://eclipse.org/modeling/gmp/) proc. gtvmt 2013 8 / 12 http://eclipse.org/modeling/emf/ http://eclipse.org/modeling/gmp/ eceasst correlation between the amount of states and the overall runtime for look aheads. as can be seen, state merging effectively delays the exponential growth of states. furthermore, figure 7 compares the performance of a strategy maximizing the resource “money” with a random execution of available story patterns. the additional computations which are required to score and compare different alternatives when using a strategy, do not noticeably decrease the overall performance. thus, concerning the runtime performance it can be stated that the implemented concepts of state merging and state scoring lead to acceptable execution times even for deeper look aheads. figure 8: starting from an initial state sx (left), the look ahead can be computed (right) 4 related work this section compares our approach to related ones, thereby focussing on approaches providing guided state space exploration or direct model checking for graph transformation systems. in [hkmp02], harel et al. extended their play approach [hm03] with an analysis of which parts of the specification fit together before an actual simulation is started. later, harel et al. also added the ability to exclude specific situations [hkp04] during the simulation. while this allows a requirements engineer to ensure that only viable paths are offered, the possibility of expressing strategies to guide the simulation more effectively into specific situations is missing. to verify whether specifications are suitable, the guide approach [ts07] enables engineers to formally execute the specification. while one of them tries to arrive at an invalid state, another one executes only safe transitions. either one has to pursue a specific strategy to arrive at a corresponding state. consequently, while no stakeholder is involved, this approach is still suitable to explore and verify specific properties of the modeled system. groove [kr06] can explore complete state spaces, but our approach does so automatically by restricting the exploration to the most promising paths concerning a single goal (such as highest increase of a resource like money or smallest amount of transitions to reach a certain state) or a set of them within the look ahead. as a model checking tool, groove can verify whether distinct properties are satisfied by the specification. groove, however, does not provide a visualization for its graph transformations which is suitable to be used in stakeholder validations. henshin [besw10] is another approach that is capable of creating a (partial) state space based on an initial state and a set of graph transformations. while it provides an interactive ui to 9 / 12 volume 58 (2013) interactive strategy-based validation of behavioral models explore the state space, it is not possible to express strategies to guide the exploration. edelkamp et al.’s approach [ejl06] reduces the state space exploration by abstracting from the original state space. finding a path conforming to the elicited constraints in the abstracted state space ensures that such a path also exists in the original state space. thus, heuristically, the exploration can be guided more efficiently by reducing the problem. however, since our approach does not deal with the complete state space but instead tries to elicit new inputs from stakeholders, their approach would only be feasible, if the generation of a suitable abstraction is possible at runtime to determine how the simulation should continue. baresi and spoletini [bs06] approach of using alloy to analyze graph transformation systems can be used to check properties of models and also to create look aheads of a specific depth. while their approach tries to answer questions that are similar to ours, their approach is not usable in an interactive way that can be integrated into or be a part of our visualization approach. 5 conclusion and future work in this paper, we extended our simulation approach of eliciting and validating scenarios between different, interacting stakeholders with simulation strategies and a bounded look ahead. while simulation and animation support stakeholders to understand behavioral specifications, requirements engineers had no explicit way of guiding the simulator effectively through these sessions. now, requirements engineers can specify strategies for the simulator to ensure that the stakeholders validate viable scenarios first instead of randomly being led into dead ends due to the inherent incompleteness of the models during the requirements engineering stage. based on our measurements, it is feasible to employ strategies for projects eliciting collaborative scenarios as they occur in workplaces, i.e. in the range of up to dozens of story patterns. for more sophisticated projects dealing with thousands and more graph transformations, the interactivity cannot be ensured. currently, only a limited set of functions can be used to specify how a state is scored. to express more sophisticated scoring algorithms, additional capabilities, such as a scoring function editor or a mini dsl to express the desired logic, will be implemented. also, since the look ahead computation performs acceptable, the focus lies on increasing the efficiency of the ui. acknowledgements: we would like to thank the anonymous reviewers for their helpful comments. also, we are grateful for holger giese’s feedback on earlier versions of this paper. bibliography [besw10] e. biermann, c. ermel, j. schmidt, a. warning. visual modeling of controlled emf model transformation using henshin. in proc. of the fourth international workshop on graph-based tools (grabats 2010). 2010. http://journal.ub.tu-berlin.de/index.php/eceasst/article/view/528 [bs06] l. baresi, p. spoletini. on the use of alloy to analyze graph transformation systems. in corradini et al. (eds.), graph transformations. lncs 4178, pp. 306–320. proc. gtvmt 2013 10 / 12 http://journal.ub.tu-berlin.de/index.php/eceasst/article/view/528 eceasst springer, 2006. doi:10.1007/11841883 22 [ejl06] s. edelkamp, s. jabbar, a. lafuente. heuristic search for the analysis of graph transition systems. in corradini et al. (eds.), graph transformations. lncs 4178, pp. 414–429. springer, 2006. doi:10.1007/11841883 29 [ggs09] g. gabrysiak, h. giese, a. seibel. interactive visualization for elicitation and validation of requirements with scenario-based prototyping. in proc. of the 4th international workshop on requirements engineering visualization. re’09, pp. 41–45. ieee computer society, los alamitos, ca, usa, 2009. doi:10.1109/rev.2009.3 [ggs10] g. gabrysiak, h. giese, a. seibel. deriving behavior of multi-user processes from interactive requirements validation. in proceedings of the ieee/acm international conference on automated software engineering. ase’10, pp. 355–356. acm, antwerp, belgium, september 2010. doi:10.1145/1858996.1859073 [ghg12] g. gabrysiak, r. hebig, h. giese. simulation-assisted elicitation and validation of behavioral specifications for multiple stakeholders. in proc. of the 21st ieee international workshop on enabling technologies: infrastructure for collaborative enterprises. wetice, pp. 220–225. toulouse, france, june 25-27 2012. doi:10.1109/wetice.2012.17 [ghs09] h. giese, s. hildebrandt, a. seibel. improved flexibility and scalability by interpreting story diagrams. in magaria et al. (eds.), proc. of the eighth international workshop on graph transformation and visual modeling techniques (gtvmt 2009). 2009. http://journal.ub.tu-berlin.de/index.php/eceasst/article/view/268 [hec06] r. heckel. graph transformation in a nutshell. electronic notes in theoretical computer science 148(1):187 – 198, 2006. proceedings of the school of segravis research training network on foundations of visual modelling techniques (fovmt 2004). doi:10.1016/j.entcs.2005.12.018 [hhv10] ábel hegedüs, ákos horváth, d. varró. towards guided trajectory exploration of graph transformation systems. in proc. of the 4th international workshop on petri nets and graph transformation. volume eceasst vol. 40. enschede, the netherlands, sept. 28 2010. satellite event of icgt 2010. http://journal.ub.tu-berlin.de/eceasst/article/view/583 [hkmp02] d. harel, h. kugler, r. marelly, a. pnueli. smart play-out of behavioral requirements. in fmcad ’02: proc. of the 4th international conference on formal meth11 / 12 volume 58 (2013) http://dx.doi.org/10.1007/11841883_22 http://dx.doi.org/10.1007/11841883_29 http://dx.doi.org/10.1109/rev.2009.3 http://dx.doi.org/10.1145/1858996.1859073 http://dx.doi.org/10.1109/wetice.2012.17 http://journal.ub.tu-berlin.de/index.php/eceasst/article/view/268 http://dx.doi.org/10.1016/j.entcs.2005.12.018 http://journal.ub.tu-berlin.de/eceasst/article/view/583 interactive strategy-based validation of behavioral models ods in computer-aided design. pp. 378–398. springer-verlag, london, uk, 2002. doi:10.1007/3-540-36126-x 23 [hkp04] d. harel, h. kugler, a. pnueli. smart play-out extended: time and forbidden elements. in qsic ’04: proceedings of the quality software, fourth international conference. pp. 2–10. ieee computer society, washington, dc, usa, 2004. doi:10.1109/qsic.2004.31 [hm03] d. harel, r. marelly. come, let’s play: scenario-based programming using lsc’s and the play-engine. springer-verlag new york, inc., secaucus, nj, usa, 2003. [knnz00] h. j. köhler, u. nickel, j. niere, a. zündorf. integrating uml diagrams for production control systems. in proc. of the 22nd international conference on software engineering. icse’00, pp. 241–251. acm, new york, ny, usa, 2000. doi:10.1145/337180.337207 [kr06] h. kastenberg, a. rensink. model checking dynamic states in groove. in model checking software. springer, 2006. doi:10.1007/11691617 19 [ts07] j. tenzer, p. stevens. guide: games with uml for interactive design exploration. know.-based syst. 20(7):652–670, 2007. doi:10.1016/j.knosys.2007.05.005 proc. gtvmt 2013 12 / 12 http://dx.doi.org/10.1007/3-540-36126-x_23 http://dx.doi.org/10.1109/qsic.2004.31 http://dx.doi.org/10.1145/337180.337207 http://dx.doi.org/10.1007/11691617_19 http://dx.doi.org/10.1016/j.knosys.2007.05.005 introduction concepts navigation and reduction guidance and scores implementation and performance-evaluation example scenario: running a steelworks strategies for a steelworks related work conclusion and future work data race detection in the linux kernel with cpalockator electronic communications of the easst volume 079 (2020) interactive workshop on the industrial application of verification and testing etaps 2020 workshop (interavt 2020) data race detection in the linux kernel with cpalockator pavel andrianov and vadim mutilin 8 pages guest editors: stylianos basagiannis, goetz botterweck, anila mjeda eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst data race detection in the linux kernel with cpalockator pavel andrianov1 and vadim mutilin2 1,2ivannikov institute for system programming of the ras 2moscow institute of physics and technology abstract: most of the state-of-the-art verification tools do not scale well on complicated software. our goal was to develop a tool, which becomes a golden mean between precise and slow software model checkers and fast and imprecise static analyzers. it allows verifying industrial software more efficiently. our method is based on the thread-modular approach elaborating the idea of abstraction from precise thread interaction and considering every thread separately, but in a special environment, which models thread effects on each other. the approach was implemented in the cpachecker framework and was evaluated on benchmarks based on linux device drivers for data race detection. it demonstrated that predicate abstraction allows keeping a false alarms rate at a reasonable level of 52%. moreover, it did not miss known real bugs found by analysis of commits in the linux kernel repository thus confirming the soundness of the approach. keywords: data race, thread-modular approach, linux kernel. 1 introduction multithreaded software is widely spread nowadays for efficient usage of multiple cpu cores. that is also correct for operating systems, which may contain a lot of parallel activities, for example, system calls, interrupt handlers and so on. in addition to generic bugs, which are common for all kinds of software, multithreaded programs may contain specific ones, related particularly with a parallel execution: deadlocks and races. data races are an important subclass of race conditions and are defined as a situation when a simultaneous accesses to the same memory take place from different threads, where one of the accesses is a write. in general, a data race may not lead to failure directly, but it is a symptom of an error. there were developed a lot of different approaches for data race detection. usually, they are divided into static and dynamic ones. further, we will concentrate mostly on static approaches, which may guarantee the correctness of the code under certain assumptions. precise approaches to model checking are based on considering all possible thread interleavings. thus, they allow to be very precise and consider different complicated cases, like lock-free synchronization and weak memory models. as a drawback, they have spent a lot of resources (time and memory) per a verification task and thus can not be applied to large benchmarks. an opposite case of static verification is a data flow-based analysis. the corresponding tools are very fast but not so precise as model checkers. particularly, the simple static analysis can not perform a path sensitive analysis. as a result, there are produced a lot of false alarms and some 1 / 8 volume 079 (2020) data race detection in the linux kernel with cpalockator of the tools apply unsound filters to remove a part of false alarms, and it may lead to a missed bug. our goal was to develop a tool that unites advantages both fast data flow analysis and precise model checking. one of the ideas to build such an approach is a sequential combination of two stages: the first stage is an imprecise analysis, which produces hints for the second stage, which is a traditional model checking. the other idea is a thread-modular approach, which considers each thread separately, but in a special environment [hjmq03, gpr11]. we implemented a thread-modular approach extended with projections in the cpachecker framework 1. cpachecker contains different kinds of analysis (cpas), which may be combined. we extended several cpas for support of the thread-modular approach with projections and implemented two specific cpas: threadcpa for thread analysis and lockcpa for tracking synchronization primitives. we successfully applied the cpalockator tool to a set of benchmarks that are based on the linux device drivers. the final rate of false alarms is quite low – 52%. we performed an analysis of a set of existing fixes in linux drivers, and the tool can detect 5 of 8 known bugs. the rest of them are missed due to timeout. 2 basic idea of the thread-modular approach with projections consider a simple program, which has only two active threads. figure 1 presents a simple model example, which uses an ad-hoc synchronization. the first thread initializes global data (in this case, a global variable g) and then sets a flag, meaning the shared data are ready. the second thread is allowed to use the shared data only after setting the flag. thus, there is no data race on a global variable g. volatile int g = 0; thread1 { 1: g = 1; 2: d = 1; 3: ... } volatile int d = 0; thread2 { 4: if (d == 1) { 5: g = 2; 6: } } figure 1: an example of a small program a suggested approach is based on a thread-modular approach. the approach considers each thread separately but in a special environment, which is constructed also during the analysis. the environment computation is based on the analysis of all threads, as every thread is a part of the environment for other threads. for each thread, a set of its actions, which may affect other threads, is collected. the actions include modification of shared variables, acquiring synchronization primitives and so on. environment precision strongly affects the precision of the whole analysis. however, there is the main question, how to compute and represent the environment efficiently. in a sequential analysis, there is a successful technique, which allows reducing the number of considered program states – an abstraction. it allows to abstract from minor details of a 1 https://cpachecker.sosy-lab.org/ interavt 2020 2 / 8 eceasst program and considers general (abstract) state. each abstract state may correspond to a set of real (concrete) program states. this idea allows to significantly increase the efficiency of the analysis. the key idea of the suggested approach is an extension of abstraction not only to the program states but also to the operations of a thread. adjusting the level of the abstraction, it is possible to choose a balance between speed and precision of the tool. figure 2 shows a part of the abstract reachability graph (arg) for the first and the second threads from figure 1. there is no interaction considered, so this is not a final step of the analysis. g → 0 d → 0 ![d == 1] g → 0 d → 0 g = 1 g → 1 d → 0 d = 1 g → 1 d → 1 thread 1 thread 2 g → 0 d → 0 #a1: #a2: #b1: figure 2: abstract transitions for two threads without any interaction the analysis in the example is based on a simple value analysis, which tracks only explicit values of variables. a transition contains an abstract state and an abstract operation. the first abstract state in both threads contains information that both global variables (d and g) are equal to zero (g → 0). after performing an operation g = 1 (transition #a1) the value of g is updated into 1 (g → 1) in the second abstract state (transition #a2). after constructing an arg for two threads separately, we need to consider the influence of threads to each other, i.e. to construct an environment. for every thread operation, we compute its projection – a representation of operation in a thread for other threads as an environment. for example, modification of local variables can not affect on other threads, so the corresponding projection is empty. modification of a global variable may affect other threads, so the projection may be equal to the original transition or overapproximate it, for example, by abstraction from a precise assigned value. a projection may contain not only information about action but also a condition for performing this action, so-called guard. consider a transition #a1. we may represent the corresponding projection in the following way: if the value of g equals zero, it may be changed to one. in other words, the projection consists of two parts: a guard ([g == 0]) and an action (g → 1). the guard corresponds to a predecessor abstract state and an action corresponds to an operation. the figure 3 presents computed projections for the first thread. there are two transitions, which may affect the global variables: #a1 and #a2. we compute the corresponding projections: #p1 and #p2. then every projection has to affect the second thread, i.e. apply to all possible (according to the guard) transitions of the second thread. we apply the projection #p1 to the transition #b1, as the state is compatible with the guard of the projection. only after that, we may apply the projection #p2 to the new transition #b2, which requires g to be equal to one. and only then the second thread may go through a new transition #b3, which discovers new paths. note, the figure presents only projections for the first thread, in complete arg there should be also projections for the second thread as well. for data race detection we have to find two transitions, which modify the same variable. the 3 / 8 volume 079 (2020) data race detection in the linux kernel with cpalockator g → 0 d → 0 g = 1 g → 0 d → 0 ![d == 1] g → 0 d → 0 g = 1 g → 0 d → 0 g = 1 g → 1 d → 0 d = 1 g → 1 d → 1 thread 1 thread 2 g → 0 d → 0 projection g → 1 d → 0 ![d == 1] g → 1 d → 0 g → 1 d → 0 d = 1 g → 1 d → 0 d = 1 g → 1 d → 1 [d == 1] g → 1 d → 1 g = 2 #a2: #a1: #b1: #b2: #b3: #b4: #p2: #p1: figure 3: application of projections to the second thread example has potential candidates: #a1 and #b4. now, we should check, if the two transitions may be executed in parallel. that means, that the corresponding abstract states must be a part of one global state, i.e. they must be compatible. in this case, the partial states are contradicting each other, as one has g → 0 and the other g → 1. so, the corresponding transitions can not be executed simultaneously. thus, we conclude there is no data race for g. note, there is a data race for d (transitions #a2 and #b2), but it may be considered as lock-free synchronization, and a potential race is a part of its implementation. the suggested approach provides a lot of possible options and configurations for targeting to a particular task. a projection may be represented by more or less precise abstraction. several projections may be joined altogether or considered separately. an example of more abstract transitions is presented in figure 4. g → 0 d → 0 g = 1 d = 1 g → 0 d → 0 ![d == 1] g → 0 d → 0 g = 1 g → * d → 0 g = 1 d = 1 g → 1 d → 0 d = 1 g → 1 d → 1 thread 1 thread 2 g → 0 d → 0 projection g → * d → * [d == 1] g → * d → * g = 2 ⋁ ⋁ #a1: #a2: #b1: #c2: #c3: #p3: figure 4: application of projections to the second thread the two initial projections (#p1 and #p2) are joined into a single one (#p3). usually, it leads to losing some information, for example, here we lost a precise value of variable g. the action of projection also becomes more complicated. the second thread can not identify a precise value of the variables, as both of the variables are now equal to zero or one. the simple kind of analysis operates only with single explicit values of variables and both variables are considered to be equal to any random value. now, transitions #a1 and #c3 become compatible, which means, interavt 2020 4 / 8 eceasst that the race is reported on variable g. the level of abstraction strongly affects the precision of the analysis and its speed, but the analysis always remains sound. 3 data-race detection algorithm data race detection algorithms may be divided into two stages: reachable states analysis and searching of pairs, which can form a race. in our case, the first subtask is related to arg construction and may be solved with different configurations. as we have already discussed, an arg from abstract transitions is constructed with the chosen configuration of the cpalockator. note, the abstract transitions in the graph are reachable with a certain abstraction level, so, they may not be reachable in a real execution. for refinement of the abstraction, we use a cegar algorithm (counterexample guided abstraction refinement). note, a cegar algorithm was reused without significant modifications. however, it allows refining only path in a single thread, i.e. it can not identify contradictions between operations in different threads. anyway, it is not a fundamental limitation of the approach, and a possible extension of the cegar algorithm for the thread-modular approach will allow obtaining more precise results. after computation of the arg we should find those transitions, which could form a data race. usually, a race condition is defined as a situation, where simultaneous access to shared memory from different threads takes place. two main questions, which appear for static data race detection, are the following: how we can determine, that the accesses are performed to the same memory and how to determine if the accesses are simultaneous. further, we will discuss both of the features of the approach. in real software, there are a lot of different operations with pointers, structures, and more complicated data. the variety of pointers breaks any kind of alias analysis. moreover, most of the approaches require the pointers to be correctly initialized, which is difficult to reach while analyzing libraries, modules and so on. thus, we use a bnb memory model [afm+17], which divides all memory into a disjoint set of regions. every region corresponds to a specific data type or a structure field (if an address-of expression is not used for it). according to the memory model, we consider access to the same region as access to the same memory. the bnb memory model has certain limitations. first of all, casting and address arithmetic may lead to a missed bug, because the two accesses will not be placed in the same region. also, the memory model may lead to false alarms in cases, when two pointers of the same type never point to the same memory but are placed in the same region. if we have two accesses to the same region, we have to check, if two accesses are taking place simultaneously. we use the already mentioned notion of compatibility of the corresponding transitions. two partial states are compatible, if they may be parts of a single global state. if the partial states are not compatible, that means, the corresponding transitions can not be executed in parallel. thus, this approach is an extension of a lockset algorithm, which defines a data race, as a pair of accesses with a disjoint set of locks. a compatibility check uses different kinds of analysis, including analysis of synchronization primitives, predicate analysis, thread analysis, hence the approach is more precise than the default lockset algorithm. 5 / 8 volume 079 (2020) data race detection in the linux kernel with cpalockator 4 evaluation on the linux device drivers cpalockator 2 tool was evaluated on a benchmark set, which is based on device drivers of the subsystem drivers/net of the linux kernel v4.2.6 3. for each kernel module, a verification task was prepared with the help of the klever framework [nz18]. for 473 modules it prepared 425 tasks for cpalockator. detailed information about its verdicts is presented in the table 1. the table 2 presents the results of the analysis of warnings. we will discuss them further. tasks description 261 safe (no bugs) 22 unsafe (races found) 142 unknow (timeout) table 1: overall verdicts number percent description 41 48% true (bugs) 25 29% imprecise scenario model 8 9% imprecise memory model 7 8% specifics of interrupts 4 5% other imprecisions in the analysis table 2: analysis of warnings in linux kernel modules 41 warnings of 85 (48%) correspond to real bugs. 10 of them are related to so-called “benign” races. it is, for example, a race on statistics counter or during printing debug information. the main part of bugs corresponds to a situation when a new thread is created while an initialization process is still uncompleted. thus, the new thread may access uninitialized memory or not allocated memory. the situation usually occurs, when registration of driver handlers is performed before the complete initialization of driver data. note, several warnings may be outputted per one module and these 41 warnings correspond to 15 modules. 44 of 85 warnings (52%) are false alarms. the main part of them (25 warnings) is related to the imprecise communicating scenario model, which defines scenarios of driver activities. the issue is not related to the cpalockator tool and is caused by an internal part of the klever framework. so, the corresponding warning is correct for the verification tool, but the data race is impossible in a real execution. for example, an imprecise communicating scenario model may consider some driver activities as parallel, but in a real execution, the corresponding scenario is impossible. other examples – absent models of external functions, which are important for analysis, or incorrect driver input data are also a responsibility of klever task generator. the main part of false alarms, related to the cpalockator tool, is due to imprecise memory model – 8 warnings. to be conservative cpalockator may consider different memory as the same (bnb model) and produce a warning about potential simultaneous access, although the accesses are not to the same memory. this is mostly happening for structure fields. one more important reason of false alarms is low-level constructions in the linux kernel. currently, an interrupt handler is considered to be executed like an ordinary thread, but actually, it has certain specifics. for example, the execution of the interrupt handler may be interrupted only in special cases and only by another interrupt. it means, that the interrupt handler is executed atomically in parallel with an ordinary thread. moreover, the registration of an interrupt handler may not mean that it becomes active. in some cases interrupts should be activated in the device. 2 cpachecker-theory-with-races@32609 3 https://gitlab.com/sosy-lab/software/ldv-benchmarks.git , directory linux-4.2.6-races interavt 2020 6 / 8 eceasst small classes of false alarms are dedicated to the analysis imprecision: shared analysis, problems with complex data structures and model variables. 5 evaluation on the set of known bugs analysis of causes of false alarms was performed on a set of benchmarks, which are based on fixes of existing bugs in stable linux kernel versions in 2014 4. 795 commits are extracted using keywords5 from the whole set of 4047 commits. then we performed a manual analysis of commits and filtered only those commits, which are related to data races and contain only lockbased synchronization primitives and are in kernel modules, see details in the table 3. we have got 13 modules after that and launched the klever framework. it failed to prepare verification tasks for 5 modules, hence the resulting set contains 8 verification tasks6. table 3: constructing a set of commits with known bugs for evaluation total amount description 4047 all commits 795 extracted using keywords 43 related only to data races 28 use lock-based synchronization 13 in kernel modules 8 klever prepared corresponding tasks the results of launching cpalockator on 8 verification tasks with known bugs are presented in the table 4. the bugs are marked by commit identifiers. we run cpalockator on the tasks prepared by klever framework for the repository before corresponding commit. for checking that the bug is not found after the fix we also launched cpalockator on a verification task prepared for the repository after corresponding commit. table 4: evaluation on known bugs in stable versions of linux kernel commit module result comment 0e2400e drivers/char/virtio console.ko + 7357404 fs/hfsplus/hfsplus.ko ± found with limited cegar iterations f1a8a3f drivers/net/bonding/bonding.ko ∓ found a nontarget bug with limited cegar iterations 1a81087 net/ipv4/tcp illinois.ko ± nontarget bug was found f0c626f drivers/target/iscsi/iscsi target mod.ko ∓ found a nontarget bug with limited cegar iterations aea9dd5 fs/btrfs/btrfs.ko − 10ef175 sound/soc/snd-soc-core.ko − timeout 4036523 drivers/gpu/drm/i915/i915.ko − • cpalockator found two bugs fixed in commits 0e2400e and 7357404. for the tasks prepared after the fix, the corresponding warnings are not found. it means that the bugs are detected correctly. the bug in 7357404 was found only if the cegar iterations are limited, in another case, there will be a timeout. 4 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 5 fix, error, race, bug, failure, crash, etc 6 https://gitlab.com/sosy-lab/software/ldv-benchmarks.git , directory ldv-commit-races 7 / 8 volume 079 (2020) data race detection in the linux kernel with cpalockator • for three more modules, cpalockator outputted warnings for the same memory location mentioned in the bug but for a different access location in the code. we call them nontarget bugs. for f1a8a3f and f0c626f the cegar iterations also must be limited to avoid the timeout. • three modules are too large and too complex and exceed 15 minutes timelimit. note, the timeout is achieved in the first iteration of cegar. thus, 5 of 8 bugs were found, and for the rest 3 modules, there were unknown verdicts. the results confirm the soundness of the approach. 6 conclusion one of the main limitations of the approach is a size of verified code and its complexity. we do not discuss it much, as it is well known for any static verifier tool. however, cpalockator is able to solve real-world tasks, which are based on linux device drivers, which shows practical benefit of the tool. we also mentioned bnb memory model, which also affects on the verification process. this is a trade off between speed of the analysis and its precision. one more limitation of the approach is support only lock-based synchronization primitives. different atomic constructions, barriers are skipped for now. we do not speak about function pointers, c constructions and so on, as it is not related to the approach itself. cpachecker framework contain different kinds of analysis, for example, function pointer analysis, and they may be included into cpalockator if it is necessary. the results on linux device drivers are quite good, as the tool demonstrates a false alarms rate of 52%. moreover, it does not miss real bugs on our benchmark set, that confirms the soundness of the approach. thus, we may conclude that the tool is practically valuable for data race detection. future plans include further improvements in the overall approach: support new synchronization primitives, investigate different combination with other analyzes. bibliography [afm+17] p. andrianov, k. friedberger, m. mandrykin, v. mutilin, a. volkov. cpa-bambnb: block-abstraction memoization and region-based memory models for predicate abstractions. in proceedings of tacas. pp. 355–359. 2017. [gpr11] a. gupta, c. popeea, a. rybalchenko. threader: a constraint-based verifier for multi-threaded programs. in proceedings of cav. pp. 412–417. springer, 2011. [hjmq03] t. a. henzinger, r. jhala, r. majumdar, s. qadeer. thread-modular abstraction refinement. in proceedings of cav. pp. 262–274. springer, 2003. [nz18] e. novikov, i. zakharov. verification of operating system monolithic kernels without extensions. in leveraging applications of formal methods, verification and validation. industrial practice. pp. 230–248. springer, 2018. interavt 2020 8 / 8 introduction basic idea of the thread-modular approach with projections data-race detection algorithm evaluation on the linux device drivers evaluation on the set of known bugs conclusion verifying model transformations by structural correspondence electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) verifying model transformations by structural correspondence anantha narayanan and gabor karsai 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst verifying model transformations by structural correspondence anantha narayanan1 and gabor karsai1 1institute for software integrated systems, vanderbilt university nashville, tn 37203 usa abstract: model transformations play a significant role in model based software development, and the correctness of the transformation is crucial to the success of the development effort. we have previously shown how we can use bisimulation to verify the preservation of certain behavioral properties across a transformation. however, transformations are often used to construct structurally different models, and we might wish to ensure that there is some structural correspondence to the original model. it may be possible to verify such transformations without having to explicitly specify the dynamic semantics of the source and target languages. in this paper, we present a technique to verify such transformations, by first specifying certain structural correspondence rules between the source and target languages, and extending the transformation so that these rules can be easily evaluated on the instance models. this will allow us to conclude if the output model has the expected structure. the verification is performed at the instance level, meaning that each execution of the transformation is verified. we will also look at some examples using this technique. keywords: verification, model transformations 1 introduction model transformations that translate a source model into an output model are often expressed in the form of rewriting rules, and can be classified according to a number of categories [mv05]. however, the correctness of a model transformation depends on several factors, such as whether the transformation terminates, whether the output model complies with the syntactical rules of the output language, and others. one question crucial to the correctness of a transformation is whether it achieved the intended result of mapping the semantics of the input model into that of the output model. for instance, a transformation from a statechart model to a non-hierarchical fsm model can be said to be correct if the output model truly reproduces the behavior of the original statechart model. models can also be seen as attributed and typed graph structures that conform to an abstract syntax. model transformations take an input graph and produce a modified output graph. in a majority of these cases, the transformation matches certain graph structures in the input graph and creates certain structures in the output graph. in such cases, correctness may be defined as whether the expected graph structures were produced in the output corresponding to the relevant structures in the input graph. if we could specify the requirements of such correspondences and trace the correspondences easily over instance models, a simple model checking process at the 1 / 14 volume 10 (2008) verifying model transformations end of a transformation can be used to verify if those instances were correctly transformed. in this paper, we explore a technique to specify structural correspondence rules, which can be used to decide if the transformation resulted in an output model with the expected structure. this will be specified along with the transformation, and evaluated for each execution of the transformation, to check whether the output model of that execution satisfies the correspondence rules. 2 background 2.1 great great [akl03] is a language framework for specifying and executing model transformations using graph transformation. it is a meta-model based transformation tool implemented within the framework of gme [lbm+01]. one of the key features of great is the ability to define cross-language elements by composing the source and target meta-models, and introducing new vertex and edge types that can be temporarily used during the transformation. such cross-metamodel associations are called cross-links. note that a similar idea is present in triple graph grammars [sch95]. this ability of great allows us to track relationships between elements of the source and target models during the course of the transformation, as the target model is being constructed from the source model. this feature plays a crucial role in our technique to provide assurances about the correctness of a model transformation. 2.2 instance based verification of model transformations verifying the correctness of model transformations in general is as difficult as verifying compilers for high-level languages. but for practical purposes, a transformation may be said to have ‘executed correctly’ if a certain instance of its execution produced an output model that preserved certain properties of interest. we call that instance ‘certified correct’. this idea is similar to the work of denney and fischer in [df05], where a program generator is extended to produce logical annotations necessary for formal verification of certain safety properties. an automated theorem prover uses these annotations to find proofs for the safety properties for the generated code. note that this does not prove the safety of the code generator, but only of a particular instance of generated code. in our previous effort [nk06], we have shown that it is both practical and prudent to verify the correctness of every execution of a model transformation, as opposed to finding a correctness proof for the transformation specification. this makes the verification tractable, and can also find errors introduced during the implementation of a transformation that may have been specified correctly. this technique was applied to the specific case of preservation of reachability related properties across a model transformation. reachability is a fairly well-understood property, and can be verified easily for a labeled transition system (lts), for instance by model checking [hol97]. if two labeled transition systems are bisimilar, then they will have the same reachability behavior. in our approach, we treated the source and target models as labeled transition systems, and verified the transformation by checking if the source and target instances were bisimilar. proc. gt-vmt 2008 2 / 14 eceasst figure 1: architecture for verifying reachability preservation in a transformation given an lts (s, λ, →), a relation r ⊆ s × s is a bisimulation [san04] if: (p, q) ∈ r and p α→ p′ implies that there exists a q′ ∈ s, such that q α→ q ′ and (p′, q′) ∈ r, and conversely, q α→ q ′ implies that there exists a p′ ∈ s, such that p α→ p ′ and (p′, q′) ∈ r. we used cross-links to relate source and target elements during the construction of the output model. these relations were then passed to a bisimilarity checker, which determined whether the source and target instances were bisimilar. if the instances were determined to be bisimilar, we could conclude that the execution of the transformation was correct. figure 1 shows an overview of the architecture for this approach. figure 2: meta-model for uml activity diagrams 2.3 uml to csp transformation the uml to csp transformation was presented as a case study at agtive ’07 [beh07], to compare the various graph transformation tools available today. we provide an overview of this 3 / 14 volume 10 (2008) verifying model transformations case study here from a great point of view, and we will use this as an example to explain our technique for verifying model transformations. the objective of this transformation is to take a uml activity diagram [omg06] and generate a communicating sequential process [hoa78] model with the equivalent behavior. the activity diagram consists of various types of activity nodes, which can be connected by directed activity edges. figure 2 shows the gme meta-model for uml activity diagrams. a csp process is defined by a process assignment, which assigns a process expression to a process id. process expressions can be a simple process, a prefix operator or a binaryoperator. figure 3 shows the gme meta-model for csp, highlighting the relevant parts for our example. figure 3: meta-model for csp the uml to csp mapping assigns a process for each activity edge. for each type of activity node, a process assignment is created, which assigns the process corresponding to the incoming activity edge to a process expression depending on the type of the activity node. figure 4 shows one such mapping, for the type action node. this assigns the incoming process to a prefix expression. the resulting csp expression can be written as a = action −→ b, which is shown in figure 4 as a model instance compliant with the csp meta-model. 3 structural correspondence as in the uml to csp case, model transformations can be used to generate a target model of a certain structure (csp) from a source model of a different structure (uml). specific structural configurations in the source model (such as an action node in the uml model) produce specific structural configurations in the target model (such as a prefix in the csp model). the rules to accomplish the structural transformations may be simple or complicated. however, it is fairly straightforward to compare and verify that the correct structural transformation was made, if we already know which parts of the source structure map to which parts of the target structure. in our technique to verify a transformation by structural correspondence, we will first define proc. gt-vmt 2008 4 / 14 eceasst (a) activity diagram (b) csp figure 4: csp process assignment for action node a set of structural correspondence rules specific to a certain transformation. we will then use cross-links to trace source elements with the corresponding target elements, and finally use these cross-links to check whether the structural correspondence rules hold. in essence, we expect that the correspondence conditions are independently specified for a model transformation, and an independent tool checks if these conditions are satisfied by the instance models, after the model transformation has been executed. in other words, the correspondence conditions depend purely on the source and target model structures and not on the rewriting rules necessary to effect the transformation. since the correspondence conditions are specified in terms of simple queries on the model around previously chosen context nodes, we expect that they will be easier to specify, and thus more reliable than the transformation itself. we also assume that the model transformation builds up a structure for bookkeeping the mapping between the source and target models. 3.1 structural correspondence rules for uml to csp transformation a structural correspondence rule is similar to a precondition-postcondition style axiom. we will construct them in such a way that they can be evaluated easily on model instances. we will use the uml to csp example to illustrate structural correspondence. consider the case for the action node, as shown in figure 4. the action node has one incoming edge and one outgoing edge. it is transformed into a process assignment in the csp. the csp structure for this instance consists of a process id and a prefix, with an event and a target process. this is the structural transformation for each occurrence of an action node in the activity diagram. we can say that for each action node in the activity diagram, there is a corresponding process assignment in the csp, with a prefix expression. when our transformation creates this corresponding process assignment, we can use a cross-link to track this correspondence. the structural correspondence is still not complete, as we have to ensure that the process id and the prefix expression are created correctly. we use a kind of path expression to specify the correctness of corresponding parts of the two structures, and the correspondence is expressed in the form sourceelement = out putelement. let us denote the action node by an, and the process assignment by pa. then the necessary correspondence rules can be written using path expressions as shown in table 1. 5 / 14 volume 10 (2008) verifying model transformations rule path expression the action node corresponds to a process assignment with a prefix pa.procex pr.type = pre f ix the incoming edge in the uml corresponds to the process id an.inedge.name = pa.procid.name the outgoing edge corresponds to the target process an.outedge.name = pa.procex pr.process.name the action of the action node corresponds to the event an.action = pa.procex pr.event table 1: structural correspondence rules for action node these rules together specify the complete structural correspondence for a section of the activity diagram and a section of its equivalent csp model. the different types of activity nodes result in different structures in the csp model, some of which are more complex than the fairly straightforward case for the action node. next, we look at the structural mapping for some of the other nodes. a fork node in the activity diagram is transformed into a process assignment with a concurrency expression. figure 5 shows a fork node with an incoming edge a and three outgoing edges b, c and d. this is represented by the csp expression a = b ‖ (c ‖ d), where ‖ represents concurrency (the actual ordering of b, c and d is immaterial). the structural representation of this expression as an instance of the csp meta-model is shown in figure 5. the fork node is transformed into a csp process assignment that consists of a process id corresponding to the incoming activity edge of the fork node, and a process expression of type concurrency. the concurrency expression consists of processes and other concurrency nodes, depending on the number of outgoing activity edges. if we denote the fork node by f n and the process assignment by pa, the structural corre(a) activity diagram (b) csp figure 5: csp process assignment for fork node proc. gt-vmt 2008 6 / 14 eceasst rule path expression the fork node corresponds to a process assignment with a concurrency pa.procex pr.type = concurrency the incoming edge in the uml corresponds to the process id f n.inedge.name = pa.procid.name for each outgoing edge, ∀o ∈ f n.outedge there is a corresponding process ∃p ∈ pa.procex pr..process : o.name = p.name in the process expression table 2: structural correspondence rules for fork node (a) activity diagram (b) csp figure 6: csp process assignment for decision node spondence rules can be described using path expressions as shown in table 2. we will use the double-dot ‘..’ to denote the descendant operator (similar to ‘//’ in xpath queries), to specify ancestor-descendant relationships. by evaluating these rules on the activity diagram and the csp models, we can determine whether the structural correspondence was satisfied for fork nodes. another type of node in the activity diagram is the decision node. the transformation mapping for the decision node is a slight variation of the fork node. figure 6 shows a decision node with an incoming edge a, and three outgoing edges b, c and d, with guards x, y and else respectively (in this case study, we will assume that the decision node always has exactly one ‘else’ edge). this is represented by the csp expression a = b 6< x 6> (c 6< y 6> d), where the operator c 6< y 6> d is the condition operator with the meaning that if y is true, then the process behaves like c, else like d. the decision node is transformed to the csp model shown in figure 6 as a model instance of the csp meta-model. the decision node is transformed into a process assignment that consists of a process id corresponding to the incoming activity edge of the decision node, and a process expression of type condition. the condition’s expression attribute is set to the guard of the corresponding activity edge, and a process corresponding to the activity edge is created as it’s lhs. for the final ‘else’ edge, a process is created in the last condition as it’s rhs. the 7 / 14 volume 10 (2008) verifying model transformations rule path expression the decision node corresponds to a process assignment with a condition pa.procex pr.type = condition the incoming edge in the uml corresponds to the process id dn.inedge.name = pa.procid.name for each outgoing edge, there is a corresponding condition in the ∀o ∈ dn.outedge ∧ o.guard 6= else process expression and a corresponding ∃c ∈ pa.procex pr..condition : process in the condition’s lhs c.ex pression = o.guard ∧ c.lhs.name = o.name for the outgoing ‘else’ edge, there is a condition in the ∀o ∈ dn.outedge ∧ o.guard = else process expression with a ∃c ∈ pa.procex pr..condition : corresponding process as it’s rhs c.rhs.name = o.name table 3: structural correspondence rules for decision node structural correspondence rules for this mapping are shown in table 3. 3.2 specifying structural correspondence rules in great specifying the structural correspondence for a transformation consists of two parts: 1. identifying the significant source and target elements of the transformation 2. specifying the structural correspondence rules for each element using path expressions the first step is accomplished in great by using cross-links between the source and target elements. a composite meta-model is added to the transformation, by associating selected source and target elements using a temporary ‘structural correspondence’ class. there will be one such class for each pair of elements. this class will have a string attribute, which is set to the path expressions necessary for structural correspondence for that pair. figure 7 shows a composite meta-model specifying the structural correspondence for fork nodes. the fork node class comes from the activity diagram meta-model, and the process assignment class comes from the csp meta-model. figure 7: composite meta-model to specify structural correspondence once the structural correspondence has been specified for all the relevant items, the transformation is enhanced to create the cross-link when creating the respective target elements. figure 8 shows the great rule in which the process assignment for a fork node is created, enhanced to proc. gt-vmt 2008 8 / 14 eceasst figure 8: great rule with cross-link for structural correspondence create the cross-link for structural correspondence. note that in incoming activity edge is represented as an association class named activityedgein. the transformation for the fork node is actually accomplished in a sequence of several rules executed recursively, as shown in figure 9. first all the fork nodes are collected, and a sequence of rules are executed for each node. these rules iterate through the out-edges of each fork node, creating the concurrency tree. though several rules are involved in the transformation for fork nodes, the cross-link needs to be added to one rule only. it must be noted that it is necessary to specify the structural correspondence rules only once in the composite meta-model. the cross-link must however be added to the transformation rules, and in most cases will be required only once for each pair of source and target element. 3.3 evaluating the structural correspondence rules once the structural correspondence rules have been specified, and the cross-links added to the transformation, the correspondence rules are evaluated on the instance models after each execution of the transformation. these rules can be evaluated by performing a simple depth first search on the instance models, and checking if the correspondence rules are satisfied at each relevant stage. this consists of two phases. the first phase is to generate the code that will traverse the instance models and evaluate the correspondence rules. since the meta-models of both the source and target languages are available with the transformations, and the path expressions are written in a standard form that can be parsed automatically, the model traverser code can be automatically generated from the structural correspondence specification. this needs to be done only once each 9 / 14 volume 10 (2008) verifying model transformations figure 9: sequence of great rules for fork node transformation time the structural correspondence specification changes. the second phase is to call the model traverser code at the end of each execution of the transformation, supplying to it the source and target model instances along with the cross-links. in the case of the uml to csp transformation, we traverse the input activity diagram model and evaluate the correspondence rules at each activity node. for each activity node, the crosslink is traversed to find the corresponding process assignment. if a correspondence rule has been defined for an activity node, and no corresponding process assignment is found, then this signals an error in the transformation. after locating the corresponding process assignment, the path expressions are evaluated. if any of the rules are not satisfied, the error is reported. if all the rules are satisfied for all the nodes, then we can conclude that the transformation has executed correctly. the instance model is traversed in a depth-first manner. the corresponding elements are located using the cross-links, which will take constant time. the path expressions are evaluated on the instances, which will take polynomial time in most cases. thus, the overall verification process does not incur a significant performance overhead in most cases. 3.4 remarks the structural correspondence based verification described here can provide important assurances about the correctness of transformations, while being practically applicable in most common transformations. the use of path expressions to specify correspondence rules makes it easy to specify correctness. the path expressions use a simple query language that can be easily evaluated on the instance models. our future research concentrates on the requirements of such a query language. most complex transformations may involve multiple rules executing recursively to transform a particular part of a model. however, it may be possible to specify the correspondence for that part of the model using a set of simple path expressions. such a specification would be simpler and easier to understand than the complex transformation rules. the structural correspondence is also specified orthogonal to the transformation specification. proc. gt-vmt 2008 10 / 14 eceasst thus, these rules may be written by someone other than the original transformation writer, or even supplied along with the requirements document. 4 related work [k0̈4], [khe03] present ideas on validating model transformations. in [khe03], the authors present a concept of rule-based model transformations with control conditions, and provide a set of criteria to ensure termination and confluence. in [k0̈4], küster focuses on the syntactic correctness of rule-based model transformations. this validates whether the source and target parts of the transformation rule are syntactically correct with respect to the abstract syntax of the source and target languages. these approaches are concerned with the functional behavior and syntactic correctness of the model transformation. [lt] also discusses validation of transformations on these lines, but also introduces ideas of syntactic consistency and behavior preservation. our technique addresses semantic correctness of model transformations, addressing errors introduced due to loss or mis-representation of information during a transformation. in [bh07], bisztray and heckel present a rule-level verification approach to verify the semantic properties of business process transformations. csp is used to capture the behavior of the processes before and after the transformation. the goal is to ensure that every application of a transformation rule has a known semantic effect. we use path expressions to capture the relation between structures before and after a transformation. these path expressions are generic (they do not make any assumptions about the underlying semantics of the models involved), and can be applied to a wide variety of transformations. ehrig et. al. [eee+07] study bidirectional transformations as a technique for preserving information across model transformations. they use triple graph grammars to define bi-directional model transformations, which can be inverted without specifying a new transformation. our approach offers a more relaxed framework, which will allow some loss of information (such as by abstraction), and concentrates on the crucial properties of interest. we also feel that our approach is better suited for transformations involving multiple models and attribute manipulations. in other related work, [vp03] presents a model level technique to verify transformations by model checking a selected semantic property on the source model, and transforming the property and validating it in the target domain. the validation requires human expertise. after transforming the property, the target model is model checked. in our approach, since the properties are specified using cross links that span over both the source and target languages, we do not need to transform them. [llmc06] discuss an approach to validate model transformations by applying ocl constraints to preserve and guarantee certain model properties. [ggl+06] is a language level verification approach which addresses the problem of verifying semantic equivalence between a model and a resulting programming language code. 4.1 mof qvt relations language the mof 2.0 query / view / transformation specification [omg05] addresses technology pertaining to manipulation of mof models. a relations language is prescribed for specifying relations that must hold between mof models, which can be used to effect model transformations. 11 / 14 volume 10 (2008) verifying model transformations relations may be specified over two or more domains, with a pair of when and where predicates. the when predicate specifies the conditions under which a relation must hold, and the where predicate specifies the condition that all the participating model elements must satisfy. additionally, relations can be marked as checkonly or enforced. if it is marked checkonly, the relation is only checked to see if there exists a valid match that satisfies the relationship. if it is marked enforced, the target model is modified to satisfy the relationship whenever the check fails. our approach can be likened to the checkonly mode of operation described above. however, in our case, the corresponding instances in the models are already matched using cross links, and the correspondence conditions are evaluated using their context. the cross links help us to avoid searching the instances for valid matches. specifying the correspondence conditions using context nodes simplifies the model checking necessary to evaluate the conditions, thus simplifying the verification process. since we verify the correspondence conditions for each instance generated by the transformation, these features play an important role. 4.2 triple graph grammars triple graph grammars [sch95] are used to describe model transformations as the evolution of graphs by applying graph rules. the evolving graph complies with a graph schema that consists of three parts. one graph schema represents the source meta model, and one represents the target meta-model. the third schema is used to track correspondences between the source and target meta models. transformations are specified declaratively using triple graph grammar rules, from which operational rules are derived to effect model transformations. the schema to track correspondences between the source and target graphs provides a framework to implement a feature similar to cross links in great. if the correspondence rules can be encoded into this schema, and the correspondence links persisted in the instance models, our verification approach can be implemented in this scenario. 5 conclusions and future work in this paper, we have shown how we can provide an assurance about the correctness of a transformation by using structural correspondence. the main errors that are addressed by this type of verification is the loss or misrepresentation of information during a model transformation. we continue to hold to the idea that it is often more practical and useful to verify transformations on an instance basis. the verification framework must be added to the transformation only once, and is invoked for each execution of the transformation. the verification process does not add a significant overhead to the transformation, but provides valuable results about the correctness of each execution. the path expressions must use a simple and powerful query language to formulate queries on the instance models. while existing languages such as ocl may be suitable for simple queries, we may need additional features, such as querying children to an arbitrary depth. our future research concentrates on the requirements of such a language. while the path expressions can be parsed automatically and evaluated on the instances, the cross-link for the relevant elements must be manually inserted into the appropriate transformation proc. gt-vmt 2008 12 / 14 eceasst rules. however, in most cases, it may be possible to infer where the cross-links must be placed. if the cross-links could be inserted into the rules automatically, the transformation can remain a black box. the main concern with this is that the cross-links are crucial to evaluating the correspondence rules correctly and also to keep the complexity down. we have seen simple string comparisons added to the path expressions in this paper. some transformations may require more complex attribute comparisons, or structure to attribute comparisons such as counting. we wish to explore such situations in further detail in future cases, to come up with a comprehensive language for specifying the path expressions. acknowledgement the research described in this paper has been supported by a grant from nsf/csr-ehs, titled “software composition for embedded systems using graph transformations”, award number cns-0509098. bibliography [akl03] a. agrawal, g. karsai, a. ledeczi. an end-to-end domain-driven software development framework. in oopsla ’03: 18th annual acm sigplan conference on oop, systems, languages, and applications. pp. 8–15. acm press, new york, ny, usa, 2003. doi:http://doi.acm.org/10.1145/949344.949347 [beh07] d. bisztray, k. ehrig, r. heckel. case study: uml to csp transformation. in applications of graph transformation with industrial relevance (agtive). 2007. [bh07] d. bisztray, r. heckel. rule-level verification of business process transformations using csp. in proceedings of the 6th international workshop on graph transformation and visual modeling techniques (gt-vmt’07). 2007. [lt] de lara, j. and taentzer, g. automated model transformation and its validation with atom3 and agg. in lecture notes in artificial intelligence, 2980. pp. 182– 198. springer. [df05] e. denney, b. fischer. certifiable program generation. in glück and lowry (eds.), gpce. lecture notes in computer science 3676, pp. 17–28. springer, 2005. [eee+07] h. ehrig, k. ehrig, c. ermel, f. hermann, g. taentzer. information preserving bidirectional model transformations. in fundamental approaches to software engineering. pp. 72–86. 2007. doi:http://dx.doi.org/10.1007/978-3-540-71289-3 7 [ggl+06] h. giese, s. glesner, j. leitner, w. schfer, r. wagner. towards verified model transformations. october 2006. [hoa78] c. a. r. hoare. communicating sequential processes. commun. acm 21(8):666– 677, 1978. 13 / 14 volume 10 (2008) http://dx.doi.org/http://doi.acm.org/10.1145/949344.949347 http://dx.doi.org/http://dx.doi.org/10.1007/978-3-540-71289-3_7 verifying model transformations [hol97] g. j. holzmann. the model checker spin. ieee trans. softw. eng. 23(5):279–295, 1997. doi:http://dx.doi.org/10.1109/32.588521 [k0̈4] j. m. küster. systematic validation of model transformations. in proceedings 3rd uml workshop in software model engineering (wisme 2004). october 2004. [khe03] j. m. küster, r. heckel, g. engels. defining and validating transformations of uml models. in hcc ’03: proceedings of the 2003 ieee symposium on human centric computing languages and environments. pp. 145–152. ieee computer society, washington, dc, usa, 2003. [lbm+01] a. ledeczi, a. bakay, m. maroti, p. volgyesi, g. nordstrom, j. sprinkle, g. karsai. composing domain-specific design environments. computer 34(11):44–51, 2001. doi:http://dx.doi.org/10.1109/2.963443 [llmc06] l. lengyel, t. levendovszky, g. mezei, h. charaf. model-based development with strictly controlled model transformation. in the 2nd international workshop on model-driven enterprise information systems, mdeis 2006. pp. 39–48. paphos, cyprus, may 2006. [mv05] t. mens, p. van gorp. a taxonomy of model transformation. in proc. int’l workshop on graph and model transformation. 2005. [nk06] a. narayanan, g. karsai. towards verifying model transformations. in bruni and varro (eds.), graph transformation and visual modeling techniques gt-vmt 2006. electronic notes in theoretical computer science, pp. 185–194. 2006. [omg05] omg. meta object facility (mof) 2.0 query/view/transformation specification. 2005. http://www.omg.org/cgi-bin/doc?ptc/2005-11-01. [omg06] omg. unifed modeling language, version 2.1.1. 2006. ”http://www.omg.org/technology/documents/formal/uml.htm” [san04] d. sangiorgi. bisimulation: from the origins to today. in lics ’04: proceedings of the 19th annual ieee symposium on logic in computer science (lics’04). pp. 298–302. ieee computer society, washington, dc, usa, 2004. doi:http://dx.doi.org/10.1109/lics.2004.13 [sch95] a. schürr. specification of graph translators with triple graph grammars. in wg ’94: proceedings of the 20th international workshop on graph-theoretic concepts in computer science. pp. 151–163. springer-verlag, london, uk, 1995. [vp03] d. varró, a. pataricza. automated formal verification of model transformations. in jürjens et al. (eds.), csduml 2003: critical systems development in uml; proceedings of the uml’03 workshop. technical report tum-i0323, pp. 63–78. technische universität münchen, september 2003. proc. gt-vmt 2008 14 / 14 http://dx.doi.org/http://dx.doi.org/10.1109/32.588521 http://dx.doi.org/http://dx.doi.org/10.1109/2.963443 http://www.omg.org/cgi-bin/doc?ptc/2005-11-01 "http://www.omg.org/technology/documents/formal/uml.htm" http://dx.doi.org/http://dx.doi.org/10.1109/lics.2004.13 introduction background great instance based verification of model transformations uml to csp transformation structural correspondence structural correspondence rules for uml to csp transformation specifying structural correspondence rules in great evaluating the structural correspondence rules remarks related work mof qvt relations language triple graph grammars conclusions and future work parsing of hyperedge replacement grammars with graph parser combinators electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) parsing of hyperedge replacement grammars with graph parser combinators steffen mazanek and mark minas 14 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst parsing of hyperedge replacement grammars with graph parser combinators steffen mazanek1 and mark minas2 1 steffen.mazanek@unibw.de 2 mark.minas@unibw.de institut für softwaretechnologie universität der bundeswehr münchen, germany abstract: graph parsing is known to be computationally expensive. for this reason the construction of special-purpose parsers may be beneficial for particular graph languages. in the domain of string languages so-called parser combinators are very popular for writing efficient parsers. inspired by this approach, we have proposed graph parser combinators in a recent paper, a framework for the rapid development of special-purpose graph parsers. our basic idea has been to define primitive graph parsers for elementary graph components and a set of combinators for the flexible construction of more advanced graph parsers. following this approach, a declarative, but also more operational description of a graph language can be given that is a parser at the same time. in this paper we address the question how the process of writing correct parsers on top of our framework can be simplified by demonstrating the translation of hyperedge replacement grammars into graph parsers. the result are recursive descent parsers as known from string parsing with some additional nondeterminism. keywords: graph parsing, functional programming, parser combinators, hyperedge replacement grammars 1 introduction graph languages are widely-used nowadays, e.g., for modeling and specification. for instance, we have specified visual languages using graph grammars [min02]. in this context we are particularly interested in solving the membership problem, i.e., checking whether a given graph belongs to a particular graph language, and parsing, i.e., finding a corresponding derivation. however, while string parsing of context-free languages can be performed in o(n3), e.g., by using the well-known algorithm of cocke, younger and kasami [kas65], graph parsing is computationally expensive. there are even context-free graph languages the parsing of which is np-complete [dhk97]. thus a general-purpose graph parser cannot be expected to run in polynomial time for arbitrary grammars. the situation can be improved by imposing particular restrictions on the graph languages or grammars. anyhow, even if a language can be parsed in polynomial time by a general-purpose parser, a special-purpose parser tailored to the language is likely to outperform it. 1 / 14 volume 10 (2008) mailto:steffen.mazanek@unibw.de mailto:mark.minas@unibw.de graph parser combinators unfortunately the development of a special-purpose graph parser is an error-prone and timeconsuming task. the parser has to be optimized such that it is as efficient as possible, but still correct. backtracking, for instance, has to be prevented wherever possible. therefore, in a recent paper [mm08] we have proposed graph parser combinators, a new approach to graph parsing that allows the rapid construction of special-purpose graph parsers. further we have introduced a haskell [pey03] library implementing this approach. it provides the generic parsing framework and a predefined set of frequently needed combinators. in [mm08] we further have demonstrated the use of this combinator framework by providing an efficient special-purpose graph parser for vex [chz95] as an example. vex is a graph language for the representation of lambda terms. the performance gains mainly have resulted from the fact, that vex is context-sensitive and ambiguous – properties many general-purpose graph parsers do not cope well with. the structure of vex graphs is quite simple though, i.e., they basically are trees closely reflecting the structure of lambda terms. only variable occurrences are not identified by names as usual; they rather have to refer to their binding explicitly by an edge. nevertheless, the parser for vex could be defined quite operationally as a tree traversal. however, the operational description of languages like, e.g., structured flowgraphs is much more difficult. parsers get very complex and hard to read and verify. this brings up the question, whether graph parser combinators actually are powerful enough to express standard graph grammar formalisms. one such formalism are hyperedge replacement grammars [dhk97], which allow such languages to be described in a declarative and natural way. therefore, the main contribution of this paper is a method for the straightforward translation of hyperedge replacement grammars [dhk97] to parsers on top of our framework. the resulting parsers are readable and can be customized in a variety of ways. they are quite similar to top-down recursive descent parsers as known from string parsing where nonterminal symbols are mapped to functions. unfortunately, in a graph setting we have to deal with additional nondeterminism: besides different productions for one and the same nonterminal, we also have to guess particular nodes occurring in the right-hand side of a production. we can use backtracking, but performance naturally suffers. however, our approach can be used to build an initial, yet less efficient parser. languagespecific performance optimizations can then be used to improve the parser’s efficiency step by step. moreover, the presented approach offers the following benefits: • combination of declarative and operational description of the graph language. • an application-specific result can be computed.1 • context information can be used to describe a much broader range of languages. • robust against errors. the largest valid subgraph is identified. this paper is structured as follows: we discuss the combinator approach to parsing in sect. 2 and introduce our graph model in sect. 3. we go on with the presentation of our framework in sect. 4 and discuss the actual mapping of a hyperedge replacement grammar in sect. 5. finally, we discuss related work (sect. 6) and conclude (sect. 7). 1 a general-purpose parser normally returns a derivation sequence or a parse tree, respectively. several systems, however, provide support for attributed graph grammars. proc. gt-vmt 2008 2 / 14 eceasst 2 parser combinators our approach has been inspired by the work of hutton and meijer [hm96] who have proposed monadic parser combinators for string parsing (although the idea of parser combinators actually is much older). the basic principle of such a parser combinator library is that primitive parsers are provided that can be combined into more advanced parsers using a set of powerful combinators. for example, there are the sequence and choice combinators that can be used to emulate a grammar. however, a wide range of other combinators are also possible. for instance, parser combinator libraries often include a combinator many that applies a given parser multiple times, while collecting the results. parser combinators are very popular, because they integrate seamlessly with the rest of the program and hence the full power of the host language can be used. unlike yacc [joh75] no extra formalism is needed to specify the grammar. functional languages are particularly well-suited for the implementation of combinator libraries. here, a parser basically is a function (as we will see). a combinator like choice then is a higher-order function. higher-order functions, i.e., functions whose parameters are functions again, support the convenient reuse of existing concepts [hug89]. for instance, consider a function symb with type char->parser that constructs a parser accepting a particular symbol. then we can easily construct a list pl of parsers, e.g., by defining pl=map symb [’a’..’z’] (applies symb to each letter). a parser lcl that accepts an arbitrary lower-case letter then can be constructed by folding pl via the choice operator, i.e., lcl=foldr choice fail pl. thereby, fail is the neutral element of choice. at this point, we provide a toy example to give an impression of how a parser constructed with monadic combinators looks like. for that purpose we compare the implementation of a parser for the string language {akbkck|k > 0} and a graph parser for the corresponding language of string graphs as defined in [dhk97]. an important advantage of the combinator approach is that a more operational description of a language can be given. for instance, our exemplary language of strings akbkck is not contextfree. hence a general-purpose parser for context-free languages cannot be applied at all, although parsing this language actually is very easy: “take as many a characters as possible, then accept the same number of b characters and finally accept the same number of c characters.” using polyparse [wal07], a well-known and freely-available parser combinator library for strings, a parser for this string language can be defined as shown in fig. 1a. the type of this parser determines that the tokens are characters and the result a number, i.e., k for a string akbkck. abc::parser char int abc = do as<-many1 (char ’a’) let k=length as exactly k (char ’b’) exactly k (char ’c’) return k abcg::node->grappa int abcg n = do (n’,as)<-chain1 (diredge "a") n let k=length as (n’’,_)<-exactchain k (diredge "b") n’ exactchain k (diredge "c") n’’ return k figure 1: parsers for a) the string and b) the graph language akbkck 3 / 14 volume 10 (2008) graph parser combinators figure 2: the string graph “aabbcc” if the given word does not begin with a member of the language one of the calls of exactly fails. the code is written in the functional programming language haskell [pey03]. the given parser uses the do-notation, syntactic sugar haskell provides for dealing with monads. monads in turn provide a means to simulate state in haskell. in the context of parsers they are used to hide yet unconsumed input. otherwise, all parsers in a sequence would have to pass this list as a parameter explicitly. users of the library, however, do not have to know how this works in detail. they rather can use the library like a domain-specific language for parsing nicely embedded into a fully-fledged programming language. in order to motivate our combinator approach to graph parsing, we provide the graph equivalent to the previously introduced string parser abc. strings generally can be represented as directed, edge-labeled graphs straightforwardly. for instance, fig. 2 provides the graph representation of the string “aabbcc”.2 a graph parser for this graph language can be defined using our combinators in a manner quite similar to the parser discussed above. it is shown in fig. 1b. the main difference between the implementations of abc and abcg is, that we have to pass through the position, i.e., the node n we currently process. 3 graphs in this section we introduce hypergraphs and the basic haskell types for their representation. our graph model differs from standard definitions as found in, e.g., [dhk97], that do not introduce the notion of a context. let c be a set of labels and type : c → in a typing function for c. in the following, a hypergraph h over c is a finite set of tuples (lab, e, ns), where e is a (hyper-)edge3 identifier unique in h, lab ∈ c is an edge label and ns is a sequence of node identifiers such that type(lab) = |ns|, the length of the sequence. the nodes represented by the node identifiers in ns are called incident to edge e. we call a tuple (lab, e, ns) a context in analogy to [erw01]. the position of a particular node n in the sequence of nodes within the context of an edge e represents the so-called tentacle of e that n is attached to. hence the order of nodes matters. 2 in contrast to the string language there is a context-free hyperedge replacement grammar describing this language. however, it is quite complicated despite the simplicity of the language (cf. [dhk97]). an earley-style parser for string generating hypergraph grammars like this is discussed in [sf04]. 3 we call hyperedges just edges and hypergraphs just graphs if it is clear from the context that we are talking about hypergraphs. proc. gt-vmt 2008 4 / 14 eceasst figure 3: an exemplary flowchart a) and its hypergraph representation b) the same node identifier also may occur in more than one context indicating that the edges represented by those contexts are connected via this node. note, that our notion of hypergraphs is slightly more restrictive than the usual one, because we cannot represent isolated nodes. in particular the nodes of h are implicitly given as the union of all nodes incident to its edges. in fact, in many hypergraph application areas isolated nodes simply do not occur. for example, in the context of visual languages diagram components can be represented by hyperedges, and nodes just represent their connection points, i.e., each node is attached to at least one edge [min02]. the following haskell code introduces the basic data structures for representing nodes, edges and graphs altogether: type node = int type edge = int type tentacle = int type context = (string, edge, [node]) type graph = set context for the sake of simplicity, we represent nodes and edges by integer numbers. we declare a graph as a set of contexts, where each context represents a labeled edge including its incident nodes.4 throughout this paper we use flowcharts as a running example. in fig. 3a a structured flowchart is given. syntax analysis of structured flowcharts means to identify the represented structured program (if any). therefore, each flowchart must have a unique entry and a unique exit point. 4 in the actual implementation these types are parameterized and can be used more flexibly. 5 / 14 volume 10 (2008) graph parser combinators flowcharts can be represented by hypergraphs that we call flowgraphs in the following. in fig. 3b the hypergraph representation of the exemplary flowchart is given. hyperedges are represented by a rectangular box marked with a particular label. for instance, the statement n:=0 is mapped to a hyperedge labeled “text”. the filled black circles represent nodes that we have additionally marked with numbers. a line between a hyperedge and a node indicates that the node is visited by that hyperedge. the small numbers close to the hyperedges are the tentacle numbers. without these numbers the image may be ambiguous. for instance, the tentacle with number 0 of “text” hyperedges always has to be attached to the node the previous statement ends at whereas the tentacle 1 links the statement to its successor. the flowgraph given in fig. 3b is represented as follows using the previous declarations: fcg = {("start",0,[1]), ("text",1,[1,2]), ("cond",2,[2,7,3]), ("cond",3,[3,4,5]), ("text",4,[4,6]), ("text",5,[5,6]), ("text",6,[6,2]), ("end",7,[7])} the language of flowgraphs can be described using a hyperedge replacement grammar in a straightforward way as we see in the next section. we provide a special-purpose parser for flowgraphs on top of our framework in sect. 5. 4 parsing graphs with combinators in this section we introduce our graph parser combinators. however, first we clarify the notion of parsing in a graph setting. 4.1 graph grammars and parsers a widely known kind of graph grammar are hyperedge replacement grammars (hrg) as described in [dhk97]. here, a nonterminal hyperedge of a given hypergraph is replaced by a new hypergraph that is glued to the remaining graph by fusing particular nodes. formally, such a hrg g is a quadruple g = (n, t, p, s) that consists of a set of nonterminals n ⊂ c, a set of terminals t ⊂ c with t ∩ n = /0, a finite set of productions p and a start symbol s ∈ n. the graph grammar for flowgraphs can be defined as gfc = (nfc, tfc, pfc, fc) where nfc = {fc, stmts, stmt}, tfc = {start, end, text, cond} and pfc contains the productions given in fig. 4a. left-hand side lhs and right-hand side rhs of each production are separated by the symbol ::= and several rhs of one and the same lhs are separated by vertical bars. node numbers are used to identify corresponding nodes of lhs and rhs. the derivation tree of our exemplary flowgraph as introduced in fig. 3b is given in fig. 4b. its leaves are the terminal edges occurring in the graph whereas its inner nodes are marked with nonterminal edges indicating the application of a production. the direct descendants of an inner node represent the edges occurring in the rhs of the applied production. the numbers in parentheses thereby identify the nodes visited by the particular edge. a general-purpose graph parser for hrgs gets passed a particular hrg and a graph as parameters and constructs a derivation tree of this graph according to the grammar. this can be proc. gt-vmt 2008 6 / 14 eceasst figure 4: flowgraphs, a) grammar and b) derivation tree of the example done, for instance, in a way similar to the well-known algorithm of cocke, younger and kasami [kas65] known from string parsing (indeed, all hrgs that do not generate graphs with isolated nodes can be transformed to the graph equivalent of the string notion chomsky normal form). this approach has been elaborated theoretically by lautemann [lau89] and proven to be useful in practical applications, e.g., in [min02] for the syntax analysis of diagrams. flowgraphs can be parsed with such a general-purpose graph parser in a straightforward way. however, as mentioned in the introduction there are graph languages that are not context-free (and thus cannot be described by a hrg) or that are highly ambiguous (thus causing most general-purpose parsers to perform poorly). furthermore, here we are not interested in the derivation tree, but rather in the program represented by the graph, i.e., its semantics. for these reasons graph parser combinators are beneficial either way. we now briefly introduce the framework and describe how the hrg of flowgraphs (and other hrgs similarly) can be translated into a graph parser on top of our framework. 4.2 the combinator library due to space restrictions in the following we focus on those types and functions that are needed to translate hyperedge replacement grammars schematically. further information and a more general version of the framework can be found in [mm08]. first we provide the declaration of the type grappa representing a graph parser: newtype grappa res = p (graph -> (either res error, graph)) this type is parameterized over the type res of the result. graph parsers basically are functions from graphs to pairs consisting of the parsing result (or an error message, respectively) and the graph that remains after successful parser application. 7 / 14 volume 10 (2008) graph parser combinators name type description context (context->bool)-> grappa context a context satisfying a particular condition. labcontext string->grappa context a context with a particular label. connlabcontext string->[(tentacle,node)]-> grappa context a labeled context connected to the given nodes via the given tentacles. edge tentacle->tentacle->string-> node->grappa (node,context) a labeled context connected to the given node via a particular tentacle also returning its successor (via the other, outgoing tentacle). diredge string->node-> grappa (node,context) a directed edge, edge 0 1. table 1: graph-specific primitive parsers name type description oneof [grappa res]->grappa res returns the first successful parser of the input list, corresponds to | in grammars. chain (node->grappa (node, res))-> node->grappa (node, [res]) a chain of graphs, a node is passed through. bestnode (node->grappa res)-> grappa res identifies the node from which the best continuation is possible, very expensive. nodangledgeat node->grappa () succeeds if the given node is not incident to an edge, handy for ensuring dangling edge condition. alldifferent [node]->grappa () succeeds if the given nodes are distinct, handy for ensuring identification condition. conncomp grappa res->grappa [res] applies the given parser once per connected component, while collecting the results. table 2: some graph parser combinators in general, the most primitive parsers are return and fail. both do not consume any input. rather return succeeds unconditionally with a particular result whereas fail always fails; thereby, backtracking is initiated. in table 1 we provide some important graph-specific primitive parsers. they are all nondeterministic, i.e., support backtracking on failure, and consume the context they return. additionally we provide the primitive parser anode::grappa node that returns a node of the remaining graph (with backtracking). in table 2 we briefly sketch some of the graph parser combinators provided by our library. variations of chain have already been used in the introductory example, e.g., chain1 that demands at least one occurrence. proc. gt-vmt 2008 8 / 14 eceasst fc::grappa program fc = do (_,_,[n1])<-labcontext "start" (_,_,[n2])<-labcontext "end" stmts (n1,n2) stmts::(node, node)->grappa program stmts (n1, n2) = oneof [stmts1, stmts2] where stmts1 = do s<-stmt (n1, n2) return [s] stmts2 = do n’<-anode s<-stmt (n1, n’) p<-stmts (n’, n2) return (s:p) stmt::(node, node)->grappa stmt stmt (n1, n2) = oneof [stmt1, stmt2, stmt3] where stmt1 = do connlabcontext "text" [(0,n1),(1,n2)] return text stmt2 = do (_,_,ns)<-connlabcontext "cond" [(0,n1)] p1<-stmts ((ns!!1), n2) p2<-stmts ((ns!!2), n2) return (ifelse p1 p2) stmt3 = do (_,_,ns)<-connlabcontext "cond" [(0,n1),(1,n2)] p<-stmts ((ns!!2), n1) return (while p) figure 5: a parser for flowgraphs 5 parsing flowgraphs in this section we directly translate the grammar given in fig. 4a to a parser for the corresponding language using our framework. our goal is to map a flowgraph to its underlying program represented by the recursively defined type program: type program = [stmt] data stmt = text | ifelse program program | while program in fig. 5 the parser for flowgraphs is presented. it is not optimized with respect to performance. rather it is written in a way that makes the translation of the hrg explicit. for each nonterminal edge label l we have defined a parser function that takes a tuple of nodes (n1, ..., nt ) as a parameter such that t = type(l). several rhs of a production are handled using the oneof 9 / 14 volume 10 (2008) graph parser combinators combinator. terminal edges are matched and consumed using primitive parsers. thereby their proper embedding has to be ensured. we use the standard list operator (!!) to extract the node visited via a particular tentacle from a node list ns. for instance, stmt3 represents the while-production. first, a “cond”-edge e visiting the nodes n1 and n2 via the tentacles 0 and 1, respectively, is matched and consumed. thereafter the body of the loop is parsed, i.e., the stmts starting at the node visited by tentacle 2 of e, i.e., ns!!2, ending again at n1. finally the result is constructed and returned. if something goes wrong and backtracking becomes necessary, previously consumed input is released automatically. the parser is quite robust. for instance, redundant components are just ignored and both the dangling and the identification condition are not enforced. these relaxations can be canceled easily – the first one by adding the primitive parser eoi (end of input) to the end of the definition of the top-level parser, the others by applying the combinators nodangledgeat and alldifferent, respectively, to the nodes involved. note, that the implementation of stmts follows a common pattern, i.e., a chain of graphs between two given nodes. so using a combinator the parser declaration can be further simplified to stmts=chain1betw stmt. here, chain1betw ensures at least one occurrence as required by the language. its signature is chain1betw::((node,node)->grappa a)->(node,node)->grappa [a] and it is defined exactly as stmts except from the fact that it abstracts from the actual parser for the partial graphs. performance this parser is not very efficient. a major source of inefficiency is the use of anode that binds a yet unknown node arbitrarily thus causing a lot of backtracking. this expensive operation has to be used only for the translation of those productions, where inner nodes within the rhs are not incident to terminal edges visiting an external node, i.e., a node also occurring in the lhs.5 however, even so there are several possibilities for improvement. for instance, we currently try to make this search more targeted by the use of narrowing techniques as known from functional-logic programming languages [han07]. performance can be further improved if particular branches of the search space can be cut. for instance, we can prevent backtracking by committing to a (partial) result. in [mm08] we have demonstrated how this can be done in our framework. finally, we can apply domain-specific techniques to further improve the performance. for instance, a basic improvement would be to first decompose the given graph into connected components and apply the parser to each of them successively. we provide the combinator conncomp for this task. however, this step can only be applied to certain languages and at the expense of readability. so we can start with an easy to build and read parser for a broad range of languages. it may be less efficient, however, it can be improved step by step if necessary. further it can be integrated and reused very flexibly, since it is a first-class object. 5 the function anode can also be used to identify the start node in our introductory example abcg. proc. gt-vmt 2008 10 / 14 eceasst 6 related work our parser combinator framework basically is an adaptation of the polyparse library [wal07]. the main distinguishing characteristics of polyparse are that backtracking is the default behavior except where explicitly disallowed and that parsers can be written using monads. there is an abundance of other parser combinator libraries besides polyparse that we cannot discuss here. however, a particularly interesting one is the uu parser combinator library of utrecht university [sa99]. it is highly sophisticated and powerful, but harder to learn for a user. its key benefit is its support for error correction. hence a parser does not fail, but a sequence of correction steps is constructed instead. approaches to parsing of particular, restricted kinds of graph grammar formalisms are also related. for instance, in [sf04] an earley parser for string generating graph languages has been proposed. the diagram editor generator diagen [min02] incorporates an hrg parser that is an adaptation of the algorithm of cocke, younger and kasami. and the visual language compilercompiler vlcc [clot97] is based on the methodology of positional grammars that allows to parse restricted kinds of flex grammars (which are essentially hrgs) even in linear time. these approaches have in common that a restricted graph grammar formalism can be parsed efficiently. however, they cannot be generalized straightforwardly to a broader range of languages like our combinators. we have demonstrated that semantics can be added very flexibly in our framework. the graph transformation system agg also provides a flexible attribution concept. here, graphs can be attributed by arbitrary java objects [tae03]. rules can be attributed with java expressions allowing complex computations during the transformation process. agg does not deal with hypergraphs. however, it can deal with a broad range of graph grammars. these are given as so-called parse grammars directly deconstructing the input graph. critical pair analysis is used to organize reverse rule application. in [rs95] a parsing algorithm for context-sensitive graph grammars with a top-down and a bottom-up phase is discussed. thereby first a set of eventually useful production applications is constructed bottom-up. thereafter viable derivations from this set are computed top-down. parser combinators generally follow a top-down approach, although in a graph setting bottomup elements are beneficial from a performance point of view. finally there are other approaches that aim at the combination of functional programming and graph transformation. schneider, for instance, currently prepares a textbook that provides an implementation of the categorical approach to graph transformation with haskell [sch07]. since graphs are a category, a higher level of abstraction is used to implement graph transformation algorithms. an even more general framework is provided in [ks00]. the benefit of their approach is its generality since it just depends on categories with certain properties. however, up to now parsing is not considered. 11 / 14 volume 10 (2008) graph parser combinators 7 concluding remarks in this paper we have discussed graph parser combinators, an extensible framework supporting the flexible construction of special-purpose graph parsers even for context-sensitive graph grammars. it already provides combinators for the parsing of several frequently occurring graph patterns. we even may end with a comprehensive collection of reusable parser components. parser combinators are best used to describe a language in an operational way. for instance, we have provided a parser for the graph language akbkck as a toy example. similar situations, however, also appear in practical applications as, e.g., discussed in [kör08]. we further have provided a schema for the straightforward translation of hyperedge replacement grammars into parsers on top of our framework. we have demonstrated this using the language of flowgraphs as an example. the resulting parser is not efficient. it is rather a proof of concept. languages like flowgraphs can be parsed very efficiently using a standard bottom-up parser. however, the main benefit of our framework is that language-specific optimizations can be incorporated easily in existing parsers, e.g., by providing additional information, using special-purpose combinators, heuristics or even a bottom-up pass simplifying the graph. parsing generally is known to be an area functional languages excel in. in the context of string parsing a broad range of different approaches have been discussed. however, in particular the popular combinator approach has not been applied to graph parsing yet. with the implementation of our library we have demonstrated that graph parser combinators are possible and beneficial for the rapid development of special-purpose graph parsers. future work our approach is not restricted to functional languages though. for instance, in [ad01] the translation of string parser combinators to the object-oriented programming language java is described. we plan to adapt this approach in the future to, e.g., integrate graph parser combinators into the diagram editor generator diagen [min02]. this hopefully will allow the convenient description of even more visual languages. the parsers presented in this paper suffer from the fact that purely functional languages are not particularly dedicated to deal with incomplete information. for instance, we have discussed why inner nodes occurring in the right-hand sides of productions have to be guessed. multiparadigm declarative languages [han07] like curry [han], or even logic libraries like [nar07], are well-suited for such kinds of problems. we currently reimplement our library in a functionallogic style to overcome these limitations. this work will also clarify the relation to proof search in linear logic [gir87]. here, the edges of a hypergraph can be mapped to facts that can be connected to a parser via so-called linear implication ((). during the proof the parser consumes these facts and at the end none of them must be left. we further plan to investigate error correction-strategies in a graph setting. for instance, in the context of visual language editors based on graph grammars this would allow for powerful content assist. whereas in a string setting error-correcting parser combinators are well-understood already [sa99], not much has been done with respect to graphs yet. admittedly, we do not expect to find an efficient solution to the problem at large. with certain restrictions some kinds of corrections might be possible though. proc. gt-vmt 2008 12 / 14 eceasst bibliography [ad01] d. s. s. atze dijkstra. lazy functional parser combinators in java. technical report uu-cs-2001-18, department of information and computing sciences, utrecht university, 2001. [chz95] w. citrin, r. hall, b. zorn. programming with visual expressions. in haarslev (ed.), proc. 11th ieee symp. vis. lang. pp. 294–301. ieee computer soc. press, 5–9 1995. [clot97] g. costagliola, a. d. lucia, s. orefice, g. tortora. a parsing methodology for the implementation of visual systems. ieee trans. softw. eng. 23(12):777–799, 1997. [dhk97] f. drewes, a. habel, h.-j. kreowski. hyperedge replacement graph grammars. in rozenberg (ed.), handbook of graph grammars and computing by graph transformation. vol. i: foundations. chapter 2, pp. 95–162. world scientific, 1997. [erw01] m. erwig. inductive graphs and functional graph algorithms. j. funct. program. 11(5):467–492, 2001. [gir87] j.-y. girard. linear logic. theoretical computer science 50:1–102, 1987. [han] hanus, m. (ed.). curry: an integrated functional logic language. available at http://www.informatik.uni-kiel.de/˜curry/. [han07] m. hanus. multi-paradigm declarative languages. in proc. of the intl. conference on logic programming (iclp 2007). pp. 45–75. springer, 2007. [hm96] g. hutton, e. meijer. monadic parser combinators. technical report nottcs-tr96-4, department of computer science, university of nottingham, 1996. [hug89] j. hughes. why functional programming matters. comput. j. 32(2):98–107, 1989. [joh75] s. c. johnson. yacc: yet another compiler compiler. technical report 32, bell laboratories, murray hill, new jersey, 1975. [kas65] t. kasami. an efficient recognition and syntax analysis algorithm for context free languages. scientific report af crl-65-758, air force cambridge research laboratory, bedford, massachussetts, 1965. [kör08] a. körtgen. modeling successively connected repetitive subgraphs. in proc. of the 3rd intl. workshop on applications of graph transformation with industrial relevance (agtive’07). lncs. springer, 2008. [ks00] w. kahl, g. schmidt. exploring (finite) relation algebras using tools written in haskell. technical report 2000-02, fakultät für informatik, universität der bundeswehr, münchen, 2000. 13 / 14 volume 10 (2008) graph parser combinators [lau89] c. lautemann. the complexity of graph languages generated by hyperedge replacement. acta inf. 27(5):399–421, 1989. [min02] m. minas. concepts and realization of a diagram editor generator based on hypergraph transformation. science of computer programming 44(2):157–180, 2002. [mm08] s. mazanek, m. minas. graph parser combinators. in proc. of the 19th intl. symposium on the implementation and application of functional languages. lncs. springer, 2008. [nar07] m. naylor, e. axelsson, c. runciman. a functional-logic library for wired. in proc. of the acm sigplan workshop on haskell. pp. 37–48. acm, 2007. [pey03] s. peyton jones. haskell 98 language and libraries. the revised report. cambridge university press, 2003. [rs95] j. rekers, a. schürr. a parsing algorithm for context sensitive graph grammars. technical report 95-05, leiden university, 1995. [sa99] s. d. swierstra, p. r. azero alcocer. fast, error correcting parser combinators: a short tutorial. in pavelka et al. (eds.), 26th seminar on current trends in theory and practice of inform. lncs 1725, pp. 111–129. 1999. [sch07] h. j. schneider. graph transformations an introduction to the categorical approach. 2007. http://www2.cs.fau.de/˜schneide/gtbook/. [sf04] s. seifert, i. fischer. parsing string generating hypergraph grammars. in ehrig et al. (eds.), graph transformations. lncs 3256, pp. 352–367. springer, 2004. [tae03] g. taentzer. agg: a graph transformation environment for modeling and validation of software. in pfaltz et al. (eds.), agtive. lncs 3062, pp. 446–453. springer, 2003. [wal07] m. wallace. polyparse. 2007. http://www.cs.york.ac.uk/fp/polyparse/. proc. gt-vmt 2008 14 / 14 introduction parser combinators graphs parsing graphs with combinators graph grammars and parsers the combinator library parsing flowgraphs related work concluding remarks microsoft word silvamarialucenasetra.doc electronic communications of the easst volume 3 (2006) guest editors: jean-marie favre, reiko heckel, tom mens managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 proceedings of the third workshop on software evolution through transformations: embracing the change (setra 2006) a mde-based approach for developing multi-agent systems viviane torres da silva, beatriz de maria, carlos j. p. de lucena 14 pages eceasst 2 / 14 volume 3 (2006) a mde-based approach for developing multi-agent systems viviane torres da silva silva*, beatriz de maria**, carlos j. p. de lucena** *departamento de sistemas informáticos y programación, ucm, spain ** departamento de informática, puc-rio, brazil viviane@fdi.ucm.es, {biamar, lucena}@inf.puc-rio.br abstract: this paper focuses on the development of multi-agent systems based on a model driven engineering approach. our goal is to cope with the traceability between design and implementation models and with the always changing characteristics of such systems. keywords: model driven architecture, multi-agent systems, transformation, evolution 1 introduction the development of multi-agent systems (mas) has rapidly increased in the last few years. modeling languages [13][17][22], platforms [16][18], methodologies [2][4][15] and some other mas modeling and implementing techniques have been proposed with the purpose of helping the developers in building such systems. although several approaches are concerned with modeling and implementing mas, only few accomplish the tracking between design models and implementation code. while dealing with mas, the refinement of design models into implementation code becomes especially difficult since it is necessary to deal with different paradigms during the system development. the agent-oriented paradigm is used while modeling the systems but, frequently, those systems are implemented by using the object-oriented paradigm (oo). since agents and objects have different properties and characteristics (for instance, agents are autonomous and goal-oriented entities that execute plans in order to achieve their goals and, different from objects, do not need external stimulus to execute and can ignore requests), the transformation from agent-oriented design models into oo code is not simple. to try to assist the implementation of mas, several oo platforms, architectures and frameworks such as [18][16] have been proposed. although such approaches satisfactory provide satisfactory support for the implementation of the mas, they fail to provide the tracing between the design models and the implementations. the numerous mas modeling language, methodologies and platforms deal with different agent properties and characteristics what directly impact in the traceability. another important concern that mostly affects the development of mas is the always changing characteristic of mas applications and techniques. since a number of fundamental questions about the nature and the use of the agent-oriented approach are still being answered, important techniques’ features and also applications’ requirements are still evolving. this paper focuses on helping the mas developers to cope with (i) the mapping between design models and implementation models and with (ii) the always changing characteristics of the mas applications and techniques. in order to achieve these two goals, we use a model driven engineering (mde) approach [11] for developing mas. being our proposal a mde approach we specify (i) the modeling languages being used to describe the short article title proc. setra 2006 3 / 14 source and target models, (ii) both models, (iii) the transformations, and (iv) some guidelines to cope with models evolution [11]. the traceability between mas design models and oo implementation models will be illustrated by the use of the multi-agent system modeling language called mas-ml [17][19] (the source modeling language), the agent society framework called asf [18] and the uml modeling language [14] (the target modeling language). the mas-ml design models (the source models) will be transformed into uml implementation models (the target models) by instantiating the asf framework according to the application characteristics. our second goal is accomplished by demonstrating that the transformation rules can be adapted to the evolution of both applications and techniques being used in the transformation. such adaptation is facilitated due to the low coupling between design and implementation models. design models are independent of the platform / framework being used to implement the system, i.e., design models are not concerned with any characteristic of the implementation technique. in addition, the framework is also defined completely independent of the modeling language being used in the design models. the paper is organized as follows. in section 2 we present the mas techniques being used in the paper: mas-ml and asf. section 3 introduces the transformation process and section 4 provides some guidelines to embrace the evolution of applications and techniques. section 5 describes some related work and section 6 draws the conclusions and discusses future work. 2 multi-agent system techniques the development process of complex and large-scale systems, such as mas, involves the construction of different models based on a variety of requirements. the transformation of a system specification into models and of these models into code is usually accomplished in a non-organized way that is not easily adaptable to technology changes. in fact, it is possible to find different modeling languages, methodologies and platforms for modeling and implementing mas but it is hard to find in the literature approaches that trace the design models into code. therefore, we propose in this paper a top-down mde approach that traces mas-ml design models into asf object-oriented code. the mas-ml modeling language mas-ml is a platform independent modeling language that extends uml incorporating agent-oriented abstractions (such as agents, organizations, environments and roles), their properties (such as goals, plans, actions, beliefs and protocols) and relationships (such as play, inhabit and ownership). although mas-ml uses agent and object-oriented abstractions, mas-ml does not restrict the implementation of its models to a specific implementation platform. figure 1 illustrates an important part of the mas-ml metamodel that presents the agent and object-oriented abstractions defined in the metamodel and the possible relationships among them. by using mas-ml it is possible to model, for instance, the roles that agents can play (by using a static diagram defined in mas-ml called organization diagram) and agents achieving their goals while executing their plans (by using the extended uml sequence diagram defined in mas-ml). eceasst 4 / 14 volume 3 (2006) class agentclass organizationclass agentroleclass environmentclass play 1 1..*0..* define 1 sub-org play 1..*1 play in 0..* 1..* 1..*1 inhabit 1 0..* inhabit inhabit 1 0..* 1 suborg 0..* 1 play in play in 0..* 0..* metaclass of the uml metamodel metaclasses introduced by mas-ml legend figure 1. part of the mas-ml metamodel the asf framework the goal of asf is to help designers implementing mas by using the object-oriented paradigm. the framework defines a set of oo models where each model represents a mas entity type. the set of oo classes and relationships defined in each module makes possible the implementation of the structural aspects of mas entities (its properties and relationships with other entities) and also the dynamic ones (their behavior). figure 2 shows a uml class diagram modeling all asf classes grouped by modules. the modules that are used to instantiate agents (delimited by a continuous rectangle), organizations (defined by the dotted enlace) and agent roles (marked by the hatched rectangle) are complex modules since they group several classes to represent all the properties of these entity types. the module that corresponds to environments (hatched circle) is simple represented by one class because the properties of this entity can be directly represented as attributes and methods. in order to use asf to implement a mas application, it is necesary to instantiate the framework by extending the defined modules. the extentions should be made according to the entities characteristics defined in the application being implemented. for instance, to implement application agents by using asf it is necessary (i) to create an oo class extending the agent abstract class defined in the asf agent module to be used to instantiate the agents, (ii) to create oo classes by extending the plan and action classes to implement the plans and actions of the agents, (iii) to implementing the constructor method of the new agent class to create the (instances of the) beliefs, goals and plans and also (iv) to relate the agent instances to the roles that they will play, the organizations where they will play such roles and also to the environments that they will inhabit. similar steps could be followed in order to implement the organizations, roles and environments defined in the mas application. 3 the transformation process in this section we describe the transformation process used to refine mas-ml design models into uml implementation models that instantiate asf. the transformations were defined by using the atlas transformation language (atl) [9]. an atl transformation program is composed of rules (described in atl) that define how source model elements are matched and navigated to create and initialize the elements of the target models. besides the rules, an atl program receives as input (i) the metamodel of the source model (the mas-ml metamodel), (ii) the source model itself (a mas-ml model) and (iii) the metamodel of the target model (the uml metamodel). the program checks the source model according to its metamodel and, short article title proc. setra 2006 5 / 14 by using the transformation rules (mas-ml2asf rules), transforms the source model into the output target model (uml model) that is compliant with the target metamodel. in mde [11], transformation processes based on the translations between metamodels are called language translations. figure 3 illustrates the inputs and the output of the atl program that transforms mas-ml models into uml models by using the mas-ml2asf rules. <> <> <> <> <> <> <><> figure 2. the asf classes and relationships the set of rules used by the atl program to transform a mas-ml model into a uml model instantiates the asf framework according to the application features modeled in masml. the set of mas-ml2asf rules is composed of (i) one general rule that generates all the classes defined in asf (and illustrated in figure 2); (ii) five rules to transform the five entity types found in mas-ml models (and defined in the mas-ml metamodel depicted in figure 1); and (iii) three other rules to generate the concrete plans, actions and protocols that extends the abstract classes plan, action and protocol defined in asf (also illustrated in figure 2). eceasst 6 / 14 volume 3 (2006) atl program uml metamodel mas-ml metamodel mas-ml model uml model mas-ml2asf rules input outputinput input figure 3. the atl transformation process the transformation rules due to page limitation, we concentrate on demonstrating the transformation of agents modeled using mas-ml into oo classes by instantiating asf. the following sections describe the masml2asf rules used by the atl program that contemplates such transformation. the creation of the concrete agent class for each distinguished agent class modeled in a mas-ml structural diagram, one objectoriented agent class that extends the abstract asf class called agent must be created. therefore, we have implemented a rule that is executed for each agent defined in mas-ml. such rule, illustrated in the box below, is responsible for creating the agent class and for implementing the constructor method (detailed in section 0). the new classes are created with the same name of the agent classes modeled in masml models. associated with each agent class, we define a generalization relationship in order to model the new agent class extending the abstract agent class defined in asf. due to such generalization, the new agent class inherits all the attributes (and relationships) defined in the abstract class. the set of features of the new class is composed of (i) the constructor method, (ii) methods for instantiating goals, beliefs, plans and actions, and (iii) methods for creating the associations between agent instances and the role instances to be played, and the associations between the agent instances and the environment instances. rule agent { from c : masml!agentclass to --------------------------- -creating the agent class outagent : uml!class ( name iterate (e; body : string = '' | body+' belief newbelief = null; beliefs = new vector(); newbelief = new belief('+e.type+','+e.value+'); -instantiating a belief beliefs.add(newbelief);') ), operationcreatebeliefs : uml!operation ( isabstract iterate (e; body : string = '' | body+' plan newplan = null; plans = new vector(); newplan = new '+e.name+'(); -instantiating a plan plans.add(newplan);') ), operationcreateplans : uml!operation ( isabstract iterate (e; body : string = '' | body+' this.environment = new '+e.env.name+'();') --environment ), operationinhab : uml!operation ( isabstract iterate (e; body : string = '' | body+' //roles being played agentrole newrole = null; rolesbeingplayed = new vector(); newrole = new '+e.role.name+'();-instantiating the role newrole.setagent(this); newrole.setorganization(\''+e.org.name+'\');-associating with the organization rolesbeingplayed.add(newrole); // organizations where is playng roles mainorganization neworg = null; organizations = new vector(); neworg = new '+e.org.name+'(); neworg.setagentrole(\''+e.role.name+'\'); organizations.add(neworg);') ), operationplays : uml!operation ( isabstract iterate (e; body : string = '' | body+' action newaction = null; actions = new vector(); newaction = new '+e.name+'(); actions.add(newaction);') ), operationactions : uml!operation ( isabstract > boolean : buyitem = false → negotiation <> book : itemtobuy ... {priceagreement} paying {paymentsent} ... negotiation {bargaining, paying} → buyitem ... user agent <> boolean : buyitem = false → negotiation <> book : itemtobuy ... {priceagreement} paying {paymentsent} ... negotiation {bargaining, paying} → buyitem ... eceasst 10 / 14 volume 3 (2006) <> <> <> <> <> <> <><> <> <> <> <> <> <> <><> negotiation payingpaying negotiation() createactions() creategoals() useragent useragent() createbeliefs() createplans() createenv() createplays() useragent useragent() createbeliefs() createplans() createenv() createplays() … figure 4. transformation of a mas-ml model into a uml model by instantiating asf besides the evolution of applications, the techniques being used in our approach may also evolve. it may occur adaptations in the mas-ml metamodel, the asf framework and also in the uml metamodel. these three different technology adaptations influence the transformation rules. the evolution of the mas-ml and uml metamodel influence the transformation rules since the rules are defined to receive well-formed models according to the source metamodels and to generate well-formed models according to the target metamodel. adaptation of the asf framework clearly influence the transformation rules since the generated target models are instances of the framework and, therefore, conforms to its specification. if the framework changes its instances also change. since the design and implementation models are low coupling, changes in the mas-ml metamodel do not influence in the asf specification or in the uml metamodel, and viceversa. besides, the rules were defined to try to minimize the effort of changing them due to technique evolution, as detailed below: • there is one rule for creating all the classes defined in asf. therefore, if the asf specification evolves, it will have a minor influence into the whole set of transformation rules. the rule that generates the asf classes will need to be modified together with few short article title proc. setra 2006 11 / 14 other rules, depending on the adaptation. for instance, if the abstract agent class is modified it may be necessary to modify the agent rule that generates the specializations of the abstract agent class. • there is one rule for each entity type defined in mas-ml. if the mas-ml metamodel evolves, it will be necessary to adapt the correspondent rule(s) that deal(s) with the modified part. fortunately, each transformation rule deals with the transformation of one entity type defined in the mas-ml metamodel. for instance, if the part of the metamodel that specifies the entity type agent is adapted, it will only be necessary to modify the agent rule. • there is one rule for generating the plans, actions and protocols. since there is a need for creating oo classes for implementing plans, actions and protocols, we have defined a rule for transforming such properties. thus, if an adaptation occurs in mas-ml that affects how such properties are modeled or in asf that affects how such properties are implemented, these rules must also be adapted. • it is easy to find out the part of the uml metamodel being used in the rules. each rule identifies the part of source model that the rule is able to transform and the part of the target model that it can generate. such identification is done by point out the metaclasses of the source and target metamodels. therefore, if the uml metamodel is modified, it will be necessary to search in all transformation rules the rules that deal with the modified part. for instance, if the specification of method is changed, it will be necessary to search in all rules the part of the rules that generate methods, i.e., the part of the rules where the sentence uml!method is stated. 5 related work although, some mas methodologies such as prometheus [15], tropos [2] and mase [4] have not used an mda approach, they have already proposed the mapping between the design models into implementation code and have also provided some tools for supporting both the design and the implementation of mas. however, they do not clearly demonstrate the mapping from design models into code by presenting the rules used in the transformation. therefore, it is extremely difficult to use the design models created by using the methodologies to generate code to another platform or framework that has not been addressed by them. in addition, they do not separate the models into platform independent models and platform specific models. by using some of these methodologies, it is possible to describe platform specific details during the design of the application. in such cases, the high-level design models are platform dependent and, consequently, are not easily portable to any other platform. other authors have already used the mda approach in other to define a mas development process. vallecillo et al [21] demonstrate the use of mda to derive mas lowlevel models from mas high-level models. the authors propose to use the tropos methodology and the malaca platform [1] in the mda approach. malaca is platform where agents are defined based on the specification and reuse of software components. the highlevel models created while using the tropos methodology are transformed into low-level malaca models. however, the transformation from the tropos models into malaca models is eceasst 12 / 14 volume 3 (2006) not completely automated. it requires manual intervention. moreover, such an approach does not deal with the transformation from malaca models into code. novikay [12] analyzes how gr [3] based on the tropos visual model can be related to mda. the author interprets the mda approach as a visual modeling activity where more abstract models are refined in more detailed models, using transformation techniques. this work covers only the requirement stage existent in tropos. the difference between our approach and this approach is that ours contemplates the pim, psm and code stages. in kazakov et al. [10], the authors recommended a methodology based on a model-driven approach for the development of distributed mobile agent systems. they define a mobile agent conceptual model for distributed environments and describe a set of components, represented by a collection of intelligent mobile agents. while such an approach focuses on a specific application domain, our approach is a domain-independent development process. 6 conclusion and future work the mas development process presented in this paper intends to provide an approach for modeling and implementing mas by using mde. we presented a language translation approach that is based on the translations between the source metamodel and the target metamodel. we have implemented a set of transformation rules by using the atl transformation languages and to several mas such as a supply chain management system [7][8] as well as web-based paper submission and reviewing system [5][23]. the proposed mde based development process was illustrated by the use of mas-ml and asf. our intention while using such techniques was to demonstrate how complex it is for transforming design models into implementation code due to the use of different paradigms while modeling the applications and while implementing them. although mas-ml and asf are founded in the same agent’s properties and characteristics, it is still not an easy task to manually instantiate asf to implement mas-ml design models. therefore, the use of an (semi-)automatic transformer tool that could generate implementation code from design models is especially important while dealing with modeling language and platforms that do not share the same set of properties and characteristics. although some times it may be very difficult to define transformation rules, once those rules are defined the implementation of any design model can easily be generated. a prototyping developing tool [6] was created in order to demonstrate the feasibility of our approach. the tool allows the designers to graphically model mas systems by using masml and to implement them while generating java code by using the asf framework. with the aim of enhancing the tool, several important improvements should be made. first, the transformer that generates code from mas-ml models should also consider the mas-ml dynamic diagrams. second, the tool should make the visualization and also the modification of the uml models that represent the system implementation feasible. in addition, the tool should provide a model checker to analyze and verify the consistency of the different models (mas-ml models and uml models). references [1] amor, m.; fuentes, l.; troya, j. a component-based approach for interoperability across fipa-compliant plataforms. cooperative information agents vii, lnai 2782, p. 266-288. 2003. short article title proc. setra 2006 13 / 14 [2] bresciani, p. tropos: an agent-oriented software development methodology. int. journal of autonomous agents and multi-agents systems, 8(3):203-236, 2004. [3] corradini, a., montanari, u., rossi, f., ehrig, h., heckel, r. and lowe m. algebraic approaches to graph transformation. handbook of graph grammars and computing by graph transformation, 1997. [4] deloach, s. a. multiagent systems engineering: a methodology and language for designing agent systems. in: proc. of agent oriented information systems, 1999. [5] deloach, s. a. analysis and design using mase and agenttool. in proc. 12th midwest artificial intelligence and cognitive science conference, 2001. [6] demaria, b.; silva, v.; chore, r.; lucena, c. visualagent: a software development environment for multi-agent systems. in: tool track of brazilian symposium on software engineering, 2005. [7] fox, m. s.; barbuceanu, m., teigen, r. agent-oriented supply-chain management. the international journal of flexible manufacturing, v.12, p.165-188. 2000. [8] huget, m. agent uml class diagrams revisited. in: proc. of agent technology and software engineering (ages), 2002. [9] jouault, f, and kurtev, i. on the architectural alignment of atl and qvt. in: proc. of acm symposium on applied computing, model transformation track, dijon, france, 2006. [10] kazakov, m., abdulrab, h., debarbouille, g. a model driven approach for design of mobile agent systems for concurrent engineering: mad4ce project 2002. [11] kent, s. model driven engineering. in proceedings of third internations conference of integrated formal methods, springer, lncs 2335, pp. 286-298, 2002. [12] novikay, a. model driven architecture approach in tropos. technical report t04-0603, istituto trentino di cultura, 2004. [13] odell, j., parunak, h. bauer, b. extending uml for agents. in proceedings of agentoriented information system workshop at aaai, pp. 3-17, 2000. [14] omg, uml: unified modeling language specification. version 2.0. available at: http://www.omg.org/uml/. accessed in: 02/2005. [15] padgham, l, winikoff, m. prometheus: a methodology for developing intelligent agents, in proc. of the 1 st int. joint conf. on autonomous agents and mas, 2002. [16] pokahr, a. braubach, l., lamerdorf, w. jadex: implementing a bdi-infrastructure for jade agents. research of innovation, 3(3):76-85, 2004. [17] silva, v., lucena, c. from a conceptual framework for agents and objects to a multiagent system modeling language. journal of autonomous agents and mas, kluwer, 9(1-2), 2004. [18] silva, v., cortes, m., lucena, c. an object-oriented framework for implementing agent societies. technical report mcc32/04, puc-rio. rio de janeiro, brazil, 2004. [19] silva, v., choren, r., lucena, c. using the mas-ml to model a multi-agent system. software engineering for large-scale multi-agent systems ii, springer, 2004. [20] sycara, k., paolucci, m., van velsen, m., criampapa, j. the retsina mas infrastructure. special joint issue of autonomous agents and mas, 7(1-2):29-48, 2003. [21] vallecillo, a., amor, m., fuentes, l. bridging the gap between agent-oriented design and implementation using mda. autonomous agents and mas workshop, pp.93-108, 2004. [22] wagner, g. the agent-object-relationship metamodel. in: second international symposium: from agent theory to agent implementation, 2000. eceasst 14 / 14 volume 3 (2006) [23] zambonelli, f.; parunak, h. from design to intention: signs of a revolution. in: proc. of the 1 st int. conference on autonomous agents and mas, pp. 455-456. 2002. a unification algorithm for gp 2 electronic communications of the easst volume 71 (2015) graph computation models selected revised papers from gcm 2014 a unification algorithm for gp 2 ivaylo hristakiev and detlef plump 17 pages guest editors: rachid echahed, annegret habel, mohamed mosbah managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst a unification algorithm for gp 2 ivaylo hristakiev∗ and detlef plump the university of york, uk abstract: the graph programming language gp 2 allows to apply sets of rule schemata (or “attributed” rules) non-deterministically. to analyse conflicts of programs statically, graphs labelled with expressisons are overlayed to construct critical pairs of rule applications. each overlay induces a system of equations whose solutions represent different conflicts. we present a rule-based unification algorithm for gp expressions that is terminating, sound and complete. for every input equation, the algorithm generates a finite set of substitutions. soundness means that each of these substitutions solves the input equation. since gp labels are lists constructed by concatenation, unification modulo associativity and unit law is required. this problem, which is also known as word unification, is infinitary in general but becomes finitary due to gp’s rule schema syntax and the assumption that rule schemata are left-linear. our unification algorithm is complete in that every solution of an input equation is an instance of some substitution in the generated set. keywords: graph programs, word unification, critical pair analysis 1 introduction a common programming pattern in the graph programming language gp 2 [plu12, bfpr15] is to apply a set of graph transformation rules as long as possible. to execute such a loop {r1,...,rn}! on a host graph, in each iteration an applicable rule ri is selected and applied. as rule selection and rule matching are non-deterministic, different graphs may result from the loop. thus, if the programmer wants the loop to implement a function, a static analysis that establishes or refutes functional behaviour would be desirable. the above loop is guaranteed to produce a unique result if the rule set {r1,...,rn} is terminating and confluent. however, conventional confluence analysis via critical pairs [plu05] assumes rules with constant labels whereas gp employs rule schemata (or “attributed” rules) whose graphs are labelled with expressions. confluence of attributed graph transformation rules has been considered in [hkt02, eept06, gleo12], but we are not aware of algorithms that check confluence over non-trivial attribute algebras such as gp’s which includes list concatenation and peano arithmetic. the problem is that one cannot use syntactic unification (as in logic programming) when constructing critical pairs and checking their joinability, but has to take into account all equations valid in the attribute algebra. for example, [hkt02] presents a method of constructing critical pairs in the case where the equational theory of the attribute algebra is represented by a confluent and terminating term ∗ this author’s work is supported by a phd scholarship of the uk engineering and physical sciences research council (epsrc) 1 / 17 volume 71 (2015) a unification algorithm for gp 2 rewriting system. the algorithm first computes normal forms of the attributes of overlayed nodes and subsequently constructs the most general (syntactic) unifier of the normal forms. this has been shown to be incomplete [eept06, p.198] in that the constructed set of critical pairs need not represent all possible conflicts. for, the most general unifier produces identical attributes—but it is necessary to find all substitutions that make attributes equivalent in the algebra’s theory. graphs in gp rule schemata are labelled with lists of integer and string expressions, where lists are constructed by concatenation. in host graphs, list entries must be constant values. integers and strings are subtypes of lists in that they represent lists of length one. as a simple example, consider the program in figure 1 for calculating shortest distances. the program expects input graphs with non-negative integers as edge labels, and arbitrary lists as node labels. there must be a unique marked node (drawn shaded) whose shortest distance to each reachable node has to be calculated. the rule schemata init and add append distances main = init; {add, reduce}! init(x: list) add(x,y: list; m,n: int) x 1 ⇒ x:0 1 x:m y 1 2 n ⇒ x:m y:m+n 1 2 n reduce(x,y: list; m,n,p: int) x:m y:p 1 2 n ⇒ x:m y:m+n 1 2 n where m+n < p figure 1: a program calculating shortest distances to the labels of nodes that have not been visited before, while reduce decreases the distance of nodes that can be reached by a path that is shorter than the current distance. to construct the conflicts of the rule schemata add and reduce, their left-hand sides are overlayed. for example, the structure of the left-hand graph of reduce can match the following structure in two different ways: consider a copy of reduce in which the variables have been renamed to x′, m′, etc. to match reduce and its copy differently requires solving the system of equations 〈x:m =? y′:p′, y:p =? x′:m′〉. solutions to these equations should be as general as possible to represent all potential conflicts resulting from the above overlay. in this simple example, it is clear that the substitution σ = {x′ 7→ y, m′ 7→ p, y′ 7→ x, p′ 7→ m} is a most general solution. it gives rise to the following critical pair:1 1 for simplicity, we ignore the condition of reduce. selected revised papers from gcm 2014 2 / 17 eceasst x:p+n′ y:p 1 2 n n′ ⇐ x:m y:p 1 2 n n′ ⇒ x:m y:m+n 1 2 n n′ in general though, equations can arise that have several independent solutions. for example, the equation 〈n:x =? y:2〉 (with n of type int and x,y of type list) has the minimal solutions σ1 = {x,y 7→ empty, n 7→ 2} and σ2 = {x 7→ z:2, y 7→ n:z} where empty represents the empty list and z is a list variable. seen algebraically, we need to solve equations modulo the associativity and unit laws au = {x : (y : z) = (x : y) : z, empty : x = x, x : empty = x}. this problem is similar to word unification [bs01], which attempts to solve equations modulo associativity. (some authors consider au -unification as word unification, e.g. [jaf90]). solvability of word unification is decidable, albeit in pspace [pla99], but there is not always a finite complete set of solutions. the same holds for au-unification (see section 3). fortunately, gp’s syntax for left-hand sides of rule schemata forbids labels with more than one list variable. it turns out that by additionally forbidding shared list variables between different left-hand labels of a rule, rule overlays induce equation systems possessing finite complete sets of solutions. this paper is the first step towards a static confluence analysis for gp programs. in section 3, we present a rule-based unification algorithm for equations between left-hand expressions of rule schemata. we show that the algorithm always terminates and that it is sound in that each substitution generated by the algorithm is an au-unifier of the input equation. moreover, the algorithm is complete in that every unifier of the input equation is an instance of some unifier in the computed set of solutions. 2 gp rule schemata we refer to [plu12, bfpr15] for the definition of gp and more example programs. in this section, we define (unconditional) rule schemata which are the “building blocks” of graph programs. a graph over a label set c is a system g = (v,e,s,t,l,m), where v and e are finite sets of nodes (or vertices) and edges, s,t : e →v are the source and target functions for edges, l : v → c is the node labelling function and m : e → c is the edge labelling function. we write g (c ) for the class of all graphs over c . figure 2 shows an example for the declaration of a rule schema. the types int and string represent integers and character strings. type atom is the union of int and string, and list represents lists of atoms. given lists l1 and l2, we write l1 : l2 for the concatenation of l1 and l2. the empty list is denoted by empty. in pictures of graphs, nodes or edges without label (such as the dashed edge in figure 2) are implicitly labelled with the empty list. we equate lists of length one with their entry to obtain the syntactic and semantic subtype relationships shown in figure 3. for example, all labels in figure 2 are list expressions. figure 4 gives a grammar in extended backus-naur form defining the abstract syntax of labels. the function length return the length of a variable, while indeg and outdeg access the indegree resp. outdegree of a left-hand node in the host graph. 3 / 17 volume 71 (2015) a unification algorithm for gp 2 bridge(x,y: list; a: atom; n: int; s,t: string) a:x 1 n 2 y 3 s t ⇒ a 1 x:n 2 3 n∗n 3 s t figure 2: declaration of a gp rule schema figure 4 defines four syntactic categories of expressions: integer, string, atom and list, where integer and string are subsets of atom which in turn is a subset of list. category node is the set of node identifiers used in rule schemata. moreover, ivar, svar, avar and lvar are the sets of variables of type int, string, atom and list. we assume that these sets are disjoint and define var = ivar ∪ svar ∪ avar ∪ lvar. the mark components of labels are represented graphically rather than textually. each expression l has a unique smallest type, denoted by type(l), which can be read off the list atom int string char ⊆ ⊆ ⊇ ⊆ (z∪ char∗)∗ z∪ char∗ z char∗ char ⊆ ⊆ ⊇ ⊆ figure 3: subtype hierarchy for labels integer ::= digit {digit} | ivar | ‘−’ integer | integer arithop integer | length ‘(’ lvar | avar | svar ‘)’ | (indeg | outdeg) ‘(’ node ‘)’ arithop ::= ‘+’ | ‘-’ | ‘∗’ | ‘/’ string ::= ‘ “ ’ {char} ‘ ” ’ | svar | string ‘.’ string atom ::= integer | string | avar list ::= empty | atom | lvar | list ‘:’ list label ::= list [mark] mark ::= red | green | blue | grey | dashed | any figure 4: abstract syntax of rule schema labels selected revised papers from gcm 2014 4 / 17 eceasst hierarchy in figure 3 after l has been normalised with the rewrite rules shown at the beginning of subsection 3.2. we write type(l1) < type(l2) or type(l1) ≤ type(l2) to compare types according to the subtype hierarchy. if the types of l1 and l2 are incomparable, we write type(l1)‖ type(l2). the values of rule schema variables at execution time are determined by graph matching. to ensure that matches induce unique “actual parameters”, expressions in the left graph of a rule schema must have a simple shape. definition 1 (simple expression) a simple expression contains no arithmetic operators, no length or degree operators, no string concatenation, and at most one occurrence of a list variable. in other words, simple expressions contain no unary or binary operators except list concatenation, and at most one occurrence of a list variable. for example, given the variable declarations of figure 2, a:x and y:n:n are simple expressions whereas n∗2 or x:y are not simple. our definition of simple expressions is more restrictive than that in [plu12] because we exclude string concatenation and the unary minus. these operations (especially string concatenation) would considerably inflate the unification algorithm and its completeness proof, without posing a substantial challenge. definition 2 (rule schema) a rule schema 〈l, r, i〉 consists of graphs l,r in g (label) and a set i, the interface, such that i = vl ∩ vr. all labels in l must be simple and all variables occurring in r must also occur in l. when a rule schema is graphically declared, as in figure 2, the interface i is represented by the node numbers in l and r. nodes without numbers in l are to be deleted and nodes without numbers in r are to be created. all variables in r have to occur in l so that for a given match of l in a host graph, applying the rule schema produces a graph that is unique up to isomorphism. assumption 1 (left-linearity). we assume that rule schemata 〈l, r, i〉 are left-linear, that is, the labels of different nodes or edges in l do not contain the same list variable. this assumption is necessary to ensure that the solutions of the equations resulting from overlaying two rule schemata can be represented by a finite set of unifiers. for example, without this assumption it is easy to construct two rule schemata that induce the system of equations 〈x : 1 =? y, y =? 1 : x〉. this system has solutions {x 7→ empty,y 7→ 1}, {x 7→ 1,y 7→ 1 : 1}, {x 7→ 1 : 1,y 7→ 1 : 1 : 1},... which form a infnite, minimal and compete set of solutions (see definition 5 below). 3 unification we start with introducing some technical notions such as substitutions, unification problems and complete sets of unifiers. then, in subsection 3.2, we present our unification algorithm. in subsection 3.3, we prove that the algorithm terminates and is sound. 5 / 17 volume 71 (2015) a unification algorithm for gp 2 3.1 preliminaries a substitution is a family of mappings σ = (σx )x∈{i,s,a,l} where σi : ivar → integer, σs : svar → string, σa : avar → atom, σl : lvar → list. here integer, string, atom and list are the sets of expressions defined by the gp label grammar of figure 4. for example, if z ∈ lvar, x ∈ ivar and y ∈ svar, then we write σ = {x 7→ x+1, z 7→ y : −x : y} for the substitution that maps x to x+1, z to y : −x : y and every other variable to itself. applying a substitution σ to an expression t, denoted by tσ , means to replace every variable x in t by σ(x) simultaneously. in the above example, (z : −x)σ = y : −x : y : −(x+1). by dom(σ) we denote the set {x ∈ var | σ(x) 6= x} and by vran(σ) the set of variables occurring in the expressions {σ(x) | x ∈ var}. a substitution σ is idempotent if dom(σ)∩ vran(σ) = /0. the composition of two substitutions σ and θ , is defined as x(σ ◦θ) = { (xσ)θ if x ∈ dom(σ) xθ otherwise and is an associative operation. definition 3 (unification problem) a unification problem is a pair of an equation and a substitution p = 〈s =? t,σp〉 where s and t are simple list expressions without common variables. the symbol =? signifies that the equation must be solved rather than having to hold for all values of variables. the purpose of σp is for the unification algorithm (section 3.2) to record a partial solution. an illustration of this concept will be seen in figure 8. in section 2, we already assumed that gp rule schemata need to be left-linear. now, the problem of solving a system of equations {s1 = t1,s2 = t2} can be broken down to solving individual equations and combining the answers if σ1 and σ2 are solutions to each individual equation, then σ1 ∪ σ2 is a solution to the combined problem as σ1 and σ2 do not share variables. consider the equational axioms for associativity and unity, au = {x : (y : z) = (x : y) : z, empty : x = x, x : empty = x} where x,y,z are variables of type list, and let =au be the equivalence relation on expressions generated by these axioms. definition 4 (unifier) given a unification problem p = 〈s =? t,σp〉 a unifier of p a is a substitution θ such that sθ =au tθ and xiθ =au tiθ for each binding {xi 7→ ti} in σp . the set of all unifiers of p is denoted by u (p). we say that p is unifiable if u (p) 6= /0. the special unification problem fail represents failure and has no unifiers. a problem p = 〈s =? t,∅〉 is initial and p = 〈∅,σp〉 is solved. selected revised papers from gcm 2014 6 / 17 eceasst a substitution σ is more general on a set of variables x than a substitution θ if there exists a substitution λ such that xθ =au xσ λ for all x ∈ x . in this case we write σ ≦x θ and say that θ is an instance of σ on x . substitutions σ and θ are equivalent on x , denoted by σ =x θ , if σ ≦x θ and θ ≦x σ . definition 5 (complete set of unifiers [plo72]) a set c of substitutions is a complete set of unifiers of a unification problem p if 1. (soundness) c ⊆ u (p), that is, each substitution in c is a unifier of p, and 2. (completeness) for each θ ∈ u (p) there exists σ ∈ c such that σ ≦x θ , where x = var(p) is the set of variables occurring in p. set c is also minimal if each pair of distinct unifiers in c are incomparable with respect to ≦x . if a unification problem p is not unifiable, then the empty set ∅ is a minimal complete set of unifiers of p. for simplicity, we replace =? with = in unification problems from now on. example 1 the minimal complete set of unifiers of the problem 〈a : x = y : 2〉 (where a is an atom variable and x,y are list variables) is {σ1,σ2} with σ1 = {a 7→ 2, x 7→ empty, y 7→ empty} and σ2 = {x 7→ z : 2, y 7→ a : z}. we have σ1(a : x) = 2 : empty =au 2 =au empty : 2 = σ1(y : 2) and σ2(a : x) = a : z : 2 = σ2(y : 2). other unifiers such as σ3 = {x 7→ 2, y 7→ a} are instances of σ2. 3.2 unification algorithm we start with some notational conventions for the rest of this section: • l,m stand for simple expressions, • x,y,z stand for variables of any type (unless otherwise specified), • a,b stand for (i) simple string or integer expressions, or (ii) string, integer or atom variables • s,t stand for (i) simple string or integer expressions, or (ii) variables of any type 7 / 17 volume 71 (2015) a unification algorithm for gp 2 preprocessing. given a unification problem p = 〈s =? t,σ〉, we rewrite the terms in s and t using the reduction rules l : empty → l and empty : l → l where l ranges over list expressions. these reduction rules are applied exhaustively before any of the transformation rules. for example, x : empty : 1 : empty → x : 1 : empty → x : 1. we call this process normalization. in addition, the rules are applied to each instance of a transformation rule (that is, once the formal parameters have been replaced with actual parameters) before it is applied, and also after each transformation rule application. transformation rules. figure 5 shows the transformation rules, the essence of our approach, in an inference system style where each rule consists of a premise and a conclusion. remove: deletes trivial equations decomp1: syntactically equates a list variable with an atom expression or list variable decomp1’: syntactically equates an atom variable with an expression of lesser type decomp2/2’: assigns a list variable to start with another list variable decomp3: removes identical symbols from the head decomp4: solves an atom variable subst1: solves a variable subst2: assigns empty to a list variable subst3: assigns an atom prefix to a list variable orient1/2: moves variables to left-hand side orient3: moves variables of larger type to left-hand side orient4: moves a list variable to the left-hand side the rules induce a transformation relation ⇒ on unification problems. in order to apply any of the rules to a problem p, the problem part of its premise needs to be matched onto p. subsequently, the boolean condition of the premise is checked and the rule instance is normalized so that its premise is identical to p. for example, the rule orient3 can be matched to p = 〈a : 2 = m, σ〉 (where a and m are variables of type atom and list, respectively) by setting y 7→ a, x 7→ m, m 7→ 2, and l 7→ empty. the rule instance and its normal form are then 〈a : 2 = m : empty,σ〉 〈m : empty = a : 2,σ〉 and 〈a : 2 = m,σ〉 〈m = a : 2,σ〉 where the conclusion of the normal form is the result of applying orient3 to p. selected revised papers from gcm 2014 8 / 17 eceasst 〈l = l,σ〉 〈∅,σ〉 remove 〈x : l = s : m,σ〉 l 6= empty type(x) = list 〈l = m, σ ◦{x 7→ s}〉 decomp1 〈x : l = a : m,σ〉 l 6= empty type(a) ≤ type(x) ≤ atom 〈(l = m){x 7→ a}, σ ◦{x 7→ a}〉 decomp1′ 〈x : l = y : m,σ〉 l 6= empty type(x) = list type(y) = list x′ is a fresh list variable 〈x′ : l = m,σ ◦{x 7→ y : x′}〉 decomp2 〈x : l = y : m,σ〉 l 6= empty type(x) = list type(y) = list y′ is a fresh list variable 〈l = y′ : m,σ ◦{y 7→ x : y′}〉 decomp2′ 〈s : l = s : m,σ〉 〈l = m,σ〉 decomp3 〈x = a : y,σ〉 type(x) = atom type(y) = list 〈empty = y,σ ◦{x 7→ a}〉 decomp4 〈x = l,σ〉 x /∈ var(l) type(x) ≥ type(l) 〈∅,σ ◦{x 7→ l}〉 subst1 〈x : l = m,σ〉 l 6= empty type(x) = list 〈l = m,σ ◦{x 7→ empty}〉 subst2 〈x : l = a : m},σ〉 l 6= empty x′ is a fresh list variable type(x) = list 〈x′ : l = m,σ ◦{x 7→ a : x′}〉 subst3 〈a : m = x : l,σ〉 a is not a variable 〈x : l = a : m,σ〉 orient1 〈x : l = y,σ〉 l 6= empty type(x) = type(y) 〈y = x : l,σ〉 orient2 〈y : m = x : l,σ〉 type(y) < type(x) 〈x : l = y : m,σ〉 orient3 〈empty = x : l,σ〉 type(x) = list 〈x : l = empty,σ〉 orient4 figure 5: transformation rules 9 / 17 volume 71 (2015) a unification algorithm for gp 2 〈x = l,σ〉 x ∈ var(l) x 6= l type(x) = list fail occur 〈a : l = empty,σ〉 fail clash2 〈a : l = b : m,σ〉 a 6= b var(a) = /0 = var(b) fail clash1 〈empty = a : l,σ〉 fail clash3 〈x = l,σ〉 type(x)‖ type(l) fail clash4 figure 6: failure rules showing that a unification problem has no solution can be a lengthy affair because we need to compute all normal forms with respect to ⇒. instead, the rules occur and clash1 to clash4, shown in figure 6, introduce failure. failure cuts off parts of the search tree for a given problem p. this is because if p ⇒ fail, then p has no unifiers and it is not necessary to compute another normal form. effectively, the failure rules have precedence over the other rules. they are justified by the following lemmata. lemma 1 a normalised equation x = l with x 6= l has no solution if l is a simple expression, x ∈ var(l) and type(x) = list. proof. since x ∈ var(l) and x 6= l, l is of the form s1 : s2 : ... : sn with n ≥ 2 and x ∈ var(si) for some 1 ≤ i ≤ n. as l is normalised, none of the terms si contains the constant empty. also, since l is simple, it contains no list variables other than x and x is not repeated. it follows σ(x) 6=au σ(l) for every substitution σ . lemma 2 equations of the form a : l = empty or empty = a : l have no solution if a is an atom expression. lemma 3 an equation a : l = b : m with a 6= b has no solution if a and b are atom expressions without variables. the algorithm. the unification algorithm in figure 7 starts by normalizing the input equation, as explained above. it uses a queue of unification problems to search the derivation tree of p with respect to ⇒ in a breadth-first manner. the first step is to put the normalized problem p on the queue. the variable next holds the head of the queue. if next is in the form 〈∅,σ〉, then σ is a unifier of the original problem and is added to the set u of solutions. otherwise, the next step is to construct all problems p′ such that next ⇒ p′. if p′ is fail, then the derivation tree below next is ignored, otherwise p′ gets normalized and enqueued. selected revised papers from gcm 2014 10 / 17 eceasst unify(p) : u := /0 create empty queue q of unification problems normalize p q.enqueue(〈p,∅〉) while q is not empty next := q.dequeue() if next is in the form 〈∅,σ〉 u := u∪{σ} else if next ; fail foreach p′ such that next ⇒ p′ normalize p′ q.enqueue(p′) end foreach end if end if end while return u figure 7: unification algorithm an example tree traversed by the algorithm is shown in figure 8. nodes are labelled with unification problems and edges represent applications of transformation rules. the root of the tree is the problem 〈y : 2 = a : x〉 to which the rules decomp1, subst2 and subst3 can be applied. the three resulting problems form the second level of the search tree and are processed in turn. eventually, the unifiers σ1 = {x 7→ 2, y 7→ a} σ2 = {x 7→ y ′ : 2, y 7→ a : y′} σ3 = {a 7→ 2, x 7→ empty, y 7→ empty} are found, which represent a complete set of unifiers of the initial problem. note that the set is not minimal because σ1 is an instance of σ2. the algorithm is similar to the a-unification (word unification) algorithm presented in [sch92] which looks at the head of the problem equation. that algorithm terminates for the special case that the input problem has no repeated variables, and is sound and complete. our approach can be seen as an extension from a-unification to au-unification, to handle the unit equations, and presented in the rule-based style of [bs01]. in addition, our algorithm deals with gp’s subtype system. 3.3 termination and soundness we show that the unification algorithm terminates if the input problem contains no repeated list variables, where termination of the algorithm follows from termination of the relation ⇒. 11 / 17 volume 71 (2015) a unification algorithm for gp 2 { y : 2 = a : x ∅ } { 2 = x y 7→ a } { x = 2 y 7→ a }    ∅ y 7→ a x 7→ 2    solved subst1 orient1 decomp1 { 2 = a : x y 7→ empty } { a : x = 2 y 7→ empty }    x = empty y 7→ empty a 7→ 2           ∅ y 7→ empty a 7→ 2 x 7→ empty        solved subst1 decomp1′ orient1 subst2 { y′ : 2 = x y 7→ a : y′ } { x = y′ : 2 y 7→ a : y′ }    ∅ y 7→ a : y′ x 7→ y′ : 2    solved subst1 orient2 { y′′ : 2 = empty y 7→ a : x : y′′ } { 2 = empty y 7→ a : x } fail clash2 subst2 decomp2    2 = x′ y 7→ a : y′ x 7→ y′ : x′       x′ = 2 y 7→ a : y′ x 7→ y′ : x′       ∅ y 7→ a : y′ x 7→ y′ : 2    solved subst1 orient1 decomp2′ subst3 figure 8: unification example selected revised papers from gcm 2014 12 / 17 eceasst theorem 1 (termination) if p is a unification problem without repeated list variables, then there is no infinite sequence p ⇒ p1 ⇒ p2 ⇒ ... proof. define the size |l| of an expression l by • 0 if l = empty, • 1 if l is an expression of category atom (see figure 4) or a list variable, • |m|+ |n|+ 1 if l = m : n. we define a lexicographic termination order by assigning to a unification problem p = 〈l = m,σ〉 the tuple (n1,n2,n3,n4), where • n1 is the size of p, that is, n1 = |l|+ |m|; • n2 = { 0 if l starts with a variable 1 otherwise • n3 = { 1 if type(x) > type(y) 0 otherwise where x and y are the starting symbols of l and m • n4 = |l| the table in figure 9 shows that for each transformation step p ⇒ p′, the tuple associated with p′ is strictly smaller than the tuple associated with p in the lexicographic order induced by the components n1 to n4. n1 n2 n3 n4 subst1−3 > decomp1−4 > remove > orient1 = > orient4 = > orient3 = = > orient2 = = = > figure 9: lexicographic termination order for most rules, the table entries are easy to check. all the rules except for orient decrease the size of the input equation s =? t. the orient rules keep the size equal, but move variables and expressions of a bigger type to the left-hand side. 13 / 17 volume 71 (2015) a unification algorithm for gp 2 lemma 4 if p ⇒ p′, then u (p) ⊇ u (p′) . proof. we show that for each transformation rule, a unifier θ of the conclusion unifies the premise. note that for remove, decomp3 and orient1-4, we have that σp′ = σp . • remove θ ∈ u (〈∅,σp′〉) ⇐⇒ θ ∈ u (〈∅,σp〉) ⇐⇒ θ ∈ u (〈∅,σp〉)∧ lθ = lθ ⇐⇒ θ ∈ u (〈l = l,σp〉) • decomp3 θ ∈ u (〈l = m,σp′〉) ⇐⇒ θ ∈ u (〈l = m,σp〉) ⇐⇒ θ ∈ u (〈l = m,σp〉)∧sθ = sθ ⇐⇒ θ ∈ u (〈s : l = s : m,σp〉) • decomp1 we have xθ = sθ and lθ = mθ . then (x : l)θ = (s : l)θ = (s : m)θ as required. • decomp1’ we have xθ = aθ and lθ = mθ . then (x : l)θ = (a : l)θ = (a : m)θ as required. • decomp2 we have xθ = (y : x′)θ and (x′ : l)θ = mθ . then (x : l)θ = (y : x′ : l)θ = (y : m)θ as required. • decomp2’ we have yθ = (x : y′)θ and lθ = (y′ : m)θ . then (y : m)θ = (x : y′ : m)θ = (x : l)θ as required. • decomp4 we have xθ = aθ and yθ = (empty)θ = empty. then (a : y)θ = (x : y)θ = (x : empty)θ = xθ as required. • subst1 we have xθ = lθ θ ∈ u (〈∅,σs′〉) ⇐⇒ θ ∈ u (〈∅,σs ◦(x 7→ l)〉) ⇐⇒ θ ∈ u (〈∅,σs ◦(x 7→ l)〉)∧xθ = lθ ⇐⇒ θ ∈ u (〈x = l,σs〉) • subst2 we have xθ = (empty)θ and lθ = mθ . then (x : l)θ = (empty : l)θ = lθ = mθ as required. • subst3 we have xθ = (a : x′)θ and (x′ : l)θ = mθ . then (x : l)θ = (a : x′ : l)θ = (a : m)θ as required. • orient1-4 since =au is an equivalence relation and hence symmetric, a unifier of the conclusion is also a unifier of the premise. selected revised papers from gcm 2014 14 / 17 eceasst theorem 2 (soundness) if p ⇒+ p′ with p′ = 〈∅,σp′〉 in solved form, then σp′ is a unifier of p. proof. we have that σp′ is a unifier of p ′ by definition. a simple induction with lemma 4 shows that σp′ must be a unifier of p. 3.4 completeness in order to prove that our algorithm is complete, by definition 5 we have to show that for any unifier δ , there is a unifier in our solution set that is more general. our proof involves using a selector algorithm that takes a unification problem 〈s =? t〉 together with an arbitrary unifier δ , and outputs a path of the unification tree associated with a more general unifier than δ . this is very similar to [sie78] where completeness of a a-unification algorithm is shown via such selector. due to space restrictions the following lemma is given without proof. for the selector algorithm and proof (comprising of an extra 9 pages) see the long version of this paper [hp14]. lemma 5 (selector lemma) there exists an algorithm select(δ ,s =? t) that takes an equation s =? t and a unifier δ as input and produces a sequence of selections b = (b1,...,bk) such that: • unify(s =? t) has a path specified by b . • for all selections b ∈ b: if σ is the substitution corresponding to b, then there exists an instantiation λ such that σ ◦ λ ≤ δ . for example, consider the unification problem 〈y : 2 = a : x〉 and δ = (x 7→ 1 : 2,y 7→ a : 1) as a unifier. the unification tree was shown in figure 8. select(δ ,y : 2 = a : x) would produce selections (subst3, decomp2’, orient1, subst1), which corresponds to the right-most path in the tree. the unifier at the end of this path is σ = (x 7→ y′ : 2,y 7→ a : y′) which is more general than δ by instantiation λ = (y′ 7→ 1). now we are able to state our completeness result, which follows directly from lemma 5. theorem 3 (completeness) for every unifier δ of a unification problem 〈s =? t〉, there exist a unifier σ generated by unify such that σ ≤ δ . 4 conclusion this paper presents groundwork for a static confluence analysis of gp programs. we have constructed a rule-based unification algorithm for systems of equations with left-hand expressions of rule schemata, and have shown that the algorithm always terminates and is sound. moreover, we have proved completeness in that every unifier of the input problem is an instance of some unifier in the computed set of solutions. 15 / 17 volume 71 (2015) a unification algorithm for gp 2 future work includes establishing a critical pair lemma in the sense of [plu05]; this entails developing a notion of independent rule schema applications, as well as restriction and embedding theorems for derivations with rule schemata. another topic is to consider critical pairs of conditional rule schemata (see [egh+12]). in addition, since critical pairs contain graphs labelled with expressions, checking joinability of critical pairs will require sufficient conditions under which equivalence of expressions can be decided. this is because the theory of gp’s label algebra includes the undecidable theory of peano arithmetic. acknowledgements: we thank the anonymous referees of gcm 2014 for their comments on previous versions of this paper. bibliography [bfpr15] c. bak, g. faulkner, d. plump, c. runciman. a reference interpreter for the graph programming language gp 2. in proc. graphs as models (gam 2015). electronic proceedings in theoretical computer science 181, pp. 48–64. 2015. [bs01] f. baader, w. snyder. unification theory. in robinson and voronkov (eds.), handbook of automated reasoning. pp. 445–532. elsevier and mit press, 2001. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. monographs in theoretical computer science. springer-verlag, 2006. [egh+12] h. ehrig, u. golas, a. habel, l. lambers, f. orejas. m-adhesive transformation systems with nested application conditions. part 2: embedding, critical pairs and local confluence. fundamenta informaticae 118(1):35–63, 2012. [gleo12] u. golas, l. lambers, h. ehrig, f. orejas. attributed graph transformation with inheritance: efficient conflict detection and local confluence analysis using abstract critical pairs. theoretical computer science 424:46–68, 2012. [hkt02] r. heckel, j. m. küster, g. taentzer. confluence of typed attributed graph transformation systems. in proc. international conference on graph transformation (icgt 2002). lecture notes in computer science 2505, pp. 161–176. springerverlag, 2002. [hp14] i. hristakiev, d. plump. a unification algorithm for gp (long version). http://www.cs.york.ac.uk/plasma/publications/pdf/hristakievplump.full.gcm14.pdf, 2014. [jaf90] j. jaffar. minimal and complete word unification. journal of the acm 37(1):47–85, 1990. selected revised papers from gcm 2014 16 / 17 http://www.cs.york.ac.uk/plasma/publications/pdf/hristakievplump.full.gcm14.pdf eceasst [pla99] w. plandowski. satisfiability of word equations with constants is in pspace. in symposium on foundations of computer science (focs 1999). pp. 495–500. ieee computer society, 1999. [plo72] g. plotkin. building-in equational theories. machine intelligence 7(4):73–90, 1972. [plu05] d. plump. confluence of graph transformation revisited. in middeldorp et al. (eds.), processes, terms and cycles: steps on the road to infinity: essays dedicated to jan willem klop on the occasion of his 60th birthday. lecture notes in computer science 3838, pp. 280–308. springer-verlag, 2005. [plu12] d. plump. the design of gp 2. in proc. international workshop on reduction strategies in rewriting and programming (wrs 2011). electronic proceedings in theoretical computer science 82, pp. 1–16. 2012. [sch92] k. u. schulz. makanin’s algorithm for word equations: two improvements and a generalization. in proc. word equations and related topics (iwwert ’90). lecture notes in computer science 572, pp. 85–150. springer-verlag, 1992. [sie78] j. siekmann. unification and matching problems. phd thesis, university of essex, 1978. 17 / 17 volume 71 (2015) introduction gp rule schemata unification preliminaries unification algorithm termination and soundness completeness conclusion towards an analysis of who creates clone and who reuses it electronic communications of the easst volume 63 (2014) proceedings of the eighth international workshop on software clones (iwsc 2014) towards an analysis of who creates clone and who reuses it — position paper — takuya moriwaki, yuki yamanaka, hiroshi igaki, norihiro yoshida, shinji kusumoto and katsuro inoue 5 pages guest editors: nils göde, yoshiki higo, rainer koschke managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards an analysis of who creates clone and who reuses it takuya moriwaki1, yuki yamanaka1, hiroshi igaki1, norihiro yoshida2, shinji kusumoto1 and katsuro inoue1 1 m-takuya@ist.osaka-u.ac.jp 2 y-yuuki@ist.osaka-u.ac.jp 3 igaki@ist.osaka-u.ac.jp 5 kusumoto@ist.osaka-u.ac.jp 6 inoue@ist.osaka-u.ac.jp graduate school of information science and technology osaka university, japan 4 yoshida@is.naist.jp graduate school of information science nara institute of science and technology, japan abstract: code clone analysis is valuable because it can reveal reuse behaviours efficiently from software repositories. recently, some code reuse analyses using clone genealogies and code clones over multiple projects were conducted. however, most of the conventional analyses do not consider the developers’ individual difference to reuse behaviors. in this paper, we propose a method for code reuse analysis which takes particular note of the differences among individuals. our analysis method clarifies who reused whose source code across multiple repositories. we believe the result might provide us with constructive perceptions such as characteristics of reused code itself by multiple developers, and developers who implement reusable code. keywords: source code reuse, code clone, clone evolution, code reuse analysis 1 introduction in the software industry and oss(open source software) projects, it is said that adequate code reuse could improve productivity and reliability of software development, and reduce development time[lim94]. though adhoc source code reuse might cause deterioration of software quality, in some cases, source code reuse seems to be a reasonable decision[kg08]. in order to encourage such source code reuse, it is meaningful to analyze developers’ reuse behaviors in existing projects. code clone detection is widely regarded as the promising approach to identify source code reuse[hdg+11]. meanwhile, there exist few analyses in consideration of the developers’ individual differences to reuse behaviors. sojer et al.[sh10] indicated the importance of code reuse, and heterogeneity in developers’ reuse behavior through a survey in oss projects. balint et al.[bgm06]and harder[har13] analyzed the authorship of the code clones to extract code reuse behaviors of each developer within a project. especially, harder[har13] reports 1 / 5 volume 63 (2014) mailto:m-takuya@ist.osaka-u.ac.jp mailto:y-yuuki@ist.osaka-u.ac.jp mailto:igaki@ist.osaka-u.ac.jp mailto:kusumoto@ist.osaka-u.ac.jp mailto:inoue@ist.osaka-u.ac.jp mailto:yoshida@is.naist.jp who creates clone and who reuses it differences between single-author and multi-author clones. conventional research implies there might exist differences between developers in the reuse behaviors. therefore, in this paper, we propose a source code reuse analysis for each developer over two or more projects in the viewpoint of specifying individual differences in ways of reusing source code. our analysis method might promote interaction between developers over reused code, and the result enables us to recommend reusable code using source code reuse behaviors. furthermore, we hope our research motivates the code clone community to think twice about an individual developer. 2 source code reuse behaviors 2.1 definition we define the source code reuse behaviors utilizing the authorship of the clone set. we call one of the code fragments which is implemented first in a clone set “original code” of the clone set, and call the developer of the original code “clone set authorship”. furthermore, we call developers who implemented the code fragments other than the original code in the clone set as “clone set users”. generally, the authorship of source code fragments can be identified using the blame command in vcs(version control system). the source code reuse behavior is defined as the relation among the authorship and the users of each clone set. in our definition, we regard authorship-user relationships in clone sets as create-reuse relationships in the source code reuse behaviors. 2.2 individual differences we conducted a miniature case study about reuse behaviors in a part of an oss java project (eclipse.platform.text). we generated a set of change evolutionary history (clone genealogy) from a part of the project repository based on the model of genealogy of code clones[ksnm05]. the repository contains 826 rev. and 16 developers. we adopted ccfinder[kki02] to generate the clone genealogy of the repository. in this case study, we detected 443 clone sets. out of them, we analyzed the authorships of 34 clone sets which are classified into the evolutionary pattern ”add” (i.e., the clone sets include code clones which are reused in different revision after creation). detail steps for identifying the authorship of the clone sets are described in the section 3. figure 1 indicates the number of times which developer a∼f committed, created, and reused in the project. developers who committed below 10 times are omitted. there is little relationships among #commit, #creation, and #reuse as evidenced by the figure. one developer reuses actively and is reused frequently, and another never reuses the code. in this figure, though #commits by developer a is more than twice than b, #create and #reuse by a are fewer than half the number of them by b. the result shows that there might exist individual differences in reuse behaviors among developers. adhoc reuse of source code is usually described to cause quality reduction of software. on the other hand, in some situations, code duplication seems to be a reasonable design option [kg08]. proc. iwsc 2014 2 / 5 eceasst 10 12 30 66 196 469 0 0 0 4 20 7 0 2 0 6 75 16 0 20 40 60 80 100 0100200300400500 f e d c b a # commit # create # reuse figure 1: individual differences in source code reuse behavior for example, developers reuse more existing code the less mature their projects [sh10]. in the survey by sojer et al.[sh10], the perception of each developer to reuse behavior seems to affect his/her actual reuse. we propose an analysis method for identifying reuse behaviors by each developer over multiple repositories. feedback of the analysis results might motivate each developer to decrease harmful reuse and increase beneficial reuse. 3 source code reuse analysis over multiple repositories our analysis method takes repositories of multiple projects as an input and provides source code reuse behaviors for each clone set as an output. detailed analysis steps are as follows. step1: merges commit logs of multiple repositories in vcs, each repository has a set of commits which indicates activities in configuration management by developers. in this step, commit logs collected from multiple repositories are concatenated into one commit log, and the commits in the concatenated log are sorted by date committed. the concatenated commit log represents development histories of the composite repository containing multiple repositories virtually. step2: classifies clone sets in this step, the clone genealogy of the composite repository is generated based on the model by kim et al.[ksnm05]. concretely, every revision of the composite repository is checked out based on the concatenated commit log first. next, we adopted the clone notifier[ycy+13] to generate the clone genealogy. the generated clone genealogy of the composite repository classifies evolution patterns of all clone sets in each revision according to the model of the genealogy 3 / 5 volume 63 (2014) who creates clone and who reuses it such as “same” and “add”. here, “same” means all code snippets in a clone set did not change between adjacent revisions, and “add” means at least one code snippet was newly added to the clone set in the latter revision[ksnm05]. step3: identifies authorship and users of clone sets first, code authorship of every code snippet in the classified clone sets is identified by using the blame command in vcs. here, the code authorship means who created the code snippet. next, for each clone set, our analysis method specifies the first code snippet which was implemented. in our definition, the first code snippet is the original code of the clone set. we regard the code authorship of the first snippet as the clone set authorship. the code authorship of the snippets other than first one indicates the clone set users. the above mentioned steps clarify the authorship and users for each clone set. 4 discussion and conclusion we have proposed source code reuse analysis over multiple projects taking into consideration difference among developers. in our assumption, our analysis method promotes inter-developer relationships, in the viewpoint of the source code reuse. for example, developers within a team using our analysis know who reused whose code snippets mutually. such mutual understanding about reuse behaviors might motivate developers to look back on their source code reuse. on the other hand, our method contains the following limitations on threats to validity. multiple account names are used by the same developer developer might use different account names for different projects. blame command in vcs adopts account names to identify code authorship. if a developer uses multiple account names, create-reuse relationships are identified incorrectly. however, we assume our analysis is used for projects within the specific community whose members know their account names each other. as a consequence, multiple account names by one developer might not cause severe problems. multiple developers implement one original code blame command represents code authorship for each line. if there exist code snippets as the original code which were implemented by multiple developers, our analysis method provides multiple developers as the clone set authorship. currently, we admit only one developer as the clone set authorship who developed most sloc(source lines of code) in the original code. developers reuse code fragment from some code base that is not part of the analysis developers might reuse code fragment from some code base which does not belong to their projects. in such a case, our analysis method cannot identify the original code fragment. however, if the code fragment has value to multiple developers, we expect the fragment to be reused by developer two or more times in the project. proc. iwsc 2014 4 / 5 eceasst for future research, we are planning to evaluate the validity of our analysis method based on some large-scale experiments. moreover, by using the result of our analysis, we try to develop a source code reuse promoting system which motivates interaction between a creator and a user of each clone set. acknowledgment this work was supported by mext/jsps kakenhi 24700030, 25220003. bibliography [bgm06] m. balint, t. girba, r. marinescu. how developers copy. in proc. of 14th ieee international conference on program comprehension(icpc) 2006. pp. 56–68. 2006. [har13] j. harder. how multiple developers affect the evolution of code clones. in 29th international conference on software maintenance. 2013. [hdg+11] l. heinemann, f. deissenboeck, m. gleirscher, b. hummel, m. irlbeck. on the extent and nature of software reuse in open source java projects. top productivity through software reuse, pp. 207–222, 2011. [kg08] c. kapser, m. w. godfrey. “cloning considered harmful” considered harmful: patterns of cloning in software. empirical software engineering 13(6):645–692, december 2008. [kki02] t. kamiya, s. kusumoto, k. inoue. ccfinder: a multi-linguistic token-based code clone detection system for large scale source code. ieee transactions on software engineering 28(7):654–670, 2002. [ksnm05] m. kim, v. sazawal, d. notkin, g. murphy. an empirical study of code clone genealogies. in proceedings of the 10th european software engineering conference held jointly with 13th acm sigsoft international symposium on foundations of software engineering. esec/fse-13, pp. 187–196. 2005. [lim94] w. lim. effects of reuse on quality, productivity, and economics. ieee software 11(5):23–30, 1994. [sh10] m. sojer, j. henkel. code reuse in open source software development: quantitative evidence, drivers, and impediments. journal of the association for information systems 11(12):868–901, 2010. [ycy+13] y. yamanaka, e. choi, n. yoshida, k. inoue, t. sano. applying clone change notification system into an industrial development process. in proc. of 2013 ieee 21st international conference on program comprehension (icpc). pp. 199–206. may 2013. 5 / 5 volume 63 (2014) introduction source code reuse behaviors definition individual differences source code reuse analysis over multiple repositories discussion and conclusion demo: simulation-as-a-service to benchmark opportunistic networks electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) demo: simulation-as-a-service to benchmark opportunistic networks jens dede, asanga udugama and anna förster 4 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst demo: simulation-as-a-service to benchmark opportunistic networks jens dede1, asanga udugama2 and anna förster3 jd@comnets.uni-bremen.de adu@comnets.uni-bremen.de anna.foerster@uni-bremen.de sustainable communication networks university of bremen, germany abstract: repeatability, reproducibility, and replicability are essential aspects of experimental and simulation-driven research. use of benchmarks in such evaluations further assists corroborative performance evaluations. in this work, we present a demonstrator of a simulation service, called ”ops on the bench” which tackles these challenges in performance evaluations of opportunistic networks. keywords: network simulation, opportunistic networks, benchmarks, omnet++ 1 introduction the confidence in performance evaluations are increased significantly when the underlying simulations are repeatable, reproducible, and replicable, and produce corrobarative findings [fei15]. depending on the complexity of the simulation setup, availability of a comparable baseline and the required computing resources, this is a challenging task. to address these challenges in evaluations of opportunistic networks (oppnets), we have developed a simulation-as-a-service platform called ops on the bench (ootb) [fkdu21]. it consist of the oppnets model framework [ufdk19] for omnet++ combined with a collection of real-world oppnets benchmarks. in this work, we demonstrate the operation of the ootb platform, simulating oppnets using benchmarks with a variety of data dissemination protocols. 2 architecture the work in [ktuf19] shows the variety of evaluations of oppnets. authors of [kcc05] and [cp16] highlight the problems of such evaluations. therefore, the ootb platform, described in this section, is designed to perform repeatable, reproducible, and replicable research to overcome the problems raised in those works. the ootb platform uses the opportunistic protocol simulator (ops)1. ops [ufdk19] is an omnet++2 based model framework used to simulate oppnets together with the inet3 1 https://github.com/comnets-bremen/ops 2 https://omnetpp.org 3 https://inet.omnetpp.org 1 / 4 volume 080 (2021) mailto:jd@comnets.uni-bremen.de mailto:adu@comnets.uni-bremen.de mailto:anna.foerster@uni-bremen.de https://github.com/comnets-bremen/ops https://omnetpp.org https://inet.omnetpp.org ootb web interface benchmarks parameters selection of repository upload of omnetpp.ini precision of final data (.sca, .vec) mail address, personal data, privacy consent admin features simulation manager simulation status simulation queue enqueue simulations simulation status send notifications to user simulation server worker run simulation create graphs (pdf) scale down and convert results worker run simulation create graphs (pdf) scale down and convert results worker run simulation create graphs (pdf) scale down and convert results file & result storage store .sca files for x days store .csv files for y days store .pdf files for z days figure 1: the architectural overview of ootb model framework. the models in ops allow the users to configure oppnet nodes and networks to simulate different scenarios. each simulation requires a configuration file consisting of the parameter values to run the simulation. the complete ootb platform is managed using a django framework4 based application, which offers a user interface, accepts user requests and channels them to backend workers. these workers are implemented using docker5 containers and run the simulation itself. the containers are deployed with all required components including the ops models to run simulations. once the simulations are completed, a cloud storage service (such as dropbox) is used to store the results. at the end, the users are informed of the simulation status and the download location of the results. figure 1 shows the architecture of ootb. it consists of five main parts interacting to perform the tasks of accepting simulation requests of users, performing simulations and processing and presenting the results. these parts are described below. a detailed description of the ootb platform is presented in [fkdu21]. • web interface: the web interface allow users of ootb to create and manage simulations. due to it being browser-based, it is operating system-independent. access permissions decide the capabilities offered to users, but in general, ootb offers three possibilities of initiating simulations. initiating a simulation by (a) invoking a benchmark [fkdu21], (b) using a wizard, or (c) by supplying an ops / omnet++ configuration file. • simulation manager: the simulation manager is the central component in ootb, designed to be the single point of truth for all the activities of ootb. the main tasks are interfacing with the web interface to obtain user requests, enqueuing simulations for the workers in the backend to pick up and simulate and to manage results of simulations. • simulation queue: the simulation queue connects the manager and simulation server controlling the multiple workers in the backend. 4 https://www.djangoproject.com 5 https://www.docker.com netsys 2021 2 / 4 https://www.djangoproject.com https://www.docker.com eceasst • simulation server and workers: the simulation server runs at least one docker container – called worker – deployed with the ops models to simulate oppnets. the worker performs tasks such as monitoring the simulation queue for new jobs, starting new simulations, monitoring active simulations to report status to the manager and to generate summaries of results once the simulation job is complete. • storage (results & reports): the results generated by the server, in the form of scalar results (original omnet++ results), summarized results (as csv files) and plotted results (as .pdf files) are stored in a cloud service for a limited duration for the user to retrieve. general simulation information required to rerun the simulation are stored without a time restriction for later comparison. 3 running a simulation this architecture offers several advantages for users simulating oppnets. the main point is the significantly reduced complexity of running a simulation. only three steps are important for the user: first step) starting a new simulation either by uploading a complete simulation configuration file, setting up the simulation using a wizard (c.f. figure 2) or changing parameters in a preconfigured benchmark simulation, second step) the simulation itself is run automatically on one of the servers without user interaction, last step) the user is informed after the simulation has finished. the results including a graphical representation are offered as a download. the advantages for the user are manifold. firstly, the setup of the complete simulation environment, including the server, is done by us. especially for newcomers in this area, this can be a time-consuming task. secondly, we aim for a standardized representation of the results. this makes the performance of different protocols comparable. it also fosters the reproducibility and comparability in the area of network simulation mentioned at the beginning of this work. thirdly, with the option of reconfiguring existing benchmark configurations, the impact of the different parameters to a simulation becomes clearer increasing the overall understanding of performance. 4 demonstration figure 2: the second step of the simulation setup: configure the nodes 3 / 4 volume 080 (2021) ootb we show the main functionality of ootb in this demontration: 1) invocation of the platform, 2) setting up simulation parameters and commencing simulations, 3) operations performed in the background by ootb, 4) accessing results and comparing with other simulation campaigns. figure 2 shows a screenshot of the ootb user interface where the nodes are set up and the corresponding models are selected. 5 summary and future work ootb [fkdu21] is a platform to overcome performance evaluation issues in simulations. it is currently available as a preview version6 to interested users. currently, the system is being extended in multiple directions. optimizing the simulation parsing, better comparison of the results and more flexibility and setup options are some of current work items. bibliography [cp16] c. collberg, t. a. proebsting. repeatability in computer systems research. commun. acm 59(3), feb. 2016. doi:10.1145/2812803 [fei15] d. g. feitelson. from repeatability to reproducibility and corroboration. sigops oper. syst. rev. 49(1):3–11, jan. 2015. doi:10.1145/2723872.2723875 [fkdu21] a. förster, t. karunathilake, j. dede, a. udugama. benchmarking data dissemination protocols for opportunistic networks. p. 12–19. association for computing machinery, new york, ny, usa, 2021. doi:10.1145/3458473.3458819 [kcc05] s. kurkowski, t. camp, m. colagrosso. manet simulation studies: the incredibles. sigmobile mob. comput. commun. rev. 9(4), oct. 2005. doi:10.1145/1096166.1096174 [ktuf19] v. kuppusamy, u. m. thanthrige, a. udugama, a. förster. evaluating forwarding protocols in opportunistic networks: trends, advances, challenges and best practices. future internet 11(5), 2019. doi:10.3390/fi11050113 [ufdk19] a. udugama, a. förster, j. dede, v. kuppusamy. simulating opportunistic networks with omnet++. in virdis and kirsche (eds.), recent advances in network simulation: the omnet++ environment and its ecosystem. pp. 425–449. 2019. doi:10.1007/978-3-030-12842-5 6 https://ootb.comnets.uni-bremen.de netsys 2021 4 / 4 http://dx.doi.org/10.1145/2812803 http://dx.doi.org/10.1145/2723872.2723875 http://dx.doi.org/10.1145/3458473.3458819 http://dx.doi.org/10.1145/1096166.1096174 http://dx.doi.org/10.3390/fi11050113 http://dx.doi.org/10.1007/978-3-030-12842-5 https://ootb.comnets.uni-bremen.de introduction architecture running a simulation demonstration summary and future work divide and conquer -organizing component-based adaptation in distributed environments electronic communications of the easst volume 11 (2008) proceedings of the first international discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus 2008) divide and conquer – organizing component-based adaptation in distributed environments ulrich scholz and romain rouvoy 12 pages guest editors: romain rouvoy, mauro caporuscio, michael wagner managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst divide and conquer – organizing component-based adaptation in distributed environments ulrich scholz1 and romain rouvoy2 1 european media laboratory gmbh schloß-wolfsbrunnenweg 33 69118 heidelberg, germany ulrich.scholz@eml-d.villa-bosch.de 2 university of oslo, dept. of informatics p.o.box 1080 blindern 0316 oslo, norway rouvoy@ifi.uio.no abstract: this paper introduces a divide and conquer approach for organizing the adaptation of distributed applications in a potentially large number of interacting middleware instances. in such an environment, a centralistic and static adaptation reasoning i) is inadequate and ii) gives the same priority to all applications. the divide and conquer method aims at minimizing the interference between running applications, allowing users to weight the priority of applications, and organizing the adaptation and the reasoning about the adaptation in a decentralized and flexible way. keywords: adaptive middleware, distributed adaptation reasoning 1 introduction this work is concerned with the task of adapting a number of large, distributed applications in mobile environments subject to frequent context changes. we consider this problem within music [mus], an initiative to develop a comprehensive open-source platform that facilitates the development of self-adaptive software in ubiquitous environments. one aim of music is a large-scale deployment of multiple middleware instances. some of these instances host two or more applications, some applications are distributed on two or more instances. furthermore, the topology of middleware instances and applications is transient—i.e., they can appear and disappear at any time. for such a collection of middleware instances, users, applications, devices, connections, and other artefacts related to adaptation, we assign the term theatre. current solutions to the adaptation problem use a centralized and coarse-grained approach, which is not suited for large theatres: if one part of an application needs adaptation, the whole application—or even a set of applications—is adapted in combination by a dedicated solver. the solver considers all alternative configurations of all these applications at once and chooses the configuration that yields the best utility. this approach is not feasible for large theatres due to the combinatorial explosion of alternative configurations and because it interferes with parts of the theatre even if such interference is not required. as a solution, we propose the divide and conquer (d&c) approach to organize the adaptation tasks of a theatre in a decentralized and distributed way. d&c considers units that are smaller than single applications and provides techniques that allow the adaptation of partial applications. 1 / 12 volume 11 (2008) ulrich.scholz@eml-d.villa-bosch.de rouvoy@ifi.uio.no divide and conquer – organizing component-based adaptation in the following, we describe the adaptation problem and introduce the basic d&c ideas (cf. section 2). then we detail these ideas, namely the application packs (cf. section 3), resource distribution (cf. section 4), the decomposition tree (cf. section 5), and the strategies (cf. section 6). before listing related work (cf. section 8) and giving concluding remarks (cf. section 9), we explain d&c with an example scenario (cf. section 7). 2 the adaptation problem and the d&c approach the music project’s focus is the adaptation of component-based applications. applications are assembled of components—i.e., pieces of code—and several different collections of components, each called a variant, can realize the same application. many variants provide the same function to the user (e.g., participation in a picture sharing community), but often with different nonfunctional properties (e.g., quality of service and cpu usage). the degree to which the nonfunctional properties of a variant satisfy the user is called the utility of that variant [fhs+06]. adapting an application means choosing and commissioning one of its variants, while the adaptation problem means adapting an application such that it has the highest—or a sufficiently high—utility in a given situation. an adaptation middleware, such as music, aims at a solution to the adaptation problem such that every application maintains its functionality and a high utility despite of changes in the theatre. not all variants of an application are valid: they have to satisfy architectural constraints [krg07]. two examples for such constraints are the existential dependency between two components that holds if choosing one only makes sense if the other is chosen too, and a dependency where two components are mutually exclusive or require each other. adaptations can introduce new dependencies to an application and remove existing ones. existing adaptive systems usually consider entire applications: if some part of an application requires an adaptation then the whole application has to be adapted. in madam [mad06] the unit of adaptation is even wider, as it comprises all applications on a local device and all parts of these application deployed on other devices. adapting large units guarantees an optimal utility but has several drawbacks. one of them is the combinatorial explosion in the number of variants that have to be considered. if an application always consists of 5 components and there are 5 variants for each then the application has 55 = 3125 variants. for an application comprising 10 components, or for the combination of 2 applications with 5 components each, there are already about 10 million of them. although increasing processing power, restrictions on valid choices of variants, and heuristics allow solving large adaptation problems, even medium sized collections of applications are often infeasible for a global method. another reason for the inadequateness of current approaches is that they affect parts of the theatre that are better left untouched. adapting an application involves stopping it and re-starting it after some time. nevertheless, some application parts, such as video stream receivers, may not support to be suspended and resumed dynamically. in addition, users are willing to accept such interruption of service only if the disruption is very short or they observe a clear advantage. as the adaptation time is often pronounced, adapting large parts of theatres can lead to many such undesired outages for a user. in contrast, d&c forgoes globally optimal solutions by adopting a more fine-grained approach proc. campus 2008 2 / 12 eceasst towards adaptation. applications are divided into smaller units, called application parts, and d&c organizes the adaptation and distribution of collections of such parts, called packs, in a decentralized and flexible manner. then, the adaptation of each part is treated independently as black box by d&c. furthermore, current approaches do not distinguish between the application adaptation and its organization. as a result, the realization of adaptation control requires in-depth knowledge about the logic of its application and the environment to foresee possible adaptation situations. d&c provides a clear separation between both aspects of adaptation reasoning. in detail, d&c comprises five concepts to adaptation organization: (1) the concept of application parts and packs, (2) the splitting and merging of packs, (3) the reasoning about pack layout, (4) the resource negotiation between packs, and (5) the decentralized, flexible coordination of the adaptation. the first two points are covered by the following section, resource negotiation by section 4, and the decomposition tree by section 5. reasoning about pack layout is not an essential part of d&c and we omit it here for space reasons. 3 packs – adapting collections of application parts the d&c units of adaptation are parts and packs. applications are divided into parts that can be adapted independently or in combination; a pack is a collections of such parts. the handling of packs—i.e., their adaptation, division, aggregation, and relocation, as well as the organization of these operations—forms the essence of the d&c approach. with respect to complexity and autonomy, application parts are positioned between components and full applications. like applications, they are built of components and have their own utility function. their overall utility is the product of the ones of their parts. as for components, architectural constraints between parts can restrict their variant space at a certain time. note that the division of an application into parts and packs does not increase its adaptation complexity compared to the same application built of components: adapting all parts in combination takes the same time as adapting all components in combination and choosing to not adapt some parts can only reduce the required effort. packs are a purely logical assembly of application parts. parts in a pack are usually handled as a whole. in particular, all parts of the same application that are in one pack are always adapted in combination, eliminating the need for d&c to handle the architectural constraints between these parts explicitly. each pack can be adapted independently of other packs and only the applications of the part in a pack have to be stopped during its adaptation. the division into packs reflects the results of d&c’s reasoning about which application parts are likely to be adapted together and which independently. if two application parts a and b of different applications in the same pack adapt in combination then the adaptation mechanism considers each element of the cross product pa × pb. the time to adapt them is ta · tb, where pa and pb are the sets of variants of a and b, respectively, and the time to establish these sets is ta and tb. in case a and b are in different packs, the elements of pa and pb are considered independently and the adaptation time is ta + tb in the worst case. in other words, by placing a and b in different packs, we go from an exponential alternative space to a linear one. the aggregation of application parts to packs allows to organize the adaptation and to adjust 3 / 12 volume 11 (2008) divide and conquer – organizing component-based adaptation the reasoning effort against the quality of adaptation. on the one hand, the larger the packs on a machine are, i) the higher the expected utility after their individual adaptation and ii) the easier to find a good resource distribution among them (cf. section 4). on the other hand, the smaller the packs—-i.e., the higher the number of packs on the machine—the faster the adaptation of individual packs. thus, changing the composition of packs allows the middleware to balance reasoning time and adaptation quality. in more details, the motivations for merging two packs are as follows. (1) optimization of utility: in case an application was distributed over two or more of the initial packs, the merged pack might offer a better utility function for this application. (2) lower resource usage: the improved utility function can lead to an adaptation that uses less resources, but does not decrease utility. (3) decrease the need for and increase the quality of resource negotiation: the fewer packs there are, the easier it is to distribute resources between them. packs are split for two reasons. (1) to minimize adaptation time: smaller packs have a potential smaller adaptation time. prerequisites are that resources are sufficient and the new packs have few architectural dependencies. (2) to change the layout of packs: in a d&c setting, packs are the unit of relocation. we assume that the realization of splitting and merging of packs is transparent with respect to time and memory. in particular, they do not change the resource consumption of the involved packs and packs resulting from a split have the same combined resource usage like the initial pack. although splitting and merging packs takes time, we assume that this time is negligible such that packs can be split and merged without interfering with the applications. the question of where to split a pack, which packs to merge, and when to do so is a question of strategies, which we discuss in section 6. 4 negotiation: balancing the resource consumption among packs applications on a machine do not run in isolation: they share the device resources. with resource negotiation, d&c tries to prevent the combined adaptation of all applications in case a single one of them has to adapt. the main idea is that each pack is assigned a specific amount of every resource under negotiation. when changes in the theatre trigger an adaptation, the affected packs adapt locally within the allocated resource budgets. the hope is that such a local adaptation of packs result in new variants that are “good enough”, while the other packs can remain untouched. currently, we assume that an estimate within ±20% of reported utility value suffices. 4.1 weighting the priority of applications d&c gives the user additional control about the resource distribution. it allows her/him to rate applications according to her/his interests by assigning a number between 0 (irrelevant) and 1 (highly important). the priority is independent of the utility and the current variant of the application, thus an adaptation does not change it. priority and utility allow the middleware to find the applications that mostly contribute to the user satisfaction: these are those having the highest product of application priority × current application utility. note that the priority of one application is independent of other applications. as an effect, the proc. campus 2008 4 / 12 eceasst memory < 20 < 40 ≥ 40 cpu < 100 0.0 0.0 0.0 cpu < 200 0.0 v3, 0.3 v5, 0.4 cpu ≥ 200 0.0 v3, 0.3 v6, 0.7 happinessv3mem(x) =      0.0 if x < 20 0.3 if 20 ≤ x < 40 0.4 if 40 ≤ x happinessv3cpu(x) = { 0.0 if x < 100 0.3 if 100 ≤ x figure 1: example of happiness functions. the table on the left give the utilities (and associated variants) of an application part for different assignments of resources. the two functions on the right are the happiness functions for variant v3 with cpu less than 200 units. sum of priority values for a user’s applications can result in a number higher than 1. the reason is that we expect the user to manually set the priority and we do not expect her/him to normalize the values. 4.2 happiness – estimating utility resource negotiation is based on estimating the utility of packs given an allocated resource budget. optimal utility values and assignment of resources require global adaptation reasoning. because the aim of resource negotiation is to decide whether adaptation reasoning is necessary, it can only be based on estimates. d&c estimates utility by happiness functions. let us first detail happiness functions for application parts. assume that a part p depends on resource types r that d&c negotiates and other context information c that is not negotiated by d&c. if the context in c remains unchanged, then the utility of p depends on the amount of resources in r that it can consume. each variant v of p has a fixed utility uv if its resource needs are met by the assignment to r; if not, the part p is not able to run properly. to find the optimal utility of p for a specific resource assignment, we have to explore all variants of p, rejecting the invalid ones, and pick the one with the highest utility among the remaining. consider figure 1 as an example. assume that r consists of the resources memory and cpu, and an application part p has six variants that all require different amounts of these resources and yield different utilities. with the current context c, three of these six variants are realizable and are not dominated by another variant, i.e., there is no other variant that can be realized with the same resources and that has a higher utility. if, for example, p is assigned 50 units of memory and 150 units of cpu then v3 is the optimal variant of p yielding an utility of 0.3. now, if the availability of resources changes, then finding the new optimal variant requires recalculating the table or its stored copy. but, if we assume that only one resource can change, then it suffices to store all the different values for memory, given cpu = 100, and all different values for cpu, given memory = 40. these values are combined to piecewise define the happiness functions. happiness functions of parts can be calculated as by-product of adaptation reasoning. in particular, if the adaptation reasoning enumerates all variants, then the happiness functions can be constructed during the search. happiness functions for packs are the combination of those of parts. while happiness functions for parts always give the correct results, those for packs only approximate the real utility. the reason is that two or more parts can adapt individually without an adaptation of the whole 5 / 12 volume 11 (2008) divide and conquer – organizing component-based adaptation ≥ 80% of last part utility inititaion failure success pack utility < 80% of last < 80% of last ≥ 80% of < 80% of last part utility combined utility ≥ 80% of last pack utility local adaptation of part within its pack assignment of resources global adaptation, adaptation of pack individual pack estimates new pack utility last pack utility figure 2: life cycle of a resource negotiation node. note that only the regular state transitions are shown. the figure does not show transitions taken in exceptional situations, e.g., when new packs are established and when large amounts of free resources become available. transitions labeled with “80%” refer to estimates compared to the last calculated utility. pack. although each new happiness function is correct for the given resource assignment, a change of this assignment itself is not considered. therefore, the pack happiness functions after a global adaptation can differ from the locally adjusted ones. 4.3 distributing resources the life cycle of a resource negotiation node is shown in figure 2. it is an interplay of global and local adaptation. the automaton starts with a global adaptation of all participating packs. if it fails then local adaptation cannot find a solution either and the resource use on the considered device has to be reduced, e.g., by pack relocation. on success, the resulting initial resource assignments are handed to the packs. the automaton changes to the lower right state, where parts that are affected by a context change adapted individually. if the estimate by the happiness function indicates that the result is insufficient, then the automaton visits the states clockwise and the scope of adaptation widens: first the pack utility is estimated, then the whole pack adapts, and finally a global adaptation is performed. if in any of the states the current utility estimate is “good enough”, then the automaton goes into the lower right state again. for reasons of readability, figure 2 does not show three transitions of the automaton that connect the upper right state from the remaining three. these state changes are taken if an increase in the amount of free resources results in a combined expected utility of the packs that exceeds 120% of the current value, if a pack is relocated onto the machine, and after starting up an application. for reasons of brevity, we also left out the handling of priorities in the explanation of resource distribution. 5 decomposition tree: controlling the organization of packs d&c organizes the adaptation of applications in a theatre in a distributed and self-organized way without using a central controller. this organization is performed by a so-called decomposition tree—i.e., a weakly-connected, directed acyclic graph (dag) with a single root. we use the term “tree” instead of dag because, usually, we do not regard pack nodes as part of the graph. proc. campus 2008 6 / 12 eceasst nn1 nn2 nn3 nn4 tn2 tn3 tn1 b2a1 a2 b1p1 a3 p2 d1 d2 figure 3: a decomposition tree. square nodes denote packs while negotiation nodes have a diamond shape. the remaining tree nodes are depicted circular. the packs and the nodes are hosted by two devices d1 and d2, separated by the dotted border. physically, the nodes of the tree are data structures manipulated by the middleware instances; some part of the data constitutes the internal state of the node. the tree is distributed and there is no central middleware instance that has complete knowledge about all nodes. nodes are controlled by rules and a node being active means that its rules are matched against its internal state. the physical decomposition of the nodes allows several nodes to be active simultaneously. logically, the decomposition tree represents the result of the organization at a certain point in time. the nodes of the tree are annotated with local information about the organization process, which is the internal state of the node, such as the node’s parent and children, information about the node’s device, and past decisions. the collection of all such internal states is the current state of the d&c method. operationally, the nodes dynamically change the tree according to rules. on a certain context change, e.g., the appearance of a new middleware instance, nodes become active and update the tree until a new final form is reached and activity ceases. thus, the partitioning reflects the evolution of the application configuration. usually, only a few nodes are active and activity is deliberately handed from node to node. 5.1 nodes of the decomposition tree the nodes of the dag are of one of the three types: tree node, negotiation node, and pack node. the root is always a tree node and tree nodes can have children of all three kinds. negotiation nodes are restricted to have pack nodes as children and pack nodes are always leaves of the dag. each device has one negotiation node that distributes its system resources; a pack on a device is automatically child of this node. d&c uses a predefined list of resource types that a device can offer, such as memory and cpu usage. each application has a direct negotiation node that holds information about the dependencies between the application’s parts. different resource and application negotiation node have no direct relation to each other. figure 3 illustrates a decomposition tree that controls five application parts belonging to two applications: application a is divided into parts a1 to a3 and application b is divided into parts b1 and b2. parts a1, a2, and b1 form pack p1 that is under control of the node tn2 while the pack p2, consisting of parts a3 and b2, is handled by node tn3. negotiation nodes nn2 and nn3 handle the direct dependencies between the respective packs. node tn1 is the root of the decomposition 7 / 12 volume 11 (2008) divide and conquer – organizing component-based adaptation tree, tn2 and tn3 are leaf nodes (negotiation nodes and pack nodes are not considered regular nodes of the distribution tree). the packs and the nodes are distributed over two devices d1 and d2, denoted by the dotted border. the resources of d1 are negotiated by node nn1, while nn4 does the same for device d2. 5.2 working of the decomposition tree the operations of the decomposition tree can be divided into three classes: atomic operations, complex operations, and strategies. atomic operations are realized directly by the middleware. each node has available a set of atomic operations used to examine and alter the decomposition tree. examples are the migration of its children to another node or the participation in a process for electing a common root node. strategies decide which complex operation to perform in which situation (cf. section 6). complex operations correspond to reactive actions to apply on the decomposition tree. they are composed of basic operations of one or more nodes. examples are “join two decomposition trees” and “react to a failing negotiation node”. different compositions can result in similar complex operations (e.g., for the first example) and for the same purpose there can be complex operations with different outcomes (e.g., for the second). we have realized four classes of complex operations. (1) operations that organize the adaptation of applications: these are the splitting and merging of packs and their re-distribution. (2) operations resulting from changes in the status of an application: a starting application gets its own pack on the machine it is started on. on termination, application parts are removed from their packs. if a new application part is created as a result of an adaptation—i.e., not by the replacement of one part by another—then it is placed in a new pack. if a pack becomes empty because of the termination of an application or because of an adaptation, then it is removed. (3) operations that handle the sudden disappearance of a connection or of a device. (4) decomposition tree maintenance operations: these balance the tree, split nodes that have too many children, and merge those with too few. 6 strategies: selecting the adaptation heuristics the previous sections explained techniques that allow to reason about and to control the organization of the adaptation of theatres, the principles of this reasoning are given by strategies. they are implemented by rules and each node has its own rule-based control loop. strategies are currently under investigation and we develop a simulator to identify and compare different strategies. in detail, each node has an internal state that holds all the knowledge that the node has about the theatre. for example, a tree node knows about its parent, its children, its hosting middleware instance, and its past decisions. the internal state is updated either by one of its rules or by the middleware. the rules are condition-action pairs that match the internal state to state changes and to atomic operations as explained in subsection 5.2. strategies control the organization of the adaptation—i.e., which packs to split and where, which packs to merge, and when to relocate a pack. regarding the decomposition tree, strategies proc. campus 2008 8 / 12 eceasst have to determine the overall structure of the tree and the location of the tree nodes. they also handle effects that result from the localness of the reasoning within the decomposition tree: for example, independent decisions can yield to a deadlock. here, strategies have either to prevent these situations or have to provide a mechanism that overcomes the problem. other problems are desired states of the tree that are not reachable by other states and oscillating tree behavior. an example for a strategy is the following: when splitting a pack, we have two choices: (1) do not separate parts of the same application, e.g., {a1, a2, b1, b2} → {a1, a2},{b1, b2}. this option can result in a linear reduction of the adaptation time. it does not increase the structural negotiation effort and does not decrease the utility of the applications. (2) separate parts of the same application, e.g., {a1, a2, b1, b2} → {a1, b1},{a2, b2}. this option can result in an exponential reduction of the adaptation time but might decrease the utility of the applications. one strategy is to always try the first option if possible and try the second one only with packs where all contained parts are from the same application. 7 use case: the instantsocial scenario the following instantsocial (is) scenario [fhs08] demonstrates the capabilities of the d&c approach in organizing the adaptation in larger theatres. one general aim of adaptive middleware systems, and thus an aim of d&c, is to be transparent to the applications and to the user. therefore, we report two views: the user view typed in normal font and system view typed in cursive. paul is visiting a large rock festival. during a björk concert, he is not able to take a good shot, others could have done better. an adaptation is triggered and restructure the is decomposition tree with other discovered is nodes using a strategy which maximizes the quality of the pictures. paul is willing to share his pictures with others. he instructs his pda to look out for other visitors with the same interest. unfortunately, the internet connection is down and there is no immediate success. the decomposition tree is configured with a strategy that maximizes björk-related multimedia content. for the time being, the decomposition tree is restricted to a single node (paul’s pda) due to the lack of connectivity. back at his tent, paul listens to some music when his pda notifies him about the presence of a media sharing group. he happily joins, gives high priority to this application, and a moment later his display shows a selection of pictures, each representing a collection of shots. he browses through the content, selects the ones he likes, and begins to download. the pda runs a mp3 player with high priority and is with low. after a picture sharing community becomes available, the priorities get reversed. thus, the negotiation group sharing resources between the mp3 player and is is updated and the adaptation process allocates more resources to is in order to list and download the content provided by the community. among the adaptations performed, the media replicator and ontology components of is are replaced by similar services provided by two other pdas. suddenly, the current download aborts prematurely: one of the group members has left without prior notification. but only some of the pictures of this user disappear, others are still available. 9 / 12 volume 11 (2008) divide and conquer – organizing component-based adaptation the connection to the weak pda is lost and the is decomposition tree adapts with the help of the music middleware. the current download aborts, but some of the björk pictures have been seamlessly replicated, so their availability does not change. some time later, paul notices that the selection he sees becomes more precise: some topics he does not care about are no longer shown and some others, unusual but interesting ones, appear. he checks the internet connection and yes, the festival’s wifi network is up again. the internet connection is re-established. the decomposition tree adapts is by replacing the ontology component on paul’s pda by a much accurate one at a remote server. the selections are re-evaluated. unnoticed by him, paul’s pda now hosts a media replicator component. he decides to see the next concert and indicates his wish to leave the group. the pda asks him to wait a few seconds. after getting the acknowledge, paul returns to the stage for some more good music. some of the pictures kept on paul’s pda are moved to the remaining media replicator. after success, paul is notified and his community service terminates. the potential gains of using d&c in this example are numerous. its distributed nature allows applications to handle the frequent changes in the theatre gracefully: first, paul’s instantsocial application cannot provide useful service because it is alone. but after other instantsocial nodes become available, the social group is set up automatically. arbitrary, unanticipated changes alter the offered functionality but keep the group operational. a centralized control mechanism would fail in such situations. the use of packs allows instantsocial to make full use of the available resources by controlling which application parts are to be adapted in combination and which are not: some part of the weak pda’s instantsocial application is hosted by paul’s pda but they run with little interference. the fine-grained control over the priority of applications allows paul to search for a picture sharing group while listening to high quality music. when the group becomes available, the music is played with less quality. but paul is distracted anyway, so he does not realize it. 8 related work the greedy approach [bhre07] is another way of improving the adaptation organization. it adapts applications one by one, beginning with the one that offers highest expected utility. each application is given the remaining available resources until they are used up. the greedy approach reduces the overall adaptation time by adapting individual applications and has the potential of yielding a high overall utility. dacar [dm07] uses rule-based policies to monitor an environment, to deploy applications, and to react to changes in the environment. the use of generic rules allows the developer to formulate fine-grained policies that allow to reason about and verify the rule base. nevertheless, the control mechanism of dacar requires an entity with complete knowledge about the environment and the applications, which poses an error-prone bottleneck in dynamic theatres. in contrast, d&c builds on distributed, incomplete knowledge that is more suitable in this case. safran [dl06] is a framework for building self-adaptive, component-based applications that separates the application logic from the adaptation. it is very high level and, in principle, allows proc. campus 2008 10 / 12 eceasst for the implementation of techniques similar to the distribution tree. although safran supports distributed adaptation by allowing each component to decide upon which reconfiguration to operate, it does not support the coordination of adaptations that are carried out and can lead to unstable behavior, in certain cases. in [bt08], authors introduce a distributed architecture for coordinating autonomous agents. the proposed approach defines supervisors as coordinating entities for clusters of autonomous agents. supervisors can interact to aggregate and analyze context data retrieved by agents. each supervisor is responsible for implementing system-wide adaptations on agents associated to its cluster. according to authors, the clusters can be dynamically created and updated using dedicated techniques [edn07]. if, similarly to d&c, this approach tackles the coordination of large theatres, the proposed decomposition is rather static and does not support application driven organization of the topology. according to [mk], d&c is a combination of meta-level control-based planning and social law-based design: applications adhere to the distribution of resources provided by the negotiation nodes because of social laws. it is also control-based planning because each node in the decomposition tree “is guided by high level strategic information for cooperation”. minsky et. al. [mu00] develop principles of law-governed interactions, of which many hold for the d&c approach, too. the main difference to d&c is that they assume independent agents with their own priorities—i.e., whose decisions have to be controlled whether they are within the law— while in d&c the agents—i.e., the nodes—follow the law by design. 9 conclusions and future work this work proposes the divide and conquer (d&c) approach for organizing the adaptation of a theatre—i.e., of a number of large, distributed applications in mobile environments with frequent context changes. this organization is independent of the application logic and relieves the application developer from providing the organization himself. d&c considers packs—i.e., collections of parts of applications—and thus gives the middleware a more fine-grained control over the adaptation than what is achievable by operating with full applications. by dividing the overall task of adapting the theatre into the tasks of adapting individual packs, d&c allows the adaptation middleware to parallelize the required work. by allowing the user to assign priority to applications, d&c enables to balance the perceived quality of service according to her/his needs. the realization of this balance is independent of the application logic and does not require provisions by the developer. d&c uses distributed reasoning activities to decide upon and to change the division, as well as to react to expected and unexpected changes in the theatre. this approach yields a more decentralized and flexible organization of the adaptation as achievable by centralized reasoning. although the work on d&c is ongoing and the algorithms and heuristics of d&c are not rigorously validated, we believe that they will overcome the shortcomings of a global adaptation approach. we currently develop strategies that tell how and when the different options of organizing the adaptation should be applied. we plan to investigate if and how the results of other rule-based approaches to distributed adaptation could be applied in a d&c setting, e.g., the rules of dacar and safran. currently, we are developing a simulator that allows to investigate and compare different strategies. 11 / 12 volume 11 (2008) divide and conquer – organizing component-based adaptation acknowledgements: the work is funded by the klaus tschira foundation and by the european commission for the music project (# 035166). the authors would like to thank yun ding, frank eliassen, gunnar brataas, eli gjørven, and bernd rapp for their helpful comments. references [bhre07] g. brataas, s. hallsteinsen, r. rouvoy, f. eliassen. scalability of decision models for dynamic product lines. in proceedings of the international workshop on dynamic software produc line. sept. 2007. [bt08] l. baresi, g. tamburrelli. loose compositions for autonomic systems. in 7th international symposium on software composition (sc). lncs 4954, pp. 165–172. springer, budapest, hungary, mar. 2008. [dl06] p.-c. david, t. ledoux. an aspect-oriented approach for developing self-adaptive fractal components. in 5th international symposium on software composition. lncs 4089, pp. 82–97. springer, 2006. [dm07] j. dubus, p. merle. applying omg d&c specification and eca rules for autonomous distributed component-based systems. in kühne (ed.), international models workshop on models @ runtime (mrt’06). lncs 4364, pp. 242–251. springer, 2007. [edn07] r. m. elisabetta di nitto, daniel dubois. self-aggregation algorithms for autonomic systems. in 2nd international conference on bio-inspired models of network, information, and computing systems (bionetics). budapest, hungary, dec. 2007. [fhs+06] j. floch, s. hallsteinsen, e. stav, f. eliassen, k. lund, e. gjørven. using architecture models for runtime adaptability. ieee software 23(2):62–70, mar./apr. 2006. [fhs08] l. fraga, s. hallsteinsen, u. scholz. “instant social” – implementing a distributed mobile multi-user application with adaptation middleware. in 1st discotec workshop on context-aware adaptation mechanisms for pervasive and ubiquitous services (campus). easst, this volume. 2008. [krg07] m. u. khan, r. reichle, k. geihs. applying architectural constraints in the modeling of self-adaptive component-based applications. in ecoop workshop on model driven software adaptation (m-adapt). berlin, germany, july/aug. 2007. [mad06] madam ist. theory of adaptation. deliverable d2.2 of the project madam: mobility and adaptation enabling middleware, dec. 2006. [mk] a. mali, s. kambhampati. distributed planning. unpublished. [mu00] n. minsky, v. ungureanu. law-governed interaction: a coordination and control mechanism for heterogeneous distributed systems. tosem 9(3):273–305, 2000. [mus] ist music project. www.ist-music.eu. proc. campus 2008 12 / 12 www.ist-music.eu introduction the adaptation problem and the d&c approach packs -adapting collections of application parts negotiation: balancing the resource consumption among packs weighting the priority of applications happiness -estimating utility distributing resources decomposition tree: controlling the organization of packs nodes of the decomposition tree working of the decomposition tree strategies: selecting the adaptation heuristics use case: the instantsocial scenario related work conclusions and future work handling domain knowledge in design and analysis of design models electronic communications of the easst volume 74 (2017) 7th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2016 handling domain knowledge in design and analysis of design models kahina hacid and yamine ait-ameur 21 pages guest editors: anna-lena lamprecht eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst handling domain knowledge in design and analysis of design models kahina hacid1 and yamine ait-ameur2 1 kahina.hacid@enseeiht.fr, 2 yamine@enseeiht.fr université de toulouse ; inp ; irit institut de recherche en informatique de toulouse france abstract: the development of complex systems involves several domain experts and several design models corresponding to different analyses (views) of the same system. no explicit information regarding the characteristics of the performed system analyses is given. we propose a stepwise approach to keep trace of the process that allows a system designer to build a point of view first, by explicitly defining the features of an analysis (view) and second, by explicitly defining the required concepts and properties borrowed from a design model. the objective is to trigger a given model analysis. strengthening the design models with domain knowledge is highly recommended before performing such analysis. we propose a model annotation methodology for this purpose. these approaches are deployed using model driven engineering (mde) techniques and illustrated on an didactic case study. keywords: multi-view modeling, domain knowledge, ontologies, design model, model analysis 1 introduction usually, during the development of complex systems several models corresponding to different views of the same system are built. in most of the developments, there is no explicit information regarding the characteristics of the performed system analyses. thus, our work is motivated by the following observations. first, the system developer usually uses part of the system model for a specific activity (an analysis to perform on the model). indeed, some concepts are not useful for a given analysis. for example, real-time analysis does not require all the functional concepts of the analyzed system. there is no explicit definition of the concepts of a given model required by a given model analysis. second, when performing model analysis, the system developer does not explicitly describe the analysis that he/she used. in order to take design decision, another system developer needs the whole information and hypotheses related to the realized system model analyses ( in fact, the result of an analysis may interfere with the inputs and results of another analysis. thus information regarding the used method, tool, properties for an analysis may be needed to best evaluate its corresponding output result.). the system developer needs to know for example: what are the performed model analyses (tool, method, inputs, outputs, etc.)? what are the hypotheses made by the other analyses? and what are the parts of the system that have been analyzed? our proposal consists first, in explicitly defining the features of an analysis and second, in explicitly defining the required concepts and properties borrowed from a design model to trigger 1 / 21 volume 74 (2017) mailto:kahina.hacid@enseeiht.fr mailto:yamine@enseeiht.fr handling domain knowledge... a given model analysis. all these definitions are described in a model we will denote as point of view. proceeding this way, our approach keeps trace of the process that allows a system designer to build its model analysis. the achievement of the objectives of our proposal requires to make explicit all the knowledge and information (like the required properties, the configuration details to perform an analysis, the used method analysis, the analysis results, etc.) manipulated by the system developer while performing the analyses. this knowledge is formalized within domain ontologies. thus, we propose a model annotation methodology in order to make explicit references to this domain knowledge carried out by domain ontologies. the model annotation methodology is also used as a preliminary step in order to strengthen and enrich system design models. this paper is structured as follows. section 2 presents a didactic case study illustrating our approach. section 3 gives a definition of domain ontologies and design models. our global approach and the developed methodology for strengthening models through an annotation-based method are described in section 4. then, our methodology to handle multi-analysis of systems is presented in section 5. section 6 details the implementation of our approach on the basis of model driven engineering (mde) techniques. the application of the proposed global approach on the case study is shown in section 7. finally, section 8 overviews different approaches promoting multi-view modeling of systems. a conclusion ends this paper and identifies some future research directions. 2 a case study in order to illustrate our proposal, we have borrowed the case study used in [ha]. it is a didactic case study describing a simple information system corresponding to a given specification. it deals with the management of students within the european higher education system. this system offers two kind of curricula: the licence (or bachelor), master, doctorate curricula (lmd for short) and the engineer curricula. in the lmd curricula, each of the three proposed diplomas corresponds to a specific level of education : bachelor/licence (high school degree with 180 credits), master (bachelor with 120 credits) and phd (master with 180 credits). in the engineering curricula, an engineering degree is delivered after at least five years of studies within specialized high engineering institutes. in the studied information system, students register to prepare their next expected diploma. this registration action takes into account the last hold academic degree (or last diploma) as a pre-requisite to register for the next diploma. a set of defined constraints on this information system does not allow a student to register for a diploma if he/she does not have the necessary background qualifications. for example, phd degree registration is authorized only if the last held degree corresponds to a master degree. the studied information system prescribes the necessary conditions (constraints) for registering students for preparing diplomas. furthermore, the chosen case study is also concerned with the management of students diplomas. it offers, among other services, a printing service for the diplomas of graduated students. some required information, provided by the studied information system, is exploited to activate this service. isola ds 2016 2 / 21 eceasst 3 background 3.1 ontologies gruber defines an ontology as an explicit specification of a conceptualization [gru93]. we consider a domain ontology as a formal and consensual dictionary of categories and properties of entities of a domain and the relationships that hold among them [jpa06]. by entity we mean being, i.e, any concept that can be said to be in the domain. the term dictionary emphasizes that any entity of the ontology and any kind of domain relationship described in the domain ontology may be referenced by a symbol directly (usually referenced to as uri), for any purpose and from any context, independently of other entities or relationships. this identification symbol may be either a language independent identifier, or a language-specific set of words. but, whatever this symbol is, and unlike linguistic dictionaries, this symbol denotes directly a domain entity or relationship, the description of which is formally stated providing for (automatic) reasoning and consistency checking. finally, the ontology conceptualization is agreed upon by a community larger than the members involved in one particular application development. for instance, iso 13584-compliant (plib) [iso98, iso04] product ontologies follow a formal standardization process and are published as iso or iec international standards. 3.2 design models design models target the definition of models from which systems are realized. they are described within design languages. they represent abstractions of the system to be designed and/or analyzed. when models are defined and according to the modeling language, it becomes possible to perform a set of analyses like verification, validation, simulation, etc. the choice of the modeling language has an impact on the kind of analysis that can be performed on the models defined within this language. during design processes, several models of the same system may be produced within different modeling languages. indeed, some modeling languages focus on some specific aspects on which analyses become possible. this situation leads to heterogeneous models and heterogeneous modeling corresponding to specific views of the system under design. 4 an overview of our global approach: domain knowledge handling in design and multi-analysis of models our global approach is composed of two main parts. the first one, represented on the left hand side of figure 1 (grey box), addresses strengthening of design models. the design models are annotated by references to domain ontologies that describe the knowledge associated to the concepts occurring in the system model. a model annotation methodology is developed for this purpose and its details are given in section 5. the second part concerns the analysis of models through the explicit definition of points of view and views (corresponding to some system analyses or functional computation of the properties of the system under design), it is depicted in the right hand side of figure 1. the model analysis methodology makes extensive use of the model annotation one. indeed, a model annotation step is recommended in order to strengthen 3 / 21 volume 74 (2017) handling domain knowledge... the quality of the system design model (by adding new domain properties and constraints). thus, the model analysis methodology will be triggered on the new enriched design model (output of the model annotation step) and the quality of the obtained views will be increased. the model analysis approach is addressed in section 6. once the integration of the two defined parts is made, the obtained view models are automatically instantiated, the corresponding analysis are triggered on the view instances (instances of the obtained view) and the results (output of external analysis tool) are collected. our global approach uses model driven engineering (mde) techniques and all the implemented models conform to the ecore meta-model. figure 1: general framework for design and analysis of design models. 5 annotating design models with references to ontologies in this section, we describe the work we have done in order to strengthen system design models [ha16, ha]. it is represented on the left hand side of figure 1 (grey box). usually, design models do not handle, in an explicit manner, the knowledge of the application domain or context where models are designed. therefore, some useful properties available in the domain knowledge are not considered by the design models. moreover, these properties may be violated by the design model if they were handled. an error or an inconsistency in the model is produced in this case. hence, linking knowledge domains expressed by ontologies with the design models strengthens the designed models and offers the support of more verifications, since the properties expressed in the ontologies will become part of the designed models. model annotation is the mechanism we set up to link ontologies with design models. it consists in defining specific relationships between ontology concepts and model entities. 5.1 a methodology to handle design model enrichment in our previous work, we have developed a generic methodology to handle model annotation through references to domain ontologies. the developed approach is made of four steps, depicted on figure 2. isola ds 2016 4 / 21 eceasst figure 2: a generic approach for model annotation. 1. domain knowledge formalization. this step consists in formalizing the knowledge of a specific domain within domain ontologies. these ontologies fulfil all the requirements recalled in subsection 3.1. 2. model specification and design. design models formalizing and handling a given set of requirements are defined at this step. they are formalized within a specific modeling language and support different analyses offered by the chosen modeling language. 3. model annotation. this step defines annotations through explicit references to ontologies. in other words, models make explicit references to ontologies concepts. different kinds of annotations have been identified. the explicit definition and details on the types of annotation are given in [ha, ha16]. 4. properties verification. this step requires (re-)checking of the properties of the design models after annotation. indeed, some already checked properties may no longer be valid and/or new properties mined from the ontologies through annotation may appear explicitly (i.e. the ontological entities properties, concepts or constraints involved in the annotation process are integrated in the new enriched design model at the end of step 3 and become available in it). ontology modeling the deployment of the model annotation methodology requires in its first step the definition of an ontology formalizing the specific domain knowledge. concepts and properties are modeled as classes and attributes of the ontology and the ontological constraints are added as ocl 5 / 21 volume 74 (2017) handling domain knowledge... figure 3: the equivalence relationship. ∀ x,y,z | x7→y ∈ eq ∧ y7→z ∈ eq ⇒ x7→z ∈ eq eq_transitivity: equivalence.allinstances()-> forall(eq1, eq2| eq1.right = eq2.left implies equivalence.allinstances()-> exists(eq3|eq2.right = eq3.right and eq1.left = eq3.left)); figure 4: equivalence relationship: transitivity property expressed ocl. constraints. the whole ontological relationships like equivalence, restriction, etc. are also expressed. as illustration, figure 3 gives the definition of the equivalence relationship as a class at the meta-modeling level. the properties related to symmetry, reflexivity and transitivity of the equivalence relationship are formalized as ocl constraints. for example, figure 4 gives an overview of the formalization of transitivity property. core classes for model annotation the relevant information and entities required to set up the methodology depicted in figure 2 are summarized in a simplified class diagram on figure 5. in step 3 of the model annotation approach (figure 2) relations defining the annotation model are established between the design model entities and the ontology concepts. these annotation relationships link between design model entities (classes, properties, datatypes, associations, etc. ) and ontology concepts (classes, properties, associations, etc.). figure 5 depicts an extract of the annotation meta-model where the annotation relationships are formalized. the annotation class classannotation is defined to link (annotate) a design model class (ex. modelclass) with an explicit reference to an ontology concept (ex. ontologyclass). other types of annotation classes, like instanceannotation and propertyannotation, etc. are also defined. they are used to annotate other entities of the design model (instances, properties, etc.). figure 5: core classes for model annotation. isola ds 2016 6 / 21 eceasst some remarks the languages used to model ontologies, design models and annotation relationships may differ. semantic alignment between these modeling languages may be required. this topic is out of the scope of this paper, we consider that these languages have the same ground semantics. a single and shared modeling language for the description of both ontologies, design models and annotations is used in this work. furthermore, the engineering application we studied uses modeling languages with classical semantics using closed world assumption (cwa) [am16]. the annotation step (step 3) described above requires the definition of annotation mechanisms. different kinds of annotation mechanisms can be set up (inheritance, partial inheritance and algebraic relationships) [ha, ha16]. the details and choice of the right mechanism are also out of the scope of this paper. 6 handling multi-analyses of systems: our proposal we have developed a stepwise methodology to handle multi-analyses of systems and/or system model processing. the definition of this methodology comes from the observation of several experiments conducted by system developers (in order to formalize well established development practices and processes). it is based on making explicit the knowledge related to the know-how associated to the performed analysis. figure 6 below depicts the defined methodology. this triptych describes what a system or model analysis is. we have identified three steps detailed in the following. figure 6: a generic approach for multi-view modeling. 1. model of point of view. this step is related to the definition of a catalogue of system model analyses. it defines the notion of point of view which corresponds to the kind of analysis to be performed independently of any specific system or model. by the term catalogue we mean an ontology describing all the relevant characteristics related to an analysis. this ontology shall mention all the required properties, the constraints, the algorithm and/or 7 / 21 volume 74 (2017) handling domain knowledge... method used for a given analysis. it shall also organize these analyses with respect to the kind or type of analysis. 2. system design model. this step consists of the definition of the model of the system to be analyzed. the choice of the right abstraction level is a key point. indeed, if the chosen abstraction level leads to models that do not contain or represent the resources required by the analysis then the chosen analysis cannot be performed. our methodology is able to check this feasibility condition. 3. view. the integration of both the point of view (analysis description) obtained at step 1 and the system model obtained at step 2 is performed at the final step 3. here, the view corresponding to the definition of the analysis (point of view of step 1) on the system model (obtained at step 2) is built. checking the availability of all the information required by the analysis is done at this level i.e. checking the feasibility of the analysis. at the end of this process we obtain a specific view model corresponding to the defined analysis description. instances of the view model are generated and the external tool in charge of the specific analysis (and described within the point of view) is triggered on this set of instances. finally, notice that although the above defined methodology relies on the definition of an integration point of view (step 1) and system design model (step 2), these two models are defined independently in an asynchronous manner. second, note that the presented multi-view analyses methodology uses a single and shared modeling language for the description of the three involved models (point of view, design model and view model). 6.1 the core model elements the relevant information and concepts required to set up the methodology depicted in figure 6 are summarized in a simplified class diagram on figure 7. the following relevant properties are required in order to obtain the integrated view corresponding to a system model analysis. 1. model of point of view. the pointofviewclass corresponds to the description of an analysis defined at step 1 of figure 6. the following properties are defined. • the viewproperties property is associated to the view. it characterize the descriptive properties of an analysis. • the requiredproperties property defines the set of properties of the system model needed in order to trigger the described analysis. mappings may be required to map the properties defined in the point of view with those defined in the system model. • the computedproperties property describes the output of the analysis corresponding to the currently described point of view or analysis. • the usedmethod property defines the specific technique, method or program that supports the defined analysis. • the constraints property defines the constraints imposed by the method to be executed. it concerns constraints related to space or processor or any other required hypotheses. isola ds 2016 8 / 21 eceasst figure 7: core classes for multi-view modeling 2. system design model. it corresponds to the information model to describe the models to be analyzed (step 2 of figure 6). it is formalized within a modeling language that supports different analyses. we may find at least what follows. • the applicableproperties property corresponds to the properties associated to classes of the model to be analyzed. • the constraints property corresponds to the constraints that are defined on the model to be analyzed. these constraints characterize the correct set of instances. 3. view. finally, at step 3 of the approach (figure 6), the integrated view or analysis is built by composing the resources issued from both concepts of step 1 and step 2. • the importedpropertiesfrommodel property corresponds to the set of properties imported from the model to be analyzed. it defines the properties needed from the model to build the view and perform the analysis. • the importedview property refers to the analysis to be performed on the considered model. • the constraints property defines the new constraints that apply on the integrated view. • the analysisresult property defines the property containing the results of the analysis. the previous resources represent the concepts of a meta-model describing the integration of a point of view and a design model in order to obtain a specific view. note that the list of the given properties is not exhaustive, other properties to describe configuration information, analysis expert comments, etc. can be added. 9 / 21 volume 74 (2017) handling domain knowledge... this meta-model also defines the constraints that guarantee the correct integration. the correct correspondence between applicableproperties of the design model and the requiredproperties of the point of view can be checked in order to guarantee the correct construction of the view. thus, a construction is considered correct only if all the required properties (requiredproperties) can be retrieved within the defined design model properties (applicableproperties). these properties correspondences are made possible through the explicit references to ontologies. in fact, if two properties refer to the same uri of an ontological property, then they are considered to be semantically equivalent (identical). 7 developed prototype figure 8: implementation of the solution with eclipse emf. the developed approach makes an extensive use of model driven engineering techniques. our prototype has been developed using the eclipse modeling framework (emf) [emf]. it uses model graphical syntaxes and transformation techniques to support and ease model manipulation. eclipse modeling framework (emf) offers strong and large capabilities for modeling and for model manipulation. indeed, the emf modeling platform provides editors and code generation isola ds 2016 10 / 21 eceasst infrastructures. models are built in a modular manner with referencing capabilities between models. this modularity allows a developer to use emf with other eclipse projects. among the used projects in our developments, we mention the sirius[sir] project related to the development of graphical tool/editors. sirius is an eclipse project which allows the creation of model-based workbench by leveraging the eclipse modeling technologies, including emf and gmf[sir]. sirius has been used in this work in order to support the whole graphical tool development we have set up as prototype. model to model transformation is set up in our prototype. this is a many to one transformation which takes a point of view and a design model as input and returns a specific view model (corresponding to the integration of the two input models) as output. figure 8 describes the overall architecture of our implementation. the view meta-model is defined and the editors for the construction of a specific analysis view are generated. the view meta-model is implemented as an extension of the ecore meta-model. the design model and the point of view are described within ecore and conform to the ecore meta-model. the transformations required for the construction of a specific view and its instances are implemented in java. details about the implementation of the model annotation methodology can be found in [ha16, ah17] 8 application on the student information system case study the deployment of our approach, presented in section 4, on the student information system case study (presented in section 2) is described in this section. figure 9: general workflow of the student information system. figure 9 depicts the overall schema of the analysis we achieved on the student information system model. first, an annotation step is performed in order to enrich, strengthen and ensure the well definition (through the verification step subsection 5.1) of the student information system model. then the diploma factory analysis is performed. the goal of the diploma factory analysis is to build a set of valid diploma factory instances (carrying all the necessary information required to trigger the external printing tool and to print student diplomas). these diploma factory instances are directly built (extracted) from the student information system instances. 11 / 21 volume 74 (2017) handling domain knowledge... figure 10: the diplomas ontology. at the end of the procedure we obtain a set of required instances (instances of the obtained diploma factory view) to trigger the external printing tool in charge of printing the students diplomas (or any other function/tool that uses properties of a given point of view and of the system under design) 8.1 strengthening student information system model the application of the model annotation methodology on the student information system case study has been already presented in our previous work [ha]. next, we show the end-to-end application of our global approach. 8.1.1 step 1. domain knowledge formalization the defined ontology for diplomas is depicted in figure 10 in a simple class diagram. diplomas ontology contains a set of inter-related classes and relevant properties as follows. a subsumption relationship (represented by the is a relationship or inheritance relationship on figure 10) is used to define hierarchies between categories of diplomas. lmddiploma and classicaldiploma describe respectively the bachelor, master and phd diplomas and other diplomas (e.g. engineer). descriptive properties, like title, degree, uri of the diploma class describe the name, the level and the uri of a given diploma, nbcredit defines the number of credits required for each diploma. a domain property states that master is equivalent to engineer. in the diplomas ontology, this isola ds 2016 12 / 21 eceasst property is represented by an equivalent class (eqo) linking master and engineer classes of the same ontology. a constraint, defined as thesisrequirement, carried by the requireddiploma relationship is added to assert that any master (or any equivalent diploma) is required to prepare a phd. note that the presented diplomas ontology is only one of the possible ontologies for describing the diplomas domain knowledge. a final domain ontology needs to be consensually defined. 8.1.2 step 2. model specification and design the system’s design model is defined according to a given specification. figure 11 shows one possible uml class diagram representing the metamodel of the information system related to the management of students and their diplomas. it is composed of institutes and diplomas. an institute (a university or an engineering school) is composed of its students. in this model, a student is represented by student class with the name, dateofbirth, idstudent (for student number), address, securitynumber (for social security number) and dateofregistration properties. each student is related to his/her institute and his/her diplomas. moreover, each student holds an obtaineddiploma representing the last obtained diploma (obtaineddiploma relationship) and a nextdiploma referring to the next in preparation diploma (nextdiploma relationship). an institute is represented by the institute class with properties name, adress, phonenumber and openingdate. the obtaineddiploma is characterised by the dateofobtention (for date when the diploma was obtained by a student) and the obtainedcredits (for the number of credits a student obtained for his last diploma) properties. nextdiploma is characterised by the requiredcredits and requireddiploma (for the number of credits and the grade of diploma required in order to register for a specific next diploma) properties. figure 11: overview of the student information system model. 13 / 21 volume 74 (2017) handling domain knowledge... student.nextdiploma.id = ”p” ⇒ student.obtaineddiploma.id = ”m” phdinscritpion: self.nextdiploma.id = ’p’ implies self.obtaineddiploma.id = ’m’ figure 12: formalization of phdinscritpion constraint. figure 13: annotation of student model. moreover, a constraint named phdinscription on the student nextdiploma is defined. it asserts that a student registering for a phd diploma needs to hold a master diploma to be allowed to register for a phd. it represents a model invariant and it is defined by the ocl constraint of figure 12. 8.1.3 step 3. model annotation in step 3, the annotation model is defined. figure 13 shows how the annotation relationships between the design model entities and the ontology concepts are set up. the obtaineddiploma class of the students information system design model instantiates modelclass (figure 3) and the master class of the diplomas ontology instantiates ontologylclass (figure 3). the obtaineddiploma class is annotated by making explicit references to the master class using a classannotation class. similarly, nextdiploma is annotated by phd of the diplomas ontology. the non-structural equivalence property and the thesisrequirement constraint can now be accessed and exploited. thus, the equivalence between master and engineer classes is expressed and made explicit within the design model. 8.1.4 step 4. properties verification the obtained annotated design model is analyzed at step 4. the annotation process (step 3) leads to the enrichment of the original design model with domain knowledge (properties, constraints, etc.). all the ontological properties involved during the annotation process (the ones selected or linked to the model entities) are now available in the enriched model. the new enriched student information system model is validated by (re-)checking all the available constraints on the model. the verification process ends with integrating the diplomas equivalence domain property and the thesisrequirement constraint into the enriched design model since all the properties they are related to are available. at this level, it becomes possible to conclude that a student can apply for preparing a phd thesis if he holds an engineer diploma. the phdinscritpion constraint is modified to integrate the result of annotation. figure 14 depicts the new enriched constraint. this property became explicit after handling domain knowledge (by annotation) expressed in the ontology. at the end, the obtained model together with its instances are now ready to be analysed. figure 15 shows an instance of the enriched student information system model. instances of student, school, obtaineddiploma and nextdiploma classes with all their associated attributes isola ds 2016 14 / 21 eceasst student.nextdiploma.id=”p” ⇒ annotation(student.obtaineddiploma) ∈ eq(master) phdinscritpion: self.nextdiploma.id = ’p’ implies let c: ecore::eclass = classannotation.allinstances()-> select(inst|inst.annotatedclass = self.obtaineddiploma)-> at(0).annotatingclass in equivalence.allinstances()-> exists(eq| eq.left.uri = ’master_uri’ and eq.right = c); figure 14: the ocl constraint phdinscritpion after annotation. figure 15: student information system model instance. are defined. next subsections show how the diplomas factory analysis is performed on these model and its instances. 8.2 the diploma factory model analysis the details of the construction and application of the diploma factory analysis are given in the following subsections. 8.2.1 step 1. model of point of view: the diploma factory analysis the deployment of our model analysis methodology requires, in its first step, the description of a point of view. to make this description explicit, we have used a simple class diagram to express the different properties required to perform the analysis. the defined point of view for the diploma factory analysis is depicted in figure 16. the external printing function to be triggered and its required input parameters are described. the printingmethod property characterises the external printing function to be used and the printingtool property makes references to the external tool (encoding the printing function) that will be called for printing students diplomas. point of view’s (pov) requiredproperties and viewproperties make references to the needed input parameters of the diploma printing function. name of a student, dateofobtention of a diploma, idstudent (for student number), etc. are described as required properties. thus, they shall be imported directly from the design model. the papersize and the logo of the university 15 / 21 volume 74 (2017) handling domain knowledge... are defined as view properties and are directly imported from the corresponding ontologies. the result class defining the url property is used to store the output results of the printing function. notice that the semantics of these properties (required properties and view ones) are defined in the corresponding domain ontologies (diplomas ontology, students ontology, printing ontology, etc.), they are not given here due to space limitation. moreover, not all the design model properties are required for the construction of a diploma factory view, thus only the required properties, specified within the point of view model, are imported for each specific analysis. figure 16: the diplomas factory point of view. 8.2.2 step 2. system design model the design model some system analyses or functional computation of the properties of the system under design is defined at this level. it corresponds, in this case study, to the new strengthened student information system model and its instances obtained at the end of the model annotation step (subsection 8.1.4). 8.2.3 step 3. diplomas factory view a specific diplomas factory view can be built by integrating the resources issued from both the student information system model and the diplomas factory point of view. thus, both the required properties and the view properties are imported in the diplomas factory view. figure 17 depicts the diplomas factory view. figure 17: diplomas factory view. isola ds 2016 16 / 21 eceasst figure 18: diplomas factory view instance. the student, obtaineddiploma, institute, printingpov and result classes containing the different properties referenced by the point of view of the diplomas factory analysis (figure 16) are imported (note that by selecting a point of view in the view editor, all the referenced properties, with their classes, are automatically imported in the view). the instances corresponding to these classes and properties are generated by a model to model transformation. an instance of the result class is generated for each instance of the diplomas factory view, it contains the url (address) of the output of the external tool to trigger. in this case the location of each printed diploma can be accessed. figure 18 depicts such a diplomas factory view instance. it is built (extracted) from the enriched student information system model instance shown in figure 15. only the relevant information for diplomas factory view are defined. the instances of the required properties defined within student, obtaineddiploma and institute classes are imported. the instance of nextdiploma class is not imported in the view instance since it is not relevant for this view (not described within the diplomas factory point of view). the usedmethod, usedtool properties are instantiated to describe the suited analysis to trigger on the view instances. the view properties like papersize are instantiated. the additional user choices are made explicit. at the end, the external printing tool is triggered on the set of diplomas factory instances. students diplomas are printed and their corresponding storing url are given as output results of the printing tool. remark. note that any function that considers a system and a view can be triggered. the student information system case study shows a functional case, but other functions describing 17 / 21 volume 74 (2017) handling domain knowledge... logical properties can envelope any system analysis. this is our intent when using a function that borrows information both from the point of view and from the design model. in the particular case of our paper, the proposed design model in the case study formalizes the student information system knowledge and the printing process is not directly attached to this knowledge. however, some of the knowledge formalized in the student information system model is required in order to trigger the printing. thus, the printing process is defined as a specific view of the system and does not unnecessarily overload the system design model 9 related work many researchers studied the issue of multi-view modeling. sirius [sir] is part of emf. it proposes a multi-view approach which allows users to manipulate sub-parts of a model and focus on specific view of a design model. [kak09] presents the ram approach, an aspect-oriented modeling approach that provides scalable multi-view modeling and however faces the global view consistency challenge. it focuses on the composition of uml class diagrams, uml state and sequence diagrams. [tqb+14] deals with the integration of viewpoints (points of view) in the development of mechatronic products. the vocabulary, assumption and constraints of a specific domain are defined in viewpoint contracts and dependency models (shared models) are used to capture the existing relations between the different views of a system. [sksp10] propose a framework for multi-view modeling to support embedded systems engineering. a common shared model, that consists of a combination of relevant knowledge from the domain-specific views, is defined in sysml. the domain-specific views are directly generated from this common model which makes extensive use of sysml profiles and model transformations. [ver94] discuss the requirements for multi-view modeling and several approaches and tools are compared with regards to the defined requirements. [fkg91] present an approach based software development with multiple viewpoints. viewpoint templates are used to encapsulate the style (representation) and the workplan (specification method) corresponding to the different domain views of a system. a viewpoint framework, corresponding to the developed approach, and a logic-based approach to consistency handling are proposed later in [fgh+94]. to the best of our knowledge, it is the only approach that focusses on the importance of the explicit definition of a point of view. compared to our approach, none of the work cited above, highlight the necessity of defining descriptive models and none of them makes use of explicit analysis models (points of view). our approach improves these approaches. first, it defines explicit models that describes the whole features of an analysis. second, it separates the descriptive domain information (ontologies) and the prescriptive system information (system’s design model), it proposes a fully developed annotation methodology in order to strengthen system’s design models by making explicit references to the domain knowledge. both modularity and annotations insures that all the models we have defined (ontology, design model, point of view) can evolve asynchronously without impacting on the setted interactions with the other models. isola ds 2016 18 / 21 eceasst 10 conclusion and perspectives the work presented in this paper shows the major interests of model strengthening and mutliview model analyses. the first part of our work demonstrated that the use of domain ontologies to describe the shared knowledge of a domain and the capability to link the design system models to these ontologies through annotations allows system designers to handle properties, axioms, hypotheses and theorems directly mined from the application domain and thus, allows the system designers to design higher quality models. indeed, the quality of design models is increased by the annotation operation. as a consequence, properties and constraints available in the ontology are imported in the annotated model. checking whether these properties and constraints are fulfilled may reveal some inconsistencies in the design models that shall be fixed by the system developer. the second contribution of our work concerns the capability to handle model analyses. this idea is not new. but, the novelty of our approach consists in two main aspects. the first one consists in making explicit model analyses through the definition of a descriptive model (point of view) that describes the whole features of an analysis. ontologies of model analysis are used for this purpose. the second aspect concerns the explicit definition of the required concepts and properties borrowed from a design model to trigger a given model analysis. indeed, as for annotation, when performing a model analysis, our approach keeps trace of the process that allowed a system designer to build its model analysis. we have shown the deployment of our global approach in the case of model driven engineering techniques. we have shown on a case study, the feasibility of our approach from model strengthening using model annotation methodology to multi-view model analysis methodology. a deployment on formal methods based on proof and refinement using the event-b method is also made [ha]. the formal deployment of multi-view model analysis methodology is however still under progress. the work presented in this paper has been developed as part of the ame corac-panda project [ame] and has been applied to several case studies issued from embedded systems engineering domain. experiments with mde based techniques have been conducted on avionic systems [ah15, ah17]. several other research directions to pursue our work can be envisaged. we are interested in offering the capability to integrate and ideally compose several model analyses. for the moment, the developed approach allows a designer to perform a single analysis at a time. allowing such integration will offer different analysis patterns. finally, we only considered, in this paper, the case where the different involved models (ontologies, design models, analysis models) are described in the same modeling language, the case of semantic mismatch, where ontologies, design models and points of view are not described in the same modeling language, should be considered. bibliography [ah15] y. aı̈t ameur, k. hacid. report ame corac-panda project. technical report, institut de recherche en informatique de toulouse, toulouse university, 2015. 19 / 21 volume 74 (2017) handling domain knowledge... [ah17] y. aı̈t ameur, k. hacid. report ame corac-panda project. technical report, institut de recherche en informatique de toulouse, toulouse university, 2017. [am16] y. aı̈t ameur, d. méry. making explicit domain knowledge in formal system development. science of computer programming 121, 2016. [ame] ame-corac: avionique modulaire etendue conseil pour la recherche aronautique civile. http://aerorecherchecorac.com/. [emf] eclipse modeling framework. https://www.eclipse.org/modeling/emf/. [fgh+94] a. c. finkelstein, d. gabbay, a. hunter, j. kramer, b. nuseibeh. inconsistency handling in multiperspective specifications. ieee transactions on software engineering 20(8):569–578, 1994. [fkg91] a. finkelstein, j. kramer, m. goedicke. viewpoint oriented software development. university of london, imperial college of science and technology, department of computing, 1991. [gru93] t. r. gruber. a translation approach to portable ontology specifications. knowl. acquis. 5(2), june 1993. [ha] k. hacid, y. aı̈t ameur. strengthening mde and formal design models by references to domain ontologies. a model annotation based approach. in leveraging applications of formal methods, verification and validation: foundational techniques 7th international symposium, isola 2016, proceedings, part i. [ha16] k. hacid, y. aı̈t ameur. annotation of engineering models by references to domain ontologies. in model and data engineering 6th international conference, medi 2016, almerı́a, spain, september 21-23, 2016, proceedings. pp. 234–244. 2016. [iso98] iso. industrial automation systems and integration parts library part 42: description methodology: methodology for structuring parts families. iso iso13584-42, international organization for standardization, geneva, switzerland, 1998. [iso04] iso. industrial automation systems and integration parts library part 25: logical resource: logical model of supplier library with aggregate values and explicit content. iso iso13584-25, international organization for standardization, geneva, switzerland, 2004. [jpa06] s. jean, g. pierra, y. aı̈t ameur. domain ontologies: a database-oriented analysis. in filipe et al. (eds.), webist (selected papers). lecture notes in business information processing 1. springer, 2006. [kak09] j. kienzle, w. al abed, j. klein. aspect-oriented multi-view modeling. in proceedings of the 8th acm international conference on aspect-oriented software development. aosd ’09, pp. 87–98. acm, new york, ny, usa, 2009. isola ds 2016 20 / 21 http://aerorecherchecorac.com/ https ://www.eclipse.org/modeling/emf/ eceasst [sir] sirius. http://www.eclipse.org/sirius/. [sksp10] a. a. shah, a. a. kerzhner, d. schaefer, c. j. j. paredis. multi-view modeling to support embedded systems engineering in sysml. pp. 580–601. springer berlin heidelberg, berlin, heidelberg, 2010. [tqb+14] m. törngren, a. qamar, m. biehl, f. loiret, j. el-khoury. integrating viewpoints in the development of mechatronic products. mechatronics 24(7):745–762, 2014. [ver94] m. verlage. multi-view modeling of software processes. software process technology, pp. 123–126, 1994. 21 / 21 volume 74 (2017) http ://www.eclipse.org/sirius/ introduction a case study background ontologies design models an overview of our global approach: domain knowledge handling in design and multi-analysis of models annotating design models with references to ontologies a methodology to handle design model enrichment handling multi-analyses of systems: our proposal the core model elements developed prototype application on the student information system case study strengthening student information system model step 1. domain knowledge formalization step 2. model specification and design step 3. model annotation step 4. properties verification the diploma factory model analysis step 1. model of point of view: the diploma factory analysis step 2. system design model step 3. diplomas factory view related work conclusion and perspectives generating meta-model-based freehand editors electronic communications of the easst volume 1 (2006) proceedings of the third international workshop on graph based tools (grabats 2006) generating meta-model-based freehand editors mark minas 13 pages guest editors: albert zündorf, daniel varró managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst generating meta-model-based freehand editors mark minas1 1mark.minas@unibw.de, http://www.unibw.de/mark.minas/ institut für softwaretechnologie universität der bundeswehr münchen, germany abstract: most visual languages as of today (e.g., uml) are specified using a model in a meta-model-based approach. editors for such languages have supported structured editing as the only editing mode so far. free-hand editing that leaves the user more freedom during editing was not supported by any editor or editor framework since parsing has not yet been considered for meta-model-based specifications. this paper describes the diagram editor generator framework diameta that makes use of meta-model-based language specifications and supports free-hand as well as structured editing. for analyzing freely drawn diagrams, diameta parses a graph representation of the diagram by solving a constraint satisfaction problem. keywords: diagram editors, meta-modelling 1 introduction each visual editor, i.e., tool for editing data structures visually, implements a certain visual language. several approaches and tools have been proposed to specify visual languages and to generate editors from such specifications. these approaches and tools can be distinguished by the way (1) the diagram language is specified, and by the way (2) the user interacts with the editor and creates resp. edits diagrams. these distinguishing features are considered in the following: 1. traditionally, some kind of grammar has been used to specify visual languages for editors providing free-hand as well as structured editors. some examples are extended positional grammars in vldesk [cdp05] and constraint multiset grammars in penguins [cm95] for free-hand editing, and hypergraph grammars in diagen [min02, min04] for freehand as well as structured editing. grammars describe a language syntax by rules that are applied, starting at a certain starting symbol, to derive valid sentences of the language. syntactically analyzing diagrams means trying to find a sequence of rule applications that derive the diagram or some representation of it. communication between diagram editor and application requires building an abstract representation of the diagram by attribute evaluation, i.e., additional specification and evaluation efforts are necessary. however, most current graph-like languages, i.e., the majority of visual languages, at least in computer science, have a model as (abstract) syntax specification. models are essentially class diagrams of the data structures that are visualized by diagrams. this approach is generally called meta-model-based since the syntax of models is specified by models, too. some examples for meta-model-based approaches are atom3 [lva04], pounamu [zgh04], and metaedit+ [met05]. there are several reasons for the success 1 / 13 volume 1 (2006) mailto:mark.minas@unibw.de http://www.unibw.de/mark.minas/ generating meta-model-based freehand editors of this approach. one of them is the training of users in specifying data structure with class diagrams. on the contrary, writing grammars appears to be much more complicated. moreover, the visual modeling languages of the unified modelling language (uml) are specified by models, too. extending such visual languages then requires to use and extend their models instead of writing grammars. 2. when considering user interaction and the way how the user can create and edit diagrams, structured editing is usually distinguished from free-hand editing. structured editors offer the user some operations that transform correct diagrams into (other) correct diagrams. free-hand editors, on the other hand, allow to arrange diagram components from a language-specific set on the screen without any restrictions. the editor has to find out whether the drawing is correct and what is its meaning. therefore, structured editors offer more guidance to the user which may make editing easy. however, free-hand editors leave more freedom to the user when she edits diagrams. allowing for (temporarily) incorrect diagrams may make the editing process even easier. there are many examples of grammar-based tools supporting structured editing and free-hand editing. however, all of the meta-model-based approaches offer structured editing only. we are not aware of any tool supporting free-hand editing although that editing mode would offer more freedom to the user. a recent paper has shown that analyzing the correctness of a diagram and determining its meaning based on a meta-model-based approach can be efficiently solved by transforming this task into a constraint satisfaction problem [min06]. based on this approach, the tool diameta is described in the following. diagram languages must be specified by models, and diameta generates visual editors offering structured editing as well as free-hand editing from such specifications. generated editors, therefore, allow for easy free-hand editing and, at the same time, easy meta-model-based language specifications. the next section describes the syntax specification with models that are class diagrams of the edited object structure. moreover, the basic concepts of syntax analysis as described in [min06] are outlined. section 3 introduces the common editor architecture of each editor built using diameta and the diagram analysis when editing a diagram in free-hand mode based on the concepts presented in section 2. section 4 presents details of the diameta environment, in particular on specification and code generation. section 5 concludes the paper. 2 syntax specification and analysis based on class diagrams class diagrams are primarily used for specification of object structures that are created by instantiation of classes and associations between them. subclassing is used to create subtypes that inherit all features of their superclasses. additional constraints on the object structures may be used to restrict the set of all valid object structures even more. the unified modeling language uml allows for expressing such constraints using the object constraint language ocl. in this paper, we are considering diagram editors that allow visually creating and modifying such object structures. hence, class diagrams together with additional constraints are the specification of the corresponding diagram language. however, we will ignore additional constraints in the following in order to simplify discussions. proc. grabats 2006 2 / 13 eceasst figure 1: model (i.e., class diagram) of trees class diagrams specify object structures, but they do not specify a diagram language syntax directly. syntax specification by class diagrams is limited to those diagram languages that provide a reasonably simple mapping between a diagram and its underlying object structure. this is particularly true for graph-like diagram languages that have an almost one-to-one relation between diagram components and objects. diameta requires that a diagram is easily and uniquely mapped to a graph that resembles its object structure.1 when drawing a diagram in free-hand mode, its representing graph is created by the editor. we use simple trees as an example in the paper. the class diagram in fig. 1 contains class abstractnode as the abstract base class of a tree’s nodes. each node has a member attribute text2. concrete classes are root, innernode, leaf, and singlenode. abstract superclasses parent and child represent nodes that act as parents resp. children. please note that innernode is a subclass of both classes. parent-child-relations are represented by the association between parent and child with the roles child resp. parent. please note the cardinalities; they specify that a parent must have at least one child, and a child must have exactly one parent. the classes circle and arrow represent aspects of the concrete syntax aspect of the visual components as described in section 3.2. the class diagram does not completely specify trees. it does not prevent object structures from being circular, and data structures may be disconnected. the first problem could be solved by turning the association into a composite association which, by definition, prohibits circles. the second problem, however, can be described by additional constraints only. we omit them and, therefore, specify sets of trees instead of trees. fig. 2 shows a valid tree and the uml object diagram of its object structure. the node names are also used as object identifiers. checking the represented tree for syntactic correctness means checking whether the object structure can be created by instantiation as described by the class diagram.3 that is obviously true here, i.e., the object structure and the represented diagram are 1 this process of mapping a diagram to an object structure is performed by the reducer as described in section 3.4. since the reducer is rather powerful, diameta is not restricted to graph-like diagrams, only. for instance, hierarchical diagrams like statecharts are supported as well as nassi-shneiderman diagrams. 2 fig. 1 is a screenshot of the emf model as used in diameta based on the eclipse modeling framework (emf) [emf06]. emf type estring corresponds to the java type string. 3 the classes circle and arrow are ignored until section 3.2. 3 / 13 volume 1 (2006) generating meta-model-based freehand editors parent child parent child parent child b a c d a:root c:leaf d:leaf b:innernode text=a text=b text=c text=d 60diagen syntax definition with graphs, graph grammars and metamodels mark minas, universität der bundeswehr münchen abstract node circle abstract node circle circleabstract node abstract node circle arrow arrowarrow figure 2: sample tree, its object diagram with respect to fig. 1, and its instance graph. syntactically correct. however, root node, inner node and leaves of a tree cannot be distinguished visually. actually, each leaf node may be turned into an inner node by adding an outgoing edge to another node. free-hand editors, therefore, cannot unchangeably bind an internal representation to the visual component. the editor rather has to reconsider this binding after each diagram modification. in the example of fig. 2, an editor can deduce from context information that a is a root node, b an inner node, and c as well as d are leaves. the editor has to perform this task by first binding the common type of all possible internal representations, i.e., class abstractnode in the example, to each visual component. the obtained data structure (called instance graph in the following) is similar to object diagrams with the exception of the not yet determined concrete component types. correctness of the instance graph and, hence, of the diagram is checked by deducing the concrete types and examining whether the resulting object structure fits to the class diagram. in the predecessor paper [min06], this problem is expressed as the problem of finding a special kind of graph morphism from the instance graph to the graph schema that represents the class diagram. searching for the concrete types of the instance graph nodes is actually a constraint satisfaction problem (csp). preprocessing of this csp requires linear time in the size of the analyzed diagram. experiments had shown that backtracking was never required after preprocessing the csp, i.e., syntax analysis is efficient when using meta-model-based syntax specifications. 3 diameta editors diameta provides an environment for rapidly developing diagram editors based on metamodelling. diagram editors developed using diameta (such editors are called “diameta editors” in the following) always support free-hand editing. each diameta editor is based on the same editor architecture and contains code that is specific for this editor and its diagram language. the editor architecture is described in the following whereas section 4 outlines how diameta’s specification and code generation tool, the diameta designer, is used to generate the specific code of an editor. 3.1 diameta editor architecture since diameta is actually an extension of the diagram editor generator diagen [min02, min04], diameta editors have a structure similar to that of diagen editors. fig. 3 shows proc. grabats 2006 4 / 13 eceasst 54diagen syntax definition with graphs, graph grammars and metamodels mark minas, universität der bundeswehr münchen diagen: architecture of generated editors with metamodels graph model graph model modeler instance graph instance graph reducer model checker java objects java objectsdiagram diagram drawing tool editor user selects operation selects operation graph transformer (optional) reads reads adds/removes modifies reads highlights syntactically correct sub-diagrams layouter (optional) figure 3: architecture of a diagram editor based on diameta. the structure which is common to all diameta editors and which is described in the following paragraphs. ovals are data structures, and rectangles represent functional components. flow of information is represented by arrows. if not labeled, information flow means reading resp. creating the corresponding data structures. the structure of diameta editors is very similar to diagen editors; they most prominently differ in the method of abstract syntax specification and, hence, syntax analysis. moreover, diagen requires a specification of attribute evaluation for creating abstract diagram representations. since class diagrams as abstract syntax specification are also a specification of abstract diagram representations, diameta does not require such an additional specification. the editor supports free-hand editing by means of the included drawing tool which is part of the editor framework, but which has been adjusted by the diameta designer. with this drawing tool, the editor user can create, arrange and modify diagram components which are specific to the diagram language. editor specific program code which has been generated by the diameta designer from the language specification is responsible for the visual representation of these language specific components. the drawing tool creates the data structure of the diagram as a set of diagram components together with their attributes (position, size, etc.). the sequence of processing steps necessary for free-hand editing starts with the modeler and ends with model checker (cf. fig. 3): the modeler first transforms the diagram into an internal model, the graph model. the reducer then creates the diagram’s instance graph that is analyzed by the model checker (cf. section 2). this last processing step identifies the maximal subdiagram which is (syntactically) correct and provides visual feedback to the user by drawing those diagram components with a certain color; errors are indicated by missing colors. however, the model checker not only checks the diagram’s abstract syntax, but also creates the object structure of the diagram’s syntactically correct subdiagram. the results of this step are not always uniquely defined, depending on the specification. the model checker cannot always uniquely deduce the concrete object types. however, this is considered a specification error. moreover, there is not always a unique maximal syntactically correct subdiagram. diameta then selects an arbitrary one. this behavior is sufficient in most cases 5 / 13 volume 1 (2006) generating meta-model-based freehand editors since wrong parts of the diagram are emphasized anyway. the layouter modifies attributes of diagram components and thus the diagram layout based on the (syntactically correct subdiagram’s) object structure. the layouter is necessary for realizing syntax-directed editing: structured editing operations modify the graph model by means of the graph transformer and add or remove components to resp. from the diagram. the visual representation of the diagram and its layout is then computed by the layouter. however, layouters and structured editing are not considered in this paper. the processing steps necessary for free-hand editing are described in more detail in the following. 3.2 diagram components each diagram consists of a finite set of diagram components, each of which is determined by its attributes. for the diagram language of trees, there are nodes and arrows. each node is a circle whose position is defined by its xpos and ypos coordinates, its size by a radius attribute, and its inscribed text by a text attribute. each edge is an arrow whose position is defined by its two end points, i.e., by two coordinate pairs xpos1 and ypos1 resp. xpos2 and ypos2. all of these attributes are necessary for completely determining a diagram component, e.g., when storing it to a file or retrieving it again. however, only some of these attributes are essential for a diagram’s abstract syntax, too. in the tree example, only the inscribed text of a node is part of the abstract syntax. position and size attributes are solely member of the concrete syntax. this fact is modelled in the tree model in fig. 1, too: attribute text is a member of abstractnode; the other attributes do not belong to any class of the abstract syntax. however, they are attributes of the two additional classes circle resp. arrow which describe the diagram components and, therefore, belong to the concrete syntax, indicated by the stereotype 〈〈vcomponent〉〉.4 these concrete syntax classes belong to the diagram language’s model for two reasons: 1. in order to specify all attributes in a single model, not only attributes from the abstract syntax are modelled in the diagram language model, but also the attributes from the concrete syntax. 2. the object structure as result of model checking is an instance of the diagram language model in terms of its class diagram. in order to contain all the information about the diagram, its concrete syntax attributes have to be represented, too. this is necessary for computing the layout based on the object structure, but also to store an object structure and to be able to retrieve the complete diagram again. note that a node’s attributes are spread over two classes: circle and abstractnode. the connection between both classes is indicated by an association annotated with stereotype 〈〈vrepresents〉〉. the code generator of the diameta designer, when generating code for visual components, uses attributes of classes annotated with 〈〈vcomponent〉〉 stereotypes and those which are connected by associations annotated with 〈〈vrepresents〉〉 stereotypes to store a visual component’s attributes. 4 diameta uses the three stereotypes 〈〈vcomponent〉〉, 〈〈vrepresents〉〉, and 〈〈vassigned〉〉 to annotate class diagrams and to control diameta’s code generator. the meaning of these stereotypes are outlined in the following. proc. grabats 2006 6 / 13 eceasst 62diagen syntax definition with graphs, graph grammars and metamodels mark minas, universität der bundeswehr münchen circle circle circlecircle arrow arrow arrow from from from at toto to atat at at at border border bord er border figure 4: graph model of the tree in fig. 2. note also that there is an association between classes arrow and child that is not annotated with 〈〈vrepresents〉〉. arrow instances do not have a direct representative in the abstract syntax like circle instances that are represented by instances of abstractnode subclasses. an arrow instance is best assigned to a child object as it has an incoming arrow. since arrow instances do not have a text attribute, stereotype 〈〈vrepresents〉〉 does not make sense for the association between classes arrow and child either. instead, stereotype 〈〈vassigned〉〉 is used as annotation for this kind of associations. diagrams are checked for their correctness in terms of their instance graphs. the main difference between instance graph and object diagram of a diagram are the not yet determined concrete classes of the object diagram. however, instance graphs are the result of a translation process from the diagram’s concrete syntax, i.e., mainly the arrangement of is diagram components. this process is described in the following, and it requires an intermediate, uniform representation of the analyzed diagram, its graph model. 3.3 graph model arrangements of diagram components can always be described by spatial relationships between them. for that purpose, each diagram component typically has several distinct attachment areas at which it can be connected to other diagram components. an arrow representing an edge of a tree, e.g., has its two end points as attachment areas. connections can be established by spatially related (e.g., overlapping) attachment areas as with trees where an arrow has to end at the border of a node’s circle in order to be connected to the node. diameta uses directed graphs to describe a diagram as a set of diagram components and the relationships between attachment areas of “connected” components. each diagram component is modeled by a node (called component node) whose type is determined by the kind of represented diagram component. attachment areas are also modeled by nodes (called attachment nodes). edges (called attachment edges) connect component nodes with attachment nodes for all attachment areas that belong to a component. edge labels are used to distinguish different attachment areas. relationships between attachment areas are modeled by edges (called relationship edges) connecting the corresponding attachment nodes. relationship edges carry the kind of relationship as edge type. fig. 4 shows the graph model of the tree in fig. 2. attachment nodes are depicted by black dots, component nodes by rectangles. thin arrows show attachment edges, thick arrows relation7 / 13 volume 1 (2006) generating meta-model-based freehand editors 59diagen syntax definition with graphs, graph grammars and metamodels mark minas, universität der bundeswehr münchen abstract node circle nodeparam reduced circle border ⇓ 61diagen syntax definition with graphs, graph grammars and metamodels mark minas, universität der bundeswehr münchen at at from to child parent edgeparam reduced arrow ⇓ a b e f c d a b c d e f arrow figure 5: reducer rules for trees. ship edges. the only relationship type at indicates that the end point of the corresponding arrow is at the border of the connected circle. 3.4 instance graph the reducer is responsible for translating the graph model to the corresponding instance graph. the translation process has to be specified in the diameta designer in terms of triple graph grammar rules [sch94], called reducer rules here. the rules specify the simultaneous construction of the graph model as well as the instance graph. additionally, it builds up a third graph which contains the information on correspondence of nodes of the graph model to nodes of the instance graph. fig. 5 shows the two rules specifying the reducer for the diagram language of trees. reducer rules operate on triple graphs: the graph model, the correspondence graph, and the instance graph, from left to right. the left rule indicates that whenever a circle component node together with its attachment node and their attachment edge is added to the graph model, corresponding nodes are added to the instance graph. the added nodes represent an abstractnode instance for the attachment node of the tree node, and a circle instance for its component node. the latter models the set of those attributes of a tree node that do not belong to the abstract syntax (cf. section 3.2). the added edge represents the link as an instance of the association between classes abstractnode and circle in fig. 1. the right rule adds an arrow node representing the arrow attributes to the instance graph if an arrow component is added to the graph model. right-hand side nodes e and f are the abstractnode nodes that have been added by the other reducer rule already. moreover, two edges are added to the instance graph that correspond to the two associations of the child in fig. 1. 3.5 model checking finally, the instance graph is checked against the diagram language’s model, its class diagram, as described in [min06] and briefly outlined in section 2. by solving a constraint satisfaction problem, the model checker tries to identify a maximal subgraph of the instance graph that corresponds to the class diagram. this subgraph is used to instantiate the class diagram; the obtained proc. grabats 2006 8 / 13 eceasst 2diagen – emf & mof mark minas, universität der bundeswehr münchen generating diagram editors with emf-diagen editor developer diagram editor diameta editor framework diameta designer diameta designerdiameta generated program code editor specification generated program code emf compiler emf compiler operates emf model emf modeller emf modeller operates figure 6: generating diagram editors with diameta. structure of java objects is an abstract representation of the diagram that can be used when integrating the editor in a larger environment. the subgraph, moreover, corresponds to a subgraph of the graph model and, hence, a subset of diagram components that form a syntactically correct subdiagram. based on this information, feedback to the user is provided as described in section 3.1. 4 diameta environment this section completes the description of diameta and outlines its environment supporting specification and code generation of diagram editors that are tailored to specific diagram languages. the diameta environment shown in fig. 6 consists of an editor framework and the diameta designer. the framework is an extension of the diagen framework and, as a collection of java classes, provides the generic editor functionality which is necessary for editing and analyzing diagrams. in order to create an editor for a specific diagram language, the editor developer has to provide two specifications: first, the abstract syntax of the diagram language in terms of its model, and second, the visual appearance of diagram components, the concrete diagram language syntax, the reducer rules and the interaction specification. diameta uses the eclipse modelling framework emf [emf06] for specifying language models and generating their implementations. a language’s class diagram is specified as an emf model that the editor developer creates by using the emf modeller. several tools are available as emf modeller, e.g., the built-in emf model editor in the emf plugin for eclipse, or eclipseuml by omondo [ecl05]. the emf compiler, being part of the emf plugin for eclipse, is used to create java code that implements the model. fig. 1 shows the tree class diagram as an emf model. the emf compiler creates java classes (resp. interfaces) for the specified classes. the editor developer uses the diameta designer for specifying the concrete syntax and the visual appearance of diagram components, e.g., that tree nodes are drawn as circles with 9 / 13 volume 1 (2006) generating meta-model-based freehand editors 5diagen – emf & mof mark minas, universität der bundeswehr münchen generation process arrow circle model other classes.. arrow circle editor other classes.. eclass ecore other classes.. diameta designer emf compiler view & controlmodelm2 m1 figure 7: generated java classes from the specification. inscribed name and tree edges as arrows. the diameta designer generates java code from this specification. this code, together with java code created by the emf compiler and the editor framework, implement an editor for the specified diagram language. fig. 7 shows java classes and packages that are taken from the framework resp. that are generated by the emf compiler and the diameta designer for our example of tree diagrams. the emf compiler creates the package model5 that contains all classes corresponding to the language’s emf model. the diameta designer generates the package editor (or an other chosen name) together with the classes that are responsible for visualizing diagram components, interacting with them in the editor, and language specific classes for diagram analysis. note that two classes circle resp. arrow are created – one in package model and one in package editor each. together, they establish a model-view-controller pattern of the diagram components and the diagram: the classes in package model created by the emf compiler represent the model aspect whereas the classes in editor created by the diameta designer represent the view and controller aspects. the classes in package model implement the emf model and, hence, the abstract syntax of the specified diagram language. however, the emf compiler does not only generate these classes, but also code that sets up a reflective model representation at start-up time as shown in fig. 8. the reflective model representation represents the emf model using ecore, emf’s counterpart of the omg mof [obj06]. this ecore model allows to inspect the emf model, i.e., the abstract diagram at editor runtime. in terms of the meta-modelling hierarchy, the abstract syntax of a specific diagram is on the m0 level. its emf model, i.e., the class diagram, is on the m1 level. ecore is the model of all emf models and, hence, on the m2 level. these ecore classes of the m2 level are instantiated at start-up time such that these instances provide a runtime data structure representing the specified emf model. the model checker makes use of this runtime 5 the emf compiler actually creates several packages. to avoid cluttering of the figure, only a single package is shown here. proc. grabats 2006 10 / 13 eceasst 5diagen – emf & mof mark minas, universität der bundeswehr münchen generation process arrow circle model other classes.. arrow circle editor other classes.. eclass ecore other classes.. editing editor state editing csp solver abstract diagram (java object structure) uses model instances reflective model representation at start-up instance graph reducing uses figure 8: using the reflective model representation for checking the diagram’s syntax by constraint satisfaction. data structure in order to inspect the emf model and to find all possible concrete classes for each node of the instance graph and all possible associations for each edge in the instance graph. 5 conclusions the paper has described diameta, a tool for generating visual editors that support free-hand and – at the same time – structured editing. however, structured editing has not been considered in this paper. the new contribution of diameta and this paper consists of the combination of free-hand editing and a diagram language specification based on a meta-modelling approach. earlier to this paper, meta-model-based editors had been restricted to structured editing. the paper has described the architecture of visual editors generated by diameta, and diagram analysis that checks the correctness of freely drawn diagrams and translates them – if they are correct – into some object structure. however, there are still unsolved questions. the predecessor of diameta, diagen, that used a grammar-based syntax specification, could easily identify maximal subdiagrams that are syntactically correct; diameta with its model-based syntax specification and its syntax analysis based on a constraint satisfaction problem does not yet provide as satisfying results as diagen. moreover, diameta does not yet support additional constraints on the object structures. such constraints are required if the diagram language is not fully specified by a class diagram. it is planned to allow for constraint specification using omg’s ocl and to add an ocl interpreter to diameta. the current diameta implementation makes use of emf for modelling diagram languages and for providing an implementation. the language of emf models is specified by an emf model, too. an apparent application of diameta, hence, is generating an editor for emf models; only the specification by the diameta designer is yet missing. such an editor would 11 / 13 volume 1 (2006) generating meta-model-based freehand editors automatically create ecore instances when creating emf models. the emf compiler could be used without any further efforts for immediately generating code from such models. since emf is a rather restricted meta-modelling framework, current work investigates omg’s mof 2.0 as an alternative and the moflon plugin [ame04] for the fujaba tool [nz00]. using mof instead of emf has the further benefit that the visual languages of the uml are already specified by a mof model. hence, generating editors for those languages will become easier. essentially, only the concrete syntax and the reducer rules have to be specified. bibliography [ame04] c. amelunxen. a mof 2.0 editor as plugin for fujaba. in giese et al. (eds.), proc. 2nd international fujaba days. volume tr-ri-04-253, pp. 43–48. 2004. [cdp05] g. costagliola, v. deufemia, g. polese. towards syntax-aware editors for visual languages. electronic notes in theoretical computer science 127(4):107–125, apr. 2005. proc. workshop on visual languages and formal methods (vlfm 2004). [cm95] s. s. chok, k. marriott. automatic construction of user interfaces from constraint multiset grammars. in proc. 1995 ieee symp. on visual languages, darmstadt, germany. pp. 242–249. ieee computer society press, sept. 1995. [ecl05] eclipseuml on the omondo web site. http://www.omondo.com/, 2005. [emf06] emf, eclipse modeling framework web page. http://www.eclipse.org/emf/, 2006. [lva04] j. de lara, h. vangheluwe, m. alfonseca. meta-modelling and graph grammars for multi-paradigm modelling in atom3. software and systems modelling 3(3):194–209, aug. 2004. [met05] metaedit+ documentation on the metacase web site. http://www.metacase.com/, 2005. [min02] m. minas. concepts and realization of a diagram editor generator based on hypergraph transformation. science of computer programming 44(2):157–180, 2002. [min04] m. minas. visualdiagen – a tool for visually specifying and generating visual editors. in pfaltz et al. (eds.), applications of graph transformation with industrial relevance, proc. 2nd intl. workshop agtive’03, charlottesville, usa, 2003, revised and invited papers. lecture notes in computer science 3062, pp. 398–412. springerverlag, 2004. [min06] m. minas. syntax analysis for diagram editors: a constraint satisfaction problem. in celentano and mussio (eds.), proc. of the working conference on advanced visual interfaces (avi’2006), may 23-26, 2006, venice, italy. pp. 167–170. acm press, 2006. proc. grabats 2006 12 / 13 eceasst [nz00] j. niere, a. zündorf. using fujaba for the development of production control systems. in nagl and schürr (eds.), int. workshop on applications of graph transformations with industrial relevance (agtive’99), selected papers. lecture notes in computer science 1779, pp. 181–191. springer, mar. 2000. [obj06] object management group. meta object facility (mof) core specification. version 2.0 edition, jan. 2006. document formal/06-01-01. [sch94] a. schürr. specification of graph translators with triple graph grammars. in tinhofer (ed.), 20th int. workshop on graph-theoretic concepts in computer science. lecture notes in computer science 903, pp. 151–163. springer verlag, heidelberg, 1994. [zgh04] n. zhu, j. grundy, j. hosking. pounamu: a meta-tool for multi-view visual language environment construction. in proc. 2004 ieee symposium on visual languages human centric computing (vl/hcc’04). pp. 254–256. 2004. 13 / 13 volume 1 (2006) introduction syntax specification and analysis based on class diagrams diameta editors diameta editor architecture diagram components graph model instance graph model checking diameta environment conclusions generating optimal decision functions from rule specifications electronic communications of the easst volume 74 (2017) 7th international symposium on leveraging applications of formal methods, verification and validation doctoral symposium, 2016 generating optimal decision functions from rule specifications frederik gossen tiziana margaria 16 pages guest editors: anna-lena lamprecht eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst generating optimal decision functions from rule specifications frederik gossen tiziana margaria csis and lero the irish software research centre, university of limerick {frederik.gossen, tiziana.margaria}@lero.ie abstract: in this paper we sketch an approach and a tool for rapid evaluation of large systems of weighted decision rules. the tool re-implements the patented miaamics approach, originally devised as a fast technique for multicriterial decision support. the weighted rules are used to express performance critical decision functions. miaamics optimizes the function and generates its efficient implementation fully automatically. being declarative, the rules allow experts to define rich sets of complex functions without being familiar with any general purpose programming language. the approach also lends itself to optimize existing decision functions that can be expressed in the form of these rules. the proposed approach first transforms the system of rules into an intermediate representation of algebraic decision diagrams. from this data structure, we generate code in a variety of commonly used target programming languages. we illustrate the principle and tools on a small, easily comprehensible example and present results from experiments with large systems of randomly generated rules. the proposed representation is significantly faster to evaluate and often of smaller size than the original representation. possible miaamics applications to machine learning concern reducing ensembles of classifiers and allowing for a much faster evaluation of these classification functions. it can also naturally be applied to large scale recommender systems where performance is key. keywords: optimal decision functions, rapid decision making, system of rules, algebraic decision diagram, machine learning, miaamics 1 introduction as known from computational science, highly frequently invoked functions crucially impact the overall performance of a program. optimizing such functions is thus particularly likely to pay off. examples from literature concern for instance loop and nested loop optimizations: they motivated researchers to find ways of expressing the computations in a way that allows for automatic optimization and code generation. in many cases these functions take as an input a description of a situation or a case in case-based reasoning, and return a decision in form of an enumerable value. we call this class of functions decision functions. to represent decision functions, we focus on a rule-based representation where each rule evaluates a situation and assigns a weight to one or more target elements from a set of possible 1 / 16 volume 74 (2017) generating optimal decision functions from rule specifications results. the target elements with the highest cumulative weight1 are returned as result of the evaluation. we call a potentially large collection of these rules a system of rules, described in detail and formally defined in section 3. miaamics. our approach bases on the award winning approach developed from 2000 to 2001 by metaframe technologies gmbh, meanwhile patented [hsm13], and on the ideas of the first miaamics implementation, used also to solve the semantic web service challenge problems [kub05, kms+09]. the core idea was to represent rules as algebraic decision diagrams (adds) so that the decision structures can be efficiently precomputed, and evaluate extremely quickly at run time. the ideal application would foresee relatively stable rule sets and many time-critical evaluations for different cases, so that the computation effort needed to be spent only once, and the evaluations would be instantaneous. indeed, one of the first application domains was personalisation of advertisement and offers in online shops [smb01, smb00]. in contrast to the implementation we present in this paper, the original idea was to return a description of target elements, not the elements themselves. in the context of personalization, it would return the pointer to the advertisement, or to the offer page. the use of descriptors/pointers allowed keeping the decision structure in main memory, with full evaluation independent of any database or network access, and to dynamically add elements at runtime, but it imposes one step of indirection. simplicity. this rule-based approach is a good example for the simplicity principle proposed in [ms10]. decisions functions are not fully general, but they elegantly capture the bulk of decision problems in a fashion amenable to powerful optimization techniques that are strong enough to enable rapid decision making. rules and systems of rules are also much simpler to state and manage than the complex decision structure that they collectively describe. in our previous experience, marketing and campaign managers with no ability to program nor familiarity with databases or query languages were perfectly able to master the rule formats and the rule collections. classifiers. classifiers in machine learning are one domain where rapid evaluation of a decision function is crucial and the proposed rule-based representation is applicable. classifiers are learned from example data only once, but the learned function is often invoked highly frequently. this can be costly when the evaluation of a learned model or a function is expensive. past research on rule extraction from such classifiers [iqb12, jac05] was partly motivated to get a better understanding of the classification method, but rule extraction can also yield a different representation to evaluate the classifier. these rules are in fact very similar to the system of rules in the miaamics approach. the rule-based representation is therefore well applicable to this class of decision functions. dsl. the system of rules can also be seen as a domain-specific (description) language giving experts the opportunity to state decision functions in a simple way, that does not require them 1 the cumulative weight is defined as the algebraic sum of the weights of all applicable rules. isola ds 2016 2 / 16 eceasst to be familiar with any general purpose programming language. at the same time an efficient implementation is guaranteed by the miaamics approach. domain experts can focus on the decision function, and not have to worry about efficiency at all. this approach is beneficial even for domain experts familiar with a general-purpose programming language: they can define decision functions once, and generate the corresponding implementation fully automatically in a variety of different target languages. the central question is how to transform a potentially large systems of rules to an efficient representation and implementation, that ideally saves both memory and evaluation time compared to the original representation of the system of rules. in section 2 we present the data structures used in miaamics, itself presented in detail in section 3. in section 4 we show how to easily generate and compile code in a variety of different programming languages from the decision data structure, so that it can be included in any application directly. we present the results to date in section 5 including an evaluation of the miaamics approach for a large system of random rules. section 7 gives an outlook of our plans to apply miaamics to real world tasks. 2 algebraic decision diagrams in our approach, we use ordered binary decision diagrams (bdds) [bry86, ake78, bm02] to compactly represent boolean expressions. for a given ordering of their predicates they are a canonical representation of the boolean function and can be minimized efficiently. all logical operations can be performed directly on the data structure. as generalization of obdds, algebraic decision diagrams (adds) [fmy97, bfg+93] are used to represent rules as well as the whole system of rules in miaamics. this is the central data structure we use in miaamics, and we briefly introduce it here. for more detailed information on algebraic decision diagrams (adds) we refer the reader to [bfg+93]. adds generalize bdds in that they are associated with an arbitrary algebraic structure rather than the standard boolean algebra. formally, an algebraic structure is a carrier set s that is associated with a set of operations o ⊂ (s ×s → s ). while bdds represent functions of the form bn → b, adds represent functions of the from bn → s . all the algebraic structure’s operations on the carrier set s can be lifted to the data structure. adds are directed acyclic graphs (v ∪t ,e ) with a distinguished root node φ ∈ v . inner nodes v ∈ v are associated with a boolean predicate x(v). all inner nodes v have exactly two outgoing edges that determine the then respectively the else successor of the node. terminal nodes t ∈ t have no outgoing edges and hold a result value s(t) ∈ s from the algebraic structure’s carrier set. the predicates of an add’s inner nodes are ordered and the sequence of predicates on every path starting with the root node φ must conform to this order. figure 1a shows an example of an add with an associated algebraic structure over real numbers. to determine the result of the function represented by an add for a given assignment of the boolean predicates one starts with the root node φ and traces down to a terminal node along the valuation of the ordered predicates: for every inner node v ∈v the corresponding predicate x(v) is considered. if it x(v) = 1 the trace continues with the then successor otherwise it continues with the else successor. the reached terminal node t ∈ t holds the result of the function s(t). 3 / 16 volume 74 (2017) generating optimal decision functions from rule specifications due to the predicate order enforced by the data structure, every evaluation trace is no longer than the total number of boolean predicates. the order of predicates allows for efficient operations on adds, similarly to how operations are performed on bdds. all operations from the algebraic structure can be lifted to the level of adds, ensuring a canonical and redundancy-free representation [bry86, bm02]. as this algebraic structure may be defined over a carrier set s of arbitrary size, in contrast to bdds adds are not limited to two terminals. in miaamics we use real values to express rule weights, a ⊥-value to indicate irrelevant paths, and strings to identify target elements. 3 the miaamics approach to rapidly evaluate decision functions represented by potentially large systems of rules, in miaamics the initial full representation of the system of rules is partially evaluated and the result is represented as an add. this data structure lends itself to be easily transformed to (efficient) code in a variety of different target programming languages, so that the final decision structure is seamlessly integrated in any program. 3.1 a small comprehensible example to explain how the miaamics approach works we will consider a comprehensible decision function: a small recommender system to decide what wine to serve with a dish. in this example, the function’s argument describes the situation: the served dish. we will base the decision on whether or not the dish contains cheese, meat and fish. the decision outcome is the recommendation which wine to serve out of a selection of available wines. for simplicity wines are characterized by three attributes: red, white and sweet. there are many rules for a good choice of wine, but some of them are more important than others. in this example we give high priority to serve white wine with every meal that contains cheese or fish. 3.2 system of rules a decision function can be specified in many different ways. a natural language formulation is often expressed as indications, i.e. a collection of rules. we focus on rules with premises, a conclusion and a weight that select one or more elements from a finite set of possible choices called target elements. the premises: each rule applies in certain situations only. situations are characterized by properties expressed as boolean predicates that we call condition predicates. the premises boolean expression over these condition predicates defines in which situations the rule applies and in which it does not. as the premises of different rules may overlap, multiple rules may apply in a given situation. the conclusion selects one or more elements from the finite set of target elements as the rule evaluation outcome. just like situations, target elements are characterized by boolean properties that we call target predicates. the conclusion of a rule is a boolean expression over these predicates that selects a subset of the target elements. the conclusion can be seen as the rule’s contribution to the overall decision. isola ds 2016 4 / 16 eceasst the weight of a rule indicates its importance or priority. when a rule triggers, it assigns this weight to all target elements in its conclusion. the higher a rule’s weight, the stronger its selected target elements will be recommended towards the final decision. in our wine selection example, the situations considered by the rules concern different categories of dishes, characterized by the ingredients cheese, meat and fish. these are our three (boolean) condition predicates. each rule will recommend as conclusions one or more appropriate wines, our target elements. they are characterized as red, white and sweet, our three (boolean) target predicates. the weight of a rule indicates its relevance, usually as a relative indicator to the other rules. we will include in our example a highly relevant rule that recommends white wines for cheese or fish dishes. the full recommender system contains a potentially large collection of such rules, that we call a system of rules r. to determine the overall decision for a given situation, all rules of r are evaluated separately. for every rule applicable in the given situation its weight is assigned to the foreseen target elements. all weights assigned to a target element are algebraically added, yielding the accumulated weight for each target element. the final outcome of a system of rules is the set of all highest weighted target elements. while applying each rule separately is simple and intuitive, in practice it is not very efficient. we will see how the miaamics approach allows for a significantly faster evaluation of large systems of rules using an efficient decision structure. we define the system of rules r formally, along the input language of the miaamics tool. the set of all target elements e is defined as a set of unique target elements of the form ei := namei,ti with namei ∈ [a−z]+ and ti ⊆ t where t is the set of all target predicates. target elements ei must be unique with regard to both name namei and characterization ti. note that not all the potential 2|t | have to exist. the actual system of rules r is a potentially large set of rules ranging over the set of target elements. rules have the form r j := if c add w to t with c j ∈ be(c ), t j ∈ be(t ), and w j ∈r where be(c ) are boolean expressions over the condition predicates c and be(t ) are boolean expressions over the target predicates t . the rule condition c j defines the situations in which a rule is applicable, and the rule target t j defines the set of target elements that are assigned the weight w j if the rule applies. given a target element ei, its characterization ti defines the assignment of target predicates corresponding to its selection (in original miaamics language, the target profile). as we use adds, we admit positive and negative weights, expressing indicators in favour or against a certain recommendation. thus there can be partial or total compensation provening from different rules expressing a variety of recommendation aspects for a given situation profile. in particular, any rule can be neutralized by an identical rule with the negated weight, that cancels its effect and makes it disappear from the decision structure. naive evaluation of a system of rules for any given situation by evaluating each rule separately at runtime is simple, and still the standard of many current personalization approaches, but inefficient. miaamics instead reduces such potentially large systems of rules to a decision structure that saves both memory and runtime. 5 / 16 volume 74 (2017) generating optimal decision functions from rule specifications cheese meat meat whitewhite fishfish white red white 0 red red sweet red 1 sweet 231.5 (a) rule add ar cheese meat meat whitewhite fishfish whitewhitewhitewhite red redred redred sweet ⊥ sweet sweet 1 01.5 (b) rule add over existing target elements are figure 1: miaamics rule adds indicating accumulated rule weights. 3.3 building the decision data structure given as inputs a system of rules r and the set of target elements e , the miaamics tool derives the add that for any given situation described in r returns all the corresponding highest weighted target elements. this add is an efficient global data structure: its evaluation requires at most one test per condition predicate, which is significantly faster than the naive individual rule evaluation already for quite small sets of rules. to compute the global decision structure for the entire system of rules r, in miaamics we initially build an individual add for each rule. given a rule (c,w,t)∈r the represented function returns the weight w if both the rule’s condition c and its target t are satisfied and 0 otherwise. the rule add therefore considers all the condition and target predicates c ∪t . once we have the individual adds, we can compute the total weight assigned to a target element by summing all these adds with the standard add sum operation to a resulting rule add ar, as in figure 1a. as the sum of adds can be computed incrementally, there is no need to keep more than two adds in memory at the same time: the current sum add and the add of the next rule to be added. figure 1a visualizes the obtained structure for the following small example system of rules r :={ if (cheese∨ f ish) add 1.0 to white , if meat add 1.0 to red if cheese add 0.5 to (sweet ∧white) , if (meat ∧cheese) add 0.5 to (sweet ∧red) }. this system of rules recommends categories of wines based on their properties, i.e. wine profiles, without knowing what actual wines are available: using a good taxonomy of predicates as target predicates we can express pretty detailed domain knowledge independently of the concrete instances (here the wine sorts) at hand. we will in fact use the distinction between recommendations in principle and feasible recommendations to optimize the decision structure. in our case, isola ds 2016 6 / 16 eceasst the first rule expresses the recommendation to serve white wine with every dish that contains cheese or fish. the last rule will turn out to be redundant because there will be no sweet red wine in out set of target elements e : this recommendation is not feasible with the wine cellar at hand. feasibility of recommendation is linked to usefulness: when transforming the rule add ar to return only the highest weighted target elements it is important to ensure that these elements actually exist. as rules express general knowledge, they can target non-existing or non available elements. we express the set of available target elements by means of a binary decision diagram be over target predicates t , which is simply the disjunction of all existing target elements e . to restrict the target consideration to existing elements when selecting the highest weight, we transform the generic rule add ar to suppress non-existing elements. this filtered rule add are is obtained with a binary operation on the two adds ar and be that evaluates to a reserved value ⊥ if the element does not exist and to the accumulated rule weight otherwise. formally the operation can be defined as f : r×b→r∪{⊥} defined as f (w,bexists) = { w if bexists ⊥ otherwise. given a situation, are returns the sum of weights for existing target elements as before and ⊥ for non-existing ones. figure 1b visualizes the result for the wine selection example with the following target elements e :={ (sauvignon blanc,{ white }), (riesling,{ sweet,white }), (merlot,{ red }) }. the redundant last rule from the example disappears in the are add because none of the available wines e is both sweet and red. all paths where the target predicates sweet and red evaluate to true lead to the ⊥-terminal. to find the highest weights for every situation, we consider the maximum over the target predicates. the maximum weight still depends on the situation. it is therefore a function from condition predicates to r∪{⊥} and can consequently be represented as an add amaxre . we are actually interested in the top recommendations, i.e., the concrete target elements associated with the maximum accumulated weight, so we compose are with the elements, replacing the accumulated weights w ∈ r∪{⊥} in are’s terminals with a reference to the actual element ei ∈ e described by the target predicates along that path if are = amaxre . where are 6= amaxre we replace the terminal with the ⊥-value to indicate the irrelevance of the element described along this path in the associated situation. figure 2a visualizes the resulting add a f , representing all elements with the highest accumulated weight per situation. for any assignment of condition and target predicates, a f returns the corresponding top-weighted target element ei if it exists, or ⊥ otherwise. the final add a f ′ should return the best recommendations for each situation, i.e. only evaluate the situation, testing the condition predicates, and return for each situation the set of top weighted elements. we thus replace the target predicates from the add with terminal nodes that hold the set of target elements. we reorder the add predicates so that condition predicates 7 / 16 volume 74 (2017) generating optimal decision functions from rule specifications cheese meat white fishfish white whitewhite red ⊥ red red sweetsweet sweet rieslingsauvignon_blanc merlot (a) rule add over highest weighted target elements a f cheese meat { riesling } fishfish { merlot, riesling, sauvignon_blanc } { merlot }{ riesling, sauvignon_blanc } (b) final add a f ′ testing only condition predicates figure 2: miaamics adds indicating best target elements. precede the target predicates, and replace the sub-add that operates only on target predicates with the set of target elements it represents. in the final data structure visualized in figure 2b, the terminal nodes hold the sets with appropriate wine recommendations. the rule recommending white wine with cheese or fish dishes influences the final decision structure with a comparably high weight of 1.0. for every dish that contains fish or cheese the decision structure thus recommends riesling or sauvignon blanc in our example. only in case of dishes that contain both fish and meat the requirement appears to be violated. this is due to the second rule of the system that recommends red wine with all dishes that contain meat. every condition predicate in the final decision structure a f ′ is evaluated at most once. for sufficiently large systems of rules this data structure therefore allows for a significantly faster evaluation than by individual rule evaluation. the worst case size of the decision diagrams is exponential in the number of predicates, but it is unaffected by the number of rules. this is an essential property: miaamicss most advantageous with large systems of rules ranging over a comparably small number of predicates. 4 code generation the final add a f ′ is optimal in size2, very efficient to evaluate, and easy to use for direct interpretation at runtime. a given situation is an assignment of condition predicates, so one can easily trace in the miaamics tool the path from the add root to the terminal node containing the top recommendation set. however, it is desirable to use the decision structure independently of the miaamics tool, as code embeddable in any user program. to this aim miaamics provides a variety of ways to export its data structure so that it can be easily analysed, interpreted, and compiled to native code. 2 for a fixed predicate ordering. isola ds 2016 8 / 16 eceasst the data structure can be exported to *.dot format, the input format for graphviz’s dot tool [gn00]. this allows easy visualization of the decision structures, e.g. to generate figures for this paper (cf. fig. 1 and fig. 2), and also to reason about the decision structure and to understand it. the add can also be exported in a simple textual format, so that external applications can parse the decision structure and use it in the same way miaamics does internally. this way, an application may analyse the data structure automatically, or work as an interpreter that evaluates the decision structure for a given situation. while parsing and interpreting the decision structure is faster than evaluating the rule system in the naive fashion, it is still one step of indirection in comparison with a direct integration as source code in the user program. to embed the decision structure directly in code, miaamics provides code generators for a wide range of popular target programming languages including c, c++, java, c#, python and javascript. these code generators take the decision structure and generate the code of the corresponding function. the function takes as input a situation in form of an assignment of condition predicates and returns the set of target elements with the highest accumulated weight for that given situation. the characteristics of the target programming language determine how directly the code can be generated from the add decision structure. it is important to maintain the properties of adds also in the generated target code, meaning that the length of traces through the decision structure should not increase and the size of the representation should not increase by more than a factor. we look at the add’s graph structure and generate code in the target programming language node by node. it is quite obvious how to test condition predicates and how to return the result from the generated function, but the challenge is to efficiently implement transitions between nodes, and this depends on the target programming language’s control flow features. there are two categories of target programming languages for which code generation is very similar: • languages comprising goto-statements: this control flow feature allows to jump through the code, allowing a direct implementation of add node transitions. in this category of target programming languages miaamics today supports c, c++, and c#. • languages without goto-support: transitions can be generated as function invocations with one function per node or the decision data structure can be resembled in memory. in this category miaamics supports java, javascript, and python today. 4.1 transitions as goto-statements using goto-statements, transition from one line in the code to any other can be efficiently implemented. this allows to generate the code per node in an arbitrary order and jump between the different nodes. this is fast and indeed allows to generate every node only once also preserving the length of traces through the decision structure. goto-statements are generally regarded as highly unreadable [dij68], and this is why many programming languages do not support them at all. however, for generated code that aims at performance, readability is no priority, so this efficiency is welcome. the level on which to read and analyse the decision structure is either as the system of rules from which it was generated or a graphical representation of the decision structure, never the generated code. 9 / 16 volume 74 (2017) generating optimal decision functions from rule specifications 4.2 simulating goto-statements if goto-statements are not natively supported by the target programming language, the same behaviour has to be simulated. one can trace through the code node by node using auxiliary functions. for every node exactly one function is generated: in case of a constant node this function simply returns the associated value, in case of an internal nodes its predicate is evaluated to delegate the remaining evaluation to one of its successor nodes respectively functions in the generated code. as exactly one function is generated per node again the size of the decision structure does not increase by more than a factor also preserving the length of all traces. alternatively, the generated code can resemble the decision structure in memory on initialization to then use the structure like an interpreter. in this case code generation allows to skip the parser step in the target application. 5 results 5.1 implementation in c++ while the idea of miaamics has its roots in 2000 [hsm13, kms+09, kub05], and it was provided as a stand-alone and integrated implementation, we reimplemented it now in c++ as a command line tool that in particular supports code generation for native embedding a variety of target languages, and visualization of the data structures. the new miaamics tool was implemented from scratch in c++ using the cudd library [som15] for binary decision diagrams and algebraic decision diagrams. the tool reads the rules and the set of target elements in its own input format and generates on demand the corresponding internal individual adds. from these individual representations it generates the global add decision structure, ready to be exported in a variety of different formats for visualization and for use in other applications. the code generators additionally allow to generate the decision structure as functions in a variety of different programming languages, so that the obtained decision structure can be compiled together with the using application, in which it seamlessly integrates. the current version of miaamics supports c, c++, c#, java, javascript and python as target programming languages. all these generators preserve the decision structure’s properties in the code: the same length of traces through the decision structure, and the size of the representation in code is not greater than the decision structure by more than a factor. 5.2 evaluation with a random system of rules we evaluated the new tool with regard to memory consumption and running time of the generated decision structure. we decided to use a large set of randomly generated rules in order to avoid the clustering typical to real life systems, where a number of rules typically refer to the same situation or target properties, thus easily inducing optimizations and sharing in the adds. in particular, using increasing systems of randomly generated rules allowed us to study the effect of hundreds of thousands of rules that one would hardly write manually. this can however easily be the result of a preceding generation process and thus be a useful intermediate representation. scalability with the number of rules is the typical weakness of rule-based approaches that isola ds 2016 10 / 16 eceasst 0 100 200 300 400 500 number of rules 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 a d d s iz e rule add final decision structure (a) growth of the rule add and the final decision structure with an increasing number of randomly generated rules. the horizontal lines mark upper bounds for the add size. 0 100 200 300 400 500 number of rules 0 1 2 3 4 5 6 n u m b e r o f d e c is io n s maximum average minimum (b) minimal, maximal and average number of predicates to be evaluated among a path in the final decision structure. figure 3: evaluation with a system of 500 random rules. evaluate at runtime. we thus looked at the behaviour of the miaamics approach for very large rule systems. to profile the decision structure for a large system of rules, we thus generated many random rules over a given set of condition and target predicates, and measured properties of the decision structure with an increasing number of rules. we experimented with 5 condition predicates and 5 target predicates, and considered all the 25 = 32 possible target elements. the rules were generated so that each of them applies to exactly one of the 32 target elements, chosen uniformly at random. the weight w of the rule was chosen uniformly at random in w ∈ [0,1]. choosing a different bounds would change all weights only by a factor and an offset, but it would not make a difference when selecting the maximum among the weights. rule conditions were generated as a random boolean expression as follows. we generate a syntax tree with 5 levels of boolean operations. conjunction, disjunction and negation are chosen equally likely on each level. for the leaf nodes one of the 5 condition predicates are chosen uniformly at random. in this way, we generate random boolean expressions for conditions that are reasonably complex yet likely to be satisfiable. keeping these parameters constant allows us to observe the behaviour of the miaamics decision structure for a growing system of random rules. for the experiment, we add one random rule after the other and record the size of the rule add ar and of the final decision structure a f ′. we also record the minimal, maximal, and average number of predicates tested in the final decision structure over all possible assignments of condition predicates. in a first experiment, we observe the behaviour for a comparably small system of up to 500 random rules. the result is visualized in figure 3. although the rule add grows faster for the first 100 rules than it does for the last 200 rules, it does grow until the 500th rule was added. interestingly, the size of the final decision structure does not remotely show a monotonic growth: its size drops several times almost in half. also the number of predicate tests in the final decision structure is not monotone. in fact additional rules can reduce both the minimal number and the 11 / 16 volume 74 (2017) generating optimal decision functions from rule specifications 0 50000 100000 150000 200000 250000 number of rules 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 a d d s iz e rule add final decision structure (a) growth of the rule add and the final decision structure with an increasing number of randomly generated rules. the horizontal lines mark upper bounds for the add size. 0 50000 100000 150000 200000 250000 number of rules 0 1 2 3 4 5 6 n u m b e r o f d e c is io n s maximum average minimum (b) minimal, maximal and average number of predicates to be evaluated among a path in the final decision structure. figure 4: evaluation with a system of 235,400 random rules. average number of tests. note that even the maximum number of test 5 is still a rapid evaluation compared to evaluating each rule separately. in our second experiment we generated 235,400 random rules in the same way as in the previous experiment. we recorded the same properties, but we computed them only every 100 rules. the result is visualized in figure 4. the previous observations also hold for this significantly larger system of rules. between the 200,000 and 250,000 rules the final decision structure appears to shrink while the rule add keeps growing. we suspect that this effect is some form of convergence related to the law of large numbers. 6 related work the miaamics approach can naturally be applied to recommender systems where the system of rules would state a strategy according to which a user is recommended products or items in a given situation. these rules can either be defined by experts or they can be derived from potentially machine learned models. ”in recent years, the interest in recommender systems has dramatically increased” [rrs11] with the most prominent examples in online shops [lsy03,sl17] and video streaming platforms [gh15, dll+10]. while these systems recommend different things the underlying algorithms are similar and the systems suffer similar problems. even in the context of smart cities ”recommendation techniques become essential tools assisting consumers in seeking the best available services” [zgn+17]. the most successful and most widely used technique is collaborative filtering (cf) [zgn+17] where a user is recommended items that ”similar” users have liked before. the algorithm typically involves processing the entire user-item matrix. it is in most cases computationally expensive [lsy03], and that’s why most implementations traditionally resorted to just a few rules/data isola ds 2016 12 / 16 eceasst points to define similarity, or abstract profiles, that undermined the specificity of the resulting recommendation. many variants are emerging that take into account not only the user-item matrix but also additional information sources to improve the overall recommendation performance [slh14]. an alternative category of algorithms are cluster models where customers are clustered into ”similar” groups to find similar customers more efficiently. the much smaller set of items in that cluster then serves as a basis for recommendations [lsy03]. a third class are search-based recommendation methods that search for similar items. these methods scale and perform well only for small sets of previously purchased items [lsy03]. recommendation algorithms like collaborative filtering (cf) and search-based methods that yield good recommendation performance lack the ability to scale to large user groups and extensive product ranges [lsy03, sl17]. clustering methods on the other hand yield low recommendation performance [lsy03]. hence there is the need for other methods just like miaamics key to the methods scalability is that expensive computations are performed offline before the system is used. currently, the most widespread across the web is amazon’s item-based collaborative filtering [sl17]. as both users and items can be described declaratively by means of predicates, we traditionally used the miaamics approach to pre-compute the decision strategies entailed by traditional collaborative filtering and search-based methods. given a user-item matrix it is also possible to derive a corresponding system of rules and consequently an efficient implementation of the corresponding recommendation strategy. the rules used in miaamics are relatively simple and understandable and serve as a high-level declarative syntax. in that sense they are similar to event condition action rules [dgg95, alt07], used to define application behaviour by means of rules rather than general purpose programming languages. in eca rules the action is always the selection of target elements or items. the high-level definition of eca allows for analysis and optimisation techniques [ppw06]. 7 conclusion the new implementation of the miaamics approach is particularly tailored for rapid evaluation of large systems of rules in ”recommender-style” systems, stand-alone or embedded as native code in applications. we defined formally the rule format, including the description and handling of the target elements it reasons about. we explained in detail the construction of the efficient miaamics internal decision structure, with all its intermediate representations and efficiencyoriented optimizations. we showed how to generate easily property-preserving native code in a variety of different target programming languages from this optimized data structure. in this way we ensure that also the generated code is optimally efficient, in the sense that it has the same computational complexity as evaluating the data structure but it can be included in applications and compiled easily. in a preliminary evaluation with a large system of random rules, we show that the miaamics decision data structure remains small and ensures short traces during evaluation even for large systems of rules with more than 200k rules. in fact, the runtime efficiency depends on the depth of the decision structure, which is determined by the number of predicates (properties) 13 / 16 volume 74 (2017) generating optimal decision functions from rule specifications characterizing the situation and the target elements, and not by the number of the rules. thus the strength of the miaamics approach lies in the very compact and efficient representation of the knowledge underlying both domains and its independence of the specific relations between all these elements. this makes it particularly promising for applications where rapid decision making is important. a promising field of application is in machine learning, where classifiers are trained with example data. these learned functions take as an input a description of a situation or a case and predict one of several classes as a result. while training these classifiers is performed only once, they are evaluated frequently. some classifiers are expensive to evaluate and thus an approach to evaluate them faster can be crucial. for binary descriptions of situations and cases, the miaamics approach is well applicable if the classifier can be expressed by means of the proposed form of rules. in fact, rule extraction from such classifiers has been a topic in research [iqb12, jac05] although not necessarily to evaluate them faster but to understand them better. of particular interest to us are decision trees, random forests, decision jungles [ssk+13] because they can be easily translated to the proposed form of rules. we also aim to test our approach with more complicated classifiers. the target criteria will again be the running time needed for evaluation, and the memory consumption of the miaamics data structure in comparison with the original representation of the system of rules as well as the original classifier. a limitation of the miaamics approach to date is that it operates on binary descriptions of situations while it is often the case that other descriptions are more appropriate. input arguments to classifiers are often real valued. for this reason, we aim to extend the miaamics approach to support real valued situation descriptions in the future, where the boolean predicates within the decision structure will express comparisons with constants, similarly to how constraints that had been introduced previously to solve the semantic web services challenge [kms+09]. we expect the specific strength of miaamics to make a significant difference for the applicability to real life problems of those classifiers. acknowledgements: this work was supported, in part, by science foundation ireland grant 13/rc/2094 and co-funded under the european regional development fund through the southern & eastern regional operational programme to lero the irish software research centre (www.lero.ie). bibliography [ake78] s. b. akers. binary decision diagrams. ieee transactions computers 27(6):509– 516, 1978. [alt07] e. e. almeida, j. e. luntz, d. m. tilbury. event-condition-action systems for reconfigurable logic control. ieee t. automation science and engineering 4(2):167– 181, 2007. [bfg+93] r. i. bahar, e. a. frohm, c. m. gaona, g. d. hachtel, e. macii, a. pardo, f. somenzi. algebraic decision diagrams and their applications. in proceedings of isola ds 2016 14 / 16 eceasst the 1993 ieee/acm international conference on computer-aided design. pp. 188– 191. ieee computer society press, 1993. [bm02] r. e. bryant, c. meinel. ordered binary decision diagrams. pp. 285–307. springer us, 2002. [bry86] r. e. bryant. graph-based algorithms for boolean function manipulation. ieee transactions computers 35(8):677–691, 1986. [dgg95] k. r. dittrich, s. gatziu, a. geppert. the active database management system manifesto: a rulebase of adbms features. in proc. of 2nd int. workshop on rules in database systems (rids ’95). lncs 985, pp. 1–17. springer berlin heidelberg, 1995. [dij68] e. w. dijkstra. letters to the editor: go to statement considered harmful. commun. acm 11(3):147–148, mar. 1968. [dll+10] j. davidson, b. liebald, j. liu, p. nandy, t. van vleet, u. gargi, s. gupta, y. he, m. lambert, b. livingston, d. sampath. the youtube video recommendation system. in proceedings of the fourth acm conference on recommender systems. recsys ’10, pp. 293–296. acm, new york, ny, usa, 2010. [fmy97] m. fujita, p. mcgeer, j.-y. yang. multi-terminal binary decision diagrams: an efficient data structure for matrix representation. formal methods in system design 10(2):149–169, 1997. [gh15] c. a. gomez-uribe, n. hunt. the netflix recommender system: algorithms, business value, and innovation. acm trans. manage. inf. syst. 6(4):13:1–13:19, 2015. [gn00] e. r. gansner, s. c. north. an open graph visualization system and its applications to software engineering. software practice and experience 30(11):1203–1233, 2000. [hsm13] h. hungar, b. steffen, t. margaria-steffen. device for generating selection structures, for making selections according to selection structures and for creating selection. united states patent application publication, 2013. appl. no.: 13/650,680. [iqb12] m. r. a. iqbal. rule extraction from ensemble methods using aggregated decision trees. in neural information processing: 19th international conference. pp. 599–607. springer berlin heidelberg, 2012. [jac05] h. jacobsson. rule extraction from recurrent neural networks: a taxonomy and review. neural computation 17(6):1223–1263, 2005. [kms+09] c. kubczak, t. margaria, b. steffen, c. winkler, h. hungar. an approach to discovery with miaamics and jabc. pp. 217–234. springer us, boston, ma, 2009. [kub05] c. kubczak. entwicklung einer verteilten umgebung zur personalisierung von webapplikationen. master’s thesis, tu dortmund university, 2005. 15 / 16 volume 74 (2017) generating optimal decision functions from rule specifications [lsy03] g. linden, b. smith, j. york. amazon.com recommendations: item-to-item collaborative filtering. ieee internet computing 7(1):76–80, 2003. [ms10] t. margaria, b. steffen. simplicity as a driver for agile innovation. computer 43(6):90–92, 2010. [ppw06] a. poulovassilis, g. papamarkos, p. t. wood. event-condition-action rule languages for the semantic web. in grust et al. (eds.), current trends in database technology – edbt 2006. pp. 855–864. springer berlin heidelberg, berlin, heidelberg, 2006. [rrs11] f. ricci, l. rokach, b. shapira. introduction to recommender systems handbook. in ricci et al. (eds.), recommender systems handbook. pp. 1–35. springer, 2011. [sl17] b. smith, g. linden. two decades of recommender systems at amazon.com. ieee internet computing 21(3):12–18, 2017. [slh14] y. shi, m. larson, a. hanjalic. collaborative filtering beyond the user-item matrix: a survey of the state of the art and future challenges. acm comput. surv. 47(1):3:1–3:45, may 2014. [smb00] b. steffen, t. margaria, v. braun. personalized electronic commerce services. in ifip wg 7.3 8th int. conference on telecommunication systems modeling and analysis. nashville, tennessee, usa, march 9-12 2000. [smb01] b. steffen, t. margaria, v. braun. coarse-granular model checking in practice. in dwyer (ed.), model checking software. pp. 304–311. springer berlin heidelberg, berlin, heidelberg, 2001. [som15] f. somenzi. cudd: cu decision diagram package release 3.0.0. university of colorado at boulder, 12 2015. [ssk+13] j. shotton, t. sharp, p. kohli, s. nowozin, j. winn, a. criminisi. decision jungles: compact and rich models for classification. in proc. nips. 2013. [zgn+17] h. zhang, i. ganchev, n. s. nikolov, z. ji, m. o’droma. a hybrid service recommendation prototype adapted for the ucww: a smart-city orientation. wireless communications and mobile computing 2017, 2017. isola ds 2016 16 / 16 introduction algebraic decision diagrams the miaamics approach a small comprehensible example system of rules building the decision data structure code generation transitions as goto-statements simulating goto-statements results implementation in c++ evaluation with a random system of rules related work conclusion generating preconditions from graph constraints by higher order graph transformation electronic communications of the easst volume 67 (2014) proceedings of the 13th international workshop on graph transformation and visual modeling techniques (gtvmt 2014) generating preconditions from graph constraints by higher order graph transformation frederik deckwerth and gergely varró 13 pages guest editors: frank hermann, stefan sauer managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst generating preconditions from graph constraints by higher order graph transformation frederik deckwerth1∗ and gergely varró2† 1 frederik.deckwerth@es.tu-darmstadt.de, 2 gergely.varro@es.tu-darmstadt.de real-time systems lab technische universität darmstadt, germany abstract: techniques for the verification of structural invariants in graph transformation systems typically rely on the derivation of negative application conditions that are attached to graph transformation rules in order to avoid the runtime occurrence of forbidden structural patterns in the system model. in this paper, we propose a practical approach for this derivation process, which produces the required negative application conditions by applying higher order graph transformation on the rule specifications themselves. additionally, we integrate filtering criteria into these higher order constructs to avoid, already at an early stage, the unnecessary construction of invalid and redundant negative application conditions. keywords: higher order graph transformation, static analysis, verification 1 introduction graph transformation (gt) [roz97] as a declarative technique to specify the rule-based manipulation of system models has been successfully employed in many practical, real-world applications [hec98] including scenarios from the security domain [kmp02], where the formal nature of graph transformation plays an important role. role-based access control (rbac) [scfy96] is undoubtedly such a well-known security scenario, in which graph transformation can be applied as suggested in [kmp02]. in this setup, an access control policy is defined (i) by modeling authorization settings (e.g., users, roles, and permissions) in the system as graphs, and (ii) by specifying their modifications declaratively by graph transformation rules, whose application actually performs these changes on the graphbased authorization model. an additional important and challenging task in an rbac scenario is to ensure that a specified access control policy is always enforced. this can be supported by automated gt verification techniques [hw95], which requires (global) negative constraints representing forbidden structures that are never allowed to occur in any authorization settings. while runtime verification techniques for graph transformation can efficiently detect the occurrences of these forbidden patterns by monitoring and reacting accordingly, this approach is unsatisfactory, if the policy is to be statically enforced in a proven and certified manner, e.g., in an auditing process carried out by the security team of a company or by external auditors. in ∗ supported by cased (www.cased.de). † supported by the dfg funded crc 1053 maki. 1 / 13 volume 67 (2014) mailto:frederik.deckwerth@es.tu-darmstadt.de mailto:gergely.varro@es.tu-darmstadt.de generating preconditions from graph constraints by higher order graph transformation such a case, static analysis techniques [hw95], which are used to derive information required to extend the left-hand side (lhs) of the graph transformation rules at design time by attaching new negative application conditions (nac) [hht96], are more appropriate. the attached nacs, generated from the given negative constraints, avoid rule applications at runtime that would lead from a policy compliant authorization setting to a policy violating one. the design-time production of graph transformation rules with a nac-enriched left-hand side is carried out by a sophisticated algorithm [hw95] in the following three steps. (1) each subgraph of each negative constraint is glued to the right-hand side (rhs) of the gt rules (in a type-conform manner) as a postcondition nac. this forbids a situation where the negative constraint is violated after the rule application. (2) the postcondition nac is back-propagated to the lhs as a regular (precondition) nac by reverting the modifications specified by the gt rule. (3) finally, the set of gt rules with (precondition) nacs is filtered to discard redundant nacs, where the negative constraint is already violated before the rule application. although the original algorithm [hw95] and its conceptual derivatives [eehp04] present many interesting theoretical considerations, the implementation of such a technique either remains an open issue, or requires additional logic or category theory based libraries. in this paper, we propose a practical approach, which can be implemented by any existing graph transformation tool that considers rule specifications as regular models, to produce graph transformation rules with negative application conditions. the proposed technique derives higher order graph transformation rules from the negative constraints, and applies these higher order constructs to the original gt rule specifications to attach appropriate nacs. additionally, we identify filtering conditions at an early stage and integrate them into the higher order rules to be able to avoid the construction of redundant (precondition) nacs. the remainder of the paper is structured as follows: section 2 introduces basic modeling and graph transformation concepts. the general precondition nac derivation process is sketched in sec. 3, while sec. 4 presents our algorithm using higher order transformations to construct these application conditions. related work is discussed in sec. 5, and sec. 6 concludes our paper. 2 modeling and graph transformation concepts this section introduces the basic concepts of metamodels, models and graph transformation. graphs and graph morphisms. a graph g = (vg,eg,sg,tg) consists of a set of vertices vg and edges eg, and two functions sg,tg : eg → vg, which map edges to their source and target vertices, respectively. a total graph morphism f from graph g to h is a pair of total functions fv : vg → vh , fe : eg → eh that map vertices and edges in a structure preserving manner, i.e., fv ◦sg = sh ◦ fe and fv ◦tg = th ◦ fe . a graph morphism f is injective, if both fv and fe is are injective functions. a partial graph morphism f from g to h is a total graph morphism from some subgraph of g. metamodels and models. a metamodel defines the core concepts of a domain, while a model describes an actual system. formally, a metamodel mm is a graph, whose vertices and edges are classes and associations, respectively. a model m typed by the metamodel mm is also a graph, whose vertices and edges (referred to as objects and links) can be mapped to classes and associations, respectively, by a total graph morphism type : m → mm. a typed (graph) proc. gtvmt 2014 2 / 13 eceasst morphism f : m → m′ from model m to m′ that are both typed by metamodel mm is a graph morphism, which preserves type information, i.e., type◦ f = type′. example. a simplified role-based access control (rbac) scenario inspired by [kmp02] is used throughout the paper as a running example. figure 1a shows the rbac metamodel, which consists of the classes user (u), role (r), permission (p), and the static separation of duty relation (ssod). the association roles defines the roles belonging to a user and the association permissions specifies the permissions assigned to a role. the association exroles connects the ssod relation to roles that can only be granted exclusively. figure 1c shows an rbac model, which contains users anne and bob having the roles financemanager and travelmanager, respectively. these roles can be granted exclusively, expressed by the ssod relation ex. the permissions accounting and booking are assigned to the roles financemanager and travelmanager, respectively. u ssod r roles p permissions exroles (a) rbac domain metamodel u1: u r1: r ex: ssod r2: r (b) neg. const. noexclusiveroles financemanager: r bob: u ex: ssod anne: u travelmanager: r booking: p accounting: p (c) consistent rbac model financemanager: r bob: u ex: ssod anne: u travelmanager: r booking: p accounting: p (d) inconsistent rbac model u: u r: ru: u r: r l r r (e) assignusertorole gt-rule figure 1: the role-based access control application scenario patterns, negative constraints and model consistency. a pattern p is a graph typed by a metamodel mm. a pattern p matches a model m if there exists a total injective typed morphism m : p → m called match morphism. the subgraph m(p)⊆ m is called match of p in m. a negative constraint nc is a pattern to declaratively define forbidden subgraphs in a model. a model m is consistent with respect to a negative constraint nc, if nc does not match m. for simplicity, we will call a model just consistent if it is clear which constraints are meant. example. figure 1b shows a negative constraint that forbids a user to have two exclusive roles. the model depicted in figure 1c is consistent, as neither anne, nor bob has two exclusive roles. in contrast, the model in figure 1d is inconsistent, as anne has both the financemanager and the travelmanager roles, which are exclusive according to the ssod relation ex. graph transformation rules and their application. a graph transformation rule r = (n/ ← l → r →n.) consists of a left hand side (lhs) pattern l and a right hand side (rhs) 3 / 13 volume 67 (2014) generating preconditions from graph constraints by higher order graph transformation pattern r and the (possibly empty) sets of preand postcondition negative application conditions (nacs) n/ and n.. the lhs and the rhs are related by the typed partial morphism r : l → r. the preand postcondition nacs n/ ∈n/ and n. ∈n. are related to l and r by typed total injective morphisms n/ : l → n/ and n. : r → n.. a rule r = (n/ ← l → r →n.) is applicable to a model m iff (i) there exists a match m : l → m of the lhs pattern l of r in m, and (ii) the precondition nacs n/ ∈n/ are satisfied. a precondition nac n/ is satisfied if the current match m(l) cannot be extended to m∗∗(n/) in m, i.e., @m∗∗ : n/ → m : m = m∗∗◦n/. a rule r = (n/ ← l → r →n.) is applied at a match m in model m to obtain the modified model m′ (denoted by m r@m =⇒m′), by constructing the pushout of the match morphism m : l→m and morphism r : l → r of rule r defined (informally) as follows: (i) remove the vertices and edges m(l)⊆ m identified by the match m that are not present in the rhs pattern r. (ii) add the vertices and edges to m that are part of the rhs pattern r, but not present in the lhs pattern l. the vertices and edges that occur in l and r are preserved. dangling edges in m′ are deleted. the violation of a postcondition nac n. ∈n. indicates that the derived model m′ is inconsistent. 1 example. figure 1e shows the gt-rule assignusertorole that assigns a user u to a role r by adding a new roles link. morphisms r, n/, and n. are implicitly specified in all the figures of the running example by matching vertex labels. the result of applying the gt-rule assignusertorole to user anne and role travelmanager in the model of figure 1c is depicted in figure 1d. consistency preservation. a rule r is consistency preserving, if for any arbitrary model m and all possible applications m r⇒m′ of rule r holds: if m is consistent then m′ is also consistent. a set of rules r is consistency preserving if all rules r ∈r are consistency preserving. the idea of consistency preservation is that if a set of rules is consistency preserving and the start graph is consistent, then consistency is preserved for all models derivable by a sequence of rule applications, as none of the rules will transform a consistent to an inconsistent model. 3 building consistency preserving graph transformation rules this section recapitulates the static analysis technique proposed in [hw95], which extends graph transformation rules with precondition nacs to produce consistency preserving gt-rules. the construction of precondition nacs can be carried out in the following three steps: 1. constructing postcondition nacs. for each non-empty subgraph of a negative constraint that is also a subgraph of the rhs pattern of a gt-rule, a postcondition nac is constructed by gluing the negative constraint and the rhs together along the common subgraph. the postcondition nacs represent all those situations where the negative constraint is violated after the rule application. 2. back-propagating postcondition nacs into precondition nacs. each postcondition nac constructed in the previous step is back-propagated to the lhs pattern as a precondition nac by reverting the modifications specified by the gt-rule. the precondition nacs can prevent the gt-rule from transforming a consistent model into an inconsistent one. 3. filtering precondition nacs. redundant or invalid precondition nacs are discarded in 1 note that in real applications postcondition nacs are of little use as they cannot prevent the derivation of inconsistent models. however, they are used as an intermediate step for the construction of precondition nacs. proc. gtvmt 2014 4 / 13 eceasst the following two cases. (i) if the complete negative constraint appears in the precondition nac, then such a construct could block rule application only on inconsistent models, which can never be created by applying consistency preserving rules on a consistent initial model. consequently, such a precondition nac can be considered redundant (assuming a consistent initial model and a set of consistency preserving rules is used). (ii) if an edge in the postcondition nac that originates exclusively from the negative constraint is adjacent to a node that is deleted by the back-propagation, then a (structurally) invalid precondition nac with dangling edges is produced. as [hw95] states, the filtering conditions for precondition nacs in step 3 can also be formulated on the corresponding postcondition nacs, consequently, an adapted filtering step can already be carried out directly after step 1 in the previous process. therefore, in the rest of the paper, we only consider the first two phases of this alternative approach, namely, the construction (sec. 3.1) and filtering (sec. 3.2) of postcondition nacs. 3.1 construction of postcondition nacs r gl ncn⊲ n⊲ q g p 1© a non-empty graph gl is a gluing graph of a rhs pattern r and a negative constraint nc if it is a subgraph of both r and nc, i.e., there exists at least a pair of total injective typed morphisms r q←− gl g−→ nc. the postcondition nac patterns n. ∈n. of r and nc can be constructed as pushouts 1© over morphisms r q←− gl g−→ nc for all gluing graphs gl of r and nc, and all total injective typed morphisms q and g. example. the postcondition nacs derived from the negative constraint noexclusiveroles (fig. 1b) and the rhs of rule assignusertorole (fig. 1e) are shown in figure 2. vertices and edges are drawn solid if they belong to the rhs. dashed vertices and edges denote the elements of the negative constraint noexclusiveroles. the gluing graph is drawn bold. u,u1: u r,r2: r r1: r ex: ssod u,u1: u r: r r1: r ex: ssod r2: r u,u1: u r,r1: r r2: r ex: ssod u,u1: u r,r2: r r1: r ex: ssod u: u r,r1: r u1: u ex: ssod r2: r u: u r,r2: r u1: u ex: ssod r1: r u,u1: u r,r1: r r2: r ex: ssod figure 2: postcondition nacs from neg. const. noexclusiveroles and rule assignusertorole 3.2 filter conditions for postcondition nacs the back-propagation of postcondition nacs into redundant or invalid precondition nacs can be avoided if the filtering is carried out on the postcondition nacs right after their construction in step 1. a postcondition nac n. of the rhs pattern r of rule r and the negative constraint nc, is discarded if either of the following conditions is fulfilled: (i) preserving condition. all elements of the gluing graph gl are preserved by the reverse application of rule r that would yield a precondition nac that contains the complete negative 5 / 13 volume 67 (2014) generating preconditions from graph constraints by higher order graph transformation constraint nc. formally, ∀vgl ∈ vgl,∃vl ∈ vl : r(vl) = q(vgl), and ∀egl ∈ egl,∃el ∈ el : r(el) = q(egl). (ii) dangling edge condition. there exists an edge e in that part of the postcondition nac n., which originates only from the negative constraint nc (formally, e ∈ en. \n.e(r)), whose source sn.(e) or target tn.(e) vertex would be deleted by the reverse application of rule r, making e a dangling edge in the precondition nac (formally, ∃v ∈(vr\rv (vl)) : sn.(e) = n.v (v)∨tn.(e) = n.v (v)). let the dangling point graph dp consist of all vertices v ∈vgl whose image gv (vdp) ⊆vnc in the negative constraint is source or target of an edge that is not in the gluing graph (formally, vdp ={v ∈vgl |∃e ∈ enc \ge(egl) : snc(e) = gv (v)∨tnc(e) = gv (v)}). lemma 1 a postcondition nac n. constructed by the pushout 1© over morphisms r q←− gl g−→ nc for gluing graph gl fulfills the dangling edge condition iff the image q(dp) ⊆ r contains at least one vertex that is deleted during the reverse application of rule r. proof. “⇒”: as the dangling edge condition is fulfilled, there exists a vertex v ∈ vr \rv (vl) s.t. there exists e ∈ en. \n.e(r) with sn.(e) = n.v (v)∨ tn.(e) = n.v (v). as n. is constructed by pushout 1© there exists an edge e′ ∈ enc such that pe(e′) = e and with a source or target vertex v′ ∈vnc such that pv (v′) = n.v (v). hence, there exists a vertex v′′ ∈vgl with gv (v′′) = v′ and qv (v′′) = v that is in vdp, as from the pushout 1© and the injectivity of g follows that e′ ∈ enc \ge(egl). “⇐”: there exists a vertex v ∈ vdp ⊆ vgl, whose image qv (v) ∈ vr \rv (vl) is deleted by the reverse rule application. from v ∈vdp, we can conclude that there exists an edge e ∈ enc \ ge(egl) such that snc(e) = gv (v)∨tnc(e) = gv (v). from the injectivity of q we know that there exists an edge e′ ∈ en. s.t. e′ = pe(e) whose source or target vertex v′ = qv ◦n.v (v). from pushout 1© and the injectivity of g follows that e′ must be in en. \n.e(r), as e has no preimage in gl. thus, the dangling edge condition is fulfilled. example. all but the first two postcondition nacs shown in figure 2 are discarded due to the preserving condition, as the gluing graph does not contain the edge between user u and role r that is deleted by the reverse application. 4 deriving postcondition nacs by higher order transformation in this section, we present an approach for the automated construction of postcondition nacs using higher order (ho) graph transformation, i.e., transformations that can be applied on graph transformation rules. our technique first constructs higher order transformation rules (ho-rules) either from the subgraphs of the negative constraints or from the gt-rules, and then these derived ho-rules are applied to the original gt-rules to produce exactly those postcondition nacs that violate either the preserving or the dangling edge condition. consequently, postcondition nacs that would result later in redundant or invalid precondition nacs are not produced in our approach. moreover, as a result of this early filtering, the approach is basically suitable (i.e., with minor changes) to directly construct precondition nacs, which is not discussed here due to space limitations. proc. gtvmt 2014 6 / 13 eceasst although the rest of this section deals with theoretical topics presenting the approach and proving its correctness, it should be highly emphasized that ho-rules can be easily specified in a graph transformation tool (like emoflon [alps11]), in which gt-rules are represented as regular models. these ho-rules can be applied by the existing machinery facilitating the construction and the filtering of postcondition nacs. 4.1 higher order transformation a higher order (ho) transformation is a transformation applied on graph transformation (gt) rule specifications. higher order transformation is now introduced analogously to the concepts of graph transformation. higher order morphism (ho-morphism) and higher order pattern (ho-pattern). a ho-morphism f̂ : r → r′ that relates the gt-rules r = (n/ n / ← l r→ r n . →n.) and r′ = (n/′ n /′ ← l′ r′→ r′ n .′ →n.′) is a tuple f̂ = (fn/, fl, fr,fn.) consisting of the typed graph morphisms fl : l → l′ and fr : r → r′, and the sets fn/ and fn. of typed graph morphism of the form fn/ : n/ → n/′ and fn. : n. → n.′, respectively. morphisms fl and fr relate the lhs and rhs patterns of the gt-rules r and r′ such that fr ◦r = r′◦ fl. the morphisms fn/ ∈ fn/ and fn. ∈ fn. relate the preand postcondition nacs of r and r′ such that fn/ ◦n/ = n/′◦ fl and fn. ◦n. = n.′◦ fr for all fn/ ∈ fn/ and fn. ∈ fn. . a ho-morphism f̂ is total (injective) if all graph morphisms in {fn/, fl, fr,fn.} are total (injective). a ho-morphism f̂ is partial if at least one graph morphism in {fn/, fl, fr,fn.} is partial. a ho-pattern p̂ = (n/ ← l → r →n.) can be matched to a rule r if there exist a total injective ho-morphism m̂ : p̂ → r. higher order transformation rules (ho-rules) and their application. a ho-rule r̂ = (n̂/ ← l̂ → r̂ → n̂.) consists of the left and right hand ho-patterns l̂ and r̂ and optionally a higher order preand postcondition nac, defined by the ho-patterns n̂/ and n̂.. the ho-lhs and rhs patterns are related by the partial ho-morphism r̂ : l̂ → r̂, while the higher order preand postcondition nacs are related to l̂ and r̂ by ho-morphisms n̂/ : l̂ → n̂/ and n̂. : r̂ → n̂.. a ho-rule r̂ is applicable to a gt-rule r iff (i) there exists a ho-match m̂ : l̂ → r of the ho-lhs pattern l̂ in gt-rule r that (ii) cannot be extended to m̂∗∗ : n̂/ → r s.t. m̂ = m̂∗◦ n̂/. a ho-rule r̂ is applied at ho-match m̂ in gt-rule r to obtain the modified rule r′ (denoted by r r̂@m̂=⇒ r′) by constructing the pushout of the ho-match m̂ : l̂ → r and ho-morphism r̂ : l̂ → r̂ of ho-rule r̂, while dangling edges are deleted. example. figure 3 shows a ho-rule (rhs pattern copying ho-rule) with a ho-lhs pattern l̂ and a ho-rhs pattern r̂. the ho-rule is applicable to the assignusertorole gt-rule, as there exists a ho-match m̂ that maps the user u and the role r, as well as the edge from lhs ho-pattern to the rhs pattern of the gt-rule. the rule is applied at match m̂ by constructing the pushout of the ho-match m̂ and the ho-morphism r̂, i.e., by adding the elements present in the ho-rhs pattern r̂ but not in the ho-lhs pattern l̂ (no elements are deleted by the horule). the result is the modified gt-rule assignusertorole’ (shown in the bottom right corner of figure 3) equipped with a postcondition nac that is identical to its rhs. 7 / 13 volume 67 (2014) generating preconditions from graph constraints by higher order graph transformation u: u r: ru: u r: r u: u r: r u: u r: r u: u r: r u: u r: r u: u r: r u: u r: r l̂ r r̂ assignusertorole assignusertorole’ rhs pattern copying ho-rule l r l r n⊲ r n⊲r̂ v̂ v̂∗ r̂′ figure 3: higher order transformation rule application 4.2 derivation of higher order rules the process of constructing the postcondition nacs is carried out by the following three kinds of ho-rules: (i) the filter criterion checking ho-rules determine the gluing graph and ensure the violation of the preserving and the dangling edge constraints. (ii) the rhs pattern copying ho-rules add a postcondition nac identical to the rhs pattern of the gt-rule. (iii) the constraint gluing ho-rules glue the negative constraint to the postcondition nac (created by the rhs pattern copying rule) along the gluing graph identified by the filter criterion checking rule. (i + iii) deriving filter criterion checking and constraint gluing ho-rules from negative constraints. for each negative constraint nc, all its subgraphs gl∗ ⊆ nc are derived as gluing graph candidates. note that gluing graph candidates gl∗ are not necessarily subgraphs of the rhs pattern. consequently, there exists an injective typed morphism g : gl∗ → nc, but there need not be an injective mapping q : gl∗ → r. ∅∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅∅ ∅ ∅∅∅∅ dpdp gl∗gl∗ gl∗gl∗ gl∗gl∗gl∗ n⊲ nc ll lrrr rr r r id|gl∗id|dpid|dp id id id û∗∗ û∗û ŵ ŵ∗ v̂ v̂∗ r̂′co r̂co r̂′gl r̂gl n̂⊳ch r̂ch n̂⊳ l̂ r̂ l̂ r̂ l̂ r̂ r r′ r′′ r̂gl ∗ ch r̂gl ∗ gl r̂rco r′r′ r′n⊲′ n⊲′ for each gl∗ ⊆ nc: for each r: figure 4: derivation and application of ho-rules for constructing the postcondition nacs for each gluing graph candidate gl∗ ⊆ nc, a filter criterion checking ho-rule r̂gl∗ch is derived (top left corner of figure 4), which consists of a ho-lhs, a ho-rhs and ho-precondition nac patterns l̂ = r̂ = (/0 ← dp id|dp→ gl∗ → /0) and n̂/ = (/0 ← gl∗ id→ gl∗ → /0), respectively. the ho-lhs l̂ ensures that a filter criterion checking ho-rule r̂gl ∗ ch is only applicable to gt-rule r if the gluing graph gl∗ is contained in its rhs and the dangling points dp ⊆ gl∗ are preserved during reverse rule application to prevent the occurrence of dangling edges (see dangling edge proc. gtvmt 2014 8 / 13 eceasst u:u r:ru:u r:r u:u r:ru:u r:r u:u r:r u:u r:r ex:ssod r2:r u:u r:ru:u r:r u1:u r1:r u1:u r1:r u1:u r1:r ex:ssod r2:r u1:u r1:r u1:u r1:r u1:u r1:r u1:u r1:r u1:u r1:r u1:u r1:r u1:u r1:ru1:u r1:r u1:u r1:r u1:u r1:r ex:ssod r2:r u1:u r1:ru1:u r1:r l l l lll r r r rr rr rrr n⊲ n⊲n⊲ n⊲n⊲ r̂assignusertoroleco r̂gl ∗ gl r̂ r̂ r̂gl ∗ ch n̂⊳ l̂ l̂ l̂ r̂ û∗∗ û∗û ŵ ŵ ∗ v̂ v̂∗ r̂co r̂′co r̂gl r̂′gl n̂⊳ch r̂ch assignusertorole assignusertorole′ assignusertorole′′ noexclusiveroles gl∗ figure 5: ho-rule derivation and application example condition and lemma 1). the ho-precondition nac n̂/ prevents the application of ho-rule r̂gl ∗ ch if all elements identified by the gluing graph are preserved by the reverse application of gt-rule r, which is fulfilled as they appear on the lhs and rhs of gt-rule r (see preserving condition). morphism id|dp is the identity morphism of gl∗ restricted to dp, i.e. id|dp(v) = v for all vertices v ∈ dp. for each gluing graph candidate gl∗ ⊆ nc, a constraint gluing ho-rule r̂gl∗gl is derived (top right corner of figure 4), which consists of the ho-rhs and ho-postcondition nac patterns r̂ = (/0 ← /0 → gl∗ id→ gl∗) and n̂. = (/0 ← /0 → gl∗ id|gl∗→ nc), respectively. (ii) deriving rhs pattern copying ho-rules from gt-rules. for each gt-rule r, a rhs pattern copying ho-rule r̂rco is derived (bottom of figure 4), which consists of ho-lhs and ho-rhs patterns l̂ = (/0 ← /0 → r → /0) and r̂ = (/0 ← /0 → r id→ r), respectively. example.the top part of fig. 5 presents the filter criterion checking and the constraint gluing ho-rules that were derived from the gluing graph candidate and the negative constraint noexclusiveroles depicted in the grey box at the bottom left corner. the rhs pattern copying ho-rule derived from the gt-rule assignusertorole is shown at the bottom of figure 5. 4.3 application of higher order rules for each pair of a gluing graph candidate gl∗ and a gt-rule r, the following steps are carried out (as shown in figure 4) to construct postcondition nacs from the gt-rules: (1) the applicability of the filter criterion checking ho-rule r̂gl ∗ ch to gt-rule r is checked by looking for a ho-match û of dp r−→ gl∗ in the gt-rule r that cannot be extended to gl∗ r−→ gl∗ in r such that û∗∗◦ n̂/ch = û. this ensures that the gluing graph candidate is really a gluing graph of the rhs pattern of gt-rule r and the postcondition nac, and it will not be discarded due to violation of the dangling edge or preserving condition (shown later in the proof of theorem 1). for each ho-match û identified in the previous step, to which r̂gl ∗ ch is applicable : 9 / 13 volume 67 (2014) generating preconditions from graph constraints by higher order graph transformation (2) the rhs pattern copying ho-rule r̂rco is applied to gt-rule r, which copies the rhs pattern of rule r as a postcondition nac into the produced rule r′. (3) the constraint gluing ho-rule r̂gl ∗ gl is applied to the gt-rule r ′, which glues the negative constraint to the postcondition nac created in step (2) along the gluing graph identified in step (1). this is achieved by choosing typed morphism components wr and wn. of the ho-match ŵ such that wr(gl∗) = ur(gl∗) and wn.(gl∗) ⊆ v∗n.(r), where ur(gl∗) is the part of the rhs pattern of gt-rule r′ identified by match ur(gl∗) in step (1), and v∗n.(r) identifies the elements of the postcondition nac created in step (2). example. the filter criterion checking ho-rule r̂ch (top left corner of fig. 5) is applicable to the gt-rule assignusertorole (in the middle) as there exists a match for the ho-lhs pattern of r̂ch in the gt-rule (mapping u1 and r1 to u and r, respectively), but no match for the hoprecondition nac n̂/. consequently, the rhs pattern copying ho-rule adds a copy of the rhs pattern as postcondition nac to the assignusertorole gt-rule. finally, the constraint gluing ho-rule is applied adding the elements in the negative constraint but not in the gluing graph. correctness of the approach. the overall correctness of the approach (including the filtering conditions on and the back-propagation of postcondition nacs) has been shown in [hw95]. hence, we limit ourselves to argue that our higher order transformation constructs postcondition nacs as described in sec. 3.1, and produces neither redundant nor invalid postcondition nacs. it is easy to see that the application of the rhs pattern copying and the constraint gluing horules constructs the correct postcondition nac if the gluing graph has already been identified. thus, it is enough to prove that the filter criterion checking ho-rule determines the gluing graph correctly and ensures that neither redundant nor invalid postcondition nacs will be produced. theorem 1 a filter criterion checking ho-rule is applicable iff (i) the gluing graph candidate is really a gluing graph of the gt-rule and the negative constraint, and the postcondition nac (going to be constructed for the gluing graph) will be preserved as it fulfills (ii) neither the preserving condition, (iii) nor the dangling edge condition. proof. the ho-rule r̂ch is applicable to a gt rule r iff a ho-match morphism û exists that cannot be extended to the ho-match û∗∗(n̂/) of the ho-precondition nac. (i) as û = (ul,ur) is total and injective, its typed morphism component ur : gl∗ → r is also total and injective. this means that the gluing graph candidate gl∗ is a subgraph of the rhs pattern r of gt-rule r and, therefore, a gluing graph of r and nc iff ur exists. (ii) the gluing graph identified by ur(gl∗) appears completely in both the lhs and the rhs pattern of gt-rule r iff ho-precondition nac is violated. consequently, the preserving condition is fulfilled iff the ho-precondition nac n/ is violated. (iii) from lemma 1 follows that the dangling edge condition is not fulfilled iff the image of the dangling point graph in the rhs is preserved during reverse application of the gt-rule. the vertices v ∈ vdp are preserved during the reverse application iff they are in the lhs and rhs pattern of gt-rule r, which is ensured iff there exists a ho-match û = (ul,ur) with morphism ul : dp → l and ur : gl∗ → r. proc. gtvmt 2014 10 / 13 eceasst 5 related work static analysis of graph transformation systems. in the context of graph transformation, the notion of patterns to express global constraints was first proposed in [hw95] and extended in [eept06] to the more general framework of high-level replacement systems. both approaches propose a mathematical construction method for application conditions from constraints founded in the abstract frameworks of category theory. although they provide the formal foundations, a direct implementation of the approaches is only feasible for transformation tools that are built on top of libraries for categorical constructions, as for example agg [tae00]. in contrast, our construction procedure can be implemented using any existing graph transformation tool that considers rule specifications as regular models. a similar idea, namely to reformulate the constructive approach to a domain supported by standard technologies, is presented in [bbg+06]. the authors propose a translation of patterns and constraints into logic formulas performing the computations symbolically using binary decision diagram based solvers. while this requires a complex translation into the logic domain and an additional solver, our approach uses the gt-engine, which already exists in gt-tools. higher-order transformation. the majority of higher order transformation approaches do not address static verification. for example, [vp04] proposes a special kind higher order transformation rules (called metarules) to transform generic rewrite rules to model level rules that can be carried out by the transformation engine. in [vp04] it is shown that under suitable assumption the rules for metamodel refractoring can also be used to adapt transformation rules to preserve compatibility with the refactorings. the approach of [bgl08] uses higher order graph transformation to translate negative constraints into postcondition nacs. instead of creating the postcondition nacs for all possible gluing graphs, only the maximal gluing graphs are considered. this avoids the construction of postcondition nacs that are subsumed by others. in contrast to our approach, the challenges regarding a practical implementation are not considered. it is also not discussed how to avoid the construction of redundant and invalid postcondition nacs using higher order transformations, which is crucial for using the approach in real world applications. 6 conclusion in this paper, we proposed an approach to produce negative application conditions at compile time by applying higher order graph transformation on rule specifications to prevent the runtime occurrence of forbidden patterns. we integrated filtering criteria into the higher order constructs to avoid the unnecessary construction of invalid and redundant negative application conditions and presented formal arguments for the correctness of this technique. as gt-rules are represented as regular models in many state-of-the-art graph transformation tools, higher order transformations can be carried out easily by the already available transformation machinery of these tools, which can be considered as a clear advantage over a handcrafted implementation. as the validity of the negative application conditions is checked before their construction, only minor extensions are required to use the approach to directly construct precondition nacs. that 11 / 13 volume 67 (2014) generating preconditions from graph constraints by higher order graph transformation is, simply modifying the presented algorithm such that it creates the same negative application condition but now as precondition nac, and adding an extra step that applies an additional horule to add (and remove) the elements in the previously created precondition nac as specified by reverse application of the gt-rule. although, this is not discussed in the paper (due to space limitations), it is included in our graph transformation tool emoflon [alps11]. additionally, we will also support positive (if then) application conditions, as well as application condition including attributes and inheritance in an upcoming release. a further task is to investigate how to use higher order transformation for static analysis of higher order transformation. for instance, the precondition nac in the filter criterion checking ho-rule can be derived using a higher order negative constraint. bibliography [alps11] a. anjorin, m. lauder, s. patzina, a. schürr. emoflon: leveraging emf and professional case tools. in informatik 2011. lni 192, p. 281. gesellschaft für informatik, bonn, october 2011. extended abstract. [bbg+06] b. becker, d. beyer, h. giese, f. klein, d. schilling. symbolic invariant verification for systems with dynamic structural adaptation. in proceedings of the 28th icse. icse ’06, pp. 72–81. acm, new york, ny, usa, 2006. [bgl08] p. bottoni, e. guerra, j. de lara. enforced generative patterns for the specification of the syntax and semantics of visual languages. journal of visual languages and computing 19(4):429 – 455, 2008. [eehp04] h. ehrig, k. ehrig, a. habel, k.-h. pennemann. constraints and application conditions: from graphs to high-level structures. in ehrig et al. (eds.), graph transformations. lncs 3256, pp. 287–303. springer berlin heidelberg, 2004. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. springer verlag, 2006. [hec98] r. heckel. compositional verification of reactive systems specified by graph transformation. in in fase 1998. lncs 1382, pp. 138–153. springer, 1998. [hht96] a. habel, r. heckel, g. taentzer. graph grammars with negative application conditions. fundamenta informaticae 26(3/4):287–313, 1996. [hw95] r. heckel, a. wagner. ensuring consistency of conditional graph rewriting – a constructive approach. in corradini and montanari (eds.), proc. of joint compugraph/semagraph workshop on graph rewriting and computation. entcs 2, pp. 118–126. elsevier, volterra, pisa, italy, august 1995. [kmp02] m. koch, l. v. mancini, f. parisi-presicce. a graph-based formalism for rbac. acm trans. inf. syst. secur. 5(3):332–365, aug. 2002. proc. gtvmt 2014 12 / 13 eceasst [roz97] g. rozenberg (ed.). handbook of graph grammars and computing by graph transformation. volume 1: foundations. world scientific, 1997. [scfy96] r. s. sandhu, e. j. coyne, h. l. feinstein, c. e. youman. role-based access control models. computer 29(2):38 –47, 1996. [tae00] g. taentzer. agg: a tool environment for algebraic graph transformation. in nagl et al. (eds.), proc. of the agtive’99. lncs 1779, pp. 481–490. springerverlag, kerkrade, the netherlands, 2000. [vp04] d. varró, a. pataricza. generic and meta-transformations for model transformation engineering. in baar et al. (eds.), uml 2004 the unified modeling language. modelling languages and applications. lncs 3273, pp. 290–304. springer, 2004. 13 / 13 volume 67 (2014) introduction modeling and graph transformation concepts building consistency preserving graph transformation rules construction of postcondition nacs filter conditions for postcondition nacs deriving postcondition nacs by higher order transformation higher order transformation derivation of higher order rules application of higher order rules related work conclusion navigating communication networks with deep reinforcement learning electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) navigating communication networks with deep reinforcement learning patrick krämer andreas blenk 16 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst navigating communication networks with deep reinforcement learning patrick krämer1 andreas blenk12 1 chair of communication networks, technical university of munich, germany 2 faculty of computer science, university of vienna, austria abstract: traditional routing protocols such as open shortest path first cannot incorporate fast-changing network states due to their inherent slowness and limited expressiveness. to overcome these limitations, we propose comnav, a system that uses reinforcement learning (rl) to learn a distributed routing protocol tailored to a specific network. comnavinterprets routing as a navigational problem, in which flows have to find a way from source to destination. thus, comnavhas a close connection to congestion games. the key concept and main contribution is the design of the learning process as a congestion game that allows rl to effectively learn a distributed protocol.game theory thereby provides a solid foundation against which the policies rl learns can be evaluated, interpreted, and questioned. we evaluate the capabilities of the learning system in two scenarios in which the routing protocol must react to changes in the network state, and make decisions based on the properties of the flow. our results show that rl can learn the desired behavior and requires the exchange of only 16 bits of information. keywords: reinforcement learning, game theory, routing 1 introduction after proper configuration, communication networks are able to adjust to changes in their state, e.g., to changes in the topology [crs16]. communication networks achieve this with a rulebased learning system. routers exchange information about the network state among each other or a central entity [bsl+18]. a routing protocol-dependent algorithm, e.g., dijkstra’s algorithm [crs16], computes the routing information base (rib) from this information [kr16]. the routing protocol derives forwarding rules, i.e., which traffic is forwarded through which port, from the rib. these rules form the forward information base (fib) [kr16]. the dataplane matches packets against those rules and derives the applicable action set [aed+14]. this approach suffers from two shortcomings: 1) limited adaptability and 2) limited expressiveness. the process to translate a change in the network into new rules on the fib has multiple steps and is thus slow to react. it is difficult for this rule-based system to condition forwarding decisions on fast-changing network state attributes such as utilization or queue length [aed+14]. to counteract this, rules for different contingencies could in principle be computed and installed on the devices. however, forwarding rules based on dynamic network state could become complex and intricate and exceed the rule table size. increasing memory is possible but expensive [sb18]. the restricted space for rules can thus limit their expressiveness and thus the extend to which forwarding decision can be conditioned on network state. 1 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning network state routing process rib fib rules rules updatesstate network state routing process rib fib rules rules updatesstate state updates node 1 node 2 (a) traditional. fib neural network node 1 rules fib neural network node 2 rules encoded state (b) comnav. figure 1: system diagrams for traditional routing protocols, comnav and a comparison of the induced logical control planes. comnav integrates the storage of network state, rib, and calculation of route into a neural network. we propose comnav, a system that relies on network programmability, reinforcement learning (rl), neural networks (nns) and hardware acceleration to overcome this limitation. the idea of comnav is to train a recurrent neural network (rnn) with a binary hidden state that implements a routing protocol. this routing protocol can be tailored to a specific network and its workload during training. using a binary representation for the hidden state allows concise encodings through a distributed representation of information in the rnn weights [gbb11]. forwarding devices implement only limited functionality: the execution of the forward pass of an rnn that can be implemented directly in hardware [ssb18, sb18]. fig. 1a and fig. 1b illustrate the architectural differences of a traditional rule-based system and comnav. network devices in traditional systems have a routing process that computes the rules of the rib and thus the fib from the current network state, and configured policies. the network devices exchange local state on the level of the routing processes through well defined messages. in comnav, the computation of rules for the fib, and the storage of network state is implemented in a rnn. nodes in comnav do also exchange messages. those message are exchanged only with direct neighboring nodes and are not explicitly specified. instead, the rnn learns how to design those messages during a training phase. this allows the network to exchange exactly the information that is necessary to achieve a specific objective. to obtain such a protocol, comnav takes a flow-centric perspective: we teach flows navigational skills with rl, which allows them to traverse a communication network, thereby exploiting its current state (e.g., current loads, failed links, etc.). in other words, we present a first building block towards a routing that is learned by the network itself, providing the opportunity to let the network react to changing traffic conditions, hardware or topological changes. to this end, we design and train a novel neural architecture that caters for the specific properties of communication networks and routing. the focus on flows introduces a connection to game theory and in netsys 2021 2 / 16 eceasst particular congestion games [rt02], which we will discuss in more detail. as a first step, we investigate the feasibility of using an rnn with a binary hidden state to make routing decisions based on the current state on network nodes. using our proof-of-concept implementation, we show the potential of such an approach in two case studies: learning to evade congested links and learning to navigate flows with different properties. indeed, we find that rl can be used to learn strategies for different network states and differentiate path selection critera based on observed flow characteristics and network state information. the remainder is organized as follows: we present our vision, identify challenges and present our approach in sec. 2. sec. 3 introduces the the environmental model for rl. sec. 4 discusses the used rl architecture. in sec. 5 we evaluate our design in two experiments to provide a proofof-concept for our proposed methodology, sec. 6 discusses related work, and sec. 7 concludes this work. 2 vision: navigation vs routing we envision networks that adapt their routing strategy for traffic that changes over short and long time-scales. in order to achieve this vision, we use rl, which allows an agent to evolve its behavior by adapting it to reward signals in our work, we take an unconventional approach as to the choice of our agent. intuitively, a forwarding device or central entity is referred to as agent [bl94, cy96, vsst17], i.e., the entity would use rl for taking its actions in order to maximize its reward. in contrast to the forwarding device-centered view, we identify with agents the entities that traverse the network: a flow, a flowlet, or a packet. we understand routing as a navigation problem. in this interpretation, multiple entities traversing the network actively take actions, which can be interpreted as a congestion game [rt02]. the choice to take on this view-point is motivated by recent advances in the navigation of artificial agents in complex simulated and real environments [mpv+16, mgm+18]. in robotics, navigational tasks are called simultaneous localization and mapping (slam): a robot has to infer its location from sensory information, and creates a map of its environment through exploration, which can then later be used for planning routes [fgs07]. the agent has to associate sensory information of the goal description, e.g., and address or image, and sensory information with a decision like moving forward or turning in order to reach its goal. our vision of routing is similar: packets navigate a network and decide at each switch where to go next, i.e., choose an outgoing port. the decision is based on the state of the network, the agent’s previous experiences, and a time invariant context. fig. 2 illustrates this process. at time t the network is in state rt . rt is not fully observable. instead, the agent obtains sensory information st from rt . sensory information can include port utilization on the switch the agent is situated on, latency information, or congestion information. the only restriction on st is that it can be obtained efficiently to support line rate. the agent then chooses an action at based on st , its memory mt and a time invariant context information c. the action at corresponds to an outgoing port on the switch. the memory summarizes past experiences of the agent, and allows her to include this information during decision making. for example, the utilization pattern on earlier links can include relevant information for later decisions. the time invariant context c can correspond to ip-addresses, quality-of-service requirements, the volume of the flow, etc. 3 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning rt rt+1 rt+2 at−1 st at st+1 at+1 st+2 c c c c mt mt+1 mt+2 figure 2: dependencies between different components of a flowagent agent: mt corresponds to the memory of the agent represented by a rnn, at corresponds to the action taken, rt corresponds to the state of the environment, i.e., the network, and st corresponds to the sensory information the agent obtains from the environment. c corresponds to a time invariant context. after choosing an action, i.e., a port on the node, the memory of the agent is updated. thus, the relevant information from the current node is present on the next node. then, the environment transitions into a new state rt+1, i.e., the agent moves to the next hop. this process continues until the agent reaches its destination. 3 a navigation network model in the following we introduce the different components of the agent-environment system. the environment. we represent a network as a graph g = (n ,e ,b,m) and model it as a queuing network. a node v ∈ n corresponds to a forwarding device, and an edge e ∈ e to a link between two forwarding devices. nodes and edges are both modeled as service units. a link e ∈ e corresponds to a service unit with one first-in-first-out (fifo) queue. a forwarding device v ∈ n has multiple queues, one queue for each flow traversing the node. queues on nodes are served using fair-queuing (fq) with byte-by-byte-round-robin. the function b : n ∪e → n returns the service rates of nodes and links, and the function m : n ∪e →n the buffer. forwarding devices enqueue packets into the queues of its connected links, and links enqueue packets into the queues of incident forwarding devices. packets are pushed into the network by sources using deterministic arrival times, i.e., each source places packets at fixed times into the queue of the incident link. an environment state r ∈ r is thus associated with a specific forwarding device and contains the states of the queues of the forwarding device, as well as the queues of the outgoing links. the flowagent. we consider flow-level routing, and an agent corresponds to a flow to avoid packet re-ordering. note that flows consist of multiple packets, i.e., we use a packet-level simulation. in our simulation, the first packet of the flow, e.g. the tcp syn packet, discovers a path from source to destination. the forwarding decisions are cached in the fib of the nodes, similar to contra [hbc+20]. subsequent packets follow the path of the first packet. a flowagent has time invariant contextual information, e.g., source and destination addresses, qos parameters, type-of-service, or flow size. the agent utilizes this contextual information for decision making. actions. when arriving on a forwarding device, a flow agent decides which link to take. the netsys 2021 4 / 16 eceasst forwarding device then enqueues the flowagent into the buffer of the chosen link. thus, the number of actions of a flowagent can differ between nodes, since each node can have a different number of incident links. thus, the possible actions in each state correspond to outgoing links at the forwarding device associated with that state, i.e., the set of all actions a corresponds to the set of edges e . at each time step t the agent can choose from a subset at ⊂ a . sensor. the sensor of a flowagent defines what the flowagent perceives, i.e., the observable part of the environment. the flowagent uses information from the sensors to make a decision. a sensor reading s ∈ s could include the mac-address of the switch or time-dependent flow properties such as the time-to-live. also local information at the forwarding devices can be observed, e.g., the number of flows at each port, or the utilization of each port. objective. the goal of each flowagent is the minimization of the flow completion time (fct). the reward used during the learning of the protocol with rl is designed to achieve this objective. other objectives, such as minimizing the maximum link utilization, or a combination of different objectives can be used as well. depending on the requirements even policies such as specific traffic should not traverse a specific link or node could be included. 4 learning to navigate networks we represent an agent as a rnn which is trained with rl. for training, we use a simulated network with changing state. each agent obtains a reward that is proportional to the fct, i.e., the time it takes until the last packet is received by the destination. the agents are exposed to varying demands and should learn which route to take based on the observed state, i.e., based on the source, destination, current location, and the utilization of the ports at the current location. a game theoretical perspective. we can view the fct minimization as a congestion game γ = (p,σ,u), p being the set of players, i.e., flowagents, σ the space of possible strategy profiles, and u : σ×p → r a utility function evaluating a strategy profile with respect to a specific player. a strategy for a player is the selected path from a source node s to a destination node d. the utility function is the fct. here, a player then consists of the tuple (s,d,v,t), where s,d ∈ n are the source and destination node of a flow, v its volume, and t its arrival time. now, let σ ∈ σ be a strategy profile, i.e., for each player in p the strategy vector σ contains the strategy of that player. further, let σ ′ := (σ−i,σ ′i ) be the profile that is created when player i ∈ a changes his strategy σi to σ ′i . further, let p : σ → r be a potential function. here, the potential function is the sum over all fcts. then, the game here is a exact potential game since: u(σ ′,i)−u(σ,i) = p(σ ′)−p(σ). (1) a simple proof sketch is as follows: since the potential function is a sum of individual fcts, a change in one fct translates to a change in p [rt02]. thus, the above game emits at least one pure strategy nash equilibrium [gib92], and the rl approach converges towards one nash equilibrium [gls17]. that is, it learns a mapping from the state to the respective strategy that optimizes its utility, i.e., fct. asynchronous advantage actor-critic (a3c). we use an actor-critic based algorithm, which maintains a policy π(at |st,c,θπ ), and an estimate of the value function v (st |θv,c) [mbm+16]. 5 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning we decided for an on-policy algorithm without replay memory to account for the non-stationarity of the environment in multi-agent scenarios [gd21]. we use parametric functions in the form of nns to represent π and v , where θπ identifies the parameters of the policy, and θv the parameters of the value function. the policy maps states to actions, whereas the value function computes the expected reward which can be obtained with a policy from a specific state. in this case, a state corresponds to a sensor reading. we use an asynchronous variant to update the parameters of the functions. that is, multiple agents and environments run in parallel. parameter updates are applied asynchronously to a global set of parameters, that are then copied to the local agent. the agents can thus continuously adapt to the changed policies of the other agents [gd21]. reward. our problem is episodic. one episode corresponds to the delivery of one flow to a destination. in case of the flowagent the reward is: gt = α t∗t + t ∗ p tt + tp , (2) where t∗t is the transmission time on the shortest path based on residual capacity, and t ∗ p the propagation delay on the shortest path based on delays calculated during the arrival of the flow. those paths serve as lower bounds. this information is only required during the training phase in the simulation. the denominator corresponds to the transmission and propagation delay the flow then experienced. eq. (2) becomes larger the closer the agent gets to the minimum values. note, that values larger one are also possible in case flows leave the system providing better shortest paths during the life time of the current flow. in addition to the terminal reward, we use a per-step reward. for the per-step reward, we exploit the relation to routing games and imitate a form of marginal cost pricing [rt02]: gs =− 1 n n ∑ i=1 ( t(i)′t −t (i) t ) . (3) t(i)′t is the transmission time of flow i with the current flow on the same link, while t (i) t was the previous transmission time. the current flow is charged with the additional time its presence on the link causes the other flows. this mechanism has been shown to reduce the price-of-anarchy in congestion games [rt02], and should, therefore, be a good guidance. nn architecture. in our architecture, we make use of parameter sharing. that is, θπ and θv do not correspond to different nns, but instead share large parts of the parameters. fig. 3 illustrates the architecture we use during our experiments. the network consists of multiple building blocks: two encoders, a binary recurrent layer, policy layers, a layer for the value function, and an layer to predict loops in the network path. the purpose of the encoder is to extract a low dimensional representation from the observation st and the context c. the encoder output for the observation st is then fed into a binary recurrent layer, serving as memory for the agent. for our experiments, a hidden layer with 16 neurons is sufficient. the output of the recurrent layer is binary, i.e., consists of zeroes and ones. this is an important design aspect since the hidden state of the recurrent layer must be transmitted to the next node. learning a binary representation results in small and concise codes and is a good fit for the distributed representations of information that nns learn [gbb11]. the encoded context netsys 2021 6 / 16 eceasst cat 16 cat ttl 48 30 25 26 20 10 ... 64 policy 1 policy 2 policy n value loop detection mac s ta te a t t im e t c on te xt binary lstm figure 3: nn architecture. each switch has its own policy. except for the policy layer are all weights identical for different switches. the numbers above the layer give their size. is not fed into the recurrent layer since the context is time invariant. the output from context encoder and recurrent layer are then used for different purposes: to predict the value, actions, and to detect loops. since the main purpose of encoder and recurrent layer is the extraction of useful information, we share them between policy and value function. loop detection is an auxiliar task that is utilized during training. the purpose of the loop detection task is to provide additional training for the recurrent layer and encoders to produce a meaningful representation. if the agent is able to discern that it has visited a certain location already, then the agent discriminated between states and memorized them. both skills are important for the task of the agent. the auxiliar task provides additional training to the agent, which can improve the data efficiency, i.e., the agent converges faster to a good policy [mpv+16]. challenges we are facing in the navigation of communication networks is the changing number of actions at each forwarding device and semantical differences between the ”same” action. with a single output layer, the number of actions on each forwarding device must equal the maximum degree in the network. further, some actions are forbidden on nodes that have a smaller degree. the agent then has to learn which actions are admissible on which location. also, the ”same” action, e.g., leave trough port zero, must not be related in a meaningful way. for example, choosing the action ”leave through port 2” will not mean that the agent is moving into a similar direction when choosing it at different forwarding devices. in navigational tasks in the real world, the same action (for example turn left) is related between two successive states. also, forwarding devices are farther apart in communication networks, and information such as the mac address are not necessarily related. in robotics one usually has a constant visual input stream. we address these challenges by proposing an architecture featuring multiple policy layers. one layer for each forwarding device. here we exploit the fact that the agent always knows 7 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning fib neural network parser deparser packet table match out port out port hidden state table miss install rule packet figure 4: data plane of a switch in comnav. upon a table miss, the nn is queried for an output port to a packet. the output is cached in the fib and re-used for subsequent packets of the flow. exactly where it is, which is usually not the case in robotics [mgm+18, mpv+16]. during learning, the weights of the different policy layers can thus be tuned independently, giving credit to the different semantics of actions at different forwarding devices. centralized learning, distributed inference. a packet cannot carry a nn. instead, we propose to distribute the nn across the communication network. a flowagent performs at each time step a forward pass through the encoders and the recurrent layer to the policy and value function, which requires the output of the recurrent layer from the previous time step. we propose to situate the parameters of the nn at the forwarding devices as illustrated in fig. 4. if an agent, i.e., the first packet of a flow arrives at a node, it first gets parsed. during parsing, relevant information such as the context information, i.e., source and destination addresses, as well as the hidden state of the rnn are extracted. then, the forwarding device searches for forwarding rules in its fib. since no such rule exists, the switch then queries the nn. the nn computes an port through which the packet should be send. the switch installs a corresponding rule in its fib. keeping rules for the active set of flows is feasible [hbc+20]. subsequent packets of the flow will match this rule and the nn is not queried again. in addition, the nn updates the hidden state. the deparser writes the new hidden state to the packet. since the output of the recurrent layer is binary, it can be used without further processing. the switch then forwards the packet to the next hop. note that the network devices perform only forward passes, i.e., no backward passes or parameter updates are computed during operation. while inference can happen in a distributed manner, training must be performed in a central location. distributed training would incur a very high overhead, since a lot of information would have to be transmitted between nodes. further, updating the network during operation can lead to unwanted behavior of the network. instead, we rely on the increasing capability to gather data, e.g., provided by network telemetry [hbc+20], in order to obtain real state information from the network and simulate traffic for learning. in this way, the parameters can continuously be updated, adapted to shifting demands, and most important, can be validated wrtt. to consistency of resulting routes. if the updated weights meet corresponding quality criteria, they can be deployed on the forwarding devices. during training, varying network conditions can be simulated netsys 2021 8 / 16 eceasst and learned with the neural architecture. in this way, shifting traffic patterns, larger topological changes, or other optimization objectives can be incroported into the protocol. the routing protocol implemented by the resulting nn then reacts to fast-changing network conditions, such as link failures, changes in the utilization of the network, and traffic patterns. one limitation of using a nn in the data plane is the large amount of inference steps that must be performed to keep line rate. recent work suggests, that even today’s asics are capable of executing small nns at line rate [sb18]. thus, we believe that per-flow inference is possible, even for larger networks. 5 evaluation we consider two scenarios as use-cases for our approach: learning to evade congested links and learning to navigate flows with different properties. topology setting: in both cases, we use the abilene network [knf+11] as topology. fig. 7 shows the abilene network topology. based on publicly available data, we added autonomous systems (ases) to the abilene network from which traffic originates during our evaluation. learning setting: for both set-ups, we use a3c with 16 cores and train the network with 10 000 flows per core. at every location, the observation st consists of the utilization of the ports at the forwarding device, and a binary identifier for the in port. utilization is represented using zero-one-hot encoding based on fortz et.al [ft02] and passed through an encoder consisting of two fully connected layers with 30 and 25 neurons and rectified linear unit (relu) activation. the port identifier is passed to the recurrent layer implemented by a long-short-term-memory (lstm) rnn [hs97] with 16 binary hidden neurons. the context c consists of a one-hotencoding for the source and destination node, which is passed separately through an encoder with 20 and 10 neurons and sigmoidal activation. the two outputs are then concatenated together to a vector with 20 elements. for the policies, we use a linear layer consuming the combined output of context encoder and lstm with softmax activation. for the value function, we use a linear layer with a single output neuron. similarly, for the loop-detection, we use a linear layer with single output neuron with a sigmoid activation. during our experiment, we experienced the problem that the agent quickly converged to a sub-optimal policy. to mitigate this risk, we additionally introduce random actions to increase the exploration and let the agent discover a better strategy. 5.1 learning to evade in this scenario, the agent starts at nysernet connected to new-york and has to navigate the network to pacific wave connected to seattle. the objective is to minimize the fct. in the uncongested case, the best fct is obtained via the path new-york chicago indianapolis kansas city denver seattle. in the congested case, the flow is slowed down on the link indianapolis kansas city, and the best path becomes new-york washington atlanta houston los-angeles sunnyvale seattle. we train the agent for both scenarios: 50 % of the trained cases contain congestion on the link indianapolis kansas city, while the other half does not. fig. 5a shows the discounted reward of the agent, and illustrates the learning progress; it shows 9 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning 5000 10000 number of flows 2.5 5.0 7.5 r ew ar d congested uncongested (a) reward 5000 10000 number of flows 10 20 p at h l en gt h congested uncongested (b) path length figure 5: reward for the agent learning to evade a bottleneck link. 0 5000 10000 number of flows 2 4 r ew ar d small big (a) reward 0 5000 10000 number of flows 5 10 p at h l en gt h small big (b) path length figure 6: reward for the agent learning to differentiate between different flow patterns based on the source and destination. that after approximately 2 000 flows the agent has converged to a stable solution, since the reward does not increase anymore. fig. 5b shows the path length, which drops as the reward increases. the difference between the congested and uncongested case is only marginally as indicated by the overlapping lines. the agent has learned to avoid the link between indianapolis and denver when it is congested. the agent thereby chooses the path new-york chicago indianapolis atlanta houston los-angeles sunnyvale seattle as alternative. this result can be explained by the fact that the agent has no means of knowing at new-york city that the link between indianapolis and kansas city is congested. in the absence of additional information, the best choice is indeed to first travel to indianapolis and then decide based on the conditions there. the agent is very confident in making that decision. in the congested case, the agent chooses with probability one to travel to atlanta; whereas for the uncongested case the agent chooses to travel to kansas city with 87 % probability, and to atlanta with 12 % probability. those numbers do not change when the agent has more trials. 5.2 learning to differentiate in this scenario, two flows start from the oregon gigaport connected to sunnyvale and pacific wave 2 connected to los-angeles towards pacific wave connected to seattle. netsys 2021 10 / 16 eceasst seattle sunnyvale los angeles houston atlanta atlam5 washington new-york city chicago indianapolis kansas city denver nysernet pacific wave oregon gigaport pacific wave 2 figure 7: abilene topology. with additionally attached autonomous systems. we now assume different applications behind the flows. flows originating at pacific wave 2 are assumed to be mostly larger downloads, whereas flows originating from the oregon gigaport are small flows. we increase the utilization on the link between sunnyvale and seattle, such that the larger flows from pacific wave experience significant transmission delay, while the flows from the oregon gigaport are small enough to experience no significant delay. thus, flows from pacific wave 2 should take a detour over denver in order to obtain a shorter fct. fig. 6a illustrates the learning progress of the a3c agents. the reward converges after approximately 5 000 flows. fig 6b illustrates how the agent finds the shorter path for the smaller, and the longer path for the larger agent. interestingly, the larger agent learned to take the correct path after only 2 000 flows, while the short flow took longer to converge. after the training ended, the two agents are very confident, taking the correct path with probability one. thus, the agent learned to associate certain sources with specific flow properties and exploited this knowledge when navigating the network 6 related work 6.1 routing and traffic engineering there exist many routing and traffic engineering (te) solutions that address various challenges and cope with different problems [nr17]. solutions range from using well-established protocols such as ospf [crs16] over new centralized designs [arr+10, baaz11, zcy+16, hkm+13, jkm+13, kmsb14, lsyr11, lvc+16, zcb+15] to distributed protocols [kksb07, mt14, aed+14] that can also utilize data plane programmability [hbc+20]. in contrast, comnavis a routing system in which relevant parts of the protocol are learned and implemented with a nn. comnavlearns forwarding rules autonomously with rl. comnav relies on the flexibility of data-plane programmability to realize the nn in the data plane. 11 / 16 volume 080 (2021) navigating communication networks with deep reinforcement learning 6.2 ml and networking combinations of ml and networking have been explored from different angles [bsl+18]. beside applications like traffic prediction [cwg16] and classification [emaw07, eam06, rrs20], also optimization of reconfigurable topologies [wcx+18, ssc+18], queue management [sz07, zdcg09, clcl18] and implementation of routing schemes have been addressed [mam19, gc18, xmw+20, ylx+20, bl94, vsst17, cy96]. in particular for routing schemes, there are several approaches considering centralized as well as distributed implementations. our work differs from previous work in the flow-centric perspective, the resulting formulation of the underlying problem as a congestion game, and the explicit design of the neural architecture with binary hidden layers and multi-head policies. previous work, especially [ylx+20] relies on large, realvalued vectors that need to be exchanged between nodes, which is impractical in practice. the same is true for the online learning of nn weights. in contrast, comnav learns the weights during a training phase and exchanges only 16 bits of information between nodes. 6.3 navigation work in [mpv+16] considers the navigation of complex mazes with rich structure using an endto-end deep rl based approach that learns directly from pixels. in a later work, [mgm+18] design a deep learning based system that is able to reliably navigate in large cities over long distances. they also showed that the learned skills can be transferred to other cities. in our work, we consider the navigation of communication networks which are quite different from real world navigational tasks. in communication networks, the agent cannot carry its intelligence by itself, also, actions have a completely different semantic between forwarding devices. 7 conclusion we presented comnav, a novel routing architecture that is motivated by programmable dataplanes and machine learning. in comnav, artificial flowagents successfully learn to traverse a communication network, accounting for the state at nodes and traffic characteristics to decide their path. flowagents query binary recurrent neural networks situated at forwarding devices for their next hop. the hidden state of the rnn is piggy-backed on packets, allowing them to memorize their route as well as encountered network conditions. we find that 16 bits are enough to successfully navigate a network. we showcase with two examples the ability of flows, i.e., agents to learn, solely based on information locally available at nodes, which path to take. this limits the action space of the agents and allows distributed inference by placing a forward model at each forwarding device. we understand our work as a first step and believe that our vision opens many interesting directions for future research. for example, it would be interesting to see whether skills obtained on one topology can be transferred to another one. another avenue of research could be to further explore and exploit the connection between our approach and game theory (and its formal guarantees). finally, the performance of the proposed approach could be evaluated in a testbed to explore its limits. netsys 2021 12 / 16 eceasst bibliography [aed+14] m. alizadeh, t. edsall, s. dharmapurikar, r. vaidyanathan, k. chu, a. fingerhut, v. t. lam, f. matus, r. pan, n. yadav, g. varghese. conga: distributed congestion-aware load balancing for datacenters. sigcomm comput. commun. rev. 44(4):503–514, aug. 2014. doi:10.1145/2740070.2626316 [arr+10] m. al-fares, s. radhakrishnan, b. raghavan, n. huang, a. vahdat. hedera: dynamic flow scheduling for data center networks. in nsdi 2010. pp. 281–296. san jose, ca, usa, 2010. [baaz11] t. benson, a. anand, a. akella, m. zhang. microte: fine grained traffic engineering for data centers. in conext ’11. pp. 8:1–8:12. acm, new york, ny, usa, 2011. doi:10.1145/2079296.2079304 [bl94] j. a. boyan, m. l. littman. packet routing in dynamically changing networks: a reinforcement learning approach. in nips 6. pp. 671–678. morgan kaufmann, 1994. [bsl+18] r. boutaba, m. a. salahuddin, n. limam, s. ayoubi, n. shahriar, f. estradasolano, o. m. caicedo. a comprehensive survey on machine learning for networking: evolution, applications and research opportunities. jisa 9(1):1–99, 2018. [clcl18] l. chen, j. lingys, k. chen, f. liu. auto: scaling deep reinforcement learning for datacenter-scale automatic traffic optimization. in sigcom’ 18. pp. 191–205. budapest, hungary, 2018. [crs16] m. chiesa, g. rétvári, m. schapira. lying your way to better traffic engineering. in conext’ 16. pp. 391–398. 2016. [cwg16] z. chen, j. wen, y. geng. predicting future traffic using hidden markov models. in icnp. pp. 1–6. 2016. [cy96] s. choi, d.-y. yeung. predictive q-routing: a memory-based reinforcement learning approach to adaptive tra c control. nips 8:945–951, 1996. [eam06] j. erman, m. arlitt, a. mahanti. traffic classification using clustering algorithms. in sc2d’ 06. pp. 281–286. 2006. [emaw07] j. erman, a. mahanti, m. arlitt, c. williamson. identifying and discriminating between web and peer-to-peer traffic in the network core. in www. pp. 883–892. 2007. [fgs07] a. förster, a. graves, j. schmidhuber. rnn-based learning of compact maps for efficient robot localization. in esann. 2007. 13 / 16 volume 080 (2021) http://dx.doi.org/10.1145/2740070.2626316 http://dx.doi.org/10.1145/2079296.2079304 navigating communication networks with deep reinforcement learning [ft02] b. fortz, m. thorup. optimizing ospf/is-is weights in a changing world. ieee j. sel. areas commun. 20(4):756–767, may 2002. doi:10.1109/jsac.2002.1003042 [gbb11] x. glorot, a. bordes, y. bengio. deep sparse rectifier neural networks. in gordon et al. (eds.), proceedings of the fourteenth international conference on artificial intelligence and statistics. proceedings of machine learning research 15, pp. 315–323. jmlr workshop and conference proceedings, fort lauderdale, fl, usa, 11–13 apr 2011. http://proceedings.mlr.press/v15/glorot11a.html [gc18] f. geyer, g. carle. learning and generating distributed routing protocols using graph-based deep learning. in big-dama ’18. pp. 40–45. acm, budapest, hungary, 2018. export key: geyer2018. doi:10.1145/3229607.3229610 [gd21] s. gronauer, k. diepold. multi-agent deep reinforcement learning: a survey. artificial intelligence review, apr. 2021. doi:10.1007/s10462-021-09996-w [gib92] r. gibbons. a primer in game theory. pearson academic, 1992. [gls17] a. greenwald, j. li, e. sodomka. solving for best responses and equilibria in extensive-form games with reinforcement learning methods. in başkent et al. (eds.), rohit parikh on logic, language and society. pp. 185–226. springer international publishing, cham, 2017. doi:10.1007/978-3-319-47843-2 11 [hbc+20] k.-f. hsu, r. beckett, a. chen, j. rexford, d. walker. contra: a programmable system for performance-aware routing. in nsdi 20. pp. 701–721. 2020. [hkm+13] c.-y. hong, s. kandula, r. mahajan, m. zhang, v. gill, m. nanduri, r. wattenhofer. achieving high utilization with software-driven wan. in sigcomm ’13. pp. 15–26. acm, new york, ny, usa, 2013. doi:10.1145/2486001.2486012 [hs97] s. hochreiter, j. schmidhuber. long short-term memory. neural comput. 9(8):1735–1780, nov. 1997. doi:10.1162/neco.1997.9.8.1735 [jkm+13] s. jain, a. kumar, s. mandal, j. ong, l. poutievski, a. singh, s. venkata, j. wanderer, j. zhou, m. zhu, j. zolla, u. hölzle, s. stuart, a. vahdat. b4: experience with a globally-deployed software defined wan. in sigcomm ’13. pp. 3–14. acm, new york, ny, usa, 2013. doi:10.1145/2486001.2486019 [kksb07] s. kandula, d. katabi, s. sinha, a. berger. dynamic load balancing without packet reordering. acm sigcomm comp. com. rev. 37(2):51–62, 2007. netsys 2021 14 / 16 http://dx.doi.org/10.1109/jsac.2002.1003042 http://proceedings.mlr.press/v15/glorot11a.html http://dx.doi.org/10.1145/3229607.3229610 http://dx.doi.org/10.1007/s10462-021-09996-w http://dx.doi.org/10.1007/978-3-319-47843-2_11 http://dx.doi.org/10.1145/2486001.2486012 http://dx.doi.org/10.1162/neco.1997.9.8.1735 http://dx.doi.org/10.1145/2486001.2486019 eceasst [kmsb14] s. kandula, i. menache, r. schwartz, s. r. babbula. calendaring for wide area networks. in sigcomm ’14. pp. 515–526. acm, new york, ny, usa, 2014. doi:10.1145/2619239.2626336 [knf+11] s. knight, h. nguyen, n. falkner, r. bowden, m. roughan. the internet topology zoo. j-sac 29(9):1765 –1775, october 2011. doi:10.1109/jsac.2011.111002 [kr16] j. f. kurose, k. w. ross. computer networking: a top-down approach. pearson, boston, ma, 7 edition, 2016. [lsyr11] n. laoutaris, m. sirivianos, x. yang, p. rodriguez. inter-datacenter bulk transfers with netstitcher. in sigcomm ’11. pp. 74–85. acm, new york, ny, usa, 2011. doi:10.1145/2018436.2018446 [lvc+16] h. h. liu, r. viswanathan, m. calder, a. akella, r. mahajan, j. padhye, m. zhang. efficiently delivering online services over integrated infrastructure. in nsdi 16. pp. 77–90. usenix association, santa clara, ca, 2016. [mam19] z. mammeri. reinforcement learning based routing in networks: review and classification of approaches. ieee access 7:55916–55950, 2019. [mbm+16] v. mnih, a. p. badia, m. mirza, a. graves, t. p. lillicrap, t. harley, d. silver, k. kavukcuoglu. asynchronous methods for deep reinforcement learning. arxiv preprint arxiv:1602.01783, 2016. http://arxiv.org/abs/1602.01783 [mgm+18] p. mirowski, m. k. grimes, m. malinowski, k. m. hermann, k. anderson, d. teplyashin, k. simonyan, k. kavukcuoglu, a. zisserman, r. hadsell. learning to navigate in cities without a map. arxiv e-prints, mar. 2018. [mpv+16] p. mirowski, r. pascanu, f. viola, h. soyer, a. j. ballard, a. banino, m. denil, r. goroshin, l. sifre, k. kavukcuoglu, d. kumaran, r. hadsell. learning to navigate in complex environments. corr abs/1611.03673, 2016. http://arxiv.org/abs/1611.03673 [mt14] n. michael, a. tang. halo: hop-by-hop adaptive link-state optimal routing. ieee/acm transactions on networking 23(6):1862–1875, 2014. [nr17] m. noormohammadpour, c. s. raghavendra. datacenter traffic control: understanding techniques and tradeoffs. ieee communications surveys & tutorials 20(2):1492–1525, 2017. [rrs20] a. rashelbach, o. rottenstreich, m. silberstein. a computational approach to packet classification. in sigcomm’ 20. pp. 542–556. 2020. [rt02] t. roughgarden, e. tardos. how bad is selfish routing? j. acm 49(2):236–259, mar. 2002. doi:10.1145/506147.506153 15 / 16 volume 080 (2021) http://dx.doi.org/10.1145/2619239.2626336 http://dx.doi.org/10.1109/jsac.2011.111002 http://dx.doi.org/10.1145/2018436.2018446 http://arxiv.org/abs/1602.01783 http://arxiv.org/abs/1611.03673 http://dx.doi.org/10.1145/506147.506153 navigating communication networks with deep reinforcement learning [sb18] g. siracusano, r. bifulco. in-network neural networks. corr abs/1801.05731, 2018. export key: siracusano2018. http://arxiv.org/abs/1801.05731 [ssb18] d. sanvito, g. siracusano, r. bifulco. can the network be the ai accelerator? in proceedings of the 2018 morning workshop on in-network computing. netcompute ’18, pp. 20–25. association for computing machinery, new york, ny, usa, 2018. event-place: budapest, hungary export key: sanvito2018. doi:10.1145/3229591.3229594 https://doi.org/10.1145/3229591.3229594 [ssc+18] s. salman, c. streiffer, h. chen, t. benson, a. kadav. deepconf: automating data center network topologies management with machine learning. in netai. pp. 8–14. 2018. [sz07] j. sun, m. zukerman. an adaptive neuron aqm for a stable internet. in networking. pp. 844–854. 2007. [the12] the open networking foundation. openflow switch specification. jun. 2012. [vsst17] a. valadarsky, m. schapira, d. shahaf, a. tamar. a machine learning approach to routing. corr abs/1708.03074, 2017. http://arxiv.org/abs/1708.03074 [wcx+18] m. wang, y. cui, s. xiao, x. wang, d. yang, k. chen, j. zhu. neural network meets dcn: traffic-driven topology adaptation with deep learning. pomacs 2(2):1–25, 2018. [xmw+20] s. xiao, h. mao, b. wu, w. liu, f. li. neural packet routing. in netai ’20. pp. 28– 34. acm, virtual event, usa, 2020. doi:10.1145/3405671.3405813 [ylx+20] x. you, x. li, y. xu, h. feng, j. zhao, h. yan. toward packet routing with fully distributed multiagent deep reinforcement learning. ieee tnsm, 2020. [zcb+15] h. zhang, k. chen, w. bai, d. han, c. tian, h. wang, h. guan, m. zhang. guaranteeing deadlines for inter-datacenter transfers. in eurosys ’15. pp. 20:1–20:14. acm, new york, ny, usa, 2015. doi:10.1145/2741948.2741957 [zcy+16] h. zhang, l. chen, b. yi, k. chen, m. chowdhury, y. geng. coda: toward automatically identifying and scheduling coflows in the dark. in sigcomm ’16. pp. 160–173. acm, new york, ny, usa, 2016. doi:10.1145/2934872.2934880 [zdcg09] c. zhou, d. di, q. chen, j. guo. an adaptive aqm algorithm based on neuron reinforcement learning. in ieee icca. pp. 1342–1346. 2009. netsys 2021 16 / 16 http://arxiv.org/abs/1801.05731 http://dx.doi.org/10.1145/3229591.3229594 https://doi.org/10.1145/3229591.3229594 http://arxiv.org/abs/1708.03074 http://dx.doi.org/10.1145/3405671.3405813 http://dx.doi.org/10.1145/2741948.2741957 http://dx.doi.org/10.1145/2934872.2934880 introduction vision: navigation vs routing a navigation network model learning to navigate networks evaluation learning to evade learning to differentiate related work routing and traffic engineering ml and networking navigation conclusion formal verification of synchronisation, gossip and environmental effects for wireless sensor networks electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) formal verification of synchronisation, gossip and environmental effects for wireless sensor networks matt webster, michael breza, clare dixon, michael fisher and julie mccann 19 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst formal verification of synchronisation, gossip and environmental effects for wireless sensor networks matt webster1, michael breza2, clare dixon1, michael fisher1 and julie mccann2 1department of computer science, university of liverpool, liverpool, l69 3bx, uk {matt,cldixon,mfisher}@liverpool.ac.uk https://www.liverpool.ac.uk/computer-science/ 2department of computing, imperial college london, london, sw7 2az, uk {mjb04,j.mccann}@doc.ic.ac.uk https://www.imperial.ac.uk/computing abstract: the internet of things (iot) promises a revolution in the monitoring and control of a wide range of applications, from urban water supply networks and precision agriculture food production, to vehicle connectivity and healthcare monitoring. for applications in such critical areas, control software and protocols for iot systems must be verified to be both robust and reliable. two of the largest obstacles to robustness and reliability in iot systems are effects on the hardware caused by environmental conditions, and the choice of parameters used by the protocol. in this paper we use probabilistic model checking to verify that a synchronisation and dissemination protocol for wireless sensor networks (wsns) is correct with respect to its requirements, and is not adversely affected by the environment. we show how the protocol can be converted into a logical model and then analysed using the probabilistic model-checker, prism. using this approach we prove under which circumstances the protocol is guaranteed to synchronise all nodes and disseminate new information to all nodes. we also examine the bounds on synchronisation as the environment changes the performance of the hardware clock, and investigate the scalability constraints of this approach. keywords: internet of things, critical systems, wireless sensor networks, formal verification 1 introduction in this paper we use formal verification, through the logical method of probabilistic modelchecking [fis11], to analyse and verify critical communication protocols used for the internet of things (iot) [yin14]. iot systems often involve networks of small, resource-constrained, computer devices embedded in an environment. these devices have low-power sensors, radios for communication, and can potentially control motors and other devices to perform actuation to change their environment. a common class of iot systems, called wireless sensor networks (wsn), enable the monitoring and control of critical infrastructures made up of large, complex 1 / 19 volume 076 (2019) https://www.liverpool.ac.uk/computer-science/ https://www.imperial.ac.uk/computing formal verification of synchronisation for wireless sensor networks systems such as precision agriculture or smart water networks. such systems require control software that can synchronise the events of the nodes in the system, and disseminate parameters and code updates. wsn and iot deployments are increasingly mobile, allowing for wider applications and new challenges in their design and deployment [nln+16, mrj+07]. a key problem with the development of critical iot systems is ensuring that they will function correctly, or at least, fail in a way that is non-destructive to the systems that they monitor and control. the use of probabilistic models is crucial because it allows us to quantitatively analyse the system with the dynamical effects caused by the environment — one of the most significant causes of failure for wsns [lbv06]. wsns deployed on critical infrastructure suffer from the effects of cyber-physical interactions in a way not seen with office or domestic computing. environmental conditions such as precipitation or changes in temperature will affect the performance of the sensor nodes, and can degrade the wsn potentially causing node failure. the control software that provides event synchronisation and controls message dissemination needs to be programmed to be reliable in the light of these potential problems. errors here can make the infrastructure itself inefficient at best, or even unstable and failing in the worst case. 1.1 formal verification and probabilistic model checking in prism formal methods are a family of techniques used to verify software and hardware, typically using mathematical, proof-based approaches [fis11]. these include techniques such as automated theorem proving [fit96], in which full mathematical proof is carried out, and model checking [bk08], in which every state of a model (also known as the model’s state space) can be examined exhaustively. formal methods allow for formal verification, where models of software and hardware systems can be proved to satisfy certain requirements. these requirements are typically provided using a precise formal logical language such as temporal logic [fis11]. in this paper we use probabilistic model-checking [knp11], a variant of traditional model-checking that allows for probabilities to be incorporated into a model, and for quantitative analyses to be carried out on such models. the probabilistic model checker, prism [knp11, par18], consists of two parts: a modeling language, and a model checker. the prism modeling language can be used to specify the behaviour of a probabilistic finite state automaton (p-fsa), which can then be formally verified via the model checker. for example, we can model a simple sensor node in the prism version 4.4 modelling language as follows: module sensornode state: [0..1] init 0; [] state=0 -> 0.99: (state’=0) + 0.01: (state’=1); [] state=1 -> 0.99: (state’=1) + 0.01: (state’=0); endmodule this sensor node is modelled as a module in prism. we have one variable, ‘state’, which can be set to 0 or 1 (which we define as representing ‘transmit’ and ‘idle’ respectively). note that we define an initial state of 0 for this variable. there are two lines denoting commands. the first command says that if the state is 0, then remain in state 0 with probability 0.99 or transition to state 1 with probability 0.01. the second command is similar, but with 0 and 1 reversed. in avocs 2018 2 / 19 eceasst general, commands take the form [s] guard -> p1 : u1 +...+pn : un; where pi are probabilities and ui are lists of variable updates. in the case where only one list of updates is made with probability 1.0, a simpler form is used (e.g., [s] guard -> u;). the letter s denotes an optional synchronisation. synchronised commands execute simultaneously with synchronisation commands from other modules that share the same label, and can be used for inter-module communication. another way for modules to communicate is via the use of local variables, which can be read by all modules, as well as global variables which can be read by, and written by, all modules. multiple modules can be specified within a prism model. models are executed by selecting non-deterministically a command (from any module) whose guard evaluates to true. if there are no commands whose guards are true, then the model has reached a fixed point and will stop executing. once a formal model has been developed in the prism language, it can be formally verified, with respect to some requirement, using the prism model checker. prism requirements can be formalised as properties using logical languages such as probabilistic computation tree logic (pctl∗) and probabilistic linear temporal logic (p–ltl) [bk08]. different logics allow different kinds of properties to be specified. in this paper we will use pctl∗ to specify properties. pctl∗ is based on a discrete formulation of time as a tree-like structure, starting from a particular point and extending into the future. the following are well-formed pctl∗ formulae: ‘ p’, meaning that p is true; ‘¬p’, meaning that p is false; ‘ p =⇒ q’, meaning if p is true then q is true; p∧q’, meaning that both p and q are true; ‘f p’, meaning p is true now or at some point in the future; and ‘g p’, meaning p is true now and at every point in the future. prism also allows the use of standard numerical operators such as =, ≥ and ≤. formal verification works by analysing the entire state space of a model in order to determine whether a particular property holds. for example, for the sensor node model above, we can use pctl∗ to specify the probability that sensor node is eventually in the ‘idle’ state: p=?[f (state = 1)] we can then use prism model checker to determine that this probability is 1.0: p=?[f (state = 1)] = 1.0 more complex properties can be formed, e.g., the following property says that the probability that the model will always be in the ‘idle’ state eventually is 1.0: p=?[g f (state = 1)] = 1.0 this kind of property is said to specify the probability that the model is in the ‘idle’ state infinitely often. 3 / 19 volume 076 (2019) formal verification of synchronisation for wireless sensor networks 2 related work formal methods have been used previously for design and analysis of wsn and iot. for example, chen et al. [czz+13] provide a survey of a number of approaches to formal verification of routing protocols for wsns. kim et al. [kklb17] conduct a formal security analysis of an authorization toolkit for the internet of things using the alloy verification tool. mouradian & augé–blum [ma13] describe the formal verification of real-time wsn protocols using the uppaal model checker. tobarra et al. [tcc09] use the avispa model checking tool to formally verify a security protocol for wsns. usman et al. [umw13] demonstrate formal verification of mobile agent-based anomaly detection for wsns using the symbolic analysis laboratory model checking tool. dong et al. [dss+08] use a formal specification language for sensor networks and perform formal verification using sat-solvers. however, none of these approaches uses a probabilistic model checker, as is the case in this paper, to determine the probability of success or failure for particular requirements. fruth [fru11] used prism to analyse contention resolution and slot allocation protocols for wsns, but not synchronisation or dissemination protocols. synchronization [gld+17b, gld+17a, psh99] and gossip protocols [bbfh07, fg06, knp08, hss08, kat08, cpr08] have been formally verified but not together, and not accounting for environmental effects. mohsin et al. [msha17] used prism to formally assess security risks in iot systems, but not risks due to the environment. modelling of embedded systems and the environment have been explored by baresi et al. [bbk+15], who used a uml-based mades approach to model a system, and by basile et al. [bdg17], who performed statistical model checking of an energysaving cyber-physical system using uppaal smc. these approaches can find when constraints are not met, but do not perform an exhaustive search of the entire state space, as is the case here. boano et al. explored the effects of temperature on cpu processing time and transceiver performance though templab, a wsn test-bed which allows for the manipulation of the temperature of each individual sensor node [bzb+14]. lenzen et al. [lsw09] studied the effect of temperature on the hardware clocks chips used as timers on many common wsn sensor node platforms. 3 modelling a wsn protocol in prism it is possible to model various wsn protocols in prism. in order to illustrate the approach, we create a model of a non-trivial decentralised wsn management protocol known as figo (an abbreviation of firefly–gossip) [bm08]. figo enables synchronisation of different sensors’ clocks in order to unify the measurement of time across the network based on firefly-like synchronisation. figo also enables consensus on key information between nodes via gossiping, in which nodes pass on new information to their neighbors. figo was chosen because it is a simple protocol that contains elements, such as epidemic propagation [jmb05], found in more complex protocols like trickle [llwc03] and rpl [bra12]. avocs 2018 4 / 19 eceasst 3.1 the firefly-gossip (figo) protocol current techniques for large-scale computer management are not suitable for wsns due to the unreliable nature of the nodes and their networks. a potential solution is to use management protocols, such as figo, that scale well and are robust to the failure of individual nodes. in applications such as precision agriculture [uais14, omr15], wireless nodes need to be synchronised to be able to deliver time-correlated samples of data such as moisture levels and temperature, and to analyse the data. if the analysis shows a problem, control messages need to be sent to nodes with actuators, e.g., to increase irrigation in a drought, or decrease it if a particular disease is discovered. synchronisation of wsns is essential in many applications, for example in adaptive sensing for smart water networks [kyam16]. wsns allow urban water providers to monitor the water flow to match customer demand. synchronisation enables the sensor nodes to measure, communicate and aggregate the flow rates and water pressure data. a control algorithm on the actuator nodes can open or close valves to stabilise water flow for the network, or re-route water in the case of a major leak. importantly, the control software can also disseminate new control algorithms or critical security updates to all the sensing and actuation nodes via gossiping. figo is typical of a class of algorithms that combine firefly synchronisation [wtp+05] and gossip protocols [jmb05] into a single epidemic process [bm08]. this mixture of synchronisation and dissemination processes is used to bring the internal states of wsn nodes to a stable, global equilibrium where all nodes are synchronised with respect to both time and metadata. experiments have shown such protocols to be both scalable and resilient to individual node failure [bm08, bre13, bm17]. a typical figo algorithm is shown in figure 1. figo algorithms have been deployed for the synchronisation and management of several wsn deployments run by the adaptive emergent systems engineering group at imperial college1. for example, they were used to organise pollution sensors for an experiment with mobile data mules as part of an imperial college grand challenge project, and to synchronise and control the sampling rate for a rainfall monitoring sensor network as part of a floodplain monitoring project done in collaboration with the imperial college department of civil engineering. they are currently undergoing evaluation for deployment across the liverpool sensor city iot-x/lorawan network2. 3.2 a prism model of figo a prism model of figo was developed precisely capturing the control flow of the algorithm in figure 1. the algorithm begins with a number of variable assignments which are directly translated into variable assignments in prism. some of the variables are not updated at all in the model, so these are set as global constants in prism, e.g.: const int cyclelength = 100; const int refractoryperiod = floor(cyclelength/2); the main loop of the algorithm is then divided into a number of phases. for example, the transmit phase corresponds to the if-statement in lines 9 to 14. the next if-statement consists of 1 http://wp.doc.ic.ac.uk/aese/ 2 http://www.sensorcity.co.uk/ 5 / 19 volume 076 (2019) http://wp.doc.ic.ac.uk/aese/ http://www.sensorcity.co.uk/ formal verification of synchronisation for wireless sensor networks figure 1: phases of the figo gossip–synchronisation algorithm. a number of nested if-statements called clockcheck, listen, sync1, sync2, and so on. the final phase corresponds to the final if-statement in the main loop and is called updateclock. these phases are defined as global constants and are used as the values of a local variable s1phase which contains the currently-executing phase: s1phase : [0..7] init transmit; note that s1phase refers to the phase of the first sensor node module, which is called s1. the phases of other sensors (sensors s2, s3, etc.) are called s2phase, s3phase, etc. when one phase has finished executing the next phase is chosen according to the control flow of the algorithm in figure 1. for example, during the sync1 phase in lines 17 to 19 the algorithm checks whether the clock is outside a ‘refractory period’ set to half of the cycle length. if it is, then the sensor updates its clock to the average of its own clock and the clock of the other sensor. avocs 2018 6 / 19 eceasst the ‘circular average’ is used, in which the average of 90 and 10 are 0 (with respect to the clock cycle of length 100), rather than 50. the circular average ensures that the update to the clock variable moves it closer to the clock of the other sensor. in the prism model, this behaviour is shown in the following three commands: [] s1phase=sync1 & s1localclock>=refractoryperiod & diff<=floor(cyclelength/2) -> (s1localclock’=s1avg1) & (s1phase’=sync2); [] s1phase=sync1 & s1localclock>=refractoryperiod & diff>floor(cyclelength/2) -> (s1localclock’=s1avg2) & (s1phase’=sync2); [] s1phase=sync1 & !( s1localclock>=refractoryperiod ) -> (s1phase’=sync2); the first two commands say that if the sensor is in the sync1 phase and the clock is greater than or equal to refractoryperiod, then set s1’s clock to the circular average of s1’s clock and s2’s clock. the third command says that if these conditions are not set, then proceed to the next phase of the algorithm, sync2. the sensor which we have modelled here is called s1. to model communication between sensor nodes we need at least one more sensor in the model, s2. the sensor s2 is exactly the same as s1, except all references to ‘s1’ in the code are modified to ‘s2.’ communication in the model is achieved asynchronously through the use of inboxes: when a sensor sends a message to another sensor it does so by leaving the message in an inbox, which can then be read by the receiving sensor when it is ready to do so. the resulting combined model is around 140 lines of code long including variable declarations, and can be found in the online repository3. this prism model is an almost direct translation from the pseudocode to prism and has not been optimised for formal verification. 4 formal verification of figo using prism we build a formal model in prism, in a manner analogous to compiling a program: the source code, in this case the prism model, is automatically converted into a mathematical model, essentially a finite state structure. during this construction, prism calculates the set of states reachable from the initial state and the transition matrix which represents a probabilistic finite state automaton. building revealed that the full model consisted of 4,680,914 reachable states, with 9,361,828 transitions between those states, and took 21 minutes on an intel core i7-3720qm cpu @ 2.60ghz laptop, with 16 gb of memory, running ubuntu linux 16.04. as we shall see in section 4.1, it was possible to reduce the size of this model significantly. one of the key features of prism is that it can find the probability of a particular property holding through some path through a computation tree. for example, we can create a property to determine the probability that eventually the two sensors are synchronised: p=?[f (s1clock = s2clock)] = 1.0 [23.8s] (1) in this case the probability is 1.0, meaning that on all paths through the model the clocks will eventually synchronise. (the time taken for model checking was 23.8 seconds.) that is not to say that they remain synchronised, or that they become synchronised again once they are no 3 http://livrepository.liverpool.ac.uk/3021710/ 7 / 19 volume 076 (2019) http://livrepository.liverpool.ac.uk/3021710/ formal verification of synchronisation for wireless sensor networks longer synchronised. if we wish to verify the latter, that synchronisation happens repeatedly, then we can create a probability with a different formula: p=?[g f s1clock = s2clock] = 1.0 [100s] (2) this probability, in which synchronisation occurs infinitely often, is 1.0. we can strengthen the property further: we can determine the probability that, once the clocks are synchronised, they remain synchronised: p=?[f g s1clock = s2clock] = 0.0 [75.6s] (3) in this case the probability of this property being true is 0.0, meaning that it is never the case that the two clocks synchronise and then remain synchronised forever. the reason this is so can be seen by examining a simulation, or trace, of the model. (a simulation is a sample path or execution of the model [par18].) below is a simulation of the model showing how de-synchronisation occurs after synchronisation: action s1phase s1clock s2phase s2clock s1 updateclock 4 updateclock 4 s2 updateclock 4 transmit 5 s2 transmit 5 transmit 5 the table shows the values of certain state variables during an execution of the model. the leftmost column, ‘action’, shows which module, s1 or s2, is currently executing. in the first state, both clocks have the value ‘4’ and are synchronised. however, a transition occurs in which one of the sensors, in this case, s2, increments its clock value resulting in de-synchronisation. however, in the next state we can see that the sensor s1 updates its clock as well, resulting in synchronisation. we might postulate that once synchronisation occurs, then de-synchronisation will occur at some point. this can be encoded as the following property: p=? [ g ( s1clock = s2clock =⇒ f ¬(s1clock = s2clock) ) ] = 1.0 [123s] (4) we can also verify whether once de-synchronisation has happened, that synchronisation will eventually happen: p=? [ g ( ¬(s1clock = s2clock) =⇒ f s1clock = s2clock ) ] = 1.0 [175s] (5) property 1 tells us that synchronisation will occur at some point during the execution of the model and property 2 tells us that synchronisation will occur infinitely often. properties 4 and 5 tell us even more: that periods of synchronisation are separated by periods of de-synchronisation, and vice versa. avocs 2018 8 / 19 eceasst 4.1 increasing the model’s accuracy examining simulations using prism reveals that clocks will rapidly de-synchronise after synchronisation, as we saw in the previous section. this is a result of the way clocks were handled in this model: we allowed for clocks to tick at any rate. therefore it is possible for clocks to tick unevenly, as in this case. in fact, it is possible for one clock to tick indefinitely without the other clock ticking. this assumption of the model can be seen to correlate with a real-world sensor system in which clocks are unreliable and may vary widely in comparative speeds. the figo sensor network we are modelling is based on the ‘micaz’ sensor mote developed by memsic inc. [mem18] the network is homogeneous across nodes, meaning that the same hardware and software is present on each node. this includes the microcontroller, in this case the ‘atmega128l’ developed by atmel corporation [atm18]. this microcontroller has a clock speed of 16 mhz and operates at up to 16 million instructions per second. as the network is homogeneous we can model the clock speed as constant across different nodes. in practice, and as we shall see in section 5, clock speeds are never exactly the same. however, treating the clock speeds as constant is much closer to reality than one clock being able to tick indefinitely without the other ticking. clock speeds were made constant by introducing synchronisations in the updateclock phase: [tick] s1phase=updateclock & s1clock (s1clock’=s1clock+1) & (s1phase’=transmit); [tick] s1phase=updateclock & s1clock=cyclelength -> (s1clock’=0) & (s1samecount’=0) & (s1phase’=transmit); the first command says that if the clock is less than the cycle length (equal to 99 in this model), then increment the clock, but if the clock is equal to 99, then reset the clock to zero. these commands both use a synchronisation label, tick, and correspond to a similar set of commands in the s2 sensor module, which use the same label. the label means that one of these commands must execute at the same time as one of the corresponding commands in the s2 module. since these commands handle clock updates, this ensures that the clocks will update synchronously, and therefore it is impossible for one clock to tick faster than the other. this models more closely the homogeneous network on which figo is used. one advantage of constant clock speeds is that it reduces the total number of states of the probabilistic model. in this case the model reduced in size from 4,680,914 states with 9,361,828 transitions to 8,870 states and 13,855 transitions. the time taken for model building also decreased, from 21 minutes to 17 minutes. property 1 was formally verified for this revised model: p=?[f s1clock = s2clock] = 1.0 [5.4s] (6) in the definition of the figo algorithm, the variable nextbroadcast is assigned a random value between 0 and 99. during model translation, however, this random value was modified to a constant integer value. we used prism variables to automatically check every possible value of nextbroadcast. this is done by removing the values of the global constants that represent the next broadcast value. then, prism can be used to perform automatic, and exhaustive, modelchecking of a property across a range of values for these constants, by automatically building and verifying a model for each value. however, the prism model has a large verification time 9 / 19 volume 076 (2019) formal verification of synchronisation for wireless sensor networks of 17 minutes. prism needs to build a model for each value of the two variables above, meaning that 10,000 models would need to be constructed, each taking 17 minutes. to reduce the size of the model the duty cycle length was reduced from 100 to 20. this reduces the size of the model to 1,947 states and 3,040 transitions, and takes 16.8 seconds to build. the duty cycle length can be reduced from 100 to 20 without significantly affecting the accuracy of the model, as there is still a large enough range of possible values to allow for an accurate depiction of clock synchronisation via circular averaging. property 2 was verified with a range of [0,20] for both variables, modelling every possible combination of the two nextbroadcast values. the results showed that the probability that synchronisation will occur infinitely often is always 1.0. 4.2 gossip and synchronisation the properties examined thus far have concerned clock synchronisation. the other main function of the figo algorithm is to spread information across a network using a gossip protocol in which sensors tell their neighbours about new information. in the case of the figo algorithm, this is represented by an integer variable whose initial value is zero, but which may increase when a node is updated with a new piece of information. this captures a common function of wsns that must share new information, roll-out software updates, etc. in order to analyse metadata synchronisation the model was modified to allow new metadata values. this was done by creating a branching point during the updateclock phase of the algorithm: [tick] s1phase=updateclock & s1clock=cyclelength & s1metadata<3 -> (1-pupdatemetadata): (s1clock’=0) & (s1samecount’=0) & (s1phase’=transmit) + pupdatemetadata: (s1clock’=0) & (s1samecount’=0) & (s1metadata’=s1metadata+1) & (s1phase’=transmit); the metadata can take any value from 0 to 3, representing a sequence of three possible updates. this updated command allows the metadata to be incremented at the point the duty cycle ends. this happens with probability pupdatemetadata which is equal to 0.5, a value chosen to represent that new metadata will happen, on average, every other duty cycle. therefore the probability that the metadata will not be updated at the end of the duty cycle is also 0.5. this functionality is included in s1, but not in s2, to model a sensor node that receives updates first. for example, this could be the sensor node located closest to an engineer who is updating node software, which will therefore receive an update first. adding this branch point to the model introduces new states for the various values of the local metadata variables. this increased the size of the model from 1,947 states and 3,040 transitions to 4,776 states and 7,467 transitions for a model with a duty cycle of 20. it is now possible to form properties that verify the gossip part of the figo algorithm. for example: p=?[f s1metadata = s2metadata] = 1.0 [0.041s] (7) this formula says that the probability that the metadata is eventually synchronised across nodes is 1.0. as is the case with software version numbers, the metadata increases but never decreases, avocs 2018 10 / 19 eceasst i.e., once it reaches 3 it stays at 3. therefore it can also be verified that at some point the metadata is synchronised (e.g., when it is equal to 3) and remains so: p=?[f g s1metadata = s2metadata] = 1.0 [2.0s] (8) furthermore, we can verify that the firefly and gossip parts of the algorithm both work, and that eventually the two sensors will by synchronised on both time and metadata, and will remain so: p=? [ f g ( s1metadata = s2metadata ∧ s1clock = s2clock ) ] = 1.0 [1.6s] (9) to examine the scalability of the model, the two-sensor network was extended to three and four sensors. a complete graph topology was used, so that every node can communicate with every other node. a range of clock duty cycle lengths was examined for 2–, 3– and 4–sensor networks. the aim was to see how the total time to verify property 2 (including build and verification time) was affected. the results are summarised in figure 2. figure 2: total time for formal verification of property 2 for 2– and 3–sensor networks. the 2– and 3–sensor networks could be verified formally with a clock cycle length of up to 100 for 2-sensor networks, and 28 for 3–sensor networks. however, the 4–sensor network could not be analysed at all. the amount of time taken to verify this property increases with cycle length, and increases significantly with the number of sensors (see figure 2). this is due to a state space explosion [cknz12] occurring as a result of a larger number of large variables occurring in the model (e.g., the duty cycle has a range of up to 100 for each sensor). the state space also increases with cycle length due to increased non-determinism in the model: the larger the duty cycles for the clocks of each sensor, the more combinations of these clock values there are in the model. all of the probabilities for property 2 for the different network and duty cycle sizes were found to be 1.0, showing that synchronisation happens infinitely often in all the cases examined. it should be noted that these results only pertain to the model examined in this paper, and other models and protocols may permit larger sensor networks to be analysed. while state space explosion is a recurrent theme in model checking, it can be mitigated through abstraction and re-modelling to reduce the size of the state space. 11 / 19 volume 076 (2019) formal verification of synchronisation for wireless sensor networks -10 0 10 20 30 temperature (°c) 921.809 921.810 921.811 921.812 921.813 921.814 921.815 f re q u e n cy ( kh z) node 1 figure 3: mica2 hardware clock frequency for different ambient temperatures [lsw09]. 5 environmental effects on hardware microcontrollers such as the atmega128l [atm18] are often set to process instructions at a particular speed, known as the clock speed. (here, the clock speed refers to the clock internal to the microcontroller, not the clock used in the figo algorithm.) these clock speeds can vary slightly due to environmental conditions (principally temperature). laboratory tests with synchronised micaz [mem18] sensor nodes, which use the atmega128l controller, have revealed that the drift in clock speed can be pronounced over a period of hours. lenzen et al. [lsw09] studied the effect of varying ambient temperature on the clock speed of a ‘mica2’ node, which uses the same processor as the micaz node used in this paper. it was found that drift was up to one microsecond per second for a difference of five degrees celsius (see figure 3). using the raw data from [lsw09] it was determined that at 0.0 degrees celsius the operating frequency was 921,814 hz, and at 30.0 degrees celsius the frequency was 921,810 hz. therefore, for each tick of the clock, the amount of time taken per tick for a processor at 30.0 degrees celsius will be 1.000004339 times longer than for a clock at 0.0 celsius. eventually the warmer clock will lag the colder clock by one whole tick, i.e., the colder clock will have ticked twice and the warmer clock will have ticked once. suppose that clock c1 has ticked n1 times, with each tick having length l1. then, after a period of time, the total time elapsed is n1l1. similarly for clock c2, after n2 ticks the total time elapsed is n2l2. after a period of time, the clocks will tick in unison, so that n1l1 = n2l2. suppose that clock c2 has ticked exactly once more than c1, so that n1 = n2 + 1. therefore we know that (n2 + 1)l1 = n2l2. if we let c1 be the colder clock, and c2 be the warmer clock, then we know that c2’s tick is 1.000004339 times longer that the tick of c1, so that l2 = 1.000004339l1. therefore (n2 + 1)l1 = 1.000004339l1n2. therefore n2 = 230,467, and we know that after 230,468 ticks of c2’s clock it will be exactly one tick behind c1’s clock. therefore, on average, every 230,468 ticks, the warmer clock will lag behind the colder one by one whole tick. we can convert this to a probability, 1 in 230,468, or 0.000004339, which can be incorporated into the prism model: [tick] s1phase=updateclock & s1clock=1 -> (1-pclockdrift): (s1clock’=s1clock+1) & (s1phase’=start) + pclockdrift: (s1clock’=s1clock+2) & (s1phase’=start); this command says that if it is time to update the clock, then increase the clock value by 1 with probability 1−pclockdrift, or by 2 with probability pclockdrift, where pclockdrift = avocs 2018 12 / 19 eceasst 0.0004339. note that pclockdrift is 100×0.000004339. this is because clock drift is modelled as happening once per duty cycle (specifically, when s1clock = 1), which is every hundred clock ticks. this helps reduce the state space because this branching point can only happen once per duty cycle, rather than on every tick. note that the clock is increased by 2 when clock drift occurs. this is to ensure that the clock drifts only once per duty cycle — if the clock was increased by 0 (representing a slower clock rather than a faster one) then the precondition of this command would be true on the next iteration of the algorithm meaning that the clock could drift more than once in the duty cycle. as clock drift can be modelled either by one clock slowing by one tick, or the other clock speeding up by one tick, the accuracy of the model is not affected. it is possible to calculate the effect of clock drift on the stability of clock synchronisation. one way to do this is use a steady-state probability in prism, denoted s=?[s], which is the probability that a model is in a particular state s at any given time. for example it was found that: s=?[s1clock = s2clock] = 0.996709321 [0.5s] (10) i.e., the probability that the model is in a synchronised state is equal to 0.996709321. that is to say, 99.67% of the time the model is in a synchronised state. it should be noted that the numerical methods normally used to determine the steady state probabilities in prism were not suitable in this case, as they either did not converge or returned a value of 1.0 after a very short execution time, indicating a possible problem with the use of the numerical method. one possible reason for this is the closeness of the probability of clock drift to zero. instead, ‘exact model checking’ was used, a technique in which the model checker builds the state space explicitly, and returns a probability based on the number of states matching the specified formula divided by the total number of states. exact model checking is not enabled by default as it requires a lot of time and memory [par18], but in this case the model was sufficiently small to allow its use. experiments with different values for pclockdrift showed that the steady state probability of synchronisation is dependent on the clock drift rate. if the clock drifts more often, then the model will spend less time in a synchronised state. the varying clock drift rates due to ambient temperature were examined to determine the effect on synchronisation of operating at varying temperatures. various clock speeds were taken from the data in lenzen et al. [lsw09] corresponding to different temperatures. these were compared against a base clock speed of 921,814.624 hz. this value was chosen as it was the highest frequency observed, and it occurred at approximately zero degrees celsius. therefore the drift rates in our experiment were relative to a reference node operating at that temperature. figure 4 shows the effect on synchronisation between two nodes when one node is at zero degrees celsius, and a second node is at a varying ambient temperature between −12.48 degrees celsius and 30.48 degrees celsius. it can be seen that the steady-state probability never drops below 0.9959677566, and decreases with increased difference in temperature between the two nodes. the shape of the curve closely matches that in figure 3, as expected. 13 / 19 volume 076 (2019) formal verification of synchronisation for wireless sensor networks figure 4: probability of synchronisation for varying temperatures of a second node. 6 conclusions and future work we have shown how formal methods, in particular probabilistic model checking using prism, can be used to model and verify protocols used in critical iot systems. models were developed based on a straightforward translation from a pseudocode-style language into the prism modelling language. key requirements of a gossip–synchronisation algorithm were encoded using probabilistic computation tree logic (pctl∗) and then verified formally using prism. these requirements included clock synchronisation, metadata synchronisation and steady-state probability of synchronisation. environmental effects, such as temperature, can affect a wsn node’s hardware and cause clock drift. we have explored the use of formal verification to quantify the extent to which clock drift affects the synchronisation of wsn nodes. results such as these can be useful for system designers who may wish to adjust the parameters of figo, or even develop new algorithms, to better cope with sources of unreliability such as clock drift. these new algorithms can then be verified formally in a similar way to that described in this paper. we have also demonstrated that state space explosion is a key challenge in the formal verification of wsns. state space explosion issues are common when using model checkers like prism [cknz12], and the results in figure 2 are typical. however, it is often possible to compensate for state space issues through the use of abstraction and re-modelling. for example, rather than modelling the algorithm completely for each sensor, we could model it in detail for a single sensor, and model the rest of the network of n nodes with a second module in prism. in doing so the module size would be kept to a minimum, but would still allow for verification of the behaviour of the node in response to a network. a possible application of this approach would be to verify how long a particular sensor node takes to synchronise with an already-synchronised network. another possibility is to use a population model (e.g., [gld+17b, gld+17a]), in which sensors are not modelled in detail, but rather the whole network, or several sub-networks, are modelled in order to verify properties concerning overall sensor network behaviour. these approaches, which could also be applied to investigate different sensor network topologies, are intended for future work. another way to compensate for state space explosion is to complement model checking with other verification methods, e.g., simulation. for example, sensor networks consisting of thousands of nodes can be analysed by simulation software [bre13]. of course, the disadvantage of simulation is that it does not allow exhaustive examination of the state space, and is therefore prone to missing highly improbable events that can be detected using model checking: so-called avocs 2018 14 / 19 eceasst ‘black swans’ [tal07]. however, this can be mitigated through analysis of sufficiently large numbers of simulations, as is the case with statistical model checking [ldb10, ap18]. naturally, we advocate the use of a range of different methods of verification for critical iot systems, as their different characteristics are often complementary. our intention is to extend this approach beyond specific synchronisation and distribution algorithms, through the generation of a more general approach to critical iot systems design. such systems have commonly-used programming archetypes, such as sense–compute–send cycles for sensor nodes, or clock duty cycles. formal modelling of these elements is often straightforward and could potentially be automated. in addition, simulation, algorithm animation, testing and a range of formal verification elements could all be included in a single tool to provide a strong and useful apparatus for the exploration and analysis of a range of design decisions. while there is much work still to be done to facilitate this, the research reported in this paper shows how certain design choices can be explored in a more precise, formal way. acknowledgements: the authors would like to thank philipp sommer for the experimental data from [lsw09]. this work was supported by the epsrc-funded programme grant s4 (ep/n007565/1) and the fair-space (ep/r026092/1), rain (ep/r026084/1). and orca (ep/r026173/1) rai hubs. bibliography [ap18] g. agha, k. palmskog. a survey of statistical model checking. acm transactions on modelling and computer simulation 28(1):6:1–6:39, 2018. doi:10.1145/3158668 [atm18] atmel corporation. atmega128l: 8-bit atmel microcontroller with 128 kbytes insystem programmable flash. http://www.atmel.com/images/doc2467.pdf, 2018. last accessed 6/4/18. [bbfh07] r. bakhshi, f. bonnet, w. fokkink, b. haverkort. formal analysis techniques for gossiping protocols. acm sigops operating systems review 41(5):28–36, oct. 2007. doi:10.1145/1317379.1317385 [bbk+15] l. baresi, g. blohm, d. kolovos, n. matragkas, a. motta, r. paige, a. radjenovic, m. rossi. formal verification and validation of embedded systems: the uml-based mades approach. software & systems modeling 14(1):343–363, feb 2015. doi:10.1007/s10270-013-0330-z [bdg17] d. basile, f. di giandomenico, s. gnesi. statistical model checking of an energysaving cyber-physical system in the railway domain. in proceedings of the symposium on applied computing. sac ’17, pp. 1356–1363. acm, new york, ny, usa, 2017. doi:10.1145/3019612.3019824 15 / 19 volume 076 (2019) http://dx.doi.org/10.1145/3158668 http://www.atmel.com/images/doc2467.pdf http://dx.doi.org/10.1145/1317379.1317385 http://dx.doi.org/10.1007/s10270-013-0330-z http://dx.doi.org/10.1145/3019612.3019824 formal verification of synchronisation for wireless sensor networks [bk08] c. baier, j.-p. katoen. principles of model checking. mit press, 2008. [bm08] m. breza, j. a. mccann. lessons in implementing bio-inspired algorithms on wireless sensor networks. in 2008 nasa/esa conference on adaptive hardware and systems. pp. 271–276. june 2008. doi:10.1109/ahs.2008.72 [bm17] m. breza, j. mccann. polite broadcast gossip for iot configuration management. in 3rd international workshop on sensors and smart cities. 2017. [bra12] brandt, a., et al. rpl: ipv6 routing protocol for low-power and lossy networks. rfc 6550, 2012. doi:10.17487/rfc6550 [bre13] m. breza. bio-inspired tools for a distributed wireless sensor network operating system. phd thesis, imperial college, london, 2013. [bzb+14] c. boano, m. zúñiga, j. brown, u. roedig, c. keppitiyagama, k. römer. templab: a testbed infrastructure to study the impact of temperature on wireless sensor networks. in proceedings of the 13th international symposium on information processing in sensor networks. pp. 95–106. 2014. [cknz12] e. m. clarke, w. klieber, m. nováček, p. zuliani. model checking and the state explosion problem. in tools for practical software verification. volume 7682, pp. 1–30. springer lncs, 2012. [cpr08] p. crouzen, j. van de pol, a. rensink. applying formal methods to gossiping networks with mcrl and groove. sigmetrics perform. eval. rev. 36(3):7–16, nov. 2008. doi:10.1145/1481506.1481510 [czz+13] z. chen, d. zhang, r. zhu, y. ma, p. yin, f. xie. a review of automated formal verification of ad hoc routing protocols for wireless sensor networks. sensor letters 11(5):752–764, 2013. [dss+08] j. s. dong, j. sun, j. sun, k. taguchi, x. zhang. specifying and verifying sensor networks: an experiment of formal methods. in liu et al. (eds.), 10th international conference on formal engineering methods, icfem 2008, kitakyushu-city, japan, october 27-31, 2008. pp. 318–337. springer, 2008. http://dx.doi.org/10.1007/978-3-540-88194-0_20 [fg06] a. fehnker, p. gao. formal verification and simulation for performance analysis for probabilistic broadcast protocols. pp. 128–141. springer, 2006. http://dx.doi.org/10.1007/11814764_12 [fis11] m. fisher. an introduction to practical formal methods using temporal logic. wiley, 2011. avocs 2018 16 / 19 http://dx.doi.org/10.1109/ahs.2008.72 http://dx.doi.org/10.17487/rfc6550 http://dx.doi.org/10.1145/1481506.1481510 http://dx.doi.org/10.1007/978-3-540-88194-0_20 http://dx.doi.org/10.1007/11814764_12 eceasst [fit96] m. fitting. first-order logic and automated theorem proving. springer, 1996. [fru11] m. fruth. formal methods for the analysis of wireless network protocols. phd thesis, university of oxford, 2011. [gld+17a] p. gainer, s. linker, c. dixon, u. hustadt, m. fisher. investigating parametric influence on discrete synchronisation protocols using quantitative model checking. in proceedings of qest 2017. volume 10503, pp. 224–239. springer lncs, 2017. [gld+17b] p. gainer, s. linker, c. dixon, u. hustadt, m. fisher. the power of synchronisation: formal analysis of power consumption in networks of pulse-coupled oscillators. arxiv e-prints, 2017. https://arxiv.org/abs/1709.04385. last accessed 23/5/18. [hss08] b. r. haverkort, m. siegle, m. van steen. quantitative analysis of gossiping protocols. sigmetrics perform. eval. rev. 36(3):2, 2008. doi:10.1145/1481506.1481508 [jmb05] m. jelasity, a. montresor, o. babaoglu. gossip-based aggregation in large dynamic networks. acm transactions on computer systems 23(3):219–252, 2005. [kat08] j.-p. katoen. how to model and analyze gossiping protocols? sigmetrics perform. eval. rev. 36(3):3–6, nov. 2008. doi:10.1145/1481506.1481509 [kklb17] h. kim, e. kang, e. a. lee, d. broman. a toolkit for construction of authorization service infrastructure for the internet of things. in proceedings of the second international conference on internet-of-things design and implementation, iotdi 2017, pittsburgh, pa, usa, april 18-21, 2017. pp. 147–158. acm, 2017. doi:10.1145/3054977.3054980 [knp08] m. kwiatkowska, g. norman, d. parker. analysis of a gossip protocol in prism. sigmetrics performance evaluation review 36(3):17–22, nov. 2008. doi:10.1145/1481506.1481511 [knp11] m. kwiatkowska, g. norman, d. parker. prism 4.0: verification of probabilistic real-time systems. in proc. 23rd international conference on computer aided verification (cav’11). lncs 6806, pp. 585–591. springer, 2011. [kyam16] s. kartakis, w. yu, r. akhavan, j. a. mccann. adaptive edge analytics for distributed networked control of water systems. in 2016 ieee first international conference on internet-of-things design and implementation (iotdi). pp. 72–82. 2016. [lbv06] k. langendoen, a. baggio, o. visser. murphy loves potatoes: experiences from a pilot sensor network deployment in precision agriculture. in 20th international parallel and distributed processing symposium. 2006. 17 / 19 volume 076 (2019) https://arxiv.org/abs/1709.04385 http://dx.doi.org/10.1145/1481506.1481508 http://dx.doi.org/10.1145/1481506.1481509 http://dx.doi.org/10.1145/3054977.3054980 http://dx.doi.org/10.1145/1481506.1481511 formal verification of synchronisation for wireless sensor networks [ldb10] a. legay, b. delahaye, s. bensalem. statistical model checking: an overview. in barringer et al. (eds.), runtime verification. pp. 122–135. springer, 2010. [llwc03] p. levis, n. lee, m. welsh, d. culler. tossim: accurate and scalable simulation of entire tinyos applications. in proceedings of the 1st international conference on embedded networked sensor systems. pp. 126–137. 2003. [lsw09] c. lenzen, p. sommer, r. wattenhofer. optimal clock synchronization in networks. in proceedings of the 7th acm conference on embedded networked sensor systems. sensys ’09, pp. 225–238. acm, new york, ny, usa, 2009. doi:10.1145/1644038.1644061 [ma13] a. mouradian, i. augé-blum. formal verification of real-time wireless sensor networks protocols with realistic radio links. in proceedings of the 21st international conference on real-time networks and systems. pp. 213–222. 2013. [mem18] memsic, inc. micaz wireless measurement system. http://www.memsic.com/ userfiles/files/datasheets/wsn/micaz_datasheet-t.pdf, 2018. last accessed 6/4/18. [mrj+07] s. a. munir, b. ren, w. jiao, b. wang, d. xie, j. ma. mobile wireless sensor network: architecture and enabling technologies for ubiquitous computing. in proceedings of the 21st international conference on advanced information networking and applications workshops. ainaw ’07 2, pp. 113–120. ieee, washington, dc, usa, 2007. doi:10.1109/ainaw.2007.257 [msha17] m. mohsin, m. sardar, o. hasan, z. anwar. iotriskanalyzer: a probabilistic model checking based framework for formal risk analytics of the internet of things. ieee access 5:5494–5505, 2017. [nln+16] k. nahrstedt, h. li, p. nguyen, s. chang, l. h. vu. internet of mobile things: mobility-driven challenges, designs and implementations. in first ieee international conference on internet-of-things design and implementation, iotdi 2016, berlin, germany, april 4-8, 2016. pp. 25–36. 2016. doi:10.1109/iotdi.2015.41 [omr15] t. ojha, s. misra, n. s. raghuwanshi. wireless sensor networks for agriculture: the state-of-the-art in practice and future challenges. computers and electronics in agriculture 118:66–84, 2015. [par18] d. parker. prism 4.4 manual. department of computer science, university of oxford, april 2018. http://www.prismmodelchecker.org/manual/main/welcome. last accessed 18/4/18. [psh99] h. pfeifer, d. schwier, f. w. von henke. formal verification for time-triggered clock synchronization. in 7th ifip international working conference on dependable computing for critical applications (dcca-7). pp. 207–226. ieee, 1999. avocs 2018 18 / 19 http://dx.doi.org/10.1145/1644038.1644061 http://www.memsic.com/userfiles/files/datasheets/wsn/micaz_datasheet-t.pdf http://www.memsic.com/userfiles/files/datasheets/wsn/micaz_datasheet-t.pdf http://dx.doi.org/10.1109/ainaw.2007.257 http://dx.doi.org/10.1109/iotdi.2015.41 http://www.prismmodelchecker.org/manual/main/welcome eceasst [tal07] n. n. taleb. the black swan: the impact of the highly improbable. penguin books, 2007. [tcc09] l. tobarra, d. cazorla, f. cuartero. security in wireless sensor networks: a formal approach. in from problem toward solution: wireless sensor networks security. chapter 8, pp. 145–164. nova, 2009. [uais14] a. ur-rehman, a. z. abbasi, n. islam, z. a. shaikh. a review of wireless sensors and networks’ applications in agriculture. computer standards & interfaces 36(2):263–270, 2014. [umw13] m. usman, v. muthukkumarasamy, x.-w. wu. formal verification of mobile agent based anomaly detection in wireless sensor networks. in 8th ieee workshop on network security. pp. 1001–1009. ieee, 2013. doi:10.1109/lcnw.2013.6758544 [wtp+05] g. werner-allen, g. tewari, a. patel, m. welsh, r. nagpal. firefly-inspired sensor network synchronicity with realistic radio effects. in proceedings of the 3rd international conference on embedded networked sensor systems. pp. 142–153. 2005. [yin14] yinbiao, s. et al. internet of things: wireless sensor networks. international electrotechnical commission white paper, july 2014. http://www.iec.ch/whitepaper/ pdf/iecwp-internetofthings-lr-en.pdf. last accessed 23/5/18. 19 / 19 volume 076 (2019) http://dx.doi.org/10.1109/lcnw.2013.6758544 http://www.iec.ch/whitepaper/pdf/iecwp-internetofthings-lr-en.pdf http://www.iec.ch/whitepaper/pdf/iecwp-internetofthings-lr-en.pdf introduction formal verification and probabilistic model checking in prism related work modelling a wsn protocol in prism the firefly-gossip (figo) protocol a prism model of figo formal verification of figo using prism increasing the model's accuracy gossip and synchronisation environmental effects on hardware conclusions and future work towards qoe-driven optimization of multi-dimensional content streaming electronic communications of the easst volume 080 (2021) conference on networked systems 2021 (netsys 2021) towards qoe-driven optimization of multi-dimensional content streaming yassin alkhalili, jannis weil, anam tahir, tobias meuser, boris koldehofe, andreas mauthe, heinz koeppl and ralf steinmetz 15 pages guest editors: andreas blenk, mathias fischer, stefan fischer, horst hellbrueck, oliver hohlfeld, andreas kassler, koojana kuladinithi, winfried lamersdorf, olaf landsiedel, andreas timm-giel, alexey vinel eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst towards qoe-driven optimization of multi-dimensional content streaming yassin alkhalili1∗, jannis weil1∗, anam tahir2∗, tobias meuser1, boris koldehofe3, andreas mauthe4, heinz koeppl2 and ralf steinmetz1 1 {yassin.alkhalili, jannis.weil, tobias.meuser, ralf.steinmetz}@kom.tu-darmstadt.de multimedia communications lab, technical university of darmstadt, germany 2 {anam.tahir, heinz.koeppl}@bcs.tu-darmstadt.de bioinspired communication systems lab, technical university of darmstadt, germany 3 b.koldehofe@rug.nl university of groningen, the netherlands 4 mauthe@uni-koblenz.de university of koblenz-landau, germany ∗ these authors contributed equally abstract: whereas adaptive video streaming for 2d video is well established and frequently used in streaming services, adaptation for emerging higher-dimensional content, such as point clouds, is still a research issue. moreover, how to optimize resource usage in streaming services that support multiple content types of different dimensions and level of interactivity has so far not been sufficiently studied. learning-based approaches aim to optimize the streaming experience according to user needs. they predict quality metrics and try to find system parameters maximizing them given the current network conditions. with this paper, we show how to approach content and network adaption driven by quality of experience (qoe) for multi-dimensional content. we describe components required to create a system adapting multiple streams of different content types simultaneously, identify research gaps and propose potential next steps. keywords: multimedia streaming, in-network processing, reinforcement learning, quality of experience 1 introduction higher-dimensional content forms the basis of many multimedia applications, especially in the recently emerging domain of virtual and mixed reality [aggs20]. its use cases include telepresence with three-dimensional avatars and interactive objects, training and education in medicine, virtual property inspection, watching sports with a clear view, and playing video games. in the last few years, there has been an increased interest towards qoe enhancements of applications using higher-dimensional content [gpb+20], which adds additional parameters that need 1 / 15 volume 080 (2021) mailto:yassin.alkhalili@kom.tu-darmstadt.de mailto: jannis.weil@kom.tu-darmstadt.de mailto: tobias.meuser@kom.tu-darmstadt.de mailto: ralf.steinmetz@kom.tu-darmstadt.de mailto:anam.tahir@bcs.tu-darmstadt.de mailto: heinz.koeppl@bcs.tu-darmstadt.de mailto:b.koldehofe@rug.nl mailto:mauthe@uni-koblenz.de towards qoe-driven optimization of multi-dimensional content streaming to be considered. in this paper, we use the term multi-dimensional (md) content encompassing lower-dimensional content types, like 2d video, and higher-dimensional content types, like point clouds. it has been that the advancement from conventional 2d video to higher-dimensional content, increases the required computational and network resources. at the same time, the level of user interactivity and immersiveness also increases [ptb+20]. to quantify a content type’s level of interactivity, we use degree of freedom (dof). dof represents the number of independent variables a user can control to interact with the content. the 2d video has a dof of 0 since it does not allow the users to interact with the content beyond changing the playback state. users watching a 360-degree video can rotate their heads along three axes (3-dof) and interaction with point clouds can additionally allow for movement in 3d space (6-dof). point clouds are a collection of points in the 3d space, each having a number of properties, including point coordinates along (x, y, and z) axes, color values encoded in rgb format, and several others. these points can be used to reconstruct a 3d object or an entire scene formed of numerous points. point clouds can be captured using specialized cameras and depth sensors and can hold up to millions of points to depict high-quality reconstructed objects. using these point clouds, the objects can be rendered from any viewing angle enabling a higher level of immersive viewing experience in comparison to 360-degree video. an increasing level of interactivity increases the difficulty of predicting which part of the content the users are going to consume next, thus reducing the performance of standard caching algorithms [pit+18]. the transmission of higher-dimensional content through the network is much more resourceintensive than 2d content since the data volume increases manifold. despite the increased capacity over the last years, the network resources are still limited and higher-dimensional content types put a much higher strain on them. because of the direct interaction, the latency requirements are stricter for higher-dimensional content as well. for example, the authors in [rk15] show that latency greater than 20ms can lead to cybersickness in virtual reality (vr) applications. in the context of traditional 2d streaming, quality of service (qos) is used to adapt the stream, by using measure network metrics such as jitter, latency, throughput, and packet loss rates. however, even for 2d content, it has been realized that the experience of the user cannot solely be captured by qos parameters. qoe is a more user-oriented measure for the more subjectively perceived quality of a service [int08]. there are many approaches that aim to improve the qoe of 2d video but finding a qoe metric which correctly reflects the requirements of higher-dimensional content types is still an open and challenging research area. the concept of adaptation using mechanism transitions [awb+19] can be leveraged for efficient streaming. the term mechanism refers to the algorithms used to process or transmit the content from the content providers to the end-user. multiple mechanisms can fulfill the same purpose while using a different amount of network resources and may lead to different levels of qoe. switching from one mechanism to another is called a transition and can be used to adapt to changing network conditions and user interactivity, in order to maintain the qoe for the user. for example, h.264 and hevc/h.265 are two different types of video encoding mechanisms. h.265 compresses images more aggressively which reduces the bandwidth requirements but consequently, it requires almost ten times more computing power than h.264 [sm16]. even though h.264 uses fewer resources as compared to h.265, links using h.264 could be overloaded by the much higher bandwidth requirements of 4k video, and thus lead to a decreased qoe for the user [ufšv14]. depending on the available network resources and the requirements of the content netsys 2021 2 / 15 eceasst type, transitions can be done between these two encoding mechanisms (and similarly amongst other available mechanisms) to improve the qoe of the current stream. however, in order to avoid having too much effect on the qoe of other parallel streams in the network, cooperative transitions are necessary. cooperative transitions enable the entities to perform this adaptation collaboratively at multiple locations in the network, given all the available resources and requirements, with the aim that no stream is disadvantaged. hence the aim is to develop a system that adapts to changing network conditions while maintaining the best possible qoe across competing media streams. this will be achieved through the use of cooperative transitions. the main contributions of this paper are (i) the identification of the system architecture for qoe optimization of md content distribution in the context of parallel (or competing) streams and (ii) the highlighting of the research gaps together with initial ideas on how to approach these. the paper is structured as follows: in section 2, we summarize related work regarding network and content adaptations with the aim of achieving a better qos or qoe. in section 3, we describe a general architecture for qoe optimization of md content distribution, highlight the individual research gaps and propose first ideas. we then conclude this paper in section 4. 2 related work the distribution of md content is influenced by (i) network resources and conditions, (ii) the data path(s) from sender to receiver (flow), and (iii) the transmitted content itself. flows are directly affected by the capabilities of the available resources of network nodes and end devices. in order to optimize the qoe, flows and their content can be adapted based on current network conditions, user preferences, and device characteristics. current approaches can be categorized into network adaptation and content adaptation. 2.1 adaptation of the network research on adaptation of the network mainly focuses on routing [shl+19, xtm+18], scheduling [msv+19] and congestion control [jrg+19] to optimize qos metrics like average bandwidth, latency, packet loss and jitter. leveraging reinforcement learning (rl) for network adaptation with respect to qos is well researched [zyk+09]. many recent publications employ deep rl to adapt the network without requiring specific domain knowledge or handcrafted features and heuristics [jrg+19]. for example, sun et al. use rl to create an software-defined networking (sdn) controller that improves the transmission delay in a real network environment by 9% as compared to traditional approaches [shl+19]. achieving a higher qos at the receiver end is possible without changing the content and can also allow for a better qoe. in addition, qoe can also directly be used as an optimization objective to improve the network’s performance. as an example, huang et al. propose to optimize network flows based on the end-to-end qoe of users consuming video streams [hyqr18]. they first create a mean opinion score (mos) model mapping selected qos metrics at the receiver end to a mos value, representing the qoe. the average predicted mos is then used as a reward signal to learn a policy for a sdn controller with rl. they show that learning-based sdn traffic control can outperform selected baselines in terms of achieved qoe. 3 / 15 volume 080 (2021) towards qoe-driven optimization of multi-dimensional content streaming 2.2 adaptation of md content in the area of content adaptation, most publications focus on adaptive video streaming using adaptive bitrates (abr). in dynamic adaptive streaming over http (dash), a video is split into segments of fixed length, e.g. 5 seconds, that are encoded at different quality levels. the client fetches the next video segment for playback and determines a quality level based on the current network conditions. this way, the client can react to network impairments (e.g. a reduction in bandwidth) by lowering the video quality to keep a high qoe. the system pensieve [mna17] leverages rl to construct algorithms for abr video streaming. given some qos metrics representing the current network conditions, the main task of pensieve is to predict the best bitrate for the next video segment with respect to the resulting qoe. it is trained using a simulation environment that aims to represent the basic dynamics of video streaming. the authors show that pensieve is able to outperform state-of-the-art abr schemes on a data set of over 30 hours of network traces and that it even generalizes to unseen networks. using a similar approach, the system deeplive extends this idea to abr live video streaming and is able to outperform pensieve in terms of qoe while having a lower computational overhead [tzn+19]. in the research study puffer [yaz+20], yan et al. argue that qoe-based content adaptation using machine learning is hard because of the unknown network and user behavior. they show that huge testing datasets are required to differentiate between different methods with statistical significance. additionally, their study reveals that the performance achieved in network simulations is not necessarily transferable to the real network. in particular, although pensieve performs well in a simulated environment and was able to deliver good mean qoe values in a comparably small data set, yan et al. show that it does not outperform a simple linear buffer-based control algorithm [hjm+14] when applied to the internet. they propose a new control policy trained in a supervised manner on real traffic information and achieve better qoe than previous approaches. in comparison to the 2d video, the qoe of 360-degree video and especially other interactive md content types like point clouds is not extensively studied. however, quality adaptation schemes for these content types also exist [ams20]. most approaches used for 2d video streaming, like dash, can also be applied to 360-degree video [kg18]. instead of adapting the quality of a whole segment, it is possible to spatially divide the individual 360-degree video frames into smaller tiles [htp+19, krz+19]. fetching only the necessary tiles at adequate quality levels based on the user’s orientation decreases the overall bandwidth requirements, which could allow for better qoe when combined with a good orientation prediction. analogous to pensive for 2d video, there exist approaches leveraging rl to adapt the content in 360-degree streaming applications [zzb+19]. in the case of point cloud streaming, there are many publications that use meta-information about multiple versions of a scene with different quality levels to adaptively stream the content [hwd+19]. extending the idea of dash to point clouds, a client-side heuristic then chooses the most appropriate representation of individual objects or 3d tiles based on the network conditions, client device characteristics, and additional properties like the current viewport. as an example for viewport-based streaming of point clouds, [pch18] splits point clouds into 3d tiles with a different level of detail (lod) similar to the segmentation used in 360-degree video. based on the user’s view frustum, individual tiles of a scene can be either cut off completely or loaded netsys 2021 4 / 15 eceasst with a lower lod. this can reduce the required bandwidth while maintaining the visual fidelity of the scene. moreover, the authors introduce a rate-utility algorithm to distribute the available bandwidth amongst the tiles. to reduce the resource requirements of higher-dimensional content types, the content can also be processed within the network. for example, qian et al. [qhpg19] propose a point cloud streaming system for regular mobile devices. with edge computing, the point cloud stream is transcoded into a regular 2d pixel-based video that can then be efficiently transmitted and decoded by mobile devices, leveraging the existing advancements of adaptive 2d video streaming in terms of software and hardware acceleration. this system also includes qoe-based bitrate and viewport adaptation. in contrast to network and 2d content adaptation, learning-based adaptation appears not to just yet be frequently used in applications featuring interactive higher-dimensional md content. 3 system architecture for md content streaming in this section, we propose a system architecture for md content adaptation based on an example scenario and discuss the challenges and research gaps of its individual components in detail. figure 1 illustrates a scenario with three content providers distributing different types of md content through the network to multiple users. the streams are represented as solid arrows. higher-dimensional content allows users to interact with it, e.g. by turning their head. this is represented by a dotted line headed (toward the respective content provider). flow may pass multiple network domains, which belong to different internet providers and have certain network infrastructure (e.g. specific routers, switches, and servers). each of these network domains employs different in-network processing mechanisms. for example, domain two contains a caching mechanism for 360-degree videos based on viewport prediction. these mechanisms can also transform the flow, e.g. by filtering points of a 3d point cloud [alrk19] or by rendering it as stereo 360-degree images. such in-network processing mechanisms can enable users with low-end devices or weaker network connections to consume the content. however, they can also lead to quality degradation and higher delays in comparison to processing the md content directly on the users’ devices. note that core network functions like routing can also be seen as mechanisms. in a realistic scenario, a content provider will only know its own network domains or the network domains of partners they cooperate with. this means there are also unknown domains that employ non-cooperative mechanisms. these unknown domains forward the md content and affect the qos of respective flows. at the receiving node, the content is consumed by the users. household 1 represents a mixed setting with 2d video and point cloud streaming, there is one mobile device streaming regular 2d video and household 2 contains one end device streaming 360-degree video. users are connected to the internet in various ways, e.g. via 5g, lan, and wi-fi, and use different end devices, e.g. mobile phones, head-mounted devices, and a smart tv. apart from the technical diversity, the users could also have different interaction patterns. for example, a person looking at a virtual exhibition in vr might interact with the content in a more predictable fashion than a person playing a fast-paced adventure game. the qoe of the users depends on their end devices, the level of interactivity, the md content 5 / 15 volume 080 (2021) towards qoe-driven optimization of multi-dimensional content streaming rendering as 360° images caching network domain 1 2d video point cloud viewport predic�on filtering network domain 2 point cloud 360° video md content stream interac�on coopera�on network domain6dof 3dof 0dof unknown networks 5g 2d video point cloud content providers lan 0dof household 2 household 1 bon the go 360° video a a a a users d e adapta�on c d e wifi lan figure 1: three md content types (left) are streamed over multiple network domains (center) to different end users (right). our design compromises five main components to optimise the qoe: a assessment of the user’s qoe, b aggregation of qoe considering fairness and guarantees, c overview of available mechanisms, d a system interface which allows to monitor and interact with the communication system, and e a policy to adapt the system’s behaviour. properties, the current network domain mechanisms, and the qos. these properties are not entirely independent but rather influence each other, e.g. a different end device allows the user to interact with the content in a different way. the goal of each individual content provider is to achieve the highest possible qoe for their consumers. an adaptive system should allow optimizing the qoe with transitions on network and content mechanisms while considering flows of multiple content types in parallel. we identify five main components of such a system, illustrated as yellow circles in figure 1. firstly, it is infeasible to access the ground-truth qoe via user feedback at run-time. hence, we need qoe models a to approximate user experience. as the system should be able to handle multiple md content streams in parallel, the issue of fairness arises [hshv17]. the available resources should be divided between all flows such that a fair qoe can be achieved. therefore, a component b is needed to aggregate individual qoe values to a shared metric, accounting for user preferences and content types. adaptation is carried out by adapting currently applied mechanisms (e.g. changing the bitrate of a video stream) or by transitioning between functionally equivalent mechanisms (e.g. switching between different video encoding mechanisms with different performance and quality implications). this is only possible if there is a component c which allows querying the available transitions together with their effects and the requirements of underlying mechanisms. in order to decide when adaptation is necessary, the system also needs to be aware of the current network conditions. network monitoring is therefore required. further, an abstract representation of the observable network state is necessary. this is facilitated through component d . this information can then be leveraged by a policy e to predict the effect of potential adaptations under the current conditions. using these estimates, individual communication systems can then be adapted independently or cooperatively to improve the qoe. netsys 2021 6 / 15 eceasst the following subsections will discuss each component a to e individually and suggest first steps on how to overcome corresponding challenges. 3.1 qoe models for md content publications in the area of qoe often focus on traditional communication services and 2d video [btb+19]. there are various authors which express qoe based on qos metrics such as the peak signal to noise ratio (psnr) [hwd+19]. in order to estimate the qoe without user studies, it is therefore common practice to create replacements for qoe models based on qos [aw13, am14]. however, to evaluate the actual user experience for md content, user studies are inevitable. measures like mos and likert scales can then be used to quantify the qoe. while a good understanding of qoe already exists for 2d content [ses+15], little is known about the quality factors of higher-dimensional content and their impact on the users [qhpg19]. in addition to traditional coding parameters such as resolution, colour depth, frame rate, affected regions, and quality variations, the qoe of md content must also account for user interactivity and preferences [sks+20]. conducting user studies is the common approach to get direct feedback from the user to quantify qoe. the crucial part of the user studies is the design of the experiment and the questionnaire. in [hpp+17] and [kbhs20], the authors generated 360degree videos that varied in the amount of motion they had, their perceptual quality, and the number of stalling events. they proposed questionnaires to measure the effect of the above variations on the qoe of the user in terms of perceptual quality, presence, acceptability, and cybersickness. mos was used by user studies to answer questions such as, what is the threshold for the compression of videos, what is the impact of resolution while viewing with a head-mount display, is cybersickness an issue or not. however, the investigation of the impact of changing user interactivity on the qoe is still missing in these studies. there is also a need for a quantitative formulation of the qoe in terms of these factors. most of the research for higher-dimensional content is related to 360-degree video. hence, there is a need to conduct user studies for 3d content like point clouds as well because we believe that the above-mentioned factors and conclusions would be different. to the best of our knowledge, the only case of qoe analysis for point clouds is by sharabayko et. al. [sks+20]. here, the authors investigated the impact of two reduction mechanisms on the qoe of images that are generated from the reduced point clouds. two kinds of audiences are involved in the study, which was conducted online with naive crowd workers besides point cloud experts. in a different study [ht18], the authors used a traditional image quality metric, namely psnr, to assess the quality of point cloud objects under the effect of bit rate adaptation of the stream. however, as argued before, psnr is not an appropriate replacement for accessing the actual user qoe. 3.2 qoe fairness for md streams the main goal of the adaptation is to improve the overall qoe with respect to the current network conditions. in the scope of this paper, the overall qoe is composed of the qoe of individual users consuming different md content types. each user should get the best experience possible, but the available resources should be distributed in a fair manner. our notion of fairness refers to qoe fairness across users and md content types. as the qoe metric should be comparable across md 7 / 15 volume 080 (2021) towards qoe-driven optimization of multi-dimensional content streaming content types, this can be seen as a form of human-to-human fairness [bma19]. in other words, multiple users consuming one content type (e.g. 2d video) should have a comparable qoe as users consuming other content types (e.g. point cloud streams). as content types have different resource requirements, this directly implies that there has to be traffic prioritization based on the content type and achievable qoe. apart from the definition of fairness itself, we believe it will also be challenging to establish a qoe notion that is consistent and universally valid across all content types and end devices to facilitate comparisons among these metrics. current approaches considering multiple users often use simple aggregated metrics like the average qoe of all users to measure the overall quality of their adaptation [hyqr18]. such metrics ignore fairness between users. for example, assume there are two users in the network and the qoe ranges from 1 (bad) to 5 (perfect). we can now describe the qoe of both users as a tuple (a, b) where a,b ∈ [1, 5] is the qoe of user a and b respectively. the average qoe of (1, 5) and (3, 3) would be three in both cases. however, (1, 5) can be considered unfair if (3, 3) could be achieved using the available resources. we want to study how to optimize qoe distributions consisting of the qoe of multiple users while considering fairness. fairness is likely connected to the variance of the qoe across users. intuitively, the optimal solution would be a configuration where the variance is zero and all users have the same qoe. in practice, optimality also depends on user preferences. let’s assume the content types of the previous example are (point cloud stream, 2d video). point clouds are expected to have much higher resource requirements and the current network conditions might allow achieving both, (3, 3) and (2.5, 4.5). although (2.5, 4.5) can be considered unfair, a point cloud user might accept a minor drop in quality if this leads to big quality differences for other users. especially if these users live in the same household. therefore, qoe models can be augmented with utility metrics that account for user preferences. they can also be used to define qoe guarantees to avoid situations where too unevenly distributed resources lead to unacceptable levels of qoe for some users. if the qoe falls below a certain threshold, the utility drops to zero. the adaptive system can then distribute network resources based on these utility metrics to achieve a fair qoe. 3.3 mechanism profiles to optimize the qoe based on the current network conditions, some aspects of the content distribution mechanisms have to be adapted. possible adaptations can be categorized as follows: • exchanging mechanisms: a currently used mechanism is replaced with another functionally compatible mechanism (transition [awb+19]), e.g., switching between different video encodings. see sec. 1 for a detailed example. • reconfiguration of existing mechanisms: the underlying mechanism remains the same but certain properties are reconfigured (self-transition [ric18]), e.g., updating routing information or changing the bitrate of a video stream to compensate for bandwidth changes. • adding and removing mechanisms: it is also possible to add and remove mechanisms in a specific flow. for example, a point cloud stream could be compressed between specific nodes. this can be transparent to the rest of the network. netsys 2021 8 / 15 eceasst in a communication system, there are multiple mechanisms running simultaneously and there can be mutual influence among different mechanisms. they can require different network resources and have a varying effect on the content stream and the qoe. hence, there is a need to create mechanism profiles that describe the available mechanisms in a domain, the number of resources they need to give a certain output, and where they can be applied in a specific flow. these profiles should allow estimating the effects a mechanism has on qos. this can then be used to estimate the qoe a mechanism can provide under certain network conditions. the adaptation process e will make use of these mechanism profiles to transition to suitable mechanisms to achieve a fair level of qoe b for all streams present. 3.4 environment for learning and evaluation platforms used in network research can be categorized into real network environments, testbeds, network emulators, and network simulators. each category has its advantages and disadvantages [hhj+12]. real network environments and emulators allow collecting information about real traffic while simulators typically allow for much faster data collection. however, simulators are based on abstract models of the network, thus creating a gap between the simulated and real network environments. behavior learned in simulations might not be transferable to real networks. unfortunately, learning-based approaches often require a huge amount of samples until the training process converges and the adaptive behavior generalizes over unseen samples. solely using real network environments is therefore only possible for big content providers. one of our goals is to create a meta-platform that leverages the advantages of the individual platforms. the core of this meta-platform will be an environment interface, similar to openai gym1 but tailored for network experiments in the domain of md content distribution. the interface should allow to include and combine specific implementations for our components a to e and therefore provide the foundation to support different md content types. this also simplifies the comparison of different approaches as they then use the same main architecture. this platform can then be connected to a network simulator like ns-32, omnet++3 or simonstrator [rsrs15], or used as a wrapper for real network environments. it would allow researchers working in any of these fields to include their systems and profit from potential synergies and easier comparability with existing solutions. learning-based approaches can then be trained and evaluated in both environment types to close the gap between simulations and real networks. for example, an initial version might be trained only using simulators and its fine-tuning could be done in real networks. using the standardized interface, it would also be possible to ground the simulation based on samples collected in real or emulated networks [hs17]. 3.5 adaptation of parallel md streams in reality, communication systems such as servers, routers, schedulers, and caches have limited access and can only carry out actions in their domains based on local observations. they are also limited in the set of actions they can perform. md content distribution depends on the current 1see https://gym.openai.com/ (accessed 28.05.2021). 2see https://www.nsnam.org/ (accessed 28.05.2021). 3see https://omnetpp.org/ (accessed 28.05.2021). 9 / 15 volume 080 (2021) https://gym.openai.com/ https://www.nsnam.org/ https://omnetpp.org/ towards qoe-driven optimization of multi-dimensional content streaming network conditions and user interactivity. there is a need for the communication systems to adapt to different conditions to achieve a good qoe. this adaptation consists of transitions between available mechanisms while accounting for resource and content requirements. the network conditions of a single stream will also be affected by other streams sharing common limited resources (e.g. a home router). therefore, it is desirable to consider cooperation across communication systems serving different content streams. our system architecture can naturally be seen as a rl problem. each transition-capable element in the network is an agent which needs to learn how to adapt to the changing network and user conditions. all these agents will be connected to our environment interface can observe all parts of the network accessible or visible to them. for example, this could include the currently processed or forwarded traffic flows and available resources. based on these observations, the network elements can decide which mechanisms to use for processing their flows and whether there is a need to transition between different mechanisms. these are the agent’s actions. the goal of this adaptation is to successfully fulfill the qoe requirements of all the concurrent users in the network. adaptation decisions must be taken quickly to meet time-critical qoe requirements. this means processing a huge amount of network data and extracting the important information from observations should be done efficiently and with sufficient accuracy. the reward of the system is an aggregated qoe metric considering fairness between multiple streams and qoe guarantees. to solve the adaptation problem, we mainly want to focus on approaches in model-free rl [sb18] that do not require an explicit model of the environment. we expect the dimensionality of the observation and action spaces to be high, therefore approximate solution methods like deep neural networks can be used to represent the agent. alternatively or in addition, the complexity and dimensionality of the adaptation problem itself could also be reduced with approaches such as variational autoencoders [kw14] and principal component analysis [dhb+13]. such methods provide the agent with the key features which are the most influential on the effectiveness of the action, resulting in a faster and more refined decision-making process. another thing to consider while adapting the system is the time and cost of the individual transitions. all actions should have a cost associated with them and do not necessarily show immediate effect after executing them. we believe that considering the temporal behavior of the adaptation could allow for a better transfer of learned behavior to real network environments. this will be especially relevant with respect to fulfilling time-critical qoe guarantees. if each agent keeps optimizing the achievable qoe only in their local network domain, this can lead to local optima. to optimize its own flows, an agent might be selfish and overuse the resources of some other agent, leading to deterioration in the performance of the overall system. we believe that to achieve optimal qoe, these adaptations have to be performed over the entire data path of each flow. achieving this in a centralized manner using one global entity can be computationally costly and does not scale well with an increasing number of flows and agents. thus, a multi-agent system [woo09] modeling is needed to decentralize this decision-making process and achieve better scalability. from the perspective of cooperative game theory [sl08], transition-capable communication systems could form coalitions with each other to achieve better qoe by performing cooperative transitions. these coalitions must take into account the interests of all communication systems, while several md streams are processed by them in parallel. lastly, the network might also contain communication systems using the same limited renetsys 2021 10 / 15 eceasst sources that are not capable of cooperation or transitions. examples would be third-party video streams such as youtube or netflix. while they independently transition between quality levels based on the available bandwidth, they do not provide the functionality to explicitly cooperate with other streams. to perform cooperative transitions in their presence, behavioral estimates [cam11] of these communication systems could help to better predict the network conditions for a reliable adaptation. 4 conclusion in this paper, we first provide a classification of the emerging content types and introduce the notion of md content, comprising content from conventional 2d video to highly interactive 3d multimedia types. in the context of adaptive streaming, we categorize related work into two main categories: adaptation of the network and adaptation of md content. instead of optimizing qos metrics, content adaptation can also be performed with respect to an expected qoe. this allows taking into account the quality actually perceived by the users due to different characteristics of viewing and interacting with the content. while qoe-driven adaptation has been used for lower-dimensional content, modeling qoe of higher-dimensional content and the development of corresponding adaptive streaming techniques is still in its infancy. based on a scenario where multiple users interact with different md content types, this paper describes an adaptive md content streaming system based on five components. this system leverages cooperative transitions for a qoe-driven optimization of parallel md content streams. subsequently, the paper discusses the corresponding challenges and research gaps and provides first ideas on how they could be tackled in the near future. by establishing the bigger picture of adaptive md content streaming, we believe that this paper will facilitate new collaborations and inspire other researchers working in this field. acknowledgements: this work has been co-funded by the german research foundation (dfg) as part of the projects c3 and b1 in the collaborative research center (crc) 1053 maki. bibliography [aggs20] k. ahir, k. govani, r. gajera, m. shah. application on virtual reality for enhanced education learning, military training and sports. augmented human research 5(1):1–9, 2020. [alrk19] y. alkhalili, m. luthra, a. rizk, b. koldehofe. 3-d urban objects detection and classification from point clouds. debs ’19. acm, 2019. [am14] s. aroussi, a. mellouk. survey on machine learning-based qoe-qos correlation models. in 2014 international conference on computing, management and telecommunications (commantel). pp. 200–204. 2014. 11 / 15 volume 080 (2021) towards qoe-driven optimization of multi-dimensional content streaming [ams20] y. alkhalili, t. meuser, r. steinmetz. a survey of volumetric content streaming approaches. in 2020 ieee sixth international conference on multimedia big data (bigmm). pp. 191–199. 2020. [aw13] m. alreshoodi, j. woods. survey on qoe\qos correlation models for multimedia services. arxiv preprint arxiv:1306.0221, 2013. [awb+19] b. alt, m. weckesser, c. becker, m. hollick, s. kar, a. klein, r. klose, r. kluge, h. koeppl, b. koldehofe et al. transitions: a protocol-independent view of the future internet. proceedings of the ieee 107(4):835–846, 2019. [bma19] a. o. basil, m. mu, a. al-sherbaz. a software defined network based research on fairness in multimedia. in proceedings of the 1st international workshop on fairness, accountability, and transparency in multimedia. pp. 11–18. 2019. [btb+19] a. bentaleb, b. taani, a. c. begen, c. timmerer, r. zimmermann. a survey on bitrate adaptation schemes for streaming media over http. ieee communications surveys tutorials 21(1):562–585, 2019. [cam11] c. f. camerer. behavioral game theory: experiments in strategic interaction. princeton university press, 2011. [dhb+13] u. demšar, p. harris, c. brunsdon, a. s. fotheringham, s. mcloone. principal component analysis on spatial data: an overview. annals of the association of american geographers 103(1):106–128, 2013. [gpb+20] s. gül, d. podborski, t. buchholz, t. schierl, c. hellge. low-latency cloud-based volumetric video streaming using head motion prediction. in proceedings of the 30th acm workshop on network and operating systems support for digital audio and video. pp. 27–33. 2020. [hhj+12] n. handigol, b. heller, v. jeyakumar, b. lantz, n. mckeown. reproducible network experiments using container-based emulation. in proceedings of the 8th international conference on emerging networking experiments and technologies. pp. 253–264. 2012. [hjm+14] t.-y. huang, r. johari, n. mckeown, m. trunnell, m. watson. a buffer-based approach to rate adaptation: evidence from a large video streaming service. in proceedings of the 2014 acm conference on sigcomm. pp. 187–198. 2014. [hpp+17] t. huyen, n. pham ngoc, c. pham, y. jung, t. cong thang. a subjective study on qoe of 360 video for vr communication. in 19th ieee int. workshop on multimedia signal processing (mmsp). pp. 1–6. 2017. [hs17] j. hanna, p. stone. grounded action transformation for robot learning in simulation. in proceedings of the aaai conference on artificial intelligence. volume 31(1). 2017. netsys 2021 12 / 15 eceasst [hshv17] t. hoßfeld, l. skorin-kapov, p. e. heegaard, m. varela. definition of qoe fairness in shared systems. ieee communications letters 21(1):184–187, 2017. [ht18] m. hosseini, c. timmerer. dynamic adaptive point cloud streaming. in 23rd packet video workshop (pv). pp. 25–30. 2018. [htp+19] j. van der hooft, m. torres vega, s. petrangeli, t. wauters, f. de turck. tilebased adaptive streaming for virtual reality video. acm transactions on multimedia computing communications and applications 15(4):24, 2019. [hwd+19] j. van der hooft, t. wauters, f. de turck, c. timmerer, h. hellwagner. towards 6dof http adaptive streaming through point cloud compression. in 27th acm int. conference on multimedia (mm). pp. 2405–2413. 2019. [hyqr18] x. huang, t. yuan, g. qiao, y. ren. deep reinforcement learning for multimedia traffic control in software defined networking. ieee network 32(6):35–41, 2018. [int08] international telecommunication union (itu). quality of experience requirements for iptv services. itu-t rec. g.1080, 2008. [jrg+19] n. jay, n. h. rotman, b. godfrey, m. schapira, a. tamar. a deep reinforcement learning perspective on internet congestion control. in proceedings of the 36th international conference on machine learning (icml). volume 97, pp. 3050–3059. 2019. [kbhs20] a. van kasteren, k. brunnström, j. hedlund, c. snijders. quality of experience assessment of 360-degree video. electronic imaging 2020(11):91–1, 2020. [kg18] k. khan, w. goodridge. future dash applications: a survey. int. journal of advanced networking and applications 10(2):3758–3764, 2018. [krz+19] c. koch, a.-t. rak, m. zink, r. steinmetz, a. rizk. transitions of viewport quality adaptation mechanisms in 360 degree video streaming. in 29th acm workshop on network and operating systems support for digital audio and video (nossdav). pp. 14–19. 2019. [kw14] d. p. kingma, m. welling. auto-encoding variational bayes. in 2nd international conference on learning representations (iclr). 2014. [mna17] h. mao, r. netravali, m. alizadeh. neural adaptive video streaming with pensieve. in conference of the acm special interest group on data communication (sigcomm). pp. 197–210. 2017. [msv+19] h. mao, m. schwarzkopf, s. b. venkatakrishnan, z. meng, m. alizadeh. learning scheduling algorithms for data processing clusters. in conference of the acm special interest group on data communication (sigcomm). pp. 270–288. 2019. [pch18] j. park, p. a. chou, j. hwang. volumetric media streaming for augmented reality. in ieee global communications conference (globecom). pp. 1–6. 2018. 13 / 15 volume 080 (2021) towards qoe-driven optimization of multi-dimensional content streaming [pit+18] g. s. paschos, g. iosifidis, m. tao, d. towsley, g. caire. the role of caching in future communication systems and networks. ieee journal on selected areas in communications 36(6):1111–1125, 2018. [ptb+20] a. perkis, c. timmerer, s. baraković, j. b. husić, s. bech, s. bosse, j. botev, k. brunnström, l. cruz, k. de moor et al. qualinet white paper on definitions of immersive media experience (imex). arxiv:2007.07032, 2020. [qhpg19] f. qian, b. han, j. pair, v. gopalakrishnan. toward practical volumetric video streaming on commodity smartphones. in 20th int. workshop on mobile computing systems and applications (hotmobile). pp. 135–140. 2019. [ric18] b. richerzhagen. mechanism transitions in publish/subscribe systems: adaptive event brokering for location-based mobile social applications. springer, 2018. [rk15] k. raaen, i. kjellmo. measuring latency in virtual reality systems. in chorianopoulos et al. (eds.), proc. 14th international conference on entertainment computing (icec). lecture notes in computer science 9353, pp. 457–462. springer, 2015. [rsrs15] b. richerzhagen, d. stingl, j. rückert, r. steinmetz. simonstrator: simulation and prototyping platform for distributed mobile applications. in theodoropoulos (ed.), proceedings of the 8th international conference on simulation tools and techniques, athens, greece, august 24-26, 2015. pp. 99–108. icst/acm, 2015. [sb18] r. s. sutton, a. g. barto. reinforcement learning: an introduction. mit press, 2018. [ses+15] m. seufert, s. egger-lampl, m. slanina, t. zinner, t. hossfeld, p. tran-gia. a survey on quality of experience of http adaptive streaming. ieee communications surveys tutorials 17(1):469–492, 2015. [shl+19] p. sun, y. hu, j. lan, l. tian, m. chen. tide: time-relevant deep reinforcement learning for routing optimization. future gener. comput. syst. 99:401–409, 2019. [sks+20] m. seufert, j. kargl, j. schauer, a. nuchter, t. hossfeld. different points of view: impact of 3d point cloud reduction on qoe of rendered images. in 12th international conference on quality of multimedia experience (qomex). pp. 1–6. 2020. [sl08] y. shoham, k. leyton-brown. multiagent systems: algorithmic, game-theoretic, and logical foundations. cambridge university press, 2008. [sm16] m. sharabayko, n. markov. contemporary video compression standards: h. 265/hevc, vp9, vp10, daala. in 2016 international siberian conference on control and communications (sibcon). pp. 1–4. 2016. netsys 2021 14 / 15 eceasst [tzn+19] z. tian, l. zhao, l. nie, p. chen, s. chen. deeplive: qoe optimization for live video streaming through deep reinforcement learning. in 2019 ieee 25th international conference on parallel and distributed systems (icpads). pp. 827–831. 2019. [ufšv14] m. uhrina, j. frnda, l. ševčı́k, m. vaculik. impact of h. 264/avc and h. 265/hevc compression standards on the video quality for 4k resolution. 2014. [woo09] m. wooldridge. an introduction to multiagent systems. john wiley & sons, 2009. [xtm+18] z. xu, j. tang, j. meng, w. zhang, y. wang, c. h. liu, d. yang. experiencedriven networking: a deep reinforcement learning based approach. in ieee conference on computer communications (infocom). pp. 1871–1879. 2018. [yaz+20] f. y. yan, h. ayers, c. zhu, s. fouladi, j. hong, k. zhang, p. levis, k. winstein. learning in situ: a randomized experiment in video streaming. in 17th usenix symposium on networked systems design and implementation (nsdi 20). pp. 495– 511. 2020. [zyk+09] y. zhou, m. yun, t. kim, a. arora, h.-a. choi. rl-based queue management for qos support in multi-channel multi-radio mesh networks. in 8th ieee int. symposium on network computing and applications (nca). pp. 306–309. 2009. [zzb+19] y. zhang, p. zhao, k. bian, y. liu, l. song, x. li. drl360: 360-degree video streaming with deep reinforcement learning. in ieee conference on computer communications (infocom). pp. 1252–1260. 2019. 15 / 15 volume 080 (2021) introduction related work adaptation of the network adaptation of md content system architecture for md content streaming qoe models for md content qoe fairness for md streams mechanism profiles environment for learning and evaluation adaptation of parallel md streams conclusion proof-oriented design of a separation kernel with minimal trusted computing base electronic communications of the easst volume 076 (2019) automated verification of critical systems 2018 (avocs 2018) proof-oriented design of a separation kernel with minimal trusted computing base narjes jomaa, paolo torrini, david nowak, gilles grimaud and samuel hym 20 pages guest editors: david pichardie, mihaela sighireanu eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst proof-oriented design of a separation kernel with minimal trusted computing base narjes jomaa, paolo torrini, david nowak, gilles grimaud and samuel hym cristal, cnrs & university of lille, france abstract: the development of provably secure os kernels represents a fundamental step in the creation of safe and secure systems. to this aim, we propose the notion of protokernel and an implementation — the pip protokernel — as a separation kernel whose trusted computing base is reduced to its bare bones, essentially providing separation of tasks in memory, on top of which non-influence can be proved. this proof-oriented design allows us to formally prove separation properties on a concrete executable model very close to its automatically extracted c implementation. our design is shown to be realistic as it can execute isolated instances of a realtime embedded system that has moreover been modified to isolate its own processes through the pip services. keywords: protokernel, memory isolation, formal proof, coq 1 introduction the development of provably secure kernels addresses the trusted computing base (tcb) that has privileged access to the hardware, thus playing a fundamental role in the development of secure systems [ast06]. making such development manageable and cost-effective remains a major challenge in formal methods even after major breakthroughs [keh+09, gsc+16]. memory management and isolation are at the core of the functionalities of separation kernels [rus81, zszl17], designed to ensure that users can access resources and communicate with each other only according to a given security policy. the centrality of memory management and access control provides our motivation for introducing the notion of protokernel, as a minimal separation kernel that in fact provides only services related to virtual memory management and context switching between applications. in this paper, we present the development and verification of the pip protokernel [the17b], relying on a comparatively lightweight approach, yet providing an efficient, real-world application. we use coq, a proof assistant based on the calculus of constructions [bc04], to develop the monadic, executable model of the services on top of a hardware abstraction layer, and we prove security properties based on a low-level memory isolation criterion, using hoare logic [the17c]. the model is then automatically translated to a small fragment of c, using an haskell-implemented translator [ho17]. pip has been developed for industrial application as part of a european project1. its development relies on a proof-oriented design, narrowing the tcb needed to implement the kernel services in a machine independent way on top of the hardware abstraction layer. this design, 1 this work was funded by the european celtic-plus project odsi c2014/2-12. 1 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base minimalistic yet efficient, is the result of a collaborative effort with our colleagues from the operating system community (cf. [bgi18, ygg+18, bjy+18] for benchmarks and more details) to support on-demand secure isolation [the17a]. crucially, pip supports efficient memory management and a dynamic notion of memory separation based on a hierarchical tcb architecture, allowing for isolated partitions to be created and removed after initialisation. 1.1 contributions in this paper, we report the formal verification viewpoint of the development of the pip protokernel. we present: 1) a coq model that includes the relied-upon hardware components (memory and mmu), an executable specification of the memory manager supporting hierarchical tcb, and a highly modular api consisting of ten services; 2) a low-level specification of memory isolation; 3) an abstract information flow model which allows us to prove a non-influence result; 4) a verification methodology based on a hoare logic on top of an enhanced state monad, designed to carry out well-structured proofs of memory isolation on the executable model; 5) the application of this methodology to the verification of three of the api services. 1.2 related work the development of secure kernels has been a long-standing goal in the formal methods community [zszl17]. memory separation in its basic form can be characterised in terms of access control. stronger notions of information flow separation have been introduced with the noninterference property [gm82], ensuring that events are not leaked [rus92], and the non-leakage property [vo04], ensuring that data are not leaked. early work on access control policies for the ucla security kernel [wkp80] focused on the verification of an abstract model, stressing the much higher cost of verifying executable code. the notion of separation kernel, originally introduced by rushby [rus81] to ensure information flow separation, is at the foundations of security-oriented kernels based on the mils architecture [ast06] and of safety-oriented ones [zszl16]. sel4 [keh+09] is a microkernel of the l4 family formally verified in isabelle-hol. it provides virtual memory management, thread scheduling, inter-process communication and access control. high-level verification is carried out using hoare logic on a abstract model. an executable specification that refines the abstract model is obtained by automated translation from a haskell prototype. the manually written c implementation is proved to refine the executable specification using an automatic translation of c to isabelle based on the semantics in [tkn07]. the refinement proofs are functional correctness ones, thus quite big, ensuring that the abstract model provides a complete specification of the c behaviour. security properties are proved relying on the abstract model and functional correctness [mmb+13]. prosper is a separation kernel that supports dataflow functionalities of the armv7 processor [dgk+13], including inter-partition communication, scheduling, and in an extended version [sd14] direct memory access. security properties have been proved in hol4. bisimulation is used to carry higher-level proofs, based on an abstract model including communication channels, over to a concrete one based on an intermediate language that represents the arm instruction set [fm10]. avocs 2018 2 / 20 eceasst certikos [gsc+16] provides a certified programming method to formally develop kernels in coq, targeting an extension of compcert clight and assembly code [bl09]. the specification approach is based on certified abstraction layers, corresponding to clight external functions, enhanced with a notion of abstract state, to allow for functional correctness specifications in the code. certikos supports fine-grained layering of programming and verification, relying on a notion of contextual refinement [gkr+15], and it has also been used to prove noninterference results [csg16]. in [bbbt11] the pikeos memory manager is verified at the c source code level using an automated static verifier, proving that initialisation-time partitioning of memory is preserved at runtime. in [bbcl11] a xen-based paravirtualization-style hypervisor is abstractly modelled in coq and information flow separation is proved. in [zszl16] isabelle-hol is used to model abstractly the arinc-653 channel-based inter-partition communication for safety-oriented separation kernels. in [bcg+16] an abstract model of the nova kernel is formalised in coq, data security properties are proved, and program extraction is used to generate testing code. in [sbh14] an abstract security model is formalised in isabelle-hol to verify properties of the xtratum kernel using refinements. 1.3 pip our system relies on a notion of memory separation, on top of which noninterference can be proved for isolated partitions. inter-partition communication and scheduling are not part of pip, and therefore communication policies are not part of the kernel tcb. on the other hand, pip allows for partition reconfiguration at runtime, and tree-like partitioning can naturally support any user tcb hierarchy. the security proof we provide does not rely on any specific architecture, and has been the driving factor in the development. the verification of memory separation is comparatively lightweight, and this has been achieved by avoiding to go through a full functional correctness proof. from the development point of view, pip relies on a separation of concerns between modelling and verification on one side and translation to c on the other. nonetheless, unlike work based on abstract models, pip provides an executable model of its services, written in a shallow embedding of a small fragment of c. indeed, our coq development is based on a direct formalisation of the executable model, relying on consistency properties to capture the abstract requirement in a bottom-up way, following the approach already used in [jngh18] for a simpler system with a flat memory model. the translation of the service layer to c source code is fully automated, and its verification, on which the correctness of the model does not depend, is under way as an independent workload (see [tnjc18] for more discussion of this point). 1.4 outline in section 2 we present the design of pip. in section 3 we present the coq model, including hardware components and partitioning manager. in section 4 we present the security properties and the abstract information flow model. in section 5 we present the isolation proofs and the underlying methodology. conclusions and further work are discussed in section 6. 3 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base 2 proof-oriented design pip is a kind of security kernel conveniently described as a protokernel [the17b, bjy+18, big17], designed to minimize the tcb. the goal of such minimization is twofold: to reduce the attack surface, and to increase the feasibility of a formal proof. pip only provides the hardware management that suffices to enforce security in the form of memory separation: in this sense, we speak of proof-oriented design, emphasising the feedback of theorem-proving in the iterative development of the system. like exokernels [eko95], pip does not offer any higher-level abstraction: in particular, it offers neither threads, nor processes, nor a file-system, nor a network stack. pip provides a runtime environment that is a kind of virtual machine and that we call a partition. on top of that we can implement any high-level abstraction. each partition allows configuring a virtual memory management unit (mmu) and managing virtual interrupt request (irq) via dedicated pip services that form the pip api. using these configuration services, it is possible to port on pip a conventional kernel (e.g. linux) as well as an embedded system (e.g. freertos) or even a hypervisor (e.g. xen). little effort is needed to adapt one of them to run as a partition (see [bjy+18] for details, including more than satisfactory benchmarks), relying on the paravirtualization approach [bdf+03]. pip can be better described as protokernel rather than hypervisor because it does not include multiplexing management, thus reducing the kernel tcb to its bare bone. indeed, in a sense pip runs a single primary partition. this partition, created at boot time, represents the whole and only real machine. pip assigns to it the entire address space (except for the memory used by pip itself) and the whole cpu time (except for the cpu time spent by pip to handle real irqs). nonetheless, pip supports a hierarchical partitioning model, allowing each partition to create its own subpartitions and split part of its own address space between them. this recursively results in the creation of a partition tree whose root is the primary one (henceforth the root partition). the management of the partition tree takes place according to a recursive scheme. only one partition can be executing at each time in a monocore system, but pip does neither multiplex interrupt requests nor share cpu time between distinct partitions. pip only deals with software interrupts that are system calls to its own api. other software interrupts are forwarded to the parent of the caller. on the other hand, all the hardware interrupts are forwarded to the root. in this way, pip delegates multiplexing (i.e. determining the control flow between partitions) to the root, which can implement any possible multiplexing policy, recursively allowing each partition to share cpu time between its children. executing multiplexing in user mode allows us to cut drastically the size of the kernel tcb. on the other hand, the hierarchical architecture allows each partition to rely on the environment managed by its parent and to split its environment between its children. this naturally induces a hierarchical characterisation of the tcb associated with each partition, which can be expressed in terms of a simple transitive policy: each partition only relies on its ancestors and the kernel. the primary purpose of this design is to allow for a cost-effective verification that this policy is enforced, by means of a memory isolation proof. the memory isolation property ensured by pip is based on hardware functionalities that control physical memory accesses. partitions can not use physical addresses: in order to access information they can only use virtual addresses that will be converted to physical ones using the memory management unit. each partition has an mmu configuration, and on every user access, avocs 2018 4 / 20 eceasst the mmu is invoked to decide on whether authorising or rejecting the access. these decisions are based on the configuration pages, called page tables or indirections, written by the kernel so as to allow translation of any given virtual address to the corresponding physical address. in order to guarantee security, page tables should never be accessible by any entity except the kernel. pip satisfies this requirement by construction. partitioning model the physical memory of a computer is split into fixed-size chunks called pages which can be allocated, accessed and used to store information. whenever a partition is created, pip associates it with a page which we call its partition descriptor (pd), denoted by an identifier referred to as pdi. the memory is split between primary kernel pages, solely accessible by the kernel, and user pages, initially assigned to the root partition and accessible by it. when a partition creates a child in the course of its execution, it allocates some of its accessible pages exclusively for that child; in particular, the executing partition hands over to the kernel the sole accessibility of some of the newly allocated pages, to be used for the configuration of the newly created partition; the remaining of those pages, already assigned to the parent are also assigned to the child. in line with the hierarchical model, the executing partition can always delete a child (and with it its descendants). when this happens, the parent regains accessibility to the configuration pages of the descendants. notice that in general, the pages a partition can access are a subset of those assigned to it. we refer to the pages assigned to a partition together with those used for its configuration as the pages allocated for that partition. the api of pip is constituted of ten services that can be called by the executing partition, eight of which are for managing its memory space. createpartition adds a new child to the caller. deletepartition deletes a child and gives all the pages allocated for it back to the caller. addvaddr lends physical memory to a child. removevaddr removes a page from a child. mappedinchild returns the child to which a given page is assigned. prepare gives pages to the kernel to manage a child’s configuration. pagecount computes the number of pages required to configure a child. collect gives pages lent to the kernel back to the calling partition. the remaining two services are for handling irqs. dispatch notifies a partition about a given interrupt. resume restores the context of a previously interrupted partition. fig. 1 serves to illustrate partition management in pip: the available memory makes up the root partition proot. user code running in any partition can use the memory management services exposed by pip to create child partitions, here p1 and p2, lending some of its accessible pages to each of them. for instance, code running in p1 can create p1.1 using available memory in p1. while the parent partition can read and write in the memory accessible by its children (we call this property vertical sharing), it cannot access anymore to the pages given to pip (we obviously want to prevent a partition from messing up pip data structures, we call this property kernel isolation). sibling partitions (i.e. partitions that have the same parent) cannot access each other’s memory (we call this property horizontal isolation). if siblings want to communicate, they cannot do it through shared memory. instead, their parent can use the services of pip to implement a communication protocol, for instance by flipping a memory page between the siblings. for example, as result of horizontal isolation, the partition p1 in figure 1 is disjoint from the 5 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base proot p1 p1.1 p1.1.1 p1.1.2 p1.1.3 p1.2 p1.2.1 p1.2.2 p2 p2.1 p2.2 figure 1: an example of partition tree partition p2. thus, code running in the partition p1 cannot access the memory in the partition p2. moreover, since partitions p1.1 and p1.2 are included in the partition p1, they are also disjoint from the partition p2. however their parent partition p1 can access their memory and the memory of their descendant partitions p1.1.1, . . . , p1.2.2 as result of vertical sharing. 3 the executable specification the development of pip is based on a layered model formalised in coq, as shown in fig. 2. at the top level, the service layer provides a source-code level executable specification of architectureindependent system management functions. the service layer consists of the kernel service api that allows for context switching and partition tree management (ptm) which is the core of the pip engine. the service layer is implemented as an algorithmic model, using the shallow embedding of a c-like fragment based on a monadic encoding, which can be automatically translated to c code. the service layer is built on top of a hardware abstraction layer (hal), including memory abstraction (mal) and interrupt abstraction (ial). the mal itself can be structured into two layers: hardware memory abstraction (hmal) and monadic memory abstraction (mmal). the hmal provides an abstract model of the physical memory and the mmu. the ial is also structured into two layers: hardware interrupts abstraction layer (hial) and monadic interrupts abstraction layer (mial) required to perform context switching. the mmal and mial provide high-level but executable specifications of low-level, architecture-dependent functions which have been manually implemented in c and assembly. the executable model that can be actually run in coq thus includes the algorithmic model of the service layer as well as the mmal and mial. avocs 2018 6 / 20 eceasst mal hardware automated translation coq implementation c implementation abstraction hmal+mmu api (ptm) mmal mal ial ial api (ptm) hial mial figure 2: the design of pip 3.1 hardware memory abstraction layer memory size is determined in our model by two architecture-dependent parameters, the positive integers pagesize for memory page size and nmbpages for the number of pages. pages are pointed to by page identifiers of type page, which are natural numbers less than nmbpages, modelled in coq using dependent records and defined as {p :> nat; hp: p < nmbpages}. we use 0 as default value for the identifier that points to the null page. the physical address of a memory cell consists of a page identifier and a position in that page, given as an offset value called index. it is modelled by type paddr and defined as (page * index). also indices are typed as a subset of positive integers index and defined as {i:> nat; hi: i< pagesize}. in general, the physical memory state of a computer can be modelled as an association list which maps physical addresses to values. however, our model is completely abstract with respect to the content of the user space. we only need to model the partition tree, and thus we only provide the content of the kernel-owned pages, from which the tree structure can be computed. the part of the hardware state that is relevant to pip consists of the partition descriptor of the currently executing partition and of the parts of the physical memory where pip stores its own data (essentially related to the configuration and management of the partition tree), as expressed by the record type state which is defined as: record state: type:={ currentpartition: page; memory: list(paddr * value)}. direct memory access is represented by a lookup function named select. the value datatype sums up the types of values that can be stored by pip. inductive value : type:= |pe: pentry → value |ve: ventry → value |pp: page → value |va: vaddr → value |i: index → value. here pentry stands for physical entry, ventry for virtual entry, and vaddr for virtual address. we prove that memory management is well-typed with respect to these value types, as an invariant consistency property of our model. physical entries (ptes) make it possible to associate page addresses with information concerning whether each page is assigned to the current partition (present) and whether it is owned by it (accessible). a physical entry is modelled by 7 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base sh1 sh2 lmmu pdkernel pages figure 3: partition tree configuration type pentry and defined as {pa: page; present: bool; accessible: bool}. a page table is a configuration page that contains a set of values, including physical entries. 3.2 partition tree management the configuration of each partition (other than the root) is stored in the memory allocated for it by its parent partition, thus assigned to the parent, though in the part of it that is only accessible to the kernel, and it is defined by four entities. the first and principal one is the mmu configuration, the other ones include two tree-like structures and a list-like one. each partition descriptor (pd) is a page that contains the addresses of four configuration entities, as illustrated by fig. 3. the pd together with its entities forms what we call a configuration node. the mmu configuration of each partition has a hierarchical structure that can be abstractly described as a graph where nodes are pages, each being either a page table or a terminal page, and each terminal page being either a page assigned to the configured partition or the null page. each entry in a page table points to another page, thus providing the arcs in the graph, while providing accessibility information. the mmu structure has two fundamental properties which have been verified as invariant consistency properties of our model. the first property ensures that the one and only physical entry marked as not present corresponds to the null page – in fact, the mmu configuration only contains pages that are assigned to the parent partition. the second property ensures that the subgraph formed by non-null pages has the structure of a tree, which we call the mmu tree. the tree depth is fixed by the architecture-dependent natural parameter levelnum. virtual addresses are modelled by type vaddr as lists of indices of length levelnum+1 and defined as: record vaddr := {va :> list index; hva: length va = levelnum + 1}. each virtual address is translated either to the null address or to a physical address in a leaf, by interpreting each index in the list as offset in the page table at the corresponding level in the mmu avocs 2018 8 / 20 eceasst tree. the last index in the list is the offset of the corresponding physical address, which may be accessible or not to the partition, depending on whether the page is owned or not, as specified by the last pte. crucially, in pip only the kernel can access directly physical addresses. virtual addresses are the objects provided by the mmu to user applications as indirect references to the physical memory. indirect access relies on the mmu_translate function, which models the hardware mapping of virtual addresses to physical ones, and which has been proved to respect the access policy. intuitively, non-null virtual addresses correspond to maximal branches in the mmu tree (plus the final offset), and they include those pointing to the descendants in the partition tree. in fact, the content of a virtual address (i.e. the value of the physical address it gets translated to) can be the pdi of another partition (indeed, this is the only kind of content pip cares for). in this way configuration nodes can be linked together. the resulting structure is a graph which we prove to be a tree, and thus to represent the partition tree, as an invariant consistency property of our model. the partition tree management makes use of two auxiliary configuration entities, called shadows, that mirror the corresponding mmu tree. the first shadow is used to find out which pages are assigned to children, an information that is needed to ensure horizontal isolation. it uses the type ventry of virtual entries which is defined using the following record: record ventry : type:={pd: bool; va: vaddr}. the flag pd indicates if the associated physical address is the pdi of a child partition. the second shadow is used to associate each partition descriptor to the virtual address it has in its parent partition. the fourth auxiliary entity is a linked list used to remember which pages have been lent to the kernel. the information in the second shadow and in the linked list is needed to process efficiently the deletion of a partition. 3.3 the monad in order to implement the pip services imperatively in coq as sequential programs, we rely on a monadic approach. monads [mog91, wad92] allow threading effects through computations, and can be used to interpret semantically imperative languages in purely functional ones. in our case, side effects include the state, corresponding to the hardware state, and a notion of exception corresponding to the possibility of undefined behaviours that we actually prove to never happen. for example, any attempt by pip to access a physical address that is not defined in the memory state would result in an undefined behaviour. we define our monad (low level interface monad) as an abstract datatype lli a that wraps together hardware state and undefined behaviours, following [mog91, wad92]. definition lli (a : type) : type := state → result (a * state). here result is an inductive type with two constructors: the first one corresponds to a result of type a, and the second one to an undefined behaviour. 9 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base inductive result (a : type) : type := |val: a → result a |undef: nat → state → result a. we define the monadic operations ret and bind, which can be easily proved to satisfy the monadic laws [mog91, wad92]. definition ret : a → lli a := fun a s ⇒ val (a, s). definition bind : lli a → (a → lli b) → lli b := fun m f s ⇒ match m s with |val (a, s’) ⇒ f a s’ |undef a s’ ⇒ undef a s’ end. we write perform x := m in e for the monadic binding operation bind m (fun x ⇒ e), which can also be written m ;; e when x is not used in e, to represent sequential composition of the stateful actions m and e. the state monad ensures we can define the usual stateful functions, e.g. get and put to read and update the state. we use the monadic functions to define the specific ones that form the mal, matching the corresponding architecture-dependent implementations in c and assembly. crucially, the pip services are implemented so to access the state only through the mmal functions. 3.4 monadic memory abstraction layer the mmal specifies a c and assembly library for the architecture-dependent part of pip, which consists of kernel atomic operations, such as reading and writing values in physical memory, and performing simple computations and comparisons on them. this includes physical memory access operations needed to configure partitions, virtual memory activation and a set of auxiliary operations. it mainly consists of bitwise operations of constant computational complexity. the functions defined in the mmal can be organized along four categories. the first one is hal_write, allowing the kernel to write values into physical memory through physical addresses and including the primitives writevirtual, writephysical, writevirentry, writephyentry, writeaccessible, writepresent, writepdflag, writeindex. for example, the writevirtual primitive has the following definition: definition writevirtual (addr:page)(idx:index)(va:vaddr): lli unit:= modify (fun s ⇒ {| currentpartition := s.(currentpartition); memory := add paddr idx (va va) s.(memory) beqpage beqindex|}). it stores a virtual address at the physical address given by a page and an index. the monadic operator modify is used to modify the association list that represents the memory. the second category is hal_read. it is about reading values from physical memory and includes the following primitives: readvirtual, readphysical, readvirentry, readphyentry, readaccessible, readpresent, readpdflag, readindex. for example, readvirtual allows reading a virtual address from a physical location. definition readvirtual (p: page) (idx: index): lli vaddr:= perform s := get in avocs 2018 10 / 20 eceasst match lookup p idx s.(memory) beqpage beqindex with |some (va v) ⇒ ret v |some _ ⇒ undefined 3 |none ⇒ undefined 2 end. this requires that there is a value of the right type at the given physical address. if the condition is not met, the result is an undefined behaviour. the third category (named hal_op) allows the kernel to perform simple operations, including e.g. successor and equality comparison, on each value type. the last category (named hal_const) is about accessing global constants. notice that since coq types are more discriminating than c ones, different mmal functions may be actually implemented as the same c function. 3.5 linguistic aspects the program extraction capabilities of coq made it possible to extract haskell code which we used to test our model. however, such code does not meet the runtime requirements of a realistic kernel. the cost of the runtime environment needed by functional programs, and particularly garbage collection, stand in the way of a reliable runtime behaviour. therefore, we rely on a translation to c. the monadic code we use in our executable specification corresponds to a quite simple imperative language: essentially, a first-order sequential language with call-by-value, primitive recursion and mutable references. from a low-level point of view, all the datastructures used by pip, including trees, can be treated as linked lists. the abstract memory model in coq matches closely this low-level characterisation: pip datastructures are represented using an encoding of linked lists, given in terms of lists and access to the monadic state, rather than by using specific inductive datatypes, and then by proving invariant consistency properties as appropriate to ensure that the low-level representation is correct. in fact, our monadic code corresponds to a shallow embedding of the denotational semantics of a language, formally described in [tnjc18], which matches closely a comparatively small fragment of c (we use no arrays, neither structures nor unions, no loop instructions, no pointer arithmetics). we use a haskell-implemented tool called digger [ho17] to generate automatically c code for the service layer from the abstract syntax of the monadic coq code. the code generated by digger from the executable model can then be compiled (we currently use gcc) together with the manually implemented mal functions. relying on a low-level modelling of data structures has a drawback in the development of recursive functions based on such structures: we cannot rely on structural recursion as coq would provide for the corresponding inductive type. this can be a problem already at the level of function definition, as coq requires that we ensure termination. nonetheless, we can easily deal with this issue, relying on the fact that pip functions only require recursion bounded by parameters of the hardware architecture such as the size of a memory page. however, this means we need to prove that fuel suffices, for each top-level function call. 11 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base 4 security properties security in pip relies on the mmu functionalities that control user access to physical memory, as user access to physical memory is only allowed through the mmu. proved consistency properties ensure, for instance, that the mmu is configured correctly, consistently with the partition tree, and that memory access through the mmu is consistent with the access policy encoded in the configuration pages. such properties are needed to prove the actual security properties of pip. we now introduce the main properties that define the pip partitioning model, provably preserved by the api services: horizontal isolation, kernel isolation, and vertical sharing. in a tree, two nodes are unrelated whenever neither of them is a descendant of the other one. with respect to the partition tree, horizontal isolation means that unrelated partitions cannot access each other’s memory. this is the case in particular for sibling partitions. definition 1 (hi) horizontal isolation holds for a state s whenever for all partition descriptors m0,m1,m2 ∈ partition tree(s), with m1,m2 ∈ children(m0,s) and pdi(m1) 6= pdi(m2), it holds that allocated pages(m1,s) ∩ allocated pages(m2,s) = /0. where partition tree is the list of partition identifiers. we use consistency properties to ensure that partitions are organized into a tree-like structure. kernel isolation means that no partition can access the pages owned by the kernel. definition 2 (ki) kernel isolation holds for a state s whenever for each partition descriptor m ∈partition tree(s), it holds that accessible pages(m,s) ∩ kernel owned pages(s) = /0. vertical sharing means that all the pages allocated for a partition are included in the pages assigned to its ancestors, and therefore, owing to the access policy implemented by the mmu, a partition has read and write access on all the memory accessible by its descendants. definition 3 (vs) vertical sharing holds for a state s whenever for all partitions m0,m1 ∈ partition tree(s), with m1 ∈children(m0,s), it holds that allocated pages(m1,s)⊂assigned pages(m0,s). relying on these invariants we can prove formally a non-influence property for isolated partitions [the17d] (i.e. excluding inter-partition communication), relying on an abstract information flow model. we call p-machine a state machine at the level of physical memory, where transition steps are specified by the type pstep (ls : list page) : state→ state . here ls is the list of pages which can be accessed in the execution of the physical action associated with the step. we can define state equivalence with respect to a list of pages (where select returns the value stored at a location). s1 ∼ps s2 := ∀(p : page) (i : index), p ∈ ps → select s1 p i = select s2 p i we write s1 ∼ s2 for s1 ∼ps s2 when ps are all the pages, and s1 ∼p s2 for s1 ∼[p] s2. we can specify the access requirement intended by pstep in terms of two conditions. first, the read avocs 2018 12 / 20 eceasst condition states that the step depends only on the values read at locations in ps (i.e. the physical action depends only on its accessible locations). readcond (π : pstep) : type := ∀(ps : list page) (s1 s2 : state), s1 ∼ps s2 → π ps s1 ∼ps π ps s2 second, the write condition states that the only locations possibly affected by the step are those in ps (i.e. the physical action only affects its accessible locations). writecond (π : pstep) : type := ∀(ps : list page) (s : state) (p : page), ¬ p ∈ ps → s ∼p π ps s any state machine can be modelled as a p-machine. runs can be modelled as action sequences. we can now introduce v-machines as virtual-level state machines which lift our information flow specification at the level of virtual memory. we can define the notion of virtual step by lifting a physical step, relying on the mmu translation function that represents virtual memory access in the hal. here m is the executing partition and vs is the list of virtual addresses accessed in the execution of the virtual action associated with the step. vstep (p : page) (π : pstep) (vs : list vaddr) (s : state) : state := let ps := map (mmu translate p) vs in π ps s the fact that the mmu is configured to return physical addresses in the memory owned by the executing partition, together with the access requirement on the p-machine steps, makes it straightforward in coq to prove non-influence (a notion defined in [vo04]), with respect to a policy that excludes communication between separated partitions. we write @m to denote all the pages that are in a partition with address m. we write s1 ∼m! ps s2 whenever s1 ∼ps s2, the executing pdi is m in both states, and s1 ∼@m s2. we prove stepwise non-leakage, defined following [vo04]. s1 ∼a!as s2 → ∀pt vs, vstep a pt vs s1 ∼as vstep a pt vs s2 this property can be easily extended to action sequences. similarly we can prove a noninterferencerelated property (called local-respect in [rus92]). ¬ a ∈ @ax → ∀pt vs, vstep ax pt vs s ∼a s this, together with non-leakage suffices to prove classical noninterference and non-influence [rus92, vo04]. our proof shows how the low-level invariants (hi, ki and vs) can be used to prove a higher-level result. the extent of the result presented here is comparatively limited, as we consider a definition of virtual step which is very strict, ruling out the mechanism we need for inter-partition communication (i.e. interrupts). on the other hand, this model could be extended to deal with given user-level communication policies, by a reformulation of the write condition that takes interrupts into account. 13 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base 5 the verification approach 5.1 hoare logic on top of a state monad our verification targets the properties ki, hi and vs, defined in section 4, as well as the consistency properties (which we will denote jointly by c in the following), with the goal of ensuring that each system call to an api service preserves all of them. thus our proofs consist mainly of reasoning about invariants. we do this by using a hoare logic which we define on top of the lli monad. we use the syntax {{ p }} m {{ q }} for our hoare triples, defined as follows. definition hoaretriple {a: type} (p: state → prop) (m: lli a) (q: a → state → prop): prop := ∀ s, p s → match m s with |val (a,s’) ⇒ q a s’ |undef _ _⇒ false end. here the unary predicate p gives the precondition and the binary predicate q the postcondition of running the computation m. if performing m yields an undefined behavior, the triple does not hold, thus ensuring a basic functional correctness property: the services of pip never lead to an undefined behavior. we created a library of general hoare logic rules to reason about monadic programs. we also created a specific library of hoare triples (in general, either weakest preconditions or strongest postconditions) for the mal primitives that sequentially form each of the api service. for example, the following has the weakest precondition of readvirtual as precondition. lemma readvirtualwp table idx (p : vaddr → state → prop) : {{fun s⇒ exists e: vaddr, lookup table idx s.(memory) beqpage beqindex = some (va e) ∧ p e s}} mal.readvirtual table idx {{p}}. our use of hoare logic relies on the assumption that each system call is atomic: it is required that interrupts are blocked during a system call. this is one of the reasons the system calls were designed to be elementary. moreover, our hoare logic deals only with the global state, therefore it is required that in multicore architectures at most one core is executing a system call at any time. concerning the hardware, we naturally assume that the physical memory behaves correctly, as specified (i.e. essentially it is not volatile), and that so does the mmu component. we also assume that the non-algorithmic mmal is correctly implemented in c and assembly, and that the system was booted in an isolated and consistent state (as our proof is essentially a preservation one). the code of pip has a sequential character. thus, verification can proceed backward, relying on weakest precondition triples, or forward relying on strongest postcondition ones. the two approaches are actually equivalent in our case, since we can ensure termination and our triples rule out undefined behaviours. in our concrete proofs we found it more convenient to move forward, following the actual execution flow. avocs 2018 14 / 20 eceasst 5.2 the separation proof for addvaddr in the case of addvaddr, the top level invariant is the following: lemma addvaddrinvariant (src dst child: vaddr): {{fun s ⇒ hi s ∧ ki s ∧ vs s ∧ c s}} addvaddr src dst child {{fun _ s ⇒ hi s ∧ ki s ∧ vs s ∧ c s }}. the addvaddr service is called by the executing partition p0 to assign one of its pages (further down denoted by srcp) to one of its children (child). here src is the virtual address of srcp in the address space of p0, whereas dst is the virtual address that gets associated with srcp in the address space of child. the first part of the service consists in making some checks, before making any update to the state. these checks include consistency ones needed to avoid undefined behaviours, and security ones on each of the given parameters. if any of the security checks fails, the service will abort leaving the state unchanged. to ensure that child is actually a child of p0, addvaddr starts by checking if the pdi of child is included in the first shadow of p0. then it makes sure that srcp is already assigned to p0 and accessible by it, checking the control bits present and accessible of the corresponding table entry in the mmu tree of p0. it checks that srcp is not already assigned to any child using the flag pd stored in the first shadow of p0. finally it verifies that dst is not already associated to a physical page by going through the mmu tree of child. this prevents overwriting data. these properties gets propagated through the sequential execution until the last part, where state updates take place. in fact, it is part of our design of the pip services to carry out state updates in a way that maximises invariant propagation without compromising efficiency. in the case of addvaddr state updates are confined to the last three instructions, for which the following triple holds: {{fun s ⇒ hi s ∧ ki s ∧ vs s ∧ c s ∧ ischild child s ∧ ispresent srcp s ∧ isaccessible srcp s ∧ notshared srcp s ∧ isempty dst s}} writevirtual shadow2tabledst dst src;; writevirentry shodow1tablesrc dst child;; writephyentry mmutabledst dst srcp {{fun _ s ⇒ hi s ∧ ki s ∧ vs s ∧ c s}}. writevirtual modifies the second shadow of child, by storing src at dst (thus ensuring that the page can be efficiently located in the parent address space when it needs to get revoked). writevirentry starts the process of assigning the page associated with src to the partition associated with child, by storing the address child at src in the first shadow of p0. writephyentry concludes the process, by associating the physical page srcp to dst in the mmu tree of child. as a result of relying on comparatively flat representations (e.g. our trees are represented using lists), a significant part of the proof consists of ensuring that consistency properties are preserved through sequential updates. this is particularly the case for the consistency of the first shadow, a data structure which has been specifically put in place to support isolation, by ensuring that a page cannot be assigned to distinct children. our policy of ordering steps to maximise propagation pays with respect to several properties: for example accessiblechildpageisaccessibleintoparent, 15 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base requiring that each page assigned to a partition has a back-pointer in its second shadow, is preserved by the fact of performing writevirtual first. however, there are some propagated properties that get temporarily broken and need to be patched up with weaker ones. for example, the property notshared srcp s, stating that srcp is not marked as shared according to the kernel information stored at p0, is no more valid after executing writevirentry. luckily, a weaker property that here we denote h holds. it states that srcp is not assigned to any child according to mmu configuration, and suffices to prove the final triple: {{fun s ⇒ hi s∧ ki s ∧ vs s ∧ c s ∧ ischild child s ∧ ispresent srcp s ∧ isaccessible srcp s ∧ h srcp s ∧ isempty dst s}} writephyentry mmutabledst idx srcp {{fun _ s ⇒ hi s ∧ ki s ∧ vs s ∧ c s}}. in particular, proving hi s (as by definition 1) involves showing that srcp is assigned to child and not assigned to any distinct sibling partition. proving ki s (as by definition 2) involves showing that srcp is not a kernel page. finally proving vs s (as by definition 3) involves showing that srcp is assigned to the parent partition of child. 5.3 overview of the development and the verification the top level executable specification includes about 1300 lines of gallina. we estimate 3 months for kernel conception and 9 months for its development. we have currently verified three services: createpartition, addvaddr and mappedinchild. we started from the proof of createpartition which introduced the majority of the consistency properties resulting in about 60k lines of proof as detailed in table 1. the other two services were proved relying largely on lemmas already proved for createpartition and resulting in about 20k additional lines of proof. the current proof has required about one person-year of verification time. along the proof, we made several changes to the code of the kernel. most of time it was about fixing bugs such as adding some missing checks or reordering instructions to simplify the proof. invariants lines of proof duration createpartition (≈ 300loc) ≈ 60000 ≈ 10 months createpartition + addvaddr (≈ 110loc) ≈ 78000 ≈ 2 monthes createpartition + addvaddr + mappedinchild (≈ 40loc) ≈ 78300 ≈ 4 hours table 1: the overview of verification 6 conclusions and further work in this paper we have presented the formalization of the protokernel pip which is written in coq and automatically translated to c code. it supports a hierarchical partitioning model that only requires managing partition virtual spaces and context switching. the main security property avocs 2018 16 / 20 eceasst ensured by the kernel is memory separation. pip was designed with special attention to increasing the feasibility of its verification. in this sense, not only the minimisation of the tcb, but also the modular design of the api, the structuring of the configuration information, and the modelling economy of the monadic encoding have played a role in allowing for comparatively simple proofs. applications in order to show that our proof-oriented design is realistic, the real-time embedded system freertos and linux 4.10.4 have been ported to pip [ygg+18, bjy+18]. the porting consists essentially in removing privileged instructions and other operations, replacing them with system calls to pip, thus allowing for isolating tasks by running them in isolated partitions. pip has also been extended to support different multi-core configurations [bgi18], and this has been possible without changing its current implementation. the modification of existing proofs on the mono-core version to account this extension is still under study. translations to c and dec a verified translation to c of the service layer is currently being implemented, following one of the work plans discussed in [tnjc18], relying on a small intermediate language called dec [tn17] which has been formalised as a deep embedding to allow for a definition in coq of a translation to compcert c [bl09]. the digger translator [ho17], which works on the ast of the shallow embedding and is currently used to obtain uncertified c code, can also be used to translate automatically the service layer to dec. ongoing work is focusing on proving the adequacy of the deep embedding with respect to the shallow one. in [tnjc18] the deep embedding has also been used to experiment with syntax-driven semi-automation of hoare logic proofs. ongoing and future work concerning the formal track, the verification of the remaining services is currently under way, and so is the verification of the translation to c. future work could involve, on one hand, extending the information flow model to deal with user-level interpartition communication, and on the other hand, extending verification to the architecture-dependent part. bibliography [ast06] j. alves-foss, w. scott harrison, c. taylor. the mils architecture for highassurance embedded systems. international journal of embedded systems, pp. 239– 247, 2006. [bbbt11] c. baumann, t. bormer, h. blasum, s. tverdyshev. proving memory separation in a microkernel by code level verification. in object/component/service-oriented real-time distributed computing workshops (isorcw), 2011 14th ieee international symposium on. pp. 25–32. 2011. 17 / 20 volume 076 (2019) proof-oriented design of a separation kernel with minimal trusted computing base [bbcl11] g. barthe, g. betarte, j. d. campo, c. luna. formally verifying isolation and availability in an idealized model of virtualization. fm, pp. 231–245, 2011. [bc04] y. bertot, p. casteran. interactive theorem proving and program development. coq’art: the calculus of inductive constructions. springer, 2004. [bcg+16] h. becker, j. m. crespo, j. galowicz, u. hensel, y. hirai, k. nakata, j. l. sacchini, h. tews, t. tuerk. combining mechanised proofs and model-based testing in the formal analysis of a hypervisor. in fm 2016: formal methods: 21st international symposium, limassol, cyprus, november 9-11, 2016, proceedings 21. pp. 69–84. 2016. [bdf+03] p. barham, b. dragovic, k. fraser, s. hand, t. harris, a. h., r. neugebauer, i. pratt, a. warfield. xen and the art of virtualization. 2003. doi:10.1145/1165389.945462 [bgi18] q. bergougnoux, g. grimaud, j. iguchi-cartigny. porting the pip proto-kernel’s model to multi-core environments. in ieee-dasc’18. p. 8 pages. 2018. [big17] q. bergougnoux, j. iguchi-cartigny, g. grimaud. pip, un proto-noyau fait pour renforcer la sécurité dans les objets connectés. in conférence d’informatique en parallélisme, architecture et système (compas), jun 2017, sophia antipolis, france. 2017. 8 pages. [bjy+18] q. bergougnoux, n. jomaa, m. yaker, j. cartigny, g. grimaud, s. hym, d. nowak. proved memory isolation in real-time embedded systems through virtualization. 2018. draft. [bl09] s. blazy, x. leroy. mechanized semantics for the clight subset of the c language. journal of automated reasoning, pp. 263–288, 2009. [csg16] d. costanzo, z. shao, r. gu. end-to-end verification of information-flow security for c and assembly programs. acm, pp. 648–664, 2016. [dgk+13] m. dam, r. guanciale, n. khakpour, h. nemati, o. schwarz. formal verification of information flow security for a simple arm-based separation kernel. in proceedings of the 2013 acm sigsac conference on computer & communications security. ccs ’13, pp. 223–234. acm, 2013. doi:10.1145/2508859.2516702 [eko95] d. r. engler, m. f. kaashoek, j. o’toole, jr. exokernel: an operating system architecture for application-level resource management. sigops oper. syst. rev., 1995. [fm10] a. c. j. fox, m. myreen. a trustworthy monadic formalization of the armv7 instruction set. interactive theorem proving, pp. 243–258, 2010. avocs 2018 18 / 20 http://dx.doi.org/10.1145/1165389.945462 http://dx.doi.org/10.1145/2508859.2516702 eceasst [gkr+15] r. gu, j. koenig, t. ramananadro, z. shao, x. n. wu, s. c. weng, h. zhang, y. guo. deep specifications and certified abstraction layers. in proceedings of the 42nd annual acm sigplan-sigact symposium on principles of programming languages. popl ’15, pp. 595–608. acm, 2015. doi:10.1145/2676726.2676975 [gm82] j. a. goguen, j. meseguer. security policies and security models. in ieee symposium on security and privacy. pp. 11–11. 1982. [gsc+16] r. gu, z. shao, h. chen, w. s. c., j. kim, v. sjoberg, d. costanzo. certikos: an extensible architecture for building certified concurrent os kernels. in osdi. pp. 653–669. 2016. [ho17] s. hym, v. oudjail. digger. 2017. https://github.com/2xs/digger. [jngh18] n. jomaa, d. nowak, g. grimaud, s. hym. formal proof of dynamic memory isolation based on mmu. sci. comput. program. 162:76–92, 2018. [keh+09] g. klein, k. elphinstone, g. heiser, j. andronick, d. cock, p. derrin, d. elkaduwe, k. engelhardt, r. kolanski, m. norrish, t. sewell, h. tich, s. winwood. sel4: formal verification of an os kernel. in proceedings of the acm sigops 22nd symposium on operating systems principles. pp. 207–220. 2009. [mmb+13] t. murray, d. matichuk, m. brassil, t. bourke, s. seefried, c. lewis, x. gao, g. klein. sel4: from general purpose to a proof of information flow enforcement. in ieee symposium on security and privacy (sp). pp. 415–429. 2013. [mog91] e. moggi. notions of computation and monads. information and computation, pp. 55–92, 1991. [ods17] odsi partners. http://celticplus-odsi.org. 2017. [vo04] d. von oheimb. information flow control revisited: noninfluence = noninterference + nonleakage. in computer security esorics 2004, 9th european symposium on research computer security, sophia antipolis, france, september 13-15, 2004, proceedings. pp. 225–243. 2004. [pip17a] pip development team. http://pip.univ-lille1.fr. 2017. [pip17b] pip development team. http://pip.univ-lille1.fr/doc/coq-doc/toc.html. 2017. [pip17c] pip development team. https://github.com/2xs/pipcore/tree/develop. 2017. [rus81] j. rushby. design and verification of secure systems. acm, 1981. [rus92] j. rushby. noninterference, transitiviy, and channel-control security policies. sri international, computer science laboratory, 1992. 19 / 20 volume 076 (2019) http://dx.doi.org/10.1145/2676726.2676975 https://github.com/2xs/digger http://celticplus-odsi.org http://pip.univ-lille1.fr http://pip.univ-lille1.fr/doc/coq-doc/toc.html https://github.com/2xs/pipcore/tree/develop proof-oriented design of a separation kernel with minimal trusted computing base [sbh14] d. sanan, a. butterfield, m. hinchey. separation kernel verification: the xtratum case study. in working conference on verified software: theories, tools, and experiments. pp. 133–149. 2014. [sd14] o. schwarz, m. dam. formal verification of secure user mode device execution with dma. in haifa verification conference. pp. 236–251. 2014. [tkn07] h. tuch, g. klein, m. norrish. types, bytes, and separation logic. in proceedings of the 34th annual acm sigplan-sigact symposium on principles of programming languages. popl ’07, pp. 97–108. acm, 2007. doi:10.1145/1190216.1190234 [tn17] p. torrini, d. nowak. https://github.com/2xs/dec.git. 2017. [tnjc18] p. torrini, d. nowak, n. jomaa, m. s. cherif. formalising executable specifications of low-level systems. in proc. vstte’18. p. 18 pages. 2018. [wad92] p. wadler. comprehending monads. mathematical structures in computer science, pp. 461–493, 1992. [wkp80] b. j. walker, r. a. kemmerer, g. j. popek. specification and verification of the ucla unix security kernel. communications of the acm, pp. 118–131, 1980. [ygg+18] m. yaker, c. gaber, g. grimaud, j.-p. wary, v. sanchez-leighton, i.-c. j., x. han. ensuring iot security with an architecture based on a separation kernel. in ficloud’18. p. 8 pages. 2018. [zszl16] y. zhao, d. sanan, f. zhang, y. liu. reasoning about information flow security of separation kernels with channel-based communication. in international conference on tools and algorithms for the construction and analysis of systems. pp. 791–810. 2016. [zszl17] y. zhao, d. sanan, f. zhang, y. liu. high-assurance separation kernels: a survey on formal methods. arxiv preprint arxiv:1701.01535, 2017. avocs 2018 20 / 20 http://dx.doi.org/10.1145/1190216.1190234 https://github.com/2xs/dec.git introduction contributions related work pip outline proof-oriented design the executable specification hardware memory abstraction layer partition tree management the monad monadic memory abstraction layer linguistic aspects security properties the verification approach hoare logic on top of a state monad the separation proof for addvaddr overview of the development and the verification conclusions and further work reconfiguration of reo connectors triggered by dataflow electronic communications of the easst volume 10 (2008) proceedings of the seventh international workshop on graph transformation and visual modeling techniques (gt-vmt 2008) reconfiguration of reo connectors triggered by dataflow christian koehler, david costa, josé proença, farhad arbab 13 pages guest editors: claudia ermel, reiko heckel, juan de lara managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst reconfiguration of reo connectors triggered by dataflow christian koehler, david costa, josé proença, farhad arbab cwi, amsterdam abstract: reo is a language for coordinating autonomous components in distributed environments. coordination in reo is performed by circuit-like connectors, which are constructed from primitive, mobile channels with well-defined behaviour. while the structure of a connector can be modeled as a graph, its behaviour is compositionally defined using that of its primitive constituents. in previous work, we showed that graph transformation techniques are well-suited to model reconfigurations of connectors. in this paper, we investigate how the connector colouring semantics can be used to perform dynamic reconfigurations. dynamic reconfigurations are triggered by dataflow in the connector at runtime, when certain structural patterns enriched with dataflow annotations occur. for instance we are able to elegantly model dynamic reo circuits, such as just-in-time augmentation of singlebuffered channels to a circuit that models a channel with an unbounded buffer. additionally we extend reo’s visual notation and the reo animation language to describe and animate dynamically reconfiguring connectors. keywords: coordination, reconfiguration, graph transformation, animation. 1 introduction the coordination paradigm provides models for describing the communication among the components in a composed system. coordination languages, such as reo [arb04], describe the ‘gluing’ of loosely coupled components, such that a desired system behaviour emerges. the achieved separation of business logic and coordination of the active entities leads to a much cleaner design and helps to handle the greater complexity of large applications. reo can be applied in various distributed scenarios—from service-oriented to grid computing—as the coordination model is exogenous and independent from the actual component implementation and infrastructure. in a reo network, software components are autonomous, self-contained entities that communicate with the outside world via a published interface. to avoid dependencies and to achieve a truly modular, distributed system, reo proposes the notion of connectors which are used to coordinate the components without their knowledge. by this, the system is divided into two orthogonal aspects: 1) the computation, performed by the components and 2) the coordination of these independent components, performed by the connectors. a major advantage of this design is the ability of changing the topology of the connector, and thereby the behaviour of the system. the configuration of a reo connector consists on the interconnection between the structural elements of the connector, together with their states. communication with the components may change the state of the connector, but not its topology. in this paper, we consider reconfigurations of a connector as high-level transformations of its underlying graph structure. using the theory 1 / 13 volume 10 (2008) reconfiguration of reo connectors triggered by dataflow of typed, attributed graph transformation, we can directly apply many useful results, such as termination and confluence theorems [kla07]. in this paper, we explore the interplay between the data flow in a connector and its reconfigurations. for this, we include the connector colouring semantics into the patterns of transformation rules. transformations are automatically applied depending on the structure, the state and the context of a connector. connectors are reconfigured at run-time based on this information. this leads to a powerful notion of dynamic connectors. we illustrate the principles through the example of a dynamically growing buffer. related work the logic rectl* was introduced in [cla08] to reason about connector reconfiguration in reo. the reconfigurations are performed using the basic primitive operations of the reo api, e.g. channel creation or node splitting. up to now we have not provided a technique to reason about our dynamic high-level reconfigurations. however, we plan to look at model checking techniques for graph transformation as proposed in [ren03a]. architectural design rewriting (adr) [blmt07] is a framework for general reconfigurable software architectures. as in our approach, reconfigurations are modeled using graph transformation rules. reconfigurations occur at run-time whenever the system evolves to a configuration that violates the architectural style of the system. in our case we do not fix the use of the reconfiguration to any particular purpose. the dynamic f if o introduced in this paper can be seen as an example of the use of reconfiguration to guarantee dataflow. if a write operation is performed while the buffer is full, the buffer is reconfigured to allow data to be stored and dataflow to occur. adr is not tied to any architectural style (e.g. client-server, peer-to-peer) while in our case, reo determines the architecture. a systematic introduction to animations based on graph transformation concepts was given in [erm06]. the animation language for reo that we use in this paper was introduced in [cp07]. it is important to note that the animation language for reo is not based on graph transformation. instead the authors introduce an abstract animation language that can be used to compute animation descriptions for a connector compositionally out of the descriptions of its constituent primitives. structure of the paper this paper is organised as follows. section 2 gives a general introduction to reo by introducing the notions of channels, nodes and connectors. an overview of the colouring semantics for reo is given in section 3. we recall the concepts of graph-based reconfigurations and provide our contributions to dynamic reconfigurations in section 4. we discuss the proposed model in section 5. the status of the current implementation and plans for future work are given in sections 6 and 7, respectively. 2 reo overview reo is an exogenous coordination language where complex connectors are compositionally built out of simpler ones. the simplest (atomic) connectors in reo consist of a user defined set of channels, each of which with its particular constraint policy. proc. gt-vmt 2008 2 / 13 eceasst a channel is a medium of communication with exactly two directed ends. there are two types of channel ends: source and sink. a source channel end accepts data into its channel. a sink channel end dispenses data out of its channel. a channel can connect two components or be composed with other channels using reo nodes to build more complex connectors. reo nodes are logical places where channel ends coincide. a node with only source channel ends is a source node; a node with only sink channel ends is a sink node; and finally a node with both source and sink channel ends is a mixed node. we use the term boundary nodes to refer indistinguishably to source and sink nodes. boundary nodes define the interface of a connector. components connect to and interact anonymously with each other through the interface of the connector by performing i/o operations on its boundary nodes: take and read operations on sink nodes, and write operations on source nodes. reo fixes the constraint policy for the dataflow in reo nodes. data flows through a node only if at least one sink channel end is pushing data and all the source channel ends can accept a copy of the data. in case more than one sink channel end is pushing data, one is picked nondeterministically and all the others are excluded. data cannot be stored in a node, hence its constraints on dataflow and exclusion must propagate through the connector. resolving the composition of the constraint policies of a connector consisting of several channels and nodes is a non-trivial task. in figure 1 we present two examples of reo connectors that illustrate how non-trivial dataflow behaviour emerges from composing channels using reo nodes. the constraints propagate through the (synchronous regions of the) connector to the boundary nodes. the propagation enables a certain context-awareness in connectors. a detailed discussion of this can be found in [cca07]. (a) (b) figure 1: (a) exclusive router, (b) ordering connector. the two connectors in figure 1 involve, in total, four different types of channels. we represent mixed nodes as filled circles ( ), and boundary nodes as empty circles ( ). the sync channel ( ) synchronously takes a data item from its source end and makes it available at its sink end. this transfer can succeed only if both ends are ready to communicate. the lossysync ( ) has the same behavior, except that it does not block if the receiver cannot accept data. in this case, the written data item is accepted and destroyed by the channel. the fifo1 ( ) is an asynchronous channel that has a buffer of size one. unlike the prior channels, fifo1 is a stateful channel. the syncdrain channel ( ) has two source ends through which it can only consume data, and no sink ends. its behavior can be described as follows: if there are data 3 / 13 volume 10 (2008) reconfiguration of reo connectors triggered by dataflow items available at both ends, it consumes (and looses) both of them atomically. the exclusive router, shown in figure 1a, routes data from a to either b or c. the connector can accept data only if there is a write operation at the source node a, and there is at least one component attached to the sink nodes b or c, which is performing a take operation. if both b and c have a take operation, the choice of whether data is routed to b or c is made nondeterministically by the mixed node i. node i can accept data only from one of its sink ends. to the other end it gives an exclusion reason for data not to flow, which forces the lossysync to lose the data. the second connector, shown in figure 1b, imposes an ordering on the flow of the data from the input nodes a and b to the output node c. the syncdrain enforces that data flows through a and b synchronously. the empty buffer together with the syncdrain guarantee that the data item obtained from a is delivered to c whereas the data item obtained from b is stored in the fifo1 buffer. at this moment the buffer of the fifo1 is full and data cannot flow in through either a or b, but c can obtain the data stored in the buffer. the buffer is then empty again. these informal descriptions of the behavior of connectors can be formalised using the connector colouring semantics, introduced in [cca07]. the colouring semantics is used to generate animations and to implement reo, and we discuss it in section 3. reo offers a number of operations to reconfigure and change the topology of a connector at run-time. operations that enable the dynamic creation of channels, splitting and joining of nodes, hiding internal nodes and more. the hiding of internal nodes is important concerning reconfiguration, because it allows to fix permanently the topology of a connector, such that only its boundary nodes are visible and available. the resulting connector can be viewed as a new primitive connector, or primitive for short, since its internal structure is hidden and its behaviour is fixed. reconfiguration is impossible on a primitive. we have the basic primitives that include the user defined channels, the reo nodes, and the i/o operations. plus the non-basic primitives constructed through the use of the hiding operation. 3 connector colouring semantics connector colouring semantics is based on the idea of colouring a connector using a set of colours colour. we consider a set colour with three colours as in clarke et al. [cca07]. one dataflow colour ( ) to mark places in the connector where data flows and two colours for no-dataflow ( , ) to mark the absence of dataflow. the reason for having two distinct nodataflow colours is to be able to trace the exclusion constraints responsible for the no-flow back to their origins. graphically, the arrow indicates the direction of exclusion, i.e. it points away from the exclusion reason and in the direction that the exclusion propagates. colouring a reo connector in a specific state with given boundary conditions (i/o operations) provides a means to determine the route alternatives for dataflow. each colouring of a connector is a solution to the synchronization and exclusion constraints imposed by its channels and nodes. the dataflow allowed by a connector is collected in a colouring table whose elements— colourings—are functions mapping each node of the connector to a colour. the different colourings present in a colouring table of a connector correspond to the alternative ways that the connector can behave in the different contexts where it can be used. proc. gt-vmt 2008 4 / 13 eceasst we recall some essential definitions from [cca07] that formalise the notion of a colouring and of a colouring table. let node be a finite set of node names. definition 1 (colouring) a colouring c : n → colour for n ⊆ node is a function that assigns a colour to every node of a connector. definition 2 (colouring table) a colouring table t over nodes n ⊆node is a set of colourings with domain n. to give semantics to a reo connector using connector colouring one must provide the colouring tables for the user defined primitives, the channels, used in the construction of that connector. table 1 shows the channels we use in this paper and their respective colouring tables. we highlight a few points of interest in this table, focusing only on reasons to exclude dataflow. no dataflow at one end of a sync or syncdrain, is enough to prevent dataflow in the all channel. the reason is propagated to the other end. an empty fifo1 buffer does not enable data flow on its output end, giving a reason for no dataflow. dually, a full fifo1 buffer gives a reason for having no dataflow on its input end. the second entry of the table for a lossysync states that it will lose the data only when a reason for no dataflow is propagated into its output end, which amounts to saying that the channel is unable to transfer the data. reo fixes the colouring tables for the other primitives: nodes and the i/o operations. the table 2 gives a brief account of the connector colouring semantics for these primitives. to comply with the page limit we omit the general colouring table of reo mixed nodes. we give an example of one possible colouring for a reo mixed node with 3 source ends and 2 sink ends. for the purpose of this paper that should suffice without compromising the understanding of what follows. for a full description we refer to [cca07]. definition 3 (primitive) a labelled tuple (n j11 , . . . , n jk k )c represents a primitive connector, c, where for 0 < ` ≤ k, n` ∈ node, j` ∈{i, o}, k ≥ 1 is the arity of the primitive, and the labels i and o indicate a source node or a sink node respectively, such that a node n appears at most as ni and/or no in (n j11 ,··· , n jk k )c. a primitive with colouring is a pair of a primitive with a colouring table t whose domain ranges over the nodes of the primitive. (ni1, n o 2)sync (n i 1, n i 2)syncdrain (n i 1, n o 2)lossysync (n i 1, n o 2)fifo1 (n i 1, n o 2)fifo1[x] table 1: user defined channels, and their colouring tables. a connector is a collection of primitives composed together, satisfying some well-formedness conditions. as such, the colouring table of a connector is computed from the colouring tables of its constituents. 5 / 13 volume 10 (2008) reconfiguration of reo connectors triggered by dataflow (ni1, n i 2, n i 3, n o 4, n o 5)node (n i)write (no)take table 2: reo primitives, and their colouring tables. definition 4 (connector) a connector c is a tuple 〈n, b, e, t〉 where, n is the set of nodes that appear in e; b ⊆ n is the set of boundary nodes; e is a set of primitives; t is a colouring table over n; such that (1) n ∈ b if and only if n appears exactly once in e, and (2) n ∈ n \b if and only if n occurs exactly once as no and as ni in e. a primitive with a colouring table can straightforwardly be considered as a connector. a connector’s semantics is computed by joining the tables of its constituents. two colourings can only be composed if the common nodes in their domains are coloured with the same colour. definition 5 (join) let ck = 〈nk, bk, ek, tk〉 with k ∈{1, 2} be connectors such that (n1\b1)∩ (n2\b2) = /0, and for each n ∈ b1∩b2, ni appears in e1 and no appears in e2, or vice versa. the join of c1 and c2, is given by: c1 �c2 . = 〈n1 ∪n2, (b1 ∪b2)\(b1 ∩b2), e1 ∪e2, t1 ·t2〉, where · is the join operator for two colouring tables defined as: t1 ·t2 . = {c1 ∪c2 | c1 ∈ t1, c2 ∈ t2, n ∈ (dom(c1)∩dom(c2)) ⇒ c1(n) = c2(n)}. figure 2 depicts two colourings of the ordering connector of figure 1(b). in both colourings, a component is connected to each boundary node and performs an i/o operation: write on both source nodes and take on the sink node. the colouring in (a) describes the dataflow behaviour (a) (b) figure 2: (a) and (b) are two possible colourings of the ordering connector. of the connector when the buffer is empty, indicating that data flows through the entire connector except for the sink end of the fifo1 channel, data is stored in the buffer, and all three i/o operations succeed. this dataflow changes the state of the fifo1 channel, changing also its colouring table. the colouring in (b) describes the dataflow behaviour of the connector when the buffer is full. this colouring states that data flows in the connector only at the sink end of the proc. gt-vmt 2008 6 / 13 eceasst fifo1[x] channel, the buffer is emptied, the take operation on node c succeeds, and the write operations on nodes a and b are delayed. figure 3 depicts the two colourings of the exclusive router that are the valid behaviour alternatives when a component is connected to each boundary node and performs an i/o operation: write on the source node and take on both the sink nodes. the colouring in (a) describes the (a) (b) figure 3: (a) and (b) are two possible colourings of the exclusive router. dataflow behaviour of the connector when the mixed node i picks, non-deterministically, node b to route the data to. alternatively the colouring in (b) describes the dataflow behaviour of the connector when the mixed node i picks, non-deterministically, node a to route the data to. 4 connector reconfiguration it has been shown in [kla07] that the theory of graph transformation can be applied to model connector reconfigurations as high-level transformations of their underlying graph structures. the approach allows to define reconfigurations at a high level of abstraction and therefore can be used to model complex reconfigurations, e.g. refactorings. while in the previous work, we considered these techniques in the context of business process customisation, we combine now these transformations with the connector colouring semantics, described in section 3. 4.1 reconfiguration triggered by dataflow dynamic reconfigurations are transformations of connectors at run-time. in the following, we present a framework that allows to define such dynamic reconfigurations by annotating transformation rules with colourings, which leads to a notion of dynamic connectors. to use graph transformation for connector reconfiguration we make the following assumptions. connectors are considered as typed, attributed graphs in the following way: i) reo nodes are vertices of the graph and ii) channels are its edges. the typegraph in this scenario consists of a single node and one edge for each channel type. edge attributes are used to model channel properties, e.g. the content of a full fifo1. since channels in reo are not necessarily directed (cf. the syncdrain channel) we simply assert an underlying direction of the channel to fit the formal model of directed graphs that is usually assumed. note also that we have given a formal definition of connectors in [kla07] and showed that it indeed forms an adhesive high-level replacement category [eept06]. 7 / 13 volume 10 (2008) reconfiguration of reo connectors triggered by dataflow we use the double-pushout (dpo) approach [eept06] for our connector reconfigurations. our transformation rules are an extended version of the usual spans of morphisms in the dpo approach. we write a connector reconfiguration rule as p = (colour c←− l l←− k r−→ r) where l, k and r are connectors (typed, attributed graphs), l, r are connector (typed, attributed graph) homomorphisms and c is a (potentially partial) colouring for the left-hand side of the rule. the rationale behind this extension is that we do not just want to match the structure of a particular connector part, but also its state and the current execution strategy. note that this introduces a certain asymmetry to the rules, caused by the fact that only the left-hand side is coloured. this is also the reason why we do not model the colouring as attributes of the graphs. such an extended rule can be applied with respect to a given match l m→ m and a current colouring m k→ colour iff 1. the gluing condition holds (see [eept06] for more details); and 2. the rule colouring matches the current colouring: c = k◦m. with the latter constraint we extend the pattern of a rule, in the way that a specific colouring has to be matched as well. a transformation rule can and will be applied only if the structure can be matched and a specific behaviour occurs. the extended version of the dpo approach can be summarised as shown in the diagram colour l k r m c n (po) (po) = loo r // m �� �� �� oo // coo k ddiiiiiiiiii where colour is a fixed set of possible flow-colours and c and k are colourings. including the colourings of a connector part makes the pattern matching much more restrictive. in fact, it is so restrictive now that the reconfiguration rules can be invoked by the reo engine without ‘supervision’. the transformation system becomes in some respect autonomous. the connector is transformed when necessary, without the need for an external party to trigger the reconfiguration. figure 4: reconfiguration rule for a dynamic f if o. figure 4 shows a reconfiguration rule for a dynamic (unbounded) f if o. the matches from the lhs to the rhs are indicated by using the same node labels. the reconfiguration rule gives rise to a dynamic connector, which we call f if o∞. the f if o∞ consists of a sequence of f if o1 channels and a reconfiguration rule. the reconfiguration adds a new f if o1 in the proc. gt-vmt 2008 8 / 13 eceasst beginning whenever the f if o∞ is full and someone tries to write to it assuring that way that the write can succeed and the data can flow and be stored in the buffer. the left-hand side matches an arbitrary full f if o1 with content x where someone tries to write to. the reason for the no-flow is the fact that the f if o1 is full already, not that there is no data available. if this pattern can be matched, the rule states that the original channel is destroyed and two new f if o1 channels are created in its place. the second f if o1 is filled with the original content x. however, the rule as it is now does not reflect our initial requirement that only the first f if o1 in the sequence is replaced by two new ones. this can achieved by adding negative application conditions [eept06] as shown in figure 5. we need two extra nacs for the dynamic f if o∞ figure 5: negative application conditions for the f if o∞. that restrict where the rule can be applied. an empty f if o1 should always be added at the very beginning of the sequence. expressed as negative application conditions, this means that there must not be an empty or a full f if o1 in front of the one where the original rule (figure 4) applies. these additional restrictions allow us to apply the transformation rule automatically at runtime when the colouring occurs. for completeness we would have to define also an inverse rule that shrinks the connector again. we omit this here. 4.2 run of a connector connectors are executed in an abstract reo engine. the reo engine includes two independent components, one to compute colouring tables and to perform the dataflow, and one for computing reconfiguration matches and executing the transformations. we refer to these components as df and tr respectively. reconfiguration rules are applied locally only in specific regions of the connector. these regions can be formally viewed as disjoint sub-graphs that restrict the domain of the transformations. these regions are the reconfigurable parts of the connector. each of these regions has a number of reconfiguration rules attached to it, such as the one in figure 4. the reo engine utilises df and tr to execute dynamic connectors. in this scenario a run of the engine consists of performing the following actions: 1. invoke df to compute the colouring table ct of the connector for the actual boundary conditions. 2. choose non-deterministically a colouring k from the colouring table ct . 3. for each reconfiguration region, invoke tr to find pattern matches m1, . . . , mn for the colouring k. 4. invoke df to execute the dataflow according to k. the state of the connector is updated. 9 / 13 volume 10 (2008) reconfiguration of reo connectors triggered by dataflow (a) (b) (c) (d) (e) (f) (g) (h) (i) figure 6: run of the f if o∞. 5. for each pattern match in m1, . . . , mn, invoke tr to perform the transformations. since the steps 3 and 4 are independent from each other, they can be performed in parallel. note also that in general, multiple transformation policies could be supported, e.g. apply at most once or until it is not applicable anymore. figure 6 depicts a run according to the descriptions above, for the f if o∞. part (a) shows the basic connector that we want to reconfigure. it consists of a single empty f if o1 with a w rite operation. the region where the transformation rule from figure 4 should be applied is delimited by the dashed box. part (b) shows the colouring k1 and the corresponding dataflow. the transformation engine is invoked with a snapshot of the reconfiguration region and the colouring k1. since the rule does not match colouring k1 no transformation is performed. in part (c) we see how the dataflow has changed the state of the f if o1 and that the write operation disappeared after succeeding. in part (d) a new write operation is attached to the connector. at this point a new run of the engine starts. figure 6e shows that the new write operation cannot succeed because the f if o1 is already full. this event is formally observed by the no-flow colouring k2. the transformation engine is invoked again and returns a match m this time, because k2 matches the colouring of the reconfiguration rule. since no dataflow has to be performed, the transformation can immediately be applied, as shown in figure 6f. the reconfigured connector is shown in part (g). at this point, the write operation succeeds, and the corresponding colouring k3 is depicted in part (h). there is no rule that matches k3, since the only possible match with the full f if o1 is restricted by nac 1, defined in figure 5. in figure 6i we show the state of the connector after the dataflow, whereas the write operation is removed and the left f if o1 becomes full. the visual representation we use is based on an extension of the animation language introduced in [cp07]. we use the colour green to highlight the part of the connector that matches the left-hand side of the rule, as depicted in the region inside the dashed box in figure 6f, and proc. gt-vmt 2008 10 / 13 eceasst the connector that appears below corresponds to the right-hand side of the rule. the dashed blue arrows in figure 6f, pointing from the match to the substitute connector, indicate that the nodes a and b are preserved by the transformation. furthermore, the colour of the new data token matches the colour of the data token in the matched part of the connector, expressing that the argument of the full f if o1 channel is the same as the argument of the new full f if o1. 5 discussion up to now we have shown that by applying graph transformation techniques to reo, we are able to describe complex connector reconfigurations using a very compact notation. transformation rules are extended with colouring information so that they can be applied when a certain behaviour occurs. external invocation of the transformation is not required. in the current setup, the transformation engine is invoked in each run of the execution of the connector. even if the required colouring is not present, the engine first tries to match the structural pattern of the current connector and then validates its colouring. if the reconfiguration regions become larger, the pattern matching can cause a significant degradation of performance. note that general pattern matching for graphs is a problem that is known to be np-complete. figure 7: rule for a f if o∞ with an evolving reconfiguration region. to improve the performance of dynamically reconfiguring connectors, we suggest the following optimisation. we augment the transformation rules with information about the reconfiguration regions. for our example of the dynamic f if o we extend the rule as shown in figure 7. the dashed boxes mark the reconfiguration regions. with this extension we can state that the rule is always applied to the first f if o1. while before the reconfiguration region was growing with each application of the rule, it will now remain as consisting of exactly two nodes and one f if o1 only, all the time. this way, the pattern matching is much faster and (in the ideal case) always uniquely determined. 6 implementation reo as a modelling framework the reo modelling framework [ect] consists of a set of plug-ins for the eclipse1 development environment such as: a graphical editor, a model checker and a flash-based animation tool. executable instances of connectors can be derived by generating code from reo specifications or by interpreting these specifications. we generate code from abstract animation descriptions 1 http://www.eclipse.org 11 / 13 volume 10 (2008) http://www.eclipse.org reconfiguration of reo connectors triggered by dataflow when producing the flash animations [cp07]. we have implemented an interpreter2, based on the colouring semantics, for the application domain of web services. currently we are integrating the dynamic reconfiguration scheme into the interpreter. reo as a runtime architecture we are also developing a distributed reo engine [pro07], where each primitive is deployed and executed as an independent block running in parallel with the other primitives. there is no centralized entity computing the colouring table of the composite connector at each step, but instead the colouring table is obtained by distributed agreement. the engine has a mechanism to pause regions of the connector, making them suitable to be reconfigured. however, since the development is still in an early stage we are not able to integrate the dynamic reconfiguration yet. 7 future work the example of the dynamic f if o is certainly very basic. in general, there may be more than one reconfiguration rule (a graph grammar) attached to a region of a connector. the role that the colouring extension in our rules plays in these more complex scenarios must be investigated. furthermore, we need to make the notion of the evolving reconfiguration regions, as suggested in section 5, more specific. additional partial mappings from the lhs to rhs may be a possible approach to model this. we are interested in preservation of behavioural properties by transformations. two different classes of transformations are interesting in this setting: transformations that preserve the behaviour and transformations that change it. on the one hand, reconfigurations that do not change the behaviour are interesting in the area of automated refactoring and optimisation. on the other, reconfigurations that change the behaviour can be used to implement new sub-circuits that adapt the behaviour of a circuit based on dataflow. in this context, it will be interesting to do static analysis of reconfiguration rules to reason about behaviour preservation. finally, we want to integrate the dynamic reconfiguration triggered by dataflow into the reo tools. for this purpose, we will extend both the eclipse based development tools and the reo runtime engine for web services. since we model reconfiguration through graph transformation, and due to the fact that our implementation of the reo development tools is based on the eclipse modeling framework (emf)3, we plan to implement the reconfiguration extensions using the tiger emf transformation tools [emt]. bibliography [arb04] f. arbab. reo: a channel-based coordination model for component composition. mathematical structures in computer science 14:329–366, 2004. 2 http://www.cwi.nl/∼koehler/services 3 http://www.eclipse.org/emf proc. gt-vmt 2008 12 / 13 http://www.cwi.nl/~koehler/services http://www.eclipse.org/emf eceasst [bek+06] e. biermann, k. ehrig, c. koehler, g. kuhns, g. taentzer, e. weiss. graphical defnition of in-place transformations in the eclipse modeling framework. in model driven engineering languages and systems (models’06). 2006. [blmt07] r. bruni, a. lluch-lafuente, u. montanari, e. tuosto. style-based architectural reconfigurations. technical report tr-07-17, computer science department, university of pisa, 2007. [cca07] d. clarke, d. costa, f. arbab. connector colouring i: synchronization and context dependency. sci. comput. program. 66(3):205–22, 2007. doi:http://dx.doi.org/10.1016/j.scico.2007.01.009 [cla08] d. clarke. a basic logic for reasoning about connector reconfiguration. fundamenta informaticæ 82:1–30, 2008. [cp07] d. costa, j. proença. connector animation: a compositional framework to analyse reo connectors. december 2007. submitted. available online: http://www.cwi. nl/∼costa/publications/publications.htm. [ect] eclipse coordination tools. http://homepages.cwi.nl/∼koehler/ect. [eept06] h. ehrig, k. ehrig, u. prange, g. taentzer. fundamentals of algebraic graph transformation. eatcs monographs in theoretical computer science. springer, 2006. [emt] tiger emf transformation project. http://tfs.cs.tu-berlin.de/emftrans. [erm06] c. ermel. simulation and animation of visual languages based on typed algebraic graph transformation. phd thesis, 2006. [kla07] c. koehler, a. lazovik, f. arbab. connector rewriting with high-level replacement systems. in proceedings of foclasa 2007, to be published in electronic notes in theoretical computer science. 2007. [pro07] j. proença. towards distributed reo. talk presented at cic workshop, 2007. [ren03a] a. rensink. groove: a graph transformation tool set for the simulation and analysis of graph grammars. http://www.cs.utwente.nl/∼groove, 2003. [ren03b] a. rensink. towards model checking graph grammars. in leuschel et al. (eds.), workshop on automated verification of critical systems (avocs). technical report dsse–tr–2003–2, pp. 150–160. university of southampton, 2003. 13 / 13 volume 10 (2008) http://dx.doi.org/http://dx.doi.org/10.1016/j.scico.2007.01.009 http://www.cwi.nl/~costa/publications/publications.htm http://www.cwi.nl/~costa/publications/publications.htm http://homepages.cwi.nl/~koehler/ect http://tfs.cs.tu-berlin.de/emftrans http://www.cs.utwente.nl/~groove introduction reo overview connector colouring semantics connector reconfiguration reconfiguration triggered by dataflow run of a connector discussion implementation future work permutation equivalence of dpo derivations with negative application conditions based on subobject transformation systems electronic communications of the easst volume 16 (2009) proceedings of the doctoral symposium at the international conference on graph transformation (icgt 2008) permutation equivalence of dpo derivations with negative application conditions based on subobject transformation systems frank hermann 16 pages guest editors: andrea corradini, emilio tuosto managing editors: tiziana margaria, julia padberg, gabriele taentzer eceasst home page: http://www.easst.org/eceasst/ issn 1863-2122 http://www.easst.org/eceasst/ eceasst permutation equivalence of dpo derivations with negative application conditions based on subobject transformation systems frank hermann1 1 frank(at)cs.tu-berlin.de institut für softwaretechnik und theoretische informatik, tu berlin, germany abstract: switch equivalence for transformation systems has been successfully used in many domains for the analysis of concurrent behaviour. when using graph transformation as modelling framework for these systems, the concept of negative application conditions (nacs) is widely used – in particular for the specification of operational semantics. in this paper we show that switch equivalence can be improved essentially for the analysis of systems with nacs by our new concept of permutation equivalence. two derivations respecting all nacs are called permutation-equivalent, if they are switch-equivalent disregarding the nacs. in fact, there are permutation-equivalent derivations which are not switch-equivalent with nacs. as main result of the paper, we solve the following problem: given a derivation with nacs, we can efficiently derive all permutation-equivalent derivations to the given one by static analysis. the results are based on extended techniques for subobject transformation systems, which have been introduced recently. keywords: graph transformation, adhesive categories, subobject transformation systems, negative application conditions, process analysis 1 introduction transformation systems based on the double pushout (dpo) approach [cmr+97] with negative application conditions (nacs) [hht96, eept06] are a suitable modelling framework for several application domains, e.g. definition of operational semantics and simulation. in this context, the analysis of concurrent behaviour of an execution of the system is of interest. a process of an execution describes all possible equivalent executions. correspondingly, a process of a derivation defines an equivalence class of derivations. processes of graph transformation systems based on the dpo approach [cmr96] were defined as occurrence grammars in [bal00]. occurrence grammars were lifted to the abstract setting of adhesive rewriting systems [bch+06] in order to generalise the process construction. this opened possibilities for analysing processes of transformation systems based on arbitrary adhesive categories [ls04], such as typed graphs, graphs with scopes and graphs with second order edges. this paper extends the standard switch equivalence of derivations without and with negative application conditions to the so-called permutation equivalence of derivations with negative application conditions (nacs) in adhesive categories. the main difference is that there 1 / 16 volume 16 (2009) mailto:frank(at)cs.tu-berlin.de permutation equivalence of dpo derivations with negative application conditions are permutation-equivalent derivations with nacs, which cannot be derived by switching nacindependent neighbouring derivation steps. the challenge is to efficiently calculate derivations, which are equivalent in the sense that all nacs are respected and the matches of the original derivation are preserved. however, a direct construction of all permutation-equivalent derivations is complex in general. first of all, the amount of possible permutations is high in general and furthermore, the permutations have to be derived from the original derivation by computing the new matches and the new intermediate objects from the old ones and checking that all nacs are fulfilled. the main result of this paper is a framework for the efficient analysis of permutation equivalence, i.e. the efficient construction of all derivations, which are permutation-equivalent to a given one (see theorems 1 3 in sec. 5). the presented technique is based on subobject transformation systems (stss) [chs08], which can be constructed in advance, i.e. possibly before a user requests an analysis. they are based on the process construction given in [bch+06] and we extend them for the case with nacs. this builds the basis for efficient dependency checks between components of pairs of rule occurrences, where expensive pattern matching is avoided. the next section reviews transformation systems and introduces the new notion of permutation equivalence. thereafter, subobject transformation systems (stss) as process model of a derivation are reviewed and section 4 shows how the process construction can be extended to systems with nacs. thereafter, section 5 presents the analysis of permutation equivalence of derivations with nacs and shows as a main result that the analysis can be transferred to the derived sts leading to correct results for the original system. section 6 concludes the main results and discusses future work within the presented framework. 2 transformation systems and permutation equivalence in this section we review transformation systems based on the double pushout (dpo) approach and the standard switch equivalence of derivations. we present an example in the context of workflow modelling, where we use negative application conditions (nacs) and show that switch equivalence does not lead to all intuitively equivalent derivations in our example. for this reason we introduce the new notion of permutation equivalence, which leads to the discussed equivalent derivations. a derivation in an adhesive category c is given by a sequence of rule applications within a grammar. a transformation rule p = (l ←l− k −r→ r) consists of three objects l, k, r ∈ ob j(c) being left-hand side, interface, and a right-hand side, respectively, nac q | ee ""e ee l m �� noo (po1) k loo r // �� (po2) r m∗�� g doo // h and two monomorphisms l, r ∈ mor(c). the interface k contains the part which is not changed by the rule and hence occurs in both l and r. applying a rule p to an object g means to find a monomorphism m : l → g and to replace the matched part in g by the corresponding right-hand side r of the rule, thus leading to a transformation step g p,m =⇒ h. in this paper, matches are required to be monomorphisms. but as explained in [he08, her09b], the analysis based on subobject transformation systems is also possible for systems with non-monomorphic matching. a transformation step is given by a double-pushout (dpo), where d is the intermediate object after constructing the pushout complement for pushout (po1) and in (po2) h is constructed as gluing of d and r proc. doctoral symposium icgt 2008 2 / 16 eceasst via k. a sequence of transformation steps d = (d1; . . . ; dn) is called a derivation. a rule may contain a set of negative application conditions (nacs) [hht96, eept06]. a nac (n, n : l → n) of a rule consists of a negative pattern n together with a monomorphism n from the left hand side of the rule to n. intuitively, it forbids the presence of a certain pattern in an object g to which the rule shall be applied. a match l −m→ g satisfies a nac n : l → n, written m |= n, if there is no monomorphism n −q→ g with q◦n = m. typed transformations are based on a type object tg and the derived slice category c ↓ tg, where each object g is typed over tg by typeg : g → tg and morphisms are compatible with the typing morphisms. a grammar specifies a start object, a type graph and a set of rules for performing typed transformations. definition 1 (grammar) given a category c, a grammar gg = (sg, tg, p, π) consists of a type object tg, a start object sg, a finite set of rule names p and a function π , which maps a rule name to a rule with nacs p = (p, n) containing a rule p = (l ←l− k −r→ r) and a finite set of negative application conditions n. the start graph and the productions of gg are typed over tg. tg workson person task started sg :person :task :person l :workson 1:person 2:task :started k 1:person 2:task r 1:person 2:task :started nac1 2:task 1:person starttask r :workson 1:person 2:task k 1:person 2:task l 1:person 2:task r :workson 1:person 2:task k 1:person 2:task l 1:person 2:task :started finishtask stoptask continuetask l :workson 1:person 3:started k 1:person r 1:person 2:task nac2 :workson 1:person 2:task 3:started 2:task 3:started 2:task nac1 :workson :person 2:task 1:person 3:started 3:started figure 1: the graph grammar gg example 1 (graph grammar gg) figure 1 shows the graph grammar gg = (sg, tg, p, π) for mobile agents in reconfigurable networks. the mappings of the rule morphisms are specified by numbers. rule “starttask” assigns a person to a task via an edge of the type “workson”, but the rule is not applicable if the task was already started, as specified by the nac “nac1”. rule “finishtask” is inverse to “starttask” and removes the assignment and the edge of the type 3 / 16 volume 16 (2009) permutation equivalence of dpo derivations with negative application conditions “started”, while rule “stoptask” also deletes the assignment, but not the flag “started”. finally, rule “continuetask” specifies that a person may continue the work, which possibly was started by another person and stopped meanwhile. the nacs nac1 and nac2 of this rule require that neither the person itself nor another person is working on the task to be assigned. switch equivalence of derivations without nacs is based on sequential independence. definition 2 (sequential independence without nacs) let d = (g0 = p1,m1===⇒ g1 = p2,m2===⇒ g2) be a derivation without nacs in a grammar gg. then, d1 = g0 = p1,m1===⇒ g1 and d2 = g1 = p2,m2===⇒ g2 are two sequentially independent derivation steps, if there exist i : r1 → d2, j : l2 → d1 in the diagram on the right, which shows parts of the derivation diagrams, s.t. l′2 ◦i = m ′ 1 and r ′ 1 ◦ j = m2. k1 �� // r1 m′1 // ��/ / i "" l2 m2 �� ���� j || k2 �� oo d1 r′1 // g1 d2l′2oo remark 1 (local church rosser) two sequentially independent derivation steps without nacs can be switched by the local church rosser theorem (thm. 5.12 in [eept06]). by mk : lk → g′k we denote the match for rule pk in the new order of the steps. given a derivation without nacs, switch equivalence leads to the complete set of its equivalent derivations [bch+06]. note that dpo derivation diagrams are unique up to isomorphism only, thus we relate isomorphic derivation diagrams by “∼=” meaning that there are isomorphisms between the objects compatible with the involved morphisms. definition 3 (switch equivalence without nacs) let d = (d1; . . . ; dk; dk+1; . . . dn) be a derivation without nacs in grammar gg, where dk; dk+1 are two sequentially independent derivation steps. let d′ be derived from d by switching (dk; dk+1) to (d′k+1; d ′ k) according to the local church rosser theorem. then, d′ is a switching of d, written d sw∼ d′. switch-equivalence sw ≈ is the union of the transitive closure of sw∼ and the relation ∼= for isomorphic derivations. we now extend the notion of switch equivalence to derivations with nacs using sequential independence for derivations with nacs according to [hht96, leo06]. definition 4 (sequential independence with nacs) let d = (g0 = p1,m1===⇒ g1 = p2,m2===⇒ g2) be a derivation with nacs in a grammar gg. suppose that i : r1 → d2, j : l2 → d1 exist in the two derivation diagrams on the right, s.t. l′2◦i = m ′ 1, r ′ 1◦ j = m2. suppose also that the derived match m1 : l1 → g′1 l1 m1 �� k1 �� //oo r1 m′1 // ��/ / i "" l2 m2 �� ���� j || k2 �� oo // r2 m′2 �� g0 d1 r′1 // l′1 oo g1 d2 l′2 oo r′2 // g2 by the local church rosser theorem and the match m2 = l′1 ◦ j : l2 → g0 fullfill all nacs, i.e. m2 |= n2 for each nac (n2 : l2 → n2) of p2 and m1 |= n1 for each nac (n1 : l1 → n1) of p1. then, g0 = p1,m1===⇒ g1, g1 = p2,m2===⇒ g2 are two sequentially independent derivation steps with nacs. definition 5 (switch equivalence with nacs) let d = (d1; . . . ; dk; dk+1; . . . dn) be a derivation with nacs in grammar gg, where dk; dk+1 are two sequentially independent derivation steps with nacs. let d′ be derived from d by switching dk; dk+1 to d′k+1; d ′ k according to the local proc. doctoral symposium icgt 2008 4 / 16 eceasst church rosser theorem. then, d′ is a switching with nacs of d, written d swn∼ d′. switch equivalence with nacs swn ≈ is the union of the transitive closure of swn∼ and the relation ∼= for isomorphic derivations. g1 4:workson 1:person 3:task 6:started 2:person ⇒ ⇒ ⇒ g0 1:person 3:task 6:started 2:person g2 1:person 3:task 6:started 2:person g3 5:workson 1:person 3:task 6:started 2:person g4 1:person 3:task 6:started 2:person ⇒ figure 2: derivation d in the grammar gg example 2 (derivation in gg) derivation d = (d1; d2; d3; d4) = (g0 = continuetask,m1========⇒ g1 = stoptask,m2======⇒ g2 = continuetask,m3========⇒ g3 = stoptask,m4======⇒ g4) in fig. 2 describes that at first person “1” works on task “3” and afterwards person “2” works on the same task, but both of them stop without finishing the task. derivation steps d2 to d4 are dependent from their preceding steps and thus, no switching of independent steps is possible: the second step deletes edge “4” produced by the first step, the nac of the third step forbids the presence of “4”, which is deleted by the second, and finally, the fourth step deletes edge “5” that was created by the third step. however, there is a permutation of the steps, which is conceptually equivalent to the depicted derivation. consider d′ = (d′3; d ′ 4; d ′ 1; d ′ 2), where the third and fourth steps are moved to the front, all nacs are respected and the rules of gg are applied at the same places of the graph that is transformed. since switch equivalence is not general enough for transformation systems with nacs as shown and explained in example 2, we introduce the notion of permutation equivalence for derivations with nacs, which relates all equivalent derivations that respect the nacs. in particular, the equivalent permutation of the example can be derived by the new notion. definition 6 (permutation equivalence of derivations) two derivations d and d′ with nacs in a grammar gg are permutation-equivalent, written d π ≈ d′, if disregarding the nacs, they are switch-equivalent. a direct analysis of permutation equivalence in the adhesive category of the derivations is possible, but can be quite complex, if e.g. the graphs of the derivation are much bigger than in the simple running example. for each possible switching disregarding the nacs we have to update the derivation diagrams and perform pattern matching for the nacs on the updated objects in order to check whether the new derivation is permutation-equivalent. therefore, we suggest to first construct a process model based on subobject transformation systems, and then to perform a more efficient analysis on it. accordingly, the main results of this paper, given by theorems 1 3 in sec. 5, show that the analysis on the basis of stss is sound and complete and that the process model can be constructed efficiently. next, we will show how subobject transformation systems can be used as process model for a derivation without nacs. thereafter, we present in sec. 4 how they can be extended to the case with nacs leading to an efficient analysis framework for permutation equivalence, which is shown and explained in sec. 5. 5 / 16 volume 16 (2009) permutation equivalence of dpo derivations with negative application conditions 3 subobject transformation systems processes of a graph grammar are defined as occurrence grammars together with a mapping to the original grammar. the concept of occurrence grammars was extended to the more abstract setting of adhesive rewriting systems [bch+06] based on subobjects. this technique was further elaborated in [chs08] introducing the general concept of subobject transformation systems (stss). in this section we review stss and their construction from a given derivation without nacs. a subobject a of an object t of a category c is an equivalence class of monomorphisms a : a → t . we write a for short to denote a representative of the equivalence class and we leave the monomorphism a implicit. the category of subobjects of t is called sub(t ) and its morphisms f : a → b are those monomorphisms in c, which are compatible with the implicit monomorphisms to t , i.e. b◦ f = a for a : a → t and b : b → t . if such an f exists, we write a ⊆ b for short. definition 7 (subobject transformation systems) a subobject transformation system s = (s0, t, p, π) over an adhesive category c consists of a super object t ∈ c, a start object s0 ⊆ t in sub(t ), a set of production names p, and a function π , which maps a production name q to a production 〈 lq, kq, rq 〉 , where lq, kq, and rq are objects in sub(t ), kq ⊆ lq and kq ⊆ rq. the application of a production in an sts is based on union and intersection, which are coproduct and product in category sub(t ) and they can be constructed in the underlying adhesive category c as follows: a∩b is given by the pullback of a → t ← b and a∪b is given by the pushout of a ← a∩b → b. the implicit monomorphism of a∩b is given by a∩b → a → t and the one of a∪b is the induced one by the pushout property [ls04]. definition 8 (direct derivations) let s = (s0, t, p, π) be a subobject transformation system, π(q) = 〈l, k, r〉 be a production, and let g be an object of sub(t ). then there is a direct derivation from g to g′ using q, written g = q ⇒ g′, if g′ ∈ sub(t ) and if there exists an object d ∈ sub(t ) such that: (i) l∪d ∼= g; (ii) l∩d ∼= k; (iii) d∪r ∼= g′, and (iv) d∩r ∼= k. according to proposition 6 of [chs08] a direct derivation in an sts induces a dpo diagram in the underlying adhesive category c. therefore, a derivation in an sts, specified by its sequence of rule names, gives rise to a derivation in c. definition 9 (derivation of an sts-sequence) let ds = (g0 = q1=⇒ g1 =⇒ . . . = qn=⇒ gn) be a derivation in an sts s. let s = 〈q1; . . . ; qn〉 be the sequence of the rule occurrences according to ds. then, drv(s) denotes the sequence of dpo diagrams in c for each derivation gi−1 = qi⇒ gi in s. in order to derive all switch-equivalent derivations to a given one we can analyse its process, which is given by an isomorphism class of occurrence grammars together with a mapping to the original grammar as presented in [cmr96, bch+06]. an occurrence grammar directly corresponds to an sts and in fact, the construction of an sts in [chs08] from a given derivation tree coincides with the above construction of an occurrence grammar in the case of a linear derivation, i.e. there is a one-to-one correspondence between both representations. in analogy to proc. doctoral symposium icgt 2008 6 / 16 eceasst [bch+06], we explicitly define the start object s0 of an sts derived from a derivation instead of leaving it implicit. furthermore, this paper does not consider general derivation trees, but derivation sequences, for which we extend the analysis to the case with nacs in sec. 5. definition 10 (sts of a derivation) let d = (g0 = q1,m1===⇒ . . . = qn,mn===⇒ gn) be a derivation in an adhesive category. the derived sts of d is denoted by prc(d) and constructed as follows: prc(d) = (s0, t, p, π), where t is the colimit of the dpo-diagrams given by d, s0 is given by the embedding g0 ⊆ t , p = {(qi, i) | i ∈ [n]} is a set that contains a rule occurrence name for each rule occurrence in d and π maps each rule occurrence name (qi, i) to the rule occurrence at the i(th) step in d extended by the embeddings into t . the sequence of rule occurrence names of p according to d is denoted by seq(d). in [bch+06] the set of all linearisations of the process is derived using compound relations, which can be obtained from basic relations as shown in [chs08]. hence, we can use the following general relation of independence subsuming the basic relations for analysing switch equivalence. definition 11 (independence of productions in stss) let s = (s0, t, p, π) be an sts and let q1, q2 ∈ p be two production names, and π(pi) = 〈li, ki, ri〉 for i ∈{1, 2} be the corresponding productions. then, q1 and q2 are independent, denoted q1 ♦ q2, if (l1 ∪r1)∩(l2 ∪r2) ⊆ (k1 ∩k2). in the following, we define the switch equivalence for sequences of rule occurrence names within an sts, which will be used in sec. 5 for the analysis of permutation equivalence. definition 12 (switch-equivalence of sequences) let s = (s0, t, p, π) be an sts, let d be a derivation in s and let s = 〈q1, . . . , qn〉 be its corresponding sequence of rule occurrence names. let qk,qk+1 be independent in s, then the sequence s′ = 〈q1, . . . , qk+1, qk, . . . , qn〉 is switchequivalent to the sequence s, written s sw∼s s′. switch equivalence sw ≈s of sequences is the transitive closure of sw∼s . 4 subobject transformation systems with nacs in this section, we extend the definition of subobject transformation systems to stss with nacs. each rule in an sts is extended by an ordered list of nacs, which is later used by the dependency relations in sec. 5 for specifying the nac that is causing a dependency. definition 13 (sts with nacs) a subobject transformation system with nacs s = (s0, t, p, π) over an adhesive category c consists of a super object t ∈ c, a start object s0 ⊆ t in sub(t ), a set of production names p, and a function π , which maps a production name q to a production with nacs ( 〈 lq, kq, rq 〉 , n), where lq, kq, and rq are objects in sub(t ), kq ⊆ lq, kq ⊆ rq and n is an ordered list of negative application conditions with l ⊆ n[i] ⊆ t , where n[i] denotes the i(th) element of n. 7 / 16 volume 16 (2009) permutation equivalence of dpo derivations with negative application conditions direct derivations with nacs in an sts correspond to direct derivations with nacs in the underlying adhesive category, but the check of a nac to be found in the intermediate object g is simplified, because a nac in an sts cannot occur at several positions in g. definition 14 (direct derivations with nacs) let s =〈s0, t, p, π〉 be a subobject transformation system with nacs, π(q) = (〈l, k, r〉, n) be a production with nacs, and let g be an object of sub(t ). then there is a direct derivation with nacs from g to g′ using q, written g = q ⇒ g′, if g′ ∈ sub(t ) and for each n[i] in n: n[i] * g and if there exists an object d ∈ sub(t ) such that: (i) l∪d ∼= g; (ii) l∩d ∼= k; (iii) d∪r ∼= g′, and (iv) d∩r ∼= k. the extension of the process mapping prc for derivations with nacs in an adhesive category is based on the following instantiation of nacs applied for all derivation steps. definition 15 (instantiated nacs) let (ni, ni)∈ n be a nac of a rule p = (p, n) of a grammar gg = (sg, tg, p, π) in an adhesive category, with p = (l ←l− k −r→ r), let d be a derivation with nacs in gg, where p is applied at step k via the match mk, and let t be the colimit of the derivation diagram of d. an instantiated nac m of (ni, ni) is a subobject of t (m ⊆ t ), such that m ∼= ni, l ⊆ m and m is compatible with the typing of ni and with ni, i.e. typeni = typet ◦ incm,t ◦ isom and incl,m = isom ◦ni as shown on the right. the set of all instantiated nacs of p is denoted by nacst (p, mk). ni typeni 00 isom gg ##g g loo nioo � _ �� l l zzvv vv vv(=) m �� // t typet��(=) t g remark 2 note that given a nac, then the set of its instantiated nacs may be empty, which means that the nac cannot be found within t . furthermore, a set of instantiated nacs may be infinite if t or d are infinite. in this case the analysis in sec. 5 may not be decidable. however, in the case of finite derivation sequences and objects being finite in its structural part, e.g. finite graph structure of an attributed graph with an infinite algebra, we get a finite list for each nac. note further that (ni, incm,t ◦isom) ∼= (m, incm,t ) in sub(t ). definition 16 (derived sts with nacs) let gg be a grammar in an adhesive category c and let d = (g0 = p1,m1===⇒ . . . = pn,mn===⇒ gn) be a derivation in gg. the sts for d is given by prc(d) = (s0, t, p, π), where t is the colimit of the derivation diagram of d, s0 is given by g0 and its embedding to t , p is a set of rule names, each distinguished name qk corresponds to a derivation step dk = gk−1 = pk,mk===⇒ gk in d and the mapping π is given as follows: π(qk) = (〈lk ⊇ kk ⊆ rk〉, nk), where nk is an ordered list of the set nacst (qk, mk). the order of nk is arbitrary but fixed. the sequence of rule names of p in d is denoted by seq(d). t 4:workson 1:person 3:task 6:started 2:person 5:workson s0 1:person 3:task 6:started 2:person figure 3: super object t and start object s0 of the sts prc(d) example 3 (sts of a derivation) for the derivation d = (g0 = continuetask,m1========⇒ g1 = stoptask,m2======⇒ g2 proc. doctoral symposium icgt 2008 8 / 16 eceasst cont1 l 4:workson 1:person 6:started k 1:person r 1:person 3:task n1[2] 5:workson 1:person 3:task 6:started 3:task 6:started 3:task r 5:workson 1:person 3:task k 1:person 3:task l 2:person 3:task n1[1] 4:workson 2:person 3:task 1:person stop2 r 4:workson 1:person 3:task k 1:person 3:task l 1:person 3:task stop1 cont2 l 5:workson 2:person 6:started k 2:person r 2:person 3:task 6:started 3:task 6:started 3:task 6:started6:started n2[2] 5:workson 2:person 3:task n2[1] 4:workson 1:person 3:task 2:person 6:started6:started figure 4: rule occurrences of the sts prc(d) = continuetask,m3========⇒ g3 = stoptask,m4======⇒ g4) in fig. 2 we construct the sts s = prc(d) = (s0, t, p, π) as shown in fig. 3 and fig. 4, where numbers denote the embeddings to the colimit t of the derivation diagram. the start object s0 is given by g0 in d and its embedding to t . rule occurrences “cont1” and “cont2” correspond to the first and third derivation step, respectively. each nac of “continuetask” can be instantiated once, given by n1[1] and n1[2] for “cont1”. for “cont2” they are instantiated to n2[1] and n2[2]. the rule occurrences “stop1” and “stop2” correspond to the second and forth derivation step of d. as explained before in example 2, no switching is possible in d. 5 efficient analysis in order to analyse dependencies within the process prc(d) of a derivation d with nacs two new relations are introduced specifying weak enabling and weak disabling dependencies. here we can use the fact that the nacs in an sts are given as ordered lists to indicate the concrete nac instantiation that is causing a dependency. these relations are used to characterise the permutation equivalence of derivations with nacs by properties in the derived sts shown by the main technical result of the paper in thm. 1. intuitively, q1 weakly enables q2 if it deletes an item that is part of the forbidden structure of the nac n2[i] of q2. this means that there is an element in l1 ∩n2[i] that is not contained in k1 ∪l2. analogously, q1 is weakly disabled by q2 if q2 produces an item that is part of the forbidden structure of the nac n1[i] of q1. definition 17 (weak nac enabling) let q1 and q2 be two rules in an sts and let n2[i] be a nac of q2, i.e. n2[i] ∈ n2 for π(q2) = (〈l2, k2, r2〉, n2). the relation