Skip to content

moise-lang/npl

Repository files navigation

NPL

Normative Programming Language (NPL) is a language to program norms for multi-agent systems. The language allows us to write norms as follows:

norm n1
    :  vl(5) & play(alice,boss)
    -> obligation(alice, play(alice,boss), vl(0), `4 seconds`).

that can be read as ``whenever vl(5) & play(alice,boss), Alice is obliged to bring about vl(0) in 4 seconds. If play(alice,boss) ceases to hold, the obligation is dropped.'' The life cycle of obligations can be seen here. More details are found in papers describing the language (folder publications) and later in this document.

The folder examples contains Java programs that illustrates how to use the interpreter of NPL.

This language is used to implement the organisational platform for Moise, called ORA4MAS, that is integrated into the JaCaMo project.

Installation

Some built releases are available at GitHub. To build NPL from the source code, use the following commands:

git clone https://github.com/moise-lang/npl.git
cd npl
./gradlew build

To run the examples:

./gradlew example0
./gradlew example1
...
ScreenShot

Norms

Let’s have a brief introduction to norms in NPL.

The syntax for a norm that creates obligations is:

norm <id>
   : <when>
  -> obligation(<who>, <while>, <what>, <deadline>)
     [if fulfilled: <sanction-rules>]
     [if unfulfilled: <sanction-rules>]
     [if inactive: <sanction-rules>]
  .

Informal semantics: As soon as <when> is true, an obligation for <who> is created and its initial state is active (see states). As soon as <what> is true, the obligation is fulfilled. As soon as <while> is false, the obligation is inactive. As soon as <deadline> is true, the obligation is unfulfilled. The deadline can be a temporal expression as 2 seconds after active or a state condition as full(room) (in the sense ``is obliged to …​ before the room is full").

When the obligation is in a final state (fulfilled, unfulfilled, or inactive), sanction rules, if specified, are evaluated (example).

The syntax for sanction rules is:

sanction-rule <id>(<args>)
   : <condition>
  -> sanction(<agent>,<description>).

that means ``if <condition> holds, a sanction <description> for <agent> is created. NPL just produces the sanction facts, its implementation is done by some agent, by the environment, …​

NPL also provides a special type of norm that produces failures (useful for regimentation of norms). A failure means an unacceptable set of facts that should be reverted. The syntax:

norm <id>
   : <condition>
  -> fail(<description>).

NPL Interpreter

The task of the NPL interpreter is to read facts (e.g., from environment, institution, …​) and produce new (normative) facts. At runtime, facts should be provided for interpreter and the current set of produced facts can be consulted.

Facts are used to evaluate <conditions>, <while>, <what>, <deadline>, …​ expressions in norms and sanction rules.

Facts produced by NPL interpreter are:

  • obligations, permissions, and prohibitions for agents as the result of activation of norms. For example obligation(bob,in_room(bob),present(paper),23h00).

  • fulfillments and unfulfillments as the result of obligations being in a final state. For example unfulfilled(obligation(bob,in_room(bob),present(paper),23h00))

  • sanctions as the result of sanction rules. For example: sanction(fine(bob,100)).

  • failures as the result of activation of norms. For example fail(in(bob,room)).


Developed by Jomi F. Hubner, Rafael H. Bordini, and Olivier Boissier.

About

Normative Programming Language (NPL). A language to program norms for multi-agent systems

Resources

License

Stars

Watchers

Forks

Packages

No packages published