A Generic Model for State-based Agent Systems

This paper presents a framework for modelling state-based agent systems. Agents are state-based entities in a possibly distributed environment. We will in particular address problems that arise when aspects of locality and shared objects have to be dealt with. The Irish School of Constructive Mathematics CM♣ provides an algebraic framework based on group theory and recursion theory. Monoids are used to model the foundations of state-based systems: states and state change. It offers extensivemethodologicalmeans to develop and verify specifications of distributed, state-based systems. 
 
This paper is an investigation into structural and consistency aspects of dynamically evolving systems under consideration of locality and sharing. A model is presented which preserves the integrity of such systems by providing operators with appropriate algebraic properties.


Introduction
The notion of state is predominant in a large number of systems from programming languages, data repositories (such as file systems or data bases) to agent-or process based architectures.Having an internal state that can be modified is a common property of objects in those systems.Active entities that live in an arbitrary (modifiable) environment -we will call them agents in a world -may also have an effect on the state of other entities.This access might depend on statically predefined structures and also the dynamic shape of the current world.Thus, each agent might have its own perspective or view on the world in a particular state.Agents deal with instantiations of certain notions (i.e.resources) which are stored as part of their state.These notions might be in a simple case just identifiers denoting some kind of entity.
Defining such a system formally, we can profit from the advantages offered by formal methods: unambiguity, preciseness, abstractness.The Irish School of Constructive Mathematics (CM | ) is a mathematical framework for formal specification (see its influence on the design of the Irish School of VDM (VDM | ) [6,10]) and is mainly based on the works of Mícheál Mac an Airchinnigh [1,2,3].The technical contribution of our paper is a generic model for agent systems enhanced by results that allow us to deal with problems that occur if there are conflicting non-local notions for an agent (e.g. which non-local identifier has to be accessed).Our model allows the discussion of general properties of agent systems.The model will be applied for agent-based planning in distributed artificial intelligence and programming language semantics.Programming language semantic will appear to be a very suitable application to illustrate our ideas.
We will show that our generic model (which could as well be specified in VDM [13] or Z [23] in a similar way) benefits in particular from the results of Constructive Mathematics when reasoning about the model has to be done.Especially recent results from monoid theory will be applied.Integrity aspects such as controlled changes on non-local objects can be guaranteed.
Content.Section 2 introduces principles of Constructive Mathematics.The specification for simple state-based systems is dealt with in section 3.In the following section 4 the full model is presented and more sophisticated ap-1st Irish Workshop on Formal Methods, 1997 plications in our approach are investigated.The Appendix summarises some more advanced results of Constructive Mathematics related to the presented work.

Irish Constructive Mathematics
In CM | we always start with building a model in the problem domain.CM | concentrates on exhibiting structure and relationships between structures.Therefore, the algebraic structures group and monoid are the foundation of our approach.In fact, monoids are a very common structure in Computer Science.They characterise data types (sets) with an associative binary operation and an identity element under the operation (inverse elements as required for groups are not so common yet).
The basic structures (power set, sequence, map) are the results of applying functors P,, , ? and , ! , (resp.) to domains.',' is an argument placeholder.
1.The powerset functor P : A 7 !PA constructs PA for a domain A. 2. For domain A the star functor ?: A 7 !A ? constructs the domain of sequences.3.If A and B denote domains, then the domain of maps (partial functions) is constructed by !: AB 7 !A ! B. X !Y denotes the space of all partial and total mappings from X to Y .By Y X we denote the space of all total mappings X !Y .The removal of a map 2 X !Y with respect to a set S 2 P X is denoted by S , .This expression can be expressed in the curried form , S or , S .The significance of this notation will become clear if used in combination with other operators, e.g., 0 = I !, S , where I is the identity function and 2 X !P Y .
S denotes the restriction of a mapping 2 X !Y by a set S 2 P X (complementary to removal). 1 t 2 denotes the extension (augmentation) of the mapping 1 2 X !Y by the mapping 2 2 X !Y when the domains of the mappings are disjoint.dom and rng denote domain and range of a mapping.=fS 1 ; : : : ; S n gabbreviates S 1 Natural numbers form a monoid under addition with 0 as identity.Words over some alphabet form a monoid under concatenation (this is usually referred to as the free monoid).Priming of domains denotes the removal of the identity element.
A monoid homomorphism h from the monoid M;; u to some other monoid P; ; v is a map h : M !P such that If the sets from the domain and range monoids of h coincide then h is called an endomorphism.
1st Irish Workshop on Formal Methods, 1997

State-based Systems
In this section we will investigate principles of state-based systems to give a flavour of specification and reasoning of state-based systems in our mathematical framework.The core elements of CM | have been presented in section 2. A summary of the mathematical machinery we use for our generic model can be found in the Appendix.We will refer to particular sections if necessary.
A notion of state is the basic mechanism on which the agents of our worlds rely.Therefore, the principles of specifying state and state change and reasoning about it will be presented here in an introductory section.
State-basedness is one of the paradigms in computing.In denotational semantics of programming languages [24, 9] a domain of memories is assumed.This is similar to the view of computers as machines with memory.We can define the meaning of a program (or the computation on a computer) by a partial function on memories.

Simple State-based Systems
A simple system can be defined by an abstract machine consisting of a state and operations on that state.The simplest notion of state is that of mapping some notions to associated elements, e.g.identifiers to values, expressed by the space X !Y .This space will be later on used to represent local states of agents.The simplest state changing operation is overriding the value assigned to a particular identifier.We will use a special monoid, the monoid of maps under override, as the basic structure to model state and state change.
X !Y;y; y denotes the override operator which overwrites one mapping by another mapping.For mappings 1 ; 2 2X !Y override is defined by: 1 y 2 = , dom 2 1 t 2 denotes the null map (the identity of the monoid).Override is naturally used to specify a substitution of bindings in a state, e.g. the semantics of the assignment statement x := e in programming languages with a given environment : x := e 4 y x 7 !e

Locations
It is common for memory management for program implementation or data bases to introduce locations, e.g. to deal with allocation and de-allocation of notions.Stores are indexed by locations, i.e. are mappings from locations to some elements.Notions are mapped to stores.
The outer laws for the monoid of maps (see Appendix A) can be used for reasoning, if the assignment is defined on more complex environments, e.g.mapping variables to stores which are mappings from locations LOC to values (X !LOC !Y ) or stack-based structures.Removal and restriction are outer laws for the monoid of maps, i.e. override distributes over , and .
An indexed monoid X !M 0 ; ; can be constructed from a base monoid M;; u and an indexing set X (see [3]).Elements of the new monoid are simply maps from X to M 0 in X !M 0 where M 0 = , u M, the identity element is the null map and the associative binary operator is an indexed version of the base operator .If is set union for example, then we usually construct to be a map-building operator defined in terms of map extend and map override.
The monoid of indexed mappings X !Y !Z 0 ; y ; , e.g.V A R !LOC !V A L as an application for programming language semantics with locations, is the monoid of maps Y !Z;y; indexed with respect to X, i.e., we have another algebraic structure usable to prove properties.Later on we will use indexed mappings to introduce agents with local states.We will indicate that the presented model covers a broad range of possible applications.We are able to deal with problems that arise if aspects of locality (distributed and local substates) and access to non-local objects occur.Security aspects are the main issue in our investigation of agent systems.In particular, we concentrate on integrity (other forms of security are e.g.confidentiality or availability) [7,21].

A Generic Model for State-based Agent Systems
Properties of our model will be established and will be based on the framework of Constructive Mathematics.Some of the results are obtained by transforming parts of the model into other spaces in which useful algebraic properties hold.Details about how monoids are constructed from others (obtaining isomorphic structures) and other technical results are presented in the appendix.

Models and their Elements
Consider the following situation; we have a collection of agents, associated with each agent is a collection of notions or resources and each notion has some associated elements.The same notion may be used by different agents.An element 2 K = W ! X !Y models this situation, where W denotes the agents, X denotes a set of possible notions (or resources) and Y denotes associated elements to the notions (which might be any kind of information).
Let us look at the elements (see figure 1) in more detail: 1st Irish Workshop on Formal Methods, 1997 A Generic Model for State-based Agent Systems is a relation describing a world1 of agents with interrelationships (expressing the use of resources).describes how agents w 2 W see their personal world ( is a substructure of ). is of type W ! P W , e.g. a tree or a graph.
A modifying operation Restructure can be applied to worlds which changes the shape of the world, but does not alter particular (local) notions.
There is an operation Change : K !K .A change updates internal information.These changes are initiated by agents.Changes for w might have side-effects on other agents (which ones is expressed by ).
denotes a set of agents with their associated structure (the latter is assumed to be X !Y ), is of type is the basic structure and describes the structure of the living world or the living system.w is a living entity with a predefined structure (which might not necessarily live in a certain state of the world).The execution of Change has to guarantee the integrity of the whole world with respect its structure .Restructure is much simpler, therefore we will concentrate on Change in the following.
We can think of a collection of agents W as a collection of independent entities (agents, processes, procedures) which have their own view or perspective on their environment (or universe of discourse).They share elements in the environment with others.They might not only think differently about their environment, they also might affect it (and due to their different opinions, there might be conflicts).We assume that local and global entities accessible for agents are structured in the same way.We have assumed a space X !Y associated with W by W ! X !Y .X is the domain on which conflicts might arise.By Y , arbitrary information can be associated to the conflicting notion.

Identification
A particular notion might appear several times in one world (even for the view of a given agent w).Thus, the most appropriate has to be identified.The problem occurs since naming is relative (and not absolute).
K is the space of W-indexed maps X !Y , i.e. agents with their associated structures.K represents the space of the overall view.Personal views or perspectives of each agent are represented in the space K p .p is partitioned with respect to notions.Let K p K denote the collection of agents with notions and their associated elements in which a notion is associated with one and only one agent.A particular notion appears only once in an element p 2 K p , this is called a partition in contrast to distributions in K.The p in p indicated that p is partitioned.Personal views do not contain irrelevant information.Some of the information of the overall view are faded out.Therefore, K p is a subspace of K.An element 2 K might look like: = w 1 7 !x 1 7 !y 1 ; x 2 7 !y 2 w 2 7 !x 1 7 !y 3 An element p 2 K p represents the private view and might look like p = w 1 7 !x 2 7 !y 2 w 2 7 !x 1 7 !y 3 expressing that the information about x 1 2 w 1 is not relevant for w 2 .

Worlds
Each agent is possibly related to other agents.A relation

W ! P W
A Generic Model for State-based Agent Systems captures this inter-relationship between agents.The characteristics of should reflect the way in which the agents behave, i.e. access their resources.can be derived from .Using (an expanded) , we will implement Change.Now, what is the meaning of changing the interpretation of a notion in the above situation?Given the agent w 2 dom we would like to define the change in the form Changex 7 !y w = : : : This leads to the question: which notion x of which agent should be updated with y, if the notion is a non-local one to w?The notion update should be the nearest notion to the agent w with respect to the relation .This shall be captured by the idea of a closure.

Closures
Let us assume that defines a tree, i.e. for each element in the range there is a unique predecessor.shall be called a closure or a predecessor relation.
Clsr w : TW !TW Clsr w : 7 !: w !w !Clsr w addw; add is overloaded (e.g.concatenation ^for sequences, union for sets).Starting with an arbitrary world as a se- quence, a sequence of agents results.The sequence begins with the agent w and is continued by those agents related by .To this end we use Clsr w : W ? !W ? for sequences with w ^ instead of addw; .Clsrproduces a list of agents based on w and the application of w (recursively).This recursive function returns a sequence of agents up to the given agent w when evaluated for the null sequence (a leaf in the tree ): Clsr w = w 1 w 2 : : : w : The above algorithms do not terminate for graphs, if there are cycles.The general problem is therefore: given a directed graph and a node w in , produce an inverted graph with respect to w.

Agent Structures
The notions and their associated elements with a structure of agents must be found by expanding agents with their internal structure: Expd : TW !T K Expd : 7 !T represents the whole world.Restrict normally expects a set, but is here adapted to other types T (i.e. is overloaded).For a sequence of agents Expd : W ? !K ? is defined by Expd : 7 !? .The expansion is here achieved by applying Expd with respect to the restriction (where w = fwg ) across the sequence: Expd Clsr w = w 1 7 !w 1 ; w 2 7 !w 2 ; : : : ; w 7 !w The above expression denotes the expanded closure (personal view) for an agent, but still including irrelevant information.

Most Closely Related
A collection of agents shall be reduced in such a way that the notions nearest the agent w dominate those notions further way from the agent w.To achieve this, a binary operation z on K p is defined.This operation will remove all irrelevant information from the current .Shadowing of information means that the most closely defined notion is the relevant one, other definitions of the same notion are shadowed by the closest one.Since they are irrelevant, they shall be removed and we obtain a much simpler, partitioned structure with respect to notions as opposed to only distributed structures before.

A Generic Model for State-based Agent Systems
Merging.The inverse function of splitting is merging Mr g(note that K p is a partition) Mr g:SpltK p ! K p Mr g: ;7 !I !which merges two elements.
Substitute.The last function to define overrides an argument by a constant map : Sbst : X !Y !X !Y Sbst : 7 !y All three functions (and z and P r o jas well) do not depend on the particular form of or and are therefore generic.

Change
We can now give the meaning of an update Change of a world under by a maplet x 7 !y initiated by an agent w, using the functions defined above: Changex 7 !y w = y Mr g I Sbst x7 !y Splt P r o j w It is clear for the above definition that we must first obtain the private views of the agent w (P r o j w ).This produces an element of K p , which is split into two parts by Splt, one of the parts is updated Sbst x7 !y , then we form an element of K p by applying Mr gand use this to update (override) .
Our general principle is reflected in this specification: the whole system is taken, the personal view of the respective agent w is selected.This view is splitted into the map for agents and into a map for notions.Since we have a guaranteed partition we can easily update the interpretation for the notion x.Then the two parts are merged again and the whole system is updated (overridden) by the new personal view.
The core principle of dealing with the problems that might occur for systems with local and global aspects, is to reduce the whole system to the view of the modifying agent, perform changes on that view and then update the whole system.

Application for Multi-Agent Systems for Planning
Distributed artificial intelligence (DAI) is concerned with the development and analysis of cooperating (intelligent) processes, called agents [11].
Multi-agent architectures consist of a set of autonomous agents which cooperate to achieve a common goal [22,25].Each agent has to construct his own plan which in turn is part of a global plan.Agents are expected to help in buildingthe global plan.Since cooperation is needed for planning, actions, plans and knowledge are to be distributed.Cooperation is the central aspect in DAI (distributed problem solving).It can be divided into the issues of communication, i.e transfer of information, and synchronisation, i.e. temporal ordering of actions.
A large class of architectures are termed blackboard-architectures.A blackboard is a shared memory which is used to write on and read from.A blackboard can contain problem knowledge, actions to be performed and plans.Agents are not explicitly synchronised in this model, they are synchronised by access to the blackboard (see e.g.[5]).
This idea (see figure 2) fits easily into our framework.
A tree represents a multi-agent system describing access to blackboard (a cone construction with the blackboard as central element -all elements are pointing to the blackboard).
is the personal view of an agent (sees the blackboard) w is either an agent or the blackboard.Restructure might be adding or removing agents, implemented by simple operations on a tree.
Change is update of plans.
These ideas can also be found in languages in which coordination models are implemented, see [4].Each agent might have his own local data repository and has access to the global data repository, the blackboard.Agents are autonomous, i.e. not influenced by others in their decisions.They do not communicate directly with each other.The relation is a tree which has the blackboard as the root and the agents as leafs.Note, that we do not aim at modelling planning strategies or learning aspects in multi-agent systems, our model describes the basic structural framework on which these aspects can be modelled.Work in DAI mainly concentrates on for example the process of planning or learning among agents (even if some of these approaches use a similar notation to ours, see [25] or [5]).The importance of a clearly structured, consistency guaranteeing architecture is often neglected.

Application for Programming Language Semantics
The treatment of Algol-like languages requires a complex model, if nesting of procedures (e.g. with static scoping) and local variables are involved [24,17,18].Procedures shall be regarded as agents.We will present a CM | -model for a state-based language with: local variables a type system including procedural types block structure Being based on CM | and its operators, it will allow us to prove properties of the model.
The elements of our generic model can be instantiated as follows (see figure 3): A tree represents access links for activated procedures (according to the static nesting of procedure definitions).
The sequence represents access links for a particular procedure activation.
Agents w are activations of procedures.
Notions are variables (identifiers) and their associated elements are values.
Restructure is starting a new activation or finishing an activation (inserting or deleting on a tree).
1st Irish Workshop on Formal Methods, 1997 Change is state override.
We will make our main model from section 4.1 now more concrete with natural numbers representing agents (procedures are identified by numbers) and identifiers I and their values V .
We now introduce an operator related to the binary operator on the monoid of inverse maps Inv X!Y ; z; (see Appendix C) which will be useful in addressing the semantics of local variables in a Pascal-like language with (possibly nested) procedures as parameters.For i ; j 2N! I! V define i z j = I !, j 0 i y j where = = rng I !dom and where the priming denotes the removal of entries of the form n 7 !(empty local environments).z updates a global environment i by j .n 2 N points to the local environment of an activation at nesting depth n.This operator and a subset of the set N !I !V form a monoid.
Let 2 N !I !V be the activation stack of a program with the current procedure as the top element.Let 2 N !P N be the tree representing links from activations of procedures to activations of procedures in which the former were statically defined.What is the environment of the current procedure and what effect does the execution of the current procedure have on the activation stack?
From ; and the current procedure a sequence of activations h! i i can be obtained, where !i 2 N !I !V for each i.The section of the activation stack relevant to the current procedure can be found by applying a reduction to the sequence z =h! i i.
The environment 2 I !V , in which the current procedure should be evaluated, is t = rng z =h! i i (see 2 Splt).
The position of the environment in the activation stack, denoted by 2 N !P 0 X , is = I !dom z =h! i i (see 1 Splt).The execution of the current procedure transforms the environment into the environment 0 .The activation stack after the completion of the procedure will have the form y I ! 0.
Even though we have been talking about language semantics, a language itself has not appeared explicitly so far.Let us adopt now an imperative language with properties as described in the introduction of this subsection.An assignment can be directly defined by Change.Assuming that procedures are program values, they are storable in the environment .They can be assigned to global variables and passed as parameters to other procedures.This allows procedures to be called outside the defining context.In a language with static scoping and side-effects, a global object accessed by a procedure might not exist.Our approach handles this problem in the following way.The operation Clsrcomputes the closure of a procedure with respect to nesting .If an accessed object is not defined in one of the procedures in the closure, the program can be aborted.
1st Irish Workshop on Formal Methods, 1997 We have presented a generic model which should allow us to specify different applications sharing some common properties: a world of agents which might change its structure dynamically agents with a local state agents might effect other agents or share resources with other agents (these effects depend on some relation between agents and/or the dynamic configuration of the world) As indicated, a number of different problems in specification and programming fit into our framework.Applications in distributed planning in artificial intelligence and aspects of locality and nesting in programming language semantics have been addressed.
The model was motivated by an attempt to model distributed agent systems, e.g.blackboard architectures for distributed planning.Looking at a variety of agent systems (such as programs, if procedures are regarded as agents which share data and which might be passed around), we observe that we have to deal with systems that not only change their state, but also alter their shape (or their structure).Agents might depend on each other based on static or dynamic relationships and either of these relationships can affect updates on the whole system.These dynamically evolving structures can also be found in process architectures formulated in the -calculus [15,16] where communication channels between processes might be passed around and used to create new connections dynamically.Since these aspects of locality and of static and dynamic dependencies recur in various areas, we have tried to capture and generalise them in our abstract model, which, we believe, provides a novel approach of viewing and reasoning about agent systems.
Our model is state-based.An introduction into specifying and reasoning about state-based systems has been given.Having state-based entities in a distributed environment, the problems of locality and visibility which might depend on static and dynamic interrelationships occur between those entities.The model consisting of domains and operation could be specified in a similar way in other modeltheoretic specification approaches as well.However using the monoid of maps under override, and constructing the monoid of indexed maps under indexed override or the monoid of inverse maps on the first, -which are specific results of our framework CM | -we obtain a clearer structuring using their algebraic properties, which in turn allowed us to gain some new insights into structure and properties of agent systems.
The presented model should be applied to other distributed architectures such as CORBA [19] or the World-Wide Web.Possibly, generalisations have to be carried out, e.g.we might need to model static and dynamic interrelations between agents by two different relations.

S 2 :
: : S n . is the characteristic function, i.e. tests membership.A monoid M;; u is defined by a set M, a binary, associative operator , i.e. for n; m; p 2 M: m n p = m n p a (unique) identity element u 2 M with m u = m = u m

Figure 1 :
Figure 1: A world of agents