Logic Programs with Propositional Connectives and Aggregates
Abstract
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.
1 Introduction
Answer set programming (ASP) is a logic programming paradigm that can be used to solve complex combinatorial search problems ([Marek and Truszczyński, 1999]), ([Niemelä, 1999]). ASP is based on the stable model semantics [Gelfond and Lifschitz, 1988] 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 [Dimopoulos et al., 1997, Lifschitz, 1999], model checking [Liu et al., 1998, Heljanko and Niemelä, 2001], product configuration [Soininen and Niemelä, 1998], logical cryptanalysis [Hietalahti et al., 2000], workflow specification [Trajcevski et al., 2000, Koksal et al., 2001], reasoning about policies [Son and Lobo, 2001], wire routing problems [Erdem et al., 2000] and phylogeny reconstruction problems [Erdem 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 smodels^{1}^{1}1http://www.tcs.hut.fi/Software/smodels/ and dlv^{2}^{2}2http://www.dbai.tuwien.ac.at/proj/dlv/ among the most popular. As in the case of SAT solvers, answer set solver competitions — where answer set solvers are compared to each others in terms of performance — are planned to be held regularly.^{3}^{3}3http://asparagus.cs.unipotsdam.de/contest/
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
(1) 
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 [Niemelä and Simons, 2000], while dlv implements aggregates as defined by Faber, Leone and Pfeifer (2005) (we call them FLPaggregates). 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 [Ferraris and Lifschitz, 2005b], 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 [Lifschitz and Turner, 1994, Erdoğan and Lifschitz, 2004] simplifies the task of computing the stable models of a program/theory by breaking it into two parts. Work on strong equivalence [Lifschitz 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: [Ferraris and Lifschitz, 2005b] 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 [Lifschitz et al., 1999]. This new definition of a stable model also turns out to closely related to equilibrium logic [Pearce, 1997], a logic based on the concept of a Kripkemodel in the logic of hereandthere. 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 [Ferraris, 2007] 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 FLPaggregates allows us to view them as a special kind of our aggregates. (The new picture of extensions is shown in Figure 2.) Consequently, we also have a “propositional” representation of FLPaggregates. We use this fact to compare them with other aggregates that have a characterization in terms of nested expressions. (As we said, [Ferraris and Lifschitz, 2005b] showed that weight constraints can be expressed as nested expressions, and also [Pelov et al., 2003] implicitly defined PDBaggregates 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 cases.^{4}^{4}4The important role of monotonicity in aggregates has already been shown, for instance, in [Faber et al., 2004].
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 [Ferraris, 2005].
2 Stable models of propositional theories
2.1 Definition
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, [Gelfond and Lifschitz, 1988]), so that we can consider the signature to be essentially propositional.
(Propositional) formulas are built from atoms and the 0place 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 theories.^{5}^{5}5Traditionally, conjunction is represented in a logic program by a comma, disjunction by a semicolon, and negation as failure as not.
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 [Osorio et al., 2004, Section 4.2].
For instance, if contains but not then
(2) 
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
(3) 
Theory is actually a traditional program, a logic program in the sense of [Gelfond and Lifschitz, 1988] (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
(4) 
(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 [Ferraris and Lifschitz, 2005a, 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.^{6}^{6}6Strong negation was introduced in the syntax of logic programs in [Gelfond and Lifschitz, 1991]. In that paper, it was called “classical negation” and treated not as a part of an atom, but rather as a logical operator. In presence of strong negation, the stable model semantics says that only sets of atoms that don’t contain both atoms and can be stable models. For simplicity, we will make no distinctions between positive and negative atoms, considering that we can remove the sets of atoms containing any pair of atoms and from the stable models of a theory by adding a formula to the theory. (See Proposition 7).
2.2 Relationship with previous definitions of a stable model
As mentioned in the introduction, a propositional theory is the extension of traditional programs [Gelfond and Lifschitz, 1988], disjunctive programs [Gelfond and Lifschitz, 1991] and programs with nested expressions [Lifschitz 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 

traditional  
disjunctive  
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 [Lifschitz et al., 1999], as the definitions from [Gelfond and Lifschitz, 1988, ?] 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 . ^{7}^{7}7We underline the set in to distinguish this definition of a reduct from the one from the previous section.
For instance, if is (3) then the reduct is
while 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.
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.
Corollary 1.
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.
Proposition 2.
For any program with nested expressions, the collections of stable models of according to our definition and according to [Lifschitz et al., 1999] are identical.
2.3 Relationship with Equilibrium Logic
Equilibrium logic [Pearce, 1997, ?] is defined in terms of Kripke models in the logic of hereandthere, a logic intermediate between intuitionistic and classical logic.
The logic of hereandthere is a 3valued logic, where an interpretation (called an HTinterpretation) 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 HTinterpretation satisfies a formula (symbolically, ) based on the following recursive definition ( stands for an atom):

iff ,

,

iff and ,

iff or ,

iff implies , and satisfies in classical logic.
An HTinterpretation satisfies a propositional theory if it satisfies all the elements of the theory. Two formulas are equivalent in the logic of hereandthere if they are satisfied by the same HTinterpretations.
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 hereandthere, and satisfaction of the reduct exists.
Proposition 3.
For any formula and any HTinterpretation , iff .
Next proposition compares the concept of an equilibrium model with the new definition of a stable model.
Proposition 4.
For any theory, its models in the sense of equilibrium logic are identical to its stable models.
This proposition offers another way of proving Proposition 2, as [Lifschitz et al., 2001] showed that the equilibrium models of a program with nested expressions are the stable models of the same program in the sense of [Lifschitz et al., 1999].
2.4 Properties of propositional theories
This section shows how several theorems about logic programs with nested expressions can be extended to propositional theories.
2.4.1 Strong equivalence
Two theories and are strongly equivalent if, for every theory , and have the same stable models.
Proposition 5.
For any two theories and , the following conditions are equivalent:

is strongly equivalent to ,

is equivalent to in the logic of hereandthere, and

for each set of atoms, is equivalent to in classical logic.
The equivalence between (i) and (ii) is essentially Lemma 4 from [Lifschitz et al., 2001] about equilibrium logic. The equivalence between (i) and (iii) is similar to Theorem 1 from [Turner, 2003] 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 hereandthere preserves equivalence in the same logic.
Cabalar and Ferraris [?] 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.
2.4.2 Other properties
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 implications. 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 odd.^{8}^{8}8The concept of a positive and negative occurrence of an atom should not be confused by the concept of a “positive” and “negative” atom mentioned at the end of Section 2.1. For instance, in a formula , the occurrences of and are positive, the one of is negative, and the one of is strictly positive.
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 [Lifschitz, 1996, Section 3.1]. An atom is an head atom of a theory if it has a strictly positive occurrence in . ^{9}^{9}9In case of programs with nested expressions, it is easy to check that head atoms are atoms that occur in the head of a rule outside the scope of negation .
Proposition 6.
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.
Proposition 7.
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 [Ferraris and Lifschitz, 2005b] 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 [Lifschitz and Turner, 1994] and [Erdoğan and Lifschitz, 2004], 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 [Ferraris and Lifschitz, 2005a] 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 [Pearce et al., 2001]. Notice that the existence of a stable model of a disjunctive program is already hard [Eiter and Gottlob, 1993, Corollary 3.8].
The existence of a stable model for a traditional program is a NPcomplete problem [Marek and Truszczyński, 1991]. 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.
Lemma 1.
Rule
() where are atoms and are literals, is strongly equivalent to the set of implications
(5) 
Proposition 11.
The problem of the existence of a stable model of a theory consisting of formulas of the form and is complete.
3 Aggregates
3.1 Syntax and semantics
A formula with aggregates is defined recursively as follows:

atoms and are formulas with aggregates^{10}^{10}10Recall that is an abbreviation for ,

propositional combinations of formulas with aggregates are formulas with aggregates, and

any expression of the form
(6) where

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,
(7) 
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
(8) 
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
(9) 
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
(10) 
Similarly,
(11) 
is
(12) 
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.
Proposition 12.
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 .
For instance,
(13) 
is monotone, and
(14) 
is antimonotone. An example of an aggregate that is neither monotone nor antimonotone is (7).
Proposition 13.
For any aggregate , formula (9) is strongly equivalent to
(15) 
if the aggregate is monotone, and to
(16) 
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 ANDOR 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.
3.4 Example
We consider the following variation of the combinatorial auction problem [Baral and Uyan, 2001], 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
(17) 
() 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
(18) 
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
(19) 
to our theory.
Finally, we need to express that Joe doesn’t lose money by selling his items. This is done by the aggregate
(20) 
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.^{11}^{11}11We are clearly assuming weight not to be arbitrary real numbers but to belong to a countable subset of real numbers, such as integers of floating point numbers. We need to check in which class of the computational hierarchy this problem belongs.
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.
Proposition 15.
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 NPcomplete. 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.
Proposition 16.
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 NPcomplete problem.
Similar results have been independently proven in [Calimeri et al., 2005] for FLPaggregates.
3.6 Other Formalisms
monotone/antimonotone  generic  antichain  

aggregates  aggregates  property  
weight constraints  NPcomplete  NPcomplete  NO 
PDBaggregates  NPcomplete  complete  YES 
FLPaggregates  NPcomplete  complete  YES 
our aggregates  NPcomplete  complete  NO 
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.
3.6.1 Programs with weight constraints
Weight constraints are aggregates defined in [Niemelä and Simons, 2000] 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
(21) 
and
(22) 
where

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
(23) 
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 [Niemelä and Simons, 2000] 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 [Niemelä and Simons, 2000] 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 [Ferraris and Lifschitz, 2005b], that consists in replacing each weight constraint with a nested expression , preserving the stable models of the program: if is (21) then is ()
(24) 
and if is (22) then is
(25) 
It turns out that the way of understanding a weight constraint of this paper is not different from when all weights are nonnegative.
Proposition 17.
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 [Ferraris and Lifschitz, 2005b] it follows that our concept of an aggregate captures the concept of weight constraints defined in [Niemelä and Simons, 2000] when all weights are nonnegative. It also captures the absence of the antichain 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,
(26) 
according to [Niemelä and Simons, 2000], has no stable models, while
(27) 
has stable model . An explanation of this difference can be seen in the preprocessing proposed by [Niemelä and Simons, 2000] that eliminates negative weights. For us, weight constraint , and the result of eliminating its negative weight, are semantically different.^{12}^{12}12The fact that the process of eliminating negative weights is somehow unintuitive was already mentioned in [Ferraris and Lifschitz, 2005b] with the same example proposed in this section. Surprisingly, under the semantics of [Niemelä and Simons, 2000], is different from . In fact,
(28) 
has stable model , the same of (27), while (26) has none. Notice that summing weights that are all positive or all negative preserves stable models under both semantics.
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 .
3.6.2 PDBaggregates
A PDBaggregate is an expression of the form (6), where are literals. A program with PDBaggregates is a set of rules of the form
where , is an atom and are PDBaggregates.
As in the case of programs with weight constraints, a program with PDBaggregates is a generalization of a traditional program, by identifying each literal in the bodies of traditional programs by aggregate .
The semantics of [Pelov et al., 2003] for programs with PDBaggregates is based on a procedure that transforms programs with such aggregates into traditional programs.^{13}^{13}13A semantics for such aggregates was proposed in [Denecker et al., 2001], based on the approximation theory [Denecker et al., 2002]. But the first characterization of PDBaggregates in terms of stable models is from [Pelov et al., 2003]. [Son et al., 2007] independently proposed a similar semantics. The procedure can be seen consisting of two parts. The first one essentially consists in rewriting each aggregate as a nested expression.^{14}^{14}14[Pelov et al., 2003] doesn’t explicitly mention nested expressions. The second part “unfolds” each rule into a strongly equivalent set of traditional rules. For our comparisons, only the first part is needed: each PDBaggregate of the form
is replaced by the following nested expression
where stands for the multiset , and stands for
For instance, for the PDBaggregate , 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 PDBaggregates and in the absence of negation as failure, the semantics of Pelov et al. is equivalent to ours.
Proposition 18.
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 [Pelov et al., 2003] seems to have the same unintuitive behaviour of [Niemelä and Simons, 2000]: for instance, according to [Pelov et al., 2003], (27) has no stable models while
has stable model .
To illustrate the problem with negative literals, consider the following :
(29) 
and :
(30) 
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 [Pelov 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 [Pelov et al., 2003], only the empty set is a stable model; it couldn’t have both stable models because stable models as defined in [Pelov et al., 2003] have the antichain property.
3.6.3 FLPaggregates
An FLPaggregate is an expression of the form (6) where each of is a conjunction of literals. A program with FLPaggregates is a set of rules of the form
(31) 
where , are atoms and are FLPaggregates.
A program with FLPaggregates is a generalization of a disjunctive program, by identifying each atom in the bodies of disjunctive rules by aggregate .
The semantics of [Faber et al., 2004] defines when a set of atoms is a stable model for a program with FLPaggregates. The definition of satisfaction of an aggregate is identical to ours. The reduct, however, is computed differently. The reduct of a program with FLPaggregates 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 FLPprogram
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 FLPaggregates, 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 [Gelfond and Lifschitz, 1991] (and successive definitions) when applied to disjunctive programs.
Next proposition shows a relationship between our concept of an aggregate and FLPaggregates. An FLPprogram is positive if, in each formula (31), .
Next proposition shows that our semantics of aggregates is essentially an extension of the
Proposition 19.
The stable models of a positive FLPprogram under our semantics are identical to its stable models in the sense of [Faber et al., 2004].
The proposition doesn’t apply to arbitrary FLPaggregates as negation has different meanings in the two semantics. In case of [Faber 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
(32) 
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
(33) 
which, according to [Faber 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 [Faber et al., 2004], its only stable models is . Under our semantics, the stable models are and . As they don’t have the antichain property, there is no program with FLPaggregates that has such stable models under [Faber et al., 2004].
As a program with FLPaggregate can be easily rewritten as a positive program with FLPaggregate, our definition of an aggregate essentially generalizes the one of [Faber et al., 2004].
4 Proofs
4.1 Proofs of Propositions 3 and 4
Lemma 2.
For any formulas , any set of atoms, and any connective , is classically equivalent to .
Proof.
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 HTinterpretation , iff .
Proof.
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.
Proof.
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 . ∎
4.2 Proof of Propositions 1 and 2
We first need the recursive definition of reduct for programs with nested expressions from [Lifschitz et al., 1999]. The reduct of a nested expression relative to a set of atoms, as follows:

, and ,

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.
Lemma 3.
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 .
Proof.
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.
Proof.
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. ∎
Proposition 2. For any program with nested expressions, the collection of stable models of according to our definition and according to [Lifschitz et al., 1999] are identical.
Proof.
If then clearly contains , and also (a wellknown 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. ∎
4.3 Proofs of Propositions 5–7
Proposition 5. For any two theories and , the following conditions are equivalent:

is strongly equivalent to ,

is equivalent to in the logic of hereandthere, and

for each set of atoms, is equivalent to in classical logic.
Proof.
We will prove the equivalence between (i) and (ii) and between (ii) and (iii). We start with the former. Lemma 4 from [Lifschitz 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 hereandthere.
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 hereandthere 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 . ∎
Lemma 4.
For any theory , let be a set of atoms that contains all head atoms of . For any set of atoms, if then .
Proof.
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 .

If then and . Consequently, by induction hypothesis, and . It remains to notice that .

The case of disjunction is similar to the case of conjunction.

If then . Assume that . Consequently and then . It follows that, since , . Since contains all head atoms of , the claim follows by the induction hypothesis.
∎
Lemma 5.
For any theory and any set of atoms, iff .
Proof.
Reduct is obtained from by replacing some subformulas that are not satisfied by with . ∎