cognitive agent programming
SIKS Dissertation Series No. 2006-19
The research reported in this thesis has been carried out under the auspices of SIKS, the Dutch Research School for Information and Knowledge Systems. ©2006 M. Birna van Riemsdijk
Printed by Gildeprint drukkerijen B.V., Enschede ISBN-10: 90-393-4355-1
Cognitive Agent Programming
A Semantic Approach
Programmeren van Cognitieve Agenten
Een Semantische Benadering
(
met een samenvatting in het Nederlands)
Proefschrift
ter verkrijging van de graad van doctor aan de Universiteit Utrecht
op gezag van de rector magnificus, Prof. Dr. W.H. Gispen,
ingevolge het besluit van het college voor promoties
in het openbaar te verdedigen
op woensdag 25 oktober 2006 des middags te 12.45 uur door
Maria Birna van Riemsdijk
promotoren: Prof. Dr. John-Jules Ch. Meyer co-promotoren: Dr. Frank S. de Boer
Het hoogste doel in het leven is de groei van het ik, de vergroting van het bewustzijn. Het hoogste geluk ligt in de vreugde over deze groei, over het gevoel meer mens te worden.
The ultimate goal in life is the growth of self, the expansion of con-sciousness. The ultimate happiness lies in the joy about this growth, in the feeling of becoming more human. - Translated by Targetranslations, Apeldoorn.
Contents
Preface xi
1 Introduction 1
1.1 Cognitive Agent Programming . . . 2
1.2 Formal Semantics . . . 4
2 Setting the Stage 7 2.1 Syntax . . . 7
2.1.1 Beliefs, Goals, and Plans . . . 7
2.1.2 Reasoning Rules . . . 8
2.1.3 An Agent . . . 9
2.2 Semantics . . . 10
2.3 Example . . . 14
2.3.1 Building a Tower . . . 15
2.3.2 Goals and Plan Revision: Programming Flexible Agents . 17 2.4 Overview of Thesis . . . 18
2.4.1 Part I: Goals . . . 19
2.4.2 Part II: Plan Revision . . . 19
2.4.3 Part III: Software Engineering Aspects . . . 20
2.5 Important Issues We Do Not Address . . . 21
I
Goals
23
3 Semantics of Subgoals 25 3.1 Syntax . . . 263.2 Semantics . . . 28
3.3 Comparison with 3APL . . . 29
3.3.1 Syntax and Semantics . . . 29
3.3.2 3APL and Subgoals . . . 32
3.4 Conclusion and Related Work . . . 36 vii
4 Goals in Conflict 39
4.1 Preliminaries . . . 40
4.1.1 Cognitive Agent Programming . . . 40
4.1.2 Default Logic . . . 43
4.2 Goal Base . . . 44
4.2.1 Semantics . . . 44
4.2.2 Properties . . . 47
4.3 Goal Base and Goal Adoption Rules . . . 51
4.3.1 Semantics . . . 51
4.3.2 Properties . . . 56
4.4 Dynamics of Goals and Intentions . . . 60
4.4.1 Commitment Strategies for Goals . . . 60
4.4.2 Intention Generation . . . 62
4.5 Related Work . . . 68
4.5.1 Van Fraassen and Horty . . . 68
4.5.2 BOID and Related Approaches . . . 73
4.6 Conclusion . . . 78
5 Putting Goals in Perspective 79 5.1 What Is a Goal? . . . 80
5.1.1 Philosophy: Dennett and Bratman . . . 80
5.1.2 Formalizing Motivational Attitudes . . . 81
5.2 Why Goals in Agent Programming? . . . 84
5.2.1 Bridging the Gap . . . 84
5.2.2 Programming Proactive Agents . . . 85
5.2.3 Goals as a Modeling Concept . . . 86
5.3 Representation . . . 87
5.3.1 Representing Goals Separately or Not . . . 87
5.3.2 Logic-Based and Non-Logic-Based Approaches . . . 89
5.3.3 Interacting Goals . . . 92
5.4 Behavior . . . 95
5.4.1 Procedural and Declarative Goals . . . 95
5.4.2 Dropping and Adopting . . . 99
5.5 Conclusion . . . 102
II
Plan Revision
105
6 Semantics of Plan Revision 107 6.1 Syntax . . . 1096.1.1 Object-Level . . . 109
6.1.2 Meta-Level . . . 110
6.2 Operational Semantics . . . 111
6.2.1 Object-Level Transition System . . . 111 viii
6.2.2 Meta-Level Transition System . . . 111
6.2.3 Operational Semantics . . . 113
6.3 Equivalence of Object- and Meta-Level Operational Semantics . 114 6.4 Denotational Semantics . . . 118
6.4.1 Preliminaries . . . 118
6.4.2 Definition of Meta-Level Denotational Semantics . . . 120
6.4.3 Continuity of Φ . . . 127
6.5 Equivalence of Operational and Denotational Semantics . . . 129
6.5.1 Equivalence Theorem . . . 130
6.5.2 Denotational Semantics of Object-Level 3APL . . . 134
6.6 Related Work and Conclusion . . . 135
7 Dynamic Logic for Plan Revision 137 7.1 Related Work . . . 138
7.2 3APL . . . 140
7.2.1 Syntax . . . 140
7.2.2 Semantics . . . 141
7.3 Plan Revision Dynamic Logic . . . 143
7.3.1 Syntax . . . 144
7.3.2 Semantics . . . 144
7.4 The Axiom System . . . 145
7.4.1 Soundness . . . 147
7.4.2 Completeness . . . 149
7.5 Proving Properties of Non-Restricted Plans . . . 155
7.5.1 From Restricted to Non-Restricted Plans . . . 155
7.5.2 Examples . . . 156
7.6 Plan Revision Rules versus Procedures . . . 162
7.6.1 Reasoning about Procedures . . . 163
7.6.2 Induction . . . 165
7.7 Conclusion . . . 166
8 Compositional Semantics of Plan Revision 169 8.1 3APL . . . 170
8.1.1 Syntax . . . 170
8.1.2 Semantics . . . 170
8.2 3APL and Non-Compositionality . . . 171
8.2.1 Compositionality of Procedural Languages . . . 171
8.2.2 Non-Compositionality of 3APL . . . 172
8.2.3 Reasoning about 3APL . . . 172
8.3 Compositional 3APL . . . 173
8.3.1 Restricted Plan Revision Rules . . . 173
8.3.2 Compositionality Theorem . . . 176
8.3.3 Reasoning about Compositional 3APL . . . 179 ix
III
Software Engineering Aspects
181
9 Goal-Oriented Modularity 183 9.1 Goal-Oriented Modularity . . . 184 9.1.1 Related Work . . . 184 9.1.2 Our Proposal . . . 186 9.1.3 Discussion . . . 1879.2 Goal-Oriented Modularity in 3APL . . . 188
9.2.1 Syntax . . . 188
9.2.2 Semantics . . . 191
9.2.3 Example . . . 195
9.3 Future Research . . . 197
10 Prototyping 3APL in the Maude Term Rewriting Language 199 10.1 3APL . . . 200
10.1.1 Syntax . . . 200
10.1.2 Semantics . . . 202
10.2 Maude . . . 203
10.3 Implementation of 3APL in Maude . . . 205
10.3.1 Object-Level . . . 205
10.3.2 Meta-Level . . . 209
10.4 Discussion and Related Work . . . 211
10.4.1 Advantages of Maude . . . 211
10.4.2 Extending the Implementation . . . 213
10.4.3 Related Work . . . 214
11 Conclusion 215 11.1 Part I: Goals . . . 216
11.2 Part II: Plan Revision . . . 217
11.3 Part III: Software Engineering Aspects . . . 217
11.4 Final Remarks . . . 218
Programmeren van Cognitieve Agenten 235
Curriculum Vitae 237
SIKS Dissertation Series 239
Preface
Simplicity is my holy grail. Only through a striving for simplicity can we make progress.
Striving for simplicity is important in the sense of identifying an issue and simplifying it such that its essence can be studied in isolation. This is what the famous Dutch computer scientist Dijkstra (1930 - 2002) has referred to as “separation of concerns”: “Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one is willing to study in depth an aspect of one’s subject matter in isolation for the sake of its own consistency, all the time knowing that one is occupying oneself only with one of the aspects. [. . .] It is what I sometimes have called “the separation of concerns”, which, even if not perfectly possible, is yet the only available technique for effective ordering of one’s thoughts, that I know of.” [?]
Contrary to what one might think, this is not a trivial undertaking. One should not over simplify matters and ignore essential aspects of the issue. That is, it is not the case that simpler is always better. Rather, I argue that when proposing a certain approach, one should ideally be able to argue for each aspect of the approach why this aspect is incorporated. Through this, one can achieve a clarity of presentation and a true understanding of the subject matter.
Unfortunately, simplicity doesn’t always sell, as illustrated by the following quote from Dijkstra: “When you give for an academic audience a lecture that is crystal clear from alpha to omega, your audience feels cheated and leaves the lecture hall commenting to each other: ‘That was rather trivial, wasn’t it?’ The sore truth is that complexity sells better.” [?]
A solution to this problem is suggested in the following poem, which is attributed to1the Danish artist and scientist Piet Hein (1905 - 1996).
If you want the world to hear Write your papers crystal clear,
then add some ingenuities to show how hard to do it is...
1I found this poem on the website of computer scientist Sophia Drossopoulou:
http://www.doc.ic.ac.uk/~scd/.
Besides the scientific progress that can be achieved through a striving for sim-plicity, a simple and clear theory can be enjoyed as a thing of beauty. This is where science and art meet.
And this is the work of an artist. The artist, who thanks to his limited talents is able to make some clear distinctions, he enables us to see some elements of fundamental reality, which up until then escaped us.
The plastic artist for example distinguishes colour, shape, space and movement as elements of the seeing and restricts himself to one of these four elements only to distinguish more clearly the phenomena of reality which come flashing by. The clarification through this of our look onto life is the perception: beauty. Our world expands itself and we rejoice in its beauty.2
Gerrit Th. Rietveld, GR 263 Like looking at art, practicing science allows one to continually discover new viewpoints and expand one’s horizon. It is this which makes me enjoy doing research.
Ok, I’ll get off my soapbox now and start thanking some people. I thank, first of all, my supervisors John-Jules Ch. Meyer, Frank S. de Boer, and Mehdi Dastani. I thank John-Jules for his open mind and cheerful spirit. I couldn’t have wished for a better promotor! John-Jules always took the time to listen to me and to give advise on anything ranging from technical matters to advise on what to do after finishing the thesis. I thank Frank for contributing his great technical knowledge and insight, for many interesting discussions, and for his humor which always made our meetings enjoyable. I thank Mehdi for always making me think about why I chose a certain approach, and for inviting me to contribute to many of his projects, whether it was writing papers or giving tutorials. Mehdi is never short of ideas for doing research, and has been great company on the many conferences that we attended together.
I thank Michael Fisher, Koen Hindriks, Joost Kok, Leon van der Torre, and Jan Treur for agreeing to be a member of the reading committee and taking the time to read my thesis. I thank my colleagues, from the Intelligent Systems group and others, for the many ways in which they have contributed to this thesis. I thank in particular Huib Aldewereld, Rafael Bordini, Lars Braubach,
2Translated by Targetranslations, Apeldoorn. Original text: “En dit is het werk van de
kunstenaar. De kunstenaar, die dank zij zijn beperking van aanleg, enkele heldere onderschei-dingen maakt, laat ons enige stukjes primaire werkelijkheid zien, die ons voorheen ontgingen. De plastische kunstenaar b.v. onderscheidt kleur, vorm, ruimte, en beweging als onderdelen van het zien en bepaalt zich tot een van deze vier, om met des te meer aandacht de voorbij flitsende verschijnselen der werkelijkheid te onderscheiden. De verheldering hierdoor van ons levensbeeld is de gewaarwording: schoonheid. Onze wereld verruimt zich en wij verheugen ons in z’n schoonheid.”
Martin Bravenboer, Jan Broersen, Martin Caminada, Jurriaan van Diggelen, Frank and Virginia Dignum, Davide Grossi, Paul Harrenstein, Koen Hindriks, John Horty, Joris Hulstijn, Wiebe van der Hoek, Geert Jonker, Henk-Jan Leb-bink, Viviana Mascardi, Peter Novak, Lin Padgham, Cees Pierik, Alexander Pokahr, Henry Prakken, Carsten Riggelsen, Sebastian Sardina, Liz Sonenberg, the PhD students from the siks research school, Leon van der Torre, Javier V´azquez-Salceda, Bob van der Vecht, Michael Winikoff, and Cees Witteveen. Extra special thanks go to Paul Harrenstein for letting me use his thesis style file (and for providing the indispensable accompanying technical support), and to Huib Aldewereld for being incredably patient in answering my numerous (usually not so interesting) questions about computers, and for always being willing to help out when I was (again) completely at a loss as to how to make the computer do what I wanted.
I thank Wilke Schram and the Department of Information and Computing Sciences of Utrecht University for giving me the opportunity to travel to many conferences which has taken me to beautiful places such as Melbourne, New York, Estonia, Lisbon, Covilha, Dagstuhl and Scotland. I thank AgentLink and Mehdi Dastani for inviting me to attend Technical Forum Groups in Ljubljana and Budapest, and the aamas organization for supporting my attendance of aamas’03 (Melbourne), aamas’04(New York), and aamas’06(Japan). Also I
am grateful for having received scholarships from the organization of the clima workshop, allowing me to attend clima’05 in London, even though I did not
have an accepted paper, and clima’06in Japan. I thank Richard Starmans and
siksfor many siks courses, and for supporting my attendance of deon’06.
I thank my roommates Huib Aldewereld, Virginia Dignum, Geert Jonker, Cees Pierik, Wieke de Vries, and the other members of the Intelligent Systems group for the pleasant working atmosphere. I have probably learned more about the world through the many discussions over lunch than from watching the evening news, and I will really miss having a “bakkie pleur” in the afternoon with my fellow PhD students. I thank especially Geert for enduring me chatting about being “almost finished” writing the thesis, about filling out forms, about the next version 1.7.x of my thesis cover, etc. I will miss Geert’s humor, and conversations about hats, cars, friendship, and the like. I thank Cees Pierik and Paul Harrenstein for being my paranimfen. I will miss Cees’ down-to-earth attitude to life, and the pleasant talks about anything from jogging to religion, and I am happy not to have to miss Paul.
I thank my friends and family for being there for me over the years. I thank especially my brother Rombout for always being willing to help, and my parents Trudy and Willem for giving advise on anything from cover design to buying a house, and for always being there to share experiences with.
All of you have made the past four years the enjoyable experience it has been.
Utrecht, August 2006
Chapter 1
Introduction
The work described in this thesis draws mainly on research done in the agent sys-tems field and on research concerning programming languages. That is, in this thesis we are concerned with the design and investigation of dedicated program-ming languages for programprogram-ming agents. In Sections 1.1 and 1.2, respectively, we provide some background on those aspects of the agent systems field and of programming language research that are relevant in the context of this thesis.
An agent is commonly seen as “an encapsulated computer system that is situated in some environment and that is capable of flexible, autonomous action in that environment in order to meet its design objectives” [Jennings, 1999].1
An autonomous computing entity encapsulates its state and makes deci-sions about what to do based on this state, without the direct intervention of humans or others [Wooldridge, 1997]. Agents are situated in some envi-ronment which can change during the execution of the agent. This requires flexible problem solving behavior, which means that the agent should be able to respond adequately to changes in its environment in such a way that it achieves its objectives or goals. Such flexibly behaving computing entities that are able to make “good” decisions about what to do, are often called intelligent agents or rational agents [Rao and Georgeff, 1991, van der Hoek et al., 1998, van der Hoek and Wooldridge, 2003].
Domains in which agents are viewed as providing added value, are typically dynamic and complex, such as the domains of business process management [Jennings et al., 1996] and disaster rescue [Visser and Burkhard, 2006].
1In [Jennings, 1999], this definition of what an agent is, is attributed to [Wooldridge, 1997].
However, the definition cannot be found literally in the paper by Wooldridge.
2 INTRODUCTION
1.1
Cognitive Agent Programming
Programming rational agents is not a trivial task. First, one needs to establish what it means that an agent is rational, i.e., one has to develop a theory of rational agents. The next step then needs to address how these theoretical ideas of rational agency can be implemented in a concrete piece of software. The latter can, broadly speaking, be approached in two ways. One possibility is to develop an architecture for rational agents, specifying what general structure a rational agent should have. Such an architecture can then be implemented using some general purpose programming language. Another possibility is to design a dedicated programming language for programming rational agents.
Research into agent theories, architectures, and languages has a strong tra-dition2 in the agent systems field (see also [Wooldridge and Jennings, 1995]).
The work as presented in this thesis builds on this tradition.
The origins of much research into agent theories, architectures, and lan-guages lie with Bratman’s so-called Belief Desire Intention (BDI ) philosophy [Bratman, 1987] (see also Section 5.1.1). BDI philosophy in turn can be viewed as based on Dennett’s intentional stance [Dennett, 1987]. The idea of the inten-tional stance is that the behavior of rainten-tional agents can be predicted by ascribing beliefs and desires to the agent, and by assuming that the agent will tend to act in pursuit of its desires, taking into account its beliefs about the world.
The idea of Bratman now is that beliefs and desires are not enough for explaining and describing rational behavior. He argues that there is another notion, i.e., intention, that is essential for an account of practical rationality. His view is that an agent may have many, possibly conflicting, desires. It is not feasible for an agent to continually weigh all its desires, in order to decide what to do. Therefore, an agent settles at some point on achieving a certain (non-conflicting) subset of its desires. These chosen desires - and corresponding courses of action - are the agent’s intentions.
Intentions have a characteristic stability, in the sense that an agent will in principle not reconsider previously formed intentions, except if a significant problem presents itself. Also, if an agent wants to adopt new intentions, these new intentions should not conflict with already existing intentions. Existing intentions thus form a so-called screen of admissibility.
BDI philosophy suggests a particular view on rational agency. It is this view that has formed the basis for the development of several BDI logics for modeling and reasoning about rational agents [Cohen and Levesque, 1990] [Rao and Georgeff, 1991, van der Hoek et al., 1998, Rao and Georgeff, 1998] (see also Section 5.1.2). The notions of which these logics investigate prop-erties are the notions of beliefs, desires, and intentions, but also related notions
2This is demonstrated by a series of successful Agent Theories, Architectures, and
Lan-guages (ATAL) workshops which were held annually from 1994 to 2001. Today, ATAL is part of the International Joint Conference on Autonomous Agents and Multi-Agent Systems (AAMAS).
COGNITIVE AGENT PROGRAMMING 3
such as goals, wishes, opportunity, capability, commitments, etc. Such notions are often referred to as mental attitudes.
Shortly after the first BDI logics were proposed, it was Shoham who first put forward the idea to program rational agents using mental attitudes [Shoham, 1993]. Shoham proposes the agent programming language AGENT-0, and coins the term agent-oriented programming. While Shoham proposes a programming language, others have proposed a specific BDI archi-tecture for the implementation of rational agents [Georgeff and Lansky, 1987] [Ingrand et al., 1992]. The resulting system was called the Procedural Reason-ing System (PRS).
Based on the PRS architecture, the agent programming language AgentSpeak(L) was proposed [Rao, 1996]. AgentSpeak(L) can be viewed as a simplified, textual language of PRS. The proposal of AgentSpeak(L) was mo-tivated by the question of how to relate implemented BDI systems to the BDI logics. Rao observes that the complexity of the code of implemented BDI sys-tems has meant that the implemented syssys-tems have lacked a strong theoretical underpinning, i.e., the relation between these systems and BDI logics was not clear. While the issue of the relation between implemented BDI systems and BDI logics was not resolved in [Rao, 1996] and is still an open issue (see Section 5.2.1), the proposal of AgentSpeak(L) was followed by an increasing amount of research into agent programming languages.
In particular, we mention the proposals for the languages 3APL [Hindriks et al., 1999b, Hindriks, 2001] and GOAL [Hindriks et al., 2001], on which most of the work in this thesis builds. Like AgentSpeak(L), 3APL and GOAL are inspired by BDI theory. Other examples of such languages and frameworks are JACK [Winikoff, 2005] and Jadex [Braubach et al., 2005, Pokahr et al., 2005b]. JACK is an extension of Java [Gosling et al., 2000] with agent-oriented constructs, and Jadex is a BDI reasoning engine implemented in Java that provides an execution environment and an API. Another language that has several agent-oriented extensions, is MetateM [Fisher, 2006]. MetateM is a programming language based on direct execution of temporal logic statements. An extension inspired by BDI was proposed in [Fisher, 1997].
In the early days of agent programming research, the term agent program-ming was synonymous with agent programprogram-ming inspired by BDI theory. How-ever, as the agent systems field grew, many other approaches to agents and agent programming emerged. For example, there is a large body of work taking an algorithmic - rather than a programming - approach towards multi-agent issues such as teamwork or negotiation. Also, there are agent programming frameworks that are not based on BDI theory, such as the IMPACT framework [Dix and Zhang, 2005]. IMPACT builds on logic programming, and focuses on the development of a multi-agent platform that is able to deal with heterogenous and distributed data, and that can be realized on top of arbitrary legacy code. In order to distinguish agent programming frameworks that are based on BDI from those that are not, many use the term BDI agent programming. However,
4 INTRODUCTION
the precise relation between such frameworks and BDI theory is generally not clear. Also, notions that are used in such frameworks are usually not precisely the notions of beliefs, desires and intentions. That is, related notions such as plans, goals, events, and capabilities are frequently used instead of, or in addition to the BDI notions. The notions in this wide spectrum have also been referred to as cognitive notions. Therefore, we prefer to use the term cognitive agent programming for approaches such as ours, that are inspired by BDI theory but also use related cognitive notions.
In particular, the cognitive notions that we generally use are the notions of beliefs, goals, and plans. The idea is that an agent should try to reach its goals by executing appropriate plans, given its beliefs. Beliefs thus form the informational component of the agent, goals form the motivational component, and plans form the procedural component.
Most cognitive agent programming languages have at least an informational and a procedural component. The term “beliefs” is used for the informational component in most of these languages. As for the procedural component, several languages also use the term “intentions” instead of or in addition to “plans”. Regarding the motivational component, the term “goals” tends to appear more often in cognitive agent programming frameworks than the term “desires”. We refer to Section 5.1.2 for a short discussion on the difference between goals and desires.
The aspects of cognitive agent programming on which we focus in this thesis, are the representation of goals (Part I), and a particular aspect of the execution of plans, i.e., plan revision (Part II). In Part III, we address some software engineering aspects. In Chapter 2, we present a simple cognitive agent pro-gramming language that incorporates beliefs, goals, plans, and a mechanism for plan revision. At the end of that chapter, we present a more detailed overview of this thesis.
1.2
Formal Semantics
Cognitive agent programming is one of the pillars on which this thesis rests. Formal semantics of programming languages is the other.
Research on formal semantics3of programming languages is concerned with
the rigorous mathematical study of the meaning of programming languages and models of computation. When defining a formal semantics for a programming language, the constructs of the language are related to objects in some domain of interpretation. That is, formal semantics is a way to give a precise specification of what it means to execute a program.
Formal semantics can be contrasted with the informal semantic descriptions as can be found in reference manuals and language standards. Such informal
FORMAL SEMANTICS 5
descriptions are less precise by nature, and are based primarily on implementa-tion techniques and intuiimplementa-tions. The use of formal semantics as a technique for describing the meaning of programming languages has several advantages over an informal approach.
An important advantage of using formal semantics as a tool for designing programming languages is that semantic issues or problems are more likely to be identified. In the foreword of [Tennent, 1991, page xvii], Reynolds puts it as follows: “The truth of the matter is that putting languages together is a very tricky business. When one attempts to combine language concepts, unexpected and counterintuitive interactions arise. At this point, even the most experienced designer’s intuition must be buttressed by a rigorous definition of what the language means.”4 In this thesis, we will see several cases in which the fact that
formal semantics forces one to be precise, brings to the surface issues that could otherwise have been overlooked easily.
Another benefit of using formal semantics is that it provides a basis for com-paring different languages. Without a precise description of the meaning of a language, it is difficult to make any claims on the exact relation between differ-ent languages. With the emergence of more and more cognitive agdiffer-ent program-ming languages, this becomes even more important if one wants to understand whether seemingly different constructs really are different. Such understanding can facilitate convergence towards one or a small number of cognitive agent programming languages.
Further, formal semantics is essential if one wants to do - especially deductive - verification. That is, if one wants to prove that a proof system for a programming language is sound and complete, one will have to define the se-mantics of this programming language (see also [de Bakker, 1980]). Otherwise, it becomes problematic to define when a specification is true for a program, which is necessary for proving soundness and completeness. In this thesis, we will be concerned with verification mainly in Chapter 7.
In the context of cognitive agent programming, formal semantics is a nec-essary prerequisite for establishing a formal relation between cognitive agent programming languages and BDI logics. As noted in Section 1.1, it is pre-cisely this which has motivated Rao to propose the programming language AgentSpeak(L) as an alternative to the BDI architecture PRS.
Finally, we mention the following as a reason for the use of formal seman-tics. Generally, formal semantics is regarded as an area of theoretical computer science, and is consequently viewed as a field that does not have an immediate connection with the everyday programming practice. In particular, in the field of cognitive agent programming, approaches such as ours are generally regarded as theoretical, whereas approaches that, e.g., build on Java and do not have formal semantics, are regarded as practical.
4Note that “putting together” means “constructing” or “creating”, rather than
6 INTRODUCTION
While this may be true to a certain extent, we like to argue that the uptake of cognitive agent programming languages in mainstream software engineering can be facilitated by using formal semantics in the design of these languages. The reason for this is that the use of formal semantics generally helps in getting a better understanding of the language. A better understanding helps to iden-tify the essence of a language, which can contribute to the design of a simpler language that captures these essential aspects.5 We believe that clarity and simplicity are features that greatly increase the chances of a language being used in practice. As formal semantics can be a tool for achieving clarity and simplicity, formal semantics can be viewed as a tool for advancing the use of cognitive agent programming languages in practice.
In summary, formal semantics provides a solid foundation for the develop-ment of programming languages, and we hope that this thesis provides such a foundation for the further development of cognitive agent programming lan-guages.
5Note that we do not argue that simpler is always better. Rather, we argue that a language
should not be unnecessarily complicated. However, if more complicated features achieve a certain desired level of expressiveness, the language designer should not refrain from adding these features.
Chapter 2
Setting the Stage
The aim of this chapter is to set the stage for the rest of this thesis. We introduce a simple cognitive agent programming language and show how we can concretize various mental attitudes in a programming language. This language combines elements of simplified versions of the cognitive agent programming languages 3APL [Hindriks et al., 1999b] and GOAL [Hindriks et al., 2001], and resembles the language Dribble [van Riemsdijk et al., 2003b]. In the rest of this thesis, we will be concerned with a further investigation of certain aspects of this language.
2.1
Syntax
2.1.1
Beliefs, Goals, and Plans
The basic components of our language are beliefs, goals, and plans. Beliefs are represented using a so-called belief base, describing the information an agent has about the world and internal information. In this thesis, a belief base will consist of a set of propositional formulas. In principle, one could use other knowledge representation languages, such as first order languages (see, e.g., [Hindriks et al., 1999b, Dastani et al., 2004] and [Hindriks, 2001, Chapter 2]). We choose to use a propositional language, because its relative simplicity allows us to focus on the essence of the aspects of cognitive agent programming lan-guages that we are concerned with in this thesis. Goals are represented using a goal base, which also consists of a set of propositional formulas. These formulas represent the situations the agent wants to achieve.
Definition 2.1 (belief base and goal base) Assume a propositional language L with typical formula φ and the connectives ∧ and ¬ with the usual meaning. An agent’s belief base is typically denoted by σ, and is a subset of L, i.e., σ ⊆ L. Similarly, an agent’s goal base is typically denoted by γ, where γ ⊆ L.
8 SETTING THE STAGE
In this thesis, we will often use Σ to denote the set of belief bases, where Σ = ℘(L). In order to refer to the beliefs and goals of an agent, we generally use so-called belief and goal formulas as defined below. These formulas can be used to express that the agent has or does not have certain beliefs or goals. Definition 2.2 (belief and goal formulas) The belief formulas LBwith typical
element β and the goal formulas LGwith typical element κ are defined as follows,
where φ ∈ L.
β ::= ⊤ | Bφ | ¬β | β1∧ β2
κ ::= ⊤ | Gφ | ¬κ | κ1∧ κ2
Note that the B and G operators cannot be nested, i.e., formulas of the form BGφ or BBφ are not part of the languages.
Plans are the agent’s means for achieving its goals. A plan is a sequence of basic actions and so-called abstract plans. As in 3APL and GOAL, basic actions can be executed, resulting in a change of the agent’s belief base. The execution of actions may also cause changes in the agent’s environment through some interface (see also [Hindriks, 2001, Chapter 2]). The interaction of an agent with its environment is however not considered in this thesis where formal semantics is concerned (see Sections 2.2 and 2.5). An abstract plan cannot be executed directly in the sense that it updates the belief base of an agent. Abstract plans, on the other hand, serve as an abstraction mechanism like procedures in imperative programming. If a plan consists of an abstract plan, this abstract plan could be transformed into basic actions through reasoning rules, which will be introduced below.
Definition 2.3 (plan) Assume that a set BasicAction with typical element a is given, together with a set AbstractPlan with typical element p. Let c ∈ (BasicAction ∪ AbstractPlan). Then the set of plans Plan with typical element π is defined as follows.
π ::= a | p | c; π
The language of plans can be extended in a straightforward way to incorpo-rate, e.g., constructs for programming conditional choice (if-then-else) or loops (while). These extensions are however not needed for the investigations car-ried out in this thesis. The reason for defining sequentially composed plans as c; π, rather than as π1; π2 as was, e.g., done in [Hindriks et al., 1999b], will be
explained in Section 2.2 (Remark 2.2).
2.1.2
Reasoning Rules
The idea is that agents in our language try to achieve their goals by means of ex-ecuting plans. In order to allow the programmer to specify which plan an agent should execute for which goals, we introduce a language construct called plan se-lection rule. Plan sese-lection rules are of the form κ | β ⇒ π. This rule represents
SYNTAX 9
that the agent may select plan π if the belief condition β and the goal condition κ hold. These rules were first introduced in [van Riemsdijk et al., 2003b], and are derivative from rules introduced in [Hindriks et al., 2001].
Besides plan selection rules, agents in our language also have so-called plan revision rules. Plan revision rules are of the form πh| β πb. Informally, this
rule expresses that if the agent has a plan πh, and believes β to be the case, it
may replace the plan πh by the plan πb. These rules can thus be used by the
agent to revise its plan at run-time. Plan revision rules were first introduced in [Hindriks et al., 1999b], and were termed “practical reasoning rules” in that paper.
Definition 2.4 (reasoning rules) The sets of plan selection rules RPSand plan
revision rules RPR are defined as follows.1
RPS = {κ | β ⇒ π : κ ∈ LG, β ∈ LB, π ∈ Plan}
RPR = {πh| β πb : β ∈ LB, πh, πb∈ Plan}
2.1.3
An Agent
To program an agent in our language means to specify its initial beliefs and goals, and to write sets of plan selection rules and plan revision rules. Also, an agent contains a specification of how the belief base of the agent is updated if basic actions are executed. For reasons of technical convenience and as done in other papers on similar languages (see, e.g., [Hindriks et al., 1999b]), we assume for this a function T that takes a belief base and a basic action, and yields a new belief base resulting from the execution of the action.
This function could be defined using advanced techniques from the field of belief revision, or, if the belief base has a simple structure, simpler methods could be used. Investigating belief revision techniques is however not the topic of this thesis. In Chapter 10, we do present a simple method for specifying belief update through action execution, which is also the one used in implementations of 3APL.
Definition 2.5 (agent) An agent is a tuple hσ0, γ0, PS, PR, T i, where
σ0 ⊆ L is the initial belief base, γ0 ⊆ L is the initial goal base, PS ⊆ RPS
and PR ⊆ RPR are the plan selection and plan revision rules, respectively, and
T : (BasicAction × Σ) → Σ is a partial function where Σ = ℘(L) is the set of belief bases, expressing how belief bases are updated through basic action execution.
Note that the agent is not endowed with an initial plan. The idea is that an agent should use its plan selection rules to adopt plans to reach its goals. Further, we use the term agent here to refer to the tuple containing the initial
1We use the notation {. . . : . . .} instead of {. . . | . . .} to define sets, to prevent confusing
10 SETTING THE STAGE
belief base and goal base, and reasoning rules and belief update function. It might be considered more appropriate to use the term “agent program” for this tuple, and to use the term “agent” for the corresponding computational entity when it is executing. However, in this thesis we will loosely use the term agent in both cases.
2.2
Semantics
In the previous section, we have defined the components of an agent. In this section, we specify what it means to execute such an agent, i.e., we specify its semantics. In order to do this, we introduce the notion of a configuration. Configurations are used to represent the (components of the) agent at each moment during execution. The reasoning rules and the belief update function do not change during computation. We will thus generally not include these in configurations, for reasons of presentation. Rather, configurations consist of a belief base, a goal base, and a plan. Configurations in the context of cognitive agent programming languages are sometimes also called mental states (see Chapter 6 and [Hindriks et al., 1999b, van Riemsdijk et al., 2003b]).
Below, we formally define configurations. The third component of a configu-ration represents the plan of the agent. This may either be a plan consisting of a sequence of basic actions and abstract plans as specified in Definition 2.3, or it may be an empty plan, which is denoted by ǫ. The empty plan is introduced for technical convenience, which will be further explained below (Remark 2.1). Definition 2.6 (configuration) A configuration is a tuple hσ, γ, πi where σ ⊆ L, γ ⊆ L, and π ∈ (Plan ∪ {ǫ}). If hσ0, γ0, PS, PR, T i is an agent, then
hσ0, γ0, ǫi is the initial configuration of the agent.
Before defining what it means to execute an agent, we need to specify the semantics of belief and goal formulas, since the application of reasoning rules depends on this. Belief and goal formulas are evaluated in a configuration. The semantics specifies that Bφ is true in a configuration if φ follows from the belief base of the agent. A formula Gφ is true if φ follows from the goal base, and φ does not follow from the belief base. The idea is, that an agent should not have something as a goal which it already believes to be achieved. These kinds of goals are generally called achievement goals, and these are the goals that we mostly consider in this thesis. We refer to Chapter 5 for a further discussion of various kinds of goals.
Definition 2.7 (semantics of belief and goal formulas) Let φ ∈ L and let |= be the standard entailment relation for L. Further, let hσ, γ, πi be an agent configuration, let β, β1, β2∈ LB and let κ, κ1, κ2∈ LG. The semantics |=LB and
SEMANTICS 11
|=LG of belief and goal formulas, respectively, are then as defined below.
hσ, γ, πi |=LB ⊤
hσ, γ, πi |=LB Bφ ⇔ σ |= φ
hσ, γ, πi |=LB ¬β ⇔ hσ, γ, πi 6|=LB β
hσ, γ, πi |=LB β1∧ β2 ⇔ hσ, γ, πi |=LB β1and hσ, γ, πi |=LB β2
hσ, γ, πi |=LG⊤
hσ, γ, πi |=LGGφ ⇔ γ |= φ and σ 6|= φ
hσ, γ, πi |=LG¬κ ⇔ hσ, γ, πi 6|=LG κ
hσ, γ, πi |=LGκ1∧ κ2 ⇔ hσ, γ, πi |=LG κ1and hσ, γ, πi |=LG κ2
It is important to note that these semantics have the property that the formulas B¬φ and ¬Bφ (and similarly for G¬φ and ¬Gφ) are not equivalent. That is, B¬φ holds in a configuration c with belief base σ iff σ |= ¬φ, and ¬Bφ holds in c iff c 6|=LB Bφ, which holds iff σ 6|= φ. The formula B¬φ thus expresses that ¬φ
should follow from the belief base (in the standard propositional logic sense), while ¬Bφ expresses that φ should not follow. In general, this is not equivalent. Consider, e.g., a configuration c with belief base {q}. In this case, B(¬p) does not hold in c, while ¬Bp does hold. If the belief base is consistent, we do have that ¬Bφ holds if B¬φ holds.
Further, we make a remark with respect to the semantics of goal formulas. From the perspective of the semantics of goal formulas, the goal bases γ1= {p, q}
and γ2 = {p ∧ q}, for example, are equivalent. Consider, e.g., the formula
G(p ∧ q). This formula is true in configurations with goal base γ1 (assuming
that p ∧ q is not believed by the agent), and in configurations with goal base γ2. This is because anything that follows from γ1(in the standard propositional
logic sense) also follows from γ2, and vice versa. However, these two goal bases
are not equivalent when considering the semantics of the execution of an agent, which will be introduced below. The idea is that γ2 represents that the agent
wants to achieve a situation in which p and q hold at the same time, while in the case of γ1, the agent does not necessarily has to strive for a situation in
which both p and q hold. It may be the case that it first achieves p, and then q. These ideas are reflected in the specification of when goals should be removed from the goal base (see Definition 2.9 below).
We now move on to defining the semantics of executing an agent in our language. This semantics is defined using a transition system [Plotkin, 1981]. A transition system for a programming language consists of a set of axioms and transition rules for deriving transitions for this language. A transition is a transformation of one configuration into another and it corresponds to a single computation step. In the transition rules below, we assume an agent with a set of plan selection rules PS, a set of plan revision rules PR, and a belief update function T .
An agent’s configuration may change through the execution of an action from the agent’s plan, or through the application of a reasoning rule.
Corre-12 SETTING THE STAGE
spondingly, the transition system consists of three transition rules, i.e., one for executing an action, one for applying a plan selection rule, and one for applying a plan revision rule.
Below, we present the transition rule for basic action execution. In that transition rule, we use a function • : Plan′ → (Plan′ → Plan′), where Plan′ is defined as Plan ∪ {ǫ}. This function takes two plans, that may also be empty plans, and concatenates these.
Definition 2.8 (plan concatenation) Let π′ ∈ Plan′, π ∈ Plan, and let c ∈
(BasicAction ∪ AbstractPlan). The function • : Plan′ → (Plan′ → Plan′) which concatenates two plans, is then defined as follows, using infix notation.
ǫ • π′ = π′
π′• ǫ = π′
c • π = c; π c; π • π′ = c; (π • π′)
We will explain why we need this function (Remark 2.1), after presenting the definition of the transition rule for basic action execution. Basic actions update the belief base of an agent if they are executed, as specified through the partial function T , where T (a, σ) returns the result of updating belief base σ by per-forming action a. The fact that T is a partial function represents that an action may not be executable in some belief states. Goals that are reached through execution of an action are removed from the goal base. After execution of an action, the action is removed from the plan.
Definition 2.9 (action execution) Let a ∈ BasicAction and let γ′= γ \ {φ ∈ γ | σ′|= φ}.
T (a, σ) = σ′
hσ, γ, a • πi → hσ′, γ′, πi
Remark 2.1 (empty plan and plan concatenation) The reason that we have defined configurations such that the plan component may be either a plan from the set Plan or an empty plan, is as follows. Because π in the transition rule above may also be the empty plan ǫ, the transition rule specifies two variants of executing an action: the plan a • π may consist of an action a followed by a non-empty sequence of actions and abstract plans (in which case π ∈ Plan), or the action a may be the only action of the plan (in which case π = ǫ). If we would not have allowed π to be the empty plan, we would have had to introduce another transition rule, that specifies how to execute an action if the action is the only action of the plan, i.e., if the plan component of the configuration is of the form a.
A consequence of this is that we can, strictly speaking, not use the sequential composition operator for specifying the configuration on the left-hand side of
SEMANTICS 13
the transition, i.e., by specifying the configuration as hσ, γ, a; πi. Following Definition 2.3, the sequential composition operator is defined on basic actions and non-empty plans from the set Plan. The concatenation operator solves our problem, because this operator is defined also on empty plans.
Alternatively, we could have introduced empty plans in the language of plans of Definition 2.3. This would however have allowed us to define, e.g., a plan of the form ǫ; ǫ; ǫ; a, from which our language would hardly benefit. Also, this would not have provided the advantage of having to specify only one transition for the execution of basic actions, since a plan a; ǫ would then consist of two elements, rather than only of a, as in the case of a • ǫ. On the contrary, we would need to specify another transition for the execution of empty plans, in order to get rid of the empty plans in, e.g., the plan ǫ; ǫ; ǫ; a.
Having explained all this, we will not be so strict in the rest of this thesis. A plan selection rule is applicable in a configuration if the goal condition and belief condition of the rule are true in that configuration. Further, it can only be applied if the plan of the agent is empty. The idea is, that an agent can only select a new plan if it has finished executing its old plan. In the resulting configuration, the plan becomes equal to the consequent of the plan selection rule.
Definition 2.10 (plan selection)
κ | β ⇒ π ∈ PS hσ, γ, ǫi |=LG κ hσ, γ, ǫi |=LB β
hσ, γ, ǫi → hσ, γ, πi
We could have defined configurations as containing a plan base consisting of a set of plans, rather than of a single plan, as done in, e.g., [Hindriks et al., 1999b, Dastani et al., 2004]. In that case, plan selection rules could be used to add plans to the plan base. Such a choice would however introduce added complexity to the semantics of plan execution, i.e., one would have to define how plans are executed concurrently, and it would call for a discussion on possible interferences between plans that are executed concurrently. Except in Chapter 4, we will avoid these additional complications throughout this thesis by having the plan base consist of only one plan.
A plan revision rule can be applied in a configuration if the head of the rule is equal to a prefix of the plan in the configuration. The application of the rule results in the revision of the plan, such that the prefix equal to the head of the rule is replaced by the plan in the body of the rule. A rule a; b | ⊤ c can for example be applied to the plan a; b; c, yielding the plan c; c. The belief base is not changed through plan revision. As in the transition rule for action execution (Definition 2.9), we use the concatenation operator.
Definition 2.11 (plan revision)
πh| β πb∈ PR hσ, γ, πh• πi |=LB β
14 SETTING THE STAGE
Remark 2.2 (structure of plans) We are now in a position to explain why we have chosen to define sequentially composed plans as c; π (where c is an atomic plan element, i.e., a basic action or an abstract plan), rather than as π1; π2.
If we would have chosen the latter option, the configuration on the left-hand side of the transition for plan revision could have been defined as hσ, γ, πh; πi
(ignoring for the moment that we might want to allow π to be the empty plan). Given, e.g., a plan revision rule a; b | ⊤ c, one could then argue that it is not clear whether this rule is applicable to, e.g., the plan a; b; c (where a, b, and c are basic actions). The reason is that this plan could be viewed as the sequential composition of a and b; c, or as the sequential composition of a; b and c. If the plan is viewed as (a; b); c (where we introduce brackets to indicate how the plan is composed), the rule can be applied. If, however, the plan is viewed as a; (b; c), the rule cannot be applied, since this plan cannot be decomposed into the plan a; b and the plan c. The idea is, however, that the rule should be applicable to both plans, regardless of how they are composed.
Our solution to this problem is to define an unambiguous grammar of plans by defining sequentially composed plans as c; π. The plan a; b; c can then only be viewed as the plan a; (b; c). Now, we have to make sure that we define the semantics such, that the rule a; b | ⊤ c is applicable to this plan. Given this definition of plans, the desired semantics can be achieved easily by using the concatenation operator, as done in Definition 2.11. The transition rule for plan revision specifies that the rule a; b | ⊤ c can be applied to any plan resulting from concatenating a; b and some plan π. In particular, the rule can be applied to the plan resulting from the concatenation of a; b and c, i.e., to the plan a; (b; c).
Having explained this, we will not always be so strict in this thesis.
The semantics of an agent in our language is derived directly from the transition relation →. It can be defined in various ways. One way of defining the semantics, is to define it as a set of so called computation runs.
Definition 2.12 (semantics) A computation run for an agent hσ0, γ0, PS, PR, T i is a finite or infinite sequence s0, . . . , sn or s0, . . . such that
si for i ≥ 0 are configurations, s0 is the initial configuration of the agent, i.e.,
s0= hσ0, γ0, ǫi (see Definition 2.6), and ∀i>0 : si−1 → si is a transition in the
transition system for the agent. For finite computation runs s0, . . . , sn it should
be the case that there is no transition sn→ sn+1for some sn+1. The semantics
of the agent is then defined as the set of all computation runs for this agent.
2.3
Example
We present a simple example in order to illustrate how the components of the language may be used, and to further clarify the semantic definitions (Section
EXAMPLE 15
2.3.1). In Section 2.3.2, we use the example to argue that goals and plan revision can be used for programming flexibly behaving agents.
2.3.1
Building a Tower
The example is adapted from [van Riemsdijk, 2002], and was also used in [van Riemsdijk et al., 2003b, Dastani et al., 2004]. Our example agent has to solve the problem of building a tower of blocks. The blocks have to be stacked in a certain order: block C has to be on the floor (F l), B should be on C, and block A should be on B. Initially, the blocks A and B are on the floor, while C is on A.
The only action an agent can take, is to move a block x from some block y to another block z (move(x, y, z)). Variables are used to ease the specification of the example agent, and should be instantiated with the relevant arguments. That is, the action move(x, y, z) represents the set of actions
{move(x, y, z) : x ∈ {A, B, C} and y, z ∈ {A, B, C, F l} and x 6= y 6= z}. The move(x, y, z) action is enabled only if the block to be moved (x) and the block to which x is moved (z) are clear. The result of the action is, that x is on z and not on y, block y becomes clear and block z is not clear anymore (assuming that z is not the floor, because the floor is always clear). Let the agent’s initial belief base σ0, goal base γ0, plan selection rules PS, and plan revision rules PR,
be as defined below. The function T will be specified in the sequel.
σ0 = {on(C, A), on(A, F l), on(B, F l), clear(B), clear(C), clear(F l)}
γ0 = {on(A, B) ∧ on(B, C) ∧ on(C, F l)}
PS = {G(on(x, z)) | B(on(x, y)) ⇒ move(x, y, z) :
x ∈ {A, B, C} and y, z ∈ {A, B, C, F l} and x 6= y 6= z} PR = {move(x, y, z) | B(on(u, x)) move(u, x, F l); move(x, y, z) :
x, u ∈ {A, B, C} and y, z ∈ {A, B, C, F l} and x 6= y 6= z} ∪ {move(x, y, z) | B(on(u, z)) move(u, z, F l); move(x, y, z) :
x, u ∈ {A, B, C} and y, z ∈ {A, B, C, F l} and x 6= y 6= z} The goal rules are used to derive the move(x, y, z) action that should be executed to fulfil a goal on(x, z). The preconditions of the move action are not checked in these rules, so it is possible that the derived action cannot be executed in a particular configuration. The plan revision rules can then be used to create a configuration in which this action can be executed. Note that the goal rules are used to select an action to fulfil a single proposition of the form on(x, z). The initial goal base however contains a conjunction of on(x, z) propositions. The goal rule is applicable to this conjunction, because a formula Gφ is true if φ is a logical consequence of the goal base (see Definition 2.7).
We assume that the function T , when applied to basic action move(x, y, z) and a belief base σ has the following properties. The function is defined iff
16 SETTING THE STAGE
σ entails clear(x) ∧ clear(z) ∧ on(x, y). The result is a belief base that en-tails on(x, z) ∧ clear(y) and that does not entail on(x, y) and clear(z) if z 6= F l. If z = F l, the resulting belief base entails on(x, z) ∧ clear(y) ∧ clear(z) and does not entail on(x, y). This describes the changes to the propositions on(x, y), on(x, z), clear(y) and clear(z) which are caused by the action move(x, y, z). Below, we specify which propositions are not changed by the action move(x, y, z), assuming that the function T is defined on action move(x, y, z) and belief base σ, i.e., let T (move(x, y, z), σ) = σ′.
σ |= on(u, v) ∧ u 6= x ⇒ σ′ |= on(u, v)
σ |= clear(w) ∧ w 6= z ⇒ σ′ |= clear(w)
In the initial configuration of the agent hσ0, γ0, ǫi, three possible plan selection
rules could be applied: x = A, y = F l, z = B or x = B, y = F l, z = C or x = C, y = A, z = F l (yielding move(A, F l, B), move(B, F l, C) or move(C, A, F l)). Suppose the first is chosen. After application of this plan selection rule, the plan of the agent becomes equal to the plan in the consequent of the plan selection rule, resulting in the following configuration.
σ1 = {on(A, F l), on(B, F l), on(C, A), clear(B), clear(C), clear(F l)}
γ1 = {on(A, B) ∧ on(B, C) ∧ on(C, F l)}
π1 = move(A, F l, B)
The plan cannot be executed because the preconditions of the action are not satisfied in this configuration (there is a block on A). The plan selection rule can-not be applied because the plan of the agent is can-not empty. The only applicable rule is the plan revision rule move(A, F l, B) | B(on(C, A)) move(C, A, F l); move(A, F l, B).
σ2 = {on(A, F l), on(B, F l), on(C, A), clear(B), clear(C), clear(F l)}
γ2 = {on(A, B) ∧ on(B, C) ∧ on(C, F l)}
π2 = move(C, A, F l); move(A, F l, B)
The only option is to execute the first action of the plan, resulting in a changed belief base that has the property as specified below.
σ3 |= on(A, F l) ∧ on(B, F l) ∧ on(C, F l) ∧ clear(A) ∧ clear(B) ∧
clear(C) ∧ clear(F l)
γ3 = {on(A, B) ∧ on(B, C) ∧ on(C, F l)}
π3 = move(A, F l, B)
In this configuration, the action move(A, F l, B) is executed. In the resulting configuration, the only (logical consequence of the) goal which is not satisfied, is on(B, C). A plan is constructed to move B onto C: first A is moved onto the floor, then B is moved onto C. The only goal which is not satisfied is on(A, B). The action move(A, F l, B) is selected using a plan selection rule and
EXAMPLE 17
then executed. This results in the following final configuration in which the goal is reached and thus removed from the goal base.
σF |= on(A, B) ∧ on(B, C) ∧ on(C, F l) ∧ clear(A) ∧ clear(F l)
γF = ∅
πF = ǫ
This example execution shows that the agent can reach its initial goal. The number of actions that the agent needs to execute before it reaches its goal, is partly dependent on which choices are made if multiple plan selection rules are applicable. As was shown, three plan selection rules are for instance applicable in the initial configuration.
2.3.2
Goals and Plan Revision: Programming Flexible Agents
Goals and plan revision form two important aspects of the presented cognitive agent programming language. While these aspects can be studied relatively independently as we do in this thesis (see Section 2.4 for an overview), they can nevertheless be linked by viewing them as both facilitating the programming of flexible agents.
Agents need to have a certain level of flexibility, since they are often expected to operate in dynamic environments. The idea that goals can provide this added flexibility, can be explained using the tower building example (see Chapter 5 for a more elaborate discussion of advantages of goals).
From the transition rules of Section 2.2, we know that a goal is removed from the goal base only if the agent believes it has achieved the goal. Now consider the example tower building agent, which we will refer to as agent A. Assume agent A is almost finished building its tower, i.e., block C is on the floor and B is on C, and A is on the floor. In order to finish the tower, it has to move block A onto block B. Now assume there is another agent in the environment, which at this point moves block B onto the floor, thereby destroying part of the tower. Also assume agent A observes this and updates its belief base accordingly.
Due to the fact that the goal on(A, B) ∧ on(B, C) ∧ on(C, F l) has not been removed from the goal base (because the tower has not been completed yet), the formula G(on(B, C)) holds once more after the other agent has moved block B (even though on(B, C) was previously believed, and therefore not a goal). Because of this, agent A can now apply the plan selection rule in order to move B onto C again. The fact that the agent has a goal base and that goals remain in the goal base until they are believed to be achieved, thus provides for flexibility in the sense that the agent will continue to try to achieve its goals, even if the environment changes in unhelpful ways, or if plans fail. While this kind of flexibility might also be achievable if programming in some general purpose language, the idea is that it can be beneficial that it is a built-in characteristic of the programming language.
18 SETTING THE STAGE
This, of course, does not mean that using goals and plan selection rules will yield satisfactory results in every dynamic environment. For example, after the execution of a plan that has not achieved its desired objective (either because the programmer has not provided the right plan, or because there were changes in the environment that prevented the agent from reaching its goal), it may be the case that the agent finds itself in a situation in which there is no applicable plan selection rule. The agent may need to return to some initial situation, in order to be able to apply plan selection rules to try once more to achieve its goals. On the other hand, one could argue that the programmer should have made sure that the agent had the appropriate plan selection rules. That is, it is still the job of the programmer to make appropriate use of the components provided by the agent programming language, as is the case with any other programming language. Always providing the agent with the right plan selection rules can however be difficult if the environment gets “too unpredictable”.
Another issue is that the agent may be left with part of a plan that is not executable anymore, because the environment has changed. In that case it needs to have a mechanism for getting rid of this old plan, and perhaps for changing the environment to allow it to start executing plans once again for achieving its goals. For this, plan revision rules could potentially be used.
Besides for cleaning up failed plans, plan revision rules can be used to provide for added flexibility in general. The idea is that plan revision rules can be used to revise an agent’s plan, if the circumstances demand this. The belief condition can be used to specify these circumstances. In the tower building example for instance, plan revision rules are used to revise the agent’s plan if a move action that is to be executed next, cannot be executed. The belief conditions of these rules specify the conditions under which a move action is not executable. In this example, the plan is revised in such a way that the desired move action can be executed eventually.
As in the case of goals and plan selection rules, it is the job of the programmer to specify appropriate plan revision rules. In order to be able to do this in an effective way, the environment cannot be too unpredictable. The programmer needs to be able to foresee up to a certain level where things might go wrong.
2.4
Overview of Thesis
In the previous sections, we have presented a cognitive agent programming language. So are we done now? Well. . . no. Several aspects of the presented language warrant a further investigation, parts of which will be carried out in the rest of this thesis. In particular, we will consider aspects related to goals (Part I), and aspects related to plan revision (Part II). Some software engineering aspects will be addressed in Part III.
OVERVIEW OF THESIS 19
2.4.1
Part I: Goals
In Part I, we investigate various ways of representing goals and of defining their semantics. In Chapter 3, we address, broadly speaking, the relation between the semantics of abstract plans and of goals. Abstract plans are sometimes viewed as the subgoals of an agent’s plan, in the sense that an abstract plan p is sometimes interpreted as representing that the agent should achieve a state in which he believes p to be the case. In this light, we have found it interesting to study whether the properties of abstract plans correspond in some way to the properties of goals, and in particular the property that goals are not dropped until they are believed to be achieved (see Definition 2.7). Chapter 3 sheds some light on this issue, thereby clarifying whether aspects of the behavior of goals can be captured by a construct present in the plans of an agent.
In Chapter 4, we address issues regarding the semantics of goals, given that we want to allow the representation of conflicting goals. The semantics for goal formulas of Definition 2.7 is trivialized if the goal base of the agent is inconsistent. That is, if the goal base is inconsistent, the agent can derive G⊥, and any other formula Gφ. If one wants to allow the goal base to be inconsistent without trivializing the semantics of goal formulas if this is the case, this semantics will have to be adapted. In Chapter 4, we investigate such adaptations. Further, we propose an extension to the representation of goals, by proposing a construct for representing that goals may be conditional on beliefs or other goals. That is, by means of this construct one can represent that if the agent has a certain belief (or goal), it should also have a certain (other) goal. Given such a construct, we again investigate a semantics for goal formulas that allows the agent to have conflicting goals, without trivializing the semantics.
Concluding Part I, Chapter 5 contains a general discussion regarding liter-ature addressing goals in the context of agent programming. We argue why we think goals are important in agent programming. Further, we identify important strands of research regarding the representation of goals in agent programming frameworks, thereby also showing how our work can be positioned with respect to other approaches.
2.4.2
Part II: Plan Revision
In Part II, we focus on plan revision. As our object of study, we take a language without goals (and therefore also without plan selection rules), and of course with plan revision rules. An important aspect of plan revision that calls for further investigation, and which is the aspect on which we focus in this the-sis, is the semantics of the execution of plans in the presence of plan revision rules. As it turns out, this semantics is not compositional. This means, broadly speaking, that the semantics of a composed plan cannot be defined in terms of the semantics of the parts of which it is composed.
20 SETTING THE STAGE
fact that the head of a plan revision rule may consist of a composed plan, rather than of an atomic plan. The issue of non-compositionality to which this gives rise, can be explained informally as follows.
Because of the presence of plan revision rules, the semantics of an atomic plan element cannot be considered in isolation. Put differently, the semantics of, e.g., a basic action a, depends on the actions that surround it. There may, e.g., be a plan revision rule with a; b as the head, and one with a; c as the head. Given a plan with a as the first action of the plan, i.e., a plan of the form a; π, the possible application of one of the plan revision rules depends on whether π is of the form b; π′or of the form c; π′(or of yet another form). When determining
the semantics of the plan a; π, the action a can thus not be considered separately from π. If the semantics of plans would have been compositional, it would have been possible to consider a in isolation. The non-compositional nature of the semantics of plans gives rise to problems if one wants to prove properties of plan execution. If the semantics of plans is not compositional, one cannot prove properties of a composed plan by proving properties of the parts of which it is composed, which is what one would generally want to do.
This issue of the non-compositionality of the semantics of plans in the pres-ence of plan revision rules is approached from three different perspectives in this thesis. In Chapter 6, we propose a meta-language on top of the agent program-ming language. This meta-language has constructs for specifying that an action should be executed, or that a plan revision rule should be applied. We show that it is possible to define a compositional semantics for this meta-language, and show that a particular meta-program is equivalent with the object-level semantics of the agent programming language. In Chapter 7, we take another approach and present a specialized dynamic logic for reasoning about plans in the presence of plan revision rules. This logic comes with a sound and complete axiomatization, and essentially circumvents the non-compositionality issue in a certain way. In Chapter 8, we approach the issue from again another angle, by restricting plan revision rules in such a way that the semantics of plans becomes compositional.
2.4.3
Part III: Software Engineering Aspects
Part III is different from the first two parts in that it does not address one particular aspect of the agent programming language presented in this chapter. The two chapters in this last part both address software engineering issues that concern the agent programming language as a whole.
Chapter 9 addresses modularization in cognitive agent programming lan-guages. Modularization is widely recognized as a central issue in software en-gineering. A system which is composed of modules, i.e., relatively independent units of functionality, is called modular. When it comes to cognitive agent pro-gramming languages, one can think of various ways in which agent programs can be modularized. We discuss existing approaches to modularity in cognitive
IMPORTANT ISSUES WE DO NOT ADDRESS 21
agent programming, and propose a new kind of modularity, i.e., goal-oriented modularity. In goal-oriented modularity, the goals of an agent are taken as the basis for modularization. We present a formal semantics of goal-oriented mod-ularity in the context of an agent programming language that is similar to the one presented in the present chapter.
In Chapter 10, we discuss a particular approach for prototyping an agent pro-gramming language similar to the one presented in this chapter. The approach we take is to implement the agent programming language in the Maude term rewriting language. Maude is based on the mathematical theory of rewriting logic. The language has been shown to be suitable both as a logical framework in which many other logics can be represented, and as a semantic framework, through which programming languages with semantics based on a transition system can be implemented in a rigorous way. We explore the usage of Maude in the context of agent programming languages, and argue that, since agent programming languages such as the one presented in this chapter have both a logical component (in the form of belief and goal formulas and their corre-sponding satisfaction relations) and a semantic component (in the form of the transition system), Maude is very well suited for prototyping such languages.
2.5
Important Issues We Do Not Address
A number of important issues related to cognitive agent programming languages are not addressed in detail in this thesis. In particular, even though we have argued that goals and plan revision can be linked by considering these as provid-ing for added flexibility in the case of dynamic environments, we will in the rest of this thesis not consider aspects related to interaction with an environment. In particular, we will not address sensing, or issues related to the problem of making sure that the belief base accurately represents the environment. The main reason that we do not do this, is that it is not needed for the investigations into semantics of goals and plan revision that we carry out in this thesis. In-corporating the environment in the semantics of agent programming languages could be done by incorporating a model of the environment in the configura-tions. However, from a technical point of view this does not really differ from using a belief base as a model of the environment. Our theory would therefore hardly benefit from this, unless one would want to investigate issues related to sensing and updating of beliefs, which we do not.
Further, we do not aim to investigate advanced formalisms for representing an agent’s beliefs. Throughout this thesis, the belief base will consist of a set of propositional formulas, and the semantics of belief formulas will be as in Definition 2.7.
Moreover, in this thesis we do not consider planning from first principles (see, e.g., [Fikes and Nilsson, 1971]), even though the vocabulary used in that field (beliefs, goals, plans) is similar to ours. The relation between planning from
22 SETTING THE STAGE
first principles and plan revision (or agent programming in general) is discussed briefly in Section 7.1.
Furthermore, in this thesis we shall not dwell on the pragmatics of the dis-cussed approach, but concentrate on theoretical issues.2 In particular, we will
not be concerned with agent-oriented design methodologies [Zambonelli et al., 2003, Bresciani et al., 2004].
Finally, we focus solely on aspects related to the programming of individ-ual agents. Even though the slogan “There is no such thing as a single-agent system” is sometimes used, the origins of research into intelligent agents lie in research concerning single-agent issues (see [Wooldridge and Jennings, 1995] for an overview). In our view, research into single-agent aspects is an important part of agent systems research. In fact, we would like to propose the slogan “There is no multi-agent system without single agents”.