HandbookofKnowledgeRepresentation.pdf

大小 151.0KB 页数 21 页 格式 PDF

649

Handbook of Knowledge Representation Edited by F. van Harmelen, V. Lifschitz and B. Porter © 2008 Elsevier B.V. All rights reserved DOI: 10.1016/S1574-6526(07)03016-7

Chapter 16

Situation Calculus

Fangzhen Lin

The situation calculus is a logical language for representing changes. It was first introduced by McCarthy in 1963,1 and described in further details by McCarthy and Hayes [29] in 1969.

The basic concepts in the situation calculus are situations , actions and fluents . Briefly, actions are what make the dynamic world change from one situation to another when performed by agents. Fluents are situation-dependent functions used to describe the effects of actions. There are two kinds of them, relational fluents and functional fluents. The former have only two values: true or false, while the latter can take a range of values. For instance, one may have a relational fluent called handempty which is true in a situation if the robot’s hand is not holding anything. We may need a relation like this in a robot domain. One may also have a functional fluent called battery - level whose value in a situation is an integer between 0 and 100 denoting the total battery power remaining on one’s laptop computer.

According to McCarthy and Hayes [29], a situation is “the complete state of the universe at an instance of time”. But for Reiter [34], a situation is the same as its history which is the finite sequence of actions that has been performed since the initial situation S0. We shall discuss Reiter’s foundational axioms that make this precise later. Whatever the interpretation, the unique feature of the situation calculus is that situations are first-order objects that can be quantified over. This is what makes the situation calculus a powerful formalism for representing change, and distinguishes it from other formalisms such as dynamic logic [11].

To describe a dynamic domain in the situation calculus, one has to decide on the set of actions available for the agents to perform, and the set of fluents needed to describe the changes these actions will have on the world. For example, consider the classic blocks world where some blocks of equal size can be arranged into a set of towers on a table. The set of actions in this domain depends on what the imaginary agent can do. If we imagine the agent to be a one-handed robot that can be directed to grasp any block that is on the top of a tower, and either add it to the top of another tower or put it down on the table to make a new tower, then we can have the following actions [30]:

1In a Stanford Technical Report that was later published as [25].

650

16. Situation Calculus

  • stack (x, y)—put block x on block y, provided the robot is holding x, and y is clear, i.e. there is no other block on it;

  • unstack (x, y)—pick up block x from block y, provided the robot’s hand is empty, x is on y, and x is clear;

  • putdown (x)—put block x down on the table, provided the robot is holding x;

  • pickup (x)—pick up block x from the table, provided the robot’s hand is empty, x is on the table and clear.

To describe the effects of these actions, we can use the following relational fluents:

  • handempty —true in a situation if the robot’s hand is empty;

  • holding (x)—true in a situation if the robot’s hand is holding block x;

  • on (x, y)—true in a situation if block x is on block y;

  • ontable (x)—true in a situation if block x is on the table;

  • clear (x)—true in a situation if block x is the top block of a tower, i.e. the robot is not holding it, and there is no other block on it.

So, for example, we can say that for action stack (x, y) to be performed in a situation, holding (x) and clear (y) must be true, and that after stack (x, y) is performed, in the resulting new situation, on (x, y) and handempty will be true, and holding (x) and clear (y) will no longer be true.

If, however, the agent in this world can move a block from a clear position to another clear position, then we only need the following action:

  • move (x, y)—move block x to position y, provided that block x is clear to move, where a position is either a block or the table.

To describe the effects of this action, it suffices to use two fluents on (x, y) and clear (x): action move (x, y) can be performed in a situation if x̸ = table , clear (x), and clear (y) are true in the situation, and that after move (x, y) is performed, in the resulting new situation, x is no longer where it was but on y now.

To axiomatize dynamic domains like these in the situation calculus, we will need to be a bit more precise about the language.

16.1 Axiomatizations

We said that the situation calculus is a logical language for reasoning about change. More precisely, it is a first-order language, sometime enriched with some secondorder features. It represents situations and actions as first-order objects that can be quantified over. Thus we can have a first-order sentence saying that among all actions, putdown (x) is the only one that can make ontable (x) true. We can also have a firstorder sentence saying that in any situation, executing different actions will always yield different situations. As we mentioned, being able to quantify over situations makes the situation calculus a very expressive language, and distinguishes it from other formalisms for representing dynamic systems.

651

F. Lin

As we mentioned, fluents are functions on situations. Of special interest are relational fluents that are either true or false in a situation. Initially, McCarthy and Hayes represented relational fluents as predicates whose last argument is a situation term [29]. For instance, to say that block x is on the table in situation s, one would use a binary predicate like ontable and write ontable (x, s). This was also the approach taken by Reiter [33, 34]. Later, McCarthy [26, 28] proposed to reify relational fluents as first-order objects as well, and introduced a special binary predicate “ Holds (p, s)” to express the truth value of a relational fluent p in situation s. Here we shall follow McCarthy’s later work, and represent relational fluents as first-order objects as well. This allows us to quantify over fluents. But more importantly, it allows us to talk about other properties of fluents like causal relationships among them [15]. One could continue to write formulas like ontable (x, s), which will be taken as a shorthand for Holds ( ontable (x), s).

To summarize, the situation calculus is a first-order language with the following special sorts: situation , action , and fluent (for relational fluents). There could be other sorts, some of them domain dependent like block for blocks in the blocks world or loc for locations in logistics domain, and others domain independent like truth for truth values. For now we assume the following special domain independent predicates and functions:

  • Holds (p, s)—fluent p is true in situation s;

  • do (a, s)—the situation that results from performing action a in situation s;

  • Poss (a, s)—action a is executable in situation s.

Other special predicates and functions may be introduced. For instance, to specify Golog programs [12], one can use a ternary predicate called Do (P, s1, s2), meaning that s2 is a terminating situation of performing program P in s1. To specify causal relations among fluents, one can use another ternary predicate Caused (p, v, s), meaning that fluent p is caused to have truth value v in situation s.

Under these conventions, a relational fluent is represented by a function that does not have a situation argument, and a functional fluent is represented by a function whose last argument is of sort situation . For instance, clear (x) is a unary relational fluent. We often write clear (x, s) which as we mentioned earlier, is just a shorthand for Holds ( clear (x), s). On the other hand, color (x, s) is a binary functional fluent, and we write axioms about it like

color (x, do ( paint (x, c), s)) = c.

We can now axiomatize our first blocks world domain with the following first-order sentences (all free variables are assumed to be universally quantified):

Poss(stack(x, y), s)≡holding(x, s)∧clear(y, s), (16.1)
Poss(unstack(x, y), s)≡on(x, y, s)∧clear(x, s)∧handempty(s), (16.2)
Poss(pickup(x), s)≡ontable(x, s)∧clear(x, s)∧handempty(s), (16.3)
Poss(putdown(x), s)≡holding(x, s), (16.4)
holding(u,do(stack(x, y), s))≡holding(u, s)∧u̸ =x, (16.5)

652

16. Situation Calculus

handempty(do(stack(x, y), s)), (16.6)
on(u, v,do(stack(x, y), s))≡(u=x∧v =y)∨on(u, v, s), (16.7)
clear(u,do(stack(x, y), s))≡u=x∨(clear(u, s)∧u̸ =y), (16.8)
ontable(u,do(stack(x, y), s))≡ontable(u, s), (16.9)
holding(u,do(unstack(x, y), s))≡u=x, (16.10)
¬handempty(do(unstack(x, y), s)), (16.11)
on(u, v,do(unstack(x, y), s))≡on(u, v, s)∧¬(x =u∧y =v), (16.12)
clear(u,do(unstack(x, y), s))≡u=y∨(clear(u, s)∧u̸ =x), (16.13)
ontable(u,do(unstack(x, y), s))≡ontable(u, s), (16.14)
holding(u,do(pickup(x), s))≡u=x, (16.15)
¬handempty(do(pickup(x), s)), (16.16)
on(u, v,do(pickup(x), s))≡on(u, v, s), (16.17)
clear(u,do(pickup(x), s))≡clear(u, s)∧u̸ =x, (16.18)
ontable(u,do(pickup(x), s))≡ontable(u, s)∧x̸ =u, (16.19)
holding(u,do(putdown(x), s))≡holding(u, s)∧u̸ =x, (16.20)
handempty(do(putdown(x), s)), (16.21)
on(u, v,do(putdown(x), s))≡on(u, v, s), (16.22)
clear(u,do(putdown(x), s))≡u=x∨clear(u, s), (16.23)
ontable(u,do(putdown(x), s))≡u=x∨ontable(u, s).
rly, we can write the following axioms for our second version of
domain.
(16.24)
the blocks
Poss(move(x, y), s)≡x̸ =table∧clear(x, s)∧clear(y, s) (16.25)
clear(u,do(move(x, y), s))≡
u=table∨on(x, u, s)∨(clear(u, s)∧u̸ =y),
(16.26)
on(u, v,do(move(x, y), s))≡
(x =u∧y =v)∨(on(u, v, s)∧u̸ =x). (16.27)

Similarly, we can write the following axioms for our second version of the blocks world domain.

16.2 The Frame, the Ramification and the Qualification Problems

The set of axioms (16.1)–(16.24) provides a complete logical characterization of the effects of actions for our first blocks world domain. For each action, it gives necessary and sufficient conditions for it to be executable in any situation, and fully specifies the effects of this action on every fluent. Similarly, the set of axioms (16.25)–(16.27) completely captures the effects of actions for our second blocks world domain.

However, there is something unsatisfying about these two sets of axioms. When we informally described the effects of actions, we did not describe it this way. For

653

F. Lin

instance, we said that after stack (x, y) is performed, in the resulting new situation, on (x, y) and handempty will be true, and holding (x) and clear (y) will no longer be true. We did not have to say, for instance, that if y is initially on the table, it will still be on the table. Many researchers believe that when people remember the effects of an action, they do not explicitly store the facts that are not changed by the action, rather they just remember the changes that this action will bring about. Consequently, when we axiomatize an action, we should only need to specify the changes that will be made by the action. But if we specify in our theory only the changes that an action will make, there is then a problem of how to derive those that are not changed by the action. This problem was identified by McCarthy and Hayes [29] in 1969, and they called it the frame problem . For our blocks world example, we can view the frame problem as the problem of looking for an appropriate logic that when given, for example the following so-called “effect axioms” about stack (x, y):

on (x, y, do ( stack (x, y), s)),

clear (x, do ( stack (x, y), s)), ¬ clear (y, do ( stack (x, y), s)),

handempty ( do ( stack (x, y), s)),

¬ holding (x, do ( stack (x, y), s)),

will derive a complete specification of the effects of action stack (x, y), like what the set of axioms (16.5)–(16.9) does in first-order logic [21].

The frame problem is one of the most well-known AI problems, if not the most well-known one, and a lot of work has been done on solving it. It motivated much of the early work on nonmonotonic logic (see papers in [6] and Chapter 6). While the problem was identified in the situation calculus, it shows up in other formalisms like the event calculus (Chapter 17), temporal action logics (Chapter 18), and nonmonotonic causal logic (Chapter 19). In fact, the general consensus is that any formalism for reasoning about change will have to deal with it.

McCarthy [27] initially proposed to solve the frame problem by the following generic frame axiom:

Holds (p, s) ∧¬ abnormal (p, a, s) Holds (p, do (a, s)) (16.28)

with the abnormality predicate abnormal circumscribed. Unfortunately, Hanks and McDermott [10] showed that this approach does not work using by now the infamous Yale Shooting Problem as a counterexample. This is a simple problem with three actions: wait (do nothing), load (load the gun), and shoot (fire the gun). Their effects can be axiomatrized by the following axioms:

loaded ( do ( load , s)), (16.29) loaded (s) ⊃ dead ( do ( shoot , s)). (16.30)

Now suppose S0 is a situation such that the following is true:

¬ loaded (S0) ∧¬ dead (S0). (16.31)

654
16. Situation Calculus

Hanks and McDermott showed that the circumscription of abnormal in the theory {(16.28), (16.29), (16.30), (16.31)} with Holds allowed to vary has two models, one in which

loaded ( do ( load , S0)) ∧ loaded ( do ( wait , do ( load , S0))) ∧

dead ( do ( shoot , do ( wait , do ( load , S0))))

is true as desired, and the other in which

loaded ( do ( load , S0)) ∧¬ loaded ( do ( wait , do ( load , S0))) ∧

¬ dead ( do ( shoot , do ( wait , do ( load , S0))))

is true, which is counter-intuitive as the action wait , which is supposed to do nothing, mysteriosly unloaded the gun.

For the next few years, the YSP motivated much of the work on the frame problem, and the frame problem became the focus of the research on nonmonotonic reasoning. In response to the problem, Shoham [37] proposed chronological minimization that prefers changes at later times. Many other proposals were put forward (e.g. [13, 14, 2, 33, 21, 35, 15, 38, 24]).

The thrust of modern solutions to the frame problem is to separate the specification of the effects of actions from the tasks of reasoning about these actions. For instance, given the effect axioms (16.29) and (16.30), one can obtain the following complete specification of the effects of the actions concerned:

loaded ( do ( load , s)),

dead ( do ( load , s)) ≡ dead (s),

loaded ( do ( shoot , s)) ≡ loaded (s),

dead ( do ( shoot , s)) ≡ loaded (s) ∨ dead (s),

loaded ( do ( wait , s)) ≡ loaded (s),

dead ( do ( wait , s)) ≡ dead (s).

Now given the initial state axiom (16.31), one can easily infer that dead ( do ( shoot , do ( wait , do ( load , S0)))) holds.

This separation between the specification of action theories and the tasks of reasoning under these theories can be done syntactically by distinguishing general effect axioms like (16.29) from specific facts like (16.31) about some particular situations, as in Reiter’s solution [33] that we shall describe next. It can also be done by encoding general effect axioms in a special language using predicates like Caused , as in Lin’s causal theories of action [15] for solving the ramification problem.

16.2.1 The Frame Problem—Reiter’s Solution

Based on earlier work by Pednault [31], Haas [9] and Schubert [36], Reiter [33, 34] proposed a simple syntactic manipulation much in the style of Clark’s predicate completion [4] (see Chapter 7) that turns a set of effect axioms into a set of successor state axioms that completely captures the true value of each fluent in any successor situation. It is best to illustrate Reiter’s method by an example. Consider our first blocks world domain, and let us write down all the effect axioms:

F. Lin 655
on(x, y,do(stack(x, y), s)), (16.32)
clear(x,do(stack(x, y), s)), (16.33)
¬clear(y,do(stack(x, y), s)), (16.34)
handempty(do(stack(x, y), s)), (16.35)
¬holding(x,do(stack(x, y), s)), (16.36)
¬on(x, y,do(unstack(x, y), s)), (16.37)
¬clear(x,do(unstack(x, y), s)), (16.38)
clear(y,do(unstack(x, y), s)), (16.39)
¬handempty(do(unstack(x, y), s)), (16.40)
holding(x,do(unstack(x, y), s)), (16.41)
ontable(x,do(putdown(x), s)), (16.42)
clear(x,do(putdown(x), s)), (16.43)
handempty(do(putdown(x), s)), (16.44)
¬holding(x,do(putdown(x), s)), (16.45)
¬ontable(x,do(pickup(x), s)), (16.46)
¬clear(x,do(pickup(x), s)), (16.47)
¬handempty(do(pickup(x), s)), (16.48)
holding(x,do(pickup(x), s)). (16.49)

Now for each of these effect axioms, transform it into one of the following two forms:

γ (a,⃗ x, s) ⊃ F(x,⃗ do (a, s)),

γ (a,⃗ x, s) ⊃¬F(x,⃗ do (a, s)).

For instance, the effect axiom (16.32) can be transformed equivalently into the following axiom:

a = stack (x, y) ⊃ on (x, y, do (a, s)),

and the effect axiom (16.34) can be transformed equivalently into the following axiom:

(∃y)a = stack (y, x) ⊃¬ clear (x, do (a, s)).

Now for each fluent F , suppose the following is the list of all such axioms so obtained:

γ1+(a,⃗x, s) ⊃F(x,⃗do(a, s)), · · ·

γm+(a,⃗x, s) ⊃F(x,⃗do(a, s)), γ1−(a,⃗x, s) ⊃¬F(x,⃗do(a, s)), · · · γn−(a,⃗x, s) ⊃¬F(x,⃗do(a, s)).

656
16. Situation Calculus

Then under what Reiter called the causal completeness assumption , which says that the above axioms characterize all the conditions under which action a causes F to become true or false in the successor situation, we conclude the following successor state axiom [33] for fluent F :

F(x,⃗ do (a, s)) ≡ γ+ (a,⃗ x, s) ∨ (F(x, s)⃗ ∧¬γ− (a,⃗ x, s)), (16.50) where γ+ (a,⃗ x, s) is γ1+(a,⃗x, s) ∨· · · ∨γ m+(a,⃗x, s), and γ −(a,⃗x, s) is γ 1−(a,⃗x, s) ∨ · · · ∨ γn−(a,⃗x, s).

For instance, for our first blocks world, we can transform the effect axioms about clear (x) into the following axioms:

(∃y.a = stack (x, y)) ⊃ clear (x, do (a, s)), (∃y.a = unstack (y, x)) ⊃ clear (x, do (a, s)), a = putdon (x) ⊃ clear (x, do (a, s)), (∃y.a = stack (y, x)) ⊃¬ clear (x, do (a, s)), (∃y.a = unstack (x, y)) ⊃¬ clear (x, do (a, s)), a = pickup (x) ⊃¬ clear (x, do (a, s)).

Thus we have the following successor state axiom for clear (x):

clear (x, do (a, s)) ≡

∃y.a = stack (x, y) ∨∃y.a = unstack (y, x) ∨ a = putdown (x) ∨ clear (x, s) ∧

¬[∃y.a = stack (y, x) ∨∃y.a = unstack (x, y) ∨ a = pickup (x)].

Once we have a successor state axiom for each fluent in the domain, we will then have an action theory that is complete in the same way as the set of axioms (16.1)–(16.24) is.

This procedure can be given a semantics in nonmonotonic logics, in particular circumscription [27] (see Chapter 6). This in fact has been done by Lin and Reiter [19].

We should also mention that for this approach to work, when generating the successor state axiom (16.50) from effect axioms, one should also assume what Reiter called the consistency assumption : the background theory should entail that ¬(γ+ ∧ γ− ). Once we have a set of successor state axioms, to reason with them we need the unique names assumption about actions: for each n-ary action A:

A(x1, . . . , xn) = A(y1, . . . , yn) ⊃ x1 = y1 ∧· · · ∧ xn = yn,

and for each distinct actions A and A′ ,

A(x1, . . . , xn)̸ = A′ (y1, . . . , ym).

For more details, see [33, 34].

657

F. Lin

16.2.2 The Ramification Problem and Lin’s Solution

Recall that the frame problem is about how one can obtain a complete axiomatization of the effects of actions from a set of effect axioms that specifies the changes that the actions have on the world. Thus Reiter’s solution to the frame problem makes the assumption that the given effect axioms characterize completely the conditions under which an action can cause a fluent to be true or false. However, in some action domains, providing such a complete list of effect axioms may not be feasible. This is because in these action domains, there are rich domain constraints that can entail new effect axioms. To see how domain constraints can entail new effect axioms, consider again the blocks world. We know that each block can be at only one location: either being held by the robot’s hand, on another block, or on the table. Thus when action stack (x, y) causes x to be on y, it also makes holding (x) false. The ramification problem , first discussed by Finger [5] in 1986, is about how to encode constraints like this in an action domain, and how these constraints can be used to derive the effects of the actions in the domain.

In the situation calculus, for a long time the only way to represent domain constraints was by universal sentences of the form ∀s.C(s). For example, the aforementioned constraint that a block can be (and must be) at only one location in the blocks world can be represented by the following sentences:

holding (x, s) ∨ ontable (x, s) ∨∃y. on (x, y),

holding (x, s) ⊃¬( ontable (x, s) ∨∃y. on (x, y)),

ontable (x, s) ⊃¬( holding (x, s) ∨∃y. on (x, y)), (∃y. on (x, y)) ⊃¬( holding (x, s) ∨ ontable (x, s)).

So, for example, these axioms and the following effect axiom about putdown (x),

ontable (x, do ( putdown (x), s))

will entail in first-order logic the following effect axiom:

¬ holding (x, do ( putdown (x), s)).

However, domain constraints represented this way may not be strong enough for determining the effects of actions. Consider the suitcase problem from [15]. Imagine a suitcase with two locks and a spring loaded mechanism which will open the suitcase when both of the locks are in the up position. Apparently, because of the spring loaded mechanism, if an action changes the status of the locks, then this action may also cause, as an indirect effect, the suitcase to open.

As with the blocks world, we can represent the constraint that this spring loaded mechanism gives rise to as the following sentence:

up (L1, s) ∧ up (L2, s) ⊃ open (s).

Although summarizing concisely the relationship among the truth values of the three relevant propositions at any particular instance of time, this constraint is too weak to describe the indirect effects of actions. For instance, suppose that initially the suitcase is closed, the first lock in the down position, and the second lock in the up position.

658
16. Situation Calculus

Suppose an action is then performed to turn up the first lock. Then this constraint is ambiguous about what will happen next. According to it, either the suitcase may spring open or the second lock may get turned down. Although we have the intuition that the former is what will happen, this constraint is not strong enough to enforce that because there is a different mechanism that will yield a logically equivalent constraint. For instance, a mechanism that turns down the second lock when the suitcase is closed and the first lock is up will yield the following logically equivalent one:

up (L1, s) ∧¬ open (s) ⊃¬ up (L2, s).

So to faithfully represent the ramification of the spring loaded mechanism on the effects of actions, something stronger than the constraint (16.51) is needed. The proposed solution by Lin [15] is to represent this constraint as a causal constraint: (through the spring loaded mechanism) the fact that both of the locks are in the up position causes the suitcase to open. To axiomatize this, Lin introduced a ternary predicate Caused (p, v, s), meaning that fluent p is caused to have truth value v in situation s. The following are some basic properties of Caused [15]:

Caused(p,true, s)⊃Holds(p, s), (16.52)
Caused(p,false, s)⊃¬Holds(p, s), (16.53)
_true_̸ =false∧(∀v)(v =true∨v =false), (16.54)

where v is a variable ranging over a new sort truthValues .

Let us illustrate how this approach works using the suitcase example. Suppose that flip (x) is an action that flips the status of the lock x. Its direct effect can be described by the following axioms:

up (x, s) ⊃ Caused ( up (x), false , do ( flip (x), s)), (16.55) ¬ up (x, s) ⊃ Caused ( up (x), true , do ( flip (x), s)). (16.56)

Assume that L1 and L2 are the two locks on the suitcase, the spring loaded mechanism is now represented by the following causal rule:

up (L1, s) ∧ up (L2, s) ⊃ Caused ( open , true , s). (16.57)

Notice that this causal rule, together with the basic axiom (16.52) about causality, entails the state constraint (16.51). Notice also that the physical, spring loaded mechanism behind the causal rule has been abstracted away. For all we care, it may just as well be that the device is not made of spring, but of bombs that will blow open the suitcase each time the two locks are in the up position. It then seems natural to say that the fluent open is caused to be true by the fact that the two locks are both in the up position. This is an instance of what has been called static causal rules as it mentions only one situation. In comparison, causal statements like the effect axioms (16.55) and (16.56) are dynamic as they mention more than one situations.

The above axioms constitute the starting theory for the domain. To describe fully the effects of the actions, suitable frame axioms need to be added. Using predicate Caused , a generic frame axiom can be stated as follows [15]: Unless caused otherwise, a fluent’s truth value will persist:

¬(∃v) Caused (p, v, do (a, s)) ⊃[ Holds (p, do (a, s)) ≡ Holds (p, s)]. (16.58)

预览结束 · 共 21 页