Feature & Fluent revisited: from Event Calculus to Fluent Logic Vincenzo Pallotta Theoretical Computer Science Laboratory Swiss Federal Institute of Technology Lausane
[email protected]
Abstract
In this paper, we make use of a meta-logical representation based on the Kowalski and Sergot's Event Calculus in order to integrate the discrete uent logic (DFL) proposed in Features & Fluents by Erik Sandewall, into a logic programming (LP) setting. As result of this attempt we obtain an extended LP-based language that we call Fluent Logic Programming (FLP). Completeness result are shown with respect to the original DFL semantics.
1 Introduction It is apparent that temporal reasoning plays a central role in the task of qualitative modeling of dynamical systems. Many dierent approaches have been proposed as partial solutions. Only in recent years there has been a trend to pull together all the results of the distinct research activities in the areas of temporal reasoning, qualitative reasoning, knowledge-based planning and model-based diagnosis and develop general frameworks in which they can be interpreted. We focused in our work on two important frameworks (e.g. Event Calculus (EC) and Features & Fluents (F&F)) for describing and reasoning about action and change. Although they may seem to be apparently distant, they can be essentially narrowed into a unique framework. In this paper, we summarize how it is possible to integrate these two formalisms within a logic programming setting making use of meta-logical techniques. As a result of this attempt we obtain the denition of an extended LP-based language that we call Fluent Logic Programming (FLP) which roughly combines the F&F syntax with the semantics of EC. 1
1.1 Event Calculus
The event calculus (EC) [SK95] is a logic programming based formalism capable of dealing with events occurring within time periods and properties of objects which can persist or change over time. EC is based on the following ontologies or domains: T : the temporal domain, that is an algebraic structure with a linear order relation < and equality, F : the properties or features domain, E : the action tokens or events domain. A scenario description is presented by dening the following predicates: happens : E T species the occurrence of an event at a certain time-point, initiates : E F and terminates : E F specify the eects of the successful execution of a certain action, holdsat : F T species the truth value of a property at a given timepoint. The core inference engine is based on the denition of the following rules and relies on the interpretation of negation as nite failure: holdsat(F; T )
happens(E;T1 ); initiates(E; F ); T1 < T; not clipped(T1 ; F; T ):
clipped(T1 ; F; T2 )
happens(E;T ); terminates(E; F ); T1 T; T < T2 :
In the above denition some epistemological and ontological assumptions are made. In our opinion the most remarkable are the following: (i) only instantaneous actions, (ii) non-determinism is not treated adequately, (iii) no partial knowledge and no temporal post-diction1. However there are several successful attempts in order to overcome these problems proving the great exibility of this formalism. For instance, Kakas and Miller in [KM97] have recently proposed the narrative-based language E , which extends the Gelfond and Lifschitz's action description language A on the basis of EC for dealing with explicit continuous time.
1.2 Features & Fluents
Features & Fluent is a logical framework proposed by Erik Sandewall in [San94] for doing qualitative temporal reasoning about inhabited dynamic systems (IDS) and it represents a systematic framework in which qualitative scenario descriptions (e.g. chronicles ) have been classied into a taxonomy in which epistemological and ontological assumptions are used to asses adequacy of proposed computational reasoning techniques. An IDS is formalized by Sandewall as a game between two players: an Ego (e.g. the agent) and a World (e.g. the environment). The syntax of discrete uent logic (DFL) on
1 The temporal post-diction problem consists in inferring pre-conditions of executed actions by the knowledge of their eects.
2
which FLP is based makes use of the following categories for representing scenario description (e.g. chronicles ): Features A feature f is a rst order term which denotes a property of a class of objects that constitute an IDS (e.g. color(traffic_light_#1)), that is a function from the object domain O to the set of feature values V . With V (f ) we denote the codomain of f that is the set of all possible values for the feature f (e.g. V (color(X )) = fred; yellow; greeng). Fluents A uent [t]f is a rst order term which represents a function from time-points to corresponding feature values, and it can be thought of as the trace over time of a particular feature (e.g. [3]color(traffic_light_#1)). Actions An action occurrence [s; t]a happens over an interval of time [s; t] through the intervention of an agent and the action designators domain is denoted by E (e.g. [2; 3]switch(traffic_light_#1)). At the semantic level the models of chronicles are represented by histories . A history is a partial function R : T F ! V where T is the time domain, F is the features domain and V is the feature-values domain. If a specic feature f is chosen, then the resulting function of time R(f ) : T ! V is a uent. Similarly, if a specic time-point t is chosen, then the function obtained R(t) : F ! V is a state.
1.2.1 Underlying Semantics
The Ego/World interaction incrementally updates a structure called nite development which keeps track of all action occurrences and feature changes over an interval of time [0; s]. Let J be the domain of all possible nite developments then we can formally dene the Ego K and the World W as mappings (or transformations) from J to J with the special properties that K preserves the interval [0; s] over which the development is dened, and W extends [0; s] to [0; s0] where s < s0. Since the nite history R (e.g. a history restricted to the closed interval [0; s]) is the main information contained in a nite development J , we do not consider here the whole structure J as in the original Sandewall's work. The way a nite history R is gradually extended by the Ego-World game is specied by a system of rules coded by a so called underlying semantics. We use here an adapted version of the Sandewall's encapsulated semantics as our underlying semantics, that is a pair hIn ; Rstati in which it is specied how the World has to extend the history when an action is carried out by the Ego. In : E R ! 2F species a set of features which are inuenced by a particular action executed in a particular state. Rstat : E R ! 2R similarly species a set of states resulting from the successful execution. Given a state R(s) where s 2 T and an action instance [s; t]a, where a 2 E , invoked by the Ego then a resulting state rj is non-deterministically chosen from Rstat(E; R(s)) = fr1; : : : ; rk g. 3
The new history R0 is obtained from the previous one, R, in the following way: 8 2 (0; s] : R0 ( ) = R( ) f2 = In (a; R(s)) ) 8 2 (s; t] : R0 (f; ) = R(f; ) f 2 In (a; R(s)) ) (R0 (f; t) = rj (f ) ^ 8 2 (s; t) : R0 (f; ) =? Note that the resulting history R0 is undened (e.g. denoted by the symbol ?) for inuenced features in In (a; R(s)) during the interval (s; t). Any Ego/World game is started in a state denoted by R(0) which contains the initial, possibly partial, knowledge about values of involved features. The encapsulated semantics denes the class of scenarios descriptions, K-ReA2 in the Sandewall's taxonomy.
2 Fluent Logic Programming We consider now a meaningful Horn clause-like one3 fragment of the syntax of Sandewall's Features & Fluents [San94] logical language discrete uent logic (DFL) and we dene a new action language, which we call uent logic programming (FLP). An FLP-chronicle is a collection of statements of the following categories:
Law (action laws): statements of either two forms:
[S; T ]a V (f1 = v1 ; : : : ; fn = vn ) ) f := v [S; T ]a V (f1 = v1 ; : : : ; fn = vn ) ) f := [w1 ; : : : ; wk ]
Scd (action occurrences): statements of the form: [s; t]a Obs (observations): statements of the form: [t]f = v where a 2 E , f; f1; : : : ; fn 2 F , v; v1; : : : ; vn; w1; : : : ; wk 2 V , s; t 2 T and S; T are variables ranging on T . Actions, features and feature values
The class K-ReA is the extension of the K-IeA class treated in F&F for dealing with continuous time. The ontological designator ReA denotes inertial scenarios with sequentially executed actions whose alternatives are completely and uniquely specied by theirs preconditions and results. The sub-specialty e stands for encapsulated actions [Pal97]. A larger class K-RACi (e.g. with indipendent concurent actions) has been formally dened by Brandano in [Bra98]. 3 We do not concern here with expressiveness of FLP which can be roughly compared to Horn clause logic with respect to rst predicate logic. 2
4
are rst order terms while the time structure T is essentially hR + ; i4 . As usual capital case is used for logic programming variables. We can partition each FLP-chronicle into three subsets: = Law [ Scd [ Obs5 . The intuitive reading is that given an instance of an action [s; t]a in Scd, the action a is performed during the time interval [s; t]. The actions laws in Law are used to represent temporal causal rules. Action pre-conditions are expressed as a, possibly empty, conjunction of equalities to be checked at the starting time-point of the action duration interval while eects are expressed by assignments (e.g. using the symbol :=) of one or more values to a feature6 . If there exists an action law in Law whose head unies (on the left of the symbol V) with an action occurrence, we can simply replace it with the body of the action law (on the right of the symbol V), substituting the variables with the terms occurring in the action occurrence. Applying this unfolding step to each action in Scd we obtain an expanded version of the original chronicle where Law and Scd are merged in a new set of statements called Law[Scd]. Each action instance [s; t]a is then rewritten according to the matching action law in the form:[s; t](f1 = v1 ; : : : ; fn = vn) ) f := v or in the non-deterministic case: [s; t](f1 = v1 ; : : : ; fn = vn) ) f := [w1; : : : ; wk ]. The set of observation statements Obs is used to assert constraints to the scenario. It is assumed that the dynamical part of the chronicle (i.e. Law and Scd) must be consistent with the observations (e.g. no misperceptions assumption for K-ReA). Viewing FLP as logic programming based language we do not assume any additional interpretation of terms in a FLP-chronicle (e.g. actually a rst order theory) which are all members of its corresponding Herbrand Universe. As an example we can see how the famous Yale Shooting Problem scenario [HM86] can be coded as a FLP-chronicle: Y SP = Law [ Scd [ Obs where HUY SP O [ V [ F [ E and O = fturkey; gung V = ftrue; falseg F = falive(turkey); loaded(gun)g, E = fload(gun); fire(gun; turkey)g and Obs = f [0]alive(turkey) = true: [0]loaded(gun) = f alse:g Scd = f [2; 4]load(gun): [10; 12]f ire(gun; turkey):g Law = f [S; T ]load(X ) V loaded(X ) := true: [S; T ]f ire(X; Y ) V (loaded(X ) = true) ) alive(Y ) := f alse: [S; T ]f ire(X; Y ) V (loaded(X ) = true) ) loaded(X ) := f alse:g: 4 In a constraint logic programming setting, the time structure T can be considered as the constraint domain over real numbers (e.g. CLP(R)). With abuse of notation we denote sets of statements with their corresponding syntactical category. 6 We consider the := operator as a syntactic constructor. 5
5
We can also have non-deterministic actions like the one of spinning the chamber of the gun whose result is randomly yielding either a loaded or an unloaded gun (e.g. the Russian Turkey Scenario proposed in [San94]). The corresponding FLP action law is: [S; T ]spin(X ) V (loaded(X ) = true) ) loaded(X ) := [true; f alse]: The following lemma claims that it is possible to provide an encapsulated semantics for FLP-chronicles thus characterizing the operational behavior of the corresponding Ego/World game. Lemma 2.1 (FLP encapsulated semantics) Let = Law [ Scd [ Obs be a FLP-chronicle over a set of objects O. There exists a unique pair hIn ; Rstati such that for each action occurrence [s; t]a 2 Scd and its corresponding law instance: [s; t](f1 = v1 ; : : : ; fn = vn ) ) f := [w1 ; : : : ; wk ] 2 Law[Scd], if R is a history such that 8i 2 f1; : : : ; ng : R(s; fi) = vi then: 8j 2 f1; : : : ; kg : 9!rj 2 Rstat(a; R(s)) : rj (f ) = vj and f 2 In (a; R(s)). Proof. is a special case of a more general theorem proved in [Pal97]. The set of possible histories for a chronicle represents the set of its intended models and it is denoted by FLP K?ReA () if the chronicle belongs to the K-ReA class in the Sandewall's taxonomy.
2.1 Fixpoint Semantics
We now present an alternative x-point semantics that characterizes the intended models set of a FLP-chronicle (e.g. FLP K?ReA ()) in a declarative manner. The history set over a chronicle is dened by H = 2H where H = fhf; v; ti j f 2 F ^ v 2 V (f ) ^ t 2 T g and F is the set of features occurring in the chronicle . We exploit the fact that a continuous domain can be generated by a countable unions of intervals. Given a FLP-chronicle = Law [ Scd [ Obs let InitObs = f[0; 0]f := v j [0]f = v 2 Obsg its initial completion. The theory InitObs is obtained transforming each initial observation (e.g. observation referring to time-point 0) into a dummy unconditioned instantaneous action executed at time point 0. A FLPchronicle = Law [ Scd [ Obs is nally transformed into a new completed theory 0 = [ Law[Scd] [ InitObs called deterministic completion. For instance, the deterministic completion of YSP is given by Y SP 0 = Law [ Scd [ Obs [ Law[Scd] [ InitObs where additionally: InitObs = f [0; 0]alive(turkey) := true: [0; 0]loaded(gun) := f alse:g Law[Scd] = f [2; 4]loaded(X ) := true: [10; 12](loaded(X ) = true) ) alive(Y ) := f alse: [10; 12](loaded(X ) = true) ) loaded(X ) := f alse:g: 6
The x-point semantics for FLP is based on the chronicle rules and on the denition of a bottom-up inertia immediate consequences operator that is intended to capture the intuition of inertia assumption in real dynamical systems as a generalization of the main event calculus inference rule. Given a chronicle and its deterministic completion 0, we dene: occluded(; f; ; H ) 9s ; t ; v : ([s ; t ](f1 = v1 ; : : : ; fm = vm ) ) f := v ) 2 ^ 2 (s ; t ] ^ 0
0
0
0
0
0
0
m
^ 0
i=1
0
0
0
0
fi ; vi ; s 2 H: 0
clipped(;f; t; ; H ) 9s ; t ; v : ([s ; t ](f1 = v1 ; : : : ; fm = vm ) ) f := v ) 2 ^ ts ^t q. More formally, given a chronicle , let S1; S2 be two WFHs, then S1 v S2 if and only if S1 = S2 _ 9t0 > q : t0 < 1 ^ q = supft j S1 jt = S2 jt g ^ 8 2 (q; t0 ] : fhf; v; i 2 S1 g = fhf; v; q i 2 S1 g where S jt = fhf; v; i 2 S j tg: The relation < is dened as usual over reals and t0 < 1 represents the fact that t0 must be a nite real number. The I operator preserves only the initial segment of the history and generates a new history by removing pieces of the old history when new preconditions for some actions
are found. More details about the WFHs is provided in [Pal97] where S ; v has been showed to be a complete partial order (cpo) with the empty
setconsidered as ?. Moreover I is a monotonic operator over the cpo S ; v . Since I is dened by a nite number of nitary conditions8 (i.e the predicates change, occluded and clipped), so it is also a continuous operator. Hence there exists its least x point dened by: inertia() = fix(I ) = I! (;). As an example consider again the YSP chronicle. Starting from the empty history we have: IY1 SP = IY SP (;) = fhalive; true; ti j t 2 [0; 1)g [ fhloaded; false; ti j t 2 [0; 2]g [ fhloaded; true; ti j t 2 [4; 1)g: The second iteration of the IY SP operator nds the pre-conditions for the action fire veried, removes the subset fhalive; true; ti j t 2 (10; 1)g from 8
Conditions are nitary since actions occurrences are ground.
8
the old history, and adds the set fhalive; false; ti j t 2 [12; 1)g. The history restricted to the feature loaded is updated in a similar way. After the second iteration we get: IY2 SP = IY SP (IY1 SP ) = fhalive; true; ti j t 2 [0; 10]g [ fhalive; false; ti j t 2 [12; 1)g [ fhloaded; false; ti j t 2 [0; 2]g [ fhloaded; true; ti j t 2 [4; 10]g [ fhloaded; false; ti j t 2 [12; 1)g Observe that IY1 SP v IY2 SP since they coincide up to time point 10 and IY2 SP adds more information about the result of action re which occurs at a later period (e.g. [10; 12]fire(gun; turkey)). Furthermore IY2 SP is a x-point for IY SP since no more information will be added during any further iteration. A deterministic chronicle has only one intended model (its complete history). To extend the x-point semantics to non-deterministic chronicles, we generate a set of deterministic histories and make their union in order to obtain the whole set of possible intended models. These histories are obtained using a set of additional chronicle theories called hypothetical theories set (e.g. Hyp()) in which we have a deterministic theory for each combination of feature assignments taken from the non-deterministic actions. Partial knowledge about the initial state can be modeled as a special case of non-determinism where a dummy instantaneous non-deterministic action with no pre-conditions is executed at time-point 0, assigning all possible values to each feature for which there is no initial knowledge (e.g. no initial observations). Hyp() is further restricted to those hypotheses which are consistent with the observations made after the initial time-point and it is obtained by removing those theories which generate histories not containing all the triples hf; v; ti corresponding to each observation [t]f = v in Obs9 such that t > 0: Hyp() jObs = fhyp 2 Hyp()j 8f; v; t > 0 : ([t]f = v 2 Obs ) hf; v; ti 2 inertia( [ hyp)g The x-point semantics for FLP is dened as the union of deterministic and non-deterministic models. Given a FLP-chronicle , then: [ finertia( [ h)g: Comp() = finertia()g [ h2Hyp()jObs
The following theorem claims that our x-point semantics for FLP is sound and complete w.r.t. the extension of Sandewall's encapsulated semantics to the K ? ReA class of FLP-chronicles. 9
More details in [Pal97, PT98]
9
Theorem 2.1 Let = Law [ Scd [ Obs be a FLP-chronicle and let FLP () the set of all possible histories computed as result of all posK?ReA sible Ego-World games corresponding to the unique pair hIn ; Rstati for starting from an initial state R(0) such that 8[0]f = v 2 Obs : R(0; f ) = v, then for each feature f 2 F: 9R 2 FLP K?ReA () : R(f; ) = v , 9H 2 Comp() : hf; ; vi 2 H:
Proof. (sketch, details in [Pal97]). For simplicity we consider here only the case of deterministic chronicles, hence the model set contains only one history, that is: FLP K?ReA () = fRg and Comp() = finertia()g and we also exploit the epistemological assumption K which allows us to assume no misperceptions and thus ignore observations in case of deterministic actions. Observe that given time-point , the value of R(f; ) depends exclusively on previous states. The proof is made by induction on the construction of the history using the inertia immediate consequence operator I. We consider two histories H1 v H2 which coincide up to time point s and such that H2 = I(H1). It is easy to check that in our order relation two histories may coincide only up to a time-point where an action [s; t]a is performed. Assuming that the theorem holds with respect to the history H1 , that is Rjs = H1, we show that there exists a time-point t s such that Rjt = H2 2
2.2 Meta-logical Semantics
In our investigation summarized in [Pal97] we also provide a meta-logical implementation for FLP, where FLP-theories are transformed into normal logic programs [AB94]. The meta-representation of is denoted by (). Furthermore we add a set of domain rules D characterizing the feature values domain, a set of completion rules and a vanilla meta-interpreter (i.e. the demo predicate) [HG98] augmented by composition operators for theories [BCT97] and negation by failure. Models of are computed as the x-point of the Fitting's immediate consequence operator V where V = D [ () [ [ for which SLDNF resolution has been showed to be sound and complete [AB94]. The two theories initial and inertia represent the core of the inference which can be viewed as an extension of the event calculus where instantaneous events have been replaced by extended duration actions and properties have been generalized by features (e.g. properties are boolean valued features). Furthermore, we compose the meta-level representation of , completed by initial and inertia, with each non-deterministic hypothetical theory selecting only those consistent with all observations. Thus we obtain proof-theoretically exactly all the intended 10
models (histories) computed by means of the x-point semantics and hence by the Sandewall's encapsulated semantics. In a similar fashion, extensions of event calculus to deal with non-determinism and incomplete knowledge have recently been proposed by Shanahan [Sha97]. It is worthwhile to remark that factorizing and selecting models consistent with the observations during the meta-transformation phase increases the overall performance since the temporal post-diction problem is solved by a bounded number of deductions.
3 Conclusions and Future Works In this paper we presented two alternative semantics for FLP-chronicles belonging to the Sandewall's class K ? ReA of scenario descriptions. To be more precise, we deal only with ground scenarios (i.e. the Kg ? ReA class), where we do not allow the use of any global variable and partially specied action instances. However, in [Pal97] we proposed an abductive semantics that solves scenarios with non-ground temporal components starting from the well known work of Esghi-Kowalski [EK89]. Moreover the meta-logical semantics can been extended to the full class K ? RA10 for dealing with trajectories. Among possible future and related works we envision that reasoning about action and change, and FLP in particular, can be fruitfully applied to temporal modeling of multimedia applications [FM99] and reasoning about properties of logical reactive systems [BES98]. Along these lines we consider further developments of FLP for suitably dealing with these possible applications.
3.1 Acknowledgments
I would like to thank Franco Turini who supported this research and advised me on how to overcome most of the problems I faced during the development of my M.Sc. thesis. I would like also to thank people at the LITH laboratory (in particular Afzal Ballim and Giovanni Coray) where I am currently employed for supporting my further research on this subject. 10 the full class K ? RA is obtained relaxing the hypothesis that changes of features happens randomly during the duration of the aecting actions. This is denoted by the ontological designator e. In the most general case it is possible to provide a number of functions (e.g. in case of non-deterministic functions), called trajectories, to specify the (possibly continuous) changes of feature values during the action duration period. Trajectory semantics for K ? RA can be found in [Bra98].
11
References [AB94] Krzysztof R. Apt and Roland N. Bol. Logic programming and negation: A survey. The Journal of Logic Programming, 19 & 20:972, May 1994. [BCT97] A. Brogi, S. Contiero, and F. Turini. Programming by Combining General Logic Programs. Technical Report 97-02, Department of Computer Science, University of Pisa, 1997. [BES98] J.J. Blanc, Rachid Echahed, and Wendelin Serwe. Towards reactive functional logic programming languages. In Herbert Kuchen, editor, Proc. of 8th Workshop on Functional and Logic Programming, 1998. [Bra98] Sergio Brandano. A logic-based calculus of uents. Technical Report TR-98-01, Dipartimento di Informatica, January 12 1998. Sun, 25 Jan 1998 18:08:16 GMT. [EK89] K. Eshghi and R. Kowalski. Abduction compared with negation by failure. In G. Levi and M. Martelli, editors, Proceedings of the 6th International Conference and 5th Symposium on Logic Programming, pages 234254. MIT Press, 1989. [FM99] Nastaran Fatemi and Philippe Mulhem. A conceptual graph approach for video data representation and retrieval. In M. Berthold, editor, Proceedings of third symposium on Intelligent Data Analysis IDA'99. Lecture Notes in Computer Science, 1999. [HG98] P. M. Hill and J. Gallagher. Meta-programming in logic progamming. In D. M. Gabbay, C. J. Hogger, and J. A. Robinson, editors, Handbook of Logic in Articial Intelligence and Logic Programming, volume 5, pages 421498. Oxford University Press, 1998. [HM86] Steve Hanks and Drew McDermott. Default Reasoning, Nonmonotonic logics, and the Frame Problem. In Proceedings of the Fifth National (U.S.) Conference on Articial Intelligence, pages 328333, Los Altos, CA, 1986. Morgan Kauman. [KM97] A. Kakas and R. Miller. A simple declarative language for describing narratives with actions. The Journal of Logic Programming, 1997. 12
[Pal97] Vincenzo Pallotta. Integrazione della programmazione logica e della logica dei uenti. Master's thesis, Universitá di Pisa, december 1997. [PT98] Vincenzo "Pallotta and Franco" Turini. Towards a uent logic programming. Technical Report TR-98-03, Dipartimento di Informatica, March 9 1998. Wed, 11 Mar 1998 09:26:54 GMT. [San94] E. Sandewall. Features and Fluents. Oxford Press, 1994. [Sha97] M.P. Shanahan. Solving the Frame Problem. MIT Press, 1997. [SK95] Fariba Sadri and Robert A. Kowalski. Variants of the event calculus. In Leon Sterling, editor, Proceedings of the 12th International Conference on Logic Programming, pages 6782, Cambridge, June1318 1995. MIT Press.
13