Implementing Dynamic Answer Set Programming

02/17/2020 ∙ by Pedro Cabalar, et al. ∙ 5

We introduce an implementation of an extension of Answer Set Programming (ASP) with language constructs from dynamic (and temporal) logic that provides an expressive computational framework for modeling dynamic applications. Starting from logical foundations, provided by dynamic and temporal equilibrium logics over finite linear traces, we develop a translation of dynamic formulas into temporal logic programs. This provides us with a normal form result establishing the strong equivalence of formulas in different logics. Our translation relies on the introduction of auxiliary atoms to guarantee polynomial space complexity and to provide an embedding that is doomed to be impossible over the same language. Finally, the reduction of dynamic formulas to temporal logic programs allows us to extend ASP with both approaches in a uniform way and to implement both extensions via temporal ASP solvers such as telingo



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Humans are not bothered at all when it comes to choosing a way home among a plethora of alternatives. Similarly, in reasoning about action or planning, the underlying specifications admit an abundance of feasible plans. Among them, we usually find only a few reasonable alternatives while the majority bear an increasing number of redundancies, leading to infinite solutions in the worst case. Popular ways to counterbalance this are to extend the specification by objectives, like shortest plans, and/or imposing limits on the plan length. Both are often implemented with optimization procedures and/or incremental reasoning methods (extending insufficient plan lengths). However, computing a valid plan with such techniques usually involves solving numerous sub-problems of nearly the same scale as the actual problem — not to mention that solving somehow optimal plans is often particularly hard (due to phase transition phenomena). This rules out such techniques when it comes to highly demanding dynamic problems, as we witnessed in applications to robotic intra-logistics 


This motivates our approach to pair action theories with control theories in order to restrict our attention to plans selected by the control theory among all feasible ones induced by the action theory. This approach was pioneered by Levesque et al. in [20] by combining action theories in the Situation Calculus with control programs expressed in Golog. The rough idea is that a plan induced by an action theory must be compatible with a run of the associated Golog program. Although Golog’s design was inspired by Dynamic Logic [17], its semantics is given by a reduction to first-order logic. Unlike this, we developed in [3, 6] the foundations of an approach integrating Answer Set Programming (ASP [21]) with (linear) Dynamic Logic. More precisely, we are interested in the combination of the logic of Here-and-There ( [19]) with linear Dynamic Logic over finite traces ( [11]), called Dynamic logic of Here-and-There () and particularly its non-monotonic extension, Dynamic Equilibrium Logic ( [6]). We review both logics in Section 2. ASP as such is known to constitute a fragment of Equilibrium Logic [22].

In what follows, our focus lies on implementing temporal and dynamic ASP via a reduction to regular ASP. This aligns with the above discussion insofar as temporal logic programs, featuring one step operators, are well-suited for providing action theories, while dynamic formulas allow for imposing compatibilities with path expressions, that amount to regular expressions over primitive actions.111Temporal formulas constitute a proper fragment of  (cf. Section 2). To this end, in this paper, we present the following contributions:

  1. we develop a three-valued characterization of ;

  2. we establish a normal form for  showing that dynamic formulas can be reduced to (so-called) temporal logic programs;

  3. we use this reduction to implement a solver accepting dynamic formulas in .

For (i), we extend the three-valued characterization from [16] to dynamic formulas, something that allows for greatly simplifying proofs and has thus benefits well beyond this paper. Also, it is, to the best of our knowledge, the first time this type of construction is used to capture dynamic logics and thus path expressions. This three-valued definition also allows for establishing (ii), which shows that any dynamic formula can be equivalently reduced to a syntactic fragment called temporal logic programs. This translation relies on the introduction of auxiliary atoms (in a Tseitin-style [25]) for, first, guaranteeing that its result is of polynomial size wrt the input formula, and, second, surmounting the fact that translations of dynamic into temporal formulas are usually impossible without extending the language. We explain both issues in more detail in Section 3. Finally, the great benefit of this reduction is that we can use it for (iii), that is, implementing dynamic formulas in , since temporal logic programs can be processed by an existing solver for temporal ASP, viz. telingo [8]. We describe the resulting implementation in Section 4 and show the potential impact of pairing action and control theories via an empirical analysis of an elevator scenario borrowed from [20].

2 Linear Dynamic Equilibrium Logic

We start from the syntax of Linear Dynamic Logic () defined in [11]. Given a set of propositional variables (called alphabet), dynamic formulas and path expressions are mutually defined by the pair of grammar rules:

This syntax is similar to the one of Dynamic Logic ( [17]) but differs in the construction of atomic path expressions: while  uses a different alphabet for atomic actions, in  there is a unique alphabet  (atomic propositions) and the only atomic path expression is the constant (read as “step”) that we also write as (see below), overloading the constant truth symbol. As we show further below, the above language allows us to capture several derived operators, like the Boolean and temporal ones:

All connectives are defined in terms of the dynamic operators and . This involves the Booleans’ , , and , among which the definition of is most noteworthy since it hints at the implicative nature of . Negation is then expressed via implication, as usual in . Then, and also allow defining the future temporal operators , , , , , , , standing for final, next, weak next, eventually, always, until, and release, and their past-oriented counterparts: , , , , , , . The weak one-step operators, and , are of particular interest when dealing with finite traces, since their behavior differs from their genuine counterparts only at the ends of a trace. In fact, can also be expressed as (and as ). A formula is propositional, if all its connectives are Boolean, and temporal, if it includes only Boolean and temporal ones. As usual, a (dynamic) theory is a set of (dynamic) formulas. Following the definition of linear  () in [11], we sometimes use a propositional formula as a path expression actually standing for . This means that the reading of as a path expression amounts to which is just equivalent to , as we see below. Another abbreviation is the sequence of repetitions of some expression defined as and . For instance, which amounts to , as we see below.

Given and , we let stand for the set and for . For the semantics, we start by defining a trace of length over alphabet as a sequence of sets . A trace is infinite if and finite otherwise, that is, for some natural number . Given traces and both of length , we write if for each ; accordingly, iff both and .

Although  shares the same syntax as , its semantics relies on traces whose states are pairs of sets of atoms. A Here-and-There trace (for short -trace) of length over alphabet is a sequence of pairs such that for any . As before, an -trace is infinite if and finite otherwise. The intuition of using these two sets stems from  and Equilibrium Logic: atoms in are those that can be proved; atoms not in are those for which there is no proof; and, finally, atoms in are assumed to hold, but have not been proved. We often represent an -trace as a pair of traces of length where and and . The particular type of -traces that satisfy are called total. Given any -trace , we define  satisfaction of formulas, namely, , in terms of an accessibility relation for path expressions whose extent depends again on by double, structural induction.

Definition 1 ( satisfaction [6])

An -trace of length over alphabet satisfies a dynamic formula at time point , written , if the following conditions hold:

  1. and

  2. if for any atom

  3. if for some with

  4. if for all with
    for both and

where, for any -trace , is a relation on pairs of time points inductively defined as follows.

We see that and quantify over time points that are reachable via path expression from the current point , that is, . An -trace is a model of a dynamic theory if for all . We write to stand for the set of models of length of a theory , and define , that is, the whole set of models of of any length. When we just write and .

A formula is a tautology (or is valid), written , iff for any -trace  and any . We call the logic induced by the set of all tautologies (Linear) Dynamic logic of Here-and-There ( for short). Two formulas are said to be equivalent, written , whenever iff for any -trace and any . This allows us to replace by and vice versa in any context, and is the same as requiring that is a tautology. Note that this relation, , is stronger than coincidence of models, viz. . For instance, because models are checked at the initial situation and there is no previous situation at that point, so . However, in general, since is satisfied for any (for instance but instead). As with formulas, we say that path expressions are equivalent, written , whenever for any -trace .

The following equivalences of path expressions allow us to push the converse operator inside, until it is only applied to .

Proposition 1 ([6])

For all path expressions , and and for all formulas , the following equivalences hold:

We say that is in converse normal form if all occurrences of the converse operator in are applied to .

We now introduce non-monotonicity by selecting a particular set of traces that we call temporal equilibrium models. First, given an arbitrary set of -traces, we define the ones in equilibrium as follows.

Definition 2 (Temporal Equilibrium/Stable models [6])

Let be some set of -traces. A total -trace is an equilibrium trace of iff there is no other such that .

If is such an equilibrium trace, we also say that trace is a stable trace of . We further talk about temporal equilibrium or temporal stable models of a theory when , respectively.

We write and to stand for the temporal equilibrium models of and respectively. Note that stable traces in are also -models of and, thus, is stronger than . Besides, as the ordering relation among traces is only defined for a fixed , it is easy to see the following result:

Proposition 2 ([6])

The set of temporal equilibrium models of can be partitioned by the trace length , that is, .

(Linear) Dynamic Equilibrium Logic () is the non-monotonic logic induced by temporal equilibrium models of dynamic theories. We obtain the variants and by applying the corresponding restriction to infinite or finite traces, respectively.

To illustrate non-monotonicity, take the formula:


whose reading is “keep sending an sos () while no help () is perceived.” Intuitively, behaves as a conditional referring to any future state after repetitions of . Then, checks whether fails one more time at : if so, it makes true again. Without additional information, this formula has a unique temporal stable model per each length satisfying , that is, is never concluded, and so, we repeat all over the trace. Suppose we add now the formula , that is, becomes true after five transitions. Then, there is a unique temporal stable model for each satisfying:

Clearly, is not entailed any more (under temporal equilibrium models) showing that is non-monotonic.

To conclude this section, we provide an alternative three-valued characterization of that is particularly useful for formal elaborations involving auxiliary atoms. This alternative characterization relies on the idea of temporal three-valued interpretation in [4] for the case of and is inspired, in its turn, in the characterization of HT in terms of Gödel’s logic [16]. Under this orientation, we deal with three truth values standing for: (or proved true) meaning satisfaction “here”; (or assumed false) meaning falsity “there”; and (potentially true) that are formulas assumed true but not proved. Given an -trace we define its associated truth valuations as a pair of mutually recursive functions and that assign a truth value in the set to formula at time point or to the pair for path expression , respectively. The valuation of formulas follows the next rules:


whereas the function for path expressions is defined as follows:

This results in the following three-valued characterisation of -traces in . 222An extended version of the paper with the proofs is available at Let be a -trace of length , its associated valuation and :

  1. iff

  2. iff

  3. iff

  4. iff

3 Reduction to temporal logic programs

In this section, we elaborate upon a reduction of arbitrary dynamic formulas333This covers finite dynamic theories, understood as the conjunction of their formulas. into a syntactic subclass called temporal logic programs [9]. A temporal logic program is a conjunction of temporal formulas with a restricted syntax that, when interpreted under temporal stable models, have a close relation to rules from disjunctive logic programming. Temporal logic programs were proved in [9] to constitute a normal form for  (if we allow for auxiliary atoms) and used later on as a basic syntax for the temporal ASP system telingo [8]. We proceed next to describe their syntax.

Given a set of propositional variables , we define the set of temporal literals as A temporal logic program is a set formed by three different types of rules:

  1. an initial rule is of the form

  2. a dynamic rule is of the form

  3. a final rule is of the form

where (with ) and (with ) and and are temporal literals in the case of dynamic rules and regular literals (i.e. ) in the case of initial and final rules. We also allow for global rules of the form that stand for the conjunction of an initial rule and a dynamic rule . [Normal form] Every dynamic formula can be converted into a temporal program being -equivalent to . To prove the above theorem, we provide a sound transformation from any dynamic formula into a temporal logic program . As a first step, we assume that is already in converse normal form: this can be achieved by repeatedly applying the equivalences in Proposition 1. The reduction of into temporal program uses an extended alphabet that additionally contains new atoms (aka label) for formulas over that are either subformulas of or elaborations of them. This set of formulas is called the Fisher-Ladner closure [12] of and formally defined below.

Definition 3 (Fisher-Ladner closure [12])

The Fisher-Ladner closure of a dynamic formula (in converse normal form) is a set of dynamic formulas inductively defined as follows:

  1. implies and ,


  2. If then

  3. If then

  4. If then and

  5. If then and

  6. If then

  7. If then

  8. If then and

  9. If then and

  10. If then

  11. If then

Any set satisfying these conditions is called closed.

Proposition 3

For any dynamic formula , its closure is finite.

Thus, given the dynamic formula on alphabet to be translated, we define the extended alphabet . For convenience, we simply use if is or an atom .

As happened with the normal form reduction for  in [9], the translation is done in two phases: we first obtain a temporal theory containing double implications, and then we unfold them into temporal rules. We start by defining the temporal theory that introduces new labels for each formula . This theory contains the formula and, per each label , a set of formulas fixing the label’s truth value. Formally:

Table 1 shows the definitions for each in the closure depending on the outer modality in the formula.

Table 1: Normal form translation

As an example, take the dynamic formula (which corresponds to the temporal formula ). In the first step, we get


where we just used as its label , and stands for which belongs to . The truth of is determined by which, in the table, is first unfolded into leading to:


with also in . Notice now that contains as a subformula, so it can be written as: . Then just corresponds to the pair of formulas:


and the whole translation amounts to .

As a second example, consider the formula meaning that holds in all even time points (this formula is well-known not to be  representable). The formulas obtained for are:


with and is:


with . Since is actually , we get :


As we have seen, in the general case, formulas in are not temporal rules, since they sometimes contain double implications. However, they all have the forms , , or , for some inner propositional formula formed with temporal literals. For instance, in (2), the inner corresponds to the propositional formula . As first shown in [7] propositional formulas in can be reduced to conjunctions of disjunctive rules. In this way, we can apply transformations (as those in [10]) and THT axioms [1] to eventually obtain a temporal logic program. In the case of (2), the inner double implication is unfolded into three rules that, after applying property , eventually lead to:

Given an -trace , we define its restriction to alphabet as . Similarly, for any set of -traces we write to stand for as expected.

The following lemma shows that and are equivalent:

Lemma 1

Let be a dynamic formula over and let be a model of being associated with the three-valuation .

Then, for any and any , we have .

For any dynamic formula and any length , we have

Corollary 1

Let be a dynamic formula over .

Then, translation is strongly faithful, that is:

for any arbitrary dynamic formula over .

Proposition 4

Translation has a polynomial size with respect to the size of .

4 Extending telingo with dynamic formulas

We have extended the temporal ASP solver telingo444Details on the functioning of telingo are given in [8]; its implementation is available at with dynamic formulas over finite traces. More precisely, the current version supports negated occurrences of dynamic formula, as in integrity constraints; it is available at

To this end, telingo provides (theory) atoms of form ‘&del{}’ that encapsulate arbitrary dynamic formulas . Their syntax is given in Table 2; it is supplied as a theory grammar to the underlying ASP system clingo [13].555Note that # and & indicate basic ASP and customizable theory concepts.