Temporal Logic Programs with Variables
In this note we consider the problem of introducing variables in temporal logic programs under the formalism of Temporal Equilibrium Logic (TEL), an extension of Answer Set Programming (ASP) for dealing with linear-time modal operators. To this aim, we provide a definition of a first-order version of TEL that shares the syntax of first-order Linear-time Temporal Logic (LTL) but has a different semantics, selecting some LTL models we call temporal stable models. Then, we consider a subclass of theories (called splittable temporal logic programs) that are close to usual logic programs but allowing a restricted use of temporal operators. In this setting, we provide a syntactic definition of safe variables that suffices to show the property of domain independence – that is, addition of arbitrary elements in the universe does not vary the set of temporal stable models. Finally, we present a method for computing the derivable facts by constructing a non-temporal logic program with variables that is fed to a standard ASP grounder. The information provided by the grounder is then used to generate a subset of ground temporal rules which is equivalent to (and generally smaller than) the full program instantiation.
Under consideration in Theory and Practice of Logic Programming (TPLP)
F. Aguado, P. Cabalar, M. Diéguez, G. Pérez, C. Vidal]
Felicidad Aguado, Pedro Cabalar, Martín Diéguez, Gilberto Pérez and Concepción Vidal
Dept. of Computer Science
University of Corunna, SPAIN
IRIT - Université Paul Sabatier
Temporal Logic Programs with Variables–LABEL:lastpage \jdateJanuary 2016 2016
rtificial Intelligence; Knowledge Representation; Temporal Logic; Grounding; Logic Programming; Answer Set Programming
Many application domains and example scenarios from Answer Set Programming (ASP) [Niemelä (1999), Marek and Truszczyński (1999)] contain a dynamic component, frequently representing transition systems over discrete time. In an attempt to provide a full logical framework for temporal reasoning in ASP, [Aguado et al. (2008)] proposed a formalism called Temporal Equilibrium Logic (TEL), syntactically identical to propositional Linear-time Temporal Logic (LTL) [Pnueli (1977)], but semantically relying on a temporal extension of Equilibrium Logic [Pearce (1996)], the most general and best studied logical characterisation of stable models [Gelfond and Lifschitz (1988)]. In [Aguado et al. (2011)] a reduction of (propositional) TEL into regular LTL was presented, but applicable to a subclass of temporal theories called splittable Temporal Logic Programs. This syntactic fragment deals with temporal rules in which, informally speaking, “past does not depend on the future,” a restriction general enough to cover most (if not all) existing examples of ASP temporal scenarios. The reduction was implemented in a tool, STeLP111http://kr.irlab.org/stelp_online [Cabalar and Diéguez (2011)], that computes the temporal stable models of a given program, that are shown as a Büchi automaton.
Although the approach in [Aguado et al. (2011)] was exclusively propositional, the input language of STeLP was extended with variables. As in non-temporal ASP, these were just understood as a shortcut for all their possible ground instances. This initial approach was not fully satisfactory for several reasons. First, it forced that any variable instance was not only safe (that is, occurring in the positive body of the rule) but also “typed” by a static predicate, i.e., a predicate whose extent does not vary along time. Second, this restriction implied sometimes the generation of irrelevant ground rules that increased the size of the resulting ground LTL theory while they could be easily detected and removed by a simple analysis of the temporal program. Last, but not least, the treatment of variables had no formal background and had not been proved to be sound with respect to the important property of domain independence [Bria et al. (2008)] – essentially, a program is domain independent when its stable models do not vary under the arbitrary addition of new constants. Although the usual definition of safe variables guarantees domain independence, there was no formal proof for temporal logic programs under TEL.
In this note we provide some results that allow an improved treatment of variables in temporal logic programs, using a first order version of TEL as underlying logical framework. We relax the STeLP definition of safe variable by removing the need for static predicates so that, as in ASP, a variable in a rule is safe when it occurs in the positive body222This definition of safety, initially introduced in DLV [Leone et al. (2006)] has been adopted in the standard ASP-Core-2 [Calimeri et al. (2015)] and also followed by Gringo [Gebser et al. (2011)].. We prove that this simpler safety condition satisfies domain independence. Finally, we describe a method for grounding temporal logic programs under this new safety condition that still allows calling a standard ASP grounder as a backend, but using a positive normal logic program that is generated by a given transformation on the original temporal logic program.
2 A motivating example
Suppose we have a set of cars placed at different cities and, at each transition, we can drive a car from one city to another in a single step, provided that there is a road connecting them.
Figure 1 contains a possible representation of this scenario in the language of STeLP. Operator ‘o’ stands for “next” whereas “::-” corresponds to the standard ASP conditional “:-”, but holding at all time points. Rule (1) is the effect axiom for driving car X to city A. The disjunctive rule (2) is used to generate possible occurrences of actions in a non-deterministic way. Rules (3) and (4) represent the inertia of fluent at(X,A). Finally, rule (5) forbids that a car is at two different cities simultaneously.
As we can see in the first line, predicates city/1, car/1 and road/2 are declared to be static. The scenario would be completed with rules for static predicates. These rules constitute what we call the static program and can only refer to static predicates without temporal operators. An example of a static program for this scenario could be:
road(A,B) :- road(B,A). % roads are bidirectional city(A) :- road(A,B). car(1). car(2). road(lisbon,madrid). road(madrid,paris). road(boston,ny). road(ny,nj).
Additionally, our temporal program would contain rules describing the initial state like, for instance, the pair of facts:
Note that all variables in a rule are always in some atom for a static predicate in the positive body. The current grounding process performed by STeLP just consists in feeding the static program to an ASP grounder (DLV or gringo) and, once it provides an extension for all the static predicates, each temporal rule is instantiated for each possible substitution of variables according to static predicates. In our running example, for instance, the grounder provides a unique model333If the static program yields several stable models, each one generates a different ground theory whose temporal stable models are computed independently. for the static program containing the facts:
car(1), car(2), city(lisbon), city(madrid), city(paris), city(boston), city(ny), city(nj), road(lisbon,madrid), road(madrid,lisbon), road(madrid,paris), road(paris,madrid), road(boston,ny), road(ny,boston), road(ny,nj), road(nj,ny)
With these data, rule (1) generates 12 ground instances, since we have two possible cars for X and six possible cities for A. Similarly, rule (4) would generate 60 instances as there are 30 pairs A,B of different cities and two cars for X. Many of these ground rules, however, are irrelevant. Take, for instance:
o at(1,ny) ::- driveto(1,ny). no_at(1,paris) ::- at(1,ny).
corresponding to possible instantiations of (1) and (4), respectively. In both cases, the body refers to a situation where car 1 is located or will drive to New York, while we can observe that it was initially at Madrid and that the European roadmap is disconnected from the American one. Of course, one could additionally encode a static reachability predicate to force that rule instances refer to reachable cities for a given car, but this would not be too transparent or elaboration tolerant.
On the other hand, if we forget, for a moment, the temporal operators and we consider the definition of safe variables used in ASP, one may also wonder whether it is possible to simply require that each variable occurs in the positive body of rules, without needing to refer to static predicates mandatorily. Figure 2 contains a possible variation of the same scenario allowing this possibility. Our goal is allowing this new, more flexible definition of safe variables and exploiting, if possible, the information in the temporal program to reduce the set of generated ground rules.
3 Temporal Quantified Equilibrium Logic
Syntactically, we consider function-free first-order languages built over a set of constant symbols, , and a set of predicate symbols, . Using , connectors and variables, an -formula is defined following the grammar:
where is an atom, is a variable and , and respectively stand for “next”, “always” and “eventually.” A theory is a finite set of formulas. We use the following derived operators:
for any formulas . An atom is any where is a predicate with -arity and each is a term (a constant or a variable) in its turn. We say that a term or a formula is ground if it does not contain variables. An -sentence or closed-formula is a formula without free-variables.
The application of consecutive ’s is denoted as follows: for and . A temporal fact is a construction of the form where is an atom.
Let be a non-empty set (the domain or universe). By we denote the set of ground atomic sentences of the language . We will also define an interpretation of constants in (and domain elements in ) as a mapping
such that for all .
A first-order LTL-interpretation is a structure where and are as above and is an infinite sequence of sets, with . Intuitively, contains those ground atoms that are true at situation . Given two LTL-interpretations and we say that is smaller than , written , when for all . As usual, stands for: and . We define the ground temporal facts associated to as follows: . It is easy to see that iff .
Given as above, we denote by the sequence of sets , where each , i.e., those atoms from that contain terms exclusively formed with universe elements that are images of syntactic constants in .
A temporal-here-and-there -structure with static domains, or a -structure, is a tuple where and are two LTL-interpretations satisfying .
A -structure of the form is said to be total. If is a -structure and any positive integer, we denote by the temporal-here-and-there -structure with and . The satisfaction relation for is defined recursively forcing us to consider formulas from . Formally, if is an -sentence for the atoms in , then:
If , then
iff and .
iff or .
iff or for all
iff for all and for all .
iff for some .
The resulting logic is called Quantified Temporal Here-and-There Logic with static domains, and denoted by or simply by . It is not difficult to see that, if we restrict to total -structures, iff in first-order LTL. Furthermore, the following property can be easily checked by structural induction.
For any formula , if , then:
A theory is a set of -sentences. An interpretation is a model of a theory , written , if it satisfies all the sentences in .
Definition 2 (Temporal Equilibrium Model)
A temporal equilibrium model of a theory is a total model of such that there is no satisfying .
If is a temporal equilibrium model of a theory , we say that the First-Order LTL interpretation is a temporal stable model of . We write to denote the set of temporal stable models of . The set of credulous consequences of a theory , written contains all the temporal facts that occur at some temporal stable model of , that is:
A property of TEL directly inherited from Equilibrium Logic (see Proposition 5 in [Pearce (2006)]) is the following:
Proposition 2 (Cumulativity for negated formulas)
Let be some theory and let be some formula such that for all temporal equilibrium models of . Then, the theories and have the same set of temporal equilibrium models.
In this work, we will further restrict the study to a syntactic subset called splittable temporal formulas (STF) which will be of one of the following types:
where and are conjunctions of atomic formulas, and are conjunctions of , being an atomic formula and and are disjunctions of atomic formulas.
A splittable temporal logic program (STL-program for short) is a finite set of sentences like
where is a splittable temporal formula with free variables.
We will also accept in an STL-program an implication of the form (that is, containing but not any ) understood as an abbreviation of the pair of STL-formulas:
The following theory is an STL-program:
Remember that all rule variables are implicitly universally quantified. For simplicity, we assume that inequality is a predefined predicate.
An STL-program is said to be positive if for all rules (1)-(3), and are empty (an empty conjunction is equivalent to ). An STL-program is said to be normal if it contains no disjunctions, i.e., for all rules (1)-(3), and are atoms.
Given a propositional combination of temporal facts with , we denote as the formula resulting from replacing each temporal fact in by . For a formula like (3), we denote by the corresponding . For instance, . As behaves as a linear operator in THT, in fact is a THT tautology.
Definition 4 (expanded program)
for . We can interpret the expanded program as an infinite, non-temporal program where the signature is the infinite set of atoms .
Theorem 1 (Theorem 1 in [Aguado et al. (2011)])
is a temporal equilibrium model of iff is a stable model of under the (infinite) signature .
Any normal positive STL-program has a unique temporal stable model which coincides with its -least LTL-model. We denote .
4 Safe Variables and Domain Independence
In this section we consider a definition of safe variables for temporal programs that removes the reference to static predicates.
where does not occur in the positive body. Although an unsafe rule does not always lead to lack of domain independence (see examples in [Cabalar et al. (2009)]) it is frequently the case. We prove next that domain independence is, in fact, guaranteed for safe STL-programs.
If is a safe sentence and is a temporal equilibrium model of , then and for any .
Let be a domain and a finite subset; the grounding over of a sentence , denoted by , is defined recursively
|with any binary operator in|
Theorem 3 (Domain independence)
Let be safe splittable temporal sentence. Suppose we expand the language by considering a set of constants . A total -model is a temporal equilibrium model of if and only if it is a temporal equilibrium model of .
5 Derivable ground facts
In this section we present a technique for grounding safe temporal programs based on the construction of a positive normal ASP program with variables. The method is based on the idea of derivable ground temporal facts for an STL-program . This set, call it , will be an upper estimation of the credulous consequences of the program, that is, . Of course, the ideal situation would be that , but the set requires the temporal stable models of and these (apart from being infinite sequences) will not be available at grounding time. In the worst case, we could choose to contain the whole set of possible temporal facts, but this would not provide relevant information to improve grounding. So, we will try to obtain some superset of as small as possible, or if preferred, to obtain the largest set of non-derivable facts we can find. Note that a non-derivable fact satisfies that and so, by Proposition 2, is equivalent to , that is, both theories have the same set of temporal equilibrium models. This information can be used to simplify the ground program either by removing rules or literals.
We begin defining several transformations on STL-programs. For any temporal rule , we define as the set of rules:
In other words, will imply all the original disjuncts in the disjunctive head of . It is interesting to note that for any rule with an empty head () this definition implies . Program is defined as the union of for all rules . As an example, consists of the rules:
whereas would be the program:
Notice that, by definition, is always a positive normal STL-program and, by Proposition 3, it has a unique temporal stable model, .
For any STL-program , .
Unfortunately, using as set of derivable facts is unfeasible, since it contains infinite temporal facts corresponding to an “infinite run” of the transition system described by . Instead, we will adopt a compromise solution taking a superset of extracted from a new theory, . This theory will collapse all the temporal facts from situation on, so that all the states for will be repeated444 Note that rules of the form (1) and (2) are not in the scope of and so may provide an irregular behaviour for atoms at situations and . In a theory only consisting of rules like (3) we could collapse all situations from on since they would follow a regular pattern.. We define as the result of replacing each rule in by the formulas:
and adding the axiom schema:
for any ground atom in the signature of . As we can see, (19) and (20) are the first two instances of the original rule corresponding to situations and . Formula (21), however, differs from the instance we would get for since, rather than having and , we use and respectively. This can be done because axiom (22) is asserting that from situation 2 on all the states are repeated.
In the cars example, for instance, (14) from would yield the three rules:
It is not difficult to see that axiom (22) implies that checking that some is a temporal equilibrium model of is equivalent to checking that is a stable model of and fixing for . This allows us to exclusively focus on the predicate extents in and , so we can see the -free program as a positive normal ASP (i.e., non-temporal) program for the propositional signature that can be directly fed to an ASP grounder, after some simple renaming conventions.
has a least LTL-model, which is a superset of .
In other words , i.e., we can use as set of derivable facts and simplify the ground program accordingly. To this aim, a slight adaptation is further required. Each rule in like (3) has the form and any predicate in is implicitly affected (Theorem 1) by the extension of in . In order to properly ground the extensions for and we replace each by the equivalent conjunction of the three rules , and . For instance, (9) would be replaced by:
and then check the possible extents for the positive bodies we get from the set of derivable facts . For example, for the last rule, we can make substitutions for and using the extents of and we have in . However, this still means making a join operation for both predicates. We can also use the ASP grounder for that purpose by just adding a rule that has as body, the positive body of the original temporal rule , and as head, a new auxiliary predicate referring to all variables in the rule. In the example, for rule (25) we would include in our ASP program:
In this way, each tuple of directly points out the variable substitution to be performed on the temporal rule.
For instance, in the small instance case described of our example ( cars and cities) we reduce the number of generated ground rules in the scope of ‘’ from using the previous STeLP grounding method to . The reader may easily imagine that the higher degree of cities interconnection, the smaller obtained reduction of rule instances. Although an exhaustive experimentation is still ongoing work, a reduction of this kind is very promising. In our initial experiments, the grounding performed on (whose generation is polynomial) does not constitute a significant time increase, whereas the computation of temporal stable models is drastically improved by the reduction of ground rules555The complexity of deciding whether a temporal stable model exists is EXPSPACE-complete in the general case [Bozzelli and Pearce (2015)]..
We have improved the grounding method for temporal logic programs with variables in different ways. First, we provided a safety condition that directly corresponds to extrapolating the usual concept of safe variable in ASP. In this way, any variable occurring in a rule is considered to be safe if it also occurs in the positive body of the rule, regardless the possible scope of temporal operators and removing the previous dependence on the use of static predicates.
We have proved that this safety condition suffices to guarantee the property of domain independence by which computing the (temporal) stable models is insensitive to the possible addition of new arbitrary constants to the universe.
We have also designed a method for grounding the temporal logic program that consists in constructing a non-temporal normal positive program with variables that is fed to an ASP solver to directly obtain the set of variable substitutions to be performed for each rule. The proposed method allows reducing in many cases the number of ground temporal rules generated as a result.
The current note contains formal results, providing the correctness (with respect to domain independence) of the safety condition and the method for grounding safe programs. Regarding implementation, a stand-alone prototype for proving examples like the one in the paper has been constructed, showing promising results. The immediate next step is incorporating the new grounding method inside STeLP and analysing its performance on benchmark scenarios.
This research was partially supported by Spanish MINECO project TIN2013-42149-P and Xunta de Galicia GPC 2013/070.
- Aguado et al. (2008) Aguado, F., Cabalar, P., Pérez, G., and Vidal, C. 2008. Strongly equivalent temporal logic programs. In JELIA’08. Lecture Notes in Computer Science, vol. 5293. Springer, 8–20.
- Aguado et al. (2011) Aguado, F., Cabalar, P., Pérez, G., and Vidal, C. 2011. Loop formulas for splitable temporal logic programs. In LPNMR’11, J. P. Delgrande and W. Faber, Eds. Lecture Notes in Computer Science, vol. 6645. Springer, 80–92.
- Bozzelli and Pearce (2015) Bozzelli, L. and Pearce, D. 2015. On the complexity of temporal equilibrium logic. In Proc. of the 30th Annual ACM/IEEE Symp. on Logic in Computer Science, (LICS’15). IEEE Computer Society, 645–656.
- Bria et al. (2008) Bria, A., Faber, W., and Leone, N. 2008. Normal form nested programs. In Proc. of the 11th European Conference on Logics in Artificial Intelligence (JELIA’08), S. H. et al, Ed. Lecture Notes in Artificial Intelligence. Springer, 76–88.
- Cabalar and Diéguez (2011) Cabalar, P. and Diéguez, M. 2011. STELP - a tool for temporal answer set programming. In LPNMR’11. Lecture Notes in Computer Science, vol. 6645. Springer, 370–375.
- Cabalar et al. (2009) Cabalar, P., Pearce, D., and Valverde, A. 2009. A revised concept of safety for general answer set programs. In Proc. of the 10th Int. Conf. Logic Programming and Nonmonotonic Reasoning (LPNMR’09). Lecture Notes in Computer Science, vol. 5753. Springer, 58–70.
- Calimeri et al. (2015) Calimeri, F., Faber, W., Gebser, M., Ianni, G., Kaminski, R., Krennwallner, T., Leone, N., Ricca, F., and Schaub, T. 2015. ASP-core-2 input language format. https://www.mat.unical.it/aspcomp2013/files/ASP-CORE-2.03c.pdf.
- Gebser et al. (2011) Gebser, M., Kaminski, R., König, A., and Schaub, T. 2011. Advances in gringo series 3. In Proc. of the 11th Intl. Conf. on Logic Programming and Nonmonotonic Reasoning (LPNMR’11), J. P. Delgrande and W. Faber, Eds. Lecture Notes in Computer Science, vol. 6645. Springer, 345–351.
- Gelfond and Lifschitz (1988) Gelfond, M. and Lifschitz, V. 1988. The stable model semantics for logic programming. In Logic Programming: Proc. of the Fifth International Conference and Symposium (Volume 2), R. A. Kowalski and K. A. Bowen, Eds. MIT Press, Cambridge, MA, 1070–1080.
- Leone et al. (2006) Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S., and Scarcello, F. 2006. The dlv system for knowledge representation and reasoning. ACM Transactions on Computational Logic 7, 499–562.
- Marek and Truszczyński (1999) Marek, V. and Truszczyński, M. 1999. Stable models and an alternative logic programming paradigm. Springer-Verlag, 169–181.
- Niemelä (1999) Niemelä, I. 1999. Logic programs with stable model semantics as a constraint programming paradigm. Annals of Mathematics and Artificial Intelligence 25, 241–273.
- Pearce (1996) Pearce, D. 1996. A new logical characterisation of stable models and answer sets. In Non monotonic extensions of logic programming. Proc. NMELP’96. (LNAI 1216). Springer-Verlag.
- Pearce (2006) Pearce, D. 2006. Equilibrium logic. Annals of Mathematics and Artificial Intelligence 47, 1-2, 3–41.
- Pnueli (1977) Pnueli, A. 1977. The temporal logic of programs. In 18th Annual Symposium on Foundations of Computer Science. IEEE Computer Society Press, 46–57.
- van Emden and Kowalski (1976) van Emden, M. H. and Kowalski, R. A. 1976. The semantics of predicate logic as a programming language. Journal of the ACM 23, 733–742.
Proof of Proposition 3. Consider the expanded program . This is an infinitary positive (non-temporal) logic program. Using the well-known results by [van Emden and Kowalski (1976)], we know it has a least Herbrand model call it , which may contain an infinite set of atoms in the signature of ground temporal facts , where is the original signature of . Furthermore, as is positive, its unique stable model is precisely . Given any set of ground temporal facts we can establish a one-to-one correspondence to an LTL-interpretation with . By Theorem 1, is a stable model of iff , with is a temporal stable model of . Finally, as is the unique stable model of we get that is the only temporal stable model of .
A variable assignment in is a mapping from the set of variables to . If has free-variables, is the closed formula obtained by replacing every free variable by .
Let be a splittable temporal formula and a variable assignment in . If is safe, then if follows that:
First of all, take of type (1) and suppose that but . This means that and . Since , there exists an atomic formula in such that but . So we have a variable in with . As is safe, we know that occurs in an atomic formula in . Then and which yields a contradiction.
If is of type (2), we use a similar argument.
Finally, take of type (3) and suppose that but . There exists such that and . We then have that and . Using that is safe and the same argument as above, we find an atomic formula in or such that which implies and leads to contradiction. The other implication follows directly from Proposition 1.
For any safe sentence
Proceed by induction over the length of the prefix. If , we can take any assignment of variables and apply Lemma 1 on . So take of length and suppose that the result is true for any universal safe sentence whose prefix has length at most . If , put with . For any , we know that and we have to show that . The induction hypothesis and the fact that is a safe sentence whose prefix has length smaller or equal than finishes the proof.
First of all, suppose that is of type (1):
and take and such that . This implies that but . is safe so there must be an atom in such that has an occurrence in . Since , it is clear that , so which yields a contradiction.
The proof for the case of being of type (2) and (3) is similar.
Let with a splittable temporal formula and such that has no other free variables than . Let be such that . Then, if is safe, we have that:
From left to right, just note that if but , for some , we would have that which would yield a contradiction.
For right to left, we can proceed by induction in . If , then is in the case of the previous lemma for any , so whenever Now, suppose the result is true for any prenex formula with length up to and take such that It only rests to show that for any . Notice that with Since we can apply the induction hypothesis on , it will be sufficient to prove that:
Now fix any and take into account that
for all , so we can replace by any constant in , including , and so:
Observe that we can apply the induction hypothesis on , where
and then . In particular which completes the proof since .
The following proposition can be easily proved
Given any :
If is a safe splittable temporal sentence and such that , then
From left to right, suppose that . By Proposition 6, we know that . The result follows since and .
Now, from the right to left direction, take a safe splittable temporal sentence and suppose that Again, we can proceed by induction in . If , then is quantifier free so . Suppose the result is true for any safe splittable sentence with length up to and put with Notice that is a safe formula that has no more free variables than , so, if we apply Lemma 3, it will be sufficient to show that . Since we are supposing that
and we can apply the induction hypothesis on any with , it follows that and this completes the proof.
If is a safe splittable temporal sentence, then is a temporal equilibrium model of iff is a temporal equilibrium model of .