Abstract
An agent is an autonomous entity that can perform actions to achieve its goals. It acts in a dynamic environment that may engender failures regarding its behavior. Therefore, a formal testing/verification approach of the agent is required to ensure the correctness of its behavior. In this paper, we propose a Default Logic formalism to abstract an agent behavior as knowledge and reasoning rules, and to verify and test the consistency of the behavior. The considered agents are implemented with JADE framework. Also, agent abstraction is translated into Answer Set Programming and solved by Clingo to generate dynamic and adaptive test cases of the agent behavior. The dynamic test cases allow predicting the agent behavior when a new information arises in the system.

Introduction
Several distributed applications are now increasingly being designed as a set of autonomous and interactive agents. These sets of agents are named multi-agent systems (MAS). Several architectures, models and tools have been proposed to develop MAS and they have been applied to various application domains, such as medical monitoring, traffic control, UAV control and robotic.
For most multi-agent applications, it is necessary to ensure the correctness of their implementation before their deployment. To boost the success of MAS, it is important to develop verification solutions. The verification process includes checking of documents, design, code and programs whereas the validation process includes testing and validation of the actual product. To validate something such as a claim or statement, we have to prove or confirm that it is true or correct. During this process, the difference between the actual result and the expected result can be identified and corrective action can then be considered. Therefore, the verification finds the bugs early in the development cycle whereas testing finds the bugs that verification cannot catch in the case of agent behavior, especially when dealing with a false or an unknown information.
To deal with this testing issue, several testing methodologies have been proposed, some consider inferential models and model-based tests [14, 30] and others exploit genetic algorithms in the field of combinatorial tests [26, 28, 27]. Also, the most important consideration in testing a program is the design of the test scenarios [10]. However, creation and completeness of these scenarios cannot guarantee the absence of errors. The test scenarios are important, but the full coverage of the tests is almost impossible; an implemented test strategy tries to put as many full tests as possible. The key issue of testing is reached when the subsets of all the scenarios have a chance of detecting a wide coverage of the errors.
These methodologies are suitable for testing deterministic behaviors, i.e., behavior will move in the same direction continuously. Moreover, they consider that any fact is true or false. They don’t propose any solution to deal with unknown information and adaptive agent behavior. Agent behavior is not always based on classical logic. Non-monotonic reasoning provides a suitable solution to deal with unknown information and non-deterministic behavior.
Non-monotonic reasoning depends on knowledge and facts. It will change with the improvement of knowledge or facts which may be incomplete or unknown. Adding knowledge will invalidate the previous conclusions and change the result. Hence this reasoning is useful in a domain such as (MAS). Recently Mendez et al. [24] treat the errors related to the code branching conditions by injecting parameters into the code and find diverse inputs by perturbing the injected parameters. The created test suites are focused on specific program parts. But the treatment of unexpected situation facing to the handling of an unknown information is still an open issue.
To address this problem, we focus on the testing process, both on the code added/modified by the developer which requires adaptation of the tests (to suit a new situation), and the handling of information. This information may be false or unknown but it is necessary for the reasoning of the agent behavior. We propose to use the non-monotonic reasoning to build an abstraction of the agent behavior, especially the Default Logic (DL) [34], that is motivated by its capability to treat the unknown or incomplete information by describing the knowledge representation and default reasoning rules. An algorithm for constructing the agent theory (knowledge base and reasoning rules) in the form of Answer Set Programming (ASP)1 is provided. Then using it by Clingo solver2 which produces an abstraction of all possible paths as stable models. Another aspect that has not been treated in previous works is the adaptation of test cases at runtime. Thereby, we develop a complementary module that transforms models into test cases with disruptive values. Moreover, an implementation of the proposed approach is provided upon Jade framework [5]. It includes a module for capturing3 the agent behavior and applying an appropriate strategy about a real dynamic behavior at runtime.
The remainder of this paper is organized as follows. Section 2 presents the related work and highlights the open issues. Section 3 presents an overview of the preliminary definitions of Default Logic as well as some formulas that we have defined according to our context. Section 4 describes a conception of our solution, then a case study is proposed in Section 5. Section 6 concludes this paper and gives some future works.
Literature review
Very few works have been developed for verifying and testing MAS. Most of these works use Prolog or Petri Net formalisms [7, 35]. We distinguish two kinds of approaches: monotonic approach and non-monotonic approach. Unlike the monotonic approach, the non-monotonic approach deals with unexpected behaviors.
In the monotonic approach, the work of Roungroongsom and Pradubsuwun [35] is centered on verification in order to detect the safety and time constraint failures that may happen at design time. It relies on Time Petri Net as a tool to model the input verification. It observes a MAS runtime and collects the messages. The latter are then converted into a Time Petri Net. Briola et al. [7] propose a solution for Jade. This solution extends the Jade Sniffer agent for distributed runtime verification, which is dedicated to intercept the exchanged messages during the execution, and verifies the messages by a Prolog-based tool. It verifies that interactions are compliant with the agent interaction protocols, but it does not cover the exceptional scenarios inside the internal implemented agent behavior. The work of Lacey and Deloach [19] introduces a formal methodology, where the agent messages are converted into a model with Promela modeling language. That model is then analyzed by SPIN to check the correctness of interactions. Also, Lam and Barber [20] propose a tracing method and a tool to verify an expected agent behavior in a MAS. It captures runtime data as actual agent behavior and creates modeled interpretation in terms of agent concepts (e.g., Belief, Desire and Intention).
These works of the monotonic approach aim either verifying the interaction protocols or guiding debugging efforts. They consider that the test designer knows the whole list of behaviors. However, the adaptation of tests to unexpected behaviors remains an open issue.
In the non-monotonic approach, recent test and verification methods mainly focus on the logical formalism to design the correctness of the agent reasoning. Most of these methods apply model checking to context-aware multi-agent systems. In [33, 32], the authors propose a formal modeling of resource-bounded context-aware systems. They handle inconsistent context information using defeasible reasoning, by focusing on automated analysis and verification. A model checker is used to perform automated analysis of the system (the desirable properties are expressed as LTL formulas) and verify non-conflicting context information guarantees it provides.
Zhang et al. [23] analyze pervasive computing systems which use a context awareness and concurrent communication. They adopt a CSP like hierarchical modeling language to model desirable systems, which could be used to encode and verify system properties using existing model checking techniques. The verification is based on the PAT model checker [39] and it is applied to a health care case study. However, it is not clear whether the predefined rules are used in a non-monotonic way. Sama et al. [36] model and verify an adaptive context-aware behavior of mobile applications by the adaptation of finite state machine. They propose some algorithms that are used to automatically detect fault patterns. They detect adaptation faults by exploring the space constructed by all possible value assignments to context variables. Preuveneers and Berbers [31] use SPIN model checker to verify a smart home environment and discuss consistency in context-aware behavior. Their work consists of designing rules based on general observations and showing how these rules can be inconsistent and lead to undesirable system behavior.
Another category of non-monotonic methods rely on Answer Set Programming (ASP), such as reasoning about actions and changes [4, 18, 17]. They study agent interactions by reasoning about agent observations of the world and also about the knowledge of other agents. Burigana et al. [8] address the problem of reasoning in multi-Agent epistemic settings exploiting declarative programming techniques. In particular, they present a modeling multi-agent epistemic planning in ASP. Moreover, other works [2, 38] focus on describing and reasoning about truthfulness of agents using answer set programming. These works illustrate the knowledge of the observations on the actions and the normal agent behavior. Furthermore, they evaluate over time the statements made by agents against a set of observations. i.e., starting from a collection of observations about the word state or actions performed by it. Then ASP program computes the truthfulness of statements of agents overtime.
The different works of the non-monotonic approach propose promising solutions. However, they don’t propose any solution for testing agent behavior in presence of incomplete information. The agent often receives new information which may be unknown and it must reason even in the absence of information. Tester aims to interpret or provide a meaning for an obscure behavior which inner reasoning is otherwise undesirable or non-understandable by the human observer.
In our testing approach, we share the idea of Enoiu and Frasheri [12] that relies on an autonomous agent. It includes a test agent which is more adaptive than a test case. It is described as a dynamic entity that can decide who and what the software should execute at runtime rather than a test case which is defined at the design step. The proposed approach is thus promising. But it has not yet been implemented using available agent technologies such as Jade [5], MCMAS [21], Netlogo,4 SeSAm,5 …etc. The use of Default Logic to formalize the captured agent behavior is proposed in the next sections.
Formal preliminaries
This section introduces Default Logic and describes the proposed predicates used in the proposed testing approach.
Default logic
where
Sometimes
A default rule
where
As Reiter’s corollary:
A closed default theory If a closed default theory has an inconsistent extension then this is its only extension. A default is called normal iff it has the from:
Thus,
where
The rule is called constraint if the
Consider a set of ground literals
We now present a concrete system to formalize an agent theory as DL [16] using ASP. We select this language because several efficient ASP solvers are available and it is used by several default reasoning approaches [9, 4, 13, 29, 37, 8, 17]. We thus use ASP to formalize the knowledge and reasoning of a captured software agent behavior (see Section 4) and a Clingo solver to generate all possible models. Let us describe some statement definitions.
A capture statement about a literal
where A capture statement about a fluent literal
where A statement holds and at about a fluent literal
Respectively, we say The default is of the form
where The applied default is represented by
We say the default A knowledge base (
For A
This means that all Applied Defaults (
Software testing [25] is an activity that aims evaluating a part of program by verifying whether it produces the required output for a particular given input. The goal of testing is not to provide means for establishing whether the agent behavior is totally correct; testing is a pragmatic and cheap way of finding errors by executing some test. Tests rely on a set of test cases. A test case is a specification of some input
This paper focuses on testing the behavior of a software agent. The behavior represents an agent task or function. It may be a simple behavior, a decision behavior or a knowledge-based behavior.
The assessment of an agent behavior is done by testing its sub-behaviors (denoted by sb) considered as unitary, which correspond to the small parts of the behavior to be tested. While each unit is tested according to the black box testing. In this way, the agent behavior can be tested and verified by adding or modifying information to cause an undesirable behavioral due to cycle changes.
Overview of the strategy process
An overview diagram of the test strategy process.
The formulation of the test of agent behavior is related to the properties of the agent that are deemed essential and on which the test will be based. The behavior requirements must be formally specified as testing properties, as shown in Fig. 1, important steps are used to specify the agent behavior. a Fig. 2 describes different steps of the construction process of an agent theory in the appropriate format. Steps are as follows:
In both steps (i) and (ii), we must use the Capture, Decomposition and Transformation (CDT) module (as described in Section 4.3). It is developed in AspectJ8 and Java to capture, split and transform the agent behavior into exploitable properties.
Activity diagram of a partial CDT process (for the corresponding Algorithm 1–3).
To make the previous process less ambiguous, we transform the software agent behavior into logical form. As shown in Fig. 2, CDT transforms the input data of agent behavior description (Step i) into output data as sub-behaviors (
The data description can be represented as a sequence of symbols from a particular alphabet. Without any loss of generality, let a behavior
Data decomposition: Data composition: Transitive composition:
Data composition and decomposition simply assume that captured data can be combined or split, without any loss of information. The transitive composition ensures that the transition is established between
A part of the CDT module is responsible for the capture. Firstly, as detailed in Fig. 2, it captures the behavior of the software agent by defining the points and parts of code which are identified as the source of input data. Followed by the decomposition, it concerns a recursively splitting of the agent behavior into sub-behaviors (
: Spliterb Agent Behavior
: Decomposerbeh – Agent Composite Behavior true or false
c: childs in beh call Spliter(c) set Strategy.Edge();
However, the set of defaults
: models Construct
m: models in satisfiable
Each default is formally represented as
Construction of the agent extended theory
Oriented graphs a.b.c
During the running step (see Step ii), the agent starts running its behavior with one of the created and chosen models
As depicted in Fig. 3b and c, let be a default
Simply, the application of a default corresponds to a transition from state
: Input and output setsAD set (In, Out) Sets
Also, during Step ii, CDT captures the AD and constructs the In and Out sets according to Eq. (13). Algorithm 3 shows the collection of the information gained by the application of the defaults in
Once all the defaults included in
: Successful of defaults setIN and OUT setsIN list of the current knowledge base after the defaults in
: Process of defaults set
Once the obtained list is in an exploitable state, it can be accompanied by a special configuration which determines the logic of sequencing or scheduling tests. Generally, a test of a component is simply conditioned by the inputs and judged by its outputs. But when we have a grouping of tests with a specific order, a new policy which consists of the ordering is imposed. Separating and scheduling consists in determining which are the input values that are appropriate for each subcomponent and what is the consequence of a sub-component among the group on the overall behavior. As indicated in Section 4.3, the captured sub-behavior is presented as the smallest sb. Chaining involves linking discrete sb together in a series, such that each result of each sb is both the reinforcement (or consequence) for the previous sb, and the stimuli (or antecedent) for the next sb.
There are many ways to test chaining, such as (i) forward chaining: starting from the first behavior in the chain, (ii) backwards chaining: starting from the last behavior, and (iii) total task chaining: in which the entire behavior is tested from the beginning to the end, rather than as a series of steps. As a simple example, we consider the different actions of opening a locked door, first the key is inserted, then turned, then the door opened. Table 1 shows the level of testing actions. Consider the following actions:
a1 a2 a3
which correspond to the following states: inserted, turned and pushed.
Level of testing actions
On Table 1, we see on the first line, the insert action is considered as the test subject and turning and pushing are the actions that follow. Once that is tested, the subject is to test it turn, then opens the door as the next step. Then push the door is considered as the subject of test and the insert and turn are taken as previous actions. Once the first step is mastered, the entire task is tested individually. Finally, total task chaining would involve testing the entire task as a single series, prompting through all steps. But before that (line 6), we also test two actions as one unit (line 4 or line 5); insert and turn as the entire test subject and push as the action following it. Or turn and push as a whole test unit and insert as an action before it. For each sub-behavior test in the chain, we would induce disrupting elements at each level of the chain.
Usually, the test case suite is created at the design stage and has a static character, and any change requires manual intervention by the developer. We evolved this by making it more dynamic to the execution context and adaptive to the change in the code of the software agent. i.e., if description of the agent behavior changes, the CDT captures the new program code and regenerates automatically another list of inputs more appropriate for the implemented behavior.
Given the agent program
The
The test case constructed in this step is based on the path search of nodes connection and the real execution for them. However, with a received messages from another agent, at runtime, information will be added into the knowledge base (
In order to disrupt the agent behavior, the CDT module decomposes the behavior and retrieves all the connections and the order between sub-behaviors. At this step, the process is based on the created models as satisfiable and the CDT looks for all the inputs that lead the behavior to the unwanted goal. The CDT applies the principle of reinforcement to strengthen the behavior towards failure. It disrupts each sub-behavior in the chain and tests the failed case.
As indicated in Algorithm 4.3, Clingo solver generates answers set as stable models with length
A consistency test
To show inconsistency in the knowledge base, by so-called defeated tests, Algorithms 3 and 3 show implemented methods, where
Formally as depicted in Fig. 4, a transition from
A consistency transition.
Three predicates are defined to conclude the state of the termination of the agent’s behavior: stable, disrupted or abnormal. If the agent is constructive with the new information, it must be finished in stable state. Otherwise, if it finished in conflict then the state is fixed to disrupted, i.e., the interaction has effect upon the behavior of agent. An additional state is added for the case of the occurring of an unexplained situation and it is labeled an abnormal state.
Let’s now some ASP rules, the Eq. (14) means that the agent
The Eq. (15) means that agent is stable at time
Otherwise, it always remains a mystery when we cannot prove the state of the behavior if it is stable or disrupted therefore remains unknown. It is represented by the rule in Eq. (17).
To illustrate the proposed testing approach, we consider the examples used in [38, 2]. In these examples, the formalization of knowledge is carried out in the framework based on reasoning about agent beliefs and truthfulness.
Example 1
A Person X is walking in a good area of the city when suddenly another person Y appears and carries a knife walking towards him. So, X is afraid and he decides to defend, X person shoots the Y person hardly and that causes his death to the latter. When the police arrived, they started their investigation and they were faced with the following situations:
Is the case manslaughter? During the confrontation punches went off and they caused the death of Y. Is the case an intentional homicide? This case is classified as self-defense despite the death.
During the investigation the police realize that the knife is fake. However, the question that arises is whether the culprit was aware or not? In this example, we demonstrate that the arise of a new information leads to contradictory knowledge.
To present a demonstration of our approach on the JADE framework, the developer will code it in a sequential behavior type as shown in Fig. 5, which will generate a single program
As described in Section 4, this will give us the results of generated defaults as detailed in the following.
A nominal and disruptive Test Cases (
State diagram of the sequential behavior of the man in imminent danger.
However, to make the example more interesting for the demonstration, we encoded it as Finite State Machine (FSM) type as depicted in Fig. 6. It is composed of five states except initial and final states. As described in Section 4, the generation of
For the set
Running of the selected dTC
State diagram of the FSM behavior of the man in an imminent danger.
The first line indicates when we disrupt the sb (inImminentDanger). We observe
However, in line 3 when we disrupt
An interesting application of our approach is the detection of Man-in-the-Middle (MITM) attacks targeting computer and cyber-physical systems. The principle of an attacker is to become embedded between two communicating parties and to capture the exchanged messages. Once possession of the information is achieved, it can exploit it in an undesirable way. For example, we consider pushing the system to a crash by modifying the data or simply stealing secret information. This kind of attack has already been used on the Stuxnet9 system, targeting a specific industrial model which is the programmable logic controller (PLC).
The state diagram of the FSM behavior of the MITM example.
Figure 7 describes the formalization of the states and transitions of the MITM example. In the same way as the preceding example, the defaults obtained from this are as follows:
When we apply the dTC to some program
The alert condition leads to hot_room state then overheat state if it is still true. The cold leads to not_hot_room, cold and not alert lead to the same state. Although the alert is triggered, the climate indicator still indicates a cold state, which explains an inconsistency somewhere. This leads us to see the problem that can occur on the system and to think that either the warning indicator is defective (it was triggered for no reason), or the temperature sensor does not work anymore and indicates false values. Therefore, we add the default indicated by the dashed arrow in Fig. 7 that can represent an attack or an intrusion on the system.
Through the two examples used in this section, we succeeded in illustrating our approach, we managed to predict some exceptions by the disruptive test sequence. In the first example, Balduccini et al. [2] and Son et al. [38] solved the problem of the diversion of fake knife to prove the innocence of the person
However, the authors presented a solution to an already produced and detected problem. An interesting question is how does the developer come to see a problem that it’s not yet produced at a very early stage by testing?
Conclusion
The paper proposed a new testing approach based on adaptive test cases as well as the handling of false or unknown information. This approach uses the Default Logic formalism to abstract a software agent as default reasoning. The agent behavior is disrupted through default theory justifications. The latter correspond to the code transition conditions and use a Clingo to find an inconsistency in the knowledge base of the agent by disrupting the injected parameters. The testing approach does not only cover the errors that are visible in the code, such as the classic errors related to the code branching conditions. Thereby, it helps the Jade developers to improve their code at an early stage when some information is false or unknown, and to better identify the undesirable situations that may arise at any time. The approach has also been used to demonstrate how a software agent behavior upon Jade framework can be abstracted on the Default Logic (in the form of ASP) for building agent-based testing.
To validate the testing approach, we apply it to two examples. Through these examples, we were able to foresee some exceptions by the disrupting the test sequence. The results show that the approach is able to cover a desired test case face to the modifications in the code of the jade agent behavior. Moreover, adding the translating code into ASP improves the test vision and the failure detection, especially, when handling false and unknown (absent) information, and the ability to forecast a scenario that prevents the undesirable situation.
To improve our approach, we plan to expand the field of justifications set which defines an area of defaults that can be inserted or retired according to the evolving conviction. It consists of a set of default justifications. Thus, we will analyze the sub-behavior as a white box testing to conclude all justifications set of default theory. For this, we can totally or partially disrupt the agent behavior, in order to show the risk level of failure.
Moreover, in the proposed approach, the behavior of the agent is tested against its sub-behaviors according to black box testing. It should be interesting to consider the different message exchanges with other agents, in order to improve goal achievement, or affect the agent and prevent it from normal reasoning. By adding the messages into the default rules [11], we will be able to widen the field of justification, and treat the received messages as false, absent or unknown information. And in this case, the tests will be considered as a partial white box testing.
Footnotes
Rules with variables are viewed as shorthand for the set of their ground instances.
Author’s bios
