Specifications for Programs From: AAAI Technical Report SS-95-07. Compilation copyright © 1995, AAAI (www.aaai.org). All rights reserved. Rob Miller Departmentof Computing, Imperial College of Science, Technology& Medicine, 180, Queen’s Gate, London SW72BZ, ENGLAND email: [email protected]

Abstract A version of the Situation Calculus is presented whichis Many-sortedfirst order predicate calculus together with able to deal with informationabout the actual occurrenceof parallel and prioritised is used to describe actions in time. Baker’s solution to the the Narrative Situation Calculus. Variable names begin using circumscriptionis adaptedto enable default reasoning with a lower case letter. All variables in formulas are about action occurrences, as well as about the effects of universally quantified with maximumscope unless actions. A translation of Situation Calculus style theories into Event Calculus style logic programsis defined, and otherwise indicated. To simplify descriptions of the results are given on its soundnessand completeness. implementations, logic programsare written in a subset of the same language, supplemented with the symbol "not" 1. Introduction (negation-as-failure). Meta-variablesare often italicised, that, for example, "F" might represent an arbitrary ground This paper compares two formalisms and two associated term of a particular sort. The parallel circumscription of default reasoning techniques for reasoning about action m predicates P1 ..... V the Situation Calculus using a variant of Baker’s Pn in a sentence T with V1 ..... k circumscriptive solution to the frame problem [Baker, allowedto vary is written as 1991], and the logic-programming based Event Calculus [Kowalski & Sergot, 1986], in which default reasoning is CIRC[T; Pl ..... Pn; V1..... Vk] realised through negation-as-failure. The version of the Situation Calculus used enables information about the If RI ..... Rmare also circumscribed, at a higher priority occurrences of actions along a time line to be represented. thanPI ..... Pn, this is written as A course of actions identified as actually occurring is referred to as a narrative, and this formalismis referred to CIRC[T; R1 ..... Rm; P1 ..... Pn,VI..... Vk] as the Narrative Situation Calculus. Information about a A CIRC[T; PI ..... Pn ; VI ..... Vk] narrative might be incomplete, so that default assumptions might be required. The circumscription policy incorporated Justification for this notation can be found, for example, in the Narrative Situation Calculus minimises action in [Lifschitz, 1995]. One other piece of notation for occurrences along the time-line. The original Event specifying uniqueness-of-names axioms will be useful. Calculus incorporates an analogous default assumption UNA[F1,..,Fm]represents the set of axioms necessary to that the only action occurrences are those provable from ensure inequality betweendifferent terms built up from the the theory. (possibly 0-ary) function symbols1 . ... Fm. It stands for the axioms The present paper shows that under certain circumstances the Narrative Situation Calculus may be regarded as a Fi(xl...... Xk)# Fj(Yl...... Yn) specification for Event Calculus style logic programs. The programs presented here are described as "Event Calculus for i0. predicates to describe the effects of actions, becauseof the i form of their persistence axioms, and because of the use of Xk)=Fi(yI ...... A xk=Yk] a time-line rather than the notion of a sequenceor structure Fi(x1 ...... Yk)--"> [x 1 =Y1 A...... of situations. They differ from someother variants of the Event Calculus in that they do not assume complete 2. A Narrative Situation Calculus knowledgeof an initial state, and in that properties can In this section an overview is given of the Narrative hold (and persist) even if they have not been explicitly Situation Calculus employed here as a specification initiated by an action. The programsdescribed are "sound" language. This work is presented more fully in [Miller & for a wide class of domains in that they only allow Shanahan, 1994]. A class of many sorted first order derivation of "Holds" information which is semantically languages is defined, and the types of sentence which can entailed by their circumscriptive specifications. Where appear in particular domaindescriptions are then described. total information is available about the initial state of Finally, the circumscription policy is discussed. affairs, the programs are also "complete" in this same sense. Definition {Narrative domain language }. A Narrative Twomore domain independent axioms are included in the domainlanguage is a first order languagewith equality of Narrative Situation Calculus, concerning properties of four sorts; a sort ct of actions with sort variables narratives and time-points: {a,al,a2,... }, a sort 0g of generalisedfluents I with sort variables {g,gl,g2.... }, a sort o of situations with sort State(t)=S0 6-- --,3al,tl [Happens(al,tl) ^ tl

withsort variables{ f.,f_l,f.2,... }, andthe sub-sortSf of Axiom(N1) relates all time points before the first action fluents with sort variables{f, fl,f2,... }, suchthat occurrence to the initial situation SO, and Axiom(N2) says that if action A1 happens at TI, T1 is before T and 0+ n 0- = O 0+ L; 0- = 0f Of c 0g no other action happens between TI and T, then the situation at is equal to Result(A1,State(Tl)). It has time-point constant symbolscorresponding to the real numbers,a finite numberof action and positive fluent Several types of axioms are either required or ~illowed in constants, a single situation constant SO, and no negative Narrative Situation Calculus theories 3. The following or generalised fluent constants. It has five functions: definitions specify the form of such sentences. Result: tx x c~ ~ o, And: 0g x Sg --~ 0g, Neg: $+ ---) 0-, Sit: Sg ~ t~, and State: R --~ ~, and six predicates (other Definition {Initial conditions description}. A formula is than equality): Holds ranging over 0g x ~, Ab ranging an initial conditions description if over a x Sf x o, Absit ranging over Sg, < (infix) it is of the form ranging over R x R, < (infix) ranging over R x R, and Happens ranging over ct x R. [] Holds(F, S0) or Holds(Neg(F),S0)

Only models are considered in which the predicates < and < whereF is a positive fluent constant. [] are interpreted in the usual way as the "less-than" and "less-than-or-equal-to" relationships betweenreal numbers. Definition {Action description}. A formula is an action "Happens(A,T)"represents that an action A occurs at time description if it is of the form T2, and "State(T)" represents the situation at time Holds(F, Result(A,s)) Several domain independent axioms will always appear in or Holds(Neg(F),Result(A,s)) Narrative Situation Calculus theories. The following five axioms are taken from [Baker, 1991]. or Holds(F,Result(A,s)) [Holds(Fl,s) ^ ... ^ Holds(Fn,s)] Holds(And(gl,g2),s) --- [Holds(gl,s) AHolds(g2,s)] or Holds(Neg(F),Result(A,s)) Holds(Neg(f+),s)-- ~Holds(f+,s) 032) [Holds(Fl,s) ^ ... ^ Holds(Fn,s)] Holds(g,Sit(g)) 4-- -,Absit(g) 033) whereA is an action constant, F, FI .... Fnare groundfluent Sit(g l)=Sit(g2) -o g 1 034) terms, and for each i and j, l.g.i,j

1/46 of-situations axioms (B I)-(B4), axioms (NI) and (N2), Example 1 {The Yale Shooting Problem, Nysp]. uniqueness-of-names axiom Holds(Neg(Alive),Result(Shoot,s)) (Y1) UNA[FI...... Fn,And,Neg] ^ UNA[AI...... Am] Holds(Loaded,s) Holds(Loaded,S0) (Y2) and a domainclosure axiomfor fluents Holds(Alive,S0) (Y3) f=F1 v .... v f=Fn v f=Neg(Fl) v .... v f=Neg(Fn ) UNA[Alive,Loaded,And,Neg] CY4) UNA[Sneeze,Shoot] Although domain constraints have not been explicitly (Y5) included in narrative domain descriptions, care must be f=Alive v f=Loaded v CY6) taken, since domain constraints might be derived from f=Neg(Alive) v f=Neg(Loaded) pairs of action descriptions, together with Axiom(B2). Happens(Sneeze,1) (Y7) For example, from the two action descriptions Happens(Shoot,3) (Y8) [] Holds(FI,Result(A,s)) ~-- Holds(F2,s) and Becauseit is not initially specified, Example2 below is Holds(Neg(Fl),Result(A,s)) ~-- Holds(F3,s) useful in illustrating that logic program translations cannot be used to derive Holds literals not warranted by the sentence ~[Holds(F2,s) ^ Holds(F3,s)] can be derived. their specifications (i.e. that they are "sound"). It concerns In fact, domainconstraints are entailed only from pairs of an electric gate, connectedto a button whichwill open the action descriptions of this form (see [Miller, 1994]). Hence gate whenpressed, provided the system is connected to an the following definition is included, of narrative domain electric supply. The gate is initially closed. There is no descriptions with no implicit domainconstraints. information as to whetherthe system is initially connected to an electrical supply, hence it is not possible to deduce Definition { Fluent independence}A narrative domain that the gate will be either open or closed after the button description N isfluent independentif for every pair of has been pressed. The full theory is referred to as NGATE. action descriptions in N of the form Example 2. { NGATE}. [Holds(F,Result(A,s)) [Holds(/~,s) ^ ... ^ Holds(Fro,s)]] Holds(Open,Result(Press,s)) (GI) and Holds(Connected,s) [Holds(Neg(F),Result(A,s)) Holds(Neg(Open),S0) (G2) [Holds(Fm+l,S)^ ... ^ Holds(Fn,s)]] UNA[Open,Connected,And,Neg] (G3) f---Open v f--Connectedv (G4) there is somei, l>i>m, and somej, m+l>j>_n,such that f=Neg(Open) v f=Neg(Connected) F,=Neg(Fj) or 6=Neg(~) Happens(Press,l) (G5) The following definition is also useful. It identifies [] narrative domaindescriptions in which information about what holds in the initial situation is complete. For a given domain description D, Baker’s original circumscription policy is Definition {Initially specified narrative domain description } A narrative domaindescription Nis initially CIRC[D; Absit ; Ab,Result,Holds,S0] specified if for every positive fluent constant F in the ^ CIRC[D; Ab ; Result,S0] language, either Holds(F, S0) or Hoids(Neg(F),S0) initial conditions description in N. [] The above policy will be referred to as CIRCb.As regards the Yale Shooting Problem, Baker shows that Twoexamples of fluent independent narrative domain descriptions are given below.The first is initially specified CIRCb[Nysp] and the second is not. Only the domain-dependentaxioms Holds(Neg(Alive),Result(Shoot,Result(Sneeze,S0))) are given. Example1 is a version of the Yale Shooting Problem, including a simple narrative in which a sneeze The Narrative Situation Calculus introduces an extended action occurs at time 1 followed by a shoot action at time circumscription policy representing the assumption that 3. Thefull theory is referred to as Nysp. the only action occurrencesare those explicitly described in the narrative description. The separation of sentences in theories into those which describe actions’ effects and those which refer to the narrative allows this to be achieved in a natural way simply by circumscribing Happens in parallel with Ab, while varying State along which is "sound" inthe following sense; for any ground with Result. As before, Absit is circumscribed at a higher fluent term F and real number x, the positive literal priority so as to ensure the existence of all consistent "Holds_at(F,x)" is SLDNF-derivablefrom EC[N] only situations. Thus, given a narrative domaindescription N, CIRCa[N]W Holds(F, State(x)), The following definition the extendedcircumscription policy is of fluent converseswill be useful.

CIRC[N; Absit ; Ab,Happens,Result,Holds,S0,State] Definition {Converse of a fluent} Let F be a ground A CIRC[N; Ab,Happens; Result,S0,State] fluent term. Then the converse of F, written F*, is

This circumscription policy is referred to as CIRCn.Three ¯ Neg(F) if F is a positive fluent constant theoremsare useful at this point. Full proofs of these can ¯ Ft if F is of the form Neg(F3for some be found in [Miller, 1994]. The first two theorems show positive fluent constant F’ [] that for the class of theory under consideration minimisation of Happens does not interfere with the Occurrence descriptions are included directly in logic minimisation used to solve the frame problem. The third programs as conditionless clauses. The following theorem shows that, unsurprisingly, circumscribing definitions show howinitial conditions descriptions and Happenshas the same effect as forming its completion, action descriptions are translated into domain-specific Initially, Initiates and Terminatesclauses. Theorem1. Let N be a narrative domain description. Then Definition {IN[IC] }. Let F be a ground fluent term and CIRCa[N] ~ CIRCb[N] [] let IC be an initial conditions description of the form "Holds(F, S0)". The programclause IN[IC] is defined Theorem2. Let N be a narrative domain description, and let Wbe a sentence whichdoes not contain the predicate Initially(F) [] symbol Happens and does not contain the function symbol State. Then Definition {INIT[AD]and TERM[AD]}. Let F, Ft .... Fn be groundfluent terms, A an action constant, s a situation CIRCa[N] W W if and only if CIRCb[N] ~ W [] variable and t a time-point variable. Let ADbe an action description of the form Theorem3. Let N be a narrative domain description with k occurrencedescriptions. If k<0 and the set of Holds(F,Result(A,s)) occurrence descriptions is {Happens(Ai,Ti)l< i~"k} then [Holds(Fl,s)A ...... A Holds(Fn,s)]

k The program clause INIT[AD]is defined as CIRCn[N] Happens(a,t) V[a=Ai A t=Ti] i=l Initiates(A,F,t)<---- [Holds_.at(Fl,t)A...... A Holds_at(Fn,t)] and if k=0 then CIRCa[N]~ --da,t[Happens(a,t)] [] and the program clause TERM[AD]is defined as Theorems 1, 2 and 3 together with Axioms(N1) and (N2) allow the deduction of what fluents hold at different time Terminates(A,F*,t)~-- points, i.e. they facilitate temporal projection. For example, in the Yale Shooting Problem (Example 1), [not Holds_at(Ft*,t)A...... A not Holds_at(F*,t)] 4 can be shown that In the definition above, although Terminates clauses have CIRCn[Nysp]~ Holds(Neg(Alive),State(5)) a similar structure to Initiates clauses, their bodies incorporate negated (not) literals with fluent converses as their first arguments. As will be seen from the examples 3. A Translation into Logic Programs below, this difference becomes important for domains For the purposes of deriving information about what holds where information about the initial situation is along the time-line, the narrative domaindescriptions of incomplete. Whereas Initiates clauses describe the the previous section can be translated into Event Calculus immediateeffects of actions, Terminates clauses play the style logic programswhich do not contain situation terms role of domain-specific "abnormality" clauses which help or arguments. In this section, logic programsare defined determine those fluents which do not persist through an which use the following predicate symbols: "Holdsat", action occurrence. The following definition gives a "Initially", "Initiates", "Terminates", "ClippedBetween", complete translation of a narrative domaindescription into "ClippedBefore", "Happens", "<" and "~". Given a a logic program. narrative domaindescription N, the aim is to define a logic program EC[N]which facilitates temporal projection and

4Aderivation of this is given in [Miller, 1994] Definition {EC[N]}. Given a narrative domain Initially(Alive) IN[(Y3)I description N with action descriptions ADI,..,ADn, initial Happens(Sneeze,1) (Y7) condition descriptions ID l,..,IDm and occurrence descriptions ODI,..,ODkthen the logic program EC[N]is Happens(Shoot,3) 0:8) defined as so that EC[Nysp]I-SLDN Holds_at(Neg(Alive),5) {INIT[AD1] .... INIT[ADn],TERM[ADI] .... F TERM[ADn],IN[IDI] .... IN[IDm], ODI,..,ODk} In Example2 (of the electric gate), the initial situation was not fully specified. EC[NGATE]consists of the clauses together with the following domain-independentclauses (ECI)-(EC4) together with the clauses Holdsat(f,t) <--- (ECD Initiates(Press,Open,t)<---- INrr[(G1)] [Initially(f) not ClippedBefore(f,t)] Holds_at(Connected,t) Holdsat(f, t3) ~-- (EC2) Terminates(Press,Neg(Open),t) TERM[(GI)I [Happens(a,tl) A tl