Logic programs with propositional connectives and aggregates
Answer set programming (ASP) is a logic programming paradigm that can be used to solve complex combinatorial search problems. Aggregates are an ASP construct that plays an important role in many applications. Defining a satisfactory semantics of aggregates turned out to be a difficult problem, and in this paper we propose a new approach, based on an analogy between aggregates and propositional connectives. First, we extend the definition of an answer set/stable model to cover arbitrary propositional theories; then we define aggregates on top of them both as primitive constructs and as abbreviations for formulas. Our definition of an aggregate combines expressiveness and simplicity, and it inherits many theorems about programs with nested expressions, such as theorems about strong equivalence and splitting.
Answer set programming (ASP) is a logic programming paradigm that can be used to solve complex combinatorial search problems ([\citeauthoryearMarek and Truszczyński1999]), ([\citeauthoryearNiemelä1999]). ASP is based on the stable model semantics [\citeauthoryearGelfond and Lifschitz1988] for logic programs: programming in ASP consists in writing a logic program whose stable models (also called answer sets) represent the solution to our problem. ASP has been used, for instance, in planning [\citeauthoryearDimopoulos et al.1997, \citeauthoryearLifschitz1999], model checking [\citeauthoryearLiu et al.1998, \citeauthoryearHeljanko and Niemelä2001], product configuration [\citeauthoryearSoininen and Niemelä1998], logical cryptanalysis [\citeauthoryearHietalahti et al.2000], workflow specification [\citeauthoryearTrajcevski et al.2000, \citeauthoryearKoksal et al.2001], reasoning about policies [\citeauthoryearSon and Lobo2001], wire routing problems [\citeauthoryearErdem et al.2000] and phylogeny reconstruction problems [\citeauthoryearErdem et al.2003].
The stable models of a logic program are found by systems called
answer set solvers. Answer set solvers
can be considered the equivalent of SAT solvers — systems used to find the
models of propositional formulas — in logic programming. On the other hand,
it is much easier to express, in logic programming, recursive definitions
(such as reachability in a graph) and defaults.
Several answer set solvers have been developed so far, with
An important construct in ASP are aggregates. Aggregates allow, for instance, to perform set operations such as counting the number of atoms in a set that are true, or summing weights the weights of the atoms that are true. We can, for instance, express that a node in a graph has exactly one color by the following cardinality constraint:
As another example, a weight constraint of the form
intuitively says that the sum of the weights (the numbers after the “” sign) of the atoms from the list , , that are true is at least 3.
Aggregates are a hot topic in ASP not only because of their importance, but also because there is no standard understanding of the concept of an aggregate. In fact, different answer set solvers implement different definitions of aggregates: for instance, smodels implements cardinality and weight constraints [\citeauthoryearNiemelä and Simons2000], while dlv implements aggregates as defined by Faber, Leone and Pfeifer (2005) (we call them FLP-aggregates). Unfortunately, constructs that are intuitively equivalent to each other may actually lead to different stable models. In some sense, no current definition of an aggregate can be considered fully satisfactory, as each of them seems to have properties that look unintuitive. For instance, it is somehow puzzling that, as noticed in [\citeauthoryearFerraris and Lifschitz2005b], weight constraints
are semantically different from each other (may lead to different stable models). Part of this problem is probably related to the lack of mathematical tools for studying properties of programs with aggregates, in particular for reasoning about the correctness of programs with aggregates.
This paper addresses the problems of aggregates mentioned above by (i) giving a new semantics of aggregates that, we argue, is more satisfactory than the existing alternatives, and (ii) providing tools for studying properties of logic programs with aggregates.
Our approach is based on a relationship between two directions of research on extending the stable model semantics: the work on aggregates, mentioned above, and the work on “propositional extensions” (see Figure 1). The latter makes the syntax of rules more and more similar to the syntax of propositional formulas. In disjunctive programs, the head of each rule is a (possibly empty) disjunction of atoms, while in programs with nested expressions the head and body of each rule can be any arbitrary formula built with connectives AND, OR and NOT. For instance,
is a rule with nested expressions. Programs with nested expressions are quite attractive especially relative to point (ii) above, because many theorems about properties of logic programs have been proved for programs of this kind. For instance, the splitting set theorem [\citeauthoryearLifschitz and Turner1994, \citeauthoryearErdoğan and Lifschitz2004] simplifies the task of computing the stable models of a program/theory by breaking it into two parts. Work on strong equivalence [\citeauthoryearLifschitz et al.2001] allows us to modify a program/theory with the guarantee that stable models are preserved (more details in Section 2.4).
Nested expressions have already been used to express aggregates: [\citeauthoryearFerraris and Lifschitz2005b] showed that each weight constraint can be replaced by a nested expressions, preserving its stable models. As a consequence, theorems about nested expressions can be used for programs with weight constraints. It turns out, however, that nested expressions are not sufficiently general for defining a semantics for aggregates that overcomes the unintuitive features of the existing approaches. For this reason, we extend the syntax of rules with nested expressions, allowing implication in every part of a “rule”, and not only as the outermost connective. (We understand a rule as an implication from the body to the head). A “rule” is then an arbitrary propositional formula, and a program an arbitrary propositional theory. Our new definition of a stable model, like all the other definitions, is based on the process of constructing a reduct. The process that we use looks very different from all the others, and in particular for programs with nested expressions. Nevertheless, it turns out that in application to programs with nested expressions, our definition is equivalent to the one from [\citeauthoryearLifschitz et al.1999]. This new definition of a stable model also turns out to closely related to equilibrium logic [\citeauthoryearPearce1997], a logic based on the concept of a Kripke-model in the logic of here-and-there. Also, we will show that many theorems about programs with nested expressions extend to arbitrary propositional theories.
On top of arbitrary propositional formulas, we give our definition of an aggregate. Our extension of the semantics to aggregates treats aggregates in a way similar to propositional connectives. Aggregates can be viewed either as primitive constructs or as abbreviations for propositional formulas; both approaches lead to the same concept of a stable model. The second view is important because it allows us to use theorems about stable models of propositional formulas in the presence of aggregates. As an example of application of such theorems, we use them to prove the correctness of an ASP program with aggregates that encodes a combinatorial auction problem.
Syntactically, our aggregates can occur in any part of a formula, even nested inside each other. (The idea of “nested aggregates” is not completely new, as the proof of Theorem 3(a) in [\citeauthoryearFerraris2007] involves “nested weight constraints”.) In our definition of an aggregate we can have, in the same program/theory, many other kinds of constructs, such as choice rules and disjunction in the head, while other definitions allow only a subset of them. Our aggregates seems not to exibit the unintuitive behaviours of other definitions of aggregates.
It also turns out that a minor syntactical modification of programs with
FLP-aggregates allows us to view them as a special kind of
(The new picture of extensions is shown in Figure 2.)
Consequently, we also have a “propositional” representation of
FLP-aggregates. We use this fact to compare them with other aggregates
that have a characterization in terms of nested expressions. (As we
said, [\citeauthoryearFerraris and Lifschitz2005b] showed that weight constraints can be expressed
as nested expressions, and also [\citeauthoryearPelov et al.2003]
implicitly defined PDB-aggregates in terms of nested expressions.)
We will show that all characterizations of aggregates are essentially
equivalent to each other when the aggregates are monotone or antimonotone and
without negation, while there are differences in the other
The paper is divided into three main parts. We start, in the next section, with the new definition of a stable model for propositional theories, their properties and comparisons with previous definitions of stable models and equilibrium logic. In Section 3 we present our aggregates, their properties and the comparisons with other definitions of aggregates. Section 4 contains all proofs for the theorems of this paper. The paper ends with the conclusions in Section 5.
Preliminary reports on some results of this paper were published in [\citeauthoryearFerraris2005].
2 Stable models of propositional theories
Usually, in logic programming, variables are allowed. As in most definitions of a stable model, we assume that the variables have been replaced by constants in a process called “grounding” (see, for instance, [\citeauthoryearGelfond and Lifschitz1988]), so that we can consider the signature to be essentially propositional.
(Propositional) formulas are built from atoms and the 0-place connective (false), using the connectives , and . Even if our definition of a stable model below applies to formulas with all propositional connectives, we will consider as an abbreviation for , a formula as an abbreviation for and as an abbreviation for . This will keep notation for other sections simpler. It can be shown that these abbreviations perfectly capture the meaning of , and as primitive connectives in the stable model semantics.
A (propositional) theory is a set of formulas. As usual in logic programming, truth assignments will be viewed as sets of atoms; we will write to express that a set of atoms satisfies a formula , and similarly for theories.
An implication can be also written as a “rule” ,
so that traditional programs, disjunctive programs and
programs with nested expressions (reviewed in Section 2.2)
can be seen as special cases of propositional
We will now define when a set of atoms is a stable model of a propositional theory . For the rest of the section denotes a set of atoms.
The reduct of a propositional formula relative to is obtained from by replacing each maximal subformula not satisfied by with . That is, recursively,
for every atom , if then is , otherwise it is ; and
for every formulas and and any binary connective , if then is , otherwise it is .
This definition of reduct is similar to a transformation proposed in [\citeauthoryearOsorio et al.2004, Section 4.2].
For instance, if contains but not then
The reduct of a propositional theory relative to is . A set of atoms is a stable model of if is a minimal set satisfying .
For instance, let be the theory consisting of
Theory is actually a traditional program, a logic program in the sense of [\citeauthoryearGelfond and Lifschitz1988] (more details in the next section). Set is a stable model of ; indeed, by looking at the first two lines of (2) we can see that is , which is satisfied by but not by its unique proper subset . It is easy to verify that is the only other stable model of . Similarly, it is not difficult to see that is the only stable model of the theory
(The reduct relative to is ).
As the name suggests, a stable model of a propositional theory is a model — in the sense of classical logic — of . Indeed, it follows from the easily verifiable fact that, for each set of atoms, iff . On the other hand, formulas that are equivalent in classical logic may have different stable models: for instance, has no stable models, while has stable model . Proposition 5 below will give some characterizations of transformations that preserves stable models. Notice that classically equivalent transformations can be applied to the reduct of a theory, as the sets of atoms that are minimal don’t change.
Finally, a note about a second kind of negation in propositional theories.
In [\citeauthoryearFerraris and Lifschitz2005a, Section 3.9], atoms were divided into two groups: “positive”
and “negative”, so that each negative atom has the form , where
is a positive atom. Symbol is called “strong negation”, to
distinguish it from the connective , which is called
negation as failure.
2.2 Relationship with previous definitions of a stable model
As mentioned in the introduction, a propositional theory is the extension of traditional programs [\citeauthoryearGelfond and Lifschitz1988], disjunctive programs [\citeauthoryearGelfond and Lifschitz1991] and programs with nested expressions [\citeauthoryearLifschitz et al.1999] (see Figure 2). We want to compare the definition of a stable model from the previous section with the definitions in the three papers cited above.
|kind of rule||syntax|
|with nested expressions||( and are nested expressions)|
The syntax of a traditional rule, disjunctive rule and rule with nested expressions are shown in Figure 3. We understand an empty conjunction as and an empty disjunction as , so that traditional and disjunctive rules are also rules with nested expressions. The part before and after the arrow are called the head and the body of the rule, respectively. When the body is empty (or ), we can denote the whole rule by its head. A logic program is a set of rules. If all rules in a logic program are traditional then we say that the program is traditional too, and similarly for the other two kinds of rules.
For instance, (3) is a traditional program as well as a disjunctive program and a program with nested expressions. On the other hand, (4) is not a logic program of any of those kinds, because of the first formula that contains implications nested in a disjunction.
For all kinds of programs described above, the definition of a stable model is similar to ours for propositional theories: to check whether a set of atoms is a stable model of a program , we (i) compute the reduct of relative to , and (ii) verify if is a minimal model of such reduct. On the other hand, the way in which the reduct is computed is different. We consider the definition from [\citeauthoryearLifschitz et al.1999], as the definitions from [\citeauthoryearGelfond and Lifschitz1988, \citeyeargel91b] are essentially its special cases.
The reduct of a program with nested expressions
relative to a set of atoms is the result of replacing,
in each rule of , each maximal subformula of the form
with if , and with otherwise.
Set is a stable
model of if it is a minimal model of .
For instance, if is (3) then the reduct is
The stable models of — based on this definition of the reduct — are the same ones that we computed in the previous section using the newer definition of a reduct: and . On the other hand, there are differences in the value of the reducts: for instance, we have just seen that is classically equivalent to , while . However, some similarities between these definitions exist. For instance, negations are treated essentially in the same way: a nested expression is transformed into if , and into otherwise, under both definitions of a reduct.
The following proposition states a more general relationship between the new definition and the 1999 definition of a reduct.
For any program with nested expressions and any set of atoms, is equivalent, in the sense of classical logic,
to , if , and
to the program obtained from by replacing all atoms that do not belong to by , otherwise.
Given two sets of atoms and with and any program with nested expressions, iff and .
From the corollary above, one of the main claims of this paper follows, that our definition of a stable model is an extension of the definition for programs with nested expressions.
For any program with nested expressions, the collections of stable models of according to our definition and according to [\citeauthoryearLifschitz et al.1999] are identical.
2.3 Relationship with Equilibrium Logic
Equilibrium logic [\citeauthoryearPearce1997, \citeyearpea99] is defined in terms of Kripke models in the logic of here-and-there, a logic intermediate between intuitionistic and classical logic.
The logic of here-and-there is a 3-valued logic, where an interpretation (called an HT-interpretation) is represented by a pair of sets of atoms where . Intuitively, atoms in are considered “true”, atoms not in are considered “false”, and all other atoms (that belong to but not ) are “undefined”.
An HT-interpretation satisfies a formula (symbolically, ) based on the following recursive definition ( stands for an atom):
iff and ,
iff or ,
iff implies , and satisfies in classical logic.
An HT-interpretation satisfies a propositional theory if it satisfies all the elements of the theory. Two formulas are equivalent in the logic of here-and-there if they are satisfied by the same HT-interpretations.
Equilibrium logic defines when a set of atoms is an equilibrium model of a propositional theory . Set is an equilibrium model of if and, for all proper subsets of , .
A relationship between the concept of a model in the logic of here-and-there, and satisfaction of the reduct exists.
For any formula and any HT-interpretation , iff .
Next proposition compares the concept of an equilibrium model with the new definition of a stable model.
For any theory, its models in the sense of equilibrium logic are identical to its stable models.
2.4 Properties of propositional theories
This section shows how several theorems about logic programs with nested expressions can be extended to propositional theories.
Two theories and are strongly equivalent if, for every theory , and have the same stable models.
For any two theories and , the following conditions are equivalent:
is strongly equivalent to ,
is equivalent to in the logic of here-and-there, and
for each set of atoms, is equivalent to in classical logic.
The equivalence between (i) and (ii) is essentially Lemma 4 from [\citeauthoryearLifschitz et al.2001] about equilibrium logic. The equivalence between (i) and (iii) is similar to Theorem 1 from [\citeauthoryearTurner2003] about nested expressions, but simpler and more general. Notice that (iii) cannot be replaced by
for each set of atoms, is equivalent to in classical logic,
not even when and are programs with nested expressions. Indeed, is strongly equivalent to , but is not classically equivalent to .
Replacing, in a theory , a (sub)formula with a formula is guaranteed to preserve strong equivalence iff is strongly equivalent to . Indeed, strong equivalence between and is clearly a necessary condition: take . It is also sufficient because — as in classical logic — replacements of formulas with equivalent formulas in the logic of here-and-there preserves equivalence in the same logic.
Cabalar and Ferraris [\citeyearcab04] showed that any propositional theory is strongly equivalent to a logic program with nested expressions. That is, a propositional theory can be seen as a different way of writing a logic program. This shows that the concept of a stable model for propositional theories is not too different from the concept of a stable model for a logic program.
To state several propositions below, we need the following definitions.
Recall that an expression of the form is an abbreviation
for , and equivalences are the conjunction of two opposite
An occurrence of an atom in a formula is positive if it is in
the antecedent of an even number of implications. An occurrence is
strictly positive if such number is 0, and negative if it
The following proposition is an extension of the property that in each
stable model of a program, each atom occurs in the head of a rule of that
program [\citeauthoryearLifschitz1996, Section 3.1].
An atom is an head atom of a theory if it has a
strictly positive occurrence in .
Each stable model of a theory consists of head atoms of .
A rule is called a constraint if its head is . In a logic program, adding constraints to a program removes the stable models of that don’t satisfy the constraints. A constraint can be seen as a formula of the form , a formula that doesn’t have head atoms. Next proposition generalizes the property of logic programs stated above to propositional theories.
For every two propositional theories and such that has no head atoms, a set of atoms is a stable model of iff is a stable model of and .
The following two propositions are generalizations of propositions stated in [\citeauthoryearFerraris and Lifschitz2005b] in the case of logic programs. We say that an occurrence of an atom is in the scope of negation when it occurs in a formula .
Proposition 8 (Lemma on Explicit Definitions).
Let be any propositional theory, and a set of atoms not occurring in . For each , let be a formula that doesn’t contain any atoms from . Then is a 1–1 correspondence between the stable models of and the stable models of .
Proposition 9 (Completion Lemma).
Let be any propositional theory, and a set of atoms that have positive occurrences in only in the scope of negation. For each , let be a formula such that all negative occurrences of atoms from in are in the scope of negation. Then and have the same stable models.
The following proposition is essentially a generalization of the splitting set theorem from [\citeauthoryearLifschitz and Turner1994] and [\citeauthoryearErdoğan and Lifschitz2004], which allows to break logic programs/propositional theories into parts and compute the stable models separately. A formulation of this theorem has also been stated in [\citeauthoryearFerraris and Lifschitz2005a] in the special case of theories consisting of a single formula.
Proposition 10 (Splitting Set Theorem).
Let and be two theories such that no atom occurring in is a head atom of . Let be a set of atoms containing all head atoms of but no head atoms of . A set of atoms is a stable model of iff is a stable model of and is a stable model of .
2.5 Computational complexity
Since the concept of a stable model is equivalent to the concept of an equilibrium model, checking the existence of a stable model of a propositional theory is a -complete problem as for equilibrium models [\citeauthoryearPearce et al.2001]. Notice that the existence of a stable model of a disjunctive program is already -hard [\citeauthoryearEiter and Gottlob1993, Corollary 3.8].
The existence of a stable model for a traditional program is a NP-complete problem [\citeauthoryearMarek and Truszczyński1991]. The same holds, more generally, for logic programs with nested expressions where the head of each rule is an atom or . (We call programs of this kind nondisjunctive). We may wonder if the same property holds for arbitrary sets of formulas of the form and . The answer is negative: the following lemma shows that as soon as we allow implications in formulas then we have the same expressivity — and then complexity — as disjunctive rules.
() where are atoms and are literals, is strongly equivalent to the set of implications
The problem of the existence of a stable model of a theory consisting of formulas of the form and is -complete.
3.1 Syntax and semantics
A formula with aggregates is defined recursively as follows:
atoms and are formulas with aggregates
propositional combinations of formulas with aggregates are formulas with aggregates, and
any expression of the form
is (a symbol for) a function from multisets of real numbers to (such as sum, product, min, max, etc.),
are formulas with aggregates, and are (symbols for) real numbers (“weights”),
is (a symbol for) a binary relation between real numbers, such as and , and
is (a symbol for) a real number,
is a formula with aggregates.
A theory with aggregates is a set of formulas with aggregates. A formula of the form (6) is called an aggregate.
The intuitive meaning of an aggregate is explained by the following clause, which extends the definition of satisfaction of propositional formulas to arbitrary formulas with aggregates. For any aggregate (6) and any set of atoms, let be the multiset consisting of the weights () such that ; we say that satisfies (6) if . For instance,
is satisfied by the sets of atoms that satisfy both and or none of them.
As usual, we say that satisfies a theory with aggregates if satisfies all formulas in . We extend the concept of classical equivalence to formulas/theories with aggregates.
We extend the definition of a stable models of propositional theories (Section 2) to cover aggregates, in a very natural way. Let be a set of atoms. The reduct of a formula with aggregates relative to is again the result of replacing each maximal formula not satisfied by with . That is, it is sufficient to add a clause relative to aggregates to the recursive definition of a reduct: for an aggregate of the form (6),
This is similar to the clause for binary connectives:
The rest of the definition of a stable model remains the same: the reduct of a theory with aggregates is , and is a stable model of if is a minimal model of .
Consider, for instance, the theory consisting of one formula
Set is a stable model of . Indeed, since both the antecedent and consequent of (8) are satisfied by , is
The antecedent of the implication above is satisfied by every set of atoms, so the whole formula is equivalent to . Consequently, is the minimal model of , and then a stable model of .
3.2 Aggregates as Propositional Formulas
A formula/theory with aggregates can also be seen as a normal propositional formula/theory, by identifying (6) with the formula
where stands for , and is the negation of .
For instance, if we consider aggregate (7), the conjunctive terms in (9) correspond to the cases when the sum of weights is 1, that is, when and . The two implications are and respectively, so that (7) is
Even though (11) can be seen as the negation of (7), the negation of (12) is not strongly equivalent to (10) (although they are classically equivalent). This shows that it is generally incorrect to “move” a negation from a binary relation symbol (such as ) in front of the aggregate as the unary connective , and vice versa.
Next proposition shows that this understanding of aggregates as propositional formulas is equivalent to the semantics for theories with aggregates of the previous section. Two formulas with aggregates are classically equivalent to each other if they are satisfied by the same sets of atoms.
Treating aggregates as propositional formulas allows us to apply many properties of propositional theories presented in Section 2.4 to theories with aggregates also. Consequently, we have the concept of an head atom, of strong equivalence, we can use the completion lemma and so on. We will use several of those properties to prove Proposition 14 below. In the rest of the paper we will often make no distinctions between the two ways of defining the semantics of aggregates discussed here.
Notice that replacing, in a theory, an aggregate of the form (6) with a formula that is not strongly equivalent to the corresponding formula (9) may lead to different stable models. This shows that there is no other way (modulo strong equivalence) of representing our aggregates as propositional formulas.
3.3 Monotone Aggregates
An aggregate is monotone if, for each pair of multisets , such that , is true whenever is true. The definition of an antimonotone aggregate is similar, with replaced by .
is monotone, and
is antimonotone. An example of an aggregate that is neither monotone nor antimonotone is (7).
For any aggregate , formula (9) is strongly equivalent to
if the aggregate is monotone, and to
if the aggregate is antimonotone.
In other words, if is monotone then the antecedents of the implications in (9) can be dropped. Similarly, in case of antimonotone aggregates, the consequents of these implications can be replaced by . In both cases, (9) is turned into a nested expression, if are nested expressions.
For instance, aggregate (13) is normally written as formula
Since the aggregate is monotone, it can also be written, by Proposition 13, as nested expression
which is strongly equivalent to . Similarly, aggregate (14) is normally written as formula
since the aggregate is nonmonotone, it can also be written as nested expression
which is strongly equivalent to .
On the other hand, if an aggregate is neither monotone nor antimonotone, it may be not possible to find a nested expression strongly equivalent to (9), even if are nested expressions. This is the case for (7). Indeed, the formula (9) corresponding to (7) is (10), whose reduct relative to is (10). Consequently, by Proposition 5, for any formula strongly equivalent to (10), is classically equivalent to (10). On the other hand, the reduct of nested expressions are essentially AND-OR combinations of atoms, and (negations either become or in the reduct), and no formula of this kind is classically equivalent to (10).
In some uses of ASP, aggregates that are neither monotone nor antimonotone are essential, as discussed in the next section.
We consider the following variation of the combinatorial auction problem [\citeauthoryearBaral and Uyan2001], which can be naturally formalized using an aggregate that is neither monotone nor antimonotone.
Joe wants to move to another town and has the problem of removing all his bulky furniture from his old place. He has received some bids: each bid may be for one piece or several pieces of furniture, and the amount offered can be negative (if the value of the pieces is lower than the cost of removing them). A junkyard will take any object not sold to bidders, for a price. The goal is to find a collection of bids for which Joe doesn’t lose money, if there is any.
Assume that there are bids, denoted by atoms . We express by the formulas
() that Joe is free to accept any bid or not. Clearly, Joe cannot accept two bids that involve the selling of the same piece of furniture. So, for every such pair of bids, we include the formula
Next, we need to express which pieces of the furniture have not been given to bidders. If there are objects we can express that an object is sold by bid by adding the rule
to our theory.
Finally, we need to express that Joe doesn’t lose money by selling his items. This is done by the aggregate
where each is the amount of money (possibly negative) obtained by accepting bid , and each is the money requested by the junkyard to remove item . Note that (20) is neither monotone nor antimonotone.
We define a solution to Joe’s problem as a set of accepted bids such that
the bids involve selling disjoint sets of items, and
the sum of the money earned from the bids is greater than the money spent giving away the remaining items.
3.5 Computational Complexity
Since theories with aggregates generalize disjunctive programs, the
problem of the existence of a stable model of a theory with aggregates
clearly is -hard.
Even if propositional formulas corresponding to aggregates can be exponentially larger than the original aggregate, it turns out that (by treating aggregates as primitive constructs) the computation is not harder than for propositional theories.
If, for every aggregate, computing requires polynomial time then the existence of a stable model of a theory with aggregates is a -complete problem.
For a nondisjunctive program with nested expressions the existence of a stable model is NP-complete. If we allow nonnested aggregates in the body, for instance by allowing rules
( are aggregates and is an atom or ) then the complexity increases to . This follows from Lemma 1, since, in (5), each formula is the propositional representation of ; similarly, each is the propositional representation of .
However, if we allow monotone and antimonotone aggregates only — even nested — in the antecedent, we are in class NP.
Consider theories with aggregates consisting of formulas of the form
where is an atom or , and contains monotone and antimonotone aggregates only, no equivalences and no implications other than negations. If, for every aggregate, computing requires polynomial time then the problem of the existence of a stable model of theories of this kind is an NP-complete problem.
Similar results have been independently proven in [\citeauthoryearCalimeri et al.2005] for FLP-aggregates.
3.6 Other Formalisms
Figure 4 already shows that there are several differences between the various definitions of an aggregate. We analyze that more in details in the rest of this section.
Programs with weight constraints
Weight constraints are aggregates defined in [\citeauthoryearNiemelä and Simons2000] and implemented in answer set solver smodels. We simplify the syntax of weight constraints and of programs with weight constraints for clarity, without reducing its semantical expressivity.
Weight constraints are expressions of the form
is (a symbol for) a real number,
each of is a (symbol for) a literal, and are (symbols for) real numbers.
An example of a weight constraint is (1).
The intuitive meaning of (21) is that the sum of the weights for all the that are true is not lower than . For (22) the sum of weights is not greater than . Often, and are written together as . If a weight is then the part “” is generally omitted. If all weights are 1 then a weight constraint is called a cardinality constraint.
A rule with weight constraints is an expression of the form
where is an atom or , and () are weight constraints.
Finally, a program with weight constraints is a set of rules with weight constraints. Rules/programs with cardinality constraints are rules/programs with weight constraints containing cardinality constraints only.
Programs with cardinality/weight constraints can be seen as a generalization of traditional programs, by identifying each literal in the body of each rule with cardinality constraint .
The definition of a stable model from [\citeauthoryearNiemelä and Simons2000] requires first the elimination of negative weights from weight constraints. This is done by replacing each term where is negative with ( is the literal complementary to ) and increasing the bound by . For instance,
is rewritten as
Then [\citeauthoryearNiemelä and Simons2000] proposes a definition of a reduct and of a stable model for programs with weight constraints without negative weights. For this paper, we prefer showing a translational, equivalent semantics of such programs from [\citeauthoryearFerraris and Lifschitz2005b], that consists in replacing each weight constraint with a nested expression , preserving the stable models of the program: if is (21) then is ()
and if is (22) then is
It turns out that the way of understanding a weight constraint of this paper is not different from when all weights are nonnegative.
In presence of nonnegative weights only, is strongly equivalent to , and is strongly equivalent to .
From this proposition, Propositions 2 and 5 of this paper, and Theorem 1 from [\citeauthoryearFerraris and Lifschitz2005b] it follows that our concept of an aggregate captures the concept of weight constraints defined in [\citeauthoryearNiemelä and Simons2000] when all weights are nonnegative. It also captures the absence of the anti-chain property of its stable models: for instance,
has stable models and in both formalisms.
When we consider negative weights, however, such correspondence doesn’t hold. For instance,
according to [\citeauthoryearNiemelä and Simons2000], has no stable models, while
has stable model . An explanation of this difference can be seen
in the pre-processing proposed by [\citeauthoryearNiemelä and Simons2000] that eliminates negative
weights. For us, weight constraint , and the result
of eliminating its negative weight, are semantically
The preliminary step of removing negative weights can be seen as a way of making weight constraints either monotone or antimonotone. This keeps the problem of the existence of a stable model in class NP, while we have seen in Section 3.5 that, under our semantics, even simple aggregates with the same intuitive meaning of bring the same problem to class .
A PDB-aggregate is an expression of the form (6), where are literals. A program with PDB-aggregates is a set of rules of the form
where , is an atom and are PDB-aggregates.
As in the case of programs with weight constraints, a program with PDB-aggregates is a generalization of a traditional program, by identifying each literal in the bodies of traditional programs by aggregate .
The semantics of [\citeauthoryearPelov et al.2003] for programs with PDB-aggregates
is based on a procedure that transforms programs with such aggregates into
is replaced by the following nested expression
where stands for the multiset , and stands for
For instance, for the PDB-aggregate , if we take , then the pairs that “contribute” to the disjunction in are
The corresponding nested expressions are
It can be shown, using strong equivalent transformations (see Proposition 5) that the disjunction of such nested expressions can be rewritten as .
In case of monotone and antimonotone PDB-aggregates and in the absence of negation as failure, the semantics of Pelov et al. is equivalent to ours.
The claim above is generally not true when either the aggregates are not monotone or antimonotone, or when some formula in the aggregate is a negative literal. Relatively to aggregates that are neither monotone nor antimonotone, the semantics of [\citeauthoryearPelov et al.2003] seems to have the same unintuitive behaviour of [\citeauthoryearNiemelä and Simons2000]: for instance, according to [\citeauthoryearPelov et al.2003], (27) has no stable models while
has stable model .
To illustrate the problem with negative literals, consider the following :
Intuitively, the two programs should have the same stable models. Indeed, the operation of replacing with in the first rule of should not affect the stable models since the second rule “defines” as : it is the only rule with in the head. However, under the semantics of [\citeauthoryearPelov et al.2003], has stable model only and has stable model also. Under our semantics, both (29) and (30) have stable models and .
Note that already the first rule of (30) has different stable models under the two semantics. Under ours, they are and . According to [\citeauthoryearPelov et al.2003], only the empty set is a stable model; it couldn’t have both stable models because stable models as defined in [\citeauthoryearPelov et al.2003] have the anti-chain property.
An FLP-aggregate is an expression of the form (6) where each of is a conjunction of literals. A program with FLP-aggregates is a set of rules of the form
where , are atoms and are FLP-aggregates.
A program with FLP-aggregates is a generalization of a disjunctive program, by identifying each atom in the bodies of disjunctive rules by aggregate .
The semantics of [\citeauthoryearFaber et al.2004] defines when a set of atoms is a stable model for a program with FLP-aggregates. The definition of satisfaction of an aggregate is identical to ours. The reduct, however, is computed differently. The reduct of a program with FLP-aggregates relative to a set of atoms consists of the rules of the form (31) such that satisfies its body. Set is a stable model for if is a minimal set satisfying .
For instance, let be the FLP-program
The only stable model of is the empty set. Indeed, since the empty set doesn’t satisfy the aggregate, , which has as the unique minimal model; we can conclude that is a stable model of . On the other hand, because satisfies the aggregate in . Since , is not a minimal model of and then it is not a stable model of .
This definition of a reduct is different from all other definitions of a reduct described in this paper (and also from many other definitions), in the sense that it may leave negation in the body of a rule. For instance, the reduct of relative to is according to those definitions the fact . In the theory of FLP-aggregates, the reduct doesn’t modify the rule. On the other hand, this definition of a stable model is equivalent to the definition of a stable model in the sense of [\citeauthoryearGelfond and Lifschitz1991] (and successive definitions) when applied to disjunctive programs.
Next proposition shows a relationship between our concept of an aggregate and FLP-aggregates. An FLP-program is positive if, in each formula (31), .
Next proposition shows that our semantics of aggregates is essentially an extension of the
The stable models of a positive FLP-program under our semantics are identical to its stable models in the sense of [\citeauthoryearFaber et al.2004].
The proposition doesn’t apply to arbitrary FLP-aggregates as negation has different meanings in the two semantics. In case of [\citeauthoryearFaber et al.2004], is essentially the same as , while we have seen, in Section 3.2, that this fact doesn’t always hold in our semantics. The difference in meaning can be seen in the following example. Program
has two stable models and according to both semantics. However, if we replace in the first rule with the body of the second ( is “defined” as by the second rule), we get program
which, according to [\citeauthoryearFaber et al.2004], has only stable model . We find it unintuitive.
It is the first rule of (33) that has a different meaning in the two semantics. The rule alone has different stable models: according to [\citeauthoryearFaber et al.2004], its only stable models is . Under our semantics, the stable models are and . As they don’t have the anti-chain property, there is no program with FLP-aggregates that has such stable models under [\citeauthoryearFaber et al.2004].
As a program with FLP-aggregate can be easily rewritten as a positive program with FLP-aggregate, our definition of an aggregate essentially generalizes the one of [\citeauthoryearFaber et al.2004].
For any formulas , any set of atoms, and any connective , is classically equivalent to .
Case 1: . Then, by the definition of reduct, . Case 2: . Then ; moreover, one of is not satisfied by , so that one of is . The case of disjunction is similar. ∎
Proposition 3. For any formula and any HT-interpretation , iff .
It is sufficient to consider the case when is a singleton , where contains only connectives , , and . The proof is by structural induction on .
is . and .
is an atom . iff and . Since , this means iff , which is the condition for which .
has the form . iff by Lemma 2, and then iff and . This is equivalent, by induction hypothesis, to say that and , and then that .
The proof for disjunction is similar to the proof for conjunction.
has the form . iff and , and then iff
This is equivalent, by the induction hypothesis, to
which is the definition of .
Proposition 4. For any theory, its models in the sense of equilibrium logic are identical to its stable models.
A set of atoms is an equilibrium model of iff
|and, for all proper subsets of , .|
In view of Proposition 3, this is equivalent to the condition
|and, for all proper subsets of , .|
which means that is a stable model of . ∎
We first need the recursive definition of reduct for programs with nested expressions from [\citeauthoryearLifschitz et al.1999]. The reduct of a nested expression relative to a set of atoms, as follows:
, and ,
Then the reduct of a rule with with nested expression is defined as , and the reduct of a program with nested expressions as the union of the reduct of its rules.
The reduct of a nested expression is equivalent, in the sense of classical logic, to the nested expression obtained from by replacing all atoms that do not belong to by .
The proof is by structural induction on .
When is or then .
For an atom , . The claim is immediate.
Let be a negation . If then ; otherwise, .
for , is , and, by Lemma 2, is equivalent to . The claim now follows by the induction hypothesis.
Proposition 1. For any program with nested expressions and any set of atoms, is equivalent, in the sense of classical logic,
to , if , and
to the program obtained from by replacing all atoms that do not belong to by , otherwise.
If then clearly contains . Otherwise, consists of formulas for each rule , and consequently for each rule . Since each and is a nested expression, the claim is immediate by Lemma 3. ∎
If then clearly contains , and also (a well-known property about programs with nested expressions), so is not a stable model under either definitions. Otherwise, by Corollary 1, the two reducts are satisfied by the same subsets of . Then is a minimal set satisfying iff it is a minimal set satisfying , and, by the definitions of a stable models is a stable model of either for both definitions or for none of them. ∎
Proposition 5. For any two theories and , the following conditions are equivalent:
is strongly equivalent to ,
is equivalent to in the logic of here-and-there, and
for each set of atoms, is equivalent to in classical logic.
We will prove the equivalence between (i) and (ii) and between (ii) and (iii). We start with the former. Lemma 4 from [\citeauthoryearLifschitz et al.2001] tells that, for any two theories, the following conditions are equivalent:
for every theory , theories and have the same equilibrium models, and
is equivalent to in the logic of here-and-there.
Condition (b) is identical to (ii). Condition (a) can be rewritten, by Proposition 4, as
for every theory , theories and have the same stable models,
which means that is strongly equivalent to .
It remains to prove the equivalence between (ii) and (iii). Theory is equivalent to in the logic of here-and-there iff, for every set of atoms, the following condition holds:
|for every , iff .|
This condition is equivalent, by Proposition 3, to
|for every , iff .|
Since and contain atoms from only (the other atoms are replaced by in the reduct), this last condition expresses equivalence between and . ∎
For any theory , let be a set of atoms that contains all head atoms of . For any set of atoms, if then .
It is clearly sufficient to prove the claim for that is a singleton . The proof is by induction on .
If then , and the claim is trivial.
For an atom , if then , but also , so that