Before we move on to the technical sections, which define precisely the meaning of preconditions, definite effects and possible effects of event-goals, we will present in this section some preliminary notions and state the assumptions we make in this chapter.
As usual, we use ~x, ~y, and ~z to denote vectors of distinct variables. Moreover, we use ~t and ~c to denote vectors of (not necessarily distinct) terms and constants, respectively. A subscript n on a vector (e.g., ~xn) denotes a vector of n elements. In this chapter, we assume that, like in AgentSpeak(L) (Rao, 1996; Moreira and Bordini, 2002), the plan-library does not mention any parallel programs P1 k P2. Since, without parallelism, we would not need to avoid ambiguity
in plan-body programs with the use of parenthesis — e.g., given program P1; (P2; P3), program
(P1; P2); P3, and program P1; P2; P3, the BDI execution engine will execute P1 first, P2 second
and P3third in all cases — we assume that parenthesis are not mentioned in plan-bodies.2
Second, we assume that the plan-library does not have recursion. Although this may seem limiting, we can overcome this restriction to a certain extent by using first principles planning to emulate recursion, as we will show in Section 6.3. To be more precise regarding our assumption, we define the two notions: children and ranking. Intuitively, the children of an event-goal e are event-goals mentioned in the plan-rules associated with e.
Definition 9. (Children) The children of an event-goal ˆe relative to a plan-library Π, denoted children(ˆe, Π), is defined as follows:3
children(ˆe, Π) ={e | e′ : ψ← P ∈ Π, ˆe and e′have the same type, and !e is mentioned in P}.
Intuitively, the ranking of an event-goal is the height of the event-goal in the given hierarchy (plan-library).
Definition 10. (Ranking) A ranking for a plan-library Π is a functionRΠ: EΠ7→ N0from event-
goal types mentioned in Π to natural numbers, such that the following condition holds: for each event-goals e1, e2∈ EΠsuch that e2is the same type as some event-goal e3 ∈ children(e1, Π), it is
the case thatRΠ(e1) >RΠ(e2).
Then, we assume that a ranking exists for the plan-library. We say thatRΠ(e) is the rank of e in Π, and moreover, given any event-goal e(~t) mentioned in Π, we defineRΠ(e(~t)) =RΠ(e(~x)), that is, the rank of an event-goal is equivalent to the rank of its type.
For example, consider the plan-library in Figure 4.2. Possible rank functions of
2On the other hand, observe that due to the use of parenthesis in programs P
1; (P2k P3) and (P1; P2)k P3, there are
executions of the latter program that cannot be obtained by executing the former, because the former program requires
P1to be (completely) executed first.
event-goals mentioned in this plan-library are shown below: RΠ(Navigate(src, dst)) = 1 RΠ(AnalyseSoilSample(dst)) = 1 RΠ(TransmitSoilResults(dst)) = 1 RΠ(ObtainSoilResults(dst)) = 2 RΠ(PerformSoilExperiment(dst)) = 3 RΠ(ExploreSoilLocation(dst)) = 4
Our third assumption is that plan-libraries are safe, i.e., all plan-rules in them are written so that whenever the context condition of a plan-rule is met in some belief base, there is at least one successful HTN execution of the corresponding plan-body. Note that this does not imply that the plan-body should be successfully executed by the BDI execution cycle – the BDI execution of the plan-body may still fail if the agent makes a wrong choice.
We define a successful HTN execution of a program P (relative to a plan-library and an action- library) as a finite sequence of configurations of the form C1 =hB1, A1, Pi·. . .·Cn=hBn, An, nili, such that Ci
plan
−→ Ci+1, for every i∈ {1, . . . , n − 1}. We say that a plan-library Π is safe (relative to an action-library) if for all plan-rules e : ψ← P ∈ Π, ground instances eθ of e, and belief bases B1,
ifB1 |= ψθθ′, then there exists a successful HTN execution C1· . . . · Cnof Pθθ′, where C1|B = B1
(recall C|B denotes the projection of the belief base in configuration C). This definition is in terms of HTN executions rather than BDI executions because we are not interested in solutions that include BDI-style failure and recovery.
Similarly, we assume that belief operations in plan-libraries are written with appropriate care. For example, a situation should never be reached in which an unground atom is added to the belief base. Specifically, for any finite sequence of configurations of the form C1=hB1, A1, Pi·. . .·Cn=
hBn, An, P′i, where P, P′are programs and Ci−→ Ci+1for every i∈ {1, . . . , n − 1}, we require that for each i∈ {1, . . . , n}, Biis a set of ground atoms (and hence consistent).
Recall from the Event rule of the CAN operational semantics in Figure 3.2 (p. 63) that in order to select a plan-rule e′(~t′) : ψ← P to achieve a given event-goal program !e(~t), the plan-rule must be relevant for !e(~t), that is, e(~t) must unify with e′(~t′). This entails, for instance, that if the argument (term) at some index i in ~t′ and the argument at the same index in ~t are constants,
then the two arguments must be equivalent. We assume that such requirements on the bindings of arguments in event-goals are encoded in context conditions of associated plan-rules. More precisely, we assume, without loss of generality, that all plan-rules e(~t) : ψ← P in a given plan-
library Π are such that ~t is a vector of distinct variables.
Let us illustrate this assumption with an example. Suppose we have the following three plan-rules for travelling to three different destinations from Melbourne:
Travel(Melb, Syd) : ψ1 ← P1; Travel(Melb, Perth) : ψ2 ← P2; Travel(src, src) : ψ3← P3.
Observe that the third plan-rule handles the situation where the agent is already at the destination (hence, P3may be the empty plan-body). Our assumption requires
that the above three plan-rules be encoded as follows:
Travel(x1, y1) : ψ1∧ =(x1, Melb) ∧ =(y1, Syd) ← P1; Travel(x2, y2) : ψ2∧ =(x2, Melb) ∧ =(y2, Perth) ← P2; Travel(x3, y3) : ψ3∧ =(x3, y3) ← P3.
Observe that the event-goals no longer mention constants, and that the context condition of each plan-rule includes equality predicates. Such predicates within a plan-rule encode the conditions under which arguments of the original associated event-goal (e.g., Travel(Melb, Syd)) will unify successfully with those of a given event-goal program for travelling (i.e., an event-goal program with symbol Travel and two arguments).
Observe that the encoding of such binding details into the context conditions of plan-rules can be easily automated.