Informatica 41 (2017) 233–252 233 Formal Development of Multi-Agent Systems with FPASSI: Towards Formalizing PASSI Methodology using Rewriting Logic Mihoub Mazouz Department of Mathematics and Computer Science, RELA(CS)2 Laboratory University of Larbi Ben M’Hidi, Oum El Bouaghi, Algeria E-mail: mazouz_mihoub@hotmail.fr Farid Mokhati Department of Mathematics and Computer Science, RELA(CS)2 Laboratory University of Larbi Ben M’Hidi, Oum El Bouaghi, Algeria E-mail: mokhati@yahoo.fr Mourad Badri Department of Mathematics and Computer Science, Glog Laboratory University of Quebec, Trois-Rivières, Canada E-mail: Mourad.Badri@uqtr.ca Keywords: formal development of MAS, PASSI, validation, verification, rewriting logic, maude, maude-strategy, model-to-text transformation Received: June 20, 2016 Agent technology has proved its ability and efficiency in modelling complex distributed applications. During the last two decades, several MAS development methodologies have been proposed like, for instance, Gaia, Tropos and PASSI. Although these methodologies have made significant contributions to meet several challenges in the MAS development field, most of them do not use formal techniques. Formal methods, as it is well known, play a significant role in developing more reliable and robust MAS. This paper presents the Formal-PASSI methodology. Formal-PASSI is an extension of the well-known PASSI methodology. The extension consists mainly of the integration of a new formal model to the design process. The new model is based on the Maude language and its extension Maude-Strategy. It aims at offering a formal description of the MAS under development by a Model-to-Text transformation. The generated formal description is then used to validate some PASSI behavioural diagrams and check properties of both single & multi-agent abstraction levels before passing to the code model. The integration of formal methods into PASSI design process seems a good way to ensure the development of high quality agent- based applications. The proposed approach is supported by a tool (F-PTK) that we have developed and illustrated throughout the ATM case study. Povzetek: V članku je predstavljena formalna PASSI MAS metodologija, tj. multi-agentna metodologija. 1 Introduction Current computing systems became increasingly complex with high safety requirements. Agent technology has proved its ability and efficiency in modelling complex distributed applications. As well as any other technology, the emergence of the agent technology pushes the research community to propose new methodologies, languages and tools to support it and to enable a wider spread in the industry sector. Many methodologies like PASSI [1,2], Gaia [3,4], ADELFE [5,6,7], Prometheus [8], Tropos [9] and INGENIAS [10] have been proposed to facilitate and to assist the development of Multi-Agent Systems (MAS). Although these methodologies have made real progress in the MAS development field, proposing new methodologies that assist agent-based systems development is still insufficient for industrial adoption [11]. The development of such systems requires solid bases in terms of specification. Existing methodologies use abstract and/or semi-formal specifications. Although such types of specifications offer several advantages such as the readability and the facility of comprehension, they have drawbacks like ambiguity and inconsistency, which are manually difficult to detect. However, formal specifications face these drawbacks and enable the description of the system under development in a precise and unambiguous way. Using formal methods is essential to produce high quality agent-based systems at the end of the development process. In particular, integrating formal methods into the development process of MAS methodologies leads to the production of reliable systems. In order to overcome the problems quoted above, many proposals are trying to use formal methods in agent- 234 Informatica 41 (2017) 233–252 M. Mazouz et al. oriented software engineering (AOSE) (see Section 2). However, most of them present several limitations, especially; they do not use formal methods within an entire design process. Moreover, many of them are not supported by adequate tools. PASSI (Process for Agent Societies Specification and Implementation) [1, 2] is a step-by-step requirement-to- code methodology for designing and developing agent- oriented systems that integrates concepts from both Object-Oriented Software Engineering (OOSE) and MAS using UML (Unified Modelling Language) notation. PASSI covers almost of development process stages, and can be used to assist the development of general-purpose agent-oriented systems although it has evolved from a long period experiment to the development of embedded robotics applications [12]. However, being PASSI based on a semi-formal language such as UML makes the validation and verification activities less efficient. In this paper, we propose F-PASSI (Formal-PASSI), a formalization of the PASSI methodology by adding a new formal model into its design process. The extension is based on rewriting logic [13, 14] and particularly the Maude language [15,16] (and its extension Maude- Strategy [17]). The integrated model aims at offering a Maude-based formal description of the MAS under development to enrich the semantic of its UML-based design. The produced formal description is then exploited to validate PASSI behavioural diagrams (some of them until now) by formal simulation thanks to Maude, and Maude LTL model-checker [18] in order to verify system properties in both single/multi agent abstract levels. A tool was developed to support our approach. The remainder of this paper is organized as follows: In section 2, we give an overview of major related works. In section 3, we give a brief description of rewriting logic as well as Maude language (and its extension Maude- Strategy). In section 4, a brief description of the PASSI methodology is given. We introduce, in section 5, the proposed formal extension for PASSI. Our developed tool is shown in section 6. In section 7, the ATM case study is used to illustrate our approach. Finally, section 8 gives some conclusions and future work directions. 2 Related works Using formal methods in multi-agent systems development is a challenge raised by many researchers in MAS area. El Fallah-Seghrouchni et al. have presented a classification of the proposed works on formal development of MAS [19]. According to the authors, three alternatives can be captured from the literature: (A) Formal derivation: which is a kind of model-to-code transformation and aims at realizing MAS based on a given specification. (B) Enhancement of an existing methodology by integrating formal meanings to its design. (C) Proposing a new one. The fact that our work can be considered as an integration of formal methods to an existing methodology, PASSI, makes our focus in this section on works belonging to the second category. 1 http://staruml.io In [20, 21], Ball et al. have presented an incremental development process using Event-B [22] for multi-agent systems. The proposed process can be divided into two stages. In the first one, informal models based on agent concepts are constructed. In the second stage, based on the informal models, the Event-B models are constructed by the developer, which is provided by guidance to make the transformation from informal design to formal models straightforward. The constructed Event-B models are refined and decomposed into specifications of roles. In [23], a set of modelling patterns providing fault-tolerance in Event-B models of multi-agent interactions are presented. Another work proposing a new formal methodology is ForMAAD [24, 25]. ForMAAD is a model driven approach for designing agent-based application. It uses Agent Modelling Language (AML) [26] to model architectural and behavioural concepts associated with multi-agent systems; and Temporal Z [27] to guarantee a formal verification of the models. Extensions of StartUML1 tool are made to support the models they proposed. Two works using formal methods for the Tropos methodology [9] can be emphasized here. First, Fuxman et al. [28] have proposed an extension of Tropos, Formal Tropos, with a formal specification of early requirements. For that, Formal Tropos language is defined by integrating the primitive concepts of Tropos with a temporal specification language inspired by KAOS [29]. After the translation (using the implemented T-tool2) of the requirements specification written by the analyst into an intermediate language, an enhanced version of NuSMV model checker [30] performs consistency checking (“the specification admits valid scenarios”), possibility checking (“there is some scenarios for the system that respect certain possibility properties”) and assertion validation (“all scenarios for the system respect certain assertion properties”). Secondly, in [31], a mapping of 𝛽- Tropos concepts [32] into the computational logic-based framework SCIFF [33] is defined and important formal properties (soundness, completeness and termination) are identified and discussed. The formal specifications are verified using SCIFF engine. Instead of writing it manually, as in the last works, the formal specification is produced in a systematic way in Formal-PASSI thanks to F-PTK (Formal-PASSI Tool Kit), the tool we have developed, this makes it, unlike Formal Tropos, less based on the subjective judgment of the developer. Also, in Formal-PASSI, the formal specification combines, in addition to the domain knowledge, the structure and behaviour of agents composing the MAS to be exploited later to validate and verify its correctness. Instead of proposing new formal methodologies for MAS development or enhancing existing ones, other researchers have used formal methods, separately from any methodology, for particular design aspects. Fadil et al. [34] have used the B method [35, 36] to formally model interactions between agents in order to check and then prove the initial UML specification. The approach was 2 http://disi.unitn.it/~ft/ft_tool.html Formal Development of Multi-Agent Systems with... Informatica 41 (2017) 233–252 235 illustrated using Contact-Net protocol as a case study. Jemni Ben Ayed et al. [37] have presented a specification and verification technique for interaction protocols in MAS by combining AUML (Agent UML) [38] and Event- B method [22]. In their technique, the interaction protocol is modelled in an AUML protocol diagram and translated in Event B. The required IPs (Interaction Protocols) safety and liveliness properties are added to the derived specification for verification using the B4free tool1. As B method, the Z language [39] and its extension Temporal Z [27] have been the subject of many works. In [40], the authors have presented a formal approach using Temporal Z in two phases. In the specification phase, user requirements are described in an abstract way avoiding the description of implementation details. Then, based on a succession of refinements, the design phase aims at inventing a set of inter-agent (collective) behaviours as well as intra-agent (individual) behaviours, which have to satisfy the user requirements. Other works address the use of formal methods in runtime to verify some properties (that are not verifiable in design phase) as in [41], where a JADE-based formal verification methodology for MAS in semi-runtime approach has been proposed. The proposed verification process used timed trace theory to detect time constraint failures. Lapouchnian et al. [42] have proposed a combined agent-oriented requirements engineering approach using informal i* [43] models, ConGolog [44] and (its extension) CASL [45] formal specifications. Social dependencies between agents are modelled using the i* framework. This framework is used to perform an analysis of opportunities and vulnerabilities. The models are gradually made more precise by using annotated models (Annotations are introduced in [46] and extended in [47]). After that, complex processes can be formally modelled using ConGolog or CASL with subsequent verification or simulation. In [48], the authors have presented an extension of G- net formalism [49] (a type of high level Petri net) called Agent-oriented G-net to serve as high level design of intelligent agents by means of their internal states, their environment, their interactions, etc. Based on this high level design, agent architecture and detailed design for agent implementation can be derived using the ADK tool they developed. Stamatopoulou et al. [50] have presented an open framework facilitating formal modelling of multi- agent systems called OPERAS by employing two existing formal methods: X-machines [51] and PPS (Population P Systems) [52]. By using this framework, agent’s behaviour can be formally modelled and controlled over its internal states, as well as the mutations that occur in the structure of a MAS. The authors have applied the framework to swarm systems. Compared to the works discussed above, the approach we propose: (1) integrates formal methods, not separately from any methodology, but into an entire design process (PASSI design process), (2) is based on a powerful formal language, Maude, which offers many tools as Maude LTL model checker [18], (3) checks the specified properties 1 http://www.b4free.com before passing to code details, (4) is supported by a tool (F-PTK) which offers many services such as automating the production of the Maude-based formal description of the MAS under development by means of its structure (Agents, roles, tasks, action tasks) and the domain knowledge. 3 Rewriting Logic, Maude & Maude-Strategy 3.1 Rewriting Logic The rewriting logic was introduced by Jose Meseguer [13, 14] to describe concurrent systems. It makes it possible to think in a correct manner on the concurrent systems having states and evolving in terms of transitions. Indeed, the rewriting logic unifies several formal models which express concurrency as labelled transition systems [53], Petri nets [54] and CCS [55]. The basic statements of this logic are called rewriting rules and have the form: t → t' if C, where t and t' are algebraic terms describing a partial state of the concurrent system. A rewriting rule, in this case, describes a change of a partial state towards another if a certain condition C is true. Formally, a theory of rewriting is a triplet R = (∑,E,R) where:  (∑, E) an equational theory with function symbols ∑ and equations E;  R a set of labelled rewrite rules. These rules are of the form: 𝑡 → 𝑡′ (unconditional rewriting rules) or 𝑡 → 𝑡′ 𝑖𝑓 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛 (conditional rewriting rules). The unconditional rewriting rules indicate that: the term 𝑡 becomes 𝑡′, but, the conditional rewriting rules indicate that: 𝑡 becomes 𝑡′ if a certain condition is true. A theory of rewriting has a set of inference rules [13, 14]:  Reflexivity: For each [t] ∈ T∑, E (X), [𝑡]→[𝑡′]  Congruency: For each 𝑓 ∈ ∑ 𝑛, 𝑛 ∈ 𝑁 [𝑡1] → [𝑡′1] … [𝑡𝑛] → [𝑡′𝑛] [𝑓(𝑡1, … , 𝑡𝑛)] → [𝑓(𝑡′1, … , 𝑡′𝑛)]  Replacement: For each rewriting rule: r: [t(x1,…, xn)] → [t’(x1,…, xn)] in R, [𝑤1] → [𝑤1 ′] … [𝑤𝑛] → [𝑤𝑛 ′ ] [𝑡(?̅? 𝑥⁄ )] → [𝑡′(?̅?′ 𝑥⁄ )] Such as 𝑡(?̅? 𝑥⁄ ) indicates the simultaneous substitution of wi for xi in t.  Transitivity: [𝑡1]→[𝑡2] [𝑡2]→[𝑡3] [𝑡1]→[𝑡3] . Figure 1 visualizes each one of these rules. 236 Informatica 41 (2017) 233–252 M. Mazouz et al. Figure 1: Visualization of inference rules of a rewriting theory [14]. Among the languages implementing the rewriting logic, we quote CafeOBJ1 [56] and Maude [15, 16]. 3.2 Maude language Defined by J. Meseguer, the Maude language [15, 16] is one of the most powerful implementations of the rewriting logic. Maude is a high level, very powerful, declarative language for the construction of the various kinds of applications based on both equational and rewriting logics. It offers few syntactic constructions and well- defined semantics. The basic unit of specification and programming in Maude is the module. In fact, there are three types of modules: Functional modules: Define the sorts of data and the operations on these data through equational theories. The sorts of data are composed of elements which can be called by terms. A functional module is declared according to the following syntax: fmod MODULE-NAME is … endfm System modules: Specify a rewriting theory. A system module has sorts, operations and can have equations and rewriting rules, which can be conditional. A System module is declared as follows: mod MODULE-NAME is … endm The addition that a system module offers (compared to a functional module), is the ability of specifying rewriting rules. The unconditional rules are declared as follows: rl [