Full text
Bringing social reality to Multiagent and Service architectures Practical reductions for monitoring of deontic-logic and constitutive norms Sergio Alvarez-Napagao Advisor: Javier Vázquez-Salceda PhD Thesis Universitat Politècnica de Catalunya
A thesis submitted for the degree of Doctor of Philosophy in Articial Intelligence at the Polytechnic University of Catalonia Tesi presentada per obtenir el títol de Doctor en Intel·ligència Articial per la Universitat Politècnica de Catalunya 2015 Bringing social reality to Multiagent and Service architectures Practical reductions for monitoring of deontic-logic and constitutive norms Sergio Alvarez-Napagao Advisor: Javier Vázquez-Salceda PhD Thesis Universitat Politècnica de Catalunya
This work is licensed under cCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) (http://creativecommons.org/licenses/by-nc-sa/4.0/). The following is a human-readable summary of (and not a substitute for) the license: You are free to: •Share copy and redistribute the material in any medium or format •Adapt remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the following license terms: •bAttribution You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. •nNonCommercial You may not use the material for commercial purposes. •aShareAlike If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. •No additional restrictions You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. In any case not covered by the license above, the exclusive rights of exploitation of this work are reserved by the author (Sergio Alvarez-Napagao), whereas the institution (Universitat Politècnica de Catalunya) holds a non-exclusive right to publicly disseminate the work. The cover artwork: 'Evening Company' (Yegorovich Makovsky, oil painting, dated 1874-1897) belongs to the public domain. Printed in Barcelona. 15 1 First edition: December 10, 2015
A Esther, por estar ahí siempre. A mis padres, a los que les debo todo y, seguramente, hasta que lean esto no se lo habrán acabado de creer.
institution noun 1. a society or organization founded for a religious, educational, social, or similar purpose: a certicate from a professional institution. •an organization providing residential care for people with special needs: an institution for the mentally ill. •an established ocial organization having an important role in the life of a country, such as a bank, church, or legislature: the institutions of democratic government. •a large company or other organization involved in nancial trading: the interest rate nancial institutions charge one another. 2. an established law, practice, or custom: the institution of marriage. •informal a well-established and familiar person, custom, or object: he soon became something of a national institution. 3. the action of instituting something: a delay in the institution of proceedings. Origin late Middle English (sense 2 and sense 3): via Old French from Latin institutio(n-), from the verb instituere (see institute). Sense 1 dates from the early 18th cent. reality noun 1. the state of things as they actually exist, as opposed to an idealistic or notional idea of them: he refuses to face reality |Laura was losing touch with reality. •[ count noun ] a thing that is actually experienced or seen, especially when this is unpleasant: the harsh realities of life in a farming community. •[ count noun ] a thing that exists in fact, having previously only existed in one's mind: we want to make the dream a reality. •the quality of being lifelike: the reality of Marryat's detail. •[ as modier ] relating to reality TV: a reality show. 2. the state or quality of having existence or substance: youth, when death has no reality. •Philosophy existence that is absolute, self-sucient, or objective, and not subject to human decisions or conventions. Origin late 15th cent.: via French from medieval Latin realitas, from late Latin realis `relating to things' (see real). New Oxford American Dictionary 3rd edition, Oxford University Press, Inc., 2010.
Short contents Short contents ·ix Contents ·xi List of Figures ·xv List of Tables ·xix Extended Abstract ·xxi Resumen ·xxiii Acknowledgments ·xxvii Introduction ·xxix I State of the art 1 1 Computation as interaction ·3 2 Norms ·11 3 Normative systems and governance ·23 II Practical reductions 43 4 The challenge ·45 5 Towards a lightweight language for norms ·51 6 Formalising regulative and constitutive norms ·85 7 Normative monitor ·105 ix
xvi List of Figures 7.1 Inference rules for the transition relation ................ 107 7.2 Inference rules for the transition relation ................ 108 7.3 Denition of classicatory counts-as rules. ................ 112 7.4 Denition of proper classicatory counts-as rules. ............ 113 7.5 Context splitting. ............................... 114 7.6 Example of context splitting. ........................ 115 7.7 Activation of counts-as rules. ........................ 116 7.8 Automatic activation of contexts. ...................... 117 7.9 Translation of base rules to Drools .................... 118 7.10 Rules for the trac scenario ......................... 119 7.11 Facts for the trac scenario ......................... 119 7.12 Architecture of the Drools implementation ............... 120 8.1 Example of reductions to monitoring and planning ............ 126 8.2 Actors in the OTMA system. Each medical unit is represented by an agent (circle in gure). ............................ 128 8.3 Layout of the architecture .......................... 129 8.4 An example of translation rule from p-assertion to Jess asserted fact . . 132 8.5 An example of violation detection rule in Jess ............... 133 9.1 Architecture of the system ......................... 139 9.2 Smart Pill Dispenser ............................. 140 9.3 Capabilities of the dierent actors ..................... 142 9.4 Sequence diagram of a typical workow, from prescription to dispensation 143 9.5 Formal model for constitutive norm C1.................. 144 9.6 Formal model for constitutive norm C2.................. 144 9.7 Formal model for regulative norm N1................... 144 9.8 Formal model for regulative norm N2................... 145 9.9 Formal model for regulative norm N3................... 145 9.10 Formal model for regulative norm N4................... 146 9.11 Formal model for regulative norm N5................... 147 9.12 ALIVE-Gaming coupling infrastructure .................. 150 9.13 Games used as case studies ......................... 151 (a) GTA IV ................................. 151 (b) Warcraft III ............................... 151 9.14 Example AI scripts for unit upgrading: (from left to right) Warcraft III and Starcraft (Blizzard), and Age of Mythology and Age of Kings (Microsoft). . . 152 9.15 Social structure for generic RTS games (OperettA Tool screenshot) . . . 154 9.16 Interaction structure for Defend city (OperettA Tool screenshot) . . . . . 154 9.17 Norm example applied to our case (OperettA Tool screenshot) ...... 155 9.18 Warcraft III units enacting actions sent from the ALIVE platform (game view) ..................................... 155 9.19 Warcraft III units enacting actions sent from the ALIVE platform (monitor view) ................................... 156
List of Figures xvii 9.20 ALIVE-Gaming coupling infrastructure for GTA ............. 158 9.21 Graphical representation of the norm it is forbidden to pass under a red light (OperettA Tool) ................................ 159 9.22 Example of translation of base rule to clara ................ 160 9.24 Scatter plot of events samplings and time spent per sample ....... 161 9.23 Example norms in Clojure .......................... 162
List of Tables 5.1 Library of contract-related actions ..................... 65 5.2 Library of contract-related predicates .................... 66 5.3 Library of contract-related actions ..................... 69 5.4 Mapping of concepts: IST-CONTRACT vs ALIVE Framework ...... 77 6.1 Three notions of counts-as. ......................... 88 8.1 Mapping between components required by SOA governance and components of our proposed architecture ................... 134 9.1 Results of the experiment (in microseconds) ............... 163 xix
Extended Abstract As distributed systems grow in complexity, the interactions among individuals (agents, services) of such systems become increasingly more complex and therefore more dif- cult to constrain and monitor. We propose to view such systems as socio-technical systems, in which organisational and institutional concepts, such as norms, can be applied to improve not only control on the components but also their autonomy by the denition of soft rather than hard constraints. Norms can be described as rules that guide the behaviour of individual agents pertaining to groups that abide to them, either by explicit or implicit support. The study of norms, and regulatory systems in general, in their many forms e.g. social norms, conventions, laws, regulations has been of interest since the beginning of philosophy, but has seen a lot of evolution during the 20th century due to the progress in the philosophy of language, especially concerning speech acts and deontic logic. Although there is a myriad of denitions and related terminologies about the concept of norm, and as such there are many perspectives on how to analyse their impact, a common denominator is that norms constrain the behaviour of groups of agents in a way that each individual agent can build, with a fair degree of condence, expectations on how each of their counterparts will behave in the situations that the norms are meant to cover. For example, on a road each driver expects everybody else to drive on only one side of the road (right or left, depending on the country). Therefore, normative contexts, usually wrapped in the form of institutions, are eective mechanisms to ensure the stability of a complex system such as an organisation, a society, or even of electronic systems. The latter has been an object of interest in the eld of Articial Intelligence, and it has been seen as a paradigm of coordination among electronic agents either in multi-agent systems or in service-oriented architectures. In order to apply norms to electronic systems, research has come up with abstractions of normative systems. In some cases these abstractions are based on regimented systems with exible denitions of the notion of norm, in order to include meanings of the concept with a coarse-grained level of logic formality such as conventions. Other approaches, on the other hand, propose the use of deontic logic for describing, from a more theoretical perspective, norm-governed interaction environments. In both cases, the purpose is to enable the monitoring and enforcement of norms on systems that include although not limited to electronic agents. In the present dissertation we will focus on the latter type, focusing on preserving the deontic aspect of norms. xxi
xxii Extended Abstract Monitoring in norm-governed systems requires making agents aware of: 1) what their normative context is, i.e. which obligations, permissions and prohibitions are applicable to each of them and how they are updated and triggered; and 2) what their current normative status is, i.e. which norms are active, and in what instances they are being fullled or violated, in order words, what their social institutional reality is. The current challenge is on designing systems that allow computational components to infer both the normative context and social reality in real-time, based on a theoretical formalism that makes such inferences sound and correct from a philosophical perspective. In the scope of multi-agent systems, many are the approaches proposed and implemented that fulll these requirements up to this date. However, the literature is still lacking a proposal that is suited to the current state-of-the-art in service-oriented architectures, more focused nowadays on automatically scalable, polyglot amalgams of lightweight services with extremely simple communication and coordination mechanisms a trend that is being called microservices. This dissertation tackles this issue, by 1) studying what properties we can infer from distributed systems that allow us to treat them as part of a socio-technical system, and 2) analysing which mechanisms we can provide to distributed systems so that they can properly act as socio-technical systems. The main product of the thesis is therefore a collection of computational elements required for formally grounded and real-time ecient understanding and monitoring of normative contexts, more specically: 1. An ontology of events to properly model the inputs from the external world and convert them into brute facts or institutional events; 2. A lightweight language for norms, suitable for its use in distributed systems; 3. An especially tailored formalism for the detection of social reality, based on and reducible to deontic logic with support for constitutive norms; 4. A reduction of such formalism to production rule systems; and 5. One or more implementations of this reduction, proven to eciently work on several scenarios. This document presents the related work, the rationale and the design/implementation of each one of these elements. By combining them, we are able to present novel, relevant work that enables the application of normative reasoning mechanisms in realworld systems in the form of a practical reasoner. Of special relevance is the fact that the work presented in this dissertation simplies, while preserving formal soundness, theoretically complex forms of reasoning. Nonetheless, the use of production systems as the implementation-level materialisation of normative monitoring allows our work to be applied in any language and/or platform available, either in the form of rule engines, ECA rules or even if-then-else patterns. The work presented has been tested and successfully used in a wide range of domains and actual applications. The thesis also describes how our mechanisms have been applied to practical use cases based on their integration into distributed eldercare management and to commercial games.
Resumen Con el incremento en la complejidad de los sistemas distribuidos, las interacciones entre los individuos (agentes, servicios) de dichos sistemas se vuelven más y más complejas y, por ello, más difíciles de restringir y monitorizar. Proponemos ver a estos sistemas como sistemas socio-técnicos, en los que conceptos organizacionales e institucionales (como las normas) pueden aplicarse para mejorar no solo el control sobre los componentes sino también su autonomía mediante la denición de restricciones débiles (en vez de fuertes). Las Normas se pueden describir como reglas que guian el comportamiento de agentes individuales que pertenecen a grupos que las siguen, ya sea con un apoyo explícito o implícito. El estudio de las normas y de los sistemas regulatorios en general y en sus formas diversas normas sociales, convenciones, leyes, reglamentos ha sido de interés para los erudítos desde los inicios de la losofía, pero ha sufrido una evolución mayor durantre el siglo 20 debido a los avances en losofía del lenguaje, en especial los relacionados con los actos del habla speech acts en inglés y formas deónticas de la lógica modal. Aunque hay una gran variedad de deniciones y terminología asociadas al concepto de norma, y por ello existen varios puntos de vista sobre como analizar su impacto, el denominador común es que las normas restringen el comportamiento de grupos de agentes de forma que cada agente individual puede construir, con un buen nivel de conanza, expectativas sobre como cada uno de los otros actores se comportará en las situaciones que las normas han de cubrir. Por ejemplo, en una carretera cada conductor espera que los demás conduzcan solo en un lado de la carretera (derecha o izquierda, dependiendo del pais). Por lo tanto, los contextos normativos, normalmente envueltos en la forma de instituciones, constituyen mecanismos efectivos para asegurar la estabilidad de un sistema complejo como una organización, una sociedad o incluso un sistema electrónico. Lo último ha sido objeto de estudio en el campo de la Inteligencia Articial, y se ha visto como paradigma de coordinación entre agentes electrónicos, tanto en sistemas multiagentes como en arquitecturas orientadas a servicios. Para aplicar normas en sistemas electrónicos, los investigadores han creado abstracciones de sistemas normativos. En algunos casos estas abstracciones se basan en sistemas regimentados con deniciones exibles del concepto de norma para poder incluir algunos signicados del concepto con un menor nivel de granularidad formal como es el xxiii
xxiv Resumen caso de las convenciones. Otras aproximaciones proponen el uso de lógica deóntica para describir, desde un punto de vista más teórico, entornos de interacción gobernados por normas. En ambos casos el propósito es el permitir la monitorización y la aplicación de las normas en sistemas que incluyen aunque no están limitados a agentes electrónicos. En el presente documento nos centraremos en el segundo tipo, teniendo cuidado en mantener el aspecto deóntico de las normas. La monitorización en sistemas gobernados por normas requiere el hacer a los agentes conscientes de: 1) cual es su contexto normativo, es decir, que obligaciones permisos y prohibiciones se aplican a cada uno de ellos y cómo se actualizan y activan; y 2) cual es su estado normativo actual, esto es, que normas están activas, y que instancias están siendo cumplidas o violadas, en denitiva, cual es su realidad social o institucional. En la actualidad el reto consiste en diseñar sistemas que permiten inferir a componentes computacionales tanto el contexto normativo como la realidad social en tiempo real, basándose en un formalismo teórico que haga que dichas inferencias sean correctas y bien fundamentadas desde el punto de vista losóco. En el ámbito de los sistemas multiagente existen muchas aproximaciones propuestas e implementadas que cubren estos requisitos. Sin embargo, esta literatura aun carece de una propuesta que sea adecuada para la tecnología de las arquitecturas orientadas a servicios, que están más centradas en amalgamas políglotas y escalables de servicios ligeros con mecanismos de coordinación y comunicación extremadamente simples, una tendencia moderna que lleva el nombre de microservicios. Esta tesis aborda esta problemática 1) estudiando que propiedades podemos inferir de los sistemas distribuidos que nos permitan tratarlos como parte de un sistema sociotécnico, y 2) analizando que mecanismos podemos proporcionar a los sistemas distribuidos de forma que puedan actuar de forma correcta como sistemas socio-técnicos. El producto principal de la tesis es, por tanto, una colección de elementos computacionales requeridos para la monitorización e interpretación ecientes en tiempo real y con clara base formal. En concreto: 1. Una ontología de eventos para modelar adecuadamente las entradas del mundo exterior y convertirlas en hechos básicos o en eventos institucionales; 2. Un lenguaje de normas ligero y sencillo, adecuado para su uso en arquitecturas orientadas a servicios; 3. Un formalismo especialmente adaptado para la detección de la realidad social, basado en y reducible a lógica deóntica con soporte para normas constitutivas; 4. Una reducción de ese formalismo a sistemas de reglas de producción; y 5. Una o más implementaciones de esta reducción, de las que se ha probado que funcionan ecientemente en distintos escenarios. Este documento presenta el estado del arte relacionado, la justicación y el diseño/implementación para cada uno de esos elementos. Al combinarlos, somos capaces de presentar trabajo novedoso y relevante que permite la aplicación de mecanismos
xxv de razonamiento normativo en sistemas del mundo real bajo la forma de un razonador práctico. De especial relevancia es el hecho de que el trabajo presentado en este documento simplica formas complejas y teóricas de razonamento perservando la correctitud formal. El uso de sistemas de reglas de producción como la materialización a nivel de implementación del monitoreo normativo permite que nuestro trabajo se pueda aplicar a cualquier lenguaje o plataforma disponible, ya sea en la forma de motores de reglas, reglas ECA o incluso patrones si-entonces. El trabajo presentado ha sido probado y usado con éxito en un amplio rango de dominios y aplicaciones prácticas. La tesis describe como nuestros mecanismos se han aplicado a casos prácticos de uso basados en su integración en la gestión distribuida de pacientes de edad avanzada o en el sector de los videojuegos comerciales.
xxxii Introduction money really means for us? A bank note is, physically, no less and no more, a piece of paper with some drawings and some writing. However, with a bank note we are granted the possibility of taking things from shops up to a certain value. Therefore, a bank note is interpreted by society as granting a certain power, in other words, it is commonly accepted that it has a meaning that is deontic in nature. Interestingly, electronic money, which is virtual rather than physical, due to temporarily having no physical grounding, receives the same treatment. In summary, society can grant deontic powers to physical or abstract objects. Money has its own rules, accepted by society. Once it is accepted that something counts as money, many dispositions and rules of play come into action. One can take something in exchange of money, lend it to other people, and so on. That is, a set of norms apply to people that have money. With a set of norms, it can be said that there is an institution. Even if money changes, such as the conversion from Pesetas to Euros, or if new types of money are introduced, as electronic money in its moment, the basic norms that apply to money tend to persist. Society handles, and in fact is continuously founded and evolving on top of, a vast amount of institutions: money, marriage, academia, language, and so on, and in order to understand social reality, we need to interpret human interaction in the context of these institutions. Institutions are social mechanisms supported by norms that constraint the behaviour of the individuals belonging to them. Usually, these norms are created as a means to provide welfare to these individuals. Sometimes they work as they should, most of the times they do not, but their objective is to minimise conicts, to reduce uncertainty, to force some predictability and provide safety on the interactions between people. As small as a family or as large as a country, an institution causes relevant eects on the individuals and even on other institutions. A person might be happy to belong to it, or be prosperous taking prot of the opportunities it provides. On the other side, a person might cause damage while defending it, or be a victim of its power. Institutions are part of our everyday life, giving shape to societies and playing a main role in the progress of humanity. In short, we are all aected by them and, at the same time, we all try to get prot of belonging to them, even at the expense of the actual institutional objectives. Sometimes we even try to change them. Institutions are also the building block on top of which organizations are built. Organizations, which are social structures enabling roles to be enacted and objectives to be followed, use the mechanisms provided by institutions in order to function correctly. Organizations have no success guaranteed by denition, no matter how well the institutional rules of the game are designed, or how well the participants of the organization t its roles, or how simple or easy are the organizational objectives. Governance mechanisms are always desirable, as a means to audit the performance of the organization. The process of governance involves dealing with practices and methodologies that seek for a better control and management over the life-cycle of an organization in order to optimise the outcomes of its participants. Usually, governance is implemented by
xxxiii enforcement of the organizational rules, including institutional norms and subsequent analysis of the performance against predened metrics. That is, if the members of the organization can rely on the tness of the rules to full the objectives, then we can say that they have the responsibility for these rules to be observed for both collective and individual benet. When rules are observed, governance brings about the stability, predictability that makes participants trust institutional mechanisms on their own benet. Enforcement and observance are, therefore, two critical processes of organizations and, by extension, societies. It can be the case and, as said before, it is more common than not, that norms are not really optimal from a collective or individual point of view. But norms can be improved, and if we are to suppose that norms are set in good faith, then consequently both enforcement and observance have to be prepared and executed. Both concepts are, in fact, quite intertwined. There can be no observance without enforcement, as rules that cannot be put in order, there is no way to check their compliance. Moreover, there can be no enforcement without observance, as rules that cannot be checked will not be able to guarantee trust between participants. And now we are in disposition to close the circle that began with apparently extraneous topics such as interpretation and common understanding of symbol and object meanings. In order for a rule to be observed, we need to have the proper apparatus to understand how things that are, things that happen, and things that are produced by participants, mean something that is relevant for a particular rule. This dissertation, built on top of theoretical concepts related to electronic institutions, develops formal artifacts, and their reduction to software components, that enable distributed systems, in the broad sense of the term, to understand norms and in consequence process the physical reality in order to perceive social reality in real-time. This is a necessary but not sucient condition for a software component to interpret their role in society1and, reciprocally, let others see the electronic system as a role enactor in their society. All these concepts that have appeared in this discourse will be properly discussed in Part I. In the next section, we will present which are the research questions that this document will try to tackle, and in order to do that we will base such research questions on the theoretical background that we have just presented. In summary: we have seen that there are social mechanisms that allow for assigning meanings to physical or virtual objects or actions that are commonly understood; that these meanings can involve deontic notions and as such they can be the building blocks of institutions through the establishment of norms; that groups of people can use the mechanism offered by institutions to create organizations with common objectives; that governance is a desirable feature of such organizations, involving enforcement and observance; and that in order to have observance, we need to understand the social mechanisms that give institutional meaning to what happens in reality. 1From now on we will use the term society to refer to a kind of socio-technical society composed by humans and articial entities, as described in [Kolp and Wautelet 2011]. And we will use the term sociotechnical system or STS to refer to the joint of the social and technical dimensions in such societies.
xxxiv Introduction Research questions As discussed in the previous section, the objective of this thesis is to provide mechanisms to distributed systems to enable the perception of social reality from inputs coming from physical reality. A rst concern on this respect is, therefore, to identify what kind of electronic systems should, and which are able to, integrate such mechanisms: Research Question 1 What properties can we infer from individuals in distributed systems that allow us to treat them as part of a socio-technical system? An answer to this will help us categorise the elements of a distributed system. From this, the question is: Research Question 2 What mechanisms can we provide to distributed systems so that they can properly act as socio-technical systems? This last question will produce a list of formal and practical components that will be the core of our contributions. Methodology and contributions One of our main assumptions is considering a broad meaning of the term distributed system. Our objective is to include not only intelligent agents, which are usually the computational element used in similar research, but also service-oriented architectures and even the current trend of microservices. By the study of the properties of such systems with respect to agency, we choose norms and institutions as the proper abstraction to apply. Our objective along the document will be to create a computer-readable language based on norms to those used by humans. This will be our rst contribution, and it will allow our electronic systems to work with a vocabulary capable of interpreting their social reality. However, detection of social reality is not trivial due to its dependence on logic formalisms such as deontic logics. We will propose a reduction from complex logics to rules of production systems, reducing such complexity at the same time that we will be able to inject those rules in as many programming languages as possible, as we are targetting services. The nal contribution of this thesis will be a monitor capable of discovering the social reality of an agent in a distributed system. This contribution will build upon our previous contributions: language and formal reduction. Our proposal is that the adoption of this kind of components to process social reality can bring about a wide range of applications that benet from institutional abstractions.
Structure of this document xxxv Structure of this document This document is divided in three major parts. The rst one includes the theoretical grounding of the conceptual background on top of which the rest of document is built upon, and is enclosed in Part I.Chapter 1 distinguishes between the possible implementations of distributed systems. These implementations are analysed form an agency perspective in Chapter 2 and we propose norms as an abstraction of individual constraint for distributed systems participants. Then we analyse the use of systems based in norms for collective constraints in Chapter 3. The central part, Part II contains our contributions. These are a lightweight language for norms for computational components (Chapter 5), operational semantics for this language (Chapter 6), and a translation from these operational semantics to practical implementations (Chapter 7). Finally, in Part III we wrap things up. First, we study the relationship between our contributions and enforcement mechanisms (Chapter 8), we demonstrate a practical use case to demonstrate our contributions based on their integration in commercial games (Chapter 9), and we end up with general conclusions (Chapter 10).
part i STATE OF THE ART
CHAPTER 1 Computation as interaction He'd understood then why Wintermute had chosen the nest to represent it, but he'd felt no revulsion. [...] Wintermute was hive mind, decision maker, eecting change in the world outside. Neuromancer William Gibson Nowadays, communication over the Internet is of utmost relevance, not only for human-to-human interaction, but also between individuals and businesses. In both cases, the use of servers that act with variable degrees of automation and autonomy have become pervasive: banking, shopping, education, public administrations, and so on. Therefore, computation in many areas of interest has evolved from mere mechanisms for data storage and processing and information retrieval into semi-automated networks of computers. This new metaphor has received the name of computation as interaction [Luck et al. 2005]. In this paradigm of computation, computing becomes a social activity. Social in the sense that the results of such computing are the result of a joint action between several agents human agents or software agents. Investigating about what an agent is and is not, and what to be an agent implies in terms of the relationship to other agents, is very important in order to explore both how social reality can be established on top of distributed computational architectures and how governance mechanisms can be introduced in order to ensure an acceptable level of social order. In this chapter, we will discuss about the concept of agency, which will allow us to understand the individual components of such social activities, and we will explore dierent types of architecture that have been used to materialise this computation as interaction paradigm as software distributed systems. 3
4Chapter 1. Computation as interaction 1.1 Agency and agents: distributed systems What constitutes an agent? Is an agent pressupossed to have free will? Is an agent merely any rational being? Is it desirable to control or constrain the freedom of other agents? It is easy to see that agency is a concept that is related to many branches of philosophy, such as moral or metaphysics, and therefore it has been the subject of much debate since Plato and Aristotle. In our case, we are more interested in a purely analytical denition, because our focus is on governance systems in which we assume the existence of norms that are not, or at least should not be, aected by moral implications. Such a denition can be found in [Davidson 1971]: a person is an agent of an event if and only if there is a description of what he did that makes true a sentence that says he did it intentionally. An agent is exercising agency, thus, if and only if the instantiation of certain mental states and events (beliefs, desires, intention) are able to produce the right (possibly physical) events, generally in the form of a chain of causal relations [Davidson 2002]. If agency is related to mental states, does that mean that agency is restricted to humans (and animals) or it can be applied to articial systems as well? If so, can we consider that articial systems can have mental states? These are fairly contentious and still open topics of discussion, but some researchers have empirically shown that agency does not necesarily entail conciousness [Bargh et al. 2001]. Furthermore, [Dennett 1989], following an instrumentalist perspective and turning the question upside down, argues that predictive patterns of behaviour supporting complex goals inevitably indicate the existence of mental states, because such existence cannot be separated from the existence of agency. These arguments support the idea of articial systems capable of agency. An example of formalisation of this concept is the Belief-Desire-Intention (BDI) agent [Rao and George 1995]: a non-physical system, grounded on multi-modal logic, that is capable of storing and transforming information, motivational and deliberative states (mental attitudes) and with the capability to act by selecting and executing appropriate actions or procedures in order to achieve goals. BDI agents are not the only articial systems that have this capability of acting. Nowadays Internet is immersed in a myriad of countless web-services and application programming interfaces (APIs) that not only digest and provide information but also trigger complex actions and processes that have physical implications (e.g. online shopping), from simple inputs. We will assume in this dissertation, following the thesis in [Dennett 1989], that web-services and APIs are capable of agency, at least at the same level as BDI agents. All agents, be them humans (animals) or articial systems, are rarely isolated. Almost no agent is self-sucient and generally agents must communicate and coordinate among themselves in order to full individual or collective objectives. This is true for humans as well as for articial systems, although it is important to note that articial systems are built in a coordinated (thus distributed) fashion, in virtually every case, to produce information or functionality to a human end-user: computation as interaction.
1.2. Agent orientation and Multi-agent systems 5 In the following sections we will discuss several relevant abstractions of coordination structures that have been created in order to full this paradigm. 1.2 Agent orientation and Multi-agent systems Agent-oriented computing appeared in the early 90s with the notion of an intelligent agent as the proposal of a key foundation for distributed systems. An intelligent agent is, in this context and explained briey, an autonomous entity realised as a software component, capable of making its own proactive decisions with no external control, as well as capable of processing and reacting to perceptions from the environment [Wooldridge and Jennings 1995]. Intelligent agents are also able to communicate with other agents to share information and to coordinate join actions in order to achieve complex goals. A group of agents that interact among themselves to manage their goal or task dependencies, sometimes sharing some common objectives is called Multiagent System (MAS). All these attributes suggest that multi-agent systems are well-suited to solve complex problems where coordination among several entities is valuable in order to nd an optimal or near to optimal solution with limited time and bounded computational resources. Intelligent agents may also exhibit other useful attributes such as learning, rationality, mobility, benevolence and veracity. Examples of Multi-agent frameworks are (but are not limited to): JADE [Bellifemine, Poggi, and Rimassa 2001], Jack [Winiko 2005], 2-APL [Dastani 2008], Jason and AgentSpeak [Bordini and Hübner 2005]. Research on MAS has been mainly academic, and therefore intelligent agents have been generally designed with strong formal groundings, i.e. multi-modal logic-based reasoning, communication based on philosophy of language, coordination mechanisms based on organisational theory. These attributes make MAS capable of distributing work in an adaptive way, allowing in some cases dynamic re-organisation. Thanks to this, MAS gained commercial success in many elds of information technology, from computer networking to decision support systems [Luck et al. 2005]. More specically, there are three features that are of special relevance to analyse the benets of MAS when building distributed systems: speech act theory, communication languages, and interaction protocols. The following subsections briey explain them. 1.2.1 Speech Act Theory Speech Act Theory is the area of the philosophy of language that studies the pragmatics1 of the dierent types of messages that two agents can exchange [Searle 1969]. This theory proposes that certain uses of language can create acts that have an inuence in the external world: saying does something [Austin 1975]. For example, if a person says that he promises to do something, the actual saying is the promising. In saying, he is committing to a promise. In this context, promising is a performative utterance, distinguished from other kinds of utterances as for example 1The study of how language is used by people in order to achieve their intentions.
12 Chapter 2. Norms 2.1 Types of norms There is no consensus on how to categorise norms, although it is accepted that norms, as an abstract concept, inuence the behaviour of rational agents. This inuence can depend on how the norms are promulgated, enforced, or whether the norms explicitly relate to an end or otherwise the norm is created as an end by itself. With respect to these issues, [Elster 1989] makes a distinction between three types of norms: •Social norms: they are not outcome oriented and tend to be enforced by individual feelings towards the other agents, and thus not necessarily benet the participants, e.g. it is customary to salute people when arriving to the oce. •Moral norms: they are consequentialist, i.e. an act is morally right if and only if that act maximises the global good, where good is a moral concept rather than an economic or functional optimal, e.g. you should not commit adultery. •Legal norms: enforced by specialists out of self-interest it is their job, e.g. it is obliged to drive on the right lane of the road whenever possible. Social norms (also called conventions, private norms or informal norms) are an interesting phenomenon: because they are not outcome oriented, they are not entirely rational from an individual perspective. They are generally unconditional, and in those cases when they are not, they are not future-oriented (due to the lack of a goal). In fact, in order to become social, a norm must be shared and sustained by approval and disapproval, and therefore a social norm is an end in itself. It might seem from this denition that social norms cannot be the foundation of a society, but they are indeed. They allow the developing of mechanisms of reciprocity and cooperation [Bicchieri 2006], because their acceptance gives shape to groups of agents distinctive to others and allows collective behaviour patterns to emerge in those gaps where the other types of norm moral, legal cannot reach. Moral and legal norms share the fact that they are outcome-oriented, and therefore following them or not requires individual rationality. The dierence between both, according to [Elster 1989], is the motivation of the enforcer: legal norms are enforced by people who would lose their job otherwise. However, this distinction is not entirely clear [Posner 2009] for example, does the Bible promulgate legal or moral norms? After all, the Catholic Church is an institution that has enforced such norms for many years and we could argue that such enforcement involved self-interested agents in many cases. On the other hand, moral norms require moral agents: consequentialism can only be understood and accepted by agents that can reason about the ends from an individual perspective. This is not the case with articial systems (at least, for now), because these have usually predened or pre-programmed goals. This very much seems clear: in both cases, enforcing norms requires the use of language in order to communicate them due to the fact that they deal with ontological concepts that are not necessarily physical. This is a distinction with respect to social norms, as it is proven that they can appear merely by means of observation between similar agents [Bicchieri 2006].
2.1. Types of norms 13 As formulated in Research Question 2, our objective is to produce computational elements that enable individual elements in distributed systems as rst-class members of socio-technical systems. In this context, it seems t to understand that the norms aected by such systems are closer to what [Elster 1989] categorises as legal norms: outcome-oriented towards an external goal, written in some kind of language and enforced by specialists. In order to simplify, from now on we will simply refer to this type as norm. Independently of this distinction of norms based on their outcome and enforcement, [Searle 2009] argues, following Speech Act Theory, that norms (called rules in this book), due to their performative value, are used by agents to eectively create social reality, that is, socially accepted facts that are ontologically subjective (their existence depends on the mental states of a rational agent) but epistemically objective (they are agreed upon by a collective of agents). As mechanisms to create this social reality, Searle identies two types of norms (called rules in this book): •Constitutive rules: they declare institutional (social) facts from brute facts which are ontologically objective or from other institutional facts. •Regulative rules: they declare constraints on the behaviour of agents with respect to their relationship with institutional facts. A constitutive rule typically has the form: X Counts as Y in C where X is a brute or institutional fact, Y is the institutional fact being created, and C is a normative context. An example of constitutive rule in action is two people considered as married (institutional fact) because they were declared as such by a person who had the power to do so. An example of regulative rule related to this institutional fact is for example that the married couple are in the mutual obligation of declaring taxes together (in some countries and/or regions). In summary, regulative rules can be seen as describing ideal situations from an institutional perspective in terms of obligations, prohibitions and permissions; whereas constitutive rules allow to construct social reality by expliciting the relationship between brute facts and institutional events. The main dierence between both types of norms is that while constitutive rules, by their very nature, are categorical, regulative rules are conditional, in the sense that they specify every applicable condition of each particular norm[Boella and Torre 2004]. In some works it has been proposed to consider a third kind of norm regimented norms [Torre et al. 2004]. These are considered hard constraints as opposed to regulative and constitutive, which are soft constraints. In this context, a hard constraint cannot be avoided, i.e. the norm is enforced by imposing a restrictive environment, whereas soft contraints can be violated, i.e. not accepting a declaration or not fullling an obligation.
14 Chapter 2. Norms In distributed systems, regimented norms already exist in the form of implementation decisions that directly or indirectly create those contraints (by design). We are more interested on the aspects of soft constraints, especially in distributed systems where the internal specications of services are usually hidden from other parties. 2.2 Representing norms In the previous section we have explored the concept of norm from a theoretical point of view, i.e. what kinds of norms we can encounter. A dierent topic, however, is how to give shape to norms. In this section, we describe the most relevant ways to describe norms in governed distributed systems1in the chronological order in which they were proposed. 2.2.1 Deontic logic Although primitive cultures had no written laws, they shared morals and conventions that were followed by the individuals. These informal norms evolved into explicit written laws developed by subsequent cultures. Two examples of these formal norms are Roman Law and Common Law. Roman Law emerged after some attempts of expressing morals and conventions, e.g. the code of Hammurabi, and is the base for the legal systems of most of the european countries that were part of the Roman Empire, the ones that were linked to them by monarchic marriages, as well as their colonies. In most of these countries the normative system is hierarchical: constitution,laws, and regulations.2 Roman Law denes two kinds of constraint sets: •Normatives or Laws: sets of norms that dene WHAT can be done by WHO and WHEN. A constitution is the highest law in a state. •Regulations: sets of rules that expand a given normative dening HOW it may be applied. In legal theory, norms are always expressed in natural language. That makes them ambiguous and hard to deal with in computational systems. To solve this gap, Mally intended to create an exact system of pure ethics to formalize legal and normative reasoning. That was the rst attempt at creating a Deontic Logic [Lokhorst 1999], based on the classical propositional calculus. Von Wright [Wright 1951] presented a formalism based on propositional calculus that was similar to a normal modal logic. Adapting Von Wright's proposal, the Standard System of Deontic Logic or KD was created as a modal logic with the following axioms: 1This discards some mechanisms, such as game theory, that are more suited for theoretical or simulated use cases. 2Some countries, like the United Kingdom, have their laws based on Common Law. As opposed to Roman Law, Common Law is composed by an aggregation of past decisions, which are used as a base for future decisions, in a case-based approach. Therefore, there is no constitution nor a layered system of norms.
2.2. Representing norms 15 O(p→q)→(O(p)→O(q)) (KD1 or K-axiom) O(p)→P(p) (KD2 or D-axiom) P(p)≡ ¬O(¬p) (KD3) F(p)≡ ¬P(p) (KD4) p, p →q`q(KD5 or Modus Ponens) p`O(p) (KD6 or O-necessitation) where O,Pand Fare modal operators for obligation,permission and prohibition. Thus Deontic Logic allows for expressing a norm as the obligations, permissions, and prohibitions that an entity has towards another entity. Verbs such as should or ought can be expressed as modalities: it should happen p",it ought to be p". The semantics of the O,Pand Foperators dene, for a normative system and in terms of possible worlds, which situations are ideal. In fact, Deontic Logic is not a logic of norms, but a logic of propositions stating the existence of norms [McNamara and Prakken 1999]. However, this makes them suitable for implementing regulative rules as dened in Section 2.1. Although there have been recent attempts to make regulative rules concrete by the reduction to constitutive rules [Aldewereld et al. 2010b], in general regulative norms based on deontic statements have been the most common way to represent normative constraints in multi-agent systems. In such systems, thus, norms are expressed as computer-readable specications based on deontic logics. However, operationalisation of such norms is not straightforward. As already mentioned, deontic statements express the existence of norms, rather than the consequences of following (or not following) them [Walter 1996]. In order to implement agents and institutional frameworks capable of reasoning about norms, we need to complement deontic logics with semantics dening fulllment and violation among other operational normative concepts. Standard Deontic Logic or KD [Meyer and Wieringa 1991] is expressive enough to analyse how obligations follow each other and is useful to nd possible paradoxes in the reasoning. However, the KD system can hardly be used from a more operational approach in order to, e.g., decide which is the next action to be performed, as it has no operational semantics. One interesting extension of KD Deontic Logic is the Dyadic Deontic Logic, proposed by Von Wright, which introduces conditional obligations with expressions such as O(p|q)(p is obligatory when condition q holds"). There are also specic logics to address temporal aspects, as the Temporal Deontic Logic. For instance, O(p<q) states that p is obligatory before condition q holds". Another option is combining deontic operators with Dynamic Logic: [p]O(q) means after p is performed it is obligatory q". Some researchers have enhanced deontic logic by adding the action modal operators E,G,H. Operator Ecomes from Kanger-Lindahl-Pörn logical theory [Kanger and
16 Chapter 2. Norms Stenlund 1974; Lindahl 2001; Pörn 1974], and allows to express direct and successful operations: EiAmeans that an agent ibrings it about that A(i.e., agent imakes A to happen and is directly involved in such achievement). Operators Gand Hwere introduced later by Santos, Jones and Carmo to model indirect actions [Santos and Carmo 1996; Santos, Jones, and Carmo 1997]. Thus, the modal operator Gallows to express indirect but successful operations: GiAmeans that an agent iensures that A(but not necessarily is involved in such achievement). The operator Hexpresses attempted (and not necessarily successful) operations: HiAmeans that an agent iattempts to make it the case that A. Examples of work on deontic logic to materialise norms are abundant and for many dierent purposes, i.e., compliance [Alvarez-Napagao et al. 2011; Cardoso and Oliveira 2009; Criado et al. 2010; García-Camino et al. 2006; Governatori and Rotolo 2010; Oren et al. 2009], verication [Ågotnes, Hoek, and Wooldridge 2010; Koo 2008; Lomuscio, Qu, and Raimondi 2009; Prisacariu and Schneider 2009], or agent behaviour [Aldewereld et al. 2005; Kollingbaum 2005; López, Luck, and d'Inverno 2004; Meneguzzi and Luck 2009; Panagiotidi and Vázquez-Salceda 2011]. While it is true that most of them dene semantics to interpret norms, there seems to be a disconnection between such semantics and either 1) the deontic logics they are supposed to be based upon; or 2) the operational level closer to the actual practical implementation. For instance, [Governatori and Rotolo 2010] denes a norm-operationalization language that can be connected with higher level abstractions, but it is not clear whether it can be translated into generic rule-based languages. [García-Camino et al. 2006] presents a rule-based language with constraints, with an implementation on Prolog, on top of which other higher-level languages can be formalised, but with no direct relationship to deontic logics. On this line of work, approaches such as [López, Luck, and d'Inverno 2004; Oren et al. 2009] dene clear operational semantics by the use of syntax loosely inspired by, but not directly related to, deontic statements. In [Aldewereld 2007], Aldewereld extends the ideas of [Vázquez-Salceda 2004] by applying parts of the methodology to highly-regulated environments (environments governed by lots of complex norms). The author formalises the implementation of norms from an institutional point of view. He denes the abstract norm, and extends this formalism to the norm frame needed for the representation of concrete norms. More specically he uses an linear-time temporal logic, based on temporal logic which he extends with deontic operators to express the obligations, permissions and prohibitions that are in the norms. He then introduces the operational constraints by which they implement the norm frame to obtain the normative institutions. The author then proceeds to specify (formal) methods for the implementation of norm enforcement and the (automatic) creation of protocols (based on constraints specied by the norms). What is somehow missing in general in the literature is a clear separation between what an abstract norm and a particular (contextual) instantiation of the norm. This problem was already discussed by Abrahams and Bacon in [Abrahams and Bacon 2002]: since propositions about norms are derived from the norms themselves, invalid or misleading in-
2.2. Representing norms 17 ferences will result if we deal merely with the propositions rather than with the identied norms3 that make those propositions true or false. This issue is not banal, as it has implications on the operational level: in order to properly check norm compliance, norm instantiations have to be tracked in an individual manner, case by case. We nd useful, at this point, to stress the fact that the lifecycles of a norm, and of a norm instance, should be dierentiated because they are dierent in essence. The lifecycle of a norm (see Figure 6.3) deals with its validity in the normative system, while the lifecycle of a norm instance (see Figure 2.2) deals with the fulllment/violation of the particular instance. Figure 2.1: Norm lifecycle § Figure 2.2: Norm instance lifecycle § Abrahams and Bacon [Abrahams and Bacon 2002] solve this problem by means of occurrences of the predicates contained in the deontic operator, but there are cases in which this can be insucient, e.g., when the obligation denes a deadline or its instantiation depends on contextual information. More recently, some works have been advancing in the direction of tackling this issue. For example, by treating instantiated deontic statements as rst-class objects of a rule-based language [Cardoso and Oliveira 3From now on, we will denote such identied norms as norm instances.
18 Chapter 2. Norms 2009; Governatori 2005]. However, as these deontic statements are already implicitly identifying the norm instance, there is no explicit tracking. Other approaches declare the norm only at the abstract level and the tracking of the norm instance, and implicitly of the norm instance lifecycle, is purely done at the operational level [Alvarez-Napagao et al. 2011; Criado et al. 2010; Modgil et al. 2015; Oren et al. 2009]. In summary, there are many approaches that tackle dierent parts of the formalization of norm operationalization. One of the purposes of our work will be, thus, to complement these approaches by lling the gaps that exist between the deontic statements and other suitable more simpler operationalisations, with special focus on norm instances. Therefore, while it is true that deontic logics provide a level of expressivity that is ideal, being somehow close to what is used in human language for norms, its complexity has proven dicult to deal with in practical systems. These limitations may impact directly or indirectly on important factors in distributed systems, esp. regarding real-time performance and scalability. We keep exploring options based on simpler formalisms in the following subsections. 2.2.2 Production systems Event-Condition-Action (ECA) rules were rst dened in the context of database management systems [McCarthy et al. 1989] and are the simplest form of rule possible. Such rules are rst-class objects of a language, with clear semantics: when an event occurs, the condition of each rule is evaluated; if the condition is satised for a particular rule, its action is executed. Therefore, they have the same expressivity and complexity of a typical if-then-else branching in a programming language, but targetting a virtually innite stream of input events. Because of their simplicity, they have been applied in almost every domain of practical applications. Many libraries and frameworks implement mechanisms for ecient execution of ECA rules systems. These are commonly referred to as rule engines or production systems. In this thesis we will use as a reference the semantics for production systems proposed in [Cirstea et al. 2008], summarised in the following paragraphs. Considering a set Pof predicate symbols, and an innite set of variables X, where a fact is a ground term, f∈ T (P), and WM is the working memory, a set of facts, a production rule is denoted if p,cremove radd a, or p,c⇒r,a, consisting of the following components: •A set of positive or negative patterns p=p+∪p−where a pattern is a term pi∈ T (F,X)and a negated pattern is denoted ¬pi.p−is the set of all negated patterns and p+is the set of the remaining patterns •A proposition cwhose set of free variables is a subset of the pattern variables: V ar(c)⊆V ar(p).
2.2. Representing norms 19 •A set rof terms whose instances could be intuitively considered as intended to be removed from the working memory when the rule is red, r={ri}i∈Ir, where V ar(r)⊆V ar(p+). •A set aof terms whose instances could be intuitively considered as intended to be added to the working memory when the rule is red, a={ai}i∈Ia, where V ar(a)⊆V ar(p). Denition 1 A set of positive patterns p+matches to a set of facts Sand a substitution σi ∀p∈p+,∃t∈ S, σ(p) = t. Similarly, a set of negative patterns p−dismatches a set of facts S i ∀¬p∈p−,∀t∈ S,∀σ, σ(p)6=t. A production rule p⇒r, a is (σ, WM0)-reable on a working memory WM when p+ matches with WM0and p−dismatches with WM, where WM0is a minimal subset of WM, and T |=σ(c).2 Denition 2 The application of a (σ, WM0)-reable rule on a working memory WM leads to the new working memory WM00 = (WM − σ(r)) ∪σ(a).2 Denition 3 A general production system PS is dened as PS =hP,WM0,Ri, where Ris a set of production rules over H=hP,Xi.2 These semantics allow us to treat production systems, which lack a high level of expressivity, as a theoretical framework in top of which we can reduce formalisms that involve more complex rules. 2.2.3 Service-level agreements The concrete approaches used for enforcement in SOA are based on Service-Level Agreements (SLA). A SLA is a formal negotiated agreement between a service provider and his customer. When a customer orders a service from a provider, an SLA is negotiated and then a contract is drawn up. The service provider must perform a SLA monitoring in order to verify whether the Quality of Service (QoS) parameters speci- ed in the SLA contract are respected. The SLA monitoring involves monitoring the performance status of the oered service and provides relevant information to the service level management system. Then, the system management assesses the provider's commitments and applies penalties if those commitments were not met. In order to dene such providers' commitments, a lot of specication work was carried out dening several XML based languages enabled to describe the contract between the service provider, his customer and a possible third party. These languages were dened closely to the common language allowing a common understanding of the service provider commitments to perform a service according to agreed guarantees. Several initiatives have been dened, and all of them are a complement to the service description implemented by WSDL. One of the best known is Cremona [Ludwig, Dan, and Kearney 2004], a SLA middleware complementing the basic Web Services stack. Cremona helps providers to read, manage agreement templates, implement the agreement protocol, check availability of
20 Chapter 2. Norms service capacity and monitor agreement states at runtime. Cremona's communication component handles various message types and message sequencing to form interaction protocols through the agent knowledge bases. In spite of that, the framework seems not to be competent on decision making based on the content of an agreement, job scheduling and resource management. Also, the monitoring components in Cremona do not provide support for agreement breaking. Finally, workow handling, which is essential when dealing with complex interactions between services, is not supported. The Web Service Level Agreement (WSLA) [Ludwig et al. 2003] is a framework targeted at dening and monitoring SLAs for Web Services [Keller and Ludwig 2003]. The general structure of an SLA in WSLA includes the involved parties, the SLA parameters, the metrics and algorithms to compute those parameters, the service level objectives (SLOs) and the actions to be taken if a violation has been detected. The WSLA Framework implementation is based on the IBM Web Services Toolkit and licensed as commercial software. Its main functionalities are the denition, negotiation, deployment, monitoring, and enforcement of SLAs. However, WSLA does not fully support multiple consumer/provider contracts, as these are signed by only two parties. Concerning partner responsibilities, it should be noted that dening them exclusively in terms of parameters and metrics is quite limiting, and there is no support for the denition of actions to be fullled. Finally, another very important issue is the lack of a generic, exible and automatically executable mechanism for corrective management actions. In the case of WS-Agreement [Andrieux et al. 2005], the general structure of agreements consists of the description of the context in which the agreement is established, the service itself and the guarantee terms. The WS-Agreement specication is less focused on the description of the related activities that should be choreographed but on the denition of the commitments and penalties.4WS-Agreement is quite often used with the conversation denition language WSCL [Banerji et al. 2002]. The WSCL/WS- Agreement over IBM's ETTK is the reference (but partial) implementation of these specications. It is built on top of Cremona and extends it by using WS-Agreement templates, richer message types, and XML-based interaction protocols. However, a WS-Agreement-based framework has quite some limitations: it does not include the specication of third parties working in the management of contracts, and no metrics are dened in order to support exible monitoring implementations over the Web service choreographies. PANDA [Bougiouklis 2008] was a project developing technology for the negotiation, monitoring and evaluation of contracts in supply-chains of producers in modular distributed Enterprise Resource Planning (ERP) systems. The infrastructure combined centralised Web service-based components (catalogue of partner proles, SLA templates storage, etc.) with distributed peer-to-peer components implemented using JADE multi-agent platform. PANDA was an attempt to connect, at a high level, Service Level Agreements and Multi-Agent Systems, focusing on semi-automated ne- 4WS-Agreement is the only specication of those under study that includes the explicit declaration of penalties, but they consist only of sets of actions.
2.3. Summary to this chapter 21 gotiation and oine monitoring of contracts, and including interesting features such as matchmaking, negotiation, and Virtual Organisation (VO) evaluation. The main issue concerning PANDA for its use in a generic contracting architecture was that its main focus was in the domain of ERP-solutions and not domain-independent. Many event-driven (ECAs) Web standards have been developed, with particular emphasis on reactive RuleML languages and their SLAs-tailored variant, namely RBSLA (Rule-based Service Level Agreements) [Paschke 2005]. However, RBSLA does not explicitly adopt the Web service-technology. Standard generic rule and inference engines such as Mandarax [Dietrich 2005], based on RuleML [Boley 2006], and Prova [Kozlenkov and Schroeder 2004] have been developed to execute and manage contracts designed in RBSLA. Prova, in specic, supports complex reaction rule-based workows, rule-based complex event processing, distributed inference services, rule interchange, rule-based decision logic and dynamic access to external data sources, web-based services and Java APIs. Nevertheless, both frameworks have an object oriented aspect, concentrate on the support of inference and reasoning engines, do not provide direct support for contracting procedures between agents and operate on a declarative rather than deontic level. Each of these existing pieces of work provide a dierent perspective on contracts and Web services, but still tackle the problem from a particular perspective such as language (RBSLA), negotiation (Cremona) or specication of the contract content (WSLA). 2.3 Summary to this chapter In this chapter, we have dened norms as proper mechanisms for describing behavioural constraints in the interactions between agents, as agency and normativity are intimately related concepts. Furthermore, we have identied types of norms depending on whether they are social, moral or legal, on one hand, and whether they are used to specify a vocabulary (constitutive) or to dene rules based on that vocabulary (regulative). The combination of constitutive and regulative norms eectively allows us, by denition, to design systems that have social reality as a rst-class citizen. Additionally, we have seen several forms of norm denition, at dierent levels of expressivity and originally designed to fulll disparate objectives: 1) Deontic Logic, very close to the expressivity of human norms, 2) Production Systems, simple rules matching conditions to produce actions, and 3) Service-Level Agreements, in the middle of the former two with regards to complexity and expressivity, and created with service-orientation as a target. Because deontic logics are usually too complex to be seamlessly translated into the implementation level of practical systems, and production systems are not expressive enough to capture the complexity of constraints usually written by humans, servicelevel agreement was at its time a fair attempt at dealing with this issue. However, as seen in Section 1.3, SOA-related proposals were gradually abandoned in favour of more ad hoc solutions, i.e. hardcoding orchestration and constraints in service implementation. For example, Amazon and Netix enforce an approach based on adding the constraints directly into the implementation of the services, making developers follow
28 Chapter 3. Normative systems and governance a predened library or interaction protocols allowed. Their norm language is suitable for regulative (not constitutive) rules, and although there are plans to integrate the norms as purely regulative, at the moment they are only used as regimented. The SMART agent architecture presented by d'Inverno and Luck [d'Inverno and Luck 2004] is based on an agent specication framework developed on top of the Z specication language [Spivey 1989]. This framework denes concepts such as objects, agents and autonomous agents2. This framework was extended by López y López, Luck and d'Inverno [López and Luck 2002; López, Luck, and d'Inverno 2001] by introducing representations of norms, which are not modelled as static constraints but as objects that can have several states: issued,active,modied,fullled or violated. These norms are related not only with the agents that should fulll or enforce them, but also with agents such as the one that issued the norm, the one that modied it or the ones that may be aected by a violation of the norm. However, there is no reported implementation of the architecture on a real use case. ISLANDER [Esteva, Padget, and Sierra 2002; Noriega 1997; Rodríguez-Aguilar 2003], later evolved to EIDE [Esteva et al. 2008], is a proposal that treats electronic institutions as a type of dialogical system where all the interactions inside the institution are a composition of multiple dialogic activities, that is, message exchanges. These interactions, called illocutions [Noriega 1997], are structured through agent group meetings called scenes that follow well-dened protocols. This division of all possible interactions in scenes allows for a modular design of the system. Another important element of ISLANDER is the notion of role: each agent can be associated to one or more roles, and these roles dene the scenes the agent can enter and the protocols it should follow. ISLANDER has been mainly used in e-commerce scenarios, and was used to model and implement an electronic Auction house, the Fishmarket. The resulting agent-mediated auction house was used, to compare dierent strategies of the trading agents [Cortés and Rodríguez-Aguilar 2000; Garcia et al. 1999; Matos and Sierra 1999]. Still, ISLANDER/EIDE presents some drawbacks in its application to complex domains such as distributed systems, due to its e-institution modelling in a low level of abstraction, by means of constraints on behavior modelled through very precise stepby-step communication protocols (performative structures, scenes, transitions), thus reducing the autonomy of the agents. InstAL [De Vos, Padget, and Satoh 2010] is a proposal for the specication of executable institutions by means of logic programming (Answer Set Programming). Firstclass elements include uents, events, obligations, and consequence relations. The specication of institutions in InstAL allow for constitutive rules, thus enabling the generation of institutional events such as violation events. As the specication is instantiated by the framework, the agents are virtual elements that are created by InstAL at runtime. Also, the operationalisation is based on the same language (ASP), and therefore there is no known way to reduce the semantics to external services in order to externalise processes such as monitoring or enforcement. 2Agents are dened as objects with goals, while autonomous agents are dened as objects with motivations.
3.2. Governance 29 Some approaches have been designed specically for the e-commerce and e-business elds, such as SMACE [Cardoso and Oliveira 2000] or the Contractual Agent Societies (CAS) [Dellarocas 2000]. In both cases the normative perspective is modelled by the use of contracts, which enforce agents to comply with the agreements they have done. However, these contracts only model agreements between parties, and do not cover those permissions, prohibitions or obligations that an e-organisation may need to de- ne in order to ensure an appropriate behavior of the society of agents. An evolution of SMACE is ANTE [Oliveira et al. 2014], a framework that improves over the former by adding a terminology layer, including vocabulary such as obligation, violation, deadline, violation or fulllment. The concept of institution is materialised in ANTE as a collection of services available for contracting, and contracts dynamically determine what an organisation is. However, in ANTE external entities are agentied into the system, that is, services must be wrapped in order to participate in the environment through the ANTE platform. 3.2 Governance According to the dictionary, governance can be dened as the action of conducting, inuencing, or regulating the policy, actions, and aairs of a state, an organisation, or a group a people. This can be done by constituting laws, rules, standards, or principles [Simpson and Weiner 2003]. Governance, in practice, is dened by Finkelstein [Finkelstein 1995] as systems of rule at all levels of human activity in which the pursuit of goals through the exercise of control has repercussions. Rosenau and Czempiel [Rosenau and Czempiel 1992] make a distinction between governance and government. Both refer to purposive behavior, to goal-oriented activities, and to systems of rule. But government suggests activities that are backed by formal authority, by police owners to insure the implementation of according constituted policies, whereas governance refers to activities backed by shared goals that may or may not derive from legal and formally prescribed responsibilities and that do not necessarily rely on police owners to overcome deance and attain compliance. Governance, in other words, is a more encompassing phenomenon than government. It embraces governmental institutions, but it also subsumes informal, nongovernmental mechanisms whereby those persons and organisations within its scope move ahead, satisfy their needs, and fulll their wants. Governance is a system of rule that works only if it is accepted by the majority, whereas governments can function even in the face of widespread opposition to their policies. Corporate governance, for example, is the subset of governance that involves corporations. That is, the set of laws, rules, institutions, and policies which aect the way a corporation is controlled and managed [Monks and Minow 2004]. The actors involved in corporate governance are the shareholders, the board of directors, the management and other stakeholders3, although in most cases it is a delegated responsibility on the managers and the board, bounded by public legislations and regulations. 3Customers, employees, suppliers or the community at large are examples of stakeholders.
30 Chapter 3. Normative systems and governance For Colley et al. [Colley et al. 2003], corporate governance is a concept of growing interest, being critical nowadays in modern economies. This is due to a continuous criticism over the years about the way corporate boards work, and the constant pressure over the fulllment of the responsibilities they have been elected for. Colley et al. claim that this is the main collective problem of business as of today, and present a template for corporate governance analysis from several perspectives: •The legal issues: what does the law require? •The ethics: how does the organisation denes and fullls its obligations to its constituencies or stakeholders in view of conicting interests? •Eectiveness: how does the board ensure that they and their management make eective decisions in an ecient and timely manner? •The board's relationships: how does the board maintain eective relationships with their constituencies, particularly shareholders and management? •The group dynamics: how well does the board function as a group or team? The denitions of governance and corporate governance seem to be clear and more or less uniform. This is not the case with IT governance. However, Simonsson and Johnson [Simonsson and Johnson 2006] analyzed over 60 articles in order to extract an approximate shared denition: IT Governance are the tactics and the strategy (decision-making process) made and carried out in order to monitor, decide and understand (scope) upon the IT goals, technologies, human resources and processes (domain) of an organisation. In most of the organisations, every IT resource and process has some level of governance associated with it in the form of policies, rules, and controls. However, according to Webb et al. [Webb, Pollard, and Ridley 2006], companies with a well designed IT governance earn a higher return on their assets. In fact, it is widely accepted that it directly inuences the benets generated by organisational IT investments [Weill 2004]. However, despite being seen as an essential component in the overall corporate governance structure, IT governance is right now the weakest link in the chain [Trites 2004]. Whereas IT Governance deals with hardware and software in general terms, SOA governance is concentrated only on the Service-Oriented Architectures subset. Moreover, SOA Governance is an emergent concept in the SOA community used for activities related to exercising control over services [webMethods 2006]. It is a form of electronic governance that has its focus on distributed services and composite architectures, more concretely on SOA scenarios, which may be under the control of dierent ownership domains. One main concern about SOA is that is supposes a paradigm shift for the industry [Ibrhaim et al. 2007]. SOA adoption is complex in the sense that, in each particular case, the possible successful implementations are too many and the outcomes are too unpredictable to make of it an straightforward process. On the contrary, this is a process that needs control to some extent. This is an issue that is being currently covered by SOA governance.
3.2. Governance 31 3.2.1 A denition of SOA governance Initially, the concept of SOA governance was applied narrowly to the development and use of Web services, for example, validating the conformance of a Web service with specic standards or managing Web services in the SOA run-time environment. SOA Governance tries to solve several issues, including: •Fragile and delicate SOA implementations. •Services that cannot easily be reused because they are unknown to developers or because they were not designed with reuse in mind. •Lack of trust and condence in services as enterprise assets, which results in a build it myself mentality, further compounding the lack of reuse with redundancy and unnecessary duplication of functionality. •Security breaches that cannot easily be traced. •Unpredictable performance. In summary, SOA Governance is intended to give the methodology and the tools needed to maintain the order in SOA environments. Some periodic reports identify how the community is doing at heading in this direction and which companies are on the good track and what they lack [Fulton, Hener, and D'Silva 2008; Kenney and Plummer 2008]. SOA Governance4is an emergent concept in the SOA community used for activities related to exercising control over services[Linthicum 2008]. It is a form of electronic governance that has its focus on distributed services and composite architectures, more concretely on SOA scenarios. In the last years many companies have started to switch to Service-Oriented Architectures for exibility reasons and to adapt to technologies and practices under continuous growth and standardization. After adopting services as a kind of business asset, SOA Governance has appeared in the form of a methodology which aects the full life cycle of the services in terms of specication, design, implementation, deployment, management, control, monitoring, maintenance, intercommunication, and redesign. Its aim is to give guidelines on how to establish shared policies, processes, architecture and policies across each layer of an organisation. The business SOA community is already aware of the importance of successfully dening and promoting a standard which may help the stakeholders in using SOA Governance and acquire its benets. 3.2.2 Institutional governance based on agents There are three steps that dene SOA Governance management [webMethods 2006]. Design-Time Governance deals with the denition and application of policies that will govern the design and implementation of Web services in the organisation, prior to 4SOA Governance should not be confused with E-Governance. E-Governance can be dened as the use of Information and Communication Technology as a means to improve transparency, quality and eciency of service delivery in the public administration.
32 Chapter 3. Normative systems and governance their deployment in the actual business environment. During Run-Time Governance, policies are dened and enforced in order to govern the deployment, execution, and use of the Web services. Eventually, Web services are supposed to be redesigned and reimplemented in order to adapt to business evolving requirements. Change-Time Governance focuses on how the changes on the services aect the behavior of a whole SOA environment. There are three steps that dene SOA Governance management [webMethods 2006]: •Design-Time Governance: denition and application of policies that will govern the denition and implementation of Web services in the organisation, prior to their deployment in the actual business environment. •Run-Time Governance: denition and enforcement of policies that will govern the deployment, execution, and use of the Web services. •Change-Time Governance: Web services are supposed to be redesigned and reimplemented in order to adapt to business evolving requirements. This type of governance focuses on how the changes on the services aect the behavior of a whole SOA environment. The approach currently used in SOA Governance management is based on adding additional Web services in the SOA environment. The main components are: a registry (a central catalog for business services), a repository (a database of governance policies and metadata), policy enforcement points (services responsible for the enactment of the policies), a rule engine (automatic system that manages the enforcement of the policies), and a conguration environment (user interface for the conguration and denition of policies and governance workows). The company webMethods (a subsidiary of Software AG) dened in a white paper [webMethods 2006] a basic classication of the components needed for a SOA governance implantation, putting together methods found in the IT governance literature and the constraints and properties of a SOA. The key components identied for a SOA governance system are summarised in Figure 3.1 and described in the following sections. The rst requirement of SOA governance is architecture governance. Architecture governance is necessary to ensure that SOA as architecture evolves by design and not by accident. To the extent that it mirrors governance requirements in other areas of IT architecture, SOA architecture governance practices can be adapted from existing organisational architecture processes. These include: •Establishing organisational technology standards. •Dening the high-level SOA architecture and topology, as well as the infrastructure capabilities that the SOA should incorporate. •Determining the SOA platform strategy and making decisions about particular third-party products and technologies.
3.2. Governance 33 Figure 3.1: Key components of a SOA governance system § •Specifying the management, operations, and quality-of-service characteristics of the SOA, such as security, reliability, and availability. •Establishing criteria for SOA project design reviews. In addition, a key aspect of SOA architecture governance is dening a roadmap that will guide a smooth and thoroughful evolution of the architecture over time. The majority of organisational SOA strategies will involve overlaying and transforming the existing systems architecture in stages, rather than a whole replacement of the current infrastructure. Governance is needed to ensure that decisions made along the way align in a consistent direction and maintain the coherency of the SOA architecture. 3.2.2.1 Service lifecycle governance A fundamental point in SOA [Erl 2004] is that it involves the creation of discrete, welldened services that exist not only as building blocks of larger systems and applications, but more importantly as independent entities. As opposed to previous paradigms, SOA exposes standalone application functionality at a ne-grained level of granularity. A a new form of governance is therefore needed: service-level lifecycle governance. Service-level governance applies at the level of individual services and covers a wide range of requirements and situations. A useful approach to categorise the scope of activities associated with service-level governance is to consider the lifecycle of a service: beginning with its design, to its use in a run-time environment, to ongoing management and change of the service, as well as the people who have responsibilities in the governance of these services. Design-Time Governance. Design-time governance is primarily an IT development function that involves the application of rules for governing the denition and creation of
34 Chapter 3. Normative systems and governance Web services. Policies might include ensuring that services are technically correct and valid, and that they conform to relevant organisational and industry standards. Examples of this type of validation might include checking that a service is compliant with the Web Services Interoperability (WS-I) proles [Nezhad et al. 2006]: usage guidelines that ensure Web services implemented on dierent platforms are interoperable, by automatically verifying service schemas, validating namespaces, and other controls. If an organisation has a SOA governance infrastructure in place, in the form of software that facilitates the implementation of SOA governance practices, these checks can be invoked automatically when developers check services into a registry. In addition, approval and notication workows can be triggered by a governance-enabled registry to ensure that services pass through pre-dened review and approval steps so that they meet architectural and organisational standards for business function encapsulation, reusability, reliability, and so on. By ensuring that these reviews are performed by appropriate members of the organisation, it becomes possible to manage the quality and coherency of the service scenario eectively. Key issues to consider include: •Determining the tness of a service, where t is a function of the functionality that is encapsulated, the likelihood of reuse, and the importance of the service within the overall portfolio of services. •Identifying which services to build against the previously existing organisational requirements. •Ensuring the strategic design of services and validating that their interfaces and implementation conform to established design patterns and other organisational standards and practices. •Establishing the governance standards to which dierent categories of services will be held, understanding that dierent levels of governance will be appropriate for dierent classes of services. Internal-use vs. services exposed to business partners, for example. Other capabilities of design-time governance include ne-grained access control over assets in the registry, so that only authorised users are able to publish, search, and view services. In addition, the ability to label services and classify providers and consumers makes it possible to have some services visible to certain classes of service consumers and not others, a feature that is particularly important for partitioning access in a shared services model. Run-Time Governance. Run-time governance is primarily of interest to IT operations. Governance at run-time revolves around the denition and enforcement of policies for controlling the deployment, utilization, and operation of deployed services. These runtime policies typically relate to non-functional requirements such as trust enablement, quality-of-service management, and compliance validation. Examples of run-time governance include:
3.2. Governance 35 •Checking a service against a set of rules before it is deployed into production, for example, to ensure that only a certain message transport or specic schemas are used. •Securing services so that they are accessible only to authorised consumers possessing the appropriate permissions, and that data is encrypted if required. •Validating that services operate in compliance with prescribed organisational standards, in eect, to conrm that a service is not just designed to be compliant, but that its implementation is actually compliant. A more specic case of run-time governance involves service-level monitoring and reporting. In order for the run-time SOA infrastructure to assess whether a given service is performing at the required level for a given consumer, in terms of response time, throughput, and availability, it is necessary to have an explicitly dened service level agreement between the service consumer and provider. SLAs can be expressed in terms of service contracts between consumer-provider pairs, and they establish the reference points for compliance monitoring and reporting by the SOA run-time environment. By tracking the actual performance of a service and comparing it to the requirements specied in the SLA, the system can identify non-compliant services and prompt remedial actions. For example, automatically instantiating another instance of the service to improve load-balancing or alerting IT managers. Change-Time Governance. Change is inevitable and, at some point, services deployed in the run-time environment will have to be changed to adapt to new requirements. Since the majority of services will be designed once and then modied several times over their lifetime, change-time governance, or in other words, the act of managing services through the cycle of change, is arguably more important in the long term than design-time governance. Change-time governance requirements and considerations include: •Understanding inter-service relationships and dependencies. •Performing impact analysis to determine the implications of changing a particular service within the run-time environment. •Managing the redeployment of services into the existing run-time environment. •Managing service replacement through the design, coding, testing, and deployment stages. •Managing changes to existing policies and service level agreements. An important aspect of change-time governance is involvement of the organisational goals. This need arises from the fact that services exist to support organisational functions as well as the inter-organisational relationships and dependencies that are implicit in SOA, particularly when services are exposed and invoked across organisational boundaries. Since changes are generally initiated and driven by the requirements, users need to be participants in the governance lifecycle.
36 Chapter 3. Normative systems and governance 3.2.3 Technologies for SOA governance If we follow the requirements structure, a SOA governance system should facilitate service-level governance across the lifecycle from design-time to run-time to changetime. It should allow polices to be dened and created, and provide mechanisms for these policies to be enforced at each phase of the service lifecycle. The main components of this system include: •Aregistry, which acts as a central catalog of services. •Arepository, for storing policies and other metadata related to the governance of the services. •Policy enforcement points, which are the agents that enact the actual policy enforcement and control at design-time, run-time, and change-time. •Arule engine for managing the declaration of policies and rules and automating their enforcement. •An environment for conguring and dening policies and for managing governance workows across the service lifecycle. 3.2.3.1 Registry A registry is usually identied as one of the rst requirements of SOA adoption and registries play an important role in governance. In simple terms, a registry [Clement 2005] is a catalog or index that acts as the system of record for the services within a SOA. A registry is not designed to store the services themselves, but indicates their location by reference. Having a centralised catalog of services is signicant from an organisational perspective because it enables the easy discovery, reuse, and management of services. A SOA registry typically fullls the following functions: •Stores service descriptions, information about their endpoints and other technical details that a consumer requires in order to invoke the service, such as protocol bindings and message formats. •Allows services to be categorised and organised. •Allows users to publish new services into the registry and to browse and search for existing services. •Maintains service history, allowing users to see when a service was published or changed. As the place where services are made known within the SOA, a registry is also a natural management and governance point. For example, compliance requirements, such as conformance with the WS-I Basic Prole or the use of specic namespaces and schemas, might be imposed on services before they are allowed to be published in the registry. Or, as services are registered or changed, the registry also has the ability to trigger approval and change notication workows so that people involved are alerted to changes. As such, a robust registry is an important component of any SOA governance solution.
3.2. Governance 37 Another important factor is the interoperability of the registry with other components of the SOA infrastructure. OASIS provides a platform-independent standard for registry interoperability known as UDDI (Universal Description, Discovery, and Integration). UDDI [Bellwood 2001] denes a Web services-based programming interface that allows dierent consumer applications, tools, and run-time systems to query the registry, discover services, and interact as required to provide management and governance capabilities. While it is not a pre-requisite for a SOA registry to be based on UDDI, it is the most commonly adopted standard and ensures the greatest degree of compatibility with other products in the environment. 3.2.3.2 Repository While the registry plays a central role in policy enforcement, the registry itself does not provide sucient context for the whole set of SOA governance requirements. For example, policies, in the form of rules and restrictions that are enforced on services, and consumer/provider service level agreements are generally not constructs that are stored in a registry. Thus another data store, usually referred to as a repository, is needed for storing governance-related artifacts and supporting the full complexity of managing service metadata throughout the service life cycle. The term repository is used in many dierent contexts, but in the context of SOA governance, the repository can be thought of as a centrally-managed policy store. Among other things, a governance repository should support the following capabilities: •An ontology for representing and storing organisational and regulatory policies that can be translated into rules that are enforced by the SOA governance system. It should be possible for policies and rules to be interpreted by people or machines, and sometimes both, as appropriate. •Audit capabilities for tracking the trail of changes and authorizations applied to assets within the repository context. •Identity management capabilities and role-based access controls to ensure that only appropriate parties have access to policies. •A notication system and content validation capabilities to provide additional assurances that policies are well-formed, consistent, and properly applied. The requirement for a logically centralised repository is particularly important for codifying and enforcing a single ocial set of policies across the organisation. However, the actual repository itself may have a federated architecture for scalability and to enable the use of the repository across dierent geographic regions, multiple lifecycle instantiations, and cross-organisational boundaries. 3.2.3.3 Policy Enforcement Points The places where policies are actually applied and enforced, the policy enforcement points, change depending on the lifecycle stage. During design-time, the registry and
CHAPTER 4 The challenge The bottom line is that simplicity is a choice. It's your fault if you don't have a simple system. Simple Made Easy Rich Hickey As seen in previous chapters, monitoring is one of the important points of abstraction for e-institutions to be deployed and integrated in SOA. Monitoring, in its traditional meaning in Software Engineering, refers to the provision of information, usually by sensors, about the system's environment, in order to take actions depending on the result of some processing done to this information [Sommerville 2006]. In other words, monitoring is based on the logging, keeping, and interpretation of messages sent by components of the software system. There are many monitoring mechanisms available in most of the service deployment platforms which cover this need. However, with the growth in the complexity of the platforms based on interacting computational components, it has been shown that this denition of monitoring is not enough to deal with common problems in distributed scenarios [Groth, Luck, and Moreau 2004; Matyska et al. 2007]. That is also the case of e-institutions, where the simple logging of messages, not explicitly linked to each other, is not enough. A norm enforcement mechanism needs more information about the distributed scenario, e.g. the actual relationship between interactions, which occur at dierent points in time and thus are apparently not related to each other, but are in fact parts of a complex transaction. 4.1 Solving the drawbacks of Service-Level Agreements We have pointed out in Section 2.2.3 the aws that the Service-Level Agreements (SLA) in SOA initiatives have, especially related to the lack of expressiveness allowed: in general, the available SLA approaches focus on monitoring simple metrics rather than 45
46 Chapter 4. The challenge enabling high levels of expressitivity. Although in some cases there is the possibility of adding declarative abstractions in the form of simple rules, there is still a lack of solutions that oer the declaration of constraints via modal or deontic expressions. With the increasing growth in the complexity of tasks and responsibilities of distributed systems as seen in Chapter 1 and especially in Section 1.3, specifying interaction contraints is also progressively more dicult to manage. Additionally, these constraints are (still) a product of stakeholders designers, developers, users , rather than being produced automatically by computers. The numerous attempts, as summarised in Section 2.2.3, to raise expressivity and therefore cope with this complexity are proof that there is a need to bring the design of such constraints closer to the way humans think of, write and understand norms. This is not possible to accomplish with simple rules [Grangard et al. 2001]. The drawbacks described have been the ones especially relevant for introducing an e-institution-based norm enforcement mechanism in SOA. However, the concept of SLA, if properly implemented, would be attractive for our purpose. As we noted in Section 3.1, institutions are created by specifying a set of norms that the members of the organization should fulll. Therefore, in principle we should be able to build institutions by using something more generic than SLA. In fact, SLAs are just specications of contracts, however somewhat limited as we have seen. In our previous work, one notable attempt to ll this gap was by using Provenance architectures1[Vázquez-Salceda and Alvarez-Napagao 2009], which in the context of IT allow capturing causal relationships between events produced by actors of distributed systems, with annotated semantics, while providing a framework for reasoning about complex distributed processes as a structured graph. Therefore, rather than focusing on storing interactions and message exchanges in a free format, using provenance allowed us to not only store internal states of actors but also the relationship between these interactions, and the temporal or causal relationship between states with interactions or other states. Provenance handling eectively enables interpretable monitoring of loosely-coupled distributed complex processes, and we took advantage of this in order to build a real-time verication system for compliance of complex rules translated from regulations and protocols. However, provenance-based systems require both a deep knowledge of the domain and the use of an event model tighly coupled to the Open Provenance Specication [Moreau et al. 2008]. In this thesis we focus on achieving the same level of compliance checking and expressivity whilst achieving greater exibility, and as analysed in the state of the art (see Section 3.1), normative systems are a candidate to provide both. In open societies, where heterogeneous agents are self-governed autonomous entities pursuing their own goals, it is a challenge to provide mechanisms to ensure that the system as a whole behaves as expected without undermining agents' autonomy. An approach widely explored in literature is to add a social layer describing and governing 1Provenance architectures allow storing and querying provenance, where the provenance of a data item is represented in a computer system by a set of assertions made by the actors involved in the process that created it.
4.2. Filling the gaps on normative systems 47 the actors' expected behaviour in order to produce desirable and avoid undesirable situations. In such models, goals and interactions are usually not specied in terms of the mental states of individual agents, but in terms of social or organisational concepts such as roles function, position , groups communities , norms regulations, policies and communication protocols including ontologies. In these cases, agents are seen as actors that perform the role(s) described by the social/organisational design. In short, Normative Systems are a socially-inspired approach for the governance of distributed, agent-oriented systems, where the expected behaviour of agents is described by means of an explicit specication of norms. As such, there are many works (see Section Section 3.1) in literature that explore the use of normative specications to dene the acceptable behaviour of a set of agents including services in a given environment. Norms such as regulative rules provide a way to introduce exibility in the specication of desired actor behaviour in a shared context, as they typically specify the boundaries of what is acceptable, but not how exactly to behave. However, regulative rules do not entail any value of truth but instead express the mere existence of a norm. Norms have indeed been studied from multiple perspectives, but while formalizations tend to be disconnected from possible implementations due to the lack of dierentiation between abstract norm and norm instantiation, on the other hand implementations tend to be weak groundings of deontic logics, tightly coupled to one particular implementation domain. In this dissertation, we build upon previous work to ll these gaps by reducing from deontic statements to structural operational semantics, with intermediate steps in linear temporal logics. Finally we hint at the feasibility of the translation of these semantics to actual implementation languages in dierent domains. 4.2 Filling the gaps on normative systems There is a lot of work on normative systems' formalization (mainly focused in Deonticlike formalisms [Wright 1951]) which is declarative in nature, focused on the expressiveness of the norms [Dignum et al. 2004], the denition of formal semantics [Aldewereld et al. 2005; Boella and Torre 2004; García-Camino et al. 2006; Oren et al. 2009] and the verication of consistency of a given set [Governatori and Rotolo 2010; Lomuscio, Qu, and Raimondi 2009]. There are some works that focus on norm compliance and norm monitoring [Ågotnes, Hoek, and Wooldridge 2010; Alvarez-Napagao et al. 2011; Criado et al. 2010; García-Camino et al. 2006; Governatori and Rotolo 2010; Oren et al. 2009] with varying degrees of covered abstraction level and allowed exibility. Also there is some work on how agents might take norms into account when reasoning [Aldewereld et al. 2005; Kollingbaum 2005; López, Luck, and d'Inverno 2004; Meneguzzi and Luck 2009; Panagiotidi and Vázquez-Salceda 2011], but few practical implementations exist that cover the full BDI cycle, as many approaches do not include the means-ends reasoning step (that is, dedicing HOW to achieve WHAT the agent is aiming for).
48 Chapter 4. The challenge Most of these approaches focus on regulative norms rather than on substantive norms, and lack a proper implementation of the ontological connection between brute events and institutional facts. Therefore, it is not uncommon in some scenarios, i.e., when building a norm-aware multi-agent system, to implement normative reasoning from several points of view at the same time. For instance, in a system with institutional-level norm enforcement, there is normative reasoning at a minimum of two levels: the institutional compliance and the individual agent reasoning. In such scenarios, the following are relevant issues that should be taken into consideration: 1. There is a need to formally connect the deontic aspects of norms with their operationalisation, preserving the former. 2. From a practical point of view, abstract norms have to be distinguished from their actual instantiations. For each abstract norm, many instantiatons may happen during the norm's lifetime. 3. Ideally, the operational semantics should be formalised in a way that ensures exibility in their translation to actual implementations while ensuring unambiguous interpretations of the norms. For instance, the semantics used by a society compliance mechanism, and the semantics integrated in the reasoning cycle of its individual agents, must be aligned to avoid, e.g., the agent norm reasoning mechanism stating that no norm has been violated while the compliance mechanism states that the agent has violated some norm instance. Some works in the literature present solutions that tackle these issues separately (e.g. recent works such as [Meneguzzi et al. 2015] tackle 1. and 2.), but it is hard to nd a proposal that manages to ll the gap left by these three issues at the same time. In this document, we present a proposal that combines ideas from many pieces of work, coming from dierent formalizations while using [Oren et al. 2009] semantics as a foundation, in order to achieve a deontic-based norm denition with a direct reduction to temporal logics which, in turn, can be translated into rule-based operational semantics. 4.3 Our proposal We present a computable language, a formalism for the monitoring of both regulative (deontic) and substantive (constitutive) norms based on Structural Operational Semantics, its reduction to Production Systems semantics and our current implementation compliant to these semantics. To ensure that the formalism used by the normative monitor is also compatible with an agents' practical reasoning, the work presented in this document is built upon the combination of work previously done separately in [Alvarez-Napagao et al. 2011; Panagiotidi and Vázquez-Salceda 2011] to have a unied normative framework with two dierent implementation perspectives: planning and monitoring.
4.3. Our proposal 49 The rest of this Part II contains the materialisation of this proposal. In Chapter 5, we present our language of norms for services and agents. We then present the operational semantics for this language in Chapter 6, and nally we present our normative monitor, along with the reduction to production systems and a implementation of it, in Chapter 7.
CHAPTER 5 Towards a lightweight language for norms `Mind you, I don't object to foreigners speaking a foreign language. I just wish they'd all speak the same foreign language.' Avanti! Billy Wilder As mentioned in Section 2.1, in order to interpret part of their social reality, agents in a socio-technical system need ways to be able to track the status of all the social norms that may apply to them and to the behaviours of other actors that may aect them (directly or indirectly). From a computational perspective, the rst foundational element needed for an eective and ecient monitoring of high-level norms in distributed systems both agent-oriented and service-oriented systems is a proper language to describe such norms in a declarative way. The following is a summary of the requirements that such a language such have: •The language should be compact and lightweight. Norms expressed in the language should have the minimum number of elements possible, as they are going to aect the size of the payload in the communications inside a distributed system. •The language should have a formal grounding, linked to the literature on the topic of normativity. The research on this eld has implications on a broad range of areas of knowledge: logics, philosophy, sociology, economics. A language that tackles directly the concept of norm should allow any derived work to be put into context from a formal perspective in order to be used or applied by the related areas of knowledge. 51
52 Chapter 5. Towards a lightweight language for norms •The language should incorporate not only the concept of regulative norm but also the concept of constitutive rules (counts-as rules, see Section 2.1). Not only the behavioural constraints themselves are relevant, but also the ontological transformation rules from brute facts to institutional events. •The language should enable dealing with meta-concepts from the domain of normative contexts, e.g. norm, obligation, prohibition, etc. This would enable reasoning at the level of the norms, beyond the domain and the predicates used in the constraints themselves. •The language should allow for an ecient operationalisation. That is, any derived execution framework for the detection of normative states based on the language should be computable in ecient time/space. Some SLA languages deal with the rst requirement, but in general none of the other requirements are tackled by them. In this Chapter we present a language that fullls these requirements. In order to do so, we take an incremental approach, showing a rst language we built especically for contracts in SOA without proper counts-as rules, trying to tackle directly the issues of SLAs; and the extensions done afterwards for adding constitutive rules and generalising the approach for distributed systems in general and multi-agent systems in particular. 5.1 A language for contract representation A contract [Simpson and Weiner 2003] is a written or spoken agreement that is intended to be enforceable. This agreement contains a set of clauses to be enforced. Each clause can be seen as a norm, so at the moment that it is signed by the parties, there is an institution created. This approach has already been explored by Dellarocas with the concept of Contractual Agent Societies [Dellarocas 2000]. We can then informally dene a contractual electronic institution as an electronic institution which has been created at the time when an electronic contract has been signed by its parties. The members of the institution are these parties, and the norms to be enforced by the institution are the clauses of the contract. In order to have a norm monitoring mechanism in SOA based on contractual electronic institutions, we will need a formalism to model contextual norms, in the form of electronic contracts, that avoids the problems SLA formalisms suer from in this subject. Also, we will need a framework that allows for services that can create, manage, and enforce contracts, that is, for the creation of contractual electronic institutions. Our research done in this eld took place in these two directions, in the scope of the IST-CONTRACT project1, where we propose a move to a more exible contracting mechanism for Service Oriented Systems based on the following three main elements: 1The IST-CONTRACT Project was a project (FP6-034418) funded under the 6th Framework Programme of the European Commission. The Contracting Language presented in Section 5.1 was developed during the project lifetime.
5.1. A language for contract representation 53 •The introduction of intentional semantics within the communication between services (based on the use of performatives such as request, inform, or commit). This is important as it re-enforces the link of actual and intended behavior. •The creation of a contracting language able not only to express a set of intended behaviors on which parties agree but also to dene the way that contracts and contract-related events are negotiated and communicated. •The creation of higher-level behavioral control mechanisms, centered not on the tracking of a limited set of metric values but on the monitoring of higher-level objects such as commitments, obligations and violations which can be extracted from the communication semantics. The combination of these three elements makes it possible to monitor the behavior of a set of actors by keeping track of the fulllment of the agreements between them. This section presents the denition of a contracting language which can be used not only to specify agreed behavior in service-oriented architectures but also for agentmediated systems. The language is based on deontic notions such as obligations, permissions and prohibitions. The language not only covers the contract document itself but several layers of communication, including the messages and the protocols for contract handling. In Section 5.1.1 we describe the conceptual layers of our contracting language. Section 5.1.2 analyses the important elements of the contract representation model. Section 5.1.3 explains how messaging and communication are achieved between the contracting parties. As an example, we will adopt one of the use cases produced during the ISTCONTRACT, consisting in a web-service system enabling agreements between several parties (insurance companies, repair companies, and a third kind of party called Damage Secure which acts as a broker between the former) in a car insurance scenario. In this scenario, insurance companies le repair requests and Damage Secure, as an intermediary, is responsible for nding the best possible repair company for the job2. 5.1.1 Layers/Elements of the Contracting Language This contracting language3aims to dene the way agents can exchange information during contract establishment, contract execution and contract termination. During these phases, agents may exchange not only information about the contracts themselves, but also about any related event, predicate or action that may be related to such contracts. Therefore it needs to dene the communication structures required to exibly exchange information about parties, processes, world states, ontological denitions and so on. 2For a more detailed description of this use case, see [Panagiotidi et al. 2008]. 3My contribution to the work presented in this section was twofold: leading the analysis of the state of the art on existing contracting languages, identifying the required layers and elements, and a strong and continuous involvement in the design process of the contracting layers. These contributions were made along with Soa Panagiotidi, Roberto Confalonieri, Javier Vázquez-Salceda and Steven Willmott.
60 Chapter 5. Towards a lightweight language for norms Figure 5.8: Representation of the world model element in the Contract Language § and the set of regulations to be applied within the organization being represented. Moreover, the context of a contract, called interaction context, may be as well contained inside another interaction context and therefore inherit all its knowledge representation elements and be constrained by its regulations. In this case, the Contextualization part of the contract has to specify which is the parent contract. If a contract is an instance of a contract template, this is also specied in this part. This concept of interaction context is equivalent to the Context dened in HARMONIA[Vázquez-Salceda 2004]. 5.1.2.6 Clauses Clauses express agreements between parties in the form of deontic statements. In order to express the clauses we have adopted a variation of the representation dened in [Aldewereld 2007], which is based on a dyadic deontic logic including conditional and temporal aspects. It is important to note here that, although the name given here is clause, which is typically used in the denition of a contract document, we are in fact representing norms in a norm condition expression language [Vázquez-Salceda, Aldewereld, and Dignum 2004]. A clause (Figure 5.9) is structured in two parts: the conditions and the deontic statement. There are three conditions, which have the form of boolean expressions, that have to be evaluated at dierent stages of the clause life cycle.
5.1. A language for contract representation 61 •Activating (or triggering) Condition: when this condition holds true, the clause is considered to be activated. This condition can also be referred to as precondition. If the boolean expression of this condition includes a violated() predicate, the clause is considered to be a violation handler (a clause specifying the deontic consequences of violating another clause). •Exploration (or maintainance) Condition: this is the invariant of the deontic statement execution, which means that when the clause is active and the statement is being enforced, the exploration condition has to hold always true. If this does not happen, a violated() predicate will be raised. This condition can include temporal operators before() and after() with allow to express temporal constraints and deadlines. •End (or achievement) Condition: the clause is considered to be inactive and successfully fullled if and only if the exploration condition has always held true and the end condition holds true. Figure 5.9: Representation of the clause element in the Contract Language § The DeonticStatement is the central element of the clause. There are three main elds in its structure: the deontic modality, the roles involved and the object of the norm (see Figure 5.10): •Modality: this eld indicates the deontic modality of the statement, which can be either Obligation, Prohibition, or Permission. •Who: contains the set of roles and groups of roles that will have to full the statement. •What: this represents the object of the norm (see Figure 5.11). This object can be an action or a state. If it is an action, this action will have to be executed in order
62 Chapter 5. Towards a lightweight language for norms Figure 5.10: Representation of the deontic statement element in the Contract Language § to full the norm. Otherwise, if it is a state, the responsible actor(s), dened in the Who attribute, will have to ensure that this state is accomplished as long as the exploration condition holds true. Figure 5.11: Representation of the What element in a clause in the Contract Language § If the Modality is Obligation, the parties responsible will have to execute/ensure the object of the norm in order to full the clause. If it is a Prohibition, the parties will have to avoid executing/ensuring the object, and if it is a Permission, the parties are informed that they can execute/ensure it. Clauses can be used in two ways:
5.1. A language for contract representation 63 •as standard clauses: the ones that dene what ought/ought not to be done. For instance, a clause stating that a buyer should pay for a given item within some time period. •as violation handling clauses: the ones dening what to do if standard clauses are violated) (i.e. The exploration condition does not hold). An example of a standard clause could be, if we suppose a car insurance scenario: The repair company is obliged to notify the insurance company before April 10 if the report of the repair is ready. Such clause, which in dyadic deontic logic would be formalised as: exists(RepairReport(car)) → ORepairCompany(sendRepairCompleted(car, DamageSecure, RepairCompany) ≤April_10) And can be expressed in our language as follows: <Clause ClauseID="NotifyRepairCompleted"> <ActivatingCondition> <BooleanExpression> exists(RepairReport, isRepaired(car12f3pw, R1)) </BooleanExpression> </ActivatingCondition> <EndCondition> <BooleanExpression> isSentRepairCompleted(car12f3pw, RepairReport, "Damage Secure", R1) </BooleanExpression> </EndCondition> <ExplorationCondition> <BooleanExpression> Before(2008-04-10T15:30:30+01:00) </BooleanExpression> </ExplorationCondition> <DeonticStatement> <Modality> <OBLIGATION/> </Modality> <Who> <One id="R1" enacting="Repair Company"/> </Who> <What> <ActionExpression> sendRepairCompleted(car12f3pw, RepairReport, "Damage Secure", R1) </ActionExpression> </What> </DeonticStatement> </Clause> This clause only activates when a report stating that the car is repaired exists, and deactivates once the report is sent. The ExplorationCondition species in this case that
64 Chapter 5. Towards a lightweight language for norms the obligation should be met before a given deadline. The DeonticStatement species that this is an obligation related to one agent, R1,5enacting the Repair Company role, and it consists of one action (sending the repair report). 5.1.2.7 Contractual Ontology (IST-Contract) As mentioned in Section 5.1.1, the Contractual Ontology is the ontology that predenes all the terms, predicates and actions that are used by the framework, independently of the application domain. The purpose of this is for a generic, non-application dependent information to exist within the framework and be shared amongst the agents. This ontology denes objects which represent primal entities existing within the framework, actions committed by an actor and predicates which declare states and conditions of the system. Some of the primal concepts that exist in the contractual ontology are: •Contract: an agreement between several parties •Obligation: an obligation corresponding to an agent •Party: a person, agent or entity •Action: an action taken by one of the parties •Predicate: a logical predicate with zero or more arguments which is true or false •List: the classical notion of list •Penalty: the penalty that one party receives in case of a violation of an obligation Table 5.1 and Table 5.2 show the pre-dened actions and predicates created to express statements about contracts are shown. Attributes represent both inputs and outputs. Wherever a predicate appears in the precondition and does not in the postcondition, it is assumed that it remains the same after the action is completed. 5.1.2.8 Domain Ontology Domain ontologies are important elements in our framework, as they semantically connect references to the same entities and objects made at dierent layers (e.g. a message referring to a car and a contract referring to the same car). These ontologies also ensure that the same denition for actions and predicates is consistently used, avoiding interpretation errors. This last aspect is especially relevant in contracts, as all parties should have the same understanding about the agreed terms in the contract. For instance, if the contract establishes the obligation of a given repair company to x the client's car windshield, both the repair company and the client should have the same denition for the concept windshield and the action to x when applied to windshields. 5It is important to note here that we show a version of the clause that is valid for both contract templates and contracts, where R1 is a variable which value is set by unication in the activating condition (i.e. the Repair Company that created the Repair Report). If one is not interested to reuse this clause in several contracts, R1 could be directly substituted here by the specic Repair Company.
5.1. A language for contract representation 65 action attributes precond. postcond. commit P: Instance of Party C is valid committed(P, C) C: Instance of Contract initiated(C) ∀O Instance of Obligation in C: obliged(P, C, O) happened(P, commit(P, C)) end P: Instance of Party exists(C) happened(terminate(P, C)) C: Instance of Contract initiated(C) ¬initiated(C) active(C) → ¬ active(C) terminated(C) withdraw P: Instance of Party exists(C) ¬committed(P, C) C: Instance of Contract initiated(C) ¬initiated(C) committed(P, C) request_cancel P: Instance of Party exists(C) happened(request_cancel(P, C)) C: Instance of Contract initiated(C) create P: Instance of Party ¬(exists(C)) exists(C) C: Instance of Contract happened(P, create(P, C)) cancel P: Instance of Party exists(C) active(C) → ¬ active(C) C: Instance of Contract initiated(C) ¬initiated(C) happened(cancel(P, C)) cancelled(C) terminated(C) ∀PT : committed(PT, C) ¬committed(PT, C) get-contract P: Instance of Party exists(C) happened(get-contract(P, C)) update P: Instance of Party exists(OC) exists(NC) PT: Instance of Party OC is valid initiated(OC) →(initiated(NC) C: Instance of Contract (old version) NC is valid ∧¬ initiated(OC)) NC: Instance of Contract (new version) active(OC) →(active(NC) ∀PT : committed(PT, OC) committed(PT, NC) ∀PT : committed(PT, OC) ¬committed(PT, OC) happened(update(P, OC, NC)) Table 5.1: Library of contract-related actions §
66 Chapter 5. Towards a lightweight language for norms predicate description attributes(terms) happened(A) An action happened at some point in the past A: Instance of Action before(T) The current time is before some time T: Instance of Time after(T) The current time is after some time T: Instance of Time committed(P, C) A party is committed to a contract P: Instance of Party C: Instance of Contract all-committed(LP, C) All parties have committed to a contract LP: List of Instances of Party C: Instance of Contract violated(P, C, LO) A party has violated obligations of a contract P: Instance of Party C: Instance of Contract LO: Instances of Obligations obliged(P, C, O) A party is bound to an obligation within a contract P: Instance of Party C: Instance of Contract O: Instance of Obligation ended(C, T) A contract has been ended due to a violation C: Instance of Contract T: Instance of Time initiated(C) A contract has been signed C: Instance of Contract active(C) A contract is taking action and has not yet terminated C: Instance of Contract cancelled(C) A contract has been cancelled C: Instance of Contract fullled(P, C, O) A party has fullled an obligation within a contract P: Instance of Party C: Instance of Contract O: Instance of Obligation Table 5.2: Library of contract-related predicates § As mentioned in Section 5.1.1, there are at least two levels of domain ontologies in the CONTRACT Communication Model: contract ontologies and context ontologies. More levels may appear if super-contexts of a given context are dened which include ontological extensions, or if sub-contracts in the scope of a given contract are dened which include additional concepts. Context ontologies dene all shared denitions by actors interacting in the domain. These ontologies will be mostly classes, without instances. Instances will only be included in the context ontologies if they are to be re-used in more than one contract and if the number is not too big and stable during the contract lifetime, e.g. the names for the known insurance companies could be added to the ontology, as they are quite stable through time and rarely appear or dissappear. Although the context ontologies are not part of the data model, there are some requirements that they should full. For instance, they should dene all predicates and actions (with their parameters), roles and terms which appear in the rest of the context denition. Contract ontologies are extensions of a given context ontology (or an overarching contract) which inherit, rene and/or extend the terms needed for that particular con-
5.1. A language for contract representation 67 tract in a given domain. These ontologies also dene instances of existing ontological classes, when enumeration of all instances is not advisable at the context ontology. In those cases where all needed classes and instances are already dened in a context ontology, then no extension should be dened and the contract ontology and the context ontology are the same. The model thus depends on the capability to extend existing ontologies with additional concepts and relations. The extended ontology should contain not only the added terms, but also inherit all denitions from the extended ontology. Domain ontologies are explicitly used in several parts of our model. Communication messages include an explicit reference to the ontology needed to interpret the content of the message (Section 5.1.3.1). Contracts also include, in their World Model part, a reference to a domain ontology. If no additional ontology is dened, then the ontology used is the context ontology (Section 5.1.2). In general, all elements and concepts used in the message content, in contracts and denitions of context should correspond to classes and/or instances which should exist in some ontology. 5.1.3 Contracting Messages and Protocols In order to increase the expressivity of the communication between services to introduce some intentional stance, the contracting language also denes a set of performatives to be used by the parties. We have extended FIPA ACL [Agents 2002b] performative set in a way that can be used not only by web services but also by agents. To properly use those performatives, our contracting language also species the message structure, a content language and a set of contracting protocols6. 5.1.3.1 Message Structure FIPA [Agents 2000] provides both a message format and a message-handling protocol to support run-time knowledge sharing among agents. It can be thought of as consisting of three layers: a protocol (performative) layer, a content layer, and an ontology layer. The domain-independent performatives in protocol layer, such as inform, propose, accept-proposal and agree, describe the communication actions between agents. FIPA-SL denes the syntax and semantics for the expression of communication content. Our proposed message structure is an XML variation of FIPA's message structure [Agents 2002b], where the message body contains the usual FIPA proposed attributes, i.e. sender, receiver, performative, language, content, etc. 5.1.3.2 Message Content The content of the communication message describes what the purpose of the communication is and expresses knowledge existing in the level of the world representation. 6My contribution to the work presented in this section was twofold: leading the research work on the state of the art that was used as our foundations and the design of 7 of the 14 interaction protocols. These contributions were made along with Soa Panagiotidi, Roberto Confalonieri, Michal Jakob, Javier Vázquez-Salceda and Steven Willmott.
68 Chapter 5. Towards a lightweight language for norms That is, the ontology and its elements are used to support the interpretation of the message content by the receiving agent and they can be found in 5.1.2.7 and 5.1.2.8 as part of the context ontology. One important feature of the contracting language is that contracts can be part of the content of a message. This is possible due to this concept being dened in the contractual ontology, which will be a basic domain framework for the communication, and provides a exible way to express knowledge related to specic contracts. The language used to express the content of the messages between the actors is based on a subset of FIPA-SL [Agents 2000]. FIPA-SL is more complete than other logic languages, such as Prolog, when focusing on content-oriented agent communication, and at the same time it is more complete than other semantic languages, as KIF [Finin et al. 1994], allowing for better constructs with better semantics and lower complexity. A subset of FIPA-SL, namely FIPA-SL2, adapted to an RDF representation7, has been chosen as a basis for the content language. The reason for this is that it remains an adequately expressive set as it allows rst order predicate, modal logic operators, quantiers (forall,exists) and reference operators (iota,any,all), which are needed in order to give the expressivity needed for exible contract-related communication. 5.1.3.3 Performatives The full set of FIPA-ACL [Agents 2002b]performatives is adopted (e.g. query,inform, etc.). However, FIPA standards do not include cases in which an agent desires to propose an action to be performed by more than one agent (e.g. to propose that many agents commit on a contract). For this reason, FIPA-ACL alone is not sucient, as its speech acts cannot be used to form, maintain and dissolve joint intention (mainly to commit) in order to support advanced social activity (i.e., teamwork). We have extended FIPA-ACL performatives with extra performatives based on joint intention theory [Tuomela 1996]: •suggest: The action of submitting a suggestion for the sender and the receiver agents to perform a certain action. <i, suggest (j, <i, act>,<j, act>)> where i is the sender and j is the receiver. •consent-suggestion: The action of showing consent to a suggestion for the sender and the receiver agents to perform a certain action. <i, consent-suggestion (j, <i, act>,<j, act>)> Agent i informs j that, it consents for agent i and agent j to perform action act giving the conditions on the agreement. •dismiss-suggestion: The action of dismissing a suggestion for the sender and the receiver agents to perform a certain action. <i, dismiss-suggestion (j, <i, act>,<j, act>,ψ)> Agent i informs j that, because of proposition ψ, i does not have the intention for i and j to perform action act. 7RDF has been chosen here instead of XML because it is easier to integrate with semantic representations such as OWL.
5.1. A language for contract representation 69 action protocol(s) end Contract Fullment Protocol With Notary request_cancel Contract Violation Protocol Without Manager Contract Violation Protocol With Manager create Simple Contract Creation Protocol With Notary Simple Contract Creation Protocol Without Notary Sideways Contract Creation Protocol With Notary Sideways Contract Creation Protocol Without Notary Simple Negotiation Creation Protocol With Notary All Parties Agree Creation Protocol Without Notary All Parties Agree Creation Protocol With Notary cancel Contract Cancelling by Agreement Protocol Without Notary Contract Cancelling by Agreement Protocol With Notary update Contract Modication/Update Protocol With Notary Table 5.3: Library of contract-related actions § 5.1.3.4 Protocols Contract execution requires agent behaviors which should be well dened and designed, in order for the contract lifecycle to be successfully executed. These include the phases of Contract Creation,Contract Fullment,Contract Modication and Update,Contract Violation,Contract Cancelling By Agreement and more. Such a communication can be achieved through communication protocols which dene a signicant part of every agent's expected behavior. The IST-CONTRACT project contributed a library of protocols which allow agents to communicate whenever one of the phases is taking place are dened. In some cases, more than one protocol is provided, since there can be more than one way in which a stage can successfully take place (i.e. when a contract is being created, there might or might not be a negotiation phase involved) and the users should be able to pick the most appropriate for the case. In Table 5.3 we show the correspondence between the protocols and the contractrelated actions listed in Table 5.1. As an example of how these protocols work, Figure 5.12 and Figure 5.13 depict examples of protocols expressing, respectively, the creation of a contract between two agents without an intermediary and the modication of a contract with the presence of a notary. The Sideways Contract Creation Protocol Without Notary consists of several interactions between two contract parties (Initiator and Participant): 1. The Initiator sends to the Participant a SUGGEST message, communicating the
76 Chapter 5. Towards a lightweight language for norms The meta-model for the Normative Structure (NS), therefore, species the norms applied within the rest of the ALIVE Framework, including live components such as coordination-level agents or service-level services. The components of the NS can be seen at Figure 5.16. Figure 5.16: Main components of the Normative Structure §
5.2. The ALIVE framework 77 IST-CONTRACT element ALIVE element Clause Norm ClauseID normID EndCondition deactivationCondition ExplorationCondition maintenanceCondition Table 5.4: Mapping of concepts: IST-CONTRACT vs ALIVE Framework § The rst component that stands out with respect to the IST-CONTRACT language is the CountsAs element, aggregated by NS as constitutiveRules. This is an addition over previous proposals and contains the constitutive denitions of the normative context. Each counts-as rule contains an abstract fact and a context that trigger the counts-as rule, and the denition of a concrete fact that will hold if and only if the rule is triggered. The second element that can be aggregated under the label norms by the NS is Norm: a mapping of the Clause model presented in Section 5.1 with some variations. The most relevant of these variations is the disappearance of an explicit concept representing the deontic modality of the norm. This change was motivated by the fact that our language, thanks to the dierent (activating, maintenance, expiration) conditions, already allowed us to model obligations, prohibitions and permissions implicitly. This is elaborated further in Chapter 6 and Appendix A. The correspondence between IST-CONTRACT clauses and ALIVE norms follow the pattern in Table 5.4, so the abstract norm tuple of Section 5.1.4 would look like: hModality, ActivationCondition, MaintenanceCondition, DeactivationCondition, W hoi Additionally, there are two relevant new elements: a repairCondition, used to specify repairing actions or sanctions that are supposed to bring a norm instance from a violated back to a normal state; and a timeout, that species an amount of time tsuch that if a norm instance has been violated for a period of time t, the instance is considered failed. The motivation for these two additions will be analysed extensively in Section 6.4, but as a summary we can say at this point that they allow a considerable improvement on the life-cycle of the IST-CONTRACT operational semantics. From a structural point of view, an element of the model that is of great importance is PartialStateDescription (see Figure 5.17). This allows implementing count-as rule conditions, as well as the conditions that form part of each norm, in either propositional, rst-order, or computational tree logic. A special kind of partial state description is the landmark, which indicate ideal intermediate states that can be used as a guidance in order to fulll organisational goals. In ALIVE, landmarks may be used to model rel-
78 Chapter 5. Towards a lightweight language for norms evant/critical states of the system interaction, and can be mapped to norms governing such interactions. Figure 5.17: Components of state descriptions in the ALIVE Framework §
5.2. The ALIVE framework 79 Figures 5.18 and 5.19 contain examples of a constitutive rule and a regulative norm that be modelled by using the proposed norm language in the ALIVE meta-model. For further and more elaborated examples of norms and other institutional abstractions modelled using ALIVE, see Section 9.1.3 and Section 9.2.3.1. 5.2.2 From events to monitoring From the global architecture diagram (see Figure 5.14), there were several components and subcomponents directly involved in the monitoring process: the Global Monitor (organisational perspective) and the Local Monitor (individual agent perspective), both receiving brute facts from the Event Bus that acted as a broker for all the events generated both externally and internally12. 12My contribution to the work presented in this section was the design and implementation of the event meta-model and the monitoring subsystems, being the coordinator of these tasks in the context of the ALIVE project. These contributions were made along with Huib Aldewereld and Javier Vázquez-Salceda.
80 Chapter 5. Towards a lightweight language for norms Counts-as rule C: In a particular context where there is a certain power to marry people, two people are considered as married if they were declared (speech act) as such by a person who had that power. Context C hasP ower(A, declared(A, married(x, y)) Antecedent C declared(A, married(B, C)) Consequent C married(B, C) Figure 5.18: Formal model for an example constitutive norm § Norm N: The repair company is obliged to notify the insurance company before April 10 if the report of the repair is ready. Otherwise, the insurance company has to report this violation to the repair company before one month after April 10. Activation Condition N exists(RepairReport(car)) Expiration Condition N sendRepairCompleted(car, DamageSecure, RepairCompany) Maintenance Condition N actualT ime(t)∧t < April10 Repair Condition N reportV iolation(RepairCompany, DamageSecure) Timeout N actualT ime(t)∧t > May10 Figure 5.19: Formal model for an example regulative norm § The key element upon which all these components were built was the Event part of the ALIVE meta-model. Our denition of event (there seems to be a lack of agreement on a common denition) was any happening of relevance that occurs within the observable boundaries of the system, where: •Ahappening is a computable item: a change of state, or a fact related to a resource or an action; •Relevance means that a specic item should be taken into consideration for a proper fullment of goals, objectives, or normative compliance; and •The Observable boundaries of a system is the total set of items that can be seen, limited by the technical and/or physical capabilities of the actors of the system. Events should ideally be described by means of an ontology, in order to be understandable by the actors processing them. In ALIVE, being a layered architecture, events represented facts at dierent levels of abstraction (organisation, agent, service, external). However, it was our objective to design the monitoring architecture in such a way that events were seen as abstract objects. For this reason, events were considered as abstract objects, independent of the information they carry. It was the responsibility
5.2. The ALIVE framework 81 of the actor processing an event to interpret the contents and the context of those contents. 5.2.2.1 Event meta-model The ALIVE Event meta-model is shown in Figure 5.20. This meta-model contains all the elements necessary to model an event in the most possible general meaning of the concept, while representing additional attributes that may help not only understand the fact, but also unequivocally identify it and place the event in both time and location. Figure 5.20: ALIVE Event meta-model § The main element, Event, represents the concept of event itself. It includes the following attributes: •The content, which is the central attribute, and can be any kind of object. •The encoding, which denes how the content is represented, e.g. as a plain text string, as an encrypted string (and thus dening as well how to decrypt it), or as
82 Chapter 5. Towards a lightweight language for norms an XML object (and thus dening which is the XSD it is dened upon). •The language, dening how to interpret the encoded content. In most cases the language is an ontology. •The asserter, that is, the actor that stated the content of the event, e.g. an agent, a service, or an architectural component. •The local key, which is a unique key created by the asserter. The combination of the asserter plus the local key has to be unique in the system. •The point of view of the asserter with respect to the asserted fact. This attribute should describe how the asserter got conscience of the fact. In most cases, this point of view is one of the following: the asserter was the direct responsible of the happening, the asserter observed the happening, or the asserter acts as a proxy or re-transmitter of a third party responsible for the fact. •The timestamp identifying the exact point in time in which the asserter became aware of the fact. 5.2.2.2 Monitoring Regardless of whether a monitor is a local monitor or a global monitor, there are common properties that it has to implement. First of all, a monitor may execute a set of rules to trigger events, e.g. send a noti- cation of the reception of a certain event. These rules dene the behaviour of a specic instance of a monitor. Our implementation was based on a rule engine Drools to manage and execute these rules. The denition of these rules was based on facts to be matched, and thus a set of rules implicitly dened a set of facts to be kept under surveillance. Each monitor was then responsible for extracting this set of relevant facts and for subscribing them to the Event Bus. Although a monitor may be congured to communicate directly with actors or components, monitors are also possible providers of events. Therefore, every monitor in the system was connected to the Event Bus. Finally, every monitor uses one or more interface to communicate with actors and with external or internal components. Considering that a monitor is not only a receiver but also a sender of events, these interfaces have to work in both ways. We solved this by dening a subscribe mechanism for each interface push rather than pull. Figure 5.21 presents the generic monitor architecture, taking into account the constraint specied in the previous paragraphs. Regardless of the specic implementation details for each type of interface, we dened a generic API to be exposed for every actor or component that interacted with a monitor (see Figure 5.22). •initialize and updateRules are methods to be called by the component responsible for creating and conguring the monitor instance. These two methods will dene the active set of rules and thus determining the behaviour of the monitor.
5.3. Conclusions 83 Figure 5.21: ALIVE Monitoring Architecture § •subscribe is a method public to any component willing to receive certain notications from the monitor, by specifying a list of facts and an endpoint. This endpoint will be used by the monitor to asynchronously send the subscribed events back. The specic way of handling these notications will depend on the implementation of the interface. This method returns a session representing the subscription. •sendEvent can be used by a component to notify an event to the monitor. •cancelSubscription can be used by a component to remove the correspondent subscription and therefore indicating the wish to stop receiving notications. 5.3 Conclusions In this chapter we have presented a language for declaring norms, focusing on its adequacy for enabling governance capabilities in distributed systems, namely both SOA and multi-agent systems. We have done it incrementally, showing in the rst place how we designed a language specically tailored for compositions of web-services that are capable of communicating in the same domain and using the same behaviour protocols. This rst version of the language allows a high level of expressivity with respect
84 Chapter 5. Towards a lightweight language for norms Figure 5.22: Monitor generic interface § to regulative norms, by the use of deontic expressions. We have shown how such a language can be formally grounded. Later in the chapter, we have presented an evolution of the pure normative part of the language in the form of a meta-model, adding constitutive rules to the language and abstracting the language from specic domains and agent behaviours. The language in the latter form can be considered as lightweight enough for its use in dierent kinds of distributed systems, and therefore it is already suitable for describing norms. However, we still need to dene a operationalisation more tting for practical reasoning in real-time, and such operationalisation should include a formal grounding for the constitutive part. We have presented the monitoring architecture from an infrastructural perspective, but we have saved the details on the formalisation of the operationalisation for the following chapters: in Section 6.3 we will deal with the latter issue before concentrating on the full operational semantics in Section 6.4 and their implementation in Chapter 7.
CHAPTER 6 Formalising regulative and constitutive norms `Take nothing on its looks; take everything on evidence. There's no better rule.' Great Expectations Charles Dickens Until recently, most of the work on normative environments works with norm speci- cations that are static and stable, and which will not change over time. Although this may be good enough from the social (institutional) perspective, it is not appropriate from the agent perspective. During their lifetime, agents may enter and leave several interaction contexts, each with its own normative framework. Furthermore they may be operating in contexts where more than one normative specication applies. So we need mechanisms where normative specications can be added to the agents' knowledge base at run-time and be practically used in their reasoning, both to be able to interpret institutional facts from brute ones (by using constitutive norms to, e.g. decide if killing a person counts as murder in the current context) and to decide what ought to be done (by using regulative norms to, e.g. prosecute the murderer). Our proposal is to use production systems to build a norm monitoring mechanism that can be used both by agents to perceive the current normative state of their environment, and for these environments to detect norm violations and enforce sanctions. Our basic idea is that an agent can congure, at a practical level, the production system at run-time by adding abstract organisational specications and sets of counts-as rules. In our approach, the detection of normative states is a passive procedure consisting in monitoring past events and checking them against a set of active norms. This type of reasoning is already covered by the declarative aspect of production systems, so no additional implementation in an imperative language is needed. Using a forward- 85
92 Chapter 6. Formalising regulative and constitutive norms rather than with the identied norms1that make those propositions true or false. This issue is not banal, as it has implications on the operational level: in order to properly check norm compliance, norm instantiations have to be tracked in an individual manner, case by case. Figure 6.3: Norm lifecycle2 § We nd useful, at this point, to stress the fact that the lifecycles of a norm, and of a norm instance, should be dierentiated because they are dierent in essence. The lifecycle of a norm (see Figure 6.3) deals with its validity in the normative system: a norm is in force when it can be fully activated, monitored, and enforced; in transition when it is being removed and cannot be activated anymore, but the eects of past activations have to be tracked until their end; and deleted when the history of the norm is to be kept but it can have no further eect on the normative system. Therefore, such lifecycle is related to the concepts of promulgation, abrogation and derogation, out of the scope of this thesis3. On the other hand, the lifecycle of a norm instance deals with the fullment/violation of each particular instance. The concept of norm instance lifecycle has been treated by dierent authors, e.g. [Abrahams and Bacon 2002; Cardoso and Oliveira 2010; Fornara and Colombetti 2009; Oren et al. 2009], but with no real consensus. Taking those interesting elements that would allow the management of norms with the concepts of activation, maintenance, fullment and reparation, a suitable norm lifecycle would be similar to the one based on the automaton depicted in Figure 6.4. A norm instance gets activated due to a certain activating condition and starts in an (A)ctive state, but if at some point a certain maintenance condition is not fullled, the norm instance gets into a (V)iolation state. If the norm instance is (A)ctive and a certain discharge condition is achieved, the norm gets (D)ischarged4. Usually reparations are not treated explicitly, but in our proposal we add the concept for completeness. If a norm instance is (V)iolated, fullling a reparation condition can bring it back to the (A)ctive state, but if the discharge condition occurs 1From now on, we will denote such identied norms as norm instances. 2This diagram, as well as ones that will appear later in the chapter, follows the standard notation of the state diagrams, where the arrow pointing from anywhere indicates an initial state and a double circle indicates a nal state. 3Promulgation, abrogation and derogation of norms in a normative monitor are the main research issue that is tackled by Ignasi Gómez-Sebastià in his PhD thesis, which will be presented in January 2016. In the meantime the interested reader can check [Gómez-Sebastià and Alvarez-Napagao 2012]. 4Note here that we assume the discharge condition to eventually happen.
6.4. Formal Semantics 93 while violated, only by fullling the same reparation condition (VD state) can the norm instance be (D)ischarged. It might be the case that a (V)iolated norm instance never gets repaired, so for safety we use a timeout condition5to make sure the norm instance is not alive forever and thus mark those permanent violations as (F)ailures. Figure 6.4: Norm instance lifecycle with reparation and timeout handling § Once there is a norm life-cycle the question to answer is how to deal with it from an operational perspective. Abrahams and Bacon [Abrahams and Bacon 2002] solve this problem by means of occurrences of the predicates contained in the deontic operator, but there are cases in which this can be insucient, e.g., when the obligation denes a deadline or its instantiation depends on contextual information. More recently, some works have been advancing in the direction of tackling this issue. For example, by treating instantiated deontic statements as rst-class objects of a rule-based language [Cardoso and Oliveira 2009; Governatori 2005]. However, as these deontic statements are already implicitly identifying the norm instance, there is no explicit tracking of which elements of the domain are involved in fullling or violating. Other approaches declare the norm only at the abstract level and the tracking of the norm instance, and implicitly of the norm instance lifecycle, is purely done at the operational level [Alvarez- Napagao et al. 2011; Criado et al. 2010; Oren et al. 2009]. 6.4 Formal Semantics In this section we dene the semantics of institutions as the environment specifying the regulative and constitutive norms and then discuss the formal semantics of our regulative framework. The results of this formalisation will then be used in Chapter 7 to describe the details of how an institution evolves over time based on incoming events, and how this impacts the monitoring process. Through the rest of this chapter, we will use as an example the following simplied trac scenario: 5The timeout condition is evaluated as starting at the point of time of violation.
94 Chapter 6. Formalising regulative and constitutive norms 1. A person driving on a street is not allowed to break a trac convention. 2. In case (1) is violated, the driver must pay a ne. 3. In a city, to exceed 50kmh counts as breaking a trac convention. 6.4.1 Preliminary denitions In this section, we present a proposal for a deontic logic for support for norm instantiation via obligations parametrised by ve states (conditions). For the purpose of this formalization, we assume the use of a predicate based propositional logic language LOwith predicates and constants taken from an ontology O, and the logical connectives {¬,∨,∧}. The set of all possible well-formed formulas of LOis denoted as wff(LO)and we assume that each formula from wff(LO)is normalised in Disjunctive Normal Form (DNF). Formulas in wff(LO)can be partially grounded, if they use at least one free variable, or fully grounded if they use no free variables, i.e. only predicates and constants. In this chapter we intensively use the concept of variable substitution. We de- ne a substitution instance Θ = {x1←t1, x2←t2, ..., xi←ti}as the substitution of the terms t1, t2, ..., tifor variables x1, x2, ..., xiin a formula f∈wff(LO). Thus, Θ(f(x1, x2, ..., xi)) ≡f(t1, t2, ..., ti). We will denote as ϑ(wff(LO),S)the set of all possible substitution instances containing the variables in wff(LO)and the terms in S. We denote the set of roles in a normative system as the set of constants R, where R⊂O, and the set of participants as P, where each participant enacts at least one role according to the ontology O. As our aim is to build a normative monitoring mechanism that can work at real time, special care has been made to choose a norm language which, without loss of expresiveness, has operational semantics that can then be mapped into production systems. Based in our previous work and experience, our denition of norm in an extension of the abstract norm dened in the formalisation in Section 5.1.4 taking into account the ALIVE extensions of repair and timeout presented in Section 5.2.1: Denition 9 (Norm) We dene a norm nas a tuple n=hα, fA n, fM n, fD n, fR n, timeouti, where: •αis the agent obliged to comply with the norm, •fA nis the activating condition of the norm, •fM nis the maintenance condition of the norm, •fD nis the deactivation condition of the norm, •fR nis the repair condition of the norm, •timeout is a fully-grounded formula that represents the upper-bound waiting condition for the reparation of a violation, taken into account of only after a violation and not before, and •fA n, fM n, fD n, fR n, timeout ∈ L. 2
6.4. Formal Semantics 95 In order to create an optimal norm monitor it is important to know which norms are active at each point in time, as only those are the ones that have to be traced (inactive norms can be discarded from the monitoring process until they become active again). The activation condition fA nspecies when a norm becomes active. It is also the main element in the norm instantiation process: when the conditions in the activating condition hold, the variables are instantiated, creating a new norm instance6. The deactivating condition fD ndenes when the norm becomes inactive. The maintenance condition fM ndenes the conditions that, when no longer hold, lead to a violation of the norm. Finally, the repair condition fR nspecies when a norm instance stops being violated, as long as the timeout condition is not activated while the violation holds. An example of a norm for the trac scenario ("A person driving on a street is not allowed to break a trac convention") would be formalised as follows: n1 = hAg, {enacts_role(Ag, Driver)∧driving(Ag)}, {¬crossed-red(Ag, L)}, {¬driving(Ag)}, {fine-paid(100)}, time(500)i The activating condition states that each time an event appears where an individual enacting the Driver role drives (driving), then a new instance of the norm becomes active; the maintenance condition states that the norm will not be violated while no trac convention is violated; this norm has no deadline, it is to apply at all times an individual is driving; the norm instance deactivates when the individual stops driving7; the target of this norm is that we want drivers not breaking trac conventions; nally the subject of the norm is someone enacting the Driver role. It is important to note here that, although our norm representation does not explicitly include deontic operators, the combination of the activation, deactivation and maintenance conditions is as expressive as conditional deontic statements with deadlines as the ones in [Dignum et al. 2004]. It is also able to express unconditional norms and maintenance obligations (i.e. the obligation to keep some conditions holding for a period of time). To show that our representation can be mapped to conditional deontic representations, let us express the semantics of the norm in denition in terms of conditional deontic statements. Denition 10 (Deontic interpretation) The deontic interpretation of a norm n, is: OfR n≤timeout([α stit :fM n]fD n|fA n) 6One main dierentiating aspect of our formalisation is that we include variables in the norm representation and we can handle multiple instantiations of the same norm and track them separately. 7Although the norm is to apply at all times an individual is driving, it is better to deactivate the norm each time the individual stops driving, instead to keep it active, to minimise the number of norm instances the monitor needs to keep track at all times.
96 Chapter 6. Formalising regulative and constitutive norms 2 The syntax of the operator proposed is similar to the obligation operator from other deontic logics, such as dyadic deontic logic and semantics of deadlines, but with important dierences. While the ≤used for fR n≤timeout corresponds to the deadline semantics found e.g. in [Dignum et al. 2004] or [Governatori et al. 2007] (if timeout occurs, there is a permanent violation), the used in [α stit :fM n]fD nshould rather be read as [α stit :fM n]should hold at all times at least until fD n. Also, the conditional notation |used in dyadic deontic logic, which not always has clear semantics in terms of temporality, in the case of the operator proposed O(A|B)should be read as starting the moment Bhappens, Ashould happen rather than simply given B,Ashould happen8. Therefore, the expression shown in Denition 10 is informally read as: if at some point fA nholds, agent αis obliged to see to it that fM nis maintained until, at least, fD nholds; otherwise, αis obliged to see to it that fR nbefore timeout. Note that in this informal reading we are not dealing with norm instances yet. How we address this issue, along with the semantics of this obligation operator, will be explained in Section 6.4.2. Following the example: Ofine-paid(100)≤time(500)([Ag stit :¬crossed-red(Ag, L)] ¬driving(Ag)|driving(Ag)) informally read as: if at some point Ag is driving, Ag is obliged to see to it that no red light is crossed until, at least, Ag is not driving anymore; otherwise, Ag has to pay a ne of 100 before the time is 500. The semantics of this operator are presented in the rest of this section. We dene the state of the world stat a specic point of time tas the set of predicates holding at that specic moment, where st⊆O, and we will denote Sas the set of all possible states of the world, where S=P(O). We will call expansion F(s)of a state of the world sas the minimal subset of wff(LO)that uses the predicates in sin combination of the logical connectives {¬,∨,∧}. One common problem for the monitoring of normative states is the need for an interpretation of brute events as institutional facts, also called constitution of social reality[Grossi 2007]. The use of counts-as rules helps solving this problem. Counts-as rules are multi-modal statements of the form [c](γ1→γ2), read as in context c,γ1 counts-as γ2. In this thesis, we will consider a context as a set of predicates, that is, as a possible subset of a state of the world: Denition 11 (Counts-as rule) A counts-as rule is a tuple c=hγ1, γ2, si, where γ1, γ2∈ wff(LO), and s⊆O.2 A set of counts-as rules is denoted as C. Although the denition of counts-as in [Grossi 2007] assumes that both γ1and γ2can be any possible formula, in our framework we limit γ2to a conjunction of predicates for practical purposes. 8In some works in the literature, this is interpreted as given Band as long as Bhappens, Ashould happen, while in other works it is interpreted in a closer way to our reading
6.4. Formal Semantics 97 Denition 12 (Institution) Following the denitions above, we dene an institution as a tuple of norms, roles, participants, counts-as rules, and an ontology: I=hN, R, P, C, Oi2 An example of Ifor the trac scenario would be formalised as follows: N:={hAg, {enacts_role(Ag, Driver)∧driving(Ag)},{¬crossed-red(Ag, L)}, {¬driving(Ag)},{fine-paid(100)}, time(500)i} R:={Driver},P:={Person1} C:={hexceeds(D, 50), traffic_violation(D), is_in_city(D)i} O:={role, enacts_role, driving, is_in_city, exceeds, traffic_violation, paid_fine, Person1, role(Driver), enacts(P erson1, Driver)} 6.4.2 Norm fulllment and norm instance fulllment If we have to take into account the following issues9: 1. deontic statements do not express a norm, but rather the existence of a norm [Walter 1996]; and 2. in order to check the compliance of a norm, its particular instances must be tracked [Abrahams and Bacon 2002], then we need to dene the compliance of a norm based on the fulllment of each of its instantiations. That is, a norm has been complied up to a certain time tif, and only if, each one of the instantiations triggered in times ti< t have not been violated, where violated means that there has been ¬fM nbefore fD never happening. In order to work with instances, we dene a norm instantiation. A norm is dened in an abstract manner, aecting all possible participants enacting a given role. Whenever a norm is active, we will say that there is a norm instance nθfor a particular norm nand a substitution instance θ. Denition 13 (Norm instance) Given a norm nand a substitution set θ, we dene a norm instance nθas: nθ=hα, θ(fA n), θ(fM n), θ(fD n), θ(fR n), timeouti, where: •θ(fA n)is fully grounded, and •θ(fM n),θ(fD n),θ(fR n)may be fully or partially grounded. 2 The reason that θ(fM n),θ(fD n),θ(fR n)may be partially grounded is that the substitution instance that instantiates the norm that is, θsuch that θ(fA n)holds is considered in our model to be the sucient and necessary set of substitutions needed to fully ground fA n. It can be the case that the set of variables used in fM n,fR nand/or fD nis larger than the arity of θ. Let us suppose, for example, that the norm should be 9We have discussed these issues in more detail in Section 6.3.
98 Chapter 6. Formalising regulative and constitutive norms instantiated at all times while it is in force, regardless of any contextual condition: in that case, fA n=>. Therefore, we have to assume that a substitution instance θ0for fM n, fR nor fD nshould fulll: θ⊆θ0. 6.4.3 Semantics of LTL In Chapter 4, we motivated the need for a formalisation allowing for grounding in both monitoring and planning contexts to allow both institutional and individual reasoning towards norms, in a way that the products of both kinds of reasoning are coherent and consistent between themselves at a formal (deontic) level. While in Section 2.2 we saw that monitoring (verication of compliance) is usually formalised in dierent ways at distinct levels of complexity, the state of the art in planning is fairly more restricted. Popular high-level formalisms such as STRIPS, SOAR or HTN [Nau et al. 2003; Newell, Rosenbloom, and Laird 1987; Nilsson and Fikes 1970] are not expressive enough to deal with complex constraints mandatory for practical deontic reasoning such as temporal predicates. PDDL solves this issue [Fox and Long 2009; Gerevini and Long 2005] by explicitly adding the Linear Temporal Logic (LTL) operators. In the eld of research, PDDL is the most common language used in both formalisations and implementations, being the reference for benchmarks [Coles et al. 2012], and the capability of using temporal operators will prove decisive in order to build our formalisation. However, as we will see in Section 6.4.4, using LTL imposes some hard constraints. Unfortunately, there are no practical planners using temporal logics more complex than LTL such as CTL*, so these are constraints we will have to deal with. This is an approach also taken in related proposals in the context of socio-technical systems [Aldewereld, Dignum, and Meyer 2007; Riemsdijk et al. 2015]. In this section, we briey present the main concepts of LTL needed to build our formalisation upon. LTL is built up from a nite set of propositional variables AP, the logical operators ¬and ∨, and the temporal modal operators X and U. Formally, the set of LTL formulas over AP is inductively dened as follows: •if p ∈AP then p is a LTL formula; •if ψand φare LTL formulas then ¬ψ, φ ∨ψ, Xψ and φUψare LTL formulas. X is read as next and U is read as until. Sometimes, N is also used in place of X. Other than these fundamental operators, there are additional logical and temporal operators dened in terms of the fundamental operators to write LTL formulas succinctly. The additional logical operators, which can be derived by the primitive ones, are ∧,→,↔, true, and false. Following are the additional temporal operators. •G for always (globally) •F for eventually (in the future) •R for release •W for weakly until
6.4. Formal Semantics 99 An LTL model M= (S, <, π)consists of a non empty set Sof states, an accessibility relation <and an interpretation function πfor propositional atoms. A full path σin Mis a sequence σ=s0, s1, s2, . . . such that for every i≥0,siis an element of Sand si<si+1, and if σis nite with snits nal state, then there is no state sn+1 in Ssuch that sn<sn+1. We say that the full path σstarts at sif and only if s0=s. We denote the state siof a full path σ=s0, s1, s2, . . . in Mby σi. Validity M, s |=φ, of an LTL formula φin a world state sof a model M= (S, <, π)is dened as: •M, s |=p⇔s∈π(p) •M, s |=¬φ⇔not M, s |=φ •M, s |=φ∨ψ⇔M, s |=φor M, s |=ψ •M, σ, s |=Xφ⇔M, σ1|=φ •M, σ, s |=φUψ⇔ ∃n > 0such that (1) M, σn|=ψand (2) ∀i with 0≤i < n it holds that M, σi|=φ Validity on an LTL model Mis dened as validity in all states of the model. If φis valid on an LTL model Mwe say that Mis a model for φ. General validity of a formula φ is dened as validity on all LDL models. The logic LTL is the set of all general validities of LLT L over the class of LTL models. The additional temporal operators R, F, and G are dened as follows: •φRψ=¬(¬φU¬ψ) •Fψ= true U ψ •Gψ= false R ψ=¬F¬ψ 6.4.4 Norm lifecycle Although LTL as a formalism is suitable enough in terms of complexity for reductions to monitoring and planning scenarios, and therefore for practical reasoning from an institutional or individual perspective, there are intrinsic constraints that limit the expressiveness of the framework. More concretely, the norm instance lifecycle proposed in Figure 6.4 cannot be expressed in LTL. As proved in [Tauriainen 2006], in order to reduce an automata to an LTL expression and vice versa , such automata has to be free of loops that involve more than one state, i.e. only cycles that start and nish in the same state and involve no second state are allowed. This is an important constraint that prevents our model to have a loop between the (A)ctive and the (V)iolated states. In other words, if we want to use LTL, the lifecycle cannot have cycles that allow to go backwards. Therefore, for the purpose of our formalisation, we propose to adopt the more straightforward lifecycle shown in Figure 6.5. The main dierence with respect to the automata in Figure 6.4 is the handling of violations. As there is no way back to an (A)ctive state anymore, from a (V)iolation
100 Chapter 6. Formalising regulative and constitutive norms Figure 6.5: Self-loop alternating automata-based norm instance lifecycle § state there are only two options: either to repair the norm instance and subsequently (D)eactivate it, or mark it as a (F)ailure if it has not been dealt with for a given amount of time. From an operational perspective, this issue can be worked around by allowing the norm-aware system to create more instances of the same norm if an instance is violated before a deactivation. For an obligation to have a deontic eect, it is required that the activating condition actually happens at some future point. Additionally, either of the following three conditions should happen: •The activating condition never occurs so the norm never gets activated. •Always, between the activating and deactivation condition, the maintenance holds (reached deactivated state). •Maintenance condition holds up to a point where it becomes false and then a violation is permanently raised. In addition, the repair condition occurs later (reached deactivated state) before timeout is reached. In this way we approach most closely that the maintenance of θ(fM n)causes the ¬viol(nθ). Thus, the deontic eect of an obligation can be described by the causal eect between the maintenance condition and a violation in Denition 14. In order to give meaning to the fullment of a norm instance, we dene a specic operator Owith similar syntax to the abstract norm operator O. Let M={S, <, θ} be an LTL model (using a predicate set Lfor the formation of LTL formulas and with θas described in Section 6.4.1), π=< s0, s1, s2, . . . > a full path in M, and viol(nθ) a predicate belonging to Lrepresenting the violation of a norm instance nθ, we can establish the semantic relationship between the lifecycle of a norm instance and the fullment/violation of a norm as:
6.4. Formal Semantics 101 Denition 14 (Causal semantics for the operator O) M, π |=Oθ(fR n)≤timeout([α stit :θ(fM n)] θ(fD n)|θ(fA n)) ≡def M, π |=G¬θ(fA n)∧ ¬viol(nθ)∨ Fθ(fA n)∧[∀θ0:θ0(θ(fM n))U∃θ00 :θ00(θ(fD n))]∧G¬viol(nθ)∨ Fθ(fA n)∧[¬viol(nθ)U∃θ0:¬θ0(θ(fM n))]∧ θ0(θ(fM n))U¬θ0(θ(fM n)) ∧Gviol(nθ)∧(¬timeoutU∃θ00 :θ00(θ(fR n)))2 The rst line of the temporal formula says that the activating condition actually never happens and no violation is raised throughout the executional path. This case does not cause any change in the state of the system. The second line says that there exists some substitution for the activating condition in the future, and that always until a substitution raises an instance of the deactivation condition, the maintenance condition holds for all substitutions. No violation is raised throughout the executional path. This case terminates the norm in a state of deactivation (D). The rest of the lines in the formula imply that there exists some substitution for the activating condition in the future, and that at some later point a substitution makes the maintenance condition not hold, thus raising a violation (which remains thereafter). In addition, another substitution makes the repair condition happen at some future after the violation has occurred but before timeout occurs. The norm terminates in a state of deactivation (D). The failed state (F), in which the timeout has occurred without the norm having realised the repair condition after a violation, is not described in the formula, since it is an unwanted state and should be avoided. The lifecycle dened in Figure 6.5 can be seen as an transition automaton. Transition properties that dene how the norm changes its status while events (world changes that modify the predicates' truthness) are occurring can be easily extracted. We are interested in directly representing these transitions as it is useful when dealing with monitoring of norms' status (see Chapter 7). The four states active (A), viol (V), deactivated (D), failed (F) are described in Denition 15: Denition 15 (Norm lifecycle predicates) M, π |=Xactive(nθ)i M, π |= (Xθ(fA n)∨active(nθ)) ∧X6 ∃θ0:θ0(θ(fD n)) M, π |=Xviol(nθ)i M, π |=active(nθ)∧X6 ∃θ0:θ0(θ(fM n)) M, π |=Xdeactivated(nθ)i (M, π |=active(nθ)∧X∃θ0:θ0(θ(fD n))) ∨(M, π |=viol(nθ)∧X∃θ0:θ0(θ(fR n))) M, s |=Xfailed(nθ)i M, s |=viol(nθ)∧Xtimeout
108 Chapter 7. Normative monitor Event processed: ei=hα, pi hhhi, s, as, vs, ds, fsi, eii, ei+1iehhi, s ∪ {p}, as, vs, ds, fsi, ei+1i(7.6) Counts-as rule activation: ∃Θ,∃f∈F(s),∃hγ1, γ2, sii ∈ C, si⊆s∧Θ(γ1)≡f∧Θ(γ2)/∈s hhhN, R, P, C, Oi, s, as, vs, ds, fsi, eica hhhN, R, P, C, Oi, s ∪ {Θ(γ2)}, as, vs, ds, fsi, ei(7.7) Counts-as rule deactivation: ∃Θ,∃f∈F(s),∃hγ1, γ2, sii ∈ C, si6⊆ s∧Θ(γ1)≡f∧Θ(γ2)∈s hhhN, R, P, C, Oi, s, as, vs, ds, fsi, eica hhhN, R, P, C, Oi, s − {Θ(γ2)}, as, vs, ds, fsi, ei(7.8) Norm instantiation: ∃n=hα, fA n, fM n, fD n, fR n, timeouti ∈ N∧ ¬∃n0∈N, Θi/∈is ∧ ∃Θ,∃f0∈F(s), f0≡Θ(fA n) hhhN, R, P, C, Oi, s, as, vs, ds, fsi, eini hhhN, R, P, C, Oi, s, as ∪ {hn, Θi}, vs, ds, fsi, ei(7.9) Norm instance violated: ∃n=hα, fA n, fM n, fD n, fR n, timeouti ∈ N∧ hn, Θ0i ∈ as ∧ hn, Θ0i/∈vs∧ ¬(∃Θ,∃f0∈F(s), f0≡Θ(fM n)∧Θ⊆Θ0) hhhN, R, P, C, Oi, s, as, vs, ds, fsi, einv hhhN, R, P, C, Oi, s, as − {hn, Θ0i}, vs ∪ {hn, Θ0i}, ds, fsi, ei (7.10) Norm instance deactivated by fullment: ∃n=hα, fA n, fM n, fD n, fR n, timeouti ∈ N∧ hn, Θ0i ∈ as ∧ ∃Θ,∃f0∈F(s), f0≡Θ(fD n)∧Θ⊆Θ0 hhhN, R, P, C, Oi, s, as, vs, ds, fsi, einf hhhN, R, P, C, Oi, s, as − {hn, Θ0i}, vs, ds ∪ hn, fs, Θ0ii, ei (7.11) Norm instance deactivated by reparation: ∃n=hα, fA n, fM n, fD n, fR n, timeouti ∈ N∧ hn, Θi ∈ vs ∧ ∃Θ0,∃f∈F(s), f ≡Θ0(fR n)∧Θ0⊆Θ hhhN, R, P, C, Oi, s, as, vs, ds, fsi, einr hhhN, R, P, C, Oi, s, as, vs − {hn, Θi}, ds ∪ {hn, Θi}, fsi, ei (7.12) Norm instance failed: ∃n=hα, fA n, fM n, fD n, fR n, timeouti ∈ N∧ hn, Θi ∈ vs ∧ hn, Θi/∈fs ∧timeout hhhN, R, P, C, Oi, s, as, vs, ds, fsi, einf hhhN, R, P, C, Oi, s, as, vs − {hn, Θi}, ds, fs ∪ {hn, Θi}i, ei (7.13) Figure 7.2: Inference rules for the transition relation § The implementation of rule-based norm operationalisation has already been explored in previous research [García-Camino, Noriega, and Rodríguez-Aguilar 2005; Paschke, Dietrich, and Kuhla 2005; Vázquez-Salceda and Alvarez-Napagao 2009], but these proposals are either not yet implemented in a real system or not using a high enough level of norm abstraction. Some recent approaches [García-Camino et al. 2009] dene specic norm-oriented programming languages that treat norms as rules of a production system. However, such an approach requires for an special production system.
7.2. Formal reduction to production systems 109 We solve this issue by combining the normative language presented in Section 5.1 with a reduction to a representation with clear operational semantics based on the framework in Section 6.4. This framework uses logic conditions that determine the state of a norm (active, fullled, violated). These conditions can be expressed in rstorder logic and can be directly translated into LHS parts of rules, with no special adaptation needed. The implementation of the operational semantics in a production system to get a practical normative reasoner is thus straightforward. This allows agents for dynamically changing its organisational context at any moment, by feeding the production system with a new abstract organisational specication. 7.2.1 Reduction In order to formalise our Normative Monitor as a production system, we will need to dene several predicates to bind norms to their conditions: activation,maintenance, deactivation, and to represent normative state over norm instances: violated,instantiated, failure, and fullled. We will also use a predicate for the arrival of events: event. For the handling of the DNF clauses, we will use the predicates holds and has_clause. Denition 21 (Production system predicates) The set of predicates for our production system, for an institution I=hN, R, P, C, Oi, is: PI:= O∪ {activated, maintained, deactivated, violated, instantiated, fulfilled, event, timeout, failed, holds, has_clause, countsas} 2 The initial working memory WM0should include the institutional specication in the form of the formulas included in the counts-as rules and the norms in order to represent the possible instantiations of the predicate holds, through the use of the predicate has_clause. First of all, we need to have the bindings between the norms and their formulas available in the working memory. For each norm n=hα, fA n, fM n, fD n, fR n, timeouti, these bindings will be: WMn:= {activation(n, fA n), maintenance(n, fM n), deactivation(n, fD n), timeout(n, timeout)} As we assume the formulas from wff(LO)to be in DNF form: Denition 22 (DNF clause holding true) We can interpret a formula as a set of conjunctive clauses f={f1, f2, ..., fN}, of which only one of these clauses fiholding true is necessary for f holding true as well: rh:= has_clause(f, f0)∧holds(f0,Θ) ⇒ ∅,{holds(f, Θ)}2
110 Chapter 7. Normative monitor For example, if f= (p1(x)∧p2(y)∧... ∧pi(z)) ∨... ∨(q1(w)∧q2(x)∧... ∧qj(y)), then the initial facts to be in WM0will be: WM0:= Sf0∈fhas_clause(f, f0) = {has_clause(f, f1), ..., has_clause(f, f2)} Also, we have to include the set of repair norms by the use of the predicate repair, and the counts-as denitions by the use of the predicate countsas. Denition 23 (Initial working memory) The initial working memory WMIfor an institution I=hN, R, P, C, Oiis: WMI:= Sn∈N n;n0repair(n, n0)∪ Sn=hα,fA n,fM n,fD n,fR n,timeouti∈N(WMn∪ WMfA n∪ WMfM n∪ WMfD n)∪ Sc=hγ1,γ2,si∈C({countsas(γ1, γ2, s)} ∪ WMγ1∪ WMs) 2 The rule for the detection of a holding formula is dened as rhc f=dfe ⇒ ∅,{holds(f, σ)}, where we denote as dfethe propositional content of a formula f∈ wff(LO)which only uses predicates from Oand the logical connectives ¬and ∧, and σas the substitution set of the activation of the rule. Following the previous example: rhc f1=p1(x)∧p2(y)∧... ∧pi(z)⇒ ∅,{holds(f1,{x, y, z})} rhc f2=q1(w)∧q2(x)∧... ∧qi(y)⇒ ∅,{holds(f2,{w, x, y})} Similarly as in Denition 23: Denition 24 (Institutional reality) The set of rules Rhc Ifor detection of holding formulas for an institution I=hN, R, P, C, Oiis: Rhc I:= Sn=hα,fA n,fM n,fD n,fR n,timeouti∈N(Sf∈{fA n,fM n,fD n}rhc f)∪Sc=hγ1,γ2,si∈C(Sf∈γ1rhc f)2 By using the predicate holds as dened above, we can translate the inference rules described at the beginning of this chapter. Please note that the rules are of the form p, c ⇒r, a as shown in Section 2.2.2. However, as we only need the cpart to create a constraint proposition in the rules for norm instance violation and fulllment, cis omitted except for these two particular cases. Denition 25 (Translated rules for the transition relation2) Rule for event processing (7.6): re=event(α, p)⇒ ∅,{dpe} Rule for counts-as rule activation (7.7): rca =countsas(γ1, γ2, c)∧holds(γ1,Θ) ∧holds(c, Θ0)∧ ¬holds(γ2,Θ) ⇒ ∅,{Θ(dγ2e)} Rule for counts-as rule deactivation (7.8): rcd =countsas(γ1, γ2, c)∧holds(γ1,Θ) ∧ ¬holds(c, Θ0)∧holds(γ2,Θ) ⇒ {Θ(dγ2e)},∅ Rule for norm instantiation (7.9): 2See Figure 7.1.
7.3. Implementations 111 rni =activation(n, f)∧holds(f, Θ) ∧ ¬instantiated(n, Θ) ∧ ¬repair(n0, n) ⇒ ∅,{instantiated(n, Θ)} Rule for norm instance violation (7.10): rnv =instantiated(n, Θ) ∧maintenance(n, f)∧ ¬holds(f, Θ0)∧repair(n, n0), ∀Θ0,Θ0⊆Θ ⇒ {instantiated(n, Θ)},{violated(n, Θ), instantiated(n0,Θ)} Rule for norm instance fulllment (7.11): rnd =deactivation(n, f)∧instantiated(n, Θ) ∧subseteq(Θ0,Θ) ∧holds(f, Θ0), Θ0⊆Θ ⇒ {instantiated(n, Θ)},{fulfilled(n, Θ)} Rule for norm instance violation repaired (7.12): rnr =violated(n, Θ) ∧repair(n, n0) ⇒ {fulfilled(n, Θ)},{violated(n, Θ)} Rule for norm instance violation failed (7.13): rnr =violated(n, Θ) ∧timeout(n) ⇒ {failed(n, Θ)},{violated(n, Θ)}2 Denition 26 (Set of institutional rules) Following Denitions 22,24 and 25, the set of rules for an institution I=hN, R, P, C, Oiare: RI:= Rhc I∪ {rh, re, rca, rcd, rni, rnv, rnd, rnr, rnf }2 Denition 27 (Institutional production system) The production system PSIfor an institution Iwill be, from Denitions 21,23 and 26: PSI:= hPI,WMI,RIi2 7.3 Implementations There are several production system implementations available, some of them widely used by the industry, such as Jess,Drools,Soar or Prova. In most of these systems rules are syntactically and semantically similar, so switching from one to the other would be quite simple. As production systems dynamically compile rules to ecient structures, they can be used as well to validate and verify the consistency of the norms. A prototype of our normative reasoner has been implemented as a Drools program. Drools is an open-source Object-Oriented rule engine for declarative reasoning in Java [JBoss Drools Business Rules, http://www.jboss.org/drools], supported by the JBoss Community. Its rule engine is an implementation of the forward chaining inference Rete algorithm. Concepts are imported from standardised Description Logic owl-dl ontologies into Java objects [Zimmermann 2009]. The use of Java objects inside the rule engine allows for an easier communication of concepts with the agent reasoning, the core of which is also implemented in Java. In Drools we can represent facts by adding them to the knowledge base as objects of the Predicate class. Predicates are dynamically imported from standardised Description Logic owl-dl ontologies into Java objects using the OWL2Java tool[Zimmermann 2009], as subclasses of a specically designed Predicate class. The following shows an
112 Chapter 7. Normative monitor example of the insertion of Mayor(a)into the knowledge base to express that a(represented as object obj3of the domain) is in fact a mayor. Object obj3 = new Object(); ksession.insert(obj3); ksession.insert(new Mayor(obj3)); In Drools we can represent facts by adding them to the knowledge base as objects of the class Predicate. The following shows an example of the insertion of Mayor(a) into the knowledge base to express that a(represented as object aof the domain) is in fact a mayor. ksession.insert(new Mayor(a)); The Predicate class is designed specically for our implementation and is the superclass of every predicate in the system. We use this abstraction as a basis to reason about norms with Drools. 7.3.1 Handling of constitutive contexts We implement the concept of Context as a subclass of Predicate, asserting its instances into the knowledge base: ksession.insert(Context.CAR_CRASH); ksession.insert(Context.FLOODING); ksession.insert(Context.UNIVERSAL); Dening contexts as concepts in the knowledge base allows us to also refer to them explicitly and reason about them. This is an important advantage over implementations where contexts are mere labels on the counts-as relations between concepts. In order to dene the proper classicatory counts-as in a specic context, the predicate ClassicatoryCountsAs is introduced. This predicate allows for the expression of classicatory relations between classes with respect to a context. ksession.insert( new CountsAs( VerbalOK.class, Inform.class)); new CountsAs( PdaOK.class, Inform.class)); new CountsAs( PdaOK.class, TraceableInform.class)); Figure 7.3: Denition of classicatory counts-as rules. § The expressions of Figure 7.3 show two examples of the classicatory counts-as, where the statements respectively describe that, in the universal context, a verbal OK counts-as an inform, and a PDA OK counts as both an inform and a traceable inform.
7.3. Implementations 113 Figure 7.4, on the other side, shows the proper classicatory counts-as for the example. In this case, and following the example of crisis management presented in Section 6.1, each counts-as refers to dierent contexts: an inform counts-as a proper inform in a car crash scenario, but in a ooding scenario a traceable inform counts-as a proper inform. ksession.insert( new ClassificatoryCountsAs( Inform.class, ProperInform.class, Context.CAR_CRASH)); new ClassificatoryCountsAs( TraceableInform.class, ProperInform.class, Context.FLOODING)); Figure 7.4: Denition of proper classicatory counts-as rules. § To implement the uniqueness criterium specied in Section 6.2.3, which allows for more ecient runtime use of the counts-as rules, we implemented translation into Drools rules to create internal parallel sets of contexts (based on the intuitions expressed in gures 6.1 and 6.2 in Section 6.2.3). The rst rule of Figure 7.5 shows how this splitting is done, while the second rule of Figure 7.5 gives an example of how one can identify in which (original) context a counts-as rule was formulated. Figure 7.6 then shows an example of the context splitting. From three counts-as rules, of which two of them are the same for two dierent contexts, the result will be two contexts. The rst rule of the example expresses that ambulances count as a means of evacuation in the context of grip-2; the second expresses that ambulances also count as a means of evacuation in the context of grip-3; the third rule expresses that in the context of grip-3 army trucks also count as a means of evacuation. After the splitting of contexts grip-2 and grip-3 containing just these three rules we end up with two contexts, namely the context which contains the rules that are present in both grip-2 and grip-3 (ambulances count as means of evacuation), and the context which gives the renement of being in context grip-3, namely that army trucks also count as means of evacuation. The result being the GRIP2GRIP3 context containing the rule about ambulances being evacuation means (now unique, as there is no need to specify it twice) and the GRIP3 context containing only the rule specifying that army trucks are evacuation means. As explained in Section 6.2.3, this split allows for an easy and ecient means
114 Chapter 7. Normative monitor rule "creation of running contexts" when ClassificatoryCountsAs(a : c1, b : c2) and lc : TreeSet() from collect( ClassificatoryCountsAs(c1 == a, c2 == b)) then RunningContext rc; rc = new RunningContext(lc); insertLogical(rc); end rule "identify running contexts" when cca : ClassificatoryCountsAs(c : context) and rc : RunningContext(countsas contains cca) then insertLogical( new RunningContextIdentifier(rc, c)); end Figure 7.5: Context splitting. § to check the similarities and dierences between the contexts grip-2 and grip-33. The internal eect of a context activation is the activation of all its shared contexts (see Figure 7.7). With the contexts active, their counts-as rules will be instantiated as active counts-as rules in the rule engine. The counts-as rules are red whenever there is a matching predicate. The eect of a red counts-as rule is that for each instance of the rst predicate of the rule, a new instance of the second predicate of the rule is created. Closure is provided in the monitor by automatically detecting which context should be active based on the active counts-as rules. Figure 7.8 shows the rules implemented for this purpose. The rst rule detects if all the proper classicatory counts-as rules for a certain shared context are instantiated, in which case that shared context will be activated automatically. The second rule checks if all the shared contexts that belong to a user dened context are active, in which case the context will be activated. By using these rules we can identify the concept of a context (like grip-2) with the counts-as rules related to that context. Having this constitutive relation between a context and the counts-as rules available we can now also handle the following scenario of the crisis management. 3Note that in this example grip-3 ended up as a subcontext of grip-2 because of the limited scope of the example. In reality, there are other dierences between these contexts which would show that they instead overlap.
7.3. Implementations 115 ksession.insert( new ClassificatoryCountsAs( Ambulance.class, MeansOfEvacuation.class, Context.GRIP2)); ksession.insert( new ClassificatoryCountsAs( Ambulance.class, MeansOfEvacuation.class, Context.GRIP3)); ksession.insert( new ClassificatoryCountsAs( ArmyTruck.class, MeansOfEvacuation.class, Context.GRIP3)); (after kession.fireAllRules()) [GRIP2GRIP3, GRIP3] Figure 7.6: Example of context splitting. § Suppose the hospital has to be evacuated due to a ooding. There are not enough ambulances available to evacuate all people in time. The commander (chief medic at the location) checks to see what can be done. He can use (special) army trucks. However, army trucks do not (in general) count-as ambulances. The commander can check (with the Drools implementation) that army trucks count-as ambulances in the context of grip-3. (They are part of constituting grip-3). So, the commander decides to move to the context of grip-3. Now he has to check what other rules constitute grip-3. One of them states that in grip-3 the mayor counts-as commander. This means that the commander has to transfer his command to the mayor. Moreover, in a ooding scenario, as stated previously, only a traceable inform counts-as an appropiate inform. That means that all agents should be aware of the new context and act accordingly, being forced to adapt to a traceable informing mechanism if they were not using it. The scenario shows that we need the context as an explicit concept and also we need the constitutive aspect of the counts-as rules that dene the context in order for the commander to be able to dene a switch to another context (grip level) and realizing the consequences of this switch. The Drools implementation presented above enables us to do this. 7.3.2 Monitoring of regulative norms Drools programs can be initialised with a rule denition le. However, its working memory and rule base can be modied at run-time by the Java process that is running the rule engine. We take advantage of this by keeping a xed base, which is a le with
116 Chapter 7. Normative monitor rule "activate running contexts" when ContextActive(c : context) and RunningContextIdentifier( rc : runningContext, context == c) then insertLogical(new RunningContextActive(rc)); end rule "classificatory counts-as" when rc : RunningContextActive( ca : ClassificatoryCountsAs( y1 : c1, y2 : c2)) and obj : Predicate(class == y1) then insertLogical(new CountsAs(y1, y2)); end rule "counts-as" when c : CountsAs(y1 : c1, y2 : c2) and obj : Predicate(class == y1) then Predicate instance; instance = (Predicate)( ((Class)y2).newInstance()); instance.setObject(obj.getObject()); insertLogical(instance); end Figure 7.7: Activation of counts-as rules. § xed contents implementing the rules from Denition 22 and 25, which are independent of the institution, and having a parser for institutional denitions that will feed the rules from Denition 24, which are dependent on the institution (see Figure 7.12). The institutional denitions we currently use are based on an extension of the XML language presented in Section 5.2.1. The base rules (see Denitions 22 and 25) have been quite straightforward and the translation is almost literal. The contents of the reusable Drools le is shown in Figure 7.9. The last rule of the Figure is the declarative implementation of the predicate SubsetEQ to represent the comparison of substitutions instances Θ⊆Θ0, needed for the cases of norm instance violation and fulllment. In our implementation in Drools, substitution instances are implemented as Set<Value>objects, where Value is a tuple
7.4. Conclusions 117 rule "activate running context" when rc : RunningContext(cal : countsas) and forall( ca : ClassificatoryCountsAs(a : c1, b : c2) from cal CountsAs(c1 == a, c2 == b)) then insertLogical(new RunningContextActive(rc)); end rule "activate context by its running contexts" when c : Context() and forall( RunningContextIdentifier( rc : runningContext, context == c) RunningContextActive(runningContext == rc) ) then insertLogical(new ContextActive(c)); end Figure 7.8: Automatic activation of contexts. § hString, Objecti. The rest of the rules (see Denitions 24) are automatically generated from the institutional specications and inserted into the Drools rule engine. An example of two generated rules for the trac scenario is shown in Figure 7.10. The initial working memory is also automatically generated by inserting objects (facts) into the Drools knowledge base following Denition 23. An example for the trac scenario is also shown in Figure 7.11. Please note that this is not an output of the parser, but a representation of what it would execute at run-time. The resulting architecture is depicted in Figure 7.12. 7.4 Conclusions In this chapter we have shown a concrete implementation of abstract norms that can be used by agents to reason about social reality. One of the key issues of connecting norms to concrete actions to be taken is that we need (at least) two uses of the countsas relation. One to connect brute facts (or events) to institutional states and actions.