handbook of knowledge representation -...

21
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 649 Chapter 16 Situation Calculus Fangzhen Lin The situation calculus is a logical language for representing changes. It was first intro- duced 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 an- other 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 ini- tial situation S 0 . 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]: 1 In a Stanford Technical Report that was later published as [25].

Upload: others

Post on 05-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

Handbookof KnowledgeRepresentationEditedby F. vanHarmelen,V. Lifschitz andB. Porter© 2008Elsevier B.V. All rightsreservedDOI: 10.1016/S1574-6526(07)03016-7

649

Chapter 16

Situation Calculus

FangzhenLin

Thesituationcalculusis a logical languagefor representingchanges.It wasfirst intro-ducedby McCarthy in 1963,1 anddescribedin furtherdetailsby McCarthy andHayes[29] in 1969.

The basicconceptsin the situationcalculusare situations, actionsand fluents.Briefly, actionsarewhat make the dynamicworld changefrom onesituationto an-otherwhenperformedby agents.Fluentsaresituation-dependentfunctionsusedtodescribethe effects of actions.Thereare two kinds of them, relational fluentsandfunctionalfluents.Theformerhave only two values:trueor false,while thelattercantake arangeof values.For instance,onemayhave arelationalfluentcalledhandemptywhich is true in a situationif the robot’s handis not holdinganything. We mayneeda relation like this in a robot domain.Onemay alsohave afunctionalfluent calledbattery-level whosevaluein a situation is an integerbetween0 and100denotingthetotal batterypower remainingonone’s laptopcomputer.

Accordingto McCarthy andHayes[29], a situationis “the completestateof theuniverseat an instanceof time”. But for Reiter [34], a situationis the sameas itshistorywhich is thefinite sequenceof actionsthathasbeenperformedsincethe ini-tial situationS0. We shall discussReiter’s foundationalaxiomsthatmake this preciselater. Whatever the interpretation,the uniquefeatureof the situationcalculusis thatsituationsarefirst-orderobjectsthat canbe quantifiedover. This is what makesthesituationcalculusa powerful formalismfor representingchange,anddistinguishesitfrom otherformalismssuchasdynamiclogic [11].

To describeadynamicdomainin thesituationcalculus,onehasto decideonthesetof actionsavailablefor theagentsto perform,andthesetof fluentsneededto describethe changestheseactionswill have on the world. For example,considerthe classicblocksworld wheresomeblocksof equalsizecanbearrangedinto a set of towersona table.The set of actionsin this domaindependson what the imaginaryagentcando.If we imaginetheagentto beaone-handedrobotthatcanbedirectedto graspanyblock thatis onthetopof a tower, andeitheraddit to thetopof anothertoweror put itdown on thetableto make anew tower, thenwecanhave thefollowing actions[30]:

1In aStanfordTechnicalReportthatwaslaterpublishedas [25].

Page 2: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

650 16.SituationCalculus

• stack(x, y)—put block x on block y, provided the robot is holdingx, andy isclear, i.e. thereis nootherblockon it;

• unstack(x, y)—pick up block x from block y, provided the robot’s hand isempty, x is ony, andx is clear;

• putdown(x)—put blockx down on thetable,providedtherobotis holdingx;

• pickup(x)—pick up blockx from thetable,providedtherobot’s handis empty,x is on thetableandclear.

To describetheeffectsof theseactions,wecanusethefollowing relationalfluents:

• handempty—truein asituationif the robot’shandis empty;

• holding(x)—truein asituationif the robot’shandis holdingblockx;

• on(x, y)—truein asituationif blockx is onblocky;

• ontable(x)—truein asituationif blockx is on thetable;

• clear(x)—truein a situationif blockx is thetop block of a tower, i.e. therobotis notholdingit, andthereis nootherblockon it.

So, for example,we cansay that for actionstack(x, y) to be performedin a situa-tion, holding(x) andclear(y) mustbetrue,andthatafterstack(x, y) is performed,intheresultingnew situation,on(x, y) andhandemptywill betrue,andholding(x) andclear(y) will no longerbetrue.

If, however, the agentin this world can move a block from a clear position toanotherclearposition,thenweonly needthefollowing action:

• move(x, y)—moveblockx to positiony, providedthatblockx is clearto move,whereapositionis eitherablockor thetable.

To describethe effects of this action, it suffices to use two fluents on(x, y) andclear(x): actionmove(x, y) canbe performedin a situation if x �= table, clear(x),andclear(y) aretrue in the situation,andthat after move(x, y) is performed,in theresultingnew situation,x is no longerwhereit wasbut ony now.

To axiomatizedynamicdomainslike thesein thesituationcalculus,we will needto beabit morepreciseaboutthelanguage.

16.1 Axiomatizations

We saidthat the situation calculusis a logical languagefor reasoningaboutchange.More precisely, it is a first-order language,sometimeenrichedwith somesecond-order features.It representssituationsand actionsas first-orderobjectsthat can bequantifiedover. Thuswecanhave afirst-ordersentencesayingthatamongall actions,putdown(x) is the only onethat canmake ontable(x) true.We canalsohave afirst-order sentencesayingthat in any situation, executingdifferent actionswill alwaysyield different situations.As we mentioned,being able to quantify over situationsmakes the situationcalculusa very expressive language,and distinguishesit fromotherformalismsfor representingdynamicsystems.

Page 3: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 651

As we mentioned,fluentsarefunctionson situations.Of specialinterestarerela-tional fluentsthatareeithertrueor falsein a situation.Initially, McCarthy andHayesrepresentedrelationalfluentsas predicateswhoselast argumentis a situation term[29]. For instance,to say that block x is on the table in situation s, onewould usea binary predicatelike ontableandwrite ontable(x, s). This wasalso the approachtakenby Reiter[33, 34]. Later, McCarthy [26, 28] proposedto reify relationalfluentsasfirst-orderobjectsaswell, andintroduceda specialbinarypredicate“Holds(p, s)”to expressthe truth value ofa relationalfluent p in situations. Herewe shall fol-low McCarthy’s later work, andrepresentrelationalfluentsasfirst-orderobjectsaswell. Thisallowsusto quantifyoverfluents.But moreimportantly, it allowsusto talkaboutotherpropertiesof fluentslikecausalrelationshipsamongthem[15]. Onecouldcontinueto write formulaslike ontable(x, s), which will be takenasa shorthandforHolds(ontable(x), s).

To summarize,the situation calculusis a first-orderlanguagewith the followingspecialsorts:situation, action, andfluent(for relationalfluents).Therecouldbeothersorts,someof themdomaindependentlikeblock for blocksin theblocksworld or locfor locationsin logisticsdomain,andothersdomainindependentlike truth for truthvalues.For now we assumethefollowing specialdomainindependentpredicatesandfunctions:

• Holds(p, s)—fluentp is truein situations;

• do(a, s)—thesituationthatresultsfrom performingactiona in situations;

• Poss(a, s)—actiona is executablein situations.

Other specialpredicatesand functionsmay be introduced.For instance,to specifyGolog programs[12], onecanusea ternarypredicatecalledDo(P, s1, s2), meaningthats2 is a terminatingsituationof performingprogramP in s1. To specify causalre-lationsamongfluents,onecanuseanotherternarypredicateCaused(p, v, s), meaningthatfluentp is causedto have truthvaluev in situations.

Undertheseconventions,a relationalfluent is representedby a functionthatdoesnot have a situation argument,and a functionalfluent is representedby a functionwhoselast argumentis of sort situation. For instance,clear(x) is a unaryrelationalfluent.We often writeclear(x, s) which aswe mentionedearlier, is just a shorthandfor Holds(clear(x), s). Ontheotherhand,color(x, s) is abinaryfunctionalfluent,andwewrite axiomsaboutit like

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

Wecannow axiomatizeourfirst blocksworlddomainwith thefollowingfirst-ordersentences(all freevariablesareassumedto beuniversallyquantified):

(16.1)Poss(stack(x, y), s) ≡ holding(x, s) ∧ clear(y, s),

(16.2)Poss(unstack(x, y), s) ≡ on(x, y, s) ∧ clear(x, s) ∧ handempty(s),

(16.3)Poss(pickup(x), s) ≡ ontable(x, s) ∧ clear(x, s) ∧ handempty(s),

(16.4)Poss(putdown(x), s) ≡ holding(x, s),

(16.5)holding(u, do(stack(x, y), s)) ≡ holding(u, s) ∧ u �= x,

Page 4: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

652 16.SituationCalculus

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

(16.7)on(u, v, do(stack(x, y), s)) ≡ (u = x ∧ v = y) ∨ on(u, v, s),

(16.8)clear(u, do(stack(x, y), s)) ≡ u = x ∨ (clear(u, s) ∧ u �= y),

(16.9)ontable(u, do(stack(x, y), s)) ≡ ontable(u, s),

(16.10)holding(u, do(unstack(x, y), s)) ≡ u = x,

(16.11)¬handempty(do(unstack(x, y), s)),

(16.12)on(u, v, do(unstack(x, y), s)) ≡ on(u, v, s) ∧ ¬(x = u ∧ y = v),

(16.13)clear(u, do(unstack(x, y), s)) ≡ u = y ∨ (clear(u, s) ∧ u �= x),

(16.14)ontable(u, do(unstack(x, y), s)) ≡ ontable(u, s),

(16.15)holding(u, do(pickup(x), s)) ≡ u = x,

(16.16)¬handempty(do(pickup(x), s)),

(16.17)on(u, v, do(pickup(x), s)) ≡ on(u, v, s),

(16.18)clear(u, do(pickup(x), s)) ≡ clear(u, s) ∧ u �= x,

(16.19)ontable(u, do(pickup(x), s)) ≡ ontable(u, s) ∧ x �= u,

(16.20)holding(u, do(putdown(x), s)) ≡ holding(u, s) ∧ u �= x,

(16.21)handempty(do(putdown(x), s)),

(16.22)on(u, v, do(putdown(x), s)) ≡ on(u, v, s),

(16.23)clear(u, do(putdown(x), s)) ≡ u = x ∨ clear(u, s),

(16.24)ontable(u, do(putdown(x), s)) ≡ u = x ∨ ontable(u, s).

Similarly, we can write the following axiomsfor our secondversionof the blocksworld domain.

(16.25)Poss(move(x, y), s) ≡ x �= table∧ clear(x, s) ∧ clear(y, s)

clear(u, do(move(x, y), s)) ≡

(16.26)u = table∨ on(x, u, s) ∨ (clear(u, s) ∧ u �= y),

on(u, v, do(move(x, y), s)) ≡

(16.27)(x = u ∧ y = v) ∨ (on(u, v, s) ∧ u �= x).

16.2 The Frame, the Ramification and the Qualification Problems

Theset of axioms(16.1)–(16.24)providesa completelogical characterizationof theeffectsof actionsfor ourfirst blocksworld domain.For eachaction,it givesnecessaryandsufficient conditionsfor it to be executablein any situation,and fully specifiestheeffectsof this actionon every fluent.Similarly, theset of axioms(16.25)–(16.27)completelycapturestheeffectsof actionsfor oursecondblocksworld domain.

However, thereis somethingunsatisfyingaboutthesetwo setsof axioms.Whenwe informally describedthe effectsof actions,we did not describeit this way. For

Page 5: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 653

instance,we said that after stack(x, y) is performed,in the resultingnew situation,on(x, y) andhandemptywill be true,andholding(x) andclear(y) will no longerbetrue.We did nothave to say, for instance,that if y is initially on thetable,it will stillbe on the table.Many researchersbelieve that whenpeoplerememberthe effectsofan action, they do not explicitly storethe factsthat are not changedby the action,ratherthey just rememberthechangesthatthisactionwill bringabout.Consequently,whenweaxiomatizeanaction,weshouldonly needto specifythechangesthatwill bemadeby theaction.But if wespecify in ourtheoryonly thechangesthatanactionwillmake,thereis thenaproblemof how to derivethosethatarenotchangedby theaction.This problemwasidentifiedby McCarthy andHayes[29] in 1969,andthey calleditthe frameproblem. For our blocksworld example,we canview the frameproblemasthe problemof looking for an appropriatelogic that whengiven, for examplethefollowing so-called“effectaxioms”aboutstack(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 acompletespecificationof theeffectsof actionstack(x, y), like what thesetof axioms(16.5)–(16.9)doesin first-orderlogic [21].

The frameproblemis oneof the mostwell-known AI problems,if not the mostwell-known one,anda lot of work hasbeendoneon solving it. It motivatedmuchof the early work on nonmonotoniclogic (seepapersin [6] andChapter6). Whiletheproblemwasidentifiedin thesituationcalculus,it shows up in otherformalismslike the event calculus(Chapter17), temporalaction logics (Chapter18), andnon-monotoniccausallogic (Chapter19). In fact,thegeneralconsensusis thatany formal-ism for reasoningaboutchangewill have to dealwith it.

McCarthy [27] initially proposedto solve the frame problemby the followinggenericframeaxiom:

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

with the abnormalitypredicateabnormalcircumscribed.Unfortunately, HanksandMcDermott[10] showedthatthis approachdoesnot work usingby now theinfamousYaleShootingProblemasa counterexample.This is a simple problemwith threeac-tions:wait (donothing),load (loadthegun),andshoot(fire thegun).Theireffectscanbeaxiomatrizedby thefollowing axioms:

(16.29)loaded(do(load, s)),

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

Now supposeS0 is a situationsuchthatthefollowing is true:

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

Page 6: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

654 16.SituationCalculus

Hanksand McDermott showed that the circumscriptionof abnormal in the theory{ (16.28), (16.29), (16.30),(16.31)} with Holdsallowed to vary hastwo models,onein which

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

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

is trueasdesired,andtheotherin 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 asthe actionwait, which is supposedto do nothing,mysterioslyunloadedthegun.

For thenext few years,theYSPmotivatedmuchof thework ontheframeproblem,andtheframeproblembecamethefocusof theresearchon nonmonotonicreasoning.In responseto the problem,Shoham[37] proposedchronologicalminimizationthatpreferschangesat latertimes.Many otherproposalswereput forward(e.g.[13, 14,2,33, 21, 35, 15, 38,24]).

Thethrustof modernsolutionsto theframeproblemis to separatethespecificationof theeffectsof actionsfrom thetasksof reasoningabouttheseactions.For instance,given the effect axioms(16.29)and(16.30), onecanobtainthe following completespecificationof theeffectsof theactionsconcerned:

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 stateaxiom (16.31), onecaneasily infer that dead(do(shoot,do(wait, do(load, S0)))) holds.

This separationbetweenthe specificationof actiontheoriesandthe tasksof rea-soningunderthesetheoriescanbedonesyntacticallyby distinguishinggeneraleffectaxiomslike (16.29)from specific factslike (16.31)aboutsomeparticularsituations,asin Reiter’s solution[33] thatweshalldescribenext. It canalsobedoneby encodinggeneraleffect axiomsin a speciallanguageusingpredicateslike Caused, as in Lin’scausaltheoriesof action[15] for solving theramificationproblem.

16.2.1 The Frame Problem—Reiter’s Solution

Basedon earlierwork by Pednault[31], Haas[9] andSchubert[36], Reiter [33, 34]proposeda simple syntacticmanipulationmuchin thestyle of Clark’s predicatecom-pletion[4] (seeChapter7) thatturnsasetof effectaxiomsinto asetof successorstateaxiomsthatcompletelycapturesthe truevalue ofeachfluent in any successorsitua-tion. It is bestto illustrateReiter’s methodby an example.Considerour first blocksworld domain,andlet uswrite down all theeffectaxioms:

Page 7: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 655

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

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

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

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

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

(16.37)¬on(x, y, do(unstack(x, y), s)),

(16.38)¬clear(x, do(unstack(x, y), s)),

(16.39)clear(y, do(unstack(x, y), s)),

(16.40)¬handempty(do(unstack(x, y), s)),

(16.41)holding(x, do(unstack(x, y), s)),

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

(16.43)clear(x, do(putdown(x), s)),

(16.44)handempty(do(putdown(x), s)),

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

(16.46)¬ontable(x, do(pickup(x), s)),

(16.47)¬clear(x, do(pickup(x), s)),

(16.48)¬handempty(do(pickup(x), s)),

(16.49)holding(x, do(pickup(x), s)).

Now for eachof theseeffectaxioms,transformit into oneof thefollowing twoforms:

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

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

For instance,theeffectaxiom(16.32)canbetransformedequivalentlyinto thefollow-ing axiom:

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

andtheeffectaxiom(16.34)canbetransformedequivalentlyinto thefollowing axiom:

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

Now for eachfluentF , supposethefollowing is thelist of all suchaxiomsso 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)).

Page 8: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

656 16.SituationCalculus

Thenunderwhat Reitercalled the causalcompletenessassumption, which saysthatthe above axiomscharacterizeall the conditionsunderwhich actiona causesF tobecometrueor falsein thesuccessorsituation,we concludethe following successorstateaxiom[33] for fluentF :

(16.50)F(-x, do(a, s)) ≡ γ +(a, -x, s) ∨ (F (-x, s) ∧ ¬γ −(a, -x, s)),

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 blocksworld, we cantransformtheeffectaxiomsaboutclear(x) into thefollowing 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)).

Thuswehave thefollowing successorstateaxiomfor 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 successorstate axiom for each fluent in the domain, we willthen have an action theory that is completein the sameway as the set of axioms(16.1)–(16.24)is.

This procedurecan be given a semanticsin nonmonotoniclogics, in particularcircumscription[27] (seeChapter6).Thisin facthasbeendoneby Lin andReiter[19].

Weshouldalsomentionthatfor thisapproachtowork,whengeneratingthesucces-sorstateaxiom(16.50)from effectaxioms,oneshouldalsoassumewhatReitercalledthe consistencyassumption: the backgroundtheoryshould entail that ¬(γ + ∧ γ −).Oncewehave asetof successorstateaxioms,to reasonwith themweneedtheuniquenamesassumptionaboutactions:for eachn-ary actionA:

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

andfor eachdistinctactionsA andA′,

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

For moredetails,see[33, 34].

Page 9: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 657

16.2.2 The Ramification Problem and Lin’ s Solution

Recallthattheframeproblemis abouthow onecanobtaina completeaxiomatizationof the effectsof actionsfrom a set of effect axiomsthat specifiesthe changesthattheactionshave on theworld. ThusReiter’s solution to theframeproblemmakestheassumptionthatthegiveneffect axiomscharacterizecompletelytheconditionsunderwhich an actioncancausea fluent to be true or false.However, in someactiondo-mains,providing such a completelist of effect axiomsmay not be feasible.This isbecausein theseactiondomains,therearerich domainconstraintsthatcanentailneweffect axioms.To seehow domainconstraintscanentailnew effect axioms,consideragain theblocksworld. We know thateachblock canbeat only onelocation:eitherbeingheld by the robot’s hand,on anotherblock, or on the table.Thuswhenactionstack(x, y) causesx to beony, it alsomakesholding(x) false. The ramificationprob-lem, first discussedby Finger[5] in 1986,is abouthow to encodeconstraintslike thisin anactiondomain,andhow theseconstraintscanbeusedto derive theeffectsof theactionsin thedomain.

In the situation calculus,for a long time the only way to representdomaincon-straintswasby universalsentencesof the form ∀s.C(s). For example,theaforemen-tionedconstraintthata block canbe(andmustbe)at only onelocationin theblocksworld canberepresentedby thefollowing 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,theseaxiomsandthefollowing effectaxiomaboutputdown(x),

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

will entail in first-orderlogic thefollowing effectaxiom:

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

However, domainconstraintsrepresentedthis way may not be strongenoughfordeterminingtheeffectsof actions.Considerthesuitcaseproblemfrom [15]. Imagineasuitcasewith two locksandaspring loadedmechanismwhichwill openthesuitcasewhenbothof thelocksarein theupposition.Apparently, becauseof thespringloadedmechanism,if an action changesthe statusof the locks, then this action may alsocause,asanindirecteffect, thesuitcaseto open.

As with the blocksworld, we canrepresentthe constraintthat this springloadedmechanismgivesriseto asthefollowing sentence:

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

Althoughsummarizingconciselytherelationshipamongthetruth valuesof thethreerelevantpropositionsat any particularinstanceof time, this constraintis too weaktodescribetheindirecteffectsof actions.For instance,supposethatinitially thesuitcaseis closed,thefirst lock in thedown position,andthe secondlock in the up position.

Page 10: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

658 16.SituationCalculus

Supposean action is then performedto turn up the first lock. Then this constraintis ambiguousaboutwhat will happennext. Accordingto it, either the suitcasemayspringopenor thesecondlock mayget turneddown. Althoughwe have theintuitionthattheformeris whatwill happen,thisconstraintis notstrongenoughto enforcethatbecausethereis adifferentmechanismthatwill yield alogically equivalentconstraint.For instance,amechanismthatturnsdown thesecondlock whenthesuitcaseis closedandthefirst lock is upwill yield thefollowing logically equivalentone:

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

So to faithfully representthe ramification of the spring loadedmechanismonthe effectsof actions,somethingstrongerthanthe constraint(16.51)is needed.Theproposedsolution by Lin [15] is to representthis constraintas a causalconstraint:(throughthe spring loadedmechanism)the fact that both of the locks are in the upposition causesthe suitcaseto open.To axiomatizethis, Lin introduceda ternarypredicateCaused(p, v, s), meaningthat fluent p is causedto have truth valuev insituations. Thefollowing aresomebasicpropertiesof Caused[15]:

(16.52)Caused(p, true, s) ⊃ Holds(p, s),

(16.53)Caused(p, false, s) ⊃ ¬Holds(p, s),

(16.54)true �= false∧ (∀v)(v = true∨ v = false),

wherev is avariablerangingoveranew sort truthValues.Let usillustratehow thisapproachworksusingthesuitcaseexample.Supposethat

flip(x) is anactionthatflips thestatusof thelock x. Its directeffect canbedescribedby thefollowing axioms:

(16.55)up(x, s) ⊃ Caused(up(x), false, do(flip(x), s)),

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

AssumethatL1 andL2 arethetwo locksonthesuitcase,thespringloadedmechanismis now representedby thefollowing causalrule:

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

Notice that this causalrule, togetherwith the basicaxiom (16.52)aboutcausality,entailsthestateconstraint(16.51). Noticealsothatthephysical,spring loadedmech-anismbehindthecausalrule hasbeenabstractedaway. For all we care,it mayjust aswell be that the device is not madeof spring,but of bombsthat will blow openthesuitcaseeachtime the two locks arein the up position.It thenseemsnaturalto saythatthefluentopenis causedto betrueby thefactthatthetwo locksarebothin theupposition.This is aninstanceof whathasbeencalledstaticcausalrulesasit mentionsonly onesituation.In comparison,causalstatementsliketheeffectaxioms(16.55)and(16.56)aredynamicasthey mentionmorethanonesituations.

Theabove axiomsconstitutethestarting theoryfor thedomain.To describefullythe effectsof the actions,suitable frameaxiomsneedto be added.Using predicateCaused, agenericframeaxiomcanbestatedasfollows[15]: Unlesscausedotherwise,a fluent’s truthvaluewill persist:

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

Page 11: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 659

For this frame axiom to make sense,oneneedsto minimize the predicateCaused.Technicallythis is doneby circumscribingCausedin the above setof axiomswithall otherpredicates(PossandHolds) fixed.However, given the form of the axioms,this circumscriptioncoincideswith Clark’s completionof Caused, and it yields thefollowing causationaxioms:

Caused(open, v, s) ≡

(16.59)v = true∧ up(L1, s) ∧ up(L2, s),

Caused(up(x), v, s) ≡

v = true∧ (∃s ′)[s = do(flip(x), s′) ∧ ¬up(x, s′)] ∨

(16.60)v = false∧ (∃s′)[s = do(flip(x), s′) ∧ up(x, s′)].

Notice that theseaxiomsentail the two directeffect axioms(16.55),(16.56)andthecausalrule (16.57).

Having computedthe causalrelation, the next step is to use the frame axiom(16.58) to computethe effects of actions.It is easyto see that from the frame ax-iom (16.58)andthe two basicaxioms(16.52),(16.53)aboutcausality, onecaninferthefollowing pseudosuccessorstateaxiom:

Holds(p, do(a, s)) ≡

Caused(p, true, do(a, s)) ∨

(16.61)Holds(p, s) ∧ ¬Caused(p, false, do(a, s)).

Fromthis axiomandthecausationaxiom(16.60)for thefluentup, onethenobtainsthefollowing realsuccessorstateaxiomfor thefluentup:

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

(a = flip(x) ∧ ¬up(x, s)) ∨ (up(x, s) ∧ a �= flip(x)).

Similarly for thefluentopen, we have

open(do(a, s)) ≡

[up(L1, do(a, s)) ∧ up(L2, do(a, s))] ∨ open(s).

Now from this axiom, first eliminatingup(L1, do(a, s)) andup(L2, do(a, s)) usingthesuccessorstateaxiomfor up, thenusingtheuniquenamesaxiomsfor actions,andtheconstraint(16.51)which,aswepointedoutearlier, is aconsequenceof ouraxioms,wecandeducethefollowing successorstateaxiomfor thefluentopen:

open(do(a, s)) ≡ a = flip(L1) ∧ ¬up(L1, s) ∧ up(L2, s) ∨

a = flip(L2) ∧ ¬up(L2, s) ∧ up(L1, s) ∨

open(s).

Obtainingthesesuccessorstateaxiomssolvestheframeandtheramificationproblemsfor thesuitcaseexample.

Lin [15] showed that this procedurecan be appliedto a generalclassof actiontheories,andLin [18] describedanimplementedsystemthatcancompilethesecausal

Page 12: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

660 16.SituationCalculus

action theoriesinto Reiter’s successorstate axiomsand STRIPS-like systems,anddemonstratedthe effectivenessof the systemby applying it to many benchmarkAIplanningdomains.

16.2.3 The Qualification Problem

Finally, we noticethat so far we have given the conditionfor an actiona to be exe-cutablein asituations, Poss(a, s), directly. It canbearguedthatthisis notareasonablething to do. In general,the executability of an action may dependon the circum-stanceswhereit is performed.For instance,we have definedPoss(putdown(x), s) ≡holding(x, s). But if the actionis to be performedin a crowd, thenwe may want toaddthatfor the actionto beexecutable,therobot’shandmustnotbeblockedby some-one;andif the robot is runninglow on battery, thenwe maywant to ensurethat therobot is not runningout of battery;etc.It is clearthatno onecananticipateall thesepossiblecircumstances,thusno onecanlist all possibleconditionsfor anactionto beexecutableaheadof time.This problemof how bestto specify thepreconditionof anactionis calledthequalificationproblem[26].

Onepossiblesolution to this problemis to assumethat an action is alwaysexe-cutableunlessexplicitly ruledout by thetheory. This canbeachievedby maximizingthepredicatePoss, or in termsof circumscription,circumscribing¬Poss. If theaxiomsaboutPossall have theform

Poss(A, s) ⊃ ϕ(s),

thatis, theuseralways providesexplicit qualificationsto anaction,thenonecancom-pute Poss by a procedurelike Clark’s predicatecompletionby rewriting the aboveaxiomas:

¬ϕ(s) ⊃ ¬Poss(A, s).

Theproblembecomesmorecomplex whensomedomainconstraints-like axiomscaninfluencePoss. This problemwas first recognizedby Ginsberg and Smith [7], anddiscussedin moredetailedby Lin andReiter[19]. For instance,we maywant to addinto the blocksworld a constraintthat says“only yellow blockscanbe directly onthe table”. Now if the robot is holding a red block, shouldshe put it down on thetable?Probablysheshouldnot. This meansthat this constrainthastwo roles:it rulesout initial statesthatdo not satisfyit, andit forbidsagentsto performany actionthatwill resultin a successorsituation thatviolatesit. What this constraintshouldnot dois to causeadditionaleffectsof actions.For instance,it shouldnot be the casethatputdown(x) would causex to becomeyellow just to maintainthis constraintin thesuccessorsituation.

Lin andReiter [19] called thoseconstraintsthat yield indirect effectsof actionsramificationconstraints, andthosethatyield additionalqualificationsof actionsqual-ificationconstraints. They arebothrepresentedassentencesof theform∀s.C(s), andit is up to theuserto classifywhichcategory they belongto.

A uniform way of handlingthesetwo kinds of constraintsis to useLin’s causaltheoriesof actionsasdescribedabove.Underthis framework, only constraintsrepre-sentedascausalrulesusingCausedcanderive new effectsof actions,andordinarysituationcalculussentencesof theform∀s.C(s) canonly derivenew qualificationson

Page 13: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 661

actions.However, for this to work, actioneffectaxiomslike (16.55)needto havePossasaprecondition:

Poss(flip(x), s) ⊃ [up(x, s) ⊃ Caused(up(x), false, do(flip(x), s))],

andthegenericframeaxiom(16.58)needto bemodifiedsimilarly:

Poss(a, s) ⊃ {¬(∃v)Caused(p, v, do(a, s)) ⊃

[Holds(p, do(a, s)) ≡ Holds(p, s)]}.

In fact, this washow actioneffectaxiomsandframeaxiomsarerepresentedin [15].An interestingobservationmadein [15] wasthat somecausalrulesmay give rise tobothnew actioneffectsandactionqualifications.Ourpresentationof Lin’scausalthe-oriesin theprevioussubsectionhasdroppedPosssothat,in line with the presentationin [34], thefinal successorstateaxiomsdonothavePossasaprecondition.

16.3 Reiter’sFoundational Axioms and BasicAction Theories

We have definedthesituationcalculusasa first-orderlanguagewith specialsortsforsituations,actions,andfluents.Thereareno axiomsto constrainthesesorts,andallaxiomsaredomainspecific given by the userfor axiomatizinga particulardynamicsystem.We have useda binaryfunctiondo(a, s) to denotethesituationresultedfromperforminga in s, thusfor a specificfinite sequenceof actionsa1, . . . , ak, we havea term denotingthe situationresultedfrom performingthe sequenceof actionsin s:do(ak, do(ak−1, . . . , do(a1, s) . . .)). However, thereis no way for us to say that onesituationis the resultof performingsomefinite sequenceof actionsin anothersitua-tion. This is neededfor many applications,such asplanningwherethe achievabilityof a goalis definedto betheexistenceof anexecutablefinite sequenceof actionsthatwill makethegoaltrueonceexecuted.Wenow introduceReiter’sfoundationalaxiomsthatmake thispossible.

Briefly, underReiter’s foundationalaxioms,thereis a uniqueinitial situation,andall situationsaretheresultof performingsomefinite sequencesof actionsin thisinitialsituation.This initial situationwill bedenotedby S0, which formally is a constantofsortsituation.

It is worth mentioningherethatwhile theconstantS0 hasbeenusedbeforeto in-formally standfor a startingsituation, it wasnot assumedto be thestartingsituationas underReiter’s situation calculus.It can be said that the differencebetweenRe-iter’s versionof the situationcalculusandMcCarthy’s original versionis thatReiterassumedthefollowing foundationalaxiomsthatpostulatethespaceof situationsasatreewith S0 astheroot:

(16.62)do(a, s) = do(a′, s′) ⊃ a = a′ ∧ s = s′,

(16.63)∀P.[P(S0) ∧ ∀a, s.P (s) ⊃ P(do(a, s))] ⊃ ∀sP (s).

Axiom (16.63)is asecond-orderinductionaxiomthatsaysthatfor any propertyP , toprove that∀s.P (s), it is sufficient to show thatP(S0), andinductively, for any situa-tion s, if P(s) thenfor any actiona, P(do(a, s)). In particular, wecanconcludethat

• S0 is asituation;

Page 14: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

662 16.SituationCalculus

• if s is asituation,anda anaction,thendo(a, s) is asituation;

• nothingelseis asituation.

Togetherwith theuniquenamesaxiom(16.62), this meansthatwe canview thedo-main of situationsas a tree whoseroot is S0, and for eachaction a, do(a, s) is achild of s. Thus for eachsituations thereis a uniquefinite sequenceα of actionssuchthat s = do(α, S0), wherefor any finite sequenceα′ of actions,and any sit-uation s′, do(α′, s′) is definedinductively as do([], s′) = s′, and do([a|α′], s′) =do(a, do(α′, s′)), herewe have written a sequencein Prolognotation.Thusthereisa one-to-onecorrespondencebetweensituationsandfinite sequencesof actionsun-derReiter’s foundationalaxioms,andbecauseof this,Reiteridentifiedsituationswithfinite sequencesof actions.

As we mentioned,thereis a needto expressassertionslike “situation s1 is theresultof performinga sequenceof actionsin s2”. This is achievedby usinga partialorder relation⊏ on situations:informally s ⊏ s′ if s′ is the resultof performingafinite nonemptysequenceof actionsin s. Formally, it is definedby thefollowing twoaxioms:

(16.64)¬s ⊏ S0,

(16.65)s ⊏ do(a, s′) ≡ s ⊑ s′,

wheres ⊑ s′ is ashorthandfor s ⊏ s′ ∨ s = s′.Notice that underthe correspondencebetweensituationsand finite sequenceof

actions,the partial order⊏ is really the sub-sequencerelation:s ⊏ s′ if f the actionsequenceof s is asub-sequenceof thatof s′. Thusto saythatagoalg is achievableinsituations, wewrite

∃s′.s ⊑ s′ ∧ Holds(g, s′) ∧ Executable(s, s′),

whereExecutable(s, s′) meansthat the sequenceof actionsthat takess to s′ is exe-cutablein s, andis definedinductively as:

Executable(s, s),

Executable(s, do(a, s′)) ≡ Poss(a, s′) ∧ Executable(s, s′).

Reiter’s foundationalaxioms(16.62)–(16.65)make it possibleto formally provemany interestingpropertiessuchastheachievability of agoal.They alsolay thefoun-dationfor usingthe situationcalculusto formalizestrategic andcontrol information(see,e.g.,[16,17]). They areparticularlyusefulin conjunctionwith Reiter’s successorstateaxioms,andarepartof whatReitercalledthebasicactiontheoriesasweproceedto describenow.

TodefineReiter’sbasicactiontheories,wefirstneedtodefinethenotionof uniformformulas. Intuitively, if σ is asituationterm,thenaformulais uniformin σ if thetruthvalue of the formula dependsonly on σ . Formally, a situationcalculusformula isuniform in σ if it satisfiesthefollowing conditions:

• it doesnot containany quantificationoversituation;

• it doesnotmentionany variablesfor relationalfluents;

Page 15: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 663

• it doesnotmentionany situationtermotherthanσ ;

• it doesnotmentionany predicatethathasasituationargumentotherthanHolds;and

• it doesnotmentionany functionthathasasituationargumentunlessthefunctionis a functionalfluent.

Thusclear(x, s) is uniformin s (recallthatthis is ashorthandfor Holds(clear(x), s)),but ∀s.clear(x, s) is not asit quantifiesover situations.The formula∀p.Holds(p, s)

is notuniformin s eitherasit containsp which is avariablefor relationalfluents.No-tice thata uniform formulacannotmentiondomain-independentsituation-dependentpredicateslike Poss, ⊏, andCaused. It cannotevencontainequalitiesbetweensitua-tionssuchass = s, but it cancontainequalitiesbetweenactionsandbetweendomainobjectssuchasx �= y, wherex andy arevariablesof sortblock in theblocksworld.

Anotherway to view uniform formulasis by using a first-orderlanguagewith-out the special situation sort. The predicatesof this languageare relationalfluentsandothersituationindependentpredicates.The functionsarefunctionalfluents,ac-tions, and other situationindependentfunctions.A situationcalculusformula Φ isuniform in σ if f thereis a formulaϕ in this languagesuchthatΦ is the resultof re-placingevery relationalfluentatomF(t1, . . . , tk) in ϕ by Holds(F (t1, . . . , tk), σ ) (orF(t1, . . . , tk, σ )) andevery functionalfluenttermf (t1, . . . , tk) by f (t1, . . . , tk, σ ). Inthefollowing, andin Chapter24 on Cognitive Robotics,this formulaΦ is written asϕ[σ ].

Uniform formulasareusedin Reiter’s actionpreconditionaxiomsandsuccessorstateaxioms.In Reiter’s basicaction theories,an actionpreconditionaxiom for anactionA(x1, . . . , xn) is asentenceof theform:

Poss(A(x1, . . . , xn), s) ≡ Π(x1, . . . , xn, s),

whereΠ(x1, . . . , xn, s) is a formulauniform in s andwhosefreevariablesareamongx1, . . . , xn, s. ThuswhetherA(x1, . . . , xn) canbeperformedin a situations dependsentirelyon s.

We have seensuccessorstateaxiomsfor relationalfluents(16.50). In general,inReiter’s basicactiontheories,a successorstateaxiomfor ann-ary relationalfluentFis asentenceof theform

(16.66)F(x1, . . . , xn, do(a, s)) ≡ ΦF (x1, . . . , xn, a, s),

where ΦF is a formula uniform in s, and whose free variables are amongx1, . . . , xn, a, s.

Similarly, if f is an(n + 1)-ary functionalfluent,thenasuccessorstateaxiomforit is asentenceof theform

(16.67)f (x1, . . . , xn, do(a, s)) = v ≡ ϕ(x1, . . . , xn, v, a, s),

where ϕ is a formula uniform in s, and whose free variables are amongx1, . . . , xn, v, a, s.

Notice that requiringthe formulasΦF andϕ in successorstateaxiomsto beuni-form amountsto makingMarkov assumptionin systemsandcontrol theory:theeffectof anactiondependsonly on thecurrentsituation.

Page 16: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

664 16.SituationCalculus

Wecannow defineReiter’sbasicactiontheories[34]. A basicactiontheoryD is asetof axiomsof thefollowing form:

Σ ∪ Dss∪ Dap ∪ Duna ∪ DS0,

where

• Σ is thesetof thefour foundationalaxioms(16.62)–(16.65).

• Dss is a set of successorstateaxioms.It mustsatisfythe following functionalfluentconsistencyproperty: if (16.67)is in Dss, then

Duna ∪ DS0 |= ∀-x.∃vϕ(-x, v, a, s) ∧

[∀v, v′.ϕ(-x, v, a, s) ∧ ϕ(-x, v′, a, s) ⊃ v = v′].

• Dap is asetof actionpreconditionaxioms.

• Duna is thesetof uniquenamesaxiomsaboutactions.

• DS0 is a set of sentencesthatareuniform in S0. This is theknowledgebasefortheinitial situationS0.

Thefollowing theoremis provedby Pirri andReiter[32].

Theorem 16.1 (Relative satisfiability). A basic action theory D is satisfiableiffDuna ∪ DS0 is.

As we mentionedabove, the basicaction theoriesare the starting point to solvevariousproblemsin dynamicsystems.Many of theseproblemscanbe solved usingbasicaction theoriesby first-orderdeduction.But some of them requireinduction.Thosethatrequireinductionaretypically aboutproving generalassertionsof theform∀s.C(s), suchasproving thatacertaingoalisnotachievable.For instance,considerthebasicactiontheoryD whereDap = ∅, Dss = {∀a, s.loaded(do(a, s)) ≡ loaded(s)},andDS0 = {loaded(S0)}. It is certainlytruethatD |= ∀s.loaded(s). But proving thisformally requiresinduction.

Theonesthatcanbedonein first-orderlogic includecheckingwhetherasequenceof groundactionsis executablein S0 andthetemporalprojectionproblem,whichaskswhethera formula holds after a sequenceof actionsis performedin S0. One veryeffective tool for solving theseproblemsis regression,2 which transformsa formula

ϕ(do([α1, . . . , αn], S0))

that is uniform in do([α1, . . . , αn], S0) to a formulaϕ′(S0) that is uniform in S0 suchthat

D |= ϕ(do([α1, . . . , αn], S0)) if f Duna ∪ DS0 |= ϕ′(S0).

If ϕ(do([α1, . . . , αn], S0)) doesnot have functionalfluents,then the regressioncanbedefinedinductively asfollows: theregressionof ϕ(S0) is ϕ(S0), andinductively, if

2Reiter[34] definedregressionfor a moregeneralclassof formulasthatcancontainPossatoms.

Page 17: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 665

α is anactionterm,andσ a situation term,thenthe regressionof ϕ(do(α, σ )) is theregressionof the formulaobtainedby replacingin ϕ(do(α, σ )) eachrelationalfluentatomF(-t , do(α, σ )) by ΦF (-t , α, σ ), whereΦF is theformulain theright sideof thesuccessorstateaxiom(16.66)for F . Whenϕ containsfunctionalfluents,thedefinitionof regressionis moreinvolved,see[34].

For instance,giventhefollowing successorstateaxioms:

F(do(a, s)) ≡ a = A ∨ F(s),

G(do(a, s)) ≡ (a = B ∧ F(s)) ∨ G(s),

theregressionof G(do(B, do(A, S0))) is theregressionof

(B = B ∧ F(do(A, S0))) ∨ G(do(A, S0)),

which is thefollowing sentenceaboutS0:

(B = B ∧ (A = A ∨ F(S0))) ∨ (A = B ∧ F(S0)) ∨ G(S0),

which is equivalentto true.Using regression,we cancheckthe executabilityof a sequenceof actionsin S0,

say[stack(A,B), pickup(C), putdown(C)], asfollows:

1. This sequenceof actionsis executablein S0 if f the following formulasareen-tailedbyD:

Poss(stack(A,B), S0),

Poss(pickup(C), do(stack(A,B), S0)),

Poss(putdown(C), do(pickup(C), do(stack(A,B), S0))).

2. Useactionpreconditionaxiomsto rewrite theabovesentencesinto uniformsen-tences.For instance,thefirst two sentencescanberewritten into thefollowingsentences:

clear(B, S0) ∧ holding(A, S0),

handempty(do(stack(A,B), S0)) ∧ ontable(C, (do(stack(A,B), S0))) ∧

clear(C, (do(stack(A,B), S0))).

3. Regressthe uniform sentencesobtainedin step2, andcheckwhetherthe re-gressedformulasareentailedby Duna ∪ DS0.

16.4 Applications

The situation calculusprovides a rich framework for solving problemsin dynamicsystems.Indeed,Reiter [34] showed that many suchproblemscanbe formulatedinthe situation calculusandsolved usinga formal situation calculusspecification.Heevenhadtheslogan“No implementationwithoutaSitCalcspecification”.

Thefirst applicationof thesituationcalculusis in planningwhereanagentneedsto figureout a courseof actionsthatwill achieve agivengoal.Green[8] formulated

Page 18: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

666 16.SituationCalculus

this problemasa theoremproving taskin thesituationcalculus:

T |= ∃s.G(s),

whereT is the situation calculustheory for the planningproblem,andG the goal.Green’s idea was that if one can find a proof of the above theoremconstructively,thena plancanbe readoff from the witnesssituation term in the proof. He actuallyimplementeda planningsystembasedon this ideausinga first-ordertheoremprover.For variousreasons,the systemcould solve only extremelysimpleproblems.Someresearchersbelieve that Green’s idea is correct.What one needsis a good way toencodedomainspecificcontrolknowledgeasthesituationcalculussentencesto directthetheoremprover intelligently.

Onereasonthat Green’s systemperformedpoorly wasthat the theoryT that en-codestheplanningproblemis notveryeffective.Assumingthattheplanningproblemis specifiedby a basicactiontheory, Reiterimplementeda plannerin Prologthatcanefficiently makeuseof domain-specificcontrolinformationlikethatin [1]. It canevendo open-world planningwherethe initial situation is not completelyspecified.Formoredetailssee[34].

Thesituationcalculushasalsobeenusedto formalizeandreasonaboutcomputerprograms.Burstallusedit to formalizeAlgol-likeprograms[3]. MannaandWaldingerusedit to formalizegeneralassignmentsin Algol 68 [22], andlater Lisp imperativeprograms[23].

More recently, Lin andReiterusedit to axiomatizelogic programswith negation-as-failure [20]. The basic idea is as follows. A rule (clause)P ← G meansthatwhenever G is proved,we canusethis rule to prove P . Thuswe cannamethis ruleby anactionso thattheconsequenceof therule becomestheeffectof theaction,andthebodyof therulebecomesthecontext underwhich the actionwill have theeffect.3

Formally, for eachrule

F(t1, . . . , tn) ← Q1, . . . , Qk, notQk+1, . . . , notQm

Lin andReiterintroducedacorrespondingn-aryactionA, andaxiomatizedit with thefollowing axioms:

Poss(A(-x), s),

[∃ -y1Holds(Q1, s) ∧ · · · ∧ ∃ -ykHolds(Qk, s) ∧

¬(∃ -yk+1, s)Holds(Qk+1, s) ∧ · · · ∧

¬(∃ -ym, s)Holds(Qm, s)] ⊃ F(t1, . . . , tn, do(A(-x), s)),

where -yi is thetupleof variablesin Qi but not in F(t1, . . . , tn).Noticethat¬(∃ -yi, s)Holds(Qi, s) meansthatthegoalQi is not achievable(prov-

able)no matterhow oneinstantiatethe variablesthat are in Qi but not in the headof the rule. This is meantto capturethe “negation-as-failure” featureof theoperator“not” in logic programming.

Now for a logic programΠ , which is a finite setof rules,onecanapplyReiter’ssolutionto theeffect axiomsobtainedthis way for all rulesin Π , andobtaina set of

3Alternatively, onecouldalsoview thebodyof a rule as thepreconditionof thecorrespondingaction.

Page 19: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 667

successorstateaxioms,one for eachpredicateoccurringin the program.4 Thus foreachprogramΠ , wehave acorrespondingbasicactiontheory5 D for it with

DS0 = {F(-x, S0) ≡ false| F is apredicatein Π}.

In otherwords,in theinitial situation,all fluentsarefalse.Now queryansweringin alogic programbecomesplanningunderthecorrespondingbasicactiontheory.

As it turnedout,thisformalizationof logicprogramsin thesituationcalculusyieldsasemanticsthatis equivalentto GelfondandLifschitz’s stablemodelsemantics.Thissituationcalculussemanticscanbeusedto formally studysomeinterestingpropertiesof logic programs.For instance,it canbeprovedthatprogramunfoldingpreservesthissemantics.More interestingly, underthis semanticsandReiter’s foundationalaxioms,derivationsundera programare isomorphicto situations.Thusthoseoperatorsthatconstrainderivationsin logic programmingcanbeaxiomatizedin thesituationscalcu-lus by their correspondingconstraintson situations.Basedon this idea,Lin proposedasituationcalculussemanticsfor the“cut” operatorin logic programming[16].

The most significant applicationso far is the useof the situation calculusas aworkinglanguagefor CognitiveRobotics.For detailsaboutthisapplication,thereaderis referredto thechapteronCognitiveRoboticsin thisHandbook.

16.5 Concluding Remarks

What we have describedso far is just the elementalof the situation calculus.Theonly thing that we careaboutan action so far is its logical effects on the physicalenvironment.We have ignoredmany otheraspectsof actions,suchastheir durationsandtheir effectson the agent’s mentalstate.We have alsoassumedthat actionsareperformedsequentiallyoneat a time andthatthey aretheonly forcethatmaychangethe state of the world. Theseand other issuesin reasoningaboutaction have beenaddressedin thesituationcalculus,primarily asaresultof usingthesituationcalculusas the working languagefor Cognitive Robotics.We refer the interestedreaderstoChapter24and[34].

Acknowledgements

I would like to thankGerhardLakemeyer, HectorLevesque,andAbhayaNayakfortheir veryusefulcommentsonanearlierversionof thisarticle.

Bibliography

[1] F. Bacchusand F. Kabanza.Using temporal logics to expresssearchcontrolknowledgefor planning.Artificial Intelligence, 16:123–191,2000.

4If a predicatedoesnot occuras theheadof a rule, thenaddan axiom to saythatthis relationdoesnothold for any situation.

5Strictly speaking,it is notabasicactiontheoryastheright sideof asuccessorstateaxiommaycontain∃s.Q(s) whenthereis anegationin front of Q in a rule, thusis nota uniform formula.

Page 20: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

668 16.SituationCalculus

[2] A.B. Baker.Nonmonotonicreasoningin theframework of thesituationcalculus.Artificial Intelligence, 49:5–23,1991.

[3] R.M. Burstall. Formal descriptionof programstructureand semanticsin first-orderlogic. In B. MeltzerandD. Michie, editors.Machine Intelligence, vol. 5,pages79–98.EdinburghUniversityPress,Edinburgh,1969.

[4] K.L. Clark.Negationasfailure.In H. GallaireandJ.Minker,editors.LogicsandDatabases, pages293–322.PlenumPress,New York, 1978.

[5] J. Finger.Exploiting constraintsin designsynthesis.PhDthesis,DepartmentofComputerScience,StanfordUniversityStanford,CA, 1986.

[6] M.L. Ginsberg. Readingsin NonmonotonicReasoning. MorganKaufmann,SanMateo,CA, 1987.

[7] M.L. GinsbergandD.E.Smith.ReasoningaboutactionII: Thequalificationprob-lem.Artificial Intelligence, 35:311–342,1988.

[8] C.C. Green.Applicationof theoremproving to problemsolving.In Proceedingsof theInternationalJoint ConferenceonArtificial Intelligence(IJCAI-69), pages219–239,1969.

[9] A.R. Haas.The casefor domain-specificframeaxioms.In F.M. Brown, editor,TheFrameProblemin Artificial Intelligence. Proceedingsof the1987Workshopon ReasoningaboutAction, pages343–348.MorganKaufmannPublishers,Inc,SanJose,CA, 1987.

[10] S.HanksandD. McDermott.Nonmonotoniclogic andtemporalprojection.Arti-ficial Intelligence, 33:379–412,1987.

[11] D. Harel. First-Order Dynamic Logic. Lecture Notes in ComputerScience,vol. 68.Springer-Verlag,New York, 1979.

[12] H. Levesque,R. Reiter,Y. Lespérance,F. Lin, andR. Scherl.GOLOG:A logicprogramminglanguagefor dynamicdomains.Journal of Logic Programming,31:59–84,1997(SpecialissueonReasoningaboutAction andChange).

[13] V. Lifschitz.Pointwisecircumscription.In Proceedingsof theFifth NationalCon-ferenceon Artificial Intelligence(AAAI-86), pages406–410.Philadelphia,PA,1986.

[14] V. Lifschitz. Formaltheoriesof action.In Proceedingsof theTenthInternationalJoint ConferenceonArtificial Intelligence(IJCAI-87), pages966–972,1987.

[15] F. Lin. Embracingcausalityin specifyingthe indirecteffectsof actions.In Pro-ceedingsof the FourteenthInternationalJoint Conferenceon Artificial Intelli-gence(IJCAI-95), pages1985–1993.IJCAI Inc.,MorganKaufmann,SanMateo,CA, 1995.

[16] F. Lin. Applicationsof thesituationcalculusto formalizingcontrolandstrategicinformation:ThePrologcutoperator.Artificial Intelligence, 103:273–294,1998.

[17] F. Lin. Searchalgorithmsin the situation calculus.In H. LevesqueandF. Pirri,editors.Logical Foundationsfor Cognitive Agents: Contributions in Honor ofRayReiter, pages213–233.Springer,Berlin, 1999.

[18] F. Lin. Compilingcausaltheoriesto successorstateaxiomsandSTRIPS-likesys-tems.Journalof Artificial IntelligenceResearch, 19:279–314,2003.

[19] F. Lin andR. Reiter.Stateconstraintsrevisited.Journal of Logic andComputa-tion, 4(5):655–678,1994(SpecialIssueonActionsandProcesses).

[20] F. Lin andR. Reiter.Rulesasactions:A situationcalculussemanticsfor logicprograms.J. of Logic Programming, 31(1–3):299–330,1997.

Page 21: Handbook of Knowledge Representation - USTCai.ustc.edu.cn/cn/seminar/files/Lin_Situation_Calculus_ch16_of_KR.pdf · 650 16. Situation Calculus • stack(x,y)—put block x on block

F. Lin 669

[21] F. Lin andY. Shoham.Provably correcttheoriesof action.Journal of theACM,42(2):293–320,1995.

[22] Z. Mannaand R. Waldinger.Problematicfeaturesof programminglanguages:A situational-calculusapproach.ActaInformatica, 16:371–426,1981.

[23] Z. MannaandR. Waldinger.The deductive synthesisof imperative LISP pro-grams.In Proceedingsof theSixthNationalConferenceonArtificial Intelligence(AAAI-87), pages155–160,Seattle,WA, 1987.

[24] N. McCainandH. Turner.Causaltheoriesof actionandchange.In Proceedingsof the14thNationalConferenceonArtificial Intelligence(AAAI-97), pages460–465.MenloPark,CA, 1997,AAAI Press.

[25] J.McCarthy. Situations,actionsandcausallaws. In M. Minsky, editor.SemanticInformationProcessing, pages410–417.MIT Press,Cambridge,MA, 1968.

[26] J. McCarthy. Epistemologicalproblemsof Artificial Intelligence.In IJCAI-77,pages1038–1044,Cambridge,MA, 1977.

[27] J. McCarthy. Applications of circumscription to formalizing commonsenseknowledge.Artificial Intelligence, 28:89–118,1986.

[28] J.McCarthy. Actionsandothereventsin situationcalculus.In Proceedingsof theEighthInternationalConferenceonPrinciplesof KnowledgeRepresentationandReasoning(KR2002), pages615–628,2002.

[29] J. McCarthy andP. Hayes.Somephilosophicalproblemsfrom thestandpointofartificial intelligence.In B. MeltzerandD. Michie,editors.MachineIntelligence,vol. 4, pages463–502.EdinburghUniversityPress,Edinburgh,1969.

[30] N.J.Nilsson.Principlesof Artificial Intelligence. MorganKaufmann,Los Altos,CA, 1980.

[31] E.P. Pednault.ADL: Exploring themiddlegroundbetweenSTRIPSandthesitu-ationcalculus.In Proceedingsof theFirst InternationalConferenceonPrinciplesof Knowledge Representationand Reasoning(KR’89), pages324–332.MorganKaufmannPublishers,Inc, 1989.

[32] F. Pirri andR. Reiter.Somecontributionsto themetatheoryof thesituationcal-culus.J. ACM, 46(3):325–361,1999.

[33] R. Reiter.Theframeproblemin thesituationcalculus:a simplesolution(some-times)anda completenessresultfor goalregression.In V. Lifschitz, editor. Arti-ficial IntelligenceandMathematicalTheoryof Computation:Papers inHonorofJohnMcCarthy, pages418–420.AcademicPress,SanDiego,CA, 1991.

[34] R. Reiter.Knowledge in Action: Logical Foundationsfor Specifyingand Imple-mentingDynamicalSystems. TheMIT Press,2001.

[35] E.Sandewall. FeaturesandFluents. A SystematicApproach to theRepresentationof KnowledgeaboutDynamicalSystems, vol. I. Oxford UniversityPress,1994.

[36] L.K. Schubert.Monotonicsolutionto theframeproblemin thesituationcalculus:anefficientmethodfor worldswith fully specifiedactions.In H. Kyberg,R.Loui,andG. Carlson,editors.Knowledge Representationand DefeasibleReasoning,pages23–67.Kluwer AcademicPress,Boston,MA, 1990.

[37] Y. Shoham.Chronologicalignorance:experimentsin nonmonotonictemporalreasoning.Artificial Intelligence, 36:279–331,1988.

[38] M. Thielscher.Ramificationand causality.Artificial Intelligence, 89:317–364,1997.