• No results found

Implementation Rules for Norm Lifecycle

4.6 Planning with Norms

5.2.3 Implementation Rules for Norm Lifecycle

In order to implement the normative reasoner, we need to be able to represent each norm’s lifecycle inside the planning domain, in such a way that at every state each of the properties of Definition5.4 are calculated, for each norm (and the instances that come to life). As already explained, PDDL planning domains consist of definitions of actions that represent the agent’s capabilities and modify the domain predicates by adding and deleting facts.

The idea here therefore is to express the properties of Definition 5.4 as predicates within the planning domain. By looking at the rules of the definition, it can be seen that some predicates are expressed in terms of the properties of the current state as well as the previous state. This means that they cannot be directly translated to PDDL predicates, since PDDL only permits each standard domain predicate to have its value calculated over the values of the predicates in the previous state. Therefore, some modifications are necessary. We will modify the rules by creating two types of rules that can be expressed in the planning domain either as derived predicates, or as

5We remind the reader at this stage that the final layer of norms would have the maintenance condition

set as true, since sequential violations should lead to some final repair norm that must always be complied with.

traditional domain predicates. The former will depend on the current state, while the latter will depend only on the previous state.

We choose rules (i),(ii) and (iv) of Definition 5.4 as a sufficient set to implement. This is because active appears in the definition of the normative planning problem (as described in Section5.2.2) and viol and prev viol are the predicates that might appear in the activating condition of a repair norm.

In addition to rules (i),(ii) and (iv) of Definition5.4, we define the predicates inactive, complied with and prev active to facilitate our implementation6. Then, we will have: By splitting Definition5.4(i) we get:

(((ααα111)) h) π, i, θi |=active(pnθαq)ifhπ, i, θi |= (fnA∨prev active(pnθαq))∧ 6 ∃θ0: θ0fnD

and

(((ααα222)) h) π, 0, θi |= ¬prev active(pnθαq)

hπ, i, θi |=prev active(pnθαq)ifhπ, i−1, θi |=active(pnθαq) for i>0

We define inactive as:

(((bbb))) hπ, i, θi |=inactive(pnθαq)ifhπ, i, θi |= ¬active(pnθαq)

We keep Definition5.4(ii)as is:

(((ccc))) hπ, i, θi |=viol(pnθαq)ifhπ, i, θi |=active(pnθαq)∧ 6 ∃θ0: θ0fnM

We define complied with as:

(((ddd))) hπ, i, θi |=complied with(pnθαq)ifhπ, i, θi |= ¬viol(pnθαq)

From Definition5.4(iv)we get:

(((eee))) hπ, 0, θi |= ¬prev viol(pnθαq)

hπ, i, θi |=prev viol(pnθαq)ifhπ, i−1, θi |=viol(pnθαq) for i>0

It can be seen that(((ααα111))), (((bbb))),(((ccc))) and(((ddd))) will be implemented as derived predicates,

whereas(((ααα222)))and(((eee)))as standard predicates. As already explained, derived predicates

cannot appear negated in another derived predicate condition or in an action precon- dition or the goal. Therefore, with the appropriate substitutions, rules(((ααα111))),(((bbb))),(((ccc))), 6The main reason for defining these predicates is the fact that, as mentioned earlier, derived predicates

are not allowed to appear negated in action conditions and other predicates. Since in our rules some do appear negated, we need to define the negated version of them as a separate derived predicate.

(((ddd)))will become:

(((ααα011010))) hπ, i, θi |=active(pnθαq)ifhπ, i, θi |= (fnA∨prev active(pnθαq))∧ 6 ∃θ0: θ0fnD

(((bbb000))) hπ, i, θi |=inactive(pnθαq)ifhπ, i, θi |= ¬((fnA∨prev active(pnαθq))∧ 6 ∃θ0: θ0fnD)

(((ccc000))) hπ, i, θi |=viol(pnθαq)ifhπ, i, θi |=active(pnαθq)∧ 6 ∃θ0: θ0fnM

(((ddd000))) hπ, i, θi |=complied with(pnθαq)ifhπ, i, θi |=inactive(pnαθq) ∨ ∃θ0: θ0fnM

Now (((ααα010101))), (((bbb000))), (((ccc000))) and (((ddd000))) can be directly implemented as derived predicates in

PDDL. Since (((ααα222))) and (((eee))) depend on the previous state, they are implemented as

standard domain predicates added to the effects of every action. The first part of(((ααα222)))

and(((eee)))is redundant in PDDL, as by default all predicates are false in the initial state, unless stated otherwise. The second part of each of the two rules is then expressed as follows:

(((ααα200202))) hπ, i−1, θi |=active(pnθαq) ⇒ hπ, i, θi |=prev active(pnθαq) for i>0

hπ, i−1, θi |=inactive(pnθαq) ⇒ hπ, i, θi |= ¬prev active(pnθαq) for i>0

(((eee000))) hπ, i−1, θi |=viol(pnθαq) ⇒ hπ, i, θi |=prev viol(pnθαq) for i>0

hπ, i−1, θi |=complied with(pnθαq) ⇒ hπ, i, θi |= ¬prev viol(pnθαq) for i>0

Therefore, we have now ready the full set of rules (((ααα01,21,201,20 )))-(((eee000))) to be implemented in

PDDL. This is seen in Table 5.2. The way these are implemented within the plan- ning domain is as follows: For each norm (both primary and repair), a separate, norm-specific predicate (made distinct by the addition of the norm name at the end) active, inactive, complied with, prev active, viol, prev viol is defined. For (repair) norms where the maintenance condition is true, predicates viol, complied with and prev viol are omitted, since their values can be pre-calculated through the rules as false, true and false respectively.

For each norm, rules(((ααα101001))),(((bbb000))),(((ccc000))),(((ddd000)))are expressed through a derived predicate in

the planning domain, expressing the conditions fnA, fnM and fnD in PDDL terms7. An example of the representation of the viol predicate of rule(((ccc000)))for norm1 of the pizza delivery example as the derived predicate viol norm1 can be the following:

1 (:derived (viol_norm1 ?p -person ?v -vehicle) (and (active_norm1 ?p ?v)

3 (not (not (exists (?main -street ?street1 -street ?street2 -street) (and (movedBetweenJunctions ?v ?main ?street1 ?street2)

5 (not (connection ?main ?street1 ?street2)))))) ))

7Such a translation should be straightforward in PDDL 2.1 where all the necessary elements such as

As derived predicates:

(α10)

(α01)

(α01) hπ, i, θi |=active(pnθαq)ifhπ, i, θi |= (fnA∨prev active(pnθαq))∧ 6 ∃θ0: θ0fnD

(b0) (b0)

(b0) hπ, i, θi |=inactive(pnθαq) if hπ, i, θi |= ¬((fnA∨prev active(pnθαq))∧ 6 ∃θ0 : θ0fnD) (c0) (c0) (c0) hπ, i, θi |=viol(pnθαq)ifhπ, i, θi |=active(pnθαq)∧ 6 ∃θ0: θ0fnM (d0) (d0)

(d0) hπ, i, θi |=complied with(pnθαq)ifhπ, i, θi |=inactive(pnθαq) ∨ ∃θ0 : θ0fnM

As domain predicates:

(α20)

(α02)

(α02) hπ, i−1, θi |=active(pnθαq) ⇒ hπ, i, θi |=prev active(pnθαq) for i>0

hπ, i−1, θi |=inactive(pnθαq) ⇒ hπ, i, θi |= ¬prev active(pnθαq) for i>0

(e0) (e0)

(e0) hπ, i−1, θi |=viol(pnθαq) ⇒ hπ, i, θi |=prev viol(pnθαq) for i>0

hπ, i−1, θi |=complied with(pnθαq) ⇒ hπ, i, θi |= ¬prev viol(pnθαq) for i>0

Table 5.2: PDDL domain implementation rules

Additionally, for each norm, rules(((ααα202020))),(((eee000)))are implemented by a domain predicate,

the value of which will be passed from one state to another through the respective rule. Since a domain might include several actions that pass the system from one state to another, each action should contain the norm’s rules in its effects (followed by the obvious and connector). An example of the representation of the prev active predi- cate of rule (((ααα200220))) for norm1 of the pizza delivery example as the domain predicate

prev active norm1inside any action’s effects can be the following:

(forall (?p -person ?v -vehicle)

2 (when (active_norm1 ?p ?v) (prev_active_norm1 ?p ?v))) (forall (?p -person ?v -vehicle)

4 (when (inactive_norm1 ?p ?v) (not (prev_active_norm1 ?p ?v))))

At this point we would like to focus on an issue that occurs when applying the rules with a repair norm. As stated, a repair norm nr = hr, fA

nr, fnrM, fnrDi would con-

tain viol(nθ

α)∧¬prev viol(n θ

α) in its activating condition f A

nr, to indicate that an instance

might get activated whenever there is a violation of a norm n and the norm n was not being violated before. The problem with this activating condition is that the viol predicate that it contains, which is defined as a derived predicate, cannot appear in rule(((bbb000)))as part of the activating condition, since the activating condition fnrAis part of a negated formula. The solution to this is to substitute the activating condition in rule

(((bbb000)))as follows:

hπ, i, θi |=inactive(pnrθ αq)if

(from(((bbb000))))

hπ,i,θi |= ¬((fnrA∨prev active(pnrθαq))∧ 6 ∃θ 0: θ0fD

nr)if

(substituting fnrA)

hπ,i,θi |= ¬((viol(nθα)∧¬prev viol(pnαθq)∨prev active(pnrθαq))∧ 6 ∃θ 0: θ0fD

nr)if hπ,i,θi |= (¬(viol(pnθ

αq)∧¬prev viol(pnθαq)∨prev active(pnrθαq)) ∨ ∃θ 0: θ0fD nr)if hπ,i,θi |= ((¬viol(pnθ αq)∨prev viol(pn θ αq)∧¬prev active(pnr θ αq)) ∨ ∃θ 0: θ0fD nr)if

(from(((ccc000))))

hπ,i,θi |= (((¬(active(pnθ αq)∧ 6 ∃θ

0: θ0fM

n ) ∨prev viol(pnθαq)) ∧ ¬prev active(pnr θ αq)) ∨ ∃θ 0: θ0fD nr)if hπ,i,θi |= ((((¬active(pnθ αq) ∨ ∃θ 0: θ0fM

n ) ∨prev viol(pnθαq)) ∧ ¬prev active(pnrαθq)) ∨ ∃θ 0: θ0fD

nr)if

(from(((ααα011001))))

hπ,i,θi |= ((((¬((fnA∨prev active(pnθαq))∧ 6 ∃θ 0: θ0fD

n) ∨ ∃θ0: θ0fnM) ∨prev viol(pnθαq)) ∧ ¬prev active(pnr θ αq)) ∨ ∃θ

0: θ0fD nr)

“Flattening” a formula so as not to contain any negative predicates of the type active, inactive, viol or complied with is always possible, by applying all substitutions. Such a substitution is necessary to happen before any of the rules(((ααα01,201,201,2)))-(((eee000)))is implemented

inside the PDDL domain. An example of the representation of the inactive predi- cate of rule(((ccc000)))for norm2-rep of the pizza delivery example as the derived predicate inactive norm2-repcan be the following:

(:derived (inactive_norm2-rep ?p -person ?street1 -street ?street2 -street) 2 (or (and (or (or (not (and

(or (hasPizzaFor ?p ?street1 ?street2)

4 (prev_active_norm2 ?p ?street1 ?street2))

(not (pizza_delivered ?p ?street1 ?street2))))

6 (not (and (hasPizzaFor ?p ?street1 ?street2)

(> (p_time) (goalpizzatime ?street1 ?street2)))))

8 (prev_viol_norm2 ?p ?street1 ?street2))

(not (prev_active_norm2-rep ?p ?street1 ?street2))) 10 (points_augmented ?p)))

The full code for the implementation of the scenario can be found in AppendixB.3.