Semantics and Compilation of Answer Set Programming with Generalized Atoms

05/06/2014 ∙ by Mario Alviano, et al. ∙ 0

Answer Set Programming (ASP) is logic programming under the stable model or answer set semantics. During the last decade, this paradigm has seen several extensions by generalizing the notion of atom used in these programs. Among these, there are aggregate atoms, HEX atoms, generalized quantifiers, and abstract constraints. In this paper we refer to these constructs collectively as generalized atoms. The idea common to all of these constructs is that their satisfaction depends on the truth values of a set of (non-generalized) atoms, rather than the truth value of a single (non-generalized) atom. Motivated by several examples, we argue that for some of the more intricate generalized atoms, the previously suggested semantics provide unintuitive results and provide an alternative semantics, which we call supportedly stable or SFLP answer sets. We show that it is equivalent to the major previously proposed semantics for programs with convex generalized atoms, and that it in general admits more intended models than other semantics in the presence of non-convex generalized atoms. We show that the complexity of supportedly stable models is on the second level of the polynomial hierarchy, similar to previous proposals and to stable models of disjunctive logic programs. Given these complexity results, we provide a compilation method that compactly transforms programs with generalized atoms in disjunctive normal form to programs without generalized atoms. Variants are given for the new supportedly stable and the existing FLP semantics, for which a similar compilation technique has not been known so far.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

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

Answer Set Programming (ASP) is a widely used problem-solving framework based on logic programming under the stable model semantics. The basic language relies on Datalog with negation in rule bodies and possibly disjunction in rule heads. When actually using the language for representing practical knowledge, it became apparent that generalizations of the basic language are necessary for usability. Among the suggested extensions are aggregate atoms (similar to aggregations in database queries) [Niemelä, Simons, and Soininen1999, Niemelä and Simons2000, Dell’Armi et al.2003, Faber et al.2008] and atoms that rely on external truth valuations [Calimeri, Cozza, and Ianni2007, Eiter et al.2004, Eiter et al.2005]. These extensions are characterized by the fact that deciding the truth values of the new kinds of atoms depends on the truth values of a set of traditional atoms rather than a single traditional atom. We will refer to such atoms as generalized atoms, which cover also several other extensions such as abstract constraints, generalized quantifiers, and HEX atoms.

Concerning semantics for programs containing generalized atoms, there have been several different suggestions. All of these appear to coincide for programs that do not contain generalized atoms in recursive definitions. The two main semantics that emerged as standards are the PSP semantics defined in [Pelov2004, Pelov, Denecker, and Bruynooghe2007] and [Son and Pontelli2007], and the FLP semantics defined in [Faber, Leone, and Pfeifer2004, Faber, Leone, and Pfeifer2011]. In a recent paper [Alviano and Faber2013] the relationship between these two semantics was analyzed in detail; among other, more intricate results, it was shown that the semantics coincide up to convex generalized atoms. It was already established earlier that each PSP answer set is also an FLP answer set, but not vice versa. So for programs containing non-convex generalized atoms, some FLP answer sets are not PSP answer sets. In particular, there are programs that have FLP answer sets but no PSP answer sets.

In this paper, we argue that the FLP semantics is still too restrictive, and some programs that do not have any FLP answer set should instead have answer sets. In order to illustrate the point, consider a coordination game that is remotely inspired by the prisoners’ dilemma. There are two players, each of which has the option to confess or defect. Let us also assume that both players have a fixed strategy already, which however still depends on the choice of the other player as well. In particular, each player will confess exactly if both players choose the same option, that is, if both players confess or both defect. The resulting program is in Example 2, where means that the first player confesses and means that the second player confesses. As will be explained later, the FLP semantics does not assign any answer set to this program, and therefore also the PSP semantics will not assign any answer sets to this program. However, this is peculiar, as the scenario in which both players confess seems like a reasonable one; indeed, even a simple inflationary operator would result in this solution.

Looking at the reason why this is not an FLP answer set, we observe that it has two countermodels that prevent it from being an answer set: One in which only the first player confesses, and another one in which only the second player confesses. Both of these countermodels are models in the classical sense, but they are weak in the sense that they are not supported, meaning that there is no rule justifying their truth. This is a situation that does not occur for aggregate-free programs, which always have supported countermodels. We argue that one needs to look at supported countermodels, instead of looking at minimal countermodels. It turns out that doing this yields the same results not only for aggregate-free programs, but also for programs containing convex aggregates, which we believe is the reason why this issue has not been noticed earlier.

In this paper, we define a new semantics along these lines and call it supportedly stable or SFLP (supportedly FLP) semantics. It provides answer sets for more programs than FLP and PSP, but is shown to be equal on convex programs. Analyzing the computational complexity of the new semantics, we show that it is in the same classes as the FLP and PSP semantics when considering polynomial-time computable generalized atoms. It should also be mentioned that the new semantics has its peculiarities, for instance adding “tautological” rules like can change the semantics of the program.

This complexity result directly leads us to the second contribution of this paper. While it has been known for quite some time that the complexity of programs with generalized atoms (even without disjunctions) is equal to the complexity of disjunctive programs, no compact transformation from programs with generalized atoms to disjunctive standard programs is known yet. We provide a contribution with this respect and show how to achieve such a compact compilation for both FLP and SFLP semantics when non-convex aggregates are in disjunctive normal form. It hinges on the use of disjunction and fresh symbols to capture satisfaction of a generalized atom.

The remainder of this paper is structured as follows. In the next section, we present the syntax and FLP semantics for programs with generalized atoms. After that, we analyze issues with the FLP semantics and define the SFLP semantics, followed by a section that proves several useful properties of the new semantics. The subsequent section then deals with compiling programs with generalized atoms into generalized-atom-free programs, followed by conclusions.

2 Syntax and FLP Semantics

In this section we present the syntax used in this paper and present the FLP semantics [Faber, Leone, and Pfeifer2004, Faber, Leone, and Pfeifer2011]. To ease the presentation, we will directly describe a propositional language here. This can be easily extended to the more usual ASP notations of programs involving variables, which stand for their ground versions (that are equivalent to a propositional program).

2.1 Syntax

Let be a countable set of propositional atoms.

Definition 1.

A generalized atom on is a mapping from to Boolean truth values. Each generalized atom has an associated, finite111In principle, we could also consider infinite domains, but refrain to do so for simplicity. domain , indicating those propositional atoms that are relevant to the generalized atom.

Example 1.

A generalized atom modeling a conjunction () of propositional atoms is such that and, for every , maps to true if and only if .

A generalized atom modeling a conjunction () of literals, where are propositional atoms and denotes negation as failure, is such that and, for every , maps to true if and only if and .

A generalized atom modeling an aggregate (), where are propositional atoms, is such that and, for every , maps to true if and only if .

In the following, when convenient, we will represent generalized atoms as conjunctions of literals or aggregate atoms. Subsets of mapped to true by such generalized atoms will be those satisfying the associated conjunction.

Definition 2.

A general rule is of the following form:

(1)

where is a disjunction ( of propositional atoms in referred to as the head of , and is a generalized atom on called the body of . For convenience, is sometimes considered a set of propositional atoms.

A general program is a set of general rules.

Example 2.

Consider the following rules:

The following are general programs:

2.2 FLP Semantics

An interpretation is a subset of . is a model for a generalized atom , denoted , if maps to true. Otherwise, if maps to false, is not a model of , denoted . is a model of a rule of the form (1), denoted , if whenever . is a model of a program , denoted , if for every rule .

Generalized atoms can be partitioned into two classes according to the following definition.

Definition 3 (Convex Generalized Atoms).

A generalized atom is convex if for all triples of interpretations such that , and implies .

Note that convex generalized atoms are closed under conjunction (but not under disjunction or negation). A convex program is a general program whose rules have convex bodies.

We now describe a reduct-based semantics, usually referred to as FLP, which has been introduced and analyzed in [Faber, Leone, and Pfeifer2004, Faber, Leone, and Pfeifer2011].

Definition 4 (FLP Reduct).

The FLP reduct of a program with respect to is defined as the set .

Definition 5 (FLP Answer Sets).

is an FLP answer set of if and for each it holds that . Let denote the set of FLP answer sets of .

Example 3.

Consider the programs from Example 2. The models of are , and , none of which is an FLP answer set. Indeed,

which have the trivial model , which is of course a subset of and . On the other hand

and so

where . We will discuss in the next section why this is a questionable situation.

Concerning , it has one model, namely , which is also its unique FLP answer set. Indeed,

and hence the only model of is .

Interpretation is also the unique model of program , which however has no FLP answer set. Here,

hence similar to ,

and .

instead has two FLP answer sets, namely and , and a further model . In this case,

and no proper subset of satisfies it. Also

and no proper subset of satisfies it. Instead, for , we have

and hence

and .

Finally, has tree models, , and , but only one answer set, namely . In fact, and is not a model of the reduct. On the other hand, is a model of , and is a model of .

3 SFLP Semantics

As noted in the introduction, the fact that has no FLP answer sets is striking. If we first assume that both and are false (interpretation ), and then apply a generalization of the well-known one-step derivability operator, we obtain truth of both and (interpretation ). Applying this operator once more again yields the same interpretation, a fix-point. is also a supported model, that is, for all true atoms there exists a rule in which this atom is the only true head atom, and in which the body is true.

It is instructive to examine why this seemingly robust model is not an FLP answer set. Its reduct is equal to the original program, . There are therefore two models of , and , that are subsets of and therefore inhibit from being an FLP answer set. The problem is that, contrary to , these two models are rather weak, in the sense that they are not supported. Indeed, when considering , there is no rule in such that is the only true atom in the rule head and the body is true in : The only available rule with in the head has a false body. The situation for is symmetric.

It is somewhat counter-intuitive that a model like should be inhibited by two weak models like and . Indeed, this is a situation that normally does not occur in ASP. For programs that do not contain generalized atoms, whenever one finds a such that there is for sure also a such that and is supported. Indeed, we will show in the following section that this is the case also for programs containing only convex generalized atoms. Our feeling is that since such a situation does not happen for a very wide set of programs, it has been overlooked so far.

We will now attempt to repair this kind of anomaly by stipulating that one should only consider supported models for finding inhibitors of answer sets. In other words, one does not need to worry about unsupported models of the reduct, even if they are subsets of the candidate. Let us first define supported models explicitly.

Definition 6 (Supportedness).

A model of a program is supported if for each there is a rule such that and . In this case we will write .

Example 4.

Continuing Example 3, programs , , and have one supported model, namely . The model of is not supported because the body of the the rule with in the head has a false body with respect to . For a symmetric argument, model of is not supported either. The supported models of , instead, are , , and , so all models of the program are supported. Note that both models and have the disjunctive rule as the only supporting rule for the respective single true atom, while for , the two rules with generalized atoms serve as supporting rules for and . Finally, the supported models of are and .

We are now ready to formally introduce the new semantics. In this paper we will normally refer to it as SFLP answer sets or SFLP semantics, but also call it supportedly stable models occasionally.

Definition 7 (SFLP Answer Sets).

is a supportedly FLP answer set (or SFLP answer set, or supportedly stable model) of if and for each it holds that . Let denote the set of SFLP answer sets of .

Example 5.

Consider again the programs from Example 2. Recall that has only one supported model, namely , and

but

therefore no proper subset of is a supported model, hence it is an SFLP answer set.

Concerning , it has one model, namely , which is supported and also its unique SFLP answer set. Indeed, recall that

and hence no proper subset of can be a model (let alone a supported model) of .

Interpretation is the unique model of program , which is supported and also its SFLP answer set. In fact

has two SFLP answer sets, namely and . In this case, recall

and no proper subset of satisfies it. Also

and no proper subset of satisfies it. Instead, for , we have

hence since

we obtain that is not an SFLP answer set.

Finally, has two SFLP answer sets, namely and . In fact, and .

The programs, models, FLP answer sets, supported models, and SFLP answer sets are summarized in Table 1.

Rules Models FLP Supported Models SFLP
, ,
, , , , , ,
, , , ,
Table 1: (Supported) models and (S)FLP answer sets of programs in Example 2, where .

An alternative, useful characterization of SFLP answer sets can be given in terms of Clark’s completion [Clark1978]. In fact, it is well-known that supported models of a program are precisely the models of its completion. We define this notion in a somewhat non-standard way, making use of the concept of generalized atom.

Next, we first define the completion of a propositional atom with respect to a general program as a generalized atom encoding the supportedness condition for .

Definition 8.

The completion of a propositional atom with respect to a general program is a generalized atom mapping to true any interpretation containing and such that there is no rule for which and .

These generalized atoms are then used to effectively define a program whose models are the supported model of .

Definition 9.

The completion of a general program is a general program extending with a rule

for each propositional atom occurring in .

Example 6.

Consider again programs from Example 2. Program extends with the following rules:

Program extends with the following rules:

Program is equal to , and program extends with the following rules:

Program instead extends with the following rules:

The only model of , , and is . The models of and instead are , , and .

Proposition 1.

Let be a general program and an interpretation. iff .

This characterization (which follows directly from [Clark1978]) provides us with a means for implementation that relies only on model checks, rather than supportedness checks.

Proposition 2.

Let be a general program and an interpretation. is a supportedly FLP answer set of if and for each it holds that .

4 Properties

The new semantics has a number of interesting properties that we report in this section. First of all, it is an extension of the FLP semantics, in the sense that each FLP answer set is also an SFLP answer set.

Theorem 1.

Let be a general program. .

Proof.

Let be an FLP answer set of . Hence, each is such that . Thus, we can conclude that for any . Therefore, is a SFLP answer set of . ∎

The inclusion is strict in general. In fact, is a simple program for which the two semantics disagree (see Examples 25 and Table 1). On the other hand, the two semantics are equivalent for a large class of programs, as shown below.

Theorem 2.

If is a convex program then .

Proof.

holds by Theorem 1. For the other direction, consider an interpretation not being an FLP answer set of . Hence, there is such that . We also assume that is a subset-minimal model of , that is, there is no such that . We shall show that . To this end, suppose by contradiction that there is such that for each either or . Consider and a rule such that . Since , , and thus because is convex. Therefore, . Moreover, because by assumption. Hence, , and therefore . This contradicts the assumption that is a subset-minimal model of . ∎

We will now focus on computational complexity. We consider here the problem of determining whether an SFLP answer set exists. We note that the only difference to the FLP semantics is in the stability check. For FLP, subsets need to be checked for being a model, for SFLP, subsets need to be checked for being a supported model. Intuitively, one would not expect that this difference can account for a complexity jump, which is confirmed by the next result.

Theorem 3.

Let be a general program whose generalized atoms are polynomial-time computable functions. Checking whether is in in general; it is -hard already in the disjunction-free case if at least one form of non-convex generalized atom is permitted. The problem is -complete if is disjunction-free and convex.

Proof.

For the membership in one can guess an interpretation and check that there is no such that . The check can be performed by a oracle.

To prove -hardness we note that extending a general program by rules for every propositional atom occurring in is enough to guarantee that all models of any reduct of are supported. We thus refer to the construction and proof by [Alviano and Faber2013].

If is disjunction-free and convex then by Theorem 2. Hence, -completeness follows from results in [Liu and Truszczyński2006]. ∎

We would like to point out that the above proof also illustrates a peculiar feature of SFLP answer sets, which it shares with the supported model semantics: the semantics is sensitive to tautological rules like , as their addition can turn non-SFLP answer sets into SFLP answer sets.

5 Compilation

The introduction of generalized atoms in logic programs does not increase the computational complexity of checking FLP as well as SFLP answer set existence, as long as one is allowed to use disjunctive rule heads. However, so far no compilation method that compactly transforms general programs to logic programs without generalized atoms has been presented for the FLP semantics. In the following we provide such a compilation for non-convex aggregates in disjunctive normal form. The compilation is also extended for the new SFLP semantics. We point out that such compilations are not necessarily intended to provide efficient methods for computing answer sets of general programs. Their purpose is instead to provide insights that may lead to obtain such methods in the future.

In this section we only consider generalized atoms in disjunctive normal form, that is, a generalized atom will be associated with an equivalent propositional formula of the following form:

(2)

where , and are propositional atoms for . We will also assume that the programs to be transformed have atomic heads. To generalize our compilations to cover disjunctive general rules is a problem to be addressed in future work.

Let be a program. In our construction we will use the following fresh propositional atoms, i.e., propositional atoms not occurring in : for each generalized atom ; for each generalized atom and integer . For a generalized atom of the form (2) and integer , let denote the following rule:

(3)

Moreover, let denote

(4)

for , and

(5)

for . Abusing of notation, let denote the following rule:

(6)

Intuitively, rule forces truth of whenever the -th disjunct of is true. Similarly, rule forces truth of whenever the -th disjunct of is false due to atom ; if all disjuncts of are false, rule forces truth of to model that is actually false. Note that atoms occurring in negative literals of the -th disjunct of have been moved in the head of . In this way, the information encoded by is preserved in the reduct with respect to an interpretation whenever the -th disjunct of is true with respect to a subset of , not necessarily itself.

The rewriting of , denoted , is the following set of rules:

(7)

The rewriting of , denoted , is obtained from by replacing each generalized atom by . The FLP-rewriting of , denoted , is obtained from by adding rules in for each generalized atom occurring in . The SFLP-rewriting of , denoted , is obtained from by adding a rule of the form

(8)

for each propositional atom occurring in , where () are the rules of having head .

Example 7.

Let be the generalized atom in Example 2. Its disjunctive normal form is . Rules and are then and . Program is

One can check that has no answer set. In particular, is not an answer set of . Its FLP reduct consists of the first four rules

and both and are minimal models of the reduct. On the other hand, neither nor are models of the original program, and so also not answer sets.

Program extends with the following rules:

The program has one answer set:

In contrast to its FLP reduct now consists of the first four rules of plus the two additional rules:

These two additional rules impede and to be models, and indeed only is a model of the reduct.

Program is . (To simplify the presentation, bodies equivalent to atomic literals are not rewritten.)

In this case,

is its only answer set. Different to , the additional rules will be present in the reduct for :

Thus the reduct models and are avoided.

Program extends with

It is easy to see that these additional rules do not alter answer sets, so also has a single answer set .

Program is . This program has no answer sets for the same reason as . Indeed, the two additional rules are not in the reduct for , and so and are again minimal models.

Program is . For the same reason as for , this program has exactly one answer set:

The two new rules disappear in the reduct, but the rules present in but not in do not allow models and .

Program contains a disjunctive rule and is thus not in the domain of and described here.

In the examples provided so far, it can be checked that answer sets are preserved by our transformations if auxiliary symbols are ignored. In the remainder of this section we will formalize this intuition.

Definition 10.

The expansion of an interpretation for a program , denoted , is the following interpretation:

(9)

The contraction of an interpretation to the symbols of , denoted , is the following interpretation:

(10)

Below, we show that expansions and contractions define bijections between the answer sets of a program and those of the corresponding compilations. In the claim we consider only FLP answer sets of the rewritten program because it is convex, and thus its FLP and SFLP answer sets coincide by Theorem 2.

Theorem 4.

Let be a program, and .

  1. If then .

  2. If then .

Proof (item 1).

Let be an answer set of . Hence, (see Definition 7 and Theorem 1). Since each generalized atom occurring in is replaced by in , and if and only if , we have . Consider rules in for some generalized atom of the form (2) occurring in , and note that either or . In both cases, all rules in are satisfied by . Hence, . Consider a rule of the form (8) such that . Since , there is such that . Thus, , and therefore . We can conclude .

Let be such that . We first show that . Consider a rule in such that and , where is of the form (2). Hence, there is such that

Therefore, because , and consequently because of rule in . We thus conclude . For , this already proves . For , let be the atoms without support, i.e., is a subset-maximal set such that implies for each rule in . Hence, . It follows that , i.e., and .

We can now show that . Let be a generalized atom of the form (2). If there is such that

and thus because and . Otherwise, if then for all there is either such that , or such that . Hence, because , and thus because . ∎

Proof (item 2).

Let be an FLP answer set of . Let be a generalized atom of the form (2) occurring in . We prove the following statements:

(11)
(12)
(13)

To prove (11), define set as a maximal subset satisfying the following requirements: If (for some ) then ; if an atom is not supported by in then . We have , from which we conclude .

Consider (12). If then by (11) no belongs to . Recall that FLP answer sets are supported models, i.e., . Thus, for , there is such that and . Therefore, . For , we just note that if is supported only by a rule of the form (8), then atom is only supported by a rule in . would be a model of in this case, then contradicting . Now consider the right-to-left direction. If then there is such that , and thus (see Equations 45). Hence, (see Equation 6). From rule (see Equation 3) we have .

Concerning (13), because of (11) and (12), we have just to show that whenever . In fact, in this case by (12), and for each there is either such that , or such that