Multi-valued Action Languages in CLP(FD)

Action description languages, such as A and B, are expressive instruments introduced for formalizing planning domains and planning problem instances. The paper starts by proposing a methodology to encode an action language (with conditional effects a…

Authors: Agostino Dovier, Andrea Formisano, Enrico Pontelli

Under conside ratio n for public ation in Theory and Practice of Logic Pro grammi ng 1 Multi-valu ed Action Languages with Constraints in CLP(FD) ∗ A GOSTINO DO VIER Univer sit ` a di Udin e, Dipartimen to di Mate matica e Informatica ( e-mail: dovier@dimi .uniud.it ) ANDREA FORMISANO Univer sit ` a di P erugia, Dipartimen to di Mate matica e Informatica ( e-mail: formis@dmi. unipg.it ) ENRICO PONTELLI New Me xico State University , Department of Computer Science ( e-mail: epontell@cs .nmsu.edu ) submitte d 5 January 2009; r evi sed 9 October 2009; accept ed 10 Decemb er 2009 Abstract Action description l anguages, such as A and B (Gelfond and Lifschitz 1998), are expressi ve instru- ments introduced for formalizing p lanning domains and planning problem instan ces. The paper starts by prop osing a methodo logy to encode an action lan guage (with conditiona l effects and static causal laws), a slight va riation of B , using Constraint Logic Pro gramming over F inite Domains . The ap- proach is then generalized to raise the use of constraints to the leve l of the action language itself. A prototype i mplementation has been de velop ed, and t he preliminary results are presented and dis- cussed. T o a ppear in Theory and Practice of Logic Pr ogra mming (TPLP). KEYWORDS : Action Description Lang uages, Kno wledge Representation, Planning , Constraint Log- ic Programming 1 Introduction The constructio n of intelligent agents that c an be effective in real-world en viron ments has been a goal of resear chers fro m th e very first days of Artificial Intelligen ce. It has long been recog nized tha t an in telligent agen t must be able to a cquir e , r e pr esen t , and r eason with k nowledge. As such, a reasoning compo nent has been an inseparable p art of m ost agent architectures in the literature. ∗ This manuscrip t is an extended ve rsion of the paper “Mul ti-val ued Action Langua ges with Constraints in CLP (FD)” in the Proceedings of the Internati onal Conference on Logic Programming, pages 255–270, Springer V erlag, 2007. 2 A. Dovier , A. F ormisano, E. P on telli Although th e u nderlying repr esentations and i mplementa tions may v ary b etween agents, the reasoning componen t o f an agent is o ften responsible for m aking decisions that a re critical to its existence. Logic p rogramm ing langu ages o ffer many p roperties that make them very su itable as knowledge representation languages. Their declarative n ature suppo rts the modular dev el- opment of p rovably correct reason ing modu les (Baral 200 3). Recursive definitions can b e easily expressed an d r easoned up on. Con trol k nowledge and heu ristic info rmation can be declaratively and incr ementally introd uced in the reasoning p rocess. Furthe rmore, many logic progr amming languages of f er a natural suppo rt for non-mon otonic reasoning, which is considered essential fo r common -sense reasoning (Lifschitz 1999). These feature s, along with the presen ce of ef ficien t inference engines (Apt 200 3; Marriott and Stucke y 1998; Simons 2000; Giunchiglia et al. 2004b; Ge bser et al. 2007), make logic pr ogramm ing an attractive pa radigm for knowledge representation and reasoning. In the context o f k nowledge representation and reason ing, a very impo rtant app lica- tion of logic pr ogramm ing has been in the domain o f r eason ing about actions an d change and, more specifically , p lanning . Plann ing p roblems have been effectively encoded u sing Answer Set Prog ramming (ASP) ( Baral 2003)—where d istinct answer sets rep resent dif- ferent tr ajectories leading to the de sired g oal. Other logic pro gramming par adigms, e. g., Constraint Logic Pr ogramming over F inite Doma ins (CLP(FD) ) (Jaffar and Maher 1994; Apt 2003), h av e been used less freq uently to handle p roblems in reason ing abo ut ac- tions (e.g. , (Reiter 2001; Thielscher 2002a)). Comparab ly more empha sis has been placed in e ncoding p lanning p roblems a s (non-lo gic prog ramming) constraint satisfaction prob- lems (Lopez and Bacchus 2003). Recent proposals on representing and reasoning about actions and chang e h av e relied on the use o f c oncise and h igh-level lan guages, co mmonly re ferred to a s action d escription languages ; s ome well-known e xamples include the langu ages A and B ( Gelfond and Lifschitz 1998) and extension s like K (Eiter et al. 2004) and AD C (Baral et al. 2002). Actio n langu ages al- low one to write pro positions that descr ibe the effects of actions on states, and to create queries to in fer pro perties of th e un derlying tra nsition system. An action do main descrip- tion is a specification of a planning domain using an action language. The goal of this work is to explore the relev a nce of constraint solving and constraint logic progr amming (Marriott and Stuckey 1998; Apt 2003) in dealing with action langu ages and planning . The push tow ards th is explorator y study cam e f rom r ecent invest igations (Dovier et al. 2005; Dovier et al. 2009a) aimed at comp aring the pr acticality an d efficiency of an swer set p ro- grammin g versus constraint log ic pro grammin g in solv ing various combinato rial an d op- timization prob lems. The study indicated that CLP of f ers a valid alternative, especially in terms of efficienc y , to ASP when dealing with plann ing proble ms. Fu rthermor e, CLP offers the flexibility o f pro grammer-developed search strategies and the ab ility to hand le numerical constraints. The first step, in th is p aper, is to illustrate a scheme that d irectly pr ocesses an action description specification, in a langu age sim ilar to B (Gelfon d and Lifschitz 19 98), p ro- ducing a CLP( FD) p rogram th at can b e used to compute solution s to the plan ning p rob- lem. Our encoding has some similarities to the o ne presen ted by Lopez and Bacch us (Lopez and Bacchus 2003), althoug h we rely o n constraint log ic program ming in stead of Multi-valued Action Languages in CL P(FD) 3 plain con straint satisfaction ( CSP), and our action language suppo rts static causal laws and non- determinism—wh ile the work of Lop ez and Bacchus is restricted to STRIPS-like specifications. While the first step relies o n using co nstraints to co mpute solutions to a plann ing prob - lem, the second step b rings the expressiv e power of con straints to th e level of the action languag e, by allowing multi-valued fluents and constraint-p roducin g a ctions to be u sed in the d omain specification. Th e extend ed action languag e (named B M V ) can b e as easily supported by the CLP(FD) fra mew ork, and it allows a declarative encodin g of pr oblems in volving ac tions with resources, delayed ef f ects, an d mainten ance go als. Th ese ideas ha ve been dev eloped in a prototype, and some preliminary e x perimen ts are repo rted. W e believe that the use o f CLP(FD) can greatly facilitate the transition of declara ti ve ex- tensions of action lang uages to co ncrete and effecti ve implementations, overcoming some inherent limitations (e.g., efficiency and limited handling of numb ers) of other logic-based systems (e.g., ASP). The p resentation is organize d as follows. Th e first par t of our paper ( Sections 2 an d 3) provides an overview of the action lan guage B and illustrates o ur approac h to mo deling problem specifications in B u sing constraints and constraint lo gic progr amming. Section 4 provides motiv ations f or the propo sed m ulti-valued extensions. Section 5 introduces the full sy ntax of the ne w lang uage B M V . Th e action langu age B M V expands the previous languag e to a lang uage with co nstraints and mu lti-valued fluents, that enables the use of dynamic and static causal laws ( a.k.a. state constraints), executability conditio ns, an d non- Markovian for ms of reaso ning with arbitrary relative or abso lute re ferences to past and future points in time. The semantics and the abstract implem entation of B M V is incre- mentally developed in Section 6, where we first con sider a sub-language not inv o lving non-Ma rkovian referen ces, and la ter we extend it to the f ull B M V . A concrete implem en- tation in CLP(FD) is described in Sectio n 7, and an experimental evaluation is discussed in Sec tion 8. Section 9 pr esents an overview o f r elated efforts appeared in the literatu re, while Section 10 presents conclusions and the directions for future in vestigatio n. 2 The Action Language B “Action langu ages a r e fo rmal models of p arts of the n atural langu age that are used for talking a bout the effects o f actio ns” (Gelfond and Lifschitz 1998). A ction la nguages are used to defin e action description s that em bed knowledge to form alize plann ing problem s. In this section, we u se the same variant o f the lang uage B u sed in (Son et al. 20 01)—see also Sectio n 9 f or a comp arison. W ith a slight abuse o f n otation, we simply refe r to this languag e as B . 2.1 Syntax of B An ac tion signatu re consists of a set F of fluen t names, a set A of action names, and a set V of values fo r flu ents in F . In th is sectio n, we consider Boolean fluen ts, hence 4 A. Dovier , A. F ormisano, E. P on telli V = { 0 , 1 } . 1 A fluent li teral is either a fluent f or its negation neg ( f ) . Fluents and actions are con cretely repr esented by g r oun d ato mic formulae p ( t 1 , . . . , t m ) from an un derlying logic lang uage L . F o r simp licity , we ass ume that the s et of terms is finite—e.g., either th ere are no function symbo ls in L , o r the use of function s s ymbols is restricted, for instance by imposing a fixed max imal depth on the n esting of term s, to avoid the cre ation of ar bitrary complex terms. The lan guage B allows us to specify an (a ction) do main description D . Th e cor e com- ponen ts o f a do main descrip tion are its flue nts —proper ties used to describe th e state of the world, that may dynam ically ch ange in respon se to ex ecution of actions—and ac- tions —deno ting how an agen t can affect th e state of the world. Fluen ts an d ac tions are introdu ced b y assertions of the f orms fluent ( f ) and action ( a ) . An a ction descrip - tion D relates actions, states, and fluents using ax ioms of th e fo llowing types —where [list-of-cond itions] denotes a list of fluent literals: 2 • causes( a , ℓ , [list-of-c onditions]) : this axiom enco des a dynamic causal law , describing the effect (i.e., tr uth assignment to the fluent literal ℓ ) of the execution of action a in a state satisfying the given cond itions • caused([list- of-conditions] , ℓ ) : this axiom describes a static causal law— i.e., the fact that th e fluent literal ℓ is true in any state satisfy ing the given precondi- tions. Moreover , p reconditio ns can be imposed on th e e xecutability of actions by m eans of asser - tion of the forms: • executable( a , [list-of-conditions]) : this axiom asserts that, for th e ac- tion a to be executable, the gi ven conditions have to be satisfied in the curre nt state. A do main descriptio n is a set of static causal laws, d ynamic laws, an d executability condition s. A specific planning pr oblem hD , O i contains a domain description D alon g with a set O of observa tions describing t he initial state and the desir e d goal : • initially( ℓ ) asserts that the fluent literal ℓ is tr ue in the initial state • goal( ℓ ) asserts that the goal req uires the fluent literal ℓ to b e true in the final state. In the specification of an action theory , we can take adv antage of a Prolog-like syntax to express in a more succinct manner the laws of the theory . F o r instance, to assert t hat in the initial state all fluents are true, we can simply write the following rule: initially(F) :- fluent(F) . instead of writing a fact initially( f ) for each possible fluent f . Remember that the notation H : − B 1 , . . . , B k is a syntactic sugar for the logical formula ∀ X 1 · · · X n ( B 1 ∧ · · · ∧ B k → H ) where X 1 , . . . , X n are all the variables present in H , B 1 , . . . , B k . 1 For simplicity , we use 0 to denote false and 1 to denote true . Consequent ly , we often say that a fluent is true (resp., false) if its v alue is 1 (resp., 0 ). 2 W e will someti mes write true as a synonymous for the empty list of condit ions. Multi-valued Action Languages in CL P(FD) 5 %% Some Type Information barrel(5). barrel(7). barrel(12). liter(0). liter(1). . . . liter(12). %% Identificatio n of the fluents fluent(cont(B,L) ):- barrel(B), liter(L), L ≤ B. %% Identificatio n of the actions action(fill(X,Y) ):- barrel(X), barrel(Y), X 6 = Y. %% Dynamic causal laws causes(fill(X,Y) , cont(X,0), [cont(X,LX), cont(Y,LY)]) :- action(fill(X,Y) ), fluent(cont(X,LX)), fluent(cont(Y,LY )), Y-LY ≥ LX. causes(fill(X,Y) , cont(Y,LYnew), [cont(X,LX), cont(Y,LY)]) :- action(fill(X,Y) ), fluent(cont(X,LX)), fluent(cont(Y,LY )), Y-LY ≥ LX, LYnew is LX+LY. causes(fill(X,Y) , cont(X,LXnew), [cont(X,LX), cont(Y,LY)]) :- action(fill(X,Y) ), fluent(cont(X,LX)), fluent(cont(Y,LY )), LX ≥ Y-LY, LXnew is LX-Y+LY. causes(fill(X,Y) , cont(Y,Y), [cont(X,LX), cont(Y,LY)]) :- action(fill(X,Y) ), fluent(cont(X,LX)), fluent(cont(Y,LY )), LX ≥ Y-LY. %% Executability conditions executable(fill( X,Y), [cont(X,LX), cont(Y,LY)]) :- action(fill(X,Y) ), fluent(cont(X,LX)), fluent(cont(Y,LY )), LX > 0, LY < Y. %% Static causal laws caused([cont(X,LX )], neg(cont(X,LY))) :- fluent(cont(X,LX )), fluent(cont(X,LY)), barrel(X), liter(LX), liter(LY), LX 6 = LY. %% Description of the initial and goal state initially(cont(1 2,12)). initially(cont(7 ,0)). initially(cont(5 ,0)). goal(cont(12,6)) . goal(cont(7,6)). goal(cont(5,0)). Fig. 1. B description of the 12-7 -5 barrels problem. Example 1 Figure 1 p resents an enc oding of th e thr ee-barre l planning prob lem using the lan guage B . There are th ree barrels o f capacity N (an even n umber) , N / 2 + 1 , an d N / 2 − 1 , r espectiv ely . At the beginnin g, the largest barrel is full of wine while the other two are empty . W e wish to reach a state in which the two lar ger barrels contain the same am ount of wine. The only permissible action is to pour wine f rom one barrel to another, until the latter is full o r the former is empty . Figu re 1 shows the en coding of the pr oblem for N = 12 . No tice that we also require that the smallest barrel is empty at the end.  2.2 Semantics of B If f ∈ F is a fluent, and S is a set of fluent literals, we say that S | = f if and only if f ∈ S and S | = neg ( f ) if and only if neg ( f ) ∈ S . A list of litera ls L = [ ℓ 1 , . . . , ℓ m ] d enotes 6 A. Dovier , A. F ormisano, E. P on telli a conjun ction of literals, hence S | = L if an d only if S | = ℓ i for all i ∈ { 1 , . . . , m } . W e denote with ¬ S the set { f ∈ F : neg ( f ) ∈ S } ∪ { neg ( f ) : f ∈ S ∩ F } . A set of fluent literals is consistent if there is no fluent f s.t. S | = f and S | = neg ( f ) . If S ∪ ¬ S ⊇ F then S is complete . A set S of literals is closed w .r . t. a set of static laws S L = { caused ( C 1 , ℓ 1 ) , . . . , c aused ( C m , ℓ m ) } , if fo r all i ∈ { 1 , . . . , m } it holds that S | = C i implies S | = ℓ i . T he set Clo S L ( S ) is d efined as the sm allest set of litera ls containing S an d clo sed w .r .t. S L . C lo S L ( S ) is un iquely deter mined and no t n ecessarily consistent. The semantics of an action languag e on the action signatu re hV , F , Ai is given in terms of a transition system hS , ν , R i (Gelfond and Lifsch itz 1998), consisting o f a set S of states, a total interpretation function ν : F × S → V (in this section V = { 0 , 1 } ), and a transition relation R ⊆ S × A × S . Giv en a transition system h S , ν, R i and a state s ∈ S , let: Lit ( s ) = { f ∈ F : ν ( f , s ) = 1 } ∪ { neg ( f ) : f ∈ F , ν ( f , s ) = 0 } . Observe that Lit ( s ) is con sistent and complete. Giv en a set o f dy namic laws { causes ( a, ℓ 1 , C 1 ) , . . . , cause s ( a, ℓ m , C m ) } for the ac- tion a ∈ A and a state s ∈ S , we define the (direct) ef fec ts of a in s as follows: E ( a, s ) = { ℓ i : 1 6 i 6 m, L it ( s ) | = C i } . The action a is said to be executable in a state s if it holds that Lit ( s ) | = h _ i =1 C i , (1) where exec utable ( a, C 1 ) , . . . , e xecutable ( a, C h ) for h > 0 , are the executability ax- ioms for the action a in D . Observe that multiple executability axioms for the same action a ar e consider ed disjunctively . Hence, f or each action a , at least one executable axiom must be present in the action description. 3 Let D be an action description defined on the action signatu re hV , F , Ai , compo sed of dynamic laws DL , executability conditions E L , and static causal laws S L . The transition system hS , ν, R i described b y D is a transition system such that: • S is the set of all states s such that L it ( s ) is closed w .r .t. S L ; • R is the set of all triples h s, a, s ′ i such that a is executable in s and Lit ( s ′ ) = Clo S L ( E ( a, s ) ∪ ( Li t ( s ) ∩ Li t ( s ′ ))) (2) Let hD , O i be a plann ing prob lem in stance, where { ℓ | initiall y ( ℓ ) ∈ O } is a consis- tent and complete set of fluent literals. A trajectory in hS , ν, R i is a seq uence h s 0 , a 1 , s 1 , a 2 , · · · , a N , s N i such that h s i , a i +1 , s i +1 i ∈ R fo r all i ∈ { 0 , . . . , N − 1 } . 3 Observe that ev en if an action is “exec utable ”, its ex ecuti on may lead to an inconsiste nt state (which effe c- ti vely prev ents the use of s uch action in that conte xt). Even though “enabled” would be a better term to use for an action that can be execu ted in a s tate, we prefer to m ainta in the same terminology as used for B in (Son et al. 2001)—see also Remark 2. Multi-valued Action Languages in CL P(FD) 7 A sequenc e o f actions h a 1 , . . . , a N i is a solution ( a plan ) to the p lanning proble m hD , O i if there is a trajectory h s 0 , a 1 , s 1 , . . . , a N , s N i in hS , ν , R i such that: • Lit ( s 0 ) | = r for each ini tially ( r ) ∈ O , and • Lit ( s N ) | = ℓ for each go al ( ℓ ) ∈ O . The plans characteriz ed in th is d efinition are sequentia l —i.e., we disallow co ncurren t ac- tions. Observe also that the desired plan length N is assume d to be gi ven. Remark 1 In this pap er we f ocus on sequen tial plans on ly . Hence, we assume that o nly on e action is executed in each state transition composing a giv en trajectory . Note that the constraint-b ased enc oding we will pro pose in th e re st of this manu script can be easily adap ted to deal with concur rent actions. Nevertheless, we have opted to ig nore this aspect in this manu script, to av oid fu rther complicatio ns of notation, and dealing with issues of concurrency goes beyond the scope o f th is paper . Th e interested reade r is referred to (Dovier et al. 2009b) for s ome further consider ations on this matter . Remark 2 Notice that the satis faction of (1) is just a necessary requirement for the e xecu tability of an action and it might not r epresent a sufficient prec ondition . Indeed , as far as the definition of transition system is con sidered, it is easy to see that, even if (1) is satisfied fo r certain a and s , t he ex ecution of a in s mig ht be inhibited because of the contradic tory effects of the causal laws. A simple e x ample is represented by the following action descriptio n D : executable( a ,[]). causes( a , f ,[]). causes( a ,neg ( f ),[]). The action a is always ex ecutable (according to its e xecutability l aw), b ut the execution o f a would y ield an inco nsistent situation . Inde ed, the execution of a does n ot corresp ond to any state transition in the transition s ystem describ ed by D . The above example also suggests a possible extension of the action description lang uage that in volves la ws of the f orm nonexecutable ( a , D ) . The semantics for such a n extended actio n lan guage c an be d efined by replacing the con- dition (1), with the following one: Lit ( s ) | = h _ i =1 C i ∧ ¬ k _ j =1 D j , where executabl e( a , C 1 ) , . . . , executabl e( a , C h ) an d nonexec utable( a , D 1 ) , . . . , nonexec utable( a , D k ) , for h > 0 an d k > 0 , are defined for the ac tion a . Thu s, the action a is executable only if at least o ne of th e C i s is satisfied an d all D j s are u nsatisfied in the state s . An altern ati ve inter pretation o f the nonexecut able axioms ca n be adopted. Na mely , the law none xecutable( a , D ) can be consider ed simply as sho rthand for the p air o f 8 A. Dovier , A. F ormisano, E. P on telli FromState ✬ ✫ ✩ ✪ ✉ F u ℓ 1 ✉ F u ℓ p ToState ✬ ✫ ✩ ✪ ✉ F v ℓ 1 ✉ F v ℓ p ✲ A a 1 ✲ A a m P m i =1 A a i = 1 Fig. 2. Action constraints from state to state. (The states are described by p fluents, ℓ 1 , . . . , ℓ p , and one among m possible actions is executed.) dynamic causal laws causes ( a , f , D ) and c auses( a , neg( f ), D ) . (Ac tually , this possibility also applies to the languages proposed in (Gelfond and Lifschitz 1998)). This shows that (n on)executability laws do not increase the expr essi ve power of the action languag e. Nevertheless, the a vailability of both types of laws permits the direct and explicit formalization of preconditions for action s e xecution. 3 Modeling B and Planning Problems Using Constraints Let us describe how action descriptio ns are mappe d to finite do main c onstraints. W e will focus o n how constraints can be used to mo del the possible transitions fr om each individual state of the transition system. 3.1 Modeling an Action Theory as Constraints Let u s conside r a domain description D and the state transition system describ ed by D . Let us also d enote with u and v the starting an d en ding states of an arbitrary transition of such a system. W e assert constraints that relate the truth v alu e of fluents in u a nd v . Th is is intuitively illustrated in Fig ure 2, where u = From State a nd v = ToState . 4 A Boolean variable is in troduce d to d escribe the truth value of each fluent literal in a state. The value of a fluent literal ℓ in u is repr esented by the variable F u ℓ ; analo gously , its value in the d estination state v is represen ted b y the variable F v ℓ . For th e sake of sim- plicity , we will freely refer t o these v ar iables as Boolean entities—and co mpose them with logical con nectives to f orm Boolean expr essions—as well as 0 /1 variables—and compose them with arithmetic o perators. Co ncrete CLP(FD) systems, e.g ., SICStus, E CLiPSe, an d BProlog, 5 enable this type of alternative p erspectives, providing basic primiti ve c onstraints (e.g., #= and #> ) and Boolean comp ositions of con straints. Giv en a conju nction of liter als α = [ ℓ 1 , . . . , ℓ m ] we will denote with α u the expr ession F u ℓ 1 ∧ . . . ∧ F u ℓ m . W e will also introdu ce, f or each action a , a Boolean variable A u a , repre sent- ing whether the action is executed or not in the transition from u to v under consider ation. 4 For the sak e of readabili ty , the two va riable s named FromState and ToState are also used in the concrete implement ation of B (cf., Section 3.3 and Figure 6). 5 W eb sites for some CLP(FD) systems. SICStus: www.sics.s e/sicstus.html , ECLiPSe: http://87.230.22. 228/ , BProlog: http://www.prob p.com/ Multi-valued Action Languages in CL P(FD) 9 Dyn u ℓ ↔ m ℓ _ j =1 ( α u ℓ,j ∧ A u a i ℓ,j ) (3) Stat v ℓ ↔ h ℓ _ j =1 γ v ℓ,j (4) Fired u,v ℓ ↔ Dyn u ℓ ∨ Stat v ℓ (5) ¬ Fired u,v ℓ ∨ ¬ Fired u,v ¯ ℓ (6) F v ℓ ↔ Fired u,v ℓ ∨ ( ¬ Fired u,v ¯ ℓ ∧ F u ℓ ) (7) Fig. 3. The constraint C u,v ℓ for the fluent literal ℓ (cf ., Section 3.1). Giv en a specific fluen t literal ℓ , we develop constraints tha t d etermine when F v ℓ is tru e and false. Let us consider the dynamic causal laws that have ℓ as a consequence : causes ( a i ℓ, 1 , ℓ, α ℓ, 1 ) · · · causes ( a i ℓ,m ℓ , ℓ, α ℓ,m ℓ ) Let us also consider the static causal laws related to ℓ caused ( γ ℓ, 1 , ℓ ) · · · caused ( γ ℓ,h ℓ , ℓ ) Finally , for each action a we will hav e its ex ecutability conditions: executable ( a, δ a, 1 ) · · · executable ( a, δ a,p a ) Figure 3 describes the Boo lean con straints tha t c an be u sed in encodin g the relations th at determine the tru th value of th e fluen t literal ℓ . In the tab le, we denote with ¯ ℓ the comp le- ment o f literal ℓ , i.e. , if ℓ is the fluen t f , the n ¯ ℓ is neg ( f ) , while if ℓ is th e liter al n eg ( f ) then ¯ ℓ is the fluen t f . The intuitiv e meaning of the constraints is as follows: (3) This constrain t states that dy namic causal laws m aking ℓ true can fire if their con ditions are satisfied and the correspond ing actions are chosen for execution. (4) This con straint captur es the fact that at least o ne o f the static cau sal laws that ma ke f true is applicable. (5) This constraint e xpresses the fact th at a fluent literal ℓ ca n be made true during a transition fo rm state u to state v , eith er by a d ynamic ca usal law (d etermined by Dyn u ℓ ) or a static causal law (determined by Stat v ℓ ). (6) This constraint is u sed to gu arantee consistency of the action theo ry—in no situations a fluent and its complemen t are both made true. (7) This constrain t expresses the fact that a fluent literal ℓ is tru e in the d estination state if and o nly if it is m ade true (by a static or a dynamic causal law) or if is tr ue in the initial state and its truth value is not modified by the transition (i.e. , inertia). Observe the similarity between this constraint and the successor state axiom commonly encountered in situation calculus (Levesque et al. 1 998). W e will denote with C u,v ℓ the conjunctio n of such con straints. Giv en an action dom ain specification over the sign ature hV , F , Ai and two states u and v , we introd uce the system of con straints C u,v F which includes: • for each fluent literal ℓ in the lang uage of F , th e constraints C u,v ℓ . 10 A. Dovier , A. F ormisano, E. P on telli • the constraint X a ∈A A u a = 1 (8) • for each action a ∈ A , the constraints A u a → p a _ j =1 δ u a,j . (9) Notice tha t th e sequentiality of the plan if im posed thr ough th e constraint (8), while con- straint (9) reflects actions’ executability conditio ns. 3.2 Soundness and Completeness Results Let us proceed with the soundn ess and completen ess proof s of the constraint-b ased en- coding. Consider a state tran sition fro m th e state u to the state v and th e corresp onding constraint C u,v f described earlier . Let S = Lit ( u ) and S ′ = Li t ( v ) be the sets of flu ent literals that hold in u and v , respec- ti vely . Note that, from an y specific S (resp., S ′ ), we can obtain a consistent assignmen t σ S (resp., σ S ′ ) of truth values for all th e variables F u f (resp., F v f ) of u (resp., v ). Conv ersely , each truth assign ment σ S (resp., σ S ′ ) for all v ar iables F u f (resp., F v f ) corre sponds to a consistent and complete set of fluents S (resp ., S ′ ). Regarding the occurrence of actions, recall that in ea ch state transition a sing le action a occurs and its occurrence i s encoded by a specific B oolean v ar iable, A u a . Let σ a denote the assignment of truth values for such v a riables such that σ a ( A u a ) = 1 if and only if a occurs in the state tr ansition fro m u to v . 6 Note th at the d omains of σ S , σ S ′ , an d σ a are d isjoint, so we can safely denote with σ S ◦ σ S ′ ◦ σ a the composition of the three assignmen ts. W ith a slight abuse of n otation, in what follows we will denote with E the direct ef fects E ( a, u ) of an action a in u . Observe that E ⊆ S ′ . Theorem 1 states the completeness of the system of constrain s intro duced in Section 3.1. It asserts that for any g iv en D = hD L , E L , S Li , if a trip le h u, a, v i belongs to the transition system d escribed b y D , then th e assignment σ = σ S ◦ σ S ′ ◦ σ a satisfies the constraint C u,v F . Theor em 1 ( Completeness ) Let D = hD L , E L , S Li . If h u, a , v i belon gs to the tr ansition system d escribed by D , th en σ S ◦ σ S ′ ◦ σ a is a solution of the constraint C u,v F . Pr oof In con straints ( 3)–(7) of Figure 3 and (8)– (9) defined at the e nd of Subsection 3 .1, a n umber of au xiliary constrain t variables are d efined, wh ose values are uniqu ely determine d once the values of the flu ents are assessed. In othe r words, when S , S ′ , and a are fixed, the substitution σ S ◦ σ S ′ ◦ σ a uniquely determ ines the value of the right-han d sides of the constraints ( 3 ) – ( 5 ) . T o prove the theorem, we need to verify that if S ′ = Clo S L ( E ∪ ( S ∩ S ′ )) , then the co nstraints ( 6 ) and ( 7 ) alon g with the co nstraints abo ut the action variables A u a (i.e., constraints of the form (8) and (9)) are satisfied for e very fluent f . 6 W e will use mapping appli cation s either as σ ( X ) or in postfix notation as X σ . Multi-valued Action Languages in CL P(FD) 11 Let us observe that (8) is equi valent to say that if A a is true ( A a = 1 ) then A b is false for all b 6 = a . Moreover, it also states that if all A b for b 6 = a are false then A a is true. Namely , (8) is equiv alen t to the conju nction, for a ∈ A o f: A a ↔ ^ b ∈A\{ b } ¬ A b Let us start b y lookin g at the actio n occur rence. Let a be the actio n executed in state u , thus σ a = { A u a / 1 } ∪ { A u b / 0 | b 6 = a } . Henc e, (8) is satisfied by σ a . Similarly , since th e semantics re quire that actions a re executed only if the executability condition s are satisfied, it hold s that S | = δ a,h (for at least on e h ∈ { 1 , . . . , p a } , corre- sponding to a con dition executa ble ( a, δ a,h ) in S L ). Th is qu ickly leads to W p a j =1 δ u a,j is true, and this allows us to conclu de t hat (9) is satisfied by σ S ◦ σ a . Let u s now consider the constraints dealing with fluents. W e recall tha t S ′ is a set of fluent literals th at is consistent, co mplete, and closed w .r .t. S L . Let us consider a flu ent f and let us prove that con straint ( 6 ) of Figu re 3 is satisfied. Assume , by contradictio n, that Fired u,v f σ an d Fired u,v neg ( f ) σ are bo th true. Four cases must be con sidered: 1. Dyn u f σ an d Dyn u neg ( f ) σ are true. Sin ce these values ar e determined by u, a, v , this means that both f and neg ( f ) belo ng to E ( a, u ) . Since th e clo sure unde r S L is mon otonic this means that Lit ( v ) = S ′ is inconsistent, representing a contradictio n. 2. Dyn u f σ an d Stat v neg ( f ) σ ar e tru e. This means that f is in E ( a, u ) and neg ( f ) is added to S ′ by the closure o peration. Th is implies that S ′ is in consistent, whic h repre sents a contradictio n. 3. Stat v f σ an d Dyn u neg ( f ) σ are tru e. This leads a contradiction as in the pre vious case. 4. Stat v f σ and S tat v neg ( f ) σ are true. This means th at f and neg ( f ) are add ed to S ′ by th e closure operation. Thus, S ′ is incon sistent, which is a con tradiction. It rem ains to prove that constraint ( 7 ) is satisfied by σ . Let us assume that f ∈ S ′ . Thus, F v f σ S ′ is true. Three cases must be considered. 1. f ∈ E ( a, u ) . This m eans that there is a dynamic causal law causes ( a, f , α f ,i ) wher e S | = α f ,i . Fro m the de finition, this leads to α u f ,i σ being true and σ a ( A u a ) = 1 . Thus, constraints ( 3 ) and ( 5 ) set Dyn u f σ and Fire d u,v f σ both tr ue. As a con sequence, constraint ( 7 ) is satisfied. 2. f / ∈ E ( a, u ) an d f ∈ S . Th is mean s that f ∈ S ∩ S ′ . In th is c ase F ired u,v neg ( f ) σ must b e false, otherwise S ′ would be inconsistent (by closure) . Thus, F u f σ S should be true, F v f σ S ′ is true and Fired u,v neg ( f ) σ is false, which satisfy constrain t ( 7 ) (r egardless of th e value of Fired u,v f σ ). 3. f / ∈ E ( a, u ) and f / ∈ S . This means that f is inserted in S ′ by clo sure. Thus, there is a static causal law of the form caused ( γ f ,j , f ) such th at S ′ | = γ f ,j . In this case, by ( 4 ) , Stat v f σ is tru e and, by ( 5 ) , so is Fired u,v f σ . Thus, con straint ( 7 ) is satisfied. If f / ∈ S ′ , th en neg ( f ) ∈ S ′ and th e proo f is similar with p ositiv e and negativ e roles interchang ed. Let us obser ve that th e co n verse of the above th eorem does not necessarily h old. The problem arises from the fact that the implicit minimality in the closure operation is n ot 12 A. Dovier , A. F ormisano, E. P on telli reflected in the compu tation of solutions to the co nstraint. Con sider the dom ain descrip tion where F = { f , g , h } an d A = { a } , with the following laws: executable( a ,[]). caused([ g ], h ). causes( a , f ,[]). caused([ h ], g ). Let u s co nsider S = { neg( f ) , neg( g ) , neg( h ) } . Then, S ′ = { f , g , h } determines a solution of the constraint C u,v F with the e xecution of action a , but Clo S L ( E ∪ ( S ∩ S ′ )) = { f } ⊂ S ′ . Howe ver , the fo llowing h olds: Theor em 2 ( W eak Sou ndness ) Let D = hD L , E L , S Li . Le t σ S ◦ σ S ′ ◦ σ a identify a solution of the constraint C u,v F . Then Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) ⊆ S ′ . Pr oof It is immed iate to see that σ S and σ S ′ uniquely d etermines two consistent and co mplete sets of fluent l iterals u and v . Let f be a positi ve fluent in Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . W e show no w that f ∈ S ′ . 1. If f is in S ∩ S ′ we are done. 2. If f ∈ E ( a, u ) , the re is a law causes ( a, f , α f ,i ) such that S | = α f ,i . Since S is determ ined by σ S , by ( 3 ) , we have that σ S ◦ σ a is a solution of α u f ,i ∧ A u a , which implies that Dyn u f is true, and σ S ′ ( F v f ) is true in σ S ′ . Th erefore, f ∈ S ′ . Obser ve also that σ a making true A u a will im ply tha t δ u a,h is tru e (for some h ∈ { 1 , . . . , p a } ), which will imply satisfiability of the executability precon ditions for a . 3. W e are left with the case of f / ∈ E ( a, u ) and f / ∈ S ∩ S ′ . Since S ′ is d etermined by σ S ′ , and f ∈ Cl o S L ( E ( a, u ) ∪ ( S ∩ S ′ )) , there is a law cause d ( γ f ,j , f ) such that S ′ | = γ f ,j , and by co nstruction σ S ′ makes γ v f ,j true. Thus, Stat v f is tr ue and therefore F v f is true. Hence, f ∈ S ′ . The pro of pro ceeds similar ly in the case of a negative fluent neg ( f ) in Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . Let us consider the set o f static cau sal laws S L . W e can intr oduce a no tion o f positive depend ence graph , following the traditional p rinciple of dependence analysis used in logic progr amming (e.g., (Lin and Zhao 2004)). The graph G ( S L ) is defin ed as follows : • the set of the nodes in G ( S L ) co rrespond s to the set of fluent literals, i.e., Nodes ( G ( S L )) = { f | f ∈ F } ∪ { neg ( f ) | f ∈ F } • edges are created to den ote the dependen ce of a flu ent literal on o ther literals due to a static causal law , i.e., Edges ( G ( S L )) = { ( ℓ 1 , ℓ 2 ) | caus ed ( L, ℓ 1 ) ∈ S L , L = [... , ℓ 2 , ...] } A set of fluent literals L is a loop if, f or an y ℓ 1 , ℓ 2 ∈ L , we have that there is a path fro m ℓ 1 to ℓ 2 in G ( S L ) such that all n odes encountered in such path are i n L . W e say that a domain specification D = hD L , E L , S Li is acyclic if t he graph G ( S L ) does not contain any loop s. Multi-valued Action Languages in CL P(FD) 13 F ∪ ¬F S S ′ E • ℓ Fig. 4. Sets of fluents in volved in a state tran sition and a literal ℓ in troduced by closure. Theor em 3 ( Acyclic Soundness ) Let D = hD L , E L , S Li . Let σ S ◦ σ S ′ ◦ σ a be a solution of the constraint C u,v F . If the depend ency g raph of P is acyclic, then Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) = S ′ . Pr oof Theorem 2 proves that Cl o S L ( E ( a, u ) ∪ ( S ∩ S ′ )) ⊆ S ′ . It re mains to prove that for any (positive o r negati ve) fluen t ℓ , if ℓ ∈ S ′ , then ℓ ∈ C lo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . If ℓ ∈ E ( a, u ) o r ℓ ∈ S , th en tri v ially ℓ ∈ Cl o S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . Let us prove that (cf., Figure 4): ( ℓ ∈ S ′ ∧ ℓ / ∈ E ( a, u ) ∪ ( S ∩ S ′ )) → ℓ ∈ Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) T o th is aim, con sider th e depen dence gr aph G ( S L ) . Because o f the acyclicity of G ( S L ) , there ar e node s in G ( S L ) with out inc oming edges—we will refer to them as leav es . For any node ℓ of G ( S L ) , let d ( ℓ ) de note the length o f the long est path f rom a leaf o f G ( S L ) to ℓ . W e prove the property for a positi ve fluent literal ℓ = f , by inductio n on d ( ℓ ) . Base case. If f / ∈ E ( a, u ) ∪ ( S ∩ S ′ ) is a positive fluent which is a leaf (the proof is similar for the case of negati ve literals), then two cases could be possible. • There is no law of the for m caused ( , f ) in S L . In this case, it can not be that f ∈ S ′ due to constraint (4). • There is a law caused ([ ] , f ) . In this case f ∈ S ′ by closure. Inductive step. Let f / ∈ E ( a, u ) ∪ ( S ∩ S ′ ) be a positive fluen t such th at there ar e laws caused ( γ f , 1 , f ) , . . . , caused ( γ f ,h , f ) in S L . By the ind uctive hypo thesis, let us assume that the thesis h olds for each fluen t literal ℓ such that d ( ℓ ) < d ( f ) . Sinc e f / ∈ E ( a, u ) and f / ∈ S ∩ S ′ , we have that F u f is false, F v f is tru e, and Dyn u f is false un der σ S ◦ σ S ′ ◦ σ a . From the fact that constraint ( 7 ) is satisfied, it follows that Stat v f is true. Moreover , Dyn u f is false becau se f / ∈ E ( a, u ) . On the other ha nd, becau se of ( 6 ) , we have that Dyn u neg ( f ) , Stat v neg ( f ) , and Fired u,v neg ( f ) are all f alse. Consequen tly , co nstraint ( 7 ) can be rewritten as F v f ↔ W h j =1 γ v f ,j . Since f ∈ S ′ (i.e., F v f is tr ue), ther e mu st exists a j ∈ { 1 , . . . , h } such that γ v f ,j is verified by σ S ′ . This implies th at, for each fluent g required to be tru e (resp., false) in γ f ,j , F v g is set true (resp., false) by σ S ′ . By inductive hy pothesis, such fluent literals (either g or neg ( g ) ) belong to Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . S ince Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) is closed w .r .t. the static laws, it follo ws that f ∈ Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) . 14 A. Dovier , A. F ormisano, E. P on telli The proof in case of a negativ e fluent neg ( f ) is similar . In order to achieve soundness in cases where the graph G ( S L ) contains loops, it is n ec- essary to intro duce additional constrain ts in conjun ction with C u,v F . Intu iti vely , in th e se- mantics of B , cyclic d epende ncies created by the static causal laws are resolved b y the closure oper ation Clo S L ( · ) by min imizing the numb er of fluent literals that a re made true—this deri ves by the im plicit minimality of the clo sure. Add itional constra ints can be adde d to enf orce this behavior; th ese con straints can be derived by following a prin- ciple similar to that of loo p formulae com monly used in th e context of lo gic program - ming (Lin and Zhao 2004). The notion of lo op formu lae can be developed in our context as follows. Let L = { ℓ 1 , . . . , ℓ k } b e a loop in G ( S L ) a nd let us consider th e tran sition f rom u to v as stud- ied earlier . Let us define a counter-support for ℓ i w .r .t. the loop L as a set of constrain ts cs with the following pro perties: • for each causes ( a j , ℓ i , α ) in D L , cs con tains either A u a j = 0 or F u ¯ ℓ = 1 fo r some ℓ in α ; • for each cause d ( γ , ℓ i ) in S L such th at none of ℓ 1 , . . . , ℓ k is in γ , fo r some ℓ in γ cs co ntains F v ¯ ℓ = 1 ; • cs co ntains either F u ¯ ℓ i = 1 or F v ¯ ℓ i = 1 . (As usual, we mig ht identify a set cs of constraint with their conjunction, depend ing on the need.) Let us denote with Counters ( ℓ i , L ) u,v the set of all such counter-suppo rts. The loop formu lae for L w .r .t. u, v is the set of constrain ts F orm ( L ) u,v = { c 1 ∧ · · · ∧ c k → F v ℓ 1 = 0 ∧ · · · ∧ F v ℓ k = 0 | c i ∈ Counters ( ℓ i , L ) u,v } . T o take into account all different loops in G ( S L ) , let F orm ( D ) u,v be the constraint F orm ( D ) u,v = ^ L is a loop in G ( S L ) F orm ( L ) u,v . Follo wing the analo gous pr oofs relating answer sets a nd m odels o f a progr am comp le- tion that satisfies loop formulae (e.g., (Lin and Zhao 2004)) one can show: Theor em 4 ( Soundn ess ) Let D = hDL , E L , S L i and let σ S ◦ σ S ′ ◦ σ a be a solution of the constrain t C u,v F ∧ F orm ( D ) u,v . Thus, Clo S L ( E ( a, u ) ∪ ( S ∩ S ′ )) = S ′ . Let the action d escription D meet th e co nditions of Th eorem 4 and let hS , ν, R i be its underly ing transition system. The following can be proved. Theor em 5 There is a tra jectory h s 0 , a 1 , s 1 , a 2 , . . . , a N , s N i in the transition system hS , ν , R i if and only if s 0 is closed w .r .t. S L an d there is a solution for the constraint N − 1 ^ j =0  C s j ,s j +1 F ∧ F orm ( D ) s j ,s j +1  Multi-valued Action Languages in CL P(FD) 15 Pr oof The r esult f ollows d irectly b y ap plication of Th eorems 1 and 4 and by observin g th at f or each tran sition h s j , a j +1 , s j +1 i , the satisfaction o f constrain t C s j ,s j +1 F implies that the state s j +1 is closed w .r .t. S L . Let hD , O i be an in stance of a plann ing pro blem w here D is an action description and O con tains any num ber of axioms of the form i nitially ( C ) a nd goal ( C ) . W e can state the following. Cor ollary 1 There is a trajectory h s 0 , a 1 , s 1 , a 2 , . . . , a N , s N i for th e p lanning problem hD , Oi if and only if s 0 is closed w .r .t. the static causal la ws of D an d th ere is a solution for the constrain t ^ initially ( C ) ∈O C s 0 ∧ N − 1 ^ j =0  C s j ,s j +1 F ∧ F orm ( D ) s j ,s j +1  ∧ ^ goal ( C ) ∈ O C s N 3.3 Mapping the Model to CLP(FD) The modeling d escribed in Section 3 .1 has been translated into a con crete im plementa- tion using SICStus Pro log. In this translation , constrain ed CLP variables directly r eflect the Boolean variables mo deling fluents and action’ s occurren ces. Conseq uently , causal laws and executability conditio ns are dir ectly translated into CLP constraints (and in- herit the correspond ing completeness and soundness results). In this section we high- light the main aspects of the implemen tation—while the comp lete code can be foun d at www.dimi.uniud.it /dovier/CLPASP . A plan with exactly N + 1 states, p fluents, and m actions is repre sented by: • A list, called States , containing N + 1 lists, each composed of p terms of the for m fluent(fluent name, Bool var) . The variable of the i th term in the j th list is assigned 1 if and only if the i th fluent is tru e in the j th state of the trajectory . For example, if we ha ve N = 2 a nd the fluents f , g , and h , we hav e: States = [[fluent(f ,X_f_0),fluent (g,X_g_0),fluent(h,X_h_0)], [fluent(f,X_f _1),fluent(g,X _g_1),fluent( h,X_h_1)], [fluent(f,X_f _2),fluent(g,X _g_2),fluent( h,X_h_2)]] • A list ActionsOcc , contain ing N lists, each composed o f m terms of the form action(action name,Bool var) . The variable of th e i th term of the j th list is assigned 1 if and only if the i th action o ccurs du ring the tr ansition f rom state j to state j + 1 . For e xample, if we hav e N = 2 an d the actions are a and b , then: ActionsOcc = [[action(a,X _a_1),action( b,X_b_1)], [action(a,X_a _2),action(b,X _b_2)]] The planner makes use of these structur es in the constru ction of the plan; appro priate con- straints are set betwe en the various Boo lean variables to capture their relationships. For each list in ActionsOcc , exactly one act ion(a i ,VA i ) co ntains a variable that is assign ed the value 1 ( cf., constraint (8)). 16 A. Dovier , A. F ormisano, E. P on telli (1) clpplan(N, ActionsOcc, States) :- (2) setof(F, fluent(F), Lf), (3) setof(A, action(A), La), (4) make states(N, Lf, States), (5) make action occurrenc es(N, La, ActionsOcc), (6) setof(F, initially(F), Init), (7) setof(F, goal(F), Goal), (8) set initial(Init, States), (9) set goal(Goal, States), (10) set transitions(Acti onsOcc, States), (11) set executability(Ac tionsOcc, States), (12) get all acti ons(ActionsOcc, AllActions), (13) labeling(AllActi ons). Fig. 5. Main predicate of the CLP(FD) planner . The CLP implemen tation of the B langu age assumes that the action description is en- coded as Prolo g facts —observe that the syntax of B is comp liant with Prolog’ s syntax, al- lowing us to directly stor e the domain descriptio n as rules and facts in the Prolog database. The entry point of the planner is shown in Figure 5. The main p redicate is clpplan(N, ActionsOcc, States) (lin e (1) ) that co mputes a plan o f length N for the actio n description presen t in the Prolog datab ase. If such a plan exists, the variables in ActionsOcc and States will be instantiated so as to d escribe the found trajectory . Lines ( 2) and (3) collect the lists o f all fluents ( Lf ) and all action s ( La ). L ines (4) and (5 ) are used f or th e creatio n of the lists States and ActionsOcc . In particular, all the vari- ables for fluents and actio ns are declared as Boolean variables. Furtherm ore, a c onstraint is added to enforce that in e very state transition , e xactly one action can be fired. Lines (6) and (7 ) collect the description of th e initial state ( Init ) and th e require d con- tent of the final state ( Goal ). These inform ation ar e then added to the Boolean variables related to the first and last state, respectiv ely , by the pred icates in lines (8) and (9). Lines ( 10) and (11) im pose th e con straints on state tr ansitions an d actio n executability , as described in Section 3.1. W e will give more details on this part below . Line (12) gathe rs all v aria bles denoting action occurr ences, in preparation for the label- ing phase (lin e (13)). No te that the labelin g is focused on the selection o f the action to be executed at each time step. Some details on th e labelin g strategy ar e discussed in Sec- tion 8. Please ob serve that in the code of Figur e 5 we omit the parts con cerning deli vering the results to the user . The main constrain ts are added b y th e predicate set transitions . The proc ess is based on a recu rsion acr oss fluents and consecutive states. The pr edicate set one fluent is called (see Figure 6) at the core of the recursion . Its param eters are the fluen t F , th e starting state FromState , the next state ToState , the list Occ of action variables, and finally the variables IV and EV , re lated to the v alu e of the fluent F in F romState an d ToState , respectively ( see also Figure 2). For a g i ven flu ent F , the pre dicate set one fluent collects th e list DynPos (re spec- ti vely DynNeg ) of all the p airs [Action,Pre conditions] su ch that the dyn amic action Action m akes F tru e (resp ectiv ely false) in the state transition ( lines (15) an d (1 6)). Th e variables inv olved are then constrained by the procedure dynamic (lines (17) and (18) ). Similarly , the static causal laws a re hand led b y collecting the lists of conditions that affect the truth value of a fluent F ( i.e., the v ariab les StatPo s and StatNeg , in lines Multi-valued Action Languages in CL P(FD) 17 (14) set one flue nt(F, IV, EV, Occ, FromState, ToState) :- (15) findall([X,L], causes(X,F,L), DynPos), (16) findall([Y,M], causes(Y,neg(F),M ), DynNeg), (17) dynamic(DynPos, Occ, FromState, DynP, EV), (18) dynamic(DynNeg, Occ, FromState, DynN, EV), (19) findall(P, caused(P,F), StatPos), (20) findall(N, caused(N,neg(F)), StatNeg), (21) static(StatPos, ToState, StatP, EV), (22) static(StatNeg, ToState, StatN, EV), (23) bool disj(DynP, StatP, PosFired), (24) bool disj(DynN, StatN, NegFired), (25) PosFired * NegFired #= 0, (26) EV #<=> PosFired #\/ (#\ NegFired #/\ IV). (27) dynamic([], , , [], ). (28) dynamic([[Action ,Precondition]|R], Occ, FromState, [Flag|Flags], EV) :- (29) member(action(Ac tion,VA), Occ), (30) get precondition var s(Precondition, FromState, ListPV), (31) length(ListPV, NPrec), (32) sum(ListPV, SumPrec), (33) (VA #/\ (SumPrec #= NPrec)) #<=> Flag, (34) dynamic(R, Occ, FromState, Flags, EV). (35) static([], , [], ). (36) static([Cond|Oth ers], ToState, [Flag|Flags], EV) :- (37) get precondition var s(Cond, ToState, ListPV), (38) length(ListPV, NPrec), (39) sum(ListPV, SumPV), (40) (SumPV #= NPrec) #<=> Flag, (41) static(Others, ToState, Flags, EV). Fig. 6. T r ansition from state to state. (19)– (20)) and constraining them through the pro cedure static (line s (21 ) an d (22 )). Th e disjunctions of all the positiv e and n egati ve conditions are co llected in lines (2 3) and (24 ) and stored in PosFired and NegFired , respectively . Finally , lin es ( 25) and (26) take care of the relationship s between all these variables. Line (25 ) implements the con straint (6) for the state ToState o f Figu re 3, stating that we do no t want in consistent action theor ies. If P osFired and NegFi red are both false, th en EV = IV (iner tia). Precisely , a flu ent is tru e in the next state ( EV ) if and on ly if there is an action or a static cau sal law making it true ( PosFired ) or it was true in the previous state ( IV ) and no causal law makes it false. Let u s conside r the predicate dynamic (see line (27) in Figure 6). It recursively pro- cesses a list o f pairs [Action, Preconditions] . T he variable VA associated to the execu- tion of action Ac tion is retrieved in li ne (29). The v ar iables associated to its preconditions are r etriev ed from state FromState and co llected in ListPV in line (30). A precond ition holds if and only if all the variables in the list ListPV are assigned value 1, i.e., when their sum is eq ual to the len gth, NPrec , of the list ListPV . If (and only if) the action variable VA is true and the preco nditions holds, then there is an actio n ef f ect (line (33)). Similarly , the predicate s tatic ( line ( 35) in Figure 6) r ecursively processes a list of precon ditions. Th e variables inv o lved in each of such precondition C ond ar e r etriev ed fro m the state ToState and collected in ListPV (line (37)). A precondition h olds if and only if all the variables in the lis t ListPV have value 1, i.e., when their sum is equal to the length, NPrec , of Lis tPV . This happens if and only if there is a static action ef fect (see line (40)). Executability condition s are handled as follows. For each state tran sition and for each action Act , the predicate set executability sub is called ( see Figure 7). The variable VA , enco ding the application of an action Act is collected in line (44). A preco ndition hold 18 A. Dovier , A. F ormisano, E. P on telli (42) set executability su b([], , ). (43) set executability su b([[Act,C]|CA], ActionsOcc, State) :- (44) member(action(Ac t,VA), ActionsOcc), (45) preconditions flags(C, State, Flags), (46) bool disj(Flags, F), (47) VA #==> F, (48) set executability su b(CA, ActionsOcc, State). (49) preconditions flags([], , []). (50) preconditions flags([C|R], State, [Flag|Flags]) :- (51) get precondition var s(C, State, Cs), (52) length(Cs, NCs), (53) sum(Cs, SumCs), (54) (NCs #= SumCs) #<=> Flag, (55) preconditions flags(R, State, Flags). Fig. 7. Executability conditions. if and only if the sum of the (Boo lean) values of its fluent literals equ als th eir num ber (lines ( 52)-(5 4)). The variable Flags store s th e list o f these conditio ns and th e variable F their disjunc tion. If the action is executed ( VA = 1 , see line (47 )), then at least one of th e executability conditio ns must ho ld. 4 The Action Language with Constraints on Multi-valued Fluents As a m atter of fact, constrain ts repr esent a very d eclarative notation to exp ress relatio nships between unkn owns. As such , the ability to u se them direc tly in an action lang uage greatly enhances the declarative an d expressive power o f th e languag e, facilitating the e ncoding of complex actio n domains, such as those in volving m ulti-valued flu ents. Furthermore, the encodin g of an action theo ry usin g m ulti-valued fluents leads to more concise and more efficient represen tations an d better exposing n on-deter minism (that could be e x ploited, for example, by a parallel planner). Let us consider s ome representative examples. Example 2 ( Maintenan ce Goals ) It is no t uncom mon to en counter plan ning problem s where alo ng with the type of goa ls described earlier (known as achievement goals), there are also maintena nce goals, re p- resenting pro perties that m ust persist th rough out the trajec tory . Con straints ar e a n atural way of encodin g mainten ance prop erties, and can be introdu ced alo ng with simple tem - poral o perators. E.g. , if the fluent f uel rep resents th e amo unt of fuel available, th en the maintenan ce goal which guar antees that we will no t be left strand ed could b e encode d as: always( f uel > 0 ) .  Example 3 ( Contr ol Knowledge ) Domain-spe cific control knowledge ca n be f ormalized as constraints tha t we expect to be satisfied b y all th e trajectories. For example, we may know that if a certain action o ccurs at a gi ven time step (e.g., in g est poison ) then at the ne xt time s tep we will alw ays perform the same action (e.g., call doctor ). This could be encode d as caused([occ( ing est poison )], occ( cal l doctor ) 1 ) where occ ( a ) is a fluent describing th e occur rence of the actio n a and f 1 indicates that th e fluent f should hold at the next time step.  Multi-valued Action Languages in CL P(FD) 19 Example 4 ( Delayed Effect ) Let u s assume tha t the action r eq uest r eimbur sement has a dela yed effect (e.g., the in- crease by $ 50 of bank account after 3 0 time un its). This co uld be expressed as a d ynamic causal law: causes( r eq ue st r eimbur sement , incr( bank account , 50 ) 30 ,[]) where incr is a constraint in troduced to d eal with additive computa tions—in a way closer to B ’ s syntax we should write: causes( r eq ue st r eimbur sement , bank account 30 = bank a ccount + 50 ,[]) . This is a particular case of additiv e fluents (Lee and Lifschitz 2003).  In what follows we intro duce the action description language B M V in which mu lti- valued fluents are ad mitted and constraints are first-class compon ents in the descrip tion of planning p roblems. Th e availability of multi-valued con straints enab les a n umber of im- mediate language e x tensions and imp roves th e e xpressive p ower of the overall fra mew ork. Action descr iption langu ages such a s B r ely on the commo n assumption, trad ition- ally refer red to as Ma rkovian pr o perty in the context of systems and con trol theory: the executability of an actio n and its effects depend exclusively on the curren t state of the world ( Gabaldon 2002; M cCarthy 1998). Nev ertheless, it is n ot u ncommo n to enco unter real world situations where su ch p roperty is no t satisfied, i.e., situations where the exe- cutability an d/or the ef fe cts of an action depend not only on what holds in the cu rrent situation, but also on wh ether some con ditions wer e satisfied at a pr evious po int in time. For example, an agent controlling access to a datab ase s hould forbid access if in t he recent past three failed password submission attemp ts ha ve been per formed by the user . Although non -Markovian pr econdition s and effects can be expr essed in a Mar kovian theory through the introduction of additional fluents (and a c orrect handling of inertia), the resulting the ory can b ecome significan tly larger and less intu iti ve. An alternative solution consists of ad mitting past referenc es in mo deling such kind of situations. I n this frame of mind, B M V allows timed refere nces to past poin ts in time within co nstraints, i.e., non- Markovian expressions that m ight in volve fluents’ values. Effects of d ynamic laws that in volves future references might also be specified. As a fur ther feature the B M V languag e admits the specification of g lobal co nstraints (inv o lving absolutely specified po ints in time) and costs for actions and plans. The resulting description language supports all the kind of modeling and reasoning out- lined in the above E xamples 2 – 4. In the next sections, we first introdu ce the syn tax o f the full-b lown ac tion description languag e B M V (Section 5). In Section 6 we will d ev elop the semantics and the constra int- based abstrac t implementatio n of this new lan guage. In do ing this, f or the sake of read- ability , we pro ceed in crementally in order to focu s on the main p oints an d fea tures o f the framework. W e first consid er the sub-lan guage B M V 0 obtained f rom B M V by d isallowing timed refer ences (Sec tion 6 .1); in Section 6 .2, we treat the ge neral case d ealing with past and fu ture referenc es. The abstract imp lementation is p rovided in Section 6.3. Fina lly , we giv e the seman tics to the co mplete lang uage in volving co st and global con straints (Sec- tion 6.4). 20 A. Dovier , A. F ormisano, E. P on telli 5 The Language B M V As for B , the action signature consists of a set F of fluent names, a set A of actio n names, and a set V of values for fluents in F . In the fo llowing we assume that V ⊆ Z . In an action domain description, an assertion ( domain declaration ) of the type fluent ( f , { d 1 , . . . , d k } ) declares that f is a fluent and that its set of v alues is { d 1 , . . . , d k } ; we ref er to the set { d 1 , . . . , d k } as the domain of f . W e also admit the simplified notation fluent ( f , d 1 , d 2 ) to specify all the integer v a lues in the interval [ d 1 , d 2 ] as adm issible (with d 1 ≤ d 2 ). An an notated fl uent ( AF ) is an expression f t , wh ere f is a flu ent and t ∈ Z . W e will often den ote f 0 simply b y f . Intu iti vely speaking , if t < 0 then f t denotes the value that the fluent f had t steps ago in the past; similarly , if t > 0 , then f t denotes the value f will have t steps in the futur e. W e refer to an notated fluents with t > 0 as p ositiv ely anno tated fluents. Annotated fluents can be used in Fluent Expressions ( FE ), which are define d in ductively as follows: FE ::= d | AF | FE 1 ⊕ FE 2 | − ( FE ) | abs ( FE ) | re i ( FC ) where d ∈ V and ⊕ ∈ { + , − , ∗ , /, mod } . FC is a fluent c onstraint ( see be low). W e ref er to the fluent e xpressions rei(FC) as the r eification of the fluent constraint FC —its formal semantics is giv en in Section 6.1. Fluent expr essions can be used to build p rimitive fluen t con straints ( PC ), i.e., formu lae of the f orm FE 1 op FE 2 , where FE 1 and FE 2 are fluent exp ressions, and op is a relation al operator, i.e., op ∈ { = , 6 = , ≥ , ≤ , >, < } . Flue nt co nstraints are propo sitional com binations of primitive fluen t constraints: PC ::= FE 1 op FE 2 C ::= PC | ¬ C | C 1 ∧ C 2 | C 1 ∨ C 2 The co nstant symbo ls t rue and false can be used as a shor thand fo r tru e con straints (e.g., d = d , for some d ∈ V ) and unsatisfiable constraints (e.g., d 6 = d ). The lang uage B M V allows one to specify an a ction domain d escription, which relates actions, states, a nd fluents u sing axio ms o f the following for ms ( P C denotes a primitive fluent constraint, while C is a fluent constraint). • Axioms of the form execut able ( a, C ) , stating that th e fluent con straint C has to be satisfied by the current state for the action a to be executable. • Axioms of the fo rm causes ( a, P C, C ) encode dyn amic causal laws. When the ac- tion a is ex ecuted, if the c onstraint C is satisfied by the current state, then state produ ced by the execution of the action is required to satisfy the prim iti ve fluent constraint P C . • Axioms of the fo rm cau sed ( C 1 , C 2 ) describe static cau sal laws. If th e fluent con- straint C 1 is satisfied in a state, then the constraint C 2 must also hold in such state. An a ction do main descriptio n of B M V is a tuple hD L , E L , S Li , where E L is a set of executability con ditions, S L is a set of static causal laws, a nd D L is a set of d ynamic Multi-valued Action Languages in CL P(FD) 21 causal laws. In the following, we assume that po siti vely anno tated flu ents can o ccur o nly in the effect part of dyn amic causal laws. A specific instance of a p lanning proble m is a pair hD , O i , where D is an action do- main d escription and O con tains any num ber of axio ms of the form initially ( C ) and goal ( C ) , where C is a fluent constrain t. Example 5 A sample action theory in B M V is: fluent( f , { 1 , 2 , 3 , 4 , 5 } ). fluent( g , { 1 , 2 , 3 , 4 , 5 } ). fluent( h , { 1 , 2 , 3 , 4 , 5 } ). causes( a , f = g + 2 , g < 3 ). executable( a , true). initially( f = 1 ). initially( g = 1 ). initially( h = 1 ). goal( f = 5 ).  Notice that, fo r any given d ynamic law causes ( a, P C , C ) , such that a is executed in a state u satisfying C , the con straint P C has to b e evaluates/satisfi ed in the target state v . Hence, the (re lati ve) timed r eferences occur ring in P C (respectiv ely , in C ) are resolved with respect to v (resp., u ). On the oth er hand, fo r a static law ca used ( C 1 , C 2 ) , re lati ve timed references of both C 1 and C 2 have to be resolved with respect to the curren t state. 5.1 Absolute T emporal References The language B M V allows the definition of absolute temporal c onstraints , i.e., constraints that ref er to specific momen ts in time in the trajec tory (by associating the time point 0 to the initial state). d ifferently fro m th e case of an notated fluents, wher e p oints in time are r elative to the curre nt state. A timed fluent is defined as an expression of the form FLUENT @ TIME . T im ed fluents can be used to b uild timed flu ent e xp r essions ( T E ) and timed primitive co n- straints ( T C ), similarly to what done for normal fluents. F o r instance, the constraint f @ 2 < g @ 4 states that the value the flue nt f has a t time 2 in the plan is less than the v alue that the fluent g h as at time 4. Similarly , h @ 2 = 3 impo ses that the fluent h must assume value 3 at time 2 . T im ed constraints can be used in the followi ng kind of assertion: time constraint ( T C ) The assertion requires the timed constraint T C to hold. Some other accepted constraints are: 22 A. Dovier , A. F ormisano, E. P on telli • holds ( F C, n ) : this con straint is a p articular case of the pr evious one. It is satisfied if the pr imitiv e fluen t constraint F C holds in the n th state. It is th erefore a gen- eralization of the initially axiom . Observe that assertions o f th is kind can be used to g uide the sear ch of a plan by add ing some poin t-wise information abou t the states oc curring alon g th e comp uted trajecto ry (e.g ., th is is useful to imp lement the landmark s model as used in the FF plan ner (Hof fmann et al. 2004)). • always ( F C ) : this co nstraint impo ses the condition that the fluent constraint F C holds in all the states. Observe that F C h as to b e evaluated in all states, an d its ev aluatio n is strict—i.e., any r eference to flu ents outside th e time limits lead s to the satisfaction of the constraint; hence, annotated fluents should be a voided in F C . In specifying a planning prob lem hD , O i , we can con sider such kinds of assertions as part of the observations O . Example 6 Let us consider the case of an agent that has a c ertain amoun t of money (e. g., $5 , 000 ) to invest; sh e is interested in purch asing as many sto cks as p ossible. Th e stock s c an b e purcha sed from th ree tradin g agencies ( 1 , 2 , and 3 ); each agency has 1 , 000 stocks av ailable at $2 eac h. T he stocks h av e to be purcha sed in separate transactions, but each trading agency require the a gent to have a bala nce of at least $ 2 , 000 at the start of the d ay befo re agreeing in the transaction. A purchase can be of at most 3 , 000 share s at a time. W e can model this prob lem with the following fluents: fluent ( money , 0 , 5000) . fluent ( hav e ( stock 1) , 0 , 1000) . fluent ( hav e ( stock 2) , 0 , 1000) . fluent ( hav e ( stock 3) , 0 , 1000) . fluent ( av ail able ( s tock 1) , 0 , 1000) . fluent ( av ail able ( s tock 2) , 0 , 1000) . fluent ( av ail able ( s tock 3) , 0 , 1000) . fluent ( pr ice ( stock 1) , 2 , 2) . fluent ( pr ice ( stock 2) , 2 , 2) . fluent ( pr ice ( stock 3) , 2 , 2)) . The only action is action ( buy ( S tock T y pe, N )) : − N > 0 , N < 3000 . The executability con dition for the actio n captu res o ne pr operty: th e agen t is accepted by the trading agency . executable ( buy ( T y pe, N ) , money @0 > 2000 ∧ money > N ∗ p r ice ( T y pe )) . The dynamic causal law for this action is: causes ( buy ( T y pe, N ) , money = money − N ∗ p r ice ( T y pe ) , true ) . causes ( buy ( T y pe, N ) , hav e ( T y pe ) = hav e ( T y pe ) + N , true ) . The initial state can be described as initially ( pr ice ( stock 1) = 2) . ini tially ( pr ice ( stock 2) = 2) . initially ( pr ice ( stock 3) = 2) . ini tially ( hav e ( stock 1) = 0) . initially ( hav e ( stock 2) = 0) . initially ( hav e ( st ock 3) = 0) . initially ( money = 5000) . initially ( av ail a ble ( s tock 1) = 1000) . initially ( av ailab le ( st ock 2) = 1000) . init ially ( av aila ble ( st ock 3) = 1000) .  Multi-valued Action Languages in CL P(FD) 23 5.2 Cost Constraints In B M V it is possible to specif y inform ation ab out the cost of each actio n and about the global cost of a p lan (that is defined as the sum of the costs of all its action s). This type of informa tion are useful to explore the use of constraints in determining optimal plans. The cost of actions is expressed using assertions of the fo llowing f orms (where F E is a fluent expression b uilt using the fluents presen t in the state): • action cost ( a, F E ) spec ifies the cost of th e execution of the action a as re sult of the expression F E . • state cost ( F E ) specifies the cost of a state as the result of the e valuation of F E . Whenever , for an action or a state, no c ost d eclaration is p rovided, a default co st of 1 is assumed. On ce we h av e pr ovided the costs for actions and states, we can imp ose constraints on the cumulative costs of specific states or co mplete trajectorie s. Th is can be do ne in B M V using ass ertions of th e follo w ing types (where k is a number a nd op a relational operator): • cost constraint ( plan op k ) ; the assertion adds a co nstraint o n the global cost of the plan. • cost constraint ( goal op k ) ; the assertion imposes a constrain t on the global cost of the final state. • cost constraint ( state(i) op k ) ; the assertion imposes a constraint on the global cost of the i th state of the trajectory . As a n imme diate g eneralization of the above c onstraints, we admit assertio ns of the form cost constraint ( C ) , where C is a constraint, possibly inv olv ing fluents, where th e atoms plan , goal , and state(i) might occu r in any place where a fluent might— intuitively rep resenting the cost of a plan, o f the goal state, and of the i th state, respec- ti vely . Some directives c an be adde d to an action theor y to select optimal solutions wit h respect to the specified costs: minimize cost ( F E ) , where F E is an expression inv olv ing the atoms plan , goal , and state(i) , and possibly other fluents. This assertion constrains the search to deter mine a plan that m inimizes the value of the expression F E . For instance, the tw o assertions minimize cost ( plan ) and minimize cost ( goal ) con strain the search o f a plan with m inimal global cost and with minimal cost of the goal state, respectiv ely . W e provide a more precise sem antics fo r all these assertions in Sec tion 6.4. In s pecifying a planning problem hD , O i , we con sider cost constraints as part of the observations O . 6 Semantics and Abstract Implementation of B M V W e will b uild the semantics of the language B M V incrementa lly . W e will start by building the semantics for the sub-lan guage of B M V dev o id of any form of ti me refer ence and cost constraints (Section 6.1). This core lan guage is called B M V 0 . The su bsequent Sections 6.2– 6.4 treat the full B M V . 24 A. Dovier , A. F ormisano, E. P on telli 6.1 Semantics for T imeless Constraints Each fluent f is uniquely assigned to a domain dom( f ) in the fo llowing way: • if fluent ( f , S et ) ∈ D , then dom( f ) = S et . A functio n v : F → V ∪ {⊥} is a state if v ( f ) ∈ dom( f ) ∪ {⊥} fo r all f ∈ F . The special symbo l ⊥ deno tes that the value of the flu ent is unde fined. A state v is c omplete if for all f ∈ F , v ( f ) 6 = ⊥ . For a number N > 1 , we define a state sequenc e ~ v as a tuple h v 0 , . . . , v N i wh ere each v i is a state. Giv en a state v , and an expression ϕ , w e define the value of ϕ in v (with abuse of notation, denoted by v ( ϕ ) ) as follows: 7 • v ( x ) = x if x ∈ V • v ( f ) = v ( f ) if f ∈ F (abuse of notation here) • v ( − ( ϕ )) = − ( v ( ϕ )) • v ( abs ( ϕ )) = | ( v ( ϕ )) | • v ( ϕ 1 ⊕ ϕ 2 ) = v ( ϕ 1 ) ⊕ v ( ϕ 2 ) • v ( rei ( C )) = 1 if v | = C • v ( rei ( C )) = 0 if v 6| = C (10) W e tr eat the inter pretation o f the various ⊕ operation s and relation s as strict with respect to ⊥ (i.e., ⊥ ⊕ x = x ⊕ ⊥ = ⊥ , abs ( ⊥ ) = ⊥ , etc.). The last two cases in ( 10) specif y th e seman tics of reification . Reified con straints are useful to enable reasoning about the satisfaction state of other formulae. The intuitiv e semantics is that a fluent expression re i ( C ) , where C is a fluen t con straint, assumes a Boolean v alu e ( 0 or 1 ) dependin g o n the truth of C . Note that the semantics of reified con- strains relies o n the notio n of satisfaction , which in turn is defined by stru ctural ind uction on constrain s, as fo llows. Given a primitive fluent con straint ϕ 1 op ϕ 2 , a state v satisfies ϕ 1 op ϕ 2 , written v | = ϕ 1 op ϕ 2 , if a nd only if it hold s that v ( ϕ 1 ) op v ( ϕ 2 ) where the se- mantics of the arithme tic relators/operator s is the u sual one on Z . If either v ( ϕ 1 ) o r v ( ϕ 2 ) is ⊥ , we assume th at v 6| = ϕ 1 op ϕ 2 (and v 6| = ϕ 1 nop ϕ 2 where no p is the negation of the o perator op ). Basically undefin ed formulas ar e neith er proved nor d isproved. The sat- isfaction relation | = can b e gener alized to the case of pro positional combination s of fluent constraints in the usual manner . Giv en a con straint C , let fluents ( C ) be the set o f fluents oc curring in it. A fun ction σ : fluents ( C ) − → V is a solution of C if σ | = C . W e deno te the dom ain fl uents ( C ) of the f unction σ as do m( σ ) . In oth er word s, a solution σ of C can b e seen as a pa rtial state satisfying C . Ob serve that we require th e solutio n to man ipulate exclusively the fluents that appear in the constraint. Example 7 Let us con sider an action theo ry over th e fluents f , g , h , where each flu ent has do main { 1 , . . . , 5 } . If C is th e con straint f > g + 2 , th en a solutio n of C is σ = { f / 5 , g / 2 } . Note that the substitution θ = { f / 5 , g / 2 , h/ 1 } is n ot a solution of C , since dom( θ ) 6 = fluents ( f > g + 2 ) .  7 The expre ssion | n | denotes the (algebrai c) absolute va lue of n . Multi-valued Action Languages in CL P(FD) 25 Let σ b e a solution of a constra int C and v a state, with ine ( σ , v ) we denote th e state obtained completing σ in v by inertia , as follows: ine ( σ, v )( f ) =  σ ( f ) if f ∈ dom( σ ) v ( f ) otherwise Example 8 Let us continu e with Example 7. If σ = { f / 5 , g / 2 } and v = { f / 1 , g / 1 , h/ 1 } , then ine ( σ , v ) = { f / 5 , g / 2 , h/ 1 } .  An action a is executable in a state v if ther e is an ax iom executab le ( a, C ) suc h that v | = C . Remark 3 As for the case of the lang uage B , also in B M V the executability laws express necessary but no t su fficient preco nditions f or actio n execution (c f., Remar k 2). Mor eover , thank s to the generality of the constra int language—i.e., any propositional combination of primiti ve constraints can be used in B M V —the ex ecutable la ws a lso allo w direct fo rmulation of non-executability cond itions an d the roles of the exe cutable and non executable axioms coincide. Let us denote with Dy n ( a ) the set of dyn amic ca usal law axioms for action a . The effect of executing a in state v , d enoted by Eff ( a, v ) , is a constraint defined as follows: Eff ( a, v ) = ^ { C | causes ( a, C, C 1 ) ∈ D y n ( a ) , v | = C 1 } . 6.1.1 B M V 0 without static causal laws Let us start by considerin g the simplified situation in which S L = ∅ , i.e., n o static causal laws are s pecified in the doma in description. During the execution o f an action a , a fluent has to be con sidered as inertial, provided that it does not ap pear amo ng the e ffects of th e dyn amic laws for a . In o ther words, since these effects are expressed throug h constra ints, a fluent is inertial if i t does not occu r in any of the constraints specified in the dynamic laws for a . The descr iption o f th e state transition s ystem correspo nding to a g i ven action description theory hDL , E L , ∅i can be com pleted by defining the notion of transition. A triple t h v , a , v ′ i , where v , v ′ are complete states and a is an action, is a valid state transition if: • the action a is executable in v , an d • v ′ = ine ( σ, v ) , wh ere σ is a solution of the con straint Eff ( a, v ) . Let hD , O i b e an instan ce of a plannin g problem , ~ v = h v 0 , . . . , v N i be a seq uence of complete states and a 1 , . . . , a N be ac tions. W e say that h v 0 , a 1 , v 1 , . . . , a N , v N i is a va lid trajectory if: • for each axiom of the form initially ( C ) in O , we have that v 0 | = C , • for each axiom of the form goal ( C ) in O , we h av e that v N | = C , and • for all i ∈ { 0 , . . . , N − 1 } , h v i , a i +1 , v i +1 i is a valid state transition. 26 A. Dovier , A. F ormisano, E. P on telli Example 9 Let us consider the Example 5. Observe th at h{ f / 1 , g / 1 , h/ 1 } , a, { f / 5 , g / 3 , h/ 1 }i is a valid trajectory .  Remark 4 Giv en a planning pro blem hD , O i in B M V 0 , dif f erently f rom what happens in the case of B , a solu tion to a plannin g pro blem is described by a valid trajector y , not just by a sequence of actions. Th is is the case b ecause action s migh t have no n-determ inistic effects. For instanc e, let us consider Examp le 5. If the action a is executed and the precondition g<3 hold s, then the dynamic causal law imposes the constrain t f=g+2 in the reached state. There are many different ways to satisfy this require ment. Henc e, in ge neral, a sequence of a ctions mig ht not characterize a unique state sequence. The same argu ment also applies to the action description language B M V , so in wh at follows we will conside r the v alid trajecto ries as the solutions of a planning problem. 6.1.2 Abstract implementation in absence of static laws In this section we propo se a constraint-b ased char acterization o f the state tr ansition system defined in Section 6. 1.1. Similarly to what we h av e done in th e case of B , for any specific state, each fluent f will b e repr esented by an integer-v alued co nstraint variable. Boolean variables will instead mod el the occurrences of actions. Let u b e a state; given a flu ent f , we in dicate w ith F u f the variable re presenting f in u . W e g eneralize such a notation to any co nstraint C , i.e., we den ote with C u the co nstraint obtained fro m C by rep lacing each fluent f ∈ fl uents ( C ) by F u f . For ea ch actio n a ∈ A , a Boolean variable A u a is introd uced, representing whether the action is executed or not in the transition from u to the next state. Giv en a specific flu ent f , we develop a system of constraints to constrain the values of F u f . Let us consider the dynam ic causal laws that ha ve f within their con sequences: DL f =  causes ( a i f, 1 , C f , 1 , α f , 1 ) , · · · , causes ( a i f,m f , C f ,m f , α f ,m f )  For each action a we will have its e xecutability conditions: E L a =  executable ( a, δ a, 1 ) , · · · , executab le ( a, δ a,p a )  Figure 8 describes th e constraints C u,v f ,a that can be u sed in encod ing the relations that determine the value of th e fluent f in the state v (i.e., constrain the variable F v f ) w .r .t. the app lication o f the action a in the state u . After the settin gs o f the dom ains (by ( 11)), we imp ose thr ough (12) that if action a is executed, then a t lea st o ne o f the p recond itions for its executability m ust ho ld in u . For each j ∈ { 1 , . . . , m f } the c onstraint (13) d efines a Boole an flag Dy n u f ,j that h olds if and only if action a i f,j is ap plicable in u and the precon ditions of the j th dynamic cau sal law for f ho lds in u . T he constrain t (14) require s that if D y n u f ,j is true, then the cor respond ing effects must hold in the new state v . Finally , inertia constraints are set by means of (15). W e will deno te with C u,v f the co njunction of these co nstraints for all actions a ∈ A . Giv en an action dom ain specification over the signature hV , F , Ai and two states u , v , th e system of constraints C u,v F includes: Multi-valued Action Languages in CL P(FD) 27 F v f , F u f ∈ dom( f ) (11) A u a → p a _ j =1 δ u a,j (12) A u a i f,j ∧ α u f ,j ↔ Dy n u f ,j ∀ j ∈ { 1 , . . . , m f } (13) Dy n u f ,j → C v f ,j ∀ j ∈ { 1 , . . . , m f } (14) ¬ m f _ j =1 Dy n u f ,j → F u f = F v f (15) Fig. 8. The constraints C u,v f ,a for a state transition from u to v , for a fluent f . • the constraint C u,v f for each fluent literal f in the langua ge of F • the constraint P a ∈A A u a = 1 (uniqu e action execution in the state transition ). The n ext the orem states com pleteness an d soundn ess o f the encodin g d escribed so far . W e need a fu rther piece o f notation . Gi ven two states u, v and an a ction a , let C u,a F be the constraint ob tained fro m C u,v F by setting A a = 1 , A b = 0 fo r all b 6 = a , and F u f = u ( f ) for each fluent literal f . Theor em 6 Let D = hDL , E L , ∅i and let u, v tw o states an d a an action. Th en h u, a, v i is a valid transition in the semantics of the languag e B M V 0 if and o nly if v represents a solutio n of the constraint C u,a F . Pr oof ( ⇒ ) Let h u , a, v i be a valid tran sition. Then , a is executable in u . Hence u | = δ a,j for some j ∈ { 1 , . . . , p a } and (12) is satisfied. By the d efinition o f state we h av e that (11) is also satisfied. Let v = ine ( σ , u ) with σ so lution of Eff ( a, u ) . If f is a fluent no t belo nging to do m( σ ) then f does not o ccur in Eff ( a, u ) and it is not affected by any dynamic causal law in volved in the state transition. By definition of ine ( · ) we have tha t v ( f ) = u ( f ) and th is satisfies constraint (15). Satisfaction of constraints (13) a nd (1 4) is imme diately verified by o bserving that for all dynam ic cau sal laws causes ( a i f,h , C f ,h , α f ,h ) having f in C f ,h , the co nstraint α f ,h is false in u . Then, the correspon ding flag D y n u f ,h is set false by (13). Consequently , (14) is satisfied. Assume n ow that f is a fluent in dom( σ ) . Th is means that there are dy namic cau sal laws causes ( a i f,h , C f ,h , α f ,h ) such that α f ,h is true in u , for h ∈ X = { j 1 , . . . , j r } ⊆ { 1 , . . . , m f } . Co nsequently , the flag D y n u f ,h is set true for h ∈ X and false oth erwise. Since σ is a solution o f Eff ( a, u ) , v satisfi es the con straint C v f ,j for all j ∈ X . This implies that (14 ) is satisfied for each j ∈ { 1 , . . . , m f } . S ince s ome flags D y n u f ,i are true constraint (15) is satisfied too. ( ⇐ ) Assume that v satisfies the constrain t C u,a F . By (12), b ecause A a = 1 , some of th e constraints δ u a,h is satisfied. Hen ce, action a is executable in u . By t he satisfaction of (13) and (14), v satisfies all co nstraints C v f ,j for whic h th e cor respond ing α u f ,j is satisfied. Then, v is a solu tion for Eff ( a, u ) . Co nsequently , since v = ine ( v , u ) (by definitio n, since v is com plete), h u, a, v i is a valid transition. 28 A. Dovier , A. F ormisano, E. P on telli Let hD , O i be an instance of a plan ning p roblem where D is a n action description an d O contains any n umber of axioms of the for m initia lly ( C ) an d goal ( C ) . W e can state the following. Theor em 7 There is a valid trajector y h v 0 , a 1 , v 1 , a 2 , . . . , a N , v N i if and on ly if there is a solution fo r the constraint ^ initially ( C ) ∈O C v 0 ∧ N − 1 ^ j =0  C v j ,v j +1 F  ∧ ^ goal ( C ) ∈O C v N Pr oof The result follows from (rep eated) applications of Theorem 6. 6.1.3 Adding static causal laws In this section we consider th e case of actio n theo ries hD L , E L , S Li o f B M V 0 , inv olv ing static causal laws (i.e., such that S L 6 = ∅ ). The p resence of static laws requir es r efining the seman tics o f the languag e, in order to ensure proper treatment of inertia in the construction of a valid trajector y . W e start by defining three operatio ns ∩ , ∪ , and △ o n states, as follows: v 1 ∪ v 2 ( f ) =        v 1 ( f ) if v 1 ( f ) = v 2 ( f ) v 1 ( f ) if v 2 ( f ) = ⊥ v 2 ( f ) if v 1 ( f ) = ⊥ ⊥ otherwise v 1 ∩ v 2 ( f ) =  v 1 ( f ) if v 1 ( f ) = v 2 ( f ) ⊥ otherwise △ ( v 1 , v 2 , S )( f ) =  v 1 ( f ) if f ∈ S v 2 ( f ) otherwise where the set S used in △ is a set of fluents. Observe t hat ine ( σ , v ) = △ ( σ , v , do m ( σ )) . A state v is closed w .r . t. a set of static causal laws S L = { caus ed ( C 1 , D 1 ) , . . . , caused ( C k , D k ) } if v | = ( C 1 → D 1 ) ∧ · · · ∧ ( C k → D k ) . W e deno te this property as v | = S L . Giv en tw o states v , v ′ , a set of flu ents D , and a set S L o f static causal laws, we say that v ′ is minimally closed w .r .t. v , D , and S L if • v ′ | = S L ( i.e., v ′ is closed) and • for all S ⊆ D , if △ ( v , v ′ , S ) 6 = v ′ then △ ( v , v ′ , S ) 6| = S L . The notion of minimally closed state is intended to capture the law of inertia, w .r .t. a giv en set D of fluents. Notice, in fact, that △ ( v , v ′ , ∅ ) = v ′ . Intuiti vely speak ing, v ′ is minimally closed when it is ob tainable fr om v by applyin g a minimal s et of (necessary ) ch anges in the values of the ‘inertial’ fl uents (those in D ). In other word s, it is not possible to obtain from Multi-valued Action Languages in CL P(FD) 29 v v ′ F \ D D △ ( v , v ′ , D ) : v v ′ F \ D D S F \ S △ ( v , v ′ , S ) for S ⊆ D : Fig. 9. Th e set △ ( v , v ′ , X ) is o btained by combin ing a portio n of v and a portio n of v ′ , depend ing o n the th ird argum ent X , which acts as a regulator in “mixin g” po rtions of v and v ′ . The figure visua lizes, in gray , the two sets △ ( v , v ′ , D ) ( above) and △ ( v , v ′ , S ) (below) fo r S ⊆ D ⊆ F and illustrates th e de finition of min imal closure. A state v ′ is minimally closed if and o nly if v ′ | = S L and for all S ⊆ D , if △ ( v , v ′ , D ) 6 = v ′ then △ ( v , v ′ , S ) 6| = S L . In both cases, the surroundin g frame represents the set F of all fl uents. v a state different from v ′ and clo sed w .r .t. S L , by applyin g “fewer changes” than tho se in volved in obtaining v ′ . A pictorial represen tation of △ ( v, v ′ , X ) is shown in Figur e 9. Observe that if S L = ∅ then v ′ is minim ally closed w .r .t. v , D , and S L if and o nly if v = v ′ . Example 10 Let f , g , h be fluents with dom( f ) = dom( g ) = dom( h ) = { 0 , 1 } and S L = { caus ed ( f = 1 , g = 1 ) , caused ( f = 0 , g = 0) } . Consider th e states v = { f / 0 , g / 0 , h/ 0 } , v ′ = { f / 1 , g / 1 , h/ 1 } , v ′′ = { f / 0 , g / 0 , h/ 1 } and let D = { f , g } . Then, v ′ and v ′′ are both closed w .r .t. S L . Howe ver, v ′′ is min imally closed w .r .t. v , D , and S L , while v ′ is no t minim ally clo sed since △ ( v , v ′ , D ) = { h/ 1 , f / 0 , g / 0 } is different from v ′ and closed.  A triple t h v , a , v ′ i , where v and v ′ are c omplete states and a is an actio n, is a valid transition if: 1. the action a is executable in v and 2. we have that v ′ = ine ( σ, v ′ ) where • σ is a solu tion of the constraint Eff ( a, v ) , and • v ′ is minimally closed w .r .t. v , F \ dom( σ ) , an d S L . Intuitively , the co nditions that define a transition are designed to guarantee that: 30 A. Dovier , A. F ormisano, E. P on telli • a solution σ fo r the constraints describing the ef fects of the action is determined; • such solution is part of the new state v ′ constructed (thanks to v ′ = ine ( σ, v ′ ) ); and • the new state is minimally closed with r espect to all the flu ents not affected by the execution of the action. Let us observe that, since all fluents in the domain of any solution σ of Eff ( a, v ) maintain the same v alue in v ′ , it holds that v ′ | = Eff ( a, v ) . Notice th at the notion of a valid transition gi ven in presence of static la ws p roperly extends the one gi ven in Section 6.1.1. In fact, the follo wing property holds: Lemma 1 If S L = ∅ then ine ( σ, v ) = ine ( σ, v ′ ) . Pr oof It is sufficient to note that, if S L = ∅ the n v ′ is minimally closed w .r .t. F \ dom ( σ ) if a nd only if ine ( σ , v ) = v ′ . Example 11 Let us extend the action description of E xample 10. W e consider the following doma in description: fluent ( f , { 0 , 1 } ) . fluent ( g , { 0 , 1 } ) . fluent ( h, { 0 , 1 } ) . action ( a ) . executable ( a, h = 0) . causes ( a, h = 1) caused ( f = 1 , g = 1) . caused ( f = 0 , g = 0) . Let us con sider the thr ee states v = { f / 0 , g / 0 , h/ 0 } , v ′ = { f / 1 , g / 1 , h/ 1 } , and v ′′ = { f / 0 , g / 0 , h/ 1 } . Then h v , a, v ′′ i is a valid transition, while h v, a, v ′ i is not.  Let hD , O i be a p lanning pr oblem instance. Let ~ v = h v 0 , . . . , v N i be a sequence o f complete states and let a 1 , . . . , a N be a ctions. Then h v 0 , a 1 , v 1 , . . . , a N , v N i is a valid trajectory if the follo win g conditions hold: • v 0 | = S L , and for each axio m initially ( C ) in O , we have that v 0 | = C ; • for each axiom of the form goal ( C ) in O , we h av e that v N | = C ; • h v i , a i +1 , v i +1 i is a valid transition, for each i ∈ { 0 , . . . , N − 1 } . 6.1.4 Abstract implementation in pr esence of static laws Let us consider a fluent f and a tr ansition from state u to s tate w , due to an action a , and let us ado pt the same n otation ( F u f , C u , A u a , etc.) introduc ed in Section 6.1 .2. The state tran- sition fr om u to w can be seen as the composition of two step s inv olving an interm ediate state v . The first of these steps reflects the effects of the dynamic laws, whereas the s econd step r ealizes the closure w .r .t. the static causal laws. Hence we pr oceed by introdu cing a set of v ariab les cor respond ing to the intermediate st ate v = ine ( σ, u ) , where σ is a solution of Eff ( a, u ) . The co nstraint-based description of th e first step is e ssentially the sam e we described in Section 6.1 .2—thus, we only ne ed to exten d the con straint system defined in Figure 8 to reflect the second part of the transition. Multi-valued Action Languages in CL P(FD) 31 F w f ∈ dom( f ) (16) Dy n u f ,j → F w f = F v f ∀ j ∈ { 1 , . . . , m f } (17) G w f ,j → D w f ,j ∀ j ∈ { 1 , . . . , h f } (18) S t a t v f ↔ ^ g ∈ L f „ “ m f _ j =1 ` Dy n u f ,j ∧ g ∈ fluents ( C f ,j ) ´ ” → F v g = F u g « (19) S t a t v f → ^ g ∈ L f F w g = F v g (20) S L u w v E ( a, u ) Inertia E ( a, u ) a S L Fig. 10. The constraints for a state transition from u to w ( with intermediate state v ), fo r a fluent f . Giv en a set L ⊆ F of fluents, let S L L ⊆ S L be the collection of all static causal laws in wh ich at least on e fluen t of L occurs. Mo reover , for simplicity , let S L f denote S L { f } , i.e., the set of all static causal laws t hat inv olve the fluent f . Let us d efine a r elation R ⊆ F × F so that f 1 Rf 2 if an d on ly if S L f 1 ∩ S L f 2 6 = ∅ . R is an equ iv alenc e relation and it partitio ns F . Each eleme nt (i.e., eq uiv alen ce class) of th e quotient F /R is said to be a cluster (w .r .t. S L ). Notice that a cluster can be a singleton { f } . Let f be a fluent, we denote with L f its cluster w . r .t. S L . Example 12 Assume that S L co nsists of the rules caused ( true , f = 1) . caused ( g = 2 , h = 3) . caused ( h < 5 , r = 2) . Then the two clusters are { f } an d { g , h , r } .  Giv en a fluen t f , let us con sider the sets of dyn amic and executability laws D L f and E L a , as defined in Section 6.1. 2. More over , let us consider th e cluster containin g f , let it be L f = { f 1 , . . . , f k } , and the correspo nding s et of static causal laws S L L f : S L L f =  caused ( G f , 1 , D f , 1 ) , · · · , caused ( G f ,h f , D f ,h f )  . Figure 10 describ es the constraints (to b e add ed to those in Fig ure 8) that are used in 32 A. Dovier , A. F ormisano, E. P on telli encodin g the relations that determine the v alu e of the fluent f in state w ( represented throug h the variable F w f ) after the execution of action a in th e state u (we recall that v is to be considered as an intermediate state v = ine ( σ , u ) ). The constraint (1 6) sets the domain s for th e variables F w f . The con straint ( 17) pro pagates to w the effects o f th e dy namic laws. C onstraint (18) imposes closure w .r .t. the static causal laws. Finally , constra ints (19)–(2 0) require th at if all the fluen ts in dom( σ ) that belong to the cluster L f are lef t unchan ged in the tran sition, then all the fluen ts of L f should not change their values. More pr ecisely , as far as (1 9) is co ncerned , S tat v f is set to true if , fo r all fluents g in L f , either g is not af fected b y the dy namic laws (i.e., F v g = F u g ), or f or each activ ated dyn amic law causes ( a i f,j , C f ,j , α f ,j ) ( i.e., such that its prec ondition α u f ,j is true) , g d oes not o ccur in its effects (i.e., in C f ,j ). Notice th at, with r espect to a spec ific state tr ansition, we are not co nsidering sub ject to iner tia all th ose flue nts that occ ur in the effects of (at least) one activ ate d dynamic la w . The enforcemen t of the con straint (20) constitutes a necessary , but not sufficient, cond i- tion for the target state to be minimally closed. W e will discuss later on this poin t. Let u s d enote with C u,w f the co njunction o f the constrain ts (11)– (18) for all actio ns a ∈ A . Given an a ction d omain specificatio n over the signatu re hV , F , Ai , the system of constraints C u,w F includes: • the constraint C u,w f for each fluent literal f in the langua ge of F ; • the constraint P a ∈A A u a = 1 . Similarly , let S tat u,w F denote the con junction of all the c onstraints of the f orms (1 9) an d (20). The next theorem states completeness of the en coding described so far . Again , given two states u, w and an action a , let C u,a F and St at u,a F denote the co nstraints obtained from C u,w F and St at u,w F , respectively , by setting A a = 1 , A b = 0 for all b 6 = a , and F u f = u ( f ) for each fluent literal f . Theor em 8 Let D = hD L , E L , S Li and let u, w two states and a a n actio n. T hen, if h u, a, w i is a valid transition in the seman tics of the lan guage B M V 0 , then w r epresents a solu tion of the constraint C u,a F ∧ Stat u,a F . Pr oof For the constraints (11)–(16), con sidering th e transition fro m u to v , the pro of p roceeds analogo usly to the first part of the proo f of Theorem 6. Let us sketch the part of the proof r egarding the effect of the static causal laws. Since h u, a, w i is a valid tr ansition, w = i n e ( σ , w ) , w ag rees with v = ine ( σ , u ) on all fluents in dom( σ ) , hen ce (17) hold. Moreover , w is closed w .r .t. S L , h ence it satisfies (1 8). From the fact that w is min imally closed w .r .t. ine ( σ , u ) , F \ dom( σ ) , and S L , it fo llows that w satisfies (19)–(20). The abov e encod ing does not g uarantee soundn ess. This is becau se the constraints (1 7)– (18) in Figures 8 and 10 might adm it solutions not corr espondin g to minimally closed states. Multi-valued Action Languages in CL P(FD) 33 W e in troduce d the notion of c luster to par tially recover the sound ness of the encoding . Intuitively spea king, a cluster generalizes, to the multi-valued case, the notion of lo op seen in Section 3.2: a clu ster is a set of fluen ts whose values ha ve been declared to be mutu ally depend ent through a set of static causal laws. I n a state transition, similarly to the ca se o f loops, chang es to the fl uents of a cluster might occur because of their mutual influen ce, n ot being (indirectly) caused by dynamic laws. Constraints (19) and (2 0) impose inertia on all the fluen ts of a cluster whe never no ne of them is influenc ed by dynam ic laws. Howe ver, note that imposing (1 9)–(20) d oes not completely c ircumvent the problem becau se state transitions violatin g the inertia are still admitted. In fact, ( 19)–(20) d o no t impo se in ertia o n the fluents of a cluster when at least one of the m is chang ed by the dyn amic laws. This might lead to in valid transitions, in which a chang e in the v alue of a fluent of a cluster hap pens e ven if th is is not necessary in order to satisfy all the static causal laws. Nev ertheless, we introduced th e co nstraints (19) and (20) because they constitute a goo d compro mise w .r .t. the efficiency of a concrete implementation (as discussed later). T o com pletely enfor ce soundness, we need to apply a filter on th e solu tions that are admitted by th e enc oding described so far . T o this aim, let us intro duce a co ndition on the values of the flu ent, wh ich is intended to mimic, in the multi-valued setting, th e effect of loop formulae. Let us as sume that the action a is ex ecuted in the state u , and that σ , v , an d w have been determined so that to satisfy the c onstraint C u,w F . In this situation the following constraint characterizes an hypoth etical state x , different from w : F orm ( D ) u,a =  C u,x F ∧ (21) ^ f ∈F  m f _ j =1 D y n u f ,j → F x f = F w f  ∧ (22) _ f ∈F F x f 6 = F w f ∧ ^ f ∈F  F x f 6 = F w f → F x f = F u f   (23) Intuitively , the satisfaction of such a formula witnesses th e existence o f a co unterexamp le for the minimal c losure of w . Notice tha t, bein g σ , v , and w already deter mined, the only fluents/variables to b e determ ined are those describing th e state x , if any . Th e co njunct in line (21) states that x is a target state alterna ti ve to w ; in particular, it en forces the c losure of x w .r .t. S L . The con junction ( 22) states th at x and w agree on th e fluents in dom( σ ) . Finally , (23) states th at x must differ from w and it must a gree with u in at least one fluent—that, because of (22), it is in F \ dom( σ ) . W e can prove the following result, that generalizes Theorem 6 to the case of S L 6 = ∅ . Theor em 9 Let D = hD L , E L , S L i and u, w two states, with u closed w .r .t. S L . L et a an action such that w r epresents a solu tion of th e constrain t C u,a F . Then h u , a, w i is a valid tran sition in the semantics of the language B M V 0 , if F orm ( D ) u,a is unsatisfiable. Pr oof 34 A. Dovier , A. F ormisano, E. P on telli By proc eeding as in th e proo f of T heorem 6, we can show that all needed cond itions for h u, a, w i to b e a valid transition are satisfied, except for the minimal closure of w . Let us assume, b y contrad iction, th at w is not minimally closed w .r .t. u , F \ do m( σ ) , and S L . Then , there exists S ⊆ F \ dom( σ ) such that x = △ ( u, w , S ) 6 = w and x | = S L For each flu ent f 6∈ S it holds that F x f = F w f . Mo reover , F v f = F w f holds too , because w satisfies C u,a F . Hence, D y n u f ,j → F x f = F v f holds for all j . For each fluent f , sin ce x is clo sed w .r .t. S L , we have tha t G x f ,j → D x f ,j (for all j ∈ { 1 , . . . , h f } ). Ob serve that the condition s of the fo rms (11)–(1 6) in the con junct at lin e (21) (i.e., in C u,x F ) do not depend on the specific x . Then, the conjunct (21) is satisfied. Let us also observe that condition (22) holds to o. This is so because, for all f ∈ dom( σ ) we have that F x f = F w f = F v f . Fro m the fact that x 6 = w it follows that W f ∈F F x f 6 = F w f holds. Finally , the c ondition (23) is satisfied becau se, whenever F x f 6 = F w f holds, b y the definition of △ , it must be the case that F x f = F u f . I t follows that F orm ( D ) u,a is satisfiable (by x ). This is a co ntradiction and p roves that w is min imally closed w .r .t. u , F \ dom( σ ) , and S L , and that h u, a, w i is a valid transition . Let hD , O i b e an instance o f a plann ing prob lem, where D is a domain descrip tion and O contains any numb er o f ax ioms of the for m initial ly ( C ) and goal ( C ) . W e conclud e this section by stating a generalization of Theorem 7 to the case of S L 6 = ∅ . Theor em 10 There is a valid trajectory h v 0 , a 1 , v 1 , a 2 , . . . , a N , v N i if and only if • v 0 | = S L • There is a solution for the constraint ^ initially ( C ) ∈O C v 0 ∧ N − 1 ^ j =0 C v j ,v j +1 F ∧ ^ goal ( C ) ∈O C v N • For each j ∈ { 0 , . . . , N − 1 } the formu la F orm ( D ) v j ,a j +1 is unsatisfiable. Pr oof The result follows from Theo rems 8 and 9. Remark 5 ( Embeddin g of B into B M V 0 ) W e con clude this section b y showing that B M V 0 is at least as exp ressi ve as B . T o this aim it suf fices to de scribe h ow to tran slate a dom ain descrip tion D of B to a B M V 0 domain description D ′ , in such a way that the semantics of the domain is preserved. Let us outline the main points of such a translation. Each Boolean flu ent f in D can be m odeled in B M V 0 by a mu lti-valued fl uent f ′ whose domain is V = { 0 , 1 } ⊆ Z . Each action in D uniqu ely corresponds to an action in D ′ . Let us consider a dynamic causal law of D , e.g. , causes ( a, f , [ f 1 , . . . , f k , neg ( g 1 ) , . . . , neg ( g h )]) . Multi-valued Action Languages in CL P(FD) 35 This law i s translated in D ′ as causes ( a, f ′ = 1 , [ f ′ 1 = 1 , . . . , f ′ k = 1 , g ′ 1 = 0 , . . . , g ′ h = 0]) . In a similar manne r , static laws and executability con ditions of D are mapped into B M V 0 . Consequently , the two do main d escriptions D and D ′ describe two isomo rphic transition systems. 6.2 Adding annotated fluents and non-Markovian references In this section, we generalize the treatm ent describe d in Sectio n 6.1 in ord er to provide a state-transition sem antics for B M V suitable to cope with tem poral refe rences. T he first form of tempora l referen ces inv o lves annotated fluents and con cerns relative acc ess to their past values, w .r .t. the c urrent state. There i s no restriction on the occurrenc es of this kind of annotated fluen ts: they migh t be used in all laws of a d omain descriptio n. In this case, the extension of th e semantics de scribed in Section 6 .1 comes r ather naturally . Sinc e referen ces may relate different poin ts in time along the plan, the app roach consists of considering sequences of states instead of pairs of states, to define the transition constraints. Regarding refer ences to f uture poin ts in time ( i.e., po siti vely annotate d fluents), we recall that they are admitted in the consequ ences of dyna mic causal laws only . This restrictio n allows th e trea tment of future and past refere nces b y exploiting the very same mechanisms. The seman tics is fu rther enric hed in Section 6 .4 to encomp ass state co nstraints specified by using absolute time references, as well as costs. Let ~ v = h v 0 , . . . , v N i b e a state sequ ence. Given ~ v , and i ∈ { 0 , . . . , N } , we de fine the concept of value of ϕ in ~ v at time i (with ab use of n otation, deno ted by ~ v ( i, ϕ ) ) as follows: 8 ~ v ( i, x ) = x if x ∈ V ~ v ( i, f j ) = v i + j ( f ) if f ∈ F , and 0 6 i + j 6 N ~ v ( i, f j ) = v 0 ( f ) if f ∈ F and i + j < 0 ~ v ( i, f j ) = v N ( f ) if f ∈ F and i + j > N ~ v ( i, abs ( ϕ )) = | ~ v ( i, ϕ ) | ~ v ( i, − ( ϕ )) = − ( ~ v ( i, ϕ )) ~ v ( i, ϕ 1 ⊕ ϕ 2 ) = ~ v ( i, ϕ 1 ) ⊕ ~ v ( i, ϕ 2 ) ~ v ( i, rei ( C )) = 1 if ~ v | = i C ~ v ( i, rei ( C )) = 0 if ~ v 6| = i C where n ∈ V , ⊕ ∈ { + , − , ∗ , /, mod } . As for (10) of Sectio n 6.1, the semantics o f reified c onstraints relies on the n otion of satisfaction, which in turn has to be co ntextualized to a specific p oint in time i . More formally , given a fluen t constraint ϕ 1 op ϕ 2 and a state sequ ence ~ v , the n otion of satisfaction at time i is defined as ~ v | = i ϕ 1 op ϕ 2 ⇔ ~ v ( i, ϕ 1 ) op ~ v ( i, ϕ 2 ) . The n otion | = i is gen eralized to the case of propo sitional comb inations of fluent constraints in the usu al manner . Giv en a constraint C , let > - fluents ( C ) be the set of anno tated fluents f i , for i > 0 , 8 A slightly simplified treatment could be described if only past references are admitted . In this case, we con- sider i to be the current point in time and j to be negati ve. The not ation could then be simplified b y c onsiderin g just a prefix ~ v = h v 0 , . . . , v i i of the state sequence. 36 A. Dovier , A. F ormisano, E. P on telli occurrin g in C . Given a state seq uence ~ v = h v 0 , . . . , v i i , with 0 6 i < N , a function σ : > - fluents ( C ) − → V is an i -solution of C w .r .t. ~ v , if it holds that h v 0 , . . . , v i , ine ( σ | 0 , v i ) , ( σ | 1 ) , . . . , ( σ | N − ( i +1) ) i | = i +1 C, where each σ | k (for k > 0 ) is the restriction of the assign ment σ to the fluent an notated with k , and µ denotes the substitution obtained by completing µ , with assignment to ⊥ for all fluents not in dom( µ ) . Note that we treat th e interpretation of the various operations as strict w .r .t. ⊥ and we assume satisfied all constra ints that refer to und efined expressions. Hence, for instance, if C is constrain t and there is a s ub-expression ψ of C ev aluated as ⊥ , then we assume ~ v | = i C . Example 13 Let N = 3 and i = 1 . Consider th e co nstraint C ≡ ( g 0 = f − 1 + f − 2 ) a nd let ~ v = h v 0 , v 1 i = h{ f / 2 , g / 1 } , { f / 1 , g / 2 }i . Then σ = { g / 3 } = σ | 0 is a 1-solution of the constraint C , since • ine ( σ | 0 , { f / 1 , g / 2 } ) = ine ( { g / 3 } , { f / 1 , g / 2 } ) = { f / 1 , g / 3 } , an d • h{ f / 2 , g / 1 } , { f / 1 , g / 2 } , { f / 1 , g / 3 } , { f / ⊥ , g / ⊥} , i | = 2 g 0 = f − 1 + f − 2 , in fact, we have that ~ v (2 , C ) is ~ v (2 , g 0 ) = ~ v (2 , f − 1 + f − 2 ) , which is equivalent to v 2 ( g 0 ) = v 1 ( f ) + v 0 ( f ) .  A state sequence ~ v = h v 0 , . . . , v h i is closed w .r .t. a set of static causal laws S L = { caus ed ( C 1 , D 1 ) , . . . , caused ( C k , D k ) } if for all i ∈ { 0 , . . . , h } it hold s that ~ v | = i ( C 1 → D 1 ) ∧ · · · ∧ ( C k → D k ) . W e also generalize the notion of minimal closur e as follo ws: given a state sequ ence ~ v = h v 0 , . . . , v i i and a state v ′ we say that v ′ is minimally closed w .r .t. ~ v , D , a nd S L if • h v 0 , . . . , v i , v ′ i is closed w .r .t. S L • for all sets of fluents S ⊆ D , if the state ∆( v i , v ′ , S ) is different fr om v ′ , then h v 0 , . . . , v i , ∆( v i , v ′ , S ) i is not closed w .r .t. S L . The action a is executable in ~ v at time i if there is an ax iom executable ( a, C ) such that ~ v | = i C . Let us denote with D y n ( a ) th e set of d ynamic cau sal laws for an action a . The effects of executing a in ~ v at time i , deno ted by E ff ( a, ~ v , i ) , is Eff ( a, ~ v , i ) = ^ { P C | causes ( a, P C , C ) ∈ D y n ( a ) , ~ v | = i C } Giv en a constraint C , we deno te by shift t ( C ) th e constraint obtained from C by replac- ing each fluent f x with f x − t . Let us assume that ~ v = h v 0 , . . . , v i i is a sequence o f co mplete states an d th at ~ a is a se- quence of action s h a 1 , . . . , a i +1 i . The effects o f the sequ ence of actio ns in ~ v is represented by the formu la E ( i, ~ a, ~ v ) = i ^ j =0 shift j − i  Eff ( a j +1 , ~ v , j )  ∧ i ^ j =0 ^ f ∈F f j − i = v j ( f ) Multi-valued Action Languages in CL P(FD) 37 Let u s observe tha t this co nstraint mig ht involv e all fluents of the states v 0 , . . . , v i , as well as fluents of future states. The v alues of fluents in states v 0 , . . . , v i are fixed by ~ v . Let hD , O i b e a planning p roblem instan ce, ~ v = h v 0 , . . . , v N i be a seq uence o f comp lete states and a 1 , . . . , a N be actions. Then, h v 0 , a 1 , v 1 , . . . , a N , v N i is a valid trajectory if the following cond itions hold: • h v 0 , . . . , v N i is closed w .r .t. S L • for each axiom of the form initial ( C ) in O , we have that ~ v | = 0 C • for each axiom of the form goal ( C ) in O , we h av e that ~ v | = N C • for each i ∈ { 0 , . . . , N − 1 } the following conditions hold — action a i +1 is executable in ~ v at time i and — we have that v i +1 = ine ( σ | 0 , v i +1 ) where – σ is a i -solution o f the constra int E ( i, h a 1 , . . . , a N i , h v 0 , . . . , v N − 1 i ) w .r .t. h v 0 , . . . , v i i , – v i +1 is minimally closed w .r .t. h v 0 , . . . , v i i , F \ dom( σ ) , and S L . Example 14 Let u s consid er the follo wing do main specification and plan ning pro blem instance (for N = 2 ): fluent ( f , 1 , 5) . fluent ( g , 1 , 5) . fluent ( h, 1 , 5 ) . action ( a ) . action ( b ) . executable ( a, true ) . executable ( b, true ) . causes ( a, g 0 = g − 1 + 2 , t rue ) . causes ( b, f 0 = g − 1 + h − 2 , true ) . initially ( f = 1) . initially ( g = 1) . initially ( h < 3 ) . goal ( f > 4 ) . Observe that the only v alid trajectory is h{ f / 1 , g / 1 , h/ 2 } , a, { f / 1 , g / 3 , h / 2 } , b, { f / 5 , g / 3 , h/ 2 }i . The v alidity can be verified by observing that: • { f / 1 , g / 1 , h/ 2 } satisfies all the constraints provided in the initial declaratio ns; • { f / 5 , g / 3 , h/ 2 } satisfies the goa l constraint f > 4 ; • the action a is executable in h v 0 i = h{ f / 1 , g / 1 , h/ 2 } i and action b is executable in h v 0 , v 1 i = h{ f / 1 , g / 1 , h/ 2 } , { f / 1 , g / 3 , h/ 2 }i (since both their executability la ws and the action con ditions are tri v ially true). • Consider the first state transition and i = 0 and note that > - fluents ( g 0 = g − 1 + 2) = { g } . Then, σ ′ = { g / 3 } is a 0 - solution of g 0 = g − 1 + 2 w .r .t. h{ f / 1 , g / 1 , h/ 2 } i . In fact, σ ′ | 0 = σ ′ , σ ′ | 1 = {} , and 38 A. Dovier , A. F ormisano, E. P on telli — v 1 = ine ( σ ′ | 0 , v 0 ) = ine ( { g / 3 } , { f / 1 , g / 1 , h/ 2 } ) = { f / 1 , g / 3 , h/ 2 } — h v 0 , v 1 , σ ′ | 1 i = h v 0 , v 1 , { f / ⊥ , g / ⊥ , h/ ⊥} i | = 1 g 0 = g − 1 + 2 . — v 1 is minimally closed w .r .t. h{ f / 1 , g / 1 , h/ 2 } i , { f , h } and ∅ . • Consider the second state transition an d i = 1 and no te that > - fluents ( f 0 = g − 1 + h − 2 ) = { f } . Then , σ ′′ = { f / 5 } is a 1 -solu tion of f 0 = g − 1 + h − 2 w .r .t. h v 0 , v 1 i . In fact, σ ′′ | 0 = σ ′′ , and — v 2 = ine ( σ ′′ | 0 , v 1 ) = ine ( { f / 5 } , { f / 1 , g / 3 , h/ 2 } ) = { f / 5 , g / 3 , h/ 2 } — h v 0 , v 1 , v 2 i | = 2 f 0 = g − 1 + h − 2 . — v 2 is minimally closed w .r .t. h v 0 , v 1 i , { g , h } and ∅ .  6.3 Abstract implementation of B M V The constraint enco ding f or B M V is similar to the one developed earlier for the case o f B M V 0 (cf., Figures 8 and 10). I n the en coding of a tra jectory h v 0 , a 1 , v 1 , . . . , a N , v N i in B M V 0 , we intro duced a v ar iable F v i f to repr esent th e v alue of the fluent f in the i th state v i . In each state transition, say from v i to v i +1 , the imp lementation of B M V 0 imposes only constraints in volving the variables/fluents of the current state. In the languag e encom pass- ing timed ref erences, ea ch constrain t o ccurring in the a ction description can ad dress the values that fluents assume in any of the states o f the sequ ence ~ v = h v 0 , . . . , v N i . Since all th e variables rep resenting the se values ar e present in th e enco ding, o nly the following change is needed to adapt to B M V the implem entation d esigned f or B M V 0 : to obtain f rom a constraint C (in volving fluents), a con straint C ~ v ,i (in volving the correspo nding v aria bles), at time i , we replace each f j with the variable F v i + j f . By ado pting th is refined construction fo r C ~ v, i , we can inherit all the results of Sec- tion 6.1 .4. I n particu lar , for an action d escription D , similarly to what do ne in Section 6. 1.4, we denote by C ~ v, a i F and by F orm ( D ) ~ v ,a i the constraints homo logou s to C v i − 1 ,v i F and F orm ( D ) v i − 1 ,a i , respectiv ely . The completeness result fo r B M V directly generalizes that ob tained for B M V 0 . W ith regards to soundness, th e ob servation mad e w .r .t. B M V 0 in Section 6 .1.4 still applies. In fact, let hD , O i b e an instance of a plannin g prob lem where D is a domain description and O contain s axioms of the form initially ( C ) and goal ( C ) . W e state the following: Theor em 11 There is a valid trajectory ~ v = h v 0 , a 1 , v 1 , . . . , v N , v N i if an d only if • ~ v is closed w .r .t. S L • There is a solution for the constraint ^ initially ( C ) ∈O C ~ v , 0 ∧ N − 1 ^ j =0 C ~ v, a j +1 F ∧ ^ goal ( C ) ∈O C ~ v , N • For each j ∈ { 0 , . . . , N − 1 } the formu la F orm ( D ) ~ v ,a j +1 is unsatisfiable. Multi-valued Action Languages in CL P(FD) 39 6.4 Adding costs and global constraints Cost and time constraints can be introdu ced by filtering the solutions character ized by The- orem 11, in ord er to rule out the unsatisf actory so lutions. More precisely , gi ven a trajectory h v 0 , a 1 , v 1 , . . . , a N , v N i satisfying the requir ements of Theorem 11, we say that the tra- jectory satisfies a set of glob al co nstraints as described in Sections 5 .1 and 5.2 if all th e constraints described next hold . Let us start by in vestigating the cost constraints. Let action cost ( a 1 , F E 1 ) , . . . , action cost ( a N , F E N ) and state cost ( F E ′ ) be specified in the action descriptio n. 9 Let us recall th at the general form of cost constrain ts is cos t constraint ( C ) , where C is a co nstraint defined as in Section 5, with the added ability to refer to the atoms plan , goal , and state( i ) wher ev er fluents can be used. C onsequen tly , we extend our definition of value of an expression ϕ in ~ v = h v 0 , . . . , v N i at time i (f or all j ) : ~ v ( j, plan ) = v 0 ( F E 1 ) + · · · + v N − 1 ( F E N ) ~ v ( j, goal ) = v N ( F E ′ ) ~ v ( j, state( i ) ) = v i ( F E ′ ) if 0 6 i 6 N (assigning cost co nstraints to to states outside the plan is senseless. Howe ver , for comp lete- ness, for i < 0 or i > N we set ~ v ( j, st ate( i ) ) = 0 but any other choice — e.g., ⊥ , or the values on states 0 o r N — is rea sonable). This mod ification allo w s us to d erive the no tion of satisf action of a cost constraint C from the notion of satisfaction defined in Section 6.3. As particular cases, we obtain that: • for each assertion cost constra int ( plan op k ) th e plan cost ( v 0 ( F E 1 ) + · · · + v N − 1 ( F E N )) has to satisfy the stated constrain t, i.e., it must hold that ( v 0 ( F E 1 ) + · · · + v N − 1 ( F E N )) op k ; • for each assertion cost constraint ( goal op k ) , the cost v N ( F E ′ ) of the goal state must satisfy the constraint: v N ( F E ′ ) op k ; • for each assertion cost constr aint ( state( i ) o p k ) , the cost v i ( F E ′ ) assign ed to the i th state has to satisfy the constrain t v i ( F E ′ ) op k . The handling of time constraints requires the following modification s: • for each assertion time constraint ( C ) , it h olds that h v 0 , . . . , v N i | = 0 C , where each timed fluent f @ i is evaluated as v i ( f ) ; • for each assertion of the form holds ( C, i ) it holds that h v 0 , . . . , v N i | = i C ; • for each assertion o f the form always ( C ) , it holds th at h v 0 , . . . , v N i | = i C for all i ∈ { 0 , . . . , N } . Moreover , if minimize cost ( F E ′′ ) is specified, the n there e x ists no other trajectory ~ v ′ such that ~ v ′ ( N , F E ′′ ) < ~ v ( N , F E ′′ ) . As particular cases, we have that • if minimize cost ( plan ) is specified, then there exists no other trajectory having a smaller plan cost; 9 As mention ed, if some of these assertion is missing a default cost 1 is assumed. 40 A. Dovier , A. F ormisano, E. P on telli • if minimize cost ( goal ) is specified in the action descrip tion, then there is no tr a- jectory h v ′ 0 , a ′ 1 , v ′ 1 , . . . , a ′ N , v ′ N i , fulfilling all constraints, and such that v ′ N ( F E ′ ) < v N ( F E ′ ) . In this m anner, we characterize th e solutions of a given plannin g problem to be exactly those solutions described by Theo rem 1 1 th at addition ally satisfy all the global co nstraints, the requ irements on costs, and the time con straints expressed in the action descriptio n. Soundn ess and completen ess pro perties directly carry over . 7 Concrete Impl ementation of B M V The overall structur e of the concre te implemen tation of the languag e B M V follows that used for implementing the B langu age. W e f ocus here on the main differences. T o start, let us briefly describe the code d epicted in Figure 11 and show that this co ncrete implementatio n reflects the abstract one defined in Figure 8. 10 Hence, we preliminar ily ignore lines (65)–(66) of Figure 11. The first difference w .r .t. the im plementation of B (cf., Section 3) is that each flu ent variable is assigned to a finite set do main, drawn fro m the fluen t d eclaration—instead of being treated as a Boolean v ariable. The predicate set one fluent (lines (56)–( 68)) has a similar ro le as in the implemen- tation of B . Given the fluent FluentName , the relev an t p arts of the dynam ic causal laws are collected in lines (57)– (59). The predicate zer o sub term is an aux iliary p redicate th at detects if a constraint in volves a fluent—i.e., it looks for an occurre nce of Fluent Name in the con straint impo sed by the dy namic causal laws. All th e fluents explicitly inv olved in the con sequence o f a dy namic law are c ollected. In line (63), the variable E V identify ing the fluent FluentName in the following state ToState is retrieved. The predicate dynamic (line (64)) co llects th e list of Boolean flags DynFormula . If one of th e variables in Dyn is true th en the variable EV is inv olved in a constra int imp osed b y a dynam ic causal law . In line (67) the disjunctio n o f these flag v ariables is comp uted in Formula (let us ignore, fo r the time b eing, the variable StatFormula ). In line (68) the inertia constraint is added: if Formula is f alse then the v alue of the fluent is left unchanged by the transition (i.e., IV = EV ) . This correspond s to the ine ( · ) o perator . For each action Act affecting the v a lue EV , the predicate dynami c (lines (69)– (82)) re- triev es its prec onditions an d builds the con straint C in volving EV that must be imp osed if the preco nditions are satisfied. T he flag variable Fla g in line ( 80) is intro duced to keep track of the fact that the action has occurred (i.e. , VA is true) an d th e corre sponding p recon- dition holds. If Flag is true then the constra in C is asserted ( line (81)). All flags are stored in a list (cf., the v ariable DynFormula in line (64)). Lines (83)–(11 4 ) provide a n excerpt o f the definition of the predicate rel parsing . This p redicate is used to transform flu ent expr essions to internal expressions inv olv ing fluent variables. States is a list of states (e ach of them, in turn is a list of all the fluent variables). The first argument is the fluent expression and the seco nd one is the output 10 Observe that the concrete implementation uses the functors eq , neq , etc. to denote the primiti ve constraint s = , 6 = , etc. Multi-valued Action Languages in CL P(FD) 41 (56) set one flue nt(fluent(FluentNa me,IV), A ctionOccs, Now, States) :- (57) findall([Act,OP ,FE1,FE2,L], (58) (causes(Act,FC,L ), zero subterm(FluentNa me,FC), (59) FC =.. [OP,FE1,FE2]), Dyn), (60) state select(Now, States, FromState), (61) Next is Now+1, (62) state select(Next, States, ToState), (63) member(fluent(F luentName,EV), ToState), (64) dynamic(Dyn, ActionOccs, FromState, DynFormula, Next, States), (65) cluster rules(FluentName , Stat), %%% These 2 lines can be dropped in (66) static(Stat, States, Next, StatFormula),%%% absence of static laws (67) bool disj(DynFormula, StatFormula, Formula), (68) #\ Formula #=> EV #= IV. (69) dynamic([], , , [], , ). (70) dynamic([[Act,O P,FE1,FE2,Prec]|Re st],AOccs,State,[Flag|PF1],Now,States) :- (71) member(action(A ct,VA), AOccs), (72) Last is Now-1, %%% Looks for preconditions in FromState and before (73) get precondition var s(Last, Prec, States, ListPV), (74) length(Prec, NPrec), (75) sum(ListPV, SumPrec), (76) %%% The effect is in the next state (Now=Last+1) (77) rel parsing(FE1, Val1, Now, States), (78) rel parsing(FE2, Val2, Now, States), (79) exp constraint(Val1, OP, Val2, C), (80) (VA #/\ (SumPrec #= NPrec)) #<=> Flag, (81) Flag #=> C, (82) dynamic(Rest, ActionOccs, State, PF1, Now, States). (83) rel parsing(Num, Num, , ) :- (84) integer(Num), !. (85) rel parsing(rei(RC), Val, Time, States) :- (86) RC =.. [OP,E1,E2], (87) rel parsing(E1, Val1, Time, States), (88) rel parsing(E2, Val2, Time, States), (89) exp constraint(Val1, OP, Val2, Val), !. (90) rel parsing(abs(FE), Val, Time, States) :- %%% similar for -(FE) (91) rel parsing(FE, Val1, Time, States), (92) Val #= abs(Val1), !. (93) rel parsing(FE, Val, Time, States) :- (94) FE =.. [OP,FE1,FE2], (95) member(OP, [+,-,mod,/, * ]), (96) rel parsing(FE1, Val1, Time, States), (97) rel parsing(FE2, Val2, Time, States), (98) ( OP = + -> Val #= Val1 + Val2; (99) OP = - -> Val #= Val1 - Val2; (100) OP = * -> Val #= Val1 * Val2; (101) OP = / -> Val #= Val1 / Val2; (102) OP = mod -> Val #= Val1 mod Val2 ), !. (103) rel parsing(FluentˆD elta, Val, Time, States) :- (104) H is Time+Delta, (105) length(States,N ), (106) in interval(H,N,E), (107) state select(E, States, State), (108) member(fluent(F luent,Val),State), !. (109) rel parsing(Fluent @ Time, Val, , States) :- (110) state select(Time,Stat es,State), (111) member(fluent(F luent,Val),State), !. (112) rel parsing(Fluent, Val, Time, States) :- (113) state select(Time, States, State), (114) member(fluent(F luent,Val), State). (115) parsing(Fluent, Val, State) :- (116) rel parsing(Fluent, Val, 0, [State]). (117) exp constraint(L, OP, R, C) :- (118) (OP == eq -> C #<=> L #= R; (119) OP == neq -> C #<=> L #\= R; (120) OP == geq -> C #<=> L #>= R; (121) OP == leq -> C #<=> L #=< R; (122) OP == gt -> C #<=> L #> R; (123) OP == lt -> C #<=> L #< R). Fig. 11. Rele vant parts of the B M V implementatio n. 42 A. Dovier , A. F ormisano, E. P on telli internal expression. The argum ent Time r epresents the specific point in time in wh ich a fluent is referred to (cf., the variable Now used in lines ( 69)–(82) and (124)–(13 4 ) to specify the p recise po int in time in which a fluent expr ession/constraint has to be ev alu ated). The predicate in interval called in line (106) sets E = H if 0 ≤ H ≤ N , E = 0 (resp ., E = N ) if H < 0 (r esp., H > N ) . Sim ilarly , p redicate exp constraint (lines (11 7)–(123)) transform s fluent constraints into the corresp onding constraints on the fl uent variables. The above described frag ment of imp lementation is comp leted with the c ode need ed to handle initial and goal state specificatio ns. Na mely , fo r a specific instance of a plann ing problem hD , O i , as d one for B , all constraint on the in itial state (resp. , those on the goal state) ar e reflected by co nstraining the variables F f in the repr esentation of the initial (resp. , final) state. W e proceed b y splitting the correctness pro of into s teps. W e can no w state the follo win g result. 11 Theor em 12 The con crete implemen tation (partially de picted in Fi gure 1 1) is correc t and co mplete w .r .t. the system of constraints of Figure 8. Pr oof This r esult immediately follows fro m the above argumen t. In fact, the constraint (11) of Figure 8 is implicitly ren dered by d omain assignment f or CLP variables. Con straints (13) and ( 14) are dea lt with in lines (57)–(6 4). Line (68) imposes constrain t (15). Con cerning the sequen tiality of the plan an d the executability conditions (i.e., constrain t (12)), we can observe that the implemen tation does n ot differ from tha t of B (in Figure 11 we om itted the correspon ding code , see Figure 7). (124) static([], , , []). (125) static([[OP,FE1 ,FE2,Cond]|Others] , States, Now, [Flag|Flags]) :- (126) get precondition var s(Now, Cond, States, List), (127) length(List, NL), (128) sum(List, Result), (129) rel parsing(FE1, Val1, Now, States), (130) rel parsing(FE2, Val2, Now, States), (131) exp constraint(Val1, OP, Val2, C), (132) (Result #= NL) #<=> Flag, (133) Flag #=> C, (134) static(Others, States, Now, Flags). Fig. 12. Static causal laws treatment Let u s now consider the presenc e of static cau sal laws. In F igure 12, we list the pred icate used to add co nstraints for the static causal laws. Notice that th e con crete implementa tion of Fi gure 12 contains a discrepancy with respect to the abstract one of Fi gure 10. In partic- ular , the concrete implementation does not deal with an intermediate state (named v in the abstract implem entation). The fluents of the target state ar e compu ted by exploiting direct relationships with the starting state of the transition. This allo w s u s to i ntrodu ce fewer CLP variables. 11 When establishing complete ness an s oundness results for the concret e implementati on, we assume the same properti es hold for the real implementati on of the CLP(FD) solver at hand (in our case, SICStus Prolog). Multi-valued Action Languages in CL P(FD) 43 In line (65) of Figure 11 the predica te clu ster rules collec ts all the (static) condition s imposed on the flu ents of the clu ster o f FluentName . Th e call to the p redicates st atic (line (66)) collec ts the list of Boolean flags StatFormula which are u sed to model the constraints (1 9) and (20) o f Figure 1 0. In line (67), the disju nction of these flag variables, together with those originating from the dynam ic causal laws (i.e., DynFormula ), is com- puted in Formula , as explained above. For each co ndition implied by a static causal law , th e p redicate static (lines (1 24)– (134)) builds the con straint C th at mu st be imposed to ensure closure. The flag variable Flag in line (13 2) is introduc ed to reflec t the satisfaction of the co nstraint. If Flag is true then the constrain C is asserted (line (133)). All such flags are stored in the list Flags (cf ., the variable StatFormu la ). W e have the following result: Theor em 13 The concrete implemen tation (partially depicted in Figures 11 and 12) is complete w .r .t. the system of constraints of Figures 8 and 10. Pr oof The result d irectly fo llows fro m the above a rgument. Constraint (16) o f Figur e 1 0 is im- plicitly rendered by the do main assignment for the CLP variables (let us rememb er that the intermediate state v is not explicit in the con crete implem entation). Constrain ts (11)–( 15) are dealt with as done in Theorem 12. The cond itions origin ating fr om the static causal laws are dealt with through the predicates cluster rules and stati c . Let us observe that there is a second difference between the concre te implemen tation of Figures 11 and 12 and the abstract one o f Figure 10: no requirem ents f or the unsatisfiability of F orm ( D ) ~ v ,a i are impo sed in correspondence of the st ate transition fro m v i − 1 to v i (for any i ). This allows the generatio n o f state transitions where the target state is potentially not minimally closed . This means that the c oncrete implementation may produce solutions (i.e., plans) that the abstract semantics would forbid because of the non-min imal effects of (clusters of) static causal laws. On the other hand , we r eflect constraints (19) and (20) as described earlier, throug h the p redicates sta tic (listed in Figure 12) an d cluster rules (whose obvious code is omitted). The final step in the design of t he concrete implemen tation is the introdu ction of suitable restrictions on the labelin g phase of the CLP solver . N otice that, if at step i in a trajector y , a con sequence of a dyn amic law inv o lves a fluent f j , fo r j > i , then such a constraint has to be evaluated consider ing as alr eady assessed all the states v h precedin g v i . Hence, the labeling has to proceed “left-to- right” w .r .t. the CLP variables that model the states v 1 , . . . , v i . In o ther words, when search ing for a so lution, the variables repr esenting the state v h have to be labeled befo re th ose represen ting the state v h +1 , for each v h in the trajectory . The implemen tation of this lab eling strategy i s depicted in Figur e 13. Moreover, observe that we impose furth er restriction s (thro ugh the predicate no loop in lines (147)– (155)) to a void l oops in plan s, i.e., to forbid th ose trajectorie s wh ere the same state appears twice. T o complete the implem entation of B M V we need to take care of the cost-based co n- straints, wh ose beh avior relies o n the o ptimization fea tures o ffered b y SICStus’ lab eling predicate: the labeling phase is guided by an objective f unction to be optimized. 44 A. Dovier , A. F ormisano, E. P on telli (135) lm labeling(Actions occ, States) :- (136) lm labeling(Actions occ, States, 1). (137) lm labeling([], , ) :- !. (138) lm labeling([CurrAc t|Actions], States, I) :- (139) lm labeling aux(Cur rAct), (140) no loop(States, I), (141) I1 is I+1, (142) lm labeling(Actions , States, I1). (143) lm labeling aux([]) . (144) lm labeling aux([ac tion( ,A)|R]) :- (145) indomain(A), (146) lm labeling aux(R). (147) no loop(States, A) :- (148) state select(A, States, StateA), (149) no loop(A, States, StateA). (150) no loop(0, , ) :- !. (151) no loop(B, States, StateA) :- (152) B1 is B-1, (153) state select(B1, States, StateB), (154) StateA \== StateB, (155) no loop(B1, States, StateA). Fig. 13. Implementatio n of a leftmost labeling strategy . Constraints o n co sts, as well as ab solute tem poral con straints, ar e ha ndled by asserting suitable CLP constraints on the v ar iables that model fluent v alues. This is realized through the p redicates listed in Figure 14. In particu lar , set cost constraints deals with con - straints on actions/plan s and states. For instance, set statecosts (line 16 7) retrieves all the assertions o f the form cost constraint(st ate(I) OP Num) and im poses the correspo nding constraints. A similar pre dicate set goal (no t repor ted in th e figure) ac- complishes the same fo r th e fin al state on ly . Th e pre dicate se t plancost acts similar ly , using th e predicate mak e one action occurrences ( lines ( 192)–(1 93)) wh ere th e co st for each single action is considered. All the a bsolute temp oral constraints d efined in th e action description are handled by the pred icate set time constra int ( cf., lines (194)–(2 02 )). Also in this case, direct ref- erences to CLP variables im plement the re ferences to fluent expressions in any ab solute point in time. As men tioned, all these co nstraints can be seen as filters u sed to validate each trajec- tory found by the labelin g p hase. T he p lanner d escribed in Figures 1 1 – 13 is completed by adding the co de in Figure 14. Completeness o f the imp lementation of the fu ll B M V immediately follows from the above discussion. 8 Experimental Analysis W e imp lemented CLP-based pro totypes of B and B M V . These have been realized in SIC- Stus Prolog 4, and they have been de velop ed on an AMD Opteron 2.2GHz Linu x m achine. Extensive testing has been perf ormed to validate our CLP-based appro ach. Here we con - centrate on a fe w represen tati ve examples. The sou rce code of the imp lementation s and the examples ca n be foun d at www.dimi.uniud.it /dovier/CLPASP . No particular b uilt-in predicates of SICStus have be en used and ther efore porting to other CLP-b ased Prolog Multi-valued Action Languages in CL P(FD) 45 (156) set cost con straints(States, PlanCost, GOALCOST) :- (157) set goalcost(States, GOALCOST), (158) set plancost(PlanCos t), (159) set statecosts(State s). (160) set plancost(PC) :- (161) findall([OP,Num] ,(cost constraint(C), C =.. [OP,plan,Num]), PlanCosts), (162) set plancost aux(PlanCosts,P C). (163) set plancost aux([], ). (164) set plancost aux([[O P,Num]|PlanCosts], PC) :- (165) add constraint(PC,OP ,Num), (166) set plancost aux(PlanCosts,P C). (167) set statecosts(State s) :- (168) findall([I,OP,N] ,(cost constraint(C), C =.. [OP,state(I),N]), Costs), (169) set statecost aux(Costs,Stat es). (170) set statecost aux([] , ). (171) set statecost aux([[ I,OP,Num]|StateCos ts],States) :- (172) (state cost(FE),!; FE = 1), (173) rel parsing(FE,Val,I ,States), (174) add constraint(Val,O P,Num), (175) set statecost aux(StateCosts ,States). (176) make action occs(N, ActionsOc c, PlanCost, Na) :- (177) setof(A, action(A), La), (178) length(La, Na), (179) make action occurrenc es(N, La, ActionsOcc, PlanCost). (180) make action occurrenc es(1, , [], 0). (181) make action occurrenc es(N, List, [Act|ActionsOcc], Cost) :- (182) N1 is N-1, (183) make action occurrenc es(N1, List, ActionsOcc, Cost1), (184) make one acti on occurrences(Lis t, Act, Cost2), (185) get action l ist(Act, AList), (186) fd only one(AList), (187) Cost #= Cost1+Cost2. (188) make one acti on occurrences([], [], 0). (189) make one acti on occurrences([A| Actions], [action(A,OccA)|OccActs], Cost) :- (190) make one acti on occurrences(Act ions, OccActs, Cost1), (191) fd domain bool(OccA ), (192) (action cost(A,CA),!; CA = 1), %%%Default action cost = 1 (193) Cost #= OccA * CA+Cost1. (194) set time con straints(States) :- (195) findall([FE1,OP ,FE2], (time constraint(C),C =.. [ OP,FE1,FE2]), TimeCs), (196) set time con straints(TimeCs, States). (197) set time con straints([], ). (198) set time con straints([[FE1,OP, FE2]|Rest], Stat es) :- (199) rel parsing(FE1, Val1, , States), (200) rel parsing(FE2, Val2, , States), (201) add constraint(Val1, OP, Val2), (202) set time con straints(Rest, States). (203) add constraint(L, OP, R) :- (204) exp constraint(L, OP, R, 1). Fig. 14. Handling of global constraints and costs. systems is straightfor ward. A porting to B-Prolog has been realized and used to participate in the 2009 ASP Competition. 12 In the rest of this section, we analy ze the perf ormance of the im plementation on a di- verse set o f ben chmarks. For eac h benc hmark, we compar e a natu ral encodin g using th e traditional B langua ge with an encoding using B M V . The pro blems encod ed in B have b een so lved using both the CLP(FD) impleme ntation 12 See the web site http://ww w.cs.kuleuven.b e/ ˜ dtai/events/AS P- co mpetition/Teams/ Bpsolver- CLPFD.shtml 46 A. Dovier , A. F ormisano, E. P on telli and implemen tations obtained by mapp ing the pr oblem to ASP and using different ASP solvers (Smodels, Clasp, and Cmo dels with dif ferent SA T -solvers). In order to so lve a B -p lanning problem hD , Oi using an ASP solver , we have developed a Pro log translator th at takes as input hD , O i and the plan len gth n , and it generates an ASP p rogram , wh ose stab le models ar e in one -to-one cor respond ence with the plans o f length n f or hD , O i . Th is encod ing follows the gene ral ideas outlin ed in (Lifsch itz 1999). In particular, the definitions of flu ent , action , and initially are alread y in ASP syntax. The leng th of the plan n is u sed to d efine the predicate time(0 ..n) . Th e ASP- based plan ner makes use o f a choice rule to ensure that exactly one action is applied at each time step: 1 { occ(Act,Ti):ac tion(Act) } 1 :- time(Ti), Ti < n . The predicate hold(F luent,Time) defines the tru th value of a fluent Fl uent at a given time step ( Time ). The tr uth value of the fluen ts at time 0 are g i ven as facts descr ibing the initial state; we requir e the initial state to be complete. The executability rules, the dynamic causal laws and th e static c ausal laws are instantiated fo r each ad missible time step. Finally , the goal cond itions are added to d efine the predica te go al ; th e requ irement that the goal has to be satisfied at the end of the plan is imposed using an ASP constraint of the form :- not goal . As f ar as the CLP-based implem entations are concerne d, we use a leftmost variable selection strategy . Moreover, we included a loo p co ntrol featur e to avoid the r epetition of the same state in a trajectory (cf., the predicate no loop in Figu re 13). T ables 1 – 5, discussed in d etail in the next subsections, illustrate an excerp t of the ex- perimental results. I n ord er to simplify the c omparison amon g th e solvers, in each table we in troduce an extra colum n, den oted by “Best ASP , ” which indica tes the per formanc e of an hypoth etical ASP-solver that always acts as the best be tween all the ASP-solvers considered . The specific meaning of the various colum ns is as follo ws: • Instance : the name of the specific instance of the problem • Length : the plan length used in searching for a solution • Answer : indicatio n of whether an answer e xists or not for the gi ven plan length • lparse : the time req uired to g round the ASP en coding of the pro blem ( using lparse 1.1.1) • Smodels : the execution time using the Smodels system (using Smod els 2.32) • Cmodels : the execution time using the Cmod els system (using Cmo dels 3 .70 with different SA T solvers) • Clasp : the execution time using the Clasp system (usin g Clasp 1.0.2) • Best ASP : a summary of the best execution t ime across all the different AS P solvers • CLP(FD) : the execution time using the CLP(FD)-based implementatio n of B . Exe- cution tim es have the form t 1 + t 2 , wh ere t 1 is the t ime need ed for p osting co nstraints and t 2 the time for solving the constraints (i.e., finding a plan) • B M V : the ex ecution time using the B M V encodin g o f the problem. The first column is r elated to computatio ns where no con straints for the plan cost are im posed. In - stead, the co mputation s of the second colum n have a co nstraint th at limits the plan Multi-valued Action Languages in CL P(FD) 47 cost to the number in parenthesis. The format is t 1 + t 2 as explained in the previous point. In the re maining subsections we briefly descr ibe the ben chmark s tested an d the ob tained results. Th e actu al encod ing in B and B M V have be en p laced in the Appen dix for the sake of r eadability . A summ ary and a discussion of all the experimen ts is presented in Section 8.6. 8.1 Three-barrel Problem W e experimented with different encod ings of the three-barrel problem. Our formulation is as described in Example 1. Figure 1 and Section A.1 show the encodin g of the pro blem (for N = 12 ) in B and in B M V , respectiv ely . Notice that, in or der to represent each multi- valued fluen t f of the B M V formu lation, a number o f Boolean flu ents have to be introdu ced in the B enco ding, one for each admissible v a lue of f . T able 1 provides the execution times (in seconds) for dif ferent v alu es of N and different plan lengths. The results show that the co nstraint-based encoding of B outperforms th e ASP encod ings (if we con sider both gro unding and execution). In turn, th e B M V encod- ing outperf orms all other en codings. This can be explain ed by co nsidering that the CLP encodin g of this prob lem benefits fro m num erical fluents (in r educed num ber, w .r .t. the B formu lation) and from arithmetic constraints (efficiently handled by C LP(FD)). 8.2 2-Dimensional Protein F olding Prob lem The problem we have encod ed is a simplification of the protein structur e folding problem. The input is a chain α 1 α 2 · · · α n with α i ∈ { 0 , 1 } , initially placed in a v ertical position, as in Figur e 1 5-left. W e will refer to each α i as an amino acid . The permissible action s are the coun ter-clockwise/clockwise pivo t moves . Once one po int i of the chain i s s elected, the points α 1 , α 2 , . . . , α i will remain fixed, while the po ints α i +1 , . . . , α n will perform a rigid counter-clockwise/clock wise rotation. Eac h confo rmation must be a self-a voiding- walk , i.e., no two amino acids are in the same p osition. Moreover, the chain cann ot be broken — i.e., two consecu ti ve am ino acid s are always at po ints at distance 1 (i.e., in co ntact). The goal is to perfo rm a sequen ce of piv o t moves lead ing to a c onfiguratio n wh ere at least k non-co nsecutive amino acid s of value 1 a re in c ontact. Figure 1 5 shows a p ossible p lan to reach a config uration with 4 contacts. T ab le 2 repo rts so me execution times. Section A.2 reports th e B M V action descrip tion encodin g this p roblem. Since the goal is based on th e notion of cost of a g iv en state, f or which reified co nstraints ar e used extensively , a dire ct encodin g in B d oes not seem to be feasible. Let us consider the re solution of the in stance dep icted in Figu re 1 5, i.e. , the fold ing of the inpu t chain 10 01001 001 of n = 1 0 amin o acids. Ask ing fo r a plan of 8 ( resp. 10 ) moves and for a so lution with cost > 4 , our plann er finds the 8- moves plan shown in Figure 1 5- center in 50 .46s ( a 1 0-moves plan in found in 60 3.37s). By r emoving the two constrain ts that keep fixed α 2 : always(x(2) eq 10). always(y(2) eq 11). 48 A. Dovier , A. F ormisano, E. P on telli Barrels’ B B M V capacities Length Answer lparse Smodels Cmodels Clasp Best CLP(FD) unconstrained constrained plan cost zchaf f relsat minisat ASP plan cost (in parenthese s) 8-5-3 6 N 8.74 0.10 0 .34 0.63 0.30 0.27 0.10 0.14+0.29 0.03+0.03 (70) 0.02+0.03 8-5-3 7 Y 8.92 0.20 1 .87 2.39 0.55 0.23 0.20 0.22+0.28 0.03+0.02 (70) 0.02+0.02 8-5-3 8 Y 8.87 0.20 7 .34 3.63 0.62 0.53 0.20 0.26+1.04 0.05+0.07 (70) 0.01+0.06 8-5-3 9 Y 9.03 0.17 17.60 5.02 0.60 2.34 0.17 0.24+1.03 0.02+0.05 (70) 0.02 +0.06 12-7-5 10 N 34.47 1.98 153.36 14.56 41.34 29.13 1.98 0.58+4.85 0.04+0.13 (120) 0.04+0.13 12-7-5 11 Y 34.54 2.28 9 8.72 1 5.78 11.71 52.15 2.28 0.64+2.61 0.02+0.07 (120) 0.03+0.07 12-7-5 12 Y 35.42 1.60 125.84 20.45 83.06 35.81 1.60 0.73+8.11 0.07+0.18 (120) 0.05+0.19 12-7-5 13 Y 35.69 0.68 342.40 42.36 97.99 111.36 0.68 0.79+6.23 0.07+0.14 (120) 0.07+0.14 16-9-7 14 N 115.47 11.15 1508.43 613.42 75.67 1838.39 11.15 1.30+27 .16 0.03+0.31 (200) 0.07+0.31 16-9-7 15 Y 114.03 12.30 586.43 58.45 65.19 1133.21 12.30 1.53+13.35 0.06+0.13 (200) 0.07+0.14 16-9-7 16 Y 115.60 6.06 793.00 151.56 157.38 744.60 6.06 1.62+37.69 0.07+0.37 (200) 0.07+0.36 16-9-7 17 Y 114.60 1.75 2963.37 128.91 145.11 1410 6.98 1.75 1.67+26.98 0.07+0.27 (200) 0.07+0.27 20-11-9 18 N 185.38 43.71 2949.10 2312.09 493.98 – 43.71 2.76+102.14 0.09+0.58 (300) 0.08+0.57 20-11-9 19 Y 186.76 40.08 3053.53 1187.10 1152.27 11292.40 40.08 2.94+45.43 0.09+0.24 (300) 0.10+0.24 20-11-9 20 Y 186.31 21.67 1866.28 2265.05 1378.93 12286.98 21.67 3.05+12 0.90 0.09+0.68 (300) 0.09+0.65 20-11-9 21 Y 189.28 4.39 5482.78 586.18 1746 .81 – 4.39 3.17+80.54 0.10+0.4 6 (300) 0.10+0.43 T able 1. Expe rimental results with v ar ious instances of the three-barrel problem (timeout 24000sec). Multi-valued Action Languages in CL P(FD) 49 10 10 19 ✉ r r ✉ r r ✉ r r ✉ pivot(2,clock) pivot(3,clock) pivot(9,clock) pivot(8,clock) pivot(7,antick) pivot(6,clock) pivot(4,antick) pivot(5,clock) 1(001) 3 -4 10 10 ✉ r r ✉ r r ✉ r r ✉ Fig. 15 . An in stance of the HP-protein fold ing pro blem: initial configur ation, a plan , an d final configuratio n w ith 4 contacts between 1-amino acids. Instance Len. Ans. B F D M V 1 7 -2 3 Y 0.07+0.01 1 7 -2 4 Y 0.09+0.01 1 13 -6 3 N 0.42+19.91 1 13 -6 4 Y 0.57+35.16 1(001) 2 -2 3 N 0 .06+0.09 1(001) 2 -2 4 Y 0 .07+0.01 1(001) 3 -4 7 N 0.47+7521 .13 1(001) 3 -4 8 Y 0 .49+50.46 1(001) 3 -4 9 ? – 1(001) 3 -4 10 Y 0.63+603.37 T able 2. The HP-pro tein fo lding problem : some results for d ifferent sequen ces, and plan lengths (timeout 12000sec). the solutions are found in 52.72 s and 617.68s, respectiv ely . On the oth er hand, by keeping fixed α 2 and adding the two constraints holds(x(3) eq 11,1). holds(y(3) eq 11,1). the execution time is reduced to 4.06s and 52.97 s. Adding the additional constraints holds(x(4) eq 11,2). holds(y(4) eq 10,2). the plans are fou nd in only 0 .37s and 4 .62s. This shows that the use of multi-v alued flue nts and the ability to exp loit d omain-spec ific knowledge, in the form of symmetry -break ing constraints, allows B M V to effecti vely conv erge to a solu tion. 8.3 The Community Problem The Community pro blem is f ormulated as follows. There a re M individuals, identified by the n umbers 1 , 2 , . . . , M . At each time step, one o f th em, say j , gives exactly j dollars to some one else, provid ed she/he owns mo re tha n j dollar s. Nobo dy can give away all of 50 A. Dovier , A. F ormisano, E. P on telli her/his mon ey . Th e goa l con sists of r eaching a state in which all the par ticipants h av e the same amount of money . T able 3 lists som e r esults for four variants of the p roblem: the person i initially owns 2 ∗ i do llars (instances A M ), i + 1 dollars (instances B M ), i ∗ i do llars (instances C M ), or i ∗ (1 + i ) dollars (instances D M ). The representations of this problem are reported in Sections A.3.1 and A.3.2. Notice th at the large num ber of Boo lean fluents that have to b e intro duced in the B de- scription causes failures du e to lack o f memo ry du ring th e grou nding p hase ( these instances are marked “mem” in T able 3). For all these e xperimen ts, the bound on memory usage was 4 GB (for the grounde r , the ASP-solvers, and the CLP(FD) engine). Observe th at, in some cases, also the CLP(FD)-based solver for B ru ns out of memory , while the failure s o f the CLP(FD) solver f or B M V have be en caused by expiration of the time limit. I n summary , the constraint-b ased encodin gs p rovides better p erforma nce in mo st of the in stances, es- pecially considering their b etter scalability w .r .t. the size of the instances. This origin ates from the smaller n umber of numerical fluen ts and from the ef ficiency o f the under lying constraint solver . Room 5 Room 6 Room 8 Room 7 Room 2 Room 1 Room 11 Room 9 Room 4 Room 10 Room 3 Instance Length Answer B M V A 1 6 N 0 . 07 + 13 . 48 A 1 7 Y 0 . 10 + 5 . 35 B 1 10 N 0 . 17 + 3846 . 20 B 1 11 Y 0 . 14 + 1802 . 76 B 1 12 Y 0 . 15 + 933 . 35 B 1 13 Y 0 . 16 + 302 . 34 B 1 14 Y 0 . 14 + 4 . 60 B 2 10 N 0 . 13 + 11134 . 82 B 2 11 Y 0 . 15 + 4191 . 20 B 2 12 Y 0 . 16 + 2156 . 52 B 2 13 Y 0 . 18 + 710 . 53 B 2 14 Y 0 . 17 + 6 . 36 B 3 10 N 0 . 12 + 18763 . 27 B 3 11 Y 0 . 16 + 6124 . 91 B 3 12 Y 0 . 15 + 3148 . 43 B 3 13 Y 0 . 20 + 1145 . 04 B 3 14 Y 0 . 18 + 9 . 97 B 4 10 N 0 . 11 + 17109 . 05 B 4 11 Y 0 . 15 + 6173 . 49 B 4 12 Y 0 . 14 + 3180 . 53 B 4 13 Y 0 . 16 + 1159 . 27 B 4 14 Y 0 . 18 + 10 . 34 Fig. 16. On the lef t: a simple schema of th e 11 ro oms for the Ga s-diffusion problem. The locked gates are in red color . The gas (in pink ) is flowing through the open gate (in green ), from Room 7 to Roo m 1 . On the right: some re sults f or different instances (i.e ., different goals and initial allocations of amounts of gas—see Section 8.4). Multi-valued Action Languages in CL P(FD) 51 B B M V Instance Length Answer lparse Smo dels Cmodels Clasp Best CLP(FD) CLP(FD) zchaf f relsat minisat ASP A 4 5 N 34.34 11.12 1.78 11.68 0.67 0.45 0.45 0.71+ 14.14 0.01+3.31 A 4 6 Y 34.90 1.43 0.26 7.38 0.57 0.09 0.09 0.82 +0.10 0.03+0.00 A 4 7 Y 35.44 15.72 0.39 47.74 0.80 0.10 0.10 0.94+0 .12 0.03+0.01 A 5 5 N 201.88 100.58 5.22 125.63 2.30 1.19 1.19 2.64+157.48 0.02+41.15 A 5 6 Y 202.64 11.43 1.85 442.22 1.63 0.28 0.28 3.17+0 .21 0.01+0.04 A 5 7 Y 202.12 34.02 2.81 114.74 2.31 0.27 0.27 3.71+447.87 0.04+142.27 B 5 5 N 51.87 30.04 4.24 44.49 1.49 0.69 0.69 1.03+ 77.06 0.03+23.13 B 5 6 Y 52.04 2.07 1.32 37.96 0.99 0.14 0.14 1.31+0.11 0.04+0.02 B 5 7 Y 52.94 13.49 0.80 41.86 1.27 0.42 0.42 1.40+0 .17 0.05+0.04 B 7 5 N mem 7.67+3345 .56 0.05+142 1.54 C 5 5 N mem 16.98+85.71 0.02+49.83 C 5 6 N mem 20.44+192 6.97 0.04+888 .30 C 7 5 N mem mem 0.05+318 6.34 D 4 5 N 138.91 7.08 1.28 13.48 0.76 0.43 0.43 3.70+21 .19 0.01+6.83 D 4 6 N 139.88 90.32 11.56 87.11 3.62 3.72 3.72 4.32+0.50 0.02+0.74 D 4 7 N 139.82 1 015.44 104.36 788.94 33.70 22.86 22.86 5.17+5.55 0.04+7.64 D 5 5 N mem 24.64+24.12 0.05+93.88 D 5 6 N mem 29.60+149 0.48 0.02+18 01.78 T able 3. Ex perimental results fo r instanc es of th e Com munity p roblem. “mem ” denotes o ut-of- memory failures. Some re sults are missing f or the ASP solvers, for those instances that are unable to complete grounding . 52 A. Dovier , A. F ormisano, E. P on telli 8.4 The Gas-diffusion Problem The Gas-diffusion pr oblem can b e formu lated as fo llows. A building contain s a number of rooms. Each r oom is co nnected to ( some) other rooms v ia gates. In itially , all gates are closed a nd some of the rooms con tain a quantity of gas—while the other rooms a re empty . Each gate can be o pened or closed— open(x ,y) a nd close( x,y) are the o nly possible action s, provide d that there is a gate betwe en roo m x a nd ro om y . When a gate between two roo ms is o pen, th e gas co ntained in these ro oms flows thro ugh the gate. The gas dif f usion continues until the pressure reaches an equilibrium. The only condition to be always satisfied is that a gate in a room can be opene d o nly if a ll the other gates are closed. The goal is to move a desired qu antity of gas to one s pecified room. W e experimented with instances of the problem where the building has a specific topol- ogy: there are elev en roo ms, all having the same physical volume. Each room is connected to the other room s via gates as depic ted in Figu re 1 6. Since all room s have the same vol- ume, when equilibriu m is reached between two rooms sh aring an open gate, they will both contain the same amount of gas. A B M V specification o f th is planning prob lem is gi ven in Section A.6. W e experimented with different instances of the Gas-diffusion problem o btained by c onsidering d ifferent goal states and by requ iring that some of the rooms have to be kept emp ty . Mo reover , we seek plans of different length. Figure 16 (on the righ t) summarizes the results obtained . In particular, all instance s shar e the same initial state: r ooms 1 0 an d 3 con tain 1 28 m oles of gas. All the other rooms are empty . Moreover , • in the instance A 1 the goal state is: roo m 1 contains at least 32 mo les of gas; • in all the instances B i the go al is: room 1 co ntains at least 50 m oles of g as. The B i instances differ in the con straints imposed on the desired plan: — in th e in stance B 1 , rooms 7, 9 , and 4 must remain empty . Th is co ndition can be imposed by including in the action description the constraints always(contai ns(7) eq 0). always(contai ns(9) eq 0). always(contai ns(4) eq 0). — in the instance B 2 , rooms 7, 8, and 5 must be kept empty . — in the instance B 3 , only room 6 must be kept empty . — in the instance B 4 , no constraint is imposed. Observe that it is q uite natural to design a B M V encodin g of this pr oblem, by exploiting the m ulti-valued flu ents. On th e other hand, adop ting the nai ve appro ach used for th e three- barrel p roblem would fo rce the intro duction of (at least) 128 distinct bo olean fluents fo r each mu lti-valued fluent. Such a large numb er of boolean fluents generates a la rge state space, making the task of any s olver for B consider ably harder . 8.5 Other Puzzles W e rep ort results from two other p lanning problem s. The first—3x3-puz zle—is an encod - ing of the 8 -tile puzzle pro blem, where the g oal is to find a seq uence of m oves t o re-o rder Multi-valued Action Languages in CL P(FD) 53 the 8 tiles, starting fro m a ran dom initial position . The perfo rmance results for this puz zle are reporte d in T able 4. The second pr oblem is the well-k nown W olf-g oat-cab bage prob- lem. The performan ce results are reported in T able 5. Notice that these p lanning pro blems are predom inantly Boolea n. The co nstraint-based encodin gs perfo rm well in solvin g th e instances of the W olf- goat-cabb age problem. I n contrast, fo r th e 8- tile puzz le pro blem, the use of num erical fluents allows us to achieve a compact encodin g, but it do es not necessarily lead to a better performance w .r .t. ASP . 8.6 A Summary of the Experiments T able 6 pictorially summariz es some of the results relating the perfo rmance of the different approa ches. For e ach prob lem instance , w e comp are the execution times obtained by th e best ASP-so lver and the CLP(FD) solvers for B and B M V action description langu ages. W e considered only those instances for which at least one of the solvers gave an answer . A score o f 1 ( 0 , − 1 ) is assigned to the fastest (seco nd fastest, slowest) solver . Th e score s of all instance s of a p roblem have been su mmed tog ether, and this p rovides the ra dius of the circles in the fig ure. In stances hav e been separated be tween “Y es” in stances (they admit a solution) and “No” instances (they ha ve no solutions). The success of the constraint-ba sed appro ach is evident. Ho wev er , it is interesting to observe that the planning pro blems th at do not m ake significa nt use of non-boo lean flu - ents tend to p erform better in the ASP-based implementations—po ssibly d ue to the greater efficiency of ASP solvers in pr opagatin g boolean knowledge dur ing search for a solution. Con versely , when nu merical q uantities are r elev an t in mod eling a plan ning p roblem, th e use of multi-valued fluen ts an d co nstraints n ot on ly red uces the m odeling e ffort, yieldin g more concise formalizatio ns, but also requires a smaller num ber of fluents (compared with the analogou s B oolean en coding ). This, comb ined with the use of con straints, often trans- lates in to a smaller state space to be explo red in findin g a solution. These seem to be the main reasons for the better behavior provide d by the B M V approa ch. The distinction between “Y es” and “No” instances is also v ery relev a nt. The C LP-based solvers ten d to perform better o n the “Y es” instances, especially for large instances. I t is interesting to o bserve th at a similar beha v ior ha s been o bserved in recent stud ies compar ing perfor mance of ASP an d CLP solution s to combina torial pro blems (Dovier et al. 2005; Dovier et al. 2007; Dovier et al. 2009 a). 9 Related work The literature o n p lanning and p lanning dom ain d escription lan guages is extensive, and it would b e imp ossible to summarize it all in this co ntext. W e focus ou r discussion and compariso n to the papers that present langu ages and techn iques similar to ours. The language in vestigated in this work is a v ar iant o f the language B origina lly in- troduced in (Gelfo nd and Lifschitz 1998), as pr esented in ( Son et al. 2001, Sect. 2) . Apart from minor syntactical differences, any actio n d escription D from the langu age of (So n et al. 2001) can be embedd ed in our B . The semantics for B p resented here r eprodu ces th e o ne of (Gelfon d and Lifschitz 19 98). The lan guage AD C has been intro duced in (Baral et al. 20 02) to m odel plann ing pro b- 54 A. Dovier , A. F ormisano, E. P on telli B B M V Instance Length Answer lparse Smodels Cmodels Clasp B est CLP(FD) CLP(FD) zchaf f relsat minisat ASP I 1 9 N 41.49 0.94 2.06 3.36 1.54 0.52 0.52 0.64+4.42 0.25+2.64 I 1 10 Y 41.80 2.02 2.52 7.36 2.06 0.70 0.70 0.73+5.43 0.29+3.64 I 2 14 N 42.68 27.10 34.46 90.07 7.15 7.42 7.15 1.03 +57.54 0.40+38.67 I 2 15 Y 43.14 50.73 49.50 131.38 8.90 1.98 1.98 1.06+7.08 0.43+4.60 I 3 19 N 43.76 739.39 1255.46 911.82 91.75 268.69 91.75 1.39+967.26 0.54+673.66 I 3 20 Y 44.52 368.28 1090.66 1445.78 58.89 268.59 58.89 1.46+597.92 0.52+435.96 I 4 24 N 51.59 10247.47 – 5613.98 7862.10 4185.42 4185 .42 1.70+13887 .17 0.71+101 09.58 I 4 25 Y 55.54 1430.43 954.68 1023.22 437.11 875.16 437.11 1.84 +79.20 0.73+57.00 I 5 24 N 49.64 6936.39 – 6041.87 1239.72 4901.13 1239.72 1.69+11092.48 0.73+9155.79 I 5 25 N 51.07 14079.78 3747.96 8583.44 11745 .93 8557.94 3747.96 1.84+18301 .15 0.73+141 95.54 T able 4. Expe rimental results for instances of the 8-tile puzzle problem (timeout 36000 sec). Multi-valued Action Languages in CL P(FD) 55 B B M V Length Answer lparse Smodels Cmodels Clasp Best CLP(FD) CLP(FD) zchaff relsat minisat ASP 21 N 0.10 0.19 1.38 1.89 0.67 0.19 0.19 0.10+0.20 0.09+0.15 22 N 0.10 0.25 1.46 3.32 0.77 0.56 0.25 0.09+0.21 0.11+0.17 23 Y 0.10 0.26 2.30 4.34 0.58 0.13 0.13 0.12+0.17 0.07+0.15 24 N 0.11 0.43 3.10 4.75 0.67 1.09 0.43 0.07+0.32 0.06+0.25 25 Y 0.12 0.27 1.15 4.92 0.74 0.42 0.27 0.12+0.06 0.08+0.08 26 N 0.12 0.68 7.23 11.52 1.18 0.69 0.68 0.10+0.49 0.10+0.40 27 Y 0.13 0.43 1.93 6.68 0.93 0.84 0.43 0.10+0.03 0.06+0.03 28 N 0.14 1.24 9.44 18.72 1.59 2.15 1.24 0.10+0.80 0.08+0.69 29 Y 0.14 0.41 1.75 15.55 1.10 0.60 0.41 0.11+0.01 0.07+0.03 30 N 0.15 2.97 16.17 43.53 2.31 1.78 1.78 0.11+1.08 0.08+1.05 31 Y 0.15 0.49 8.40 7.10 0.89 4.60 0.49 0.12+0.01 0.11+0.04 32 N 0.16 2.78 23.76 38.58 2.20 5.37 2.20 0.13+1.35 0.09+1.32 33 Y 0.16 1.06 31.92 26.67 1.23 0.57 0.57 0.10+0.07 0.14+0.06 34 N 0.17 3.61 38.62 51.22 3.11 5.86 3.11 0.13+1.75 0.10+1.60 35 Y 0.18 1.39 31.10 30.25 3.20 4.21 1.39 0.15+0.54 0.08+0.32 36 N 0.18 4.55 43.97 57.21 4.24 12.68 4.24 0.13+1.87 0.11+1.79 T able 5. Expe rimental results for instanc es of the W olf- goat-cab bage prob lem. lems in presence of actions w ith dura tion and d elayed effects. Th e langua ge relies o n m ulti- valued fluents, akin to those used in our languag e. ADC action s ha ve tw o types of effects: 1. Direct modification of fluent values, described by dynamic causal la ws of the forms a causes f = g ( f , f 1 , . . . , f n , t ) from t 1 to t 2 (24) a cont rib utes g ( f , f 1 , . . . , f n , t ) to f from t 1 to t 2 (25) The first axiom d escribes the value o f the fluent f as a function, that modifies its value over the period of time from t 1 to t 2 —these represent time units relative to the current point in time. Th e seco nd axiom is similar, except that it den otes the quantity that sho uld be add ed to the value o f f over the period of time. These axioms are importan t when describing actions who se ef fe ct has a known duration ov er time (i.e., the interval of length t 2 − t 1 ). 2. Indirec t m odifications thro ugh the initiation an d termin ation of p r ocesses , that can modify fluents until exp licitly stopped; th e axio ms inv o lved are axiom s for the cre- ation and terminatio n of pro cesses: a 1 initiates p from t 1 (26) a 2 terminates p at t 2 (27) and axioms that describe how processes modify fluents p is associated with f = g ( f , f 1 , . . . , f n , t ) (28) p is associated with f ← g ( f , f 1 , . . . , f n , t ) (29) The first axio m describe s how the value of the fluent f will chang e as a functio n of time once a p rocess is started; the second ax iom determin es h ow the value of f changes while the process p is active. 56 A. Dovier , A. F ormisano, E. P on telli Three-barrel Community Goat&C. T i le-puzzle B - B E S T - A S P B - C L P ( F D ) B M V - C L P ( F D ) B - B E S T - A S P B - C L P ( F D ) B M V - C L P ( F D ) B - B E S T - A S P B - C L P ( F D ) B M V - C L P ( F D ) “No” instances “Y es” instances All instanc es T able 6. Relative perfo rmance of the solvers for each set of instances (the rad ii of the circles are propor tional to the perfo rmance of the specific solver). ADC has so me similarities to B M V ; they both allow multi-valued flu ents and some f orms of tem poral ref erences. B M V has the flexibility of allowing no n-Markovian behavior and it allo ws referen ces to v a lues of fluents at different time points, features t hat are missing in ADC . On the other hand , AD C allows th e r epresentation o f co ntinuou s time and the ability to describe continuou s changes to the value of fluents. Sev eral features of ADC can b e reaso nably simu lated in B M V ; we will f ocus o n th e axioms of type (26)–(29), since these subsume the capabilities of axioms (24) and (25): • we can represen t each process p u sing a correspon ding fluent; • the axioms (26) and (27) can be simulated by causes ( a 1 , p t 1 − 1 = 1 , true ) causes ( a 2 , p t 2 − 1 = 0 , tru e ) • the axiom (28) can be simulated by introduc ing the static causal law caused ( p > 0 , f = g ( f − 1 , f − 1 1 , . . . , f − 1 n , p − 1 ) ∧ p = p − 1 + 1) Note that, due to the inability of B M V to handle continu ous time, we are considering only discrete time measures. The languag e C + propo sed in (Giunchiglia et al. 2004a) also has some similarities to the languag e B M V . C + does not offer capabilities for non-Markovian and tempo ral refer ences, but sup ports mu lti-valued fluents. T he syntax o f C + builds o n a language of fluent constan ts (each with an associated domain) and action names (viewed as Boolean variables): Multi-valued Action Languages in CL P(FD) 57 • Static causal laws caused F if G where F an d G are flu ent form ulae ( i.e., propo sitional co mbination s of atom s of the form f = v for f fluent and v ∈ do m( f ) ). Th e lan guage introdu ces sy ntactic restrictions that are e ffecti vely eq uiv alen t to pr ev enting cyclic dep endenc ies among fluents. Static causal laws describe depend encies betwee n flu ents with in a state of the world. • Fluent dynamic laws caused F if G a fter H where F and G ar e fluent formu lae and H is a form ula that may also contain action variables. T he semantics of dynamic la ws can be summarized as follows: if H h olds in a state, then the implication G → F shou ld hold in the successi ve state. • Actions that can be freely generated are declared to be exogenou s exogenous a • Fluents can be declared to be inertial (i.e., they satisfy the frame axiom) inertial f The relationships between the two languages can be summarized as follows : • C + is r estricted to non-cyclic depen dencies among fluen ts, while B M V lifts th is r e- striction. • C + is capable of iden tifying fluents as iner tial or non -inertial, while B M V focuses only on inertial fluents (thou gh it is relati vely simple to introdu ce an ad ditional type of constraint to create non -inertial fluents). • C + can describe dom ains wh ere concurr ent actions are allowed—by a llowing occur- rences of different action variables in th e H compon ent of the fluent dy namic laws; although B M V does not currently supports this featur e, a similar extension has been in vestigated in a recent paper (Dovier et al. 2009b). Subsets of B M V and C + can be sho wn to have the same expr essi ve power; in particu - lar , let us consid er th e sub set of C + that co ntains only domains tha t meet the f ollowing requirem ents: • there are no concu rrent actions—i.e., each H contains exactly one occ urrence of an action variable; thus caused F if G a fter a ∧ H where H is a fluent for mula; • for each action a , there is a declaration exogenous a. Under these restrictions, it is po ssible to map a C + domain D to an equiv a lent do main in B M V . In particular: • for each non- inertial fluent f , with default value v , we intro duce the static law caused ( f − 1 6 = v , f 0 = v ) 58 A. Dovier , A. F ormisano, E. P on telli • for each static causal law caused F if G we introd uce a causal law caused ( G, F ) • for each fluent dyn amic law r of the form caused F if G after a ∧ H , we in troduce the following axioms (where exec r is a f resh fluent): causes ( a, exec r = 1 , H ) causes ( a, exec r 1 = 0 , H ) caused ( exec r = 1 ∧ G, F ) Logic programmin g, a nd more specifically Prolog, has been also used to implement the first p rototyp e of GOLOG (as discussed in (Levesque et al. 199 7)). GOLOG is a p ro- grammin g lan guage fo r de scribing ag ents and their capabilities of chan ging the state o f the world. Th e langu age builds on the found ations o f situation calculus. It provides hig h lev el con structs for the d efinition of co mplex actions and fo r the intr oduction o f contr ol knowledge in the ag ent specification . Prolog is employed to create an inte rpreter, w hich enables, for example, to answer p rojection queries (i.e., determ ine the properties that ho ld in a situation after the execution of a seq uence of actions). The go als of GOLOG an d the use of logic progra mming in that work are radically different from the focu s of our work. The work by (Thielscher 2002a) takes a different p erspective in using constraint pro- grammin g to h andle p roblems in r easoning about actions and ch ange. Thielscher’ s work builds on the use of Fluent Calculus (Thielscher 1999) for the represen tation of actions and their effects. Flue nt calculu s views states as sets of flu ents, con structed u sing an op- erator ◦ , an d with the ability to encode p artially sp ecified sets (e.g., f 1 ◦ f 2 ◦ Z wher e Z represents the “rest” of the state). I n (Thielscher 2002a), an encod ing of the flue nt calcu- lus a xioms u sing Con straint Hand ling Rules (CHRs) is presen ted; th e e ncoding uses lists to re present states, and it employs CHRs to explicitly imp lement the operations on lists required to operate on states—e.g. , truth o r falsity of a fluent, validation of d isjunctions of fluents. The ability to code o pen lists enab les reason ing with incomplete knowledge. Experime ntal results (rep orted in (Thielscher 2002b)) denote a good perfo rmance with re- spect to GO LOG. Th e fr amew ork is very suitab le fo r dealing with incomple te knowledge and sen sing action s. D ifferently fro m our framework, it does not supp ort n on-Mar kovian reasoning , multi-valued reasoning , and it d oes n ot b ring the expr essi veness of co nstraint progr amming to the level o f the action specification language. Th e use of constrain ts in the two ap proach es is rad ically d ifferent—Thielscher’ s work develops new con straint so lvers to implement reasoning about states, while we use existing s olvers as black boxes. A stro ng piece of work r egarding the use of co nstraint pr ogramm ing in plan ning is (V idal and Geffner 200 6). The au thors use constraint progr amming, based on the CLAI RE lang uage ( Caseau et al. 2002), to encod e tem poral plann ing pr oblems and to search f or minimal plans. They also use a se- ries o f inte resting heu ristics fo r solv ing that problem. This lin e o f r esearch is more accurate than ours from the imp lementation point of view—although their heur istic strategies can be implemented in our sy stem and it would be interesting to exploit them during the label- ing phase. O n the o ther h and, the proposal b y V idal and Geffner o nly d eals with Boolean fluents and without explicitly defined s tatic causal laws. Similar co nsideration s can be d one with respect to the cited proposal b y Lopez an d Bacchus (Lopez and Bacchus 2003). The autho rs start fr om Graphplan and exploit con- straints to encod e k -plan prob lems. Fluents are i n this case only Boo lean (n ot multi-valued) Multi-valued Action Languages in CL P(FD) 59 and the process is de terministic o nce a n action is ch osen ( instead, we deal also with non- determinism, e.g., when we ha ve conseque nces such as f > 5 ) . Th e prop osal o f L opez and Bacchus does not address the encoding of static causal laws. 10 Conclusions and Future W ork In this p aper, we investi gated the app lication of co nstraint log ic pro grammin g techn ology to the pro blem of reason ing about actions an d ch ange and plann ing. In par ticular , we pre- sented a m odeling of the a ction lang uage B u sing c onstraints, developed an imp lementation using CLP(FD), and reported on its perfor mance. W e also presented th e actio n lang uage B M V , which allows the use of multi-v alued flue nts and th e use of constraints as conditions and con sequences of actions. Once ag ain, the use of con straints is instrum ental in mak ing these extensions possible. W e illustrated the app lication of both B and B M V to several planning problems. Both language s have been implem ented using SICStus Prolog . W e consider the research and the results discussed in this paper as a preliminary step in a very pro mising d irection. The experim ental results, as well as the elegance of the en codings of complex problems, shows th e prom ise o f constraint-b ased techno logy to address the needs of complex p lanning d omains. A nu mber o f re search d irections are curren tly being pursued : • we have intro duced th e use o f global constraints to encode different form s o f pref- erences (e.g., action costs) and control knowledge. Global constraints ha ve been widely used in constraint progr amming to enh ance e fficienc y , by providing more effecti ve constrain t propagation s between sets of variables; we believe a similar use of global constrain ts can b e introduce d in th e context of plannin g—e.g., th e use o f technique s used to efficiently handle the alldifferen t globa l con straint to enfo rce non-r epetition of states in a trajectory . • W e a lso believe that significan t improvements in e fficienc y can be a chieved by del- egating p arts of the c onstraint solvin g p rocess to an e fficient dedica ted solver ( e.g., encoded using a constrain t platfor m such as GECODE, possibly enhan ced with l ocal search moves). • The encoding in CLP(FD) allo w us to think of extensions in se veral directions, such as th e enco ding o f q ualitativ e and quantitative preferences ( a prelim inary stud y h as been presente d in (T u et a l. 2007)), and the use o f constraints to repre sent incom plete states—e.g., to de termine most gen eral condition s for the existence of a plan and to support confo rmant plannin g (Son et al. 2007). • An interesting line o f research is represen ted by the application of th e approach discussed here to multi-agent systems. In that case, besides admitting the execu- tion of mo re that one ac tion in each state transition (cf., Remark 1), other im por- tant issues have to be ad dressed, since different ag ents may comp ete o r collab orate in order to reach the desired resu lts. For instance, concurre ncy of actions m ay b e subject to c onstraints to model incom patibilities o r interde pendenc ies amo ng the oc- currenc es/effects of different action s executed by d ifferent agents ( ev en in d ifferent points in time). Hence, the action description language, as well as its CLP encoding , has to be suitably enriched in order to deal with these aspects. A first step in this direction has been presented in (Dovier et al. 2009b). 60 A. Dovier , A. F ormisano, E. P on telli Ackno wledgments The au thors would like to th ank th e fo llowing researchers fo r th eir h elp, co mments, an d suggestions: Son Cao T ran, Michael Gelfond , and the anonymous revie wers of ICLP 2007 and TPLP . The research h as been p artially supported by NSF Gra nts IIS-081 2267 , HRD-0 42040 7, and CNS-0220 590, by the FIRB grant RBNE0 3B8KK, and by GNCS— Gruppo Nazionale per il Calcolo Scientifico (p roject T ec niche inn ovative per la pr ogrammazione con vincoli in applicazion i strate giche ). References A P T , K . R . 2003. P rinciples of constra int pr ogramming . Cambridge Univ ersity P ress. B A R A L , C . 2 003. Knowledg e r epre sentation, r easoning and d eclarative prob lem solving . Cambridge Univ ersity Pr ess. B A R A L , C . , S O N , T. , A N D T U A N L - C . A transition f unction based characterization of actions with delayed and continuous effects. Principles and Practice of Knowledge Repr esentation and Reasoning , Morgan Kaufman n, pp. 291–302 , 2002. C A S E AU , Y . , J O S S E T , F - X . , A N D L A B U RT H E F. CLAIRE: combining sets, search and rules to better express algorithms. T heory and Practice of Lo gic Pr ogramming , 2(6):769 –805, 2002. D O V I E R , A . , F O R M I S A N O , A . , A N D P O N T E L L I , E . 2005. A comparison of CLP(F D) and ASP solutions to NP-complete problems. In Pr oc. of ICL P 2008 , M. Gabbrielli and G. Gupta, Eds. Lecture Notes in Computer Science, vol. 3668 . Springer V erlag, 67–82. D O V I E R , A . , F O R M I S A N O , A . , A N D P O N T E L L I , E . 2007. An experimental comparison of constraint logic programming and answer set programming. In Proce edings of the T wenty-Second A AAI Confer ence on Artificial Intelligence . AAAI Press, V ancouver , Br itish Columbia, Canada, 1622– 1625. D O V I E R , A . , F O R M I S A N O , A . , A N D P O N T E L L I , E . 2009a. An empirical study of CLP and ASP solutions of combinatorial problems. Jo urnal of Experimental & Theor etical Artificial Intelli- gence 21, 2 (Jun.), 79–12 1. D O V I E R , A ., F O R M I S A N O , A ., A N D P O N T E L L I , E . 2009b . Representing multi-agent planning in CLP. In Logic Pr ogr amming and Non-mo notonic Reaso ning, 10th Intern ational Confer ence , LPNMR 2009, P otsdam, Germany , September 14-18, 2009, Pro ceedings , E. Erdem, F . Li n, and T . Schaub, Eds. Lecture Notes in Computer Science, vol. 5753. Springer , 423–429. E I T E R , T., F A B E R , W., L E O N E , N ., P F E I F E R , G . , A N D P O L L E R E S , A . 2004. A logic program- ming approach to knowledge-state planning: Semantics and complexity . ACM T ransactions on Computational Logic 5, 2 (Apr .), 206–26 3. G A BA L D O N , A . 2 002. Non-Mark ovian control in t he situation calculus. In Pro ceedings of the Eighteenth Nati onal Confer ence o n Artificial Intelligence , R. Dechter, M. Kea rns, and R. S. Sutton, Eds. American Association for Artifi cial Intelligence, AAAI P ress, Menlo Park, California, 519– 524. G E B S E R , M ., K AU F M A N N , B . , N E U M A N N , A ., A N D S C H AU B , T. 2007. Clasp: A conflict-driv en answer set solver . In Logic Pro gramming and Non-Monotonic R easoning , C. Baral, G. Brewka, and J. S. Schlipf, Eds., Springer V erlag, 260–2 65. G E L F O N D , M . A N D L I F S C H I T Z , V . 1998. Action languages. E lectr onic T ransactions on Artificial Intelligence 2 , 193–21 0. G I U N C H I G L I A , E . , L E E , J . , L I F S C H I T Z , V ., M C C A I N , N . , AN D T U R N E R , H . 2004. Non-monotonic causal theories. Artificial Intelligence 153, (1–2), 49–104. G I U N C H I G L I A , E ., L I E R L E R , Y . , A N D M A R AT E A , M . 2004. SA T-based answer set programming. In AAAI-04 , D. L. McGuinness and G. Ferguson, Eds. The MIT Press, 61–6 6. Multi-valued Action Languages in CL P(FD) 61 H O FF M A N N , M . J ., P O RT E O U S , J ., A N D S E B A S T I A , L . 2004 . Ordered landmarks i n planning. Jour - nal of Artificial Intelligence Resear ch , 22:215–27 8. J A FF A R , J . and M A H E R , M . 1994. Constraint logic programming: a survey . Jo urnal of Logic Pro- gramming , 19/20:503–581. L E E , J . A N D L I F S C H I T Z , V . 2003. Describing additive fluents in action language C+. In IJCAI-03, Pr oceedings of the Eighteenth International J oint Confer ence on Artificial Intelligence , Acapulco, Mexico, Au gust 9-15, 2003 , G. Gottlob and T . W alsh, Eds. Morg an Kaufmann, 1079–10 84. L E V E S QU E , H . J . , P I R R I , F., A N D R E I T E R , R . 1997. GOLOG: a logic programming language for dynamic domains. Jo urnal of Logic Pr ogramming , 31(1–3):59 –83. L E V E S QU E , H . J ., P I R R I , F. , A N D R E I T E R , R . 1998. Founda tions for t he situation calculus. Elec- tr onic Tr ansactions on Artificial Intelligence 2 , 159–178 . L I F S C H I T Z , V . 1999. Answer set planning. In Pr oc. of the 1 6th Intl. Confer ence on Logic Pr ogra m- ming , D. de Schreye, Ed. MIT Press, 23–37 . L I N , F. A N D Z H A O , Y . 2004. ASSA T: C omputing answer sets of a logic program by SA T solvers. Artificial Intelligence 157, 1–2, 115– 137. L O P E Z , A . A N D B A C C H U S , F. 20 03. Generalizing Graphplan by formulating plann ing as a CSP. In IJCAI-03, Pr oceedings of the Eighteenth International Joint Confer ence on Artificial Intellig ence , Acapulco, Mexico, August 9-15, 20 03 , G. Gottlob and T . W alsh, Eds. M organ Kaufmann, 954–960. M A R R I O T T , K . A N D S T U C K E Y , P. J . 1998. Pro gramming with constra ints . The MIT Press. M C C A RT H Y , J . 1998. El ephant 2 000 - A program ming language based on speech ac ts. A vailable in www.formal.st anford.edu/jmc . R E I T E R , R . 2001. Knowledge in action: logical foundations for describing and i mplementing dy- namical systems . MIT Press, Bradford Books, Cambridge, MA. S I M O N S , P . 2000. Extending and implementing t he stable model semantics. P h.D. thesis, Helsi nki Univ ersity of T echnology. S O N , T. C ., B A R A L , C ., A N D M C I L R A I T H , S . A . 2001. Planning with different forms of domain- dependen t control k no wl edge - An answer set programmin g appro ach. In Lo gic Pr ogr amming and Non-monotonic Reaso ning, 6th Interna tional Confer ence, LPNMR 2001, V ienna, Austria, Septem- ber 17-19, 2001, Pr oceeding s , T . Eiter, W . Faber, and M. Truszc zy ´ nski, Eds. Lecture Notes in Computer Science, vol. 217 3. Springer, 226–239. S O N , T. C ., T U , P . H . , A N D B A R A L , C . 2007. Reasoning and planning w ith sensing actions, i n- complete information, and static causal laws usin g answer set p rogramming. Theory and Practice of Logic Pr ogramming 7, 4, 37 7–450. T H I E L S C H E R , M . 1999. F rom s ituation calculus to fluent c alculus: state update axioms a s a solution to the inferential frame problem. In Artificial Intelligence , 111(1–2 ):277–299 . T H I E L S C H E R , M . 2002a. Reasoning abou t actions with CHRs and finite domain constraints. Lecture Notes in Computer Science 2401 , 70–84. T H I E L S C H E R , M . 2002b . Pushing the en velope: prog ramming reasoning agents. In AAAI W orkshop on Cognitive Robotics , AAAI Press. T U , P . H . , S O N , T. C . , A N D P O N T E L L I , E . 2007. CPP: A constraint logic programming based planner with preferences. In Logic Pro gramming and Non-monotonic Reasoning, 9th International Confer ence, LPNMR 2007, T empe, AZ, USA, May 15-17, 20 07, Pr oceedings , C. Baral, G. Brewka, and J. S. Schlipf, Eds. Lecture Notes in Computer Science, vol. 44 83. Springer , 290–296. V I DA L , V . , and G E FF N E R , G . 2006. Branching and pruning: an optimal t emporal P OCL planner based in constraint programming. Artificial Intelligence 170:298– 335. 62 A. Dovier , A. F ormisano, E. P on telli Ap pendix A Some of the codes of the Experimental Section A.1 The Three-Barrel Problem: B M V description of the 12-7- 5 barrels prob lem The B M V encodin g of the three bar rels plannin g problem for N = 12 . (Figu re 1 pr esents an encoding using the language B .) barrel(5). barrel(7). barrel(12). fluent(cont(B),0 ,B) :- barrel(B). action(fill(X,Y) ) :- barrel(X), barrel(Y), neq(X,Y). causes(fill(X,Y) , cont(X) eq 0, [Y-cont(Y) geq cont(X)]) :- action(fill(X,Y) ). causes(fill(X,Y) , cont(Y) eq cont(Y)ˆ(-1)+cont(X)ˆ(-1), [Y-cont(Y) geq cont(X)]) :- action(fill(X,Y) ). causes(fill(X,Y) , cont(Y) eq Y, [Y-cont(Y) lt cont(X)]) :- action(fill(X,Y) ). causes(fill(X,Y) , cont(X) eq cont(X)ˆ(-1)-Y+cont(Y)ˆ(-1), [Y-cont(Y) lt cont(X)]) :- action(fill(X,Y) ). executable(fill( X,Y), [cont(X) gt 0, cont(Y) lt Y]) :- action(fill(X,Y) ). caused([], cont(12) eq 12-cont(5)-cont( 7)). initially(cont(1 2) eq 12). goal(cont(12) eq cont(7)). Multi-valued Action Languages in CL P(FD) 63 A.2 The HP Protein F olding Prob lem B M V encodin g of the HP-p rotein fo lding pr oblem with piv ot moves on input of the form 10010 0100 1. . . startin g from a vertical s traight line. length(10). amino(A) :- length(N), interval(A,1,N). direction(clock) . direction(antick ). fluent(x(A),1,M) :- length(N), M is 2 * N, amino(A). fluent(y(A),1,M) :- length(N), M is 2 * N, amino(A). fluent(type(A),0 ,1) :- amino(A). fluent(saw,0,1). action(pivot(A,D )) :- length(N), amino(A), 1 A. causes(pivot(A,c lock), y(B) eq y(A)ˆ(-1)+x(A)ˆ(-1)-x(B) ˆ(-1), [ ]) :- action(pivot(A,c lock)), a mino(B), B > A. causes(pivot(A,a ntick), x(B) eq x(A)ˆ(-1)-y(B)ˆ(-1)+y(A )ˆ(-1), []) :- action(pivot(A,a ntick)), amino(B), B > A. causes(pivot(A,a ntick), y(B) eq y(A)ˆ(-1)-x(A)ˆ(-1)+x(B )ˆ(-1), []) :- action(pivot(A,a ntick)), amino(B), B > A. caused([x(A) eq x(B), y(A) eq y(B)], saw eq 0) :- amino(A), amino(B), A < B. initially(saw eq 1). initially(x(A) eq N) :- length(N), amino(A). initially(y(A) eq Y) :- length(N), amino(A), Y is N+A-1. initially(type(X ) eq 1) :- amino(X), X mod 3 =:= 1. initially(type(X ) eq 0) :- amino(X), X mod 3 = \ = 1. goal(saw gt 0). state cost(FE) :- length(N), auxc(1,4,N,FE). auxc(I,J,N,0) :- I > N-3,!. auxc(I,J,N,FE) :- J > N, !, I1 is I+1, J1 is I1+3, auxc(I1,J1,N,FE). auxc(I,J,N,FE1+t ype(I) * type(J) * rei(abs(x(I)-x(J ))+abs(y(I)-y(J)) eq 1)) :- J1 is J+2, auxc(I,J1,N,FE1). always(x(1) eq 10). always(y(1) eq 10). always(x(2) eq 10). always(y(2) eq 11). cost constraint(goal geq 4). 64 A. Dovier , A. F ormisano, E. P on telli A.3 The Community Problem A.3.1 B d escription of the instance A 4 max people(4). person(X) :- max people(N), interval(X,1,N). money(X) :- max people(N), M is N * (N+1), interval(X,1,M). fluent(owns(B,M) ) :- person(B), money(M). action(gives(X,Y )) :- person(X), person(Y), neq(X,Y). executable(gives (X,Y), [owns(X,Mx)]) :- action(gives(X,Y )), fluent(owns(X,Mx )), Mx > X. causes(gives(X,Y ), owns(X,NewMx), [owns(X,Mx)]) :- action(gives(X,Y )), money(Mx), fluent(owns(X,Ne wMx)), fluent(owns(X,Mx)), NewMx is Mx-X. causes(gives(X,Y ), owns(Y,NewMy), [owns(Y,My)]) :- action(gives(X,Y )), money(My), fluent(owns(Y,Ne wMy)), fluent(owns(Y,My)), NewMy is My+X. caused([owns(X,M x)], neg(owns(X,Other))) :- fluent(owns(X,Mx )), fluent(owns(X,Other)), person(X), money(Mx), money(Other), neq(Mx,Other). initially(owns(X ,M)) :- person(X), M is 2 * X. goal(owns(X,Mid) ) :- person(X), max people(N), Mid is (N * (N+1))//N. A.3.2 B M V description of the instance A 4 max people(4). person(X) :- max people(N), interval(X,1, N). fluent(owns(B),1 ,M) :- person(B), max people(N), M is N * (N+1). action(gives(X,Y )) :- person(X), person(Y), neq(X,Y). executable(gives (X,Y), [owns(X) gt X]) :- action(gives(X,Y )). causes(gives(X,Y ), owns(X) eq owns(X)ˆ(-1)-X, []) :- action(gives(X,Y )). causes(gives(X,Y ), owns(Y) eq owns(Y)ˆ(-1)+X, []) :- action(gives(X,Y )). initially(owns(X ) eq M) :- person(X), M is 2 * X. goal(owns(X) eq Mid) :- person(X), max people(N), Mid is (N * (N+1))//N. Multi-valued Action Languages in CL P(FD) 65 A.4 The 8-T ile Puzzle Problem A.4.1 B description of the instance I 1 cell(X) :- interval(X,1, 9). val(X) :- interval(X,1,9 ), neq(X,3). near(1,2). near(1,4). near(2,1). near(2,3). near(2,5). near(3,2). near(3,6). near(4,1). near(4,5). near(4,7). near(5,2). near(5,4). near(5,6). near(5,8). near(6,3). near(6,5). near(6,9). near(7,4). near(7,8). near(8,5). near(8,7). near(8,9). near(9,6). near(9,8). fluent(at(X,Y)) :- val(X), cell(Y). fluent(free(Y)) :- cell(Y). action(move(X,Y) ) :- val(X), cell(Y). executable(move( X,Y), [at(X,Z), free(Y)]) :- val(X), cell(Y), cell(Z), near(Z,Y). causes(move(X,Y) , at(X,Y), []) :- val(X), cell(Y). causes(move(X,Y) , free(Z), [at(X,Z)]) :- val(X), cell(Y), cell(Z). caused([at(X,Y)] , neg(free(Y))) :- val(X), cell(Y). caused([at(X,Y)] , neg(at(X,Z))) :- val(X), cell(Y), cell(Z), neq(Y,Z). caused([at(X,Y)] , neg(at(W,Y))) :- val(X), val(W), cell(Y), neq(X,W). initially(at(1,1 )). initially(at(2,3)). initially(at(4,8)). initially(at(5,2 )). initially(at(6,9)). initially(at(7,4)). initially(at(8,6 )). initially(at(9,7)). initially(free(5)). initially(neg(at (1,X))) :- cell(X), neq(X,1). initially(neg(at (2,X))) :- cell(X), neq(X,3). initially(neg(at (4,X))) :- cell(X), neq(X,8). initially(neg(at (5,X))) :- cell(X), neq(X,2). initially(neg(at (6,X))) :- cell(X), neq(X,9). initially(neg(at (7,X))) :- cell(X), neq(X,4). initially(neg(at (8,X))) :- cell(X), neq(X,6). initially(neg(at (9,X))) :- cell(X), neq(X,7). initially(neg(fr ee(X))) :- cell(X), neq(X,5). goal(at(X,X)) :- val(X). goal(free(3)). 66 A. Dovier , A. F ormisano, E. P on telli A.4.2 B M V description of the instance I 1 cell(X) :- interval(X,1, 9). tile(X) :- interval(X,1, 9), neq(X,3). near(1,2). near(1,4). ...%as for B ... near(9,6). near(9,8). fluent(at(X),1,9 ) :- tile(X). fluent(free,1,9) . action(move(X,Y) ) :- cell(Y), tile(X). executable(move( X,Y), [at(X) eq Z, free eq Y]) :- tile(X), cell(Y), near(Z,Y). causes(move(X,Y) , at(X) eq Y, []) :- tile(X), cell(Y). causes(move(X,Y) , free eq at(X)ˆ(-1), []) :- tile(X), cell(Y). initially(at(1) eq 1). initially(at(2) eq 3). initially(at(4) eq 8). initially(at(5) eq 2). initially(at(6) eq 9). initially(at(7) eq 4). initially(at(8) eq 6). initially(at(9) eq 7). initially(free eq 5). goal(at(X) eq X) :- tile(X). goal(free eq 3). Multi-valued Action Languages in CL P(FD) 67 A.5 The W olf-Goat- Cabbage Problem A.5.1 B d escription of the W olf-g oat-cab bage pr oble m obj(goat). obj(cabbage). obj(wolf). obj(man). side(left). side(right). pos(X) :- side(X). pos(boat). fluent(is in(X,Y)) :- obj(X), pos(Y). fluent(boat at(Y)) :- side(Y). fluent(alive). action(sail(A,B) ) :- side(A), side(B), neq(A,B). action(go aboard(A)) :- obj(A). action(get off(A)) :- obj(A). executable(sail( A,B), [boat at(A), is in(man,boat)]) :- side(A), side(B), neq(A,B). executable(go aboard(A), [boat at(L), is in(A ,L)]) :- obj(A), side(L). executable(get off(A), [is in(A ,boat)]) :- obj(A). causes(sail(A,B) , boat at(B), []) :- side(A), side(B), neq(A,B). causes(go aboard(A), is in(A,boat) , []) :- obj(A). causes(get off(A), is in(A, L), [boat at(L)]) :- obj(A), side(L). caused([is in(Ogg,L1)], neg(is in(Ogg,L2)) ) :- obj(Ogg), pos(L1), pos(L2), neq(L1,L2). caused([boat at(L1)], neg(boat at(L2))) :- side(L1), side(L2), neq(L1,L2). caused([is in(A,boat), is in(B,boat )], neg(alive)) :- obj(A), obj(B), diff(A,B,man). caused([is in(wolf,L), is in(goat,L ), neg(is in(man,L))], neg(alive)) :- pos(L). caused([is in(cabbage,L), is in(goa t,L), neg(is in( man,L))], neg(alive)) :- pos(L). initially(is in(A,left)) :- obj(A). initially(alive) . initially(boat at(left)). goal(is in(A,right)) :- obj(A). goal(alive). 68 A. Dovier , A. F ormisano, E. P on telli A.5.2 B M V description of the W o lf-goat-ca bbage p r oblem obj(goat). obj(cabbage). obj(wolf). obj(man). % 0=boat, 1=on-the-left, 2=on-the-right : fluent(is in(X),0,2) :- obj(X). fluent(boat at,1,2). fluent(alive,0,1 ). action(sail). action(go aboard(A)) :- obj(A). action(get off(A)) :- obj(A). executable(sail, [is in(man) eq 0]). executable(go aboard(A), [boat at eq is in(A) ]) :- obj(A). executable(get off(A), [is in(A ) eq 0]) :- obj(A). causes(sail, boat at eq 1, [boat at eq 2]). causes(sail, boat at eq 2, [boat at eq 1]). causes(go aboard(A), is in(A) eq 0, []) :- obj(A). causes(get off(A), is in(A) eq boat atˆ(-1), []) :- obj(A). caused([is in(A) eq 0, is in(B) eq 0], alive eq 0) :- obj(A), obj(B), diff(A,B,man). caused([is in(wolf) eq is in(goat), is in(man) neq is in(wolf)] , alive eq 0). caused([is in(cabbage) eq is in(goa t), is in(man) neq is in(cabbag e)], alive eq 0). initially(is in(A) eq 1) :- obj(A). initially(boat at eq 1). initially(alive eq 1). goal(is in(A) eq 2) :- obj(A). goal(alive eq 1). Multi-valued Action Languages in CL P(FD) 69 A.6 The Gas-diffusion Problem: B M V description of the instance A 4 room(N) :- interval(N,1, 11). gate(1,2). gate(1,7). gate(1,11). gate(2,3). gate(3,4). gate(4,5). gate(5,6). gate(6,7). gate(6,8). gate(8,9). gate(9,10). gate(10,11). fluent(contains( N),0,255) :- room(N). fluent(is open(X,Y),0,1) :- gate(X,Y). action(open(X,Y) ) :- gate(X,Y). action(close(X,Y )) :- gate(X,Y). executable(open( X,Y),L) :- action(open(X,Y) ), findall((is open(X,Z) eq 0), gate(X,Z),L1), findall((is open(Z,X) eq 0), gate(Z,X),L2), findall((is open(Y,Z) eq 0), (gate(Y,Z),neq( Z,X)),L3), findall((is open(Z,Y) eq 0), (gate(Z,Y),neq( Z,X)),L4), append(L1,L2,La) ,append(L3,L4,Lb), append(La,Lb,L). executable(close (X,Y), [is open(X,Y) eq 1]) :- action(close(X,Y )). causes(open(X,Y) , contains(Y) eq (contains(X)ˆ(-1) +contains(Y)ˆ(-1) )/2, []) :- action(open(X,Y) ). causes(open(X,Y) , contains(X) eq (contains(X)ˆ(-1) +contains(Y)ˆ(-1) )/2, []) :- action(open(X,Y) ). causes(open(X,Y) , is open(X,Y) eq 1, []) :- action(open(X,Y) ). causes(close(X,Y ), is open(X,Y) eq 0, []) :- action(close(X,Y )). initially(is open(X,Y) eq 0) :- gate(X,Y). initially(contai ns(10) eq 128). initially(contai ns(3) eq 128). initially(contai ns(A) eq 0) :- room(A), diff(A,3,10). goal(contains(1) gt 50).

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment