Vicious Circle Principle and Logic Programs with Aggregates
Abstract
The paper presents a knowledge representation language which extends ASP with aggregates. The goal is to have a language based on simple syntax and clear intuitive and mathematical semantics. We give some properties of , an algorithm for computing its answer sets, and comparison with other approaches.
Gelfond and Zhang]
Michael Gelfond and Yuanlin Zhang
Texas Tech University, Lubbock, Texas 79414, USA
ggregates, Answer Set Programming
1 Introduction
The development of answer set semantics for logic programs [gl88, gl91] led to the creation of powerful knowledge representation language, Answer Set Prolog (ASP), capable of representing recursive definitions, defaults, effects of actions and other important phenomena of natural language. The design of algorithms for computing answer sets and their efficient implementations in systems called ASP solvers [nss02, dlv06, clasp07] allowed the language to become a powerful tool for building nontrivial knowledge intensive applications [BrewkaET11, ErdemLL12]. There are a number of extensions of the ASP which also contributed to this success. This paper is about one such extension – logic programs with aggregates. By aggregates we mean functions defined on sets of objects of the domain. (For simplicity of exposition we limit our attention to aggregates defined on finite sets.) Here is a typical example.
Example 1 (Classes That Need Teaching Assistants)
Suppose that we have a complete list of students enrolled in a class that is represented by the following collection of atoms:
enrolled(c,mike). enrolled(c,john). ...
Suppose also that we would like to define a new relation that holds iff the class needs a teaching assistant. In this particular school is true iff the number of students enrolled in the class is greater than . The definition can be given by a simple rule in the language of logic programs with aggregates:
where stands for the cardinality function. Let us call the resulting program .
The program is simple, has a clear intuitive meaning, and can be run on some of the existing ASP solvers. However, the situation is more complex than that. Unfortunately, currently there is no the language of logic programs with aggregates. Instead there is a comparatively large collection of such languages with different syntax and, even more importantly, different semantics [pdb07, nss02, SonP07, FaberPL11, gel02, KempS91]. As an illustration consider the following example:
Example 2
Let consist of the following rule:
Even for this seemingly simple program, there are different opinions about its meaning. According to [FaberPL11] the program has one answer set ; according to [gel02, KempS91] it has two answer sets: and .
In our judgment this and other similar “clashes of intuition” cause a serious impediment to the use of aggregates for knowledge representation and reasoning. In this paper we aim at addressing this problem by suggesting yet another logic programming language with aggregates, called , which is based on the following design principles:

the language should have a simple syntax and intuitive semantics based on understandable informal principles, and

the informal semantics should have clear and elegant mathematics associated with it.
In our opinion existing extensions of ASP by aggregates often do not have clear intuitive principles underlying the semantics of the new constructs. Moreover, some of these languages violate such original foundational principles of ASP as the rationality principle. The problem is compounded by the fact that some of the semantics of aggregates use rather nontrivial mathematical constructions which makes it difficult to understand and explain their intuitive meaning.
The semantics of is based on Vicious Circle Principle (VCP): no object or property can be introduced by the definition referring to the totality of objects satisfying this property. According to Feferman [fef] the principle was first formulated by Poincare [poin1906] in his analysis of paradoxes of set theory. Similar ideas were already successfully used in a collection of logic programming definitions of stratification including that of stratified aggregates (see, for instance, [FaberPL11]. Unfortunately, limiting the language to stratified aggregates eliminates some of the useful forms of circles (see Example 9 below). In this paper we give a new form of VCP which goes beyond stratification: cannot be introduced by the definition referring to a set of objects satisfying if this set can contain . Technically, the principle is incorporated in our new definition of answer set (which coincides with the original definition for programs without aggregates). The definition is short and simple. We hope that, combined with a number of informal examples, it will be sufficient for developing an intuition necessary for the use of the language. The paper is organized as follows. In Section 2, we define the syntax and semantics of . We give some properties of programs in Section 3 and present an algorithm for computing an answer set of an program in Section 4. A comparison with the existing work is done in Section 5, and we conclude the paper in Section 6.
2 Syntax and Semantics of
We start with defining the syntax and intuitive semantics of the language.
2.1 Syntax
Let be a (possibly sorted) signature with a finite collection of predicate, function, and object constants and be a finite collection of symbols used to denote functions from finite sets of terms of into integers. Terms and literals over signature are defined as usual and referred to as regular. Regular terms are called ground if they contain no variables and no occurrences of symbols for arithmetic functions. Similarly for literals. An aggregate term is an expression of the form
(1) 
where , is a collection of regular literals, and is a list of variables occurring in . We refer to an expression
(2) 
as a set name. An occurrence of a variable from in (2) is called bound within (2). If the condition from (2) contains no variables except those in then it is read as the set of all objects of the program satisfying . If contains other variables, say , then defines the function mapping possible values of these variables into sets where is the result of replacing by .
By an aggregate atom we mean an expression of the form
(3) 
where is or !=, and is constructed from variables and integers using arithmetic operations, , , , etc.
By eliterals we mean regular literals possibly preceded by default negation . The latter (former) are called negative (positive) eliterals.
A rule of is an expression of the form
(4) 
where is a disjunction of regular literals, and are collections of regular literals and regular literals preceded by respectively, and is a collection of aggregate atoms. All parts of the rule, including , can be empty. An occurrence of a variable in (4) not bound within any set name in this rule is called free in (4). A rule of is called ground if it contains no occurrences of free variables and no occurrences of arithmetic functions.
A program of is a finite collection of ’s rules. A program is ground if its rules are ground.
As usual for ASP based languages, rules of program with variables are viewed as collections of their ground instantiations. A ground instantiation of a rule is the program obtained from by replacing free occurrences of variables in by ground terms of and evaluating all arithmetic functions. If the signature is sorted (as, for instance, in [BalaiGZ13]) the substitutions should respect sort requirements for predicates and functions.
Clearly the grounding of an program is a ground program. The following examples illustrate the definition:
Example 3 (Grounding: all occurrences of the set variable are bound)
Consider a program with variables:
q(Y) : card{X:p(X,Y)} = 1, r(Y). r(a). r(b). p(a,b).
Here all occurrences of a set variable are bound; all occurrences of a variable are free. The program’s grounding, , is
q(a) : card{X:p(X,a)} = 1, r(a). q(b) : card{X:p(X,b)} = 1, r(b). r(a). r(b). p(a,b).
The next example deal with the case when some occurrences of the set variable in a rule are free and some are bound.
Example 4 (Grounding: some occurrences of a set variable are free)
Consider an program
r : card{X:p(X)} >= 2, q(X). p(a). p(b). q(a).
Here the occurrence of in is free. Hence the ground program is:
r : card{X:p(X)} >= 2, q(a). r : card{X:p(X)} >= 2, q(b). p(a). p(b). q(a).
Note that despite its apparent simplicity the syntax of differs substantially from syntax of most other logic programming languages allowing aggregates (with the exception of that in [gel02]). We illustrate the differences using the language presented in [FaberPL11]. (In what follows we refer to this language as .) While syntactically programs of can also be viewed as programs of the opposite is not true. Among other things allows parameters of aggregates to be substantially more complex than those of . For instance, an expression where is an aggregate atom of but not of . This construction which is different from a usual settheoretic notation used in is important for the definition of grounding. For instance the grounding of the first rule of program from Example 3 understood as a program of consists of rules
q(a) : card{a:p(a,a),b:p(b,a)} = 1, r(a). q(b) : card{a:p(a,b),b:p(b,b)} = 1, r(b).
which is not even a program of . Another important difference between the grounding methods of these languages can be illustrated by the grounding of program from Example 4 that looks as follows:
r : card{a:p(a)} >= 2, q(a). r : card{b:p(b)} >= 2, q(b). p(a). p(b). q(a).
Clearly this is substantially different from the grounding of from Example 4. In Section 5 we show that this difference in grounding reflects substantial semantic differences between the two languages.
2.2 Semantics
To define the semantics of programs we expand the standard definition of answer set from [gl88]. The resulting definition captures the rationality principle  believe nothing you are not forced to believe [GelK13]  and avoids vicious circles. As usual the definition of answer set is given for ground programs. Some terminology: a ground aggregate atom (where is one of the arithmetic relations allowed in the language) is true in a set of ground regular literals if ; otherwise the atom is false in .
Definition 1 (Aggregate Reduct)
The aggregate reduct of a ground program of with respect to a set of ground regular literals is obtained from by

removing from all rules containing aggregate atoms false in .

replacing every remaining aggregate atom by the set (which is called the reduct of the aggregate with respect to ).
(Here is the result of replacing variable by ground term ). The second clause of the definition reflects the principle of avoiding vicious circles – a rule with aggregate atom in the body can only be used if “the totality” of all objects satisfying has already being constructed. Attempting to apply this rule to define will either lead to contradiction or to turning the rule into tautology (see Examples 7 and 9).
Definition 2 (Answer Set)
A set of ground regular literals over the signature of a ground program of is an answer set of if it is an answer set of an aggregate reduct of with respect to .
We will illustrate this definition by a number of examples.
Example 5 (Example 3 Revisited)
Consider a program and its grounding from Example 3. It is easy to see that the aggregate reduct of the program with respect to any set not containing consists of the program facts, and hence is not an answer set of . However the program’s aggregate reduct with respect to consists of the program’s facts and the rule
q(b) : p(a,b),r(b).
Hence is an answer set of .
Example 6 (Example 4 Revisited)
Consider now the grounding
r : card{X:p(X)} >= 2, q(a). r : card{X:p(X)} >= 2, q(b). p(a). p(b). q(a).
of program from Example 4. Any answer set of this program must contain its facts. Hence . satisfies the body of the first rule and must also contain . Indeed, the aggregate reduct of with respect to consists of the facts of and the rules
r : p(a),p(b),q(a). r : p(a),p(b),q(b).
Hence is the answer set of .
Neither of the two examples above required the application of VCP. The next example shows how this principle influences our definition of answer sets and hence our reasoning.
Example 7 (Example 2 Revisited)
Consider a program from Example 2. The program, consisting of a rule
p(a) : card{X : p(X)}=1
is grounded. It has two candidate answer sets, and . The aggregate reduct of the program with respect to is the empty program. Hence, is an answer set of . The program’s aggregate reduct with respect to however is
p(a) : p(a).
The answer set of this reduct is empty and hence is the only answer of .
Example 7 shows how the attempt to define in terms of totality of turns the defining rule into a tautology. The next example shows how it can lead to inconsistency of a program.
Example 8 (Vicious Circles through Aggregates and Inconsistency)
Consider a program :
p(a). p(b) : card{X:p(X)} > 0.
Since every answer set of the program must contain , the program has two candidate answer sets: and . The aggregate reduct of with respect to is
p(a). p(b) : p(a).
The answer set of the reduct is and hence is not an answer set of . The reduct of with respect to is
p(a). p(b) : p(a),p(b).
Again its answer set is not equal to and hence is inconsistent (i.e., has no answer sets). The inconsistency is the direct result of an attempt to violate the underlying principle of the semantics. Indeed, the definition of refers to the set of objects satisfying that can contain which is prohibited by our version of VCP. One can, of course, argue that can be viewed as a reasonable collection of beliefs which can be formed by a rational reasoner associated with . After all, we do not need the totality of to satisfy the body of the rule defining . It is sufficient to know that contains . This is indeed true but this reasoning depends on the knowledge which is not directly incorporated in the definition of . If one were to replace by
p(a). p(b) : card{X:p(X), X != b} > 0.
then, as expected, the vicious circle principle will not be violated and the program will have unique answer set .
We end this section by a simple but practical example of a program which allows recursion through aggregates but avoids vicious circles.
Example 9 (Defining Digital Circuits)
Consider part of a logic program formalizing propagation of binary signals through simple digital circuits. We assume that the circuit does not have a feedback, i.e., a wire receiving a signal from a gate cannot be an input wire to this gate. The program may contain a simple rule
val(W,0) : gate(G, and), output(W, G), card{W: val(W,0), input(W, G)} > 0.
(partially) describing propagation of symbols through an and gate. Here holds iff the digital signal on a wire has value . Despite its recursive nature the definition of avoids vicious circle. To define the signal on an output wire of an and gate one needs to only construct a particular subset of input wires of . Since, due to absence of feedback in our circuit, can not belong to the latter set our definition is reasonable. To illustrate that our definition of answer set produces the intended result let us consider program consisting of the above rule and a collection of facts:
gate(g, and). output(w0, g). input(w1, g). input(w2, g). val(w1,0).
The grounding, , of consists of the above facts and the three rules of the form
val(w,0) : gate(g, and), output(w, g), card{W: val(W,0), input(W, g)} > 0.
where is , ,and .
Let . The aggregate reduct of with respect to is the collection of facts and the rules
val(w,0) : gate(g, and), output(w, g), input(w1, g), val(w1, 0).
where is , , and .
The answer set of the reduct is and hence is an answer set of . As expected it is the only answer set. (Indeed it is easy to see that other candidates do not satisfy our definition.)
3 Properties of programs
In this section we give some basic properties of programs. Propositions 1 and 2 ensure that, as in regular ASP, answer sets of program are formed using the program rules together with the rationality principle. Proposition 3 is the version of the basic technical tool used in theoretical investigations of ASP and its extensions. Proposition 4 shows that complexity of entailment in is the same as that in regular ASP.
We will use the following terminology: eliterals and are called contrary; denotes a literal contrary to eliteral ; a partial interpretation over signature is a consistent set of eliterals of this signature; an eliteral is true in if ; it is false if ; otherwise is undefined in . An aggregate atom is true in if is true, i.e., the value of on the set and the number satisfy property . Otherwise, the atom is false in . The head of a rule is satisfied by if at least one of its literals is true in ; the body of a rule is satisfied by if all of its aggregate atoms and eliterals are true in . A rule is satisfied by if its head is satisfied by or its body is not satisfied by .
Proposition 1 (Rule Satisfaction and Supportedness)
Let be an answer set of a ground program . Then

satisfies every rule of .

If then there is a rule from such that the body of is satisfied by and is the only atom in the head of which is true in . (It is often said that rule supports atom .)
Proposition 2 (Antichain Property)
Let be an answer set of an program . Then there is no answer set of such that is a proper subset of .
Proposition 3 (Splitting Set Theorem)
Let and be programs of 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 an answer set of iff is an answer set of and is an answer set of .
Proposition 4 (Complexity)
The problem of checking if a ground atom belongs to all answer sets of an program is complete.
4 An Algorithm for Computing Answer Sets
In this section we briefly outline an algorithm, called , for computing answer sets of programs. We follow the tradition and limit our attention to programs without classical negation. Hence, in this section we consider only programs of this type. By an atom we mean an eatom or an aggregate atom.
Definition 3 (Strong Satisfiability and Refutability)

An atom is strongly satisfied (strongly refuted) by a partial interpretation if it is true (false) in every partial interpretation containing ; an atom which is neither strongly satisfied nor strongly refuted by is undecided by .

A set of atoms is strongly satisfied by if all atoms in are strongly satisfied by ;

is strongly refuted by if for every partial interpretation containing , some atom of is false in .
For instance, an eatom is strongly satisfied (refuted) by iff it is true (false) in ; an atom which is true in is strongly satisfied by ; an atom which is false in is strongly refuted by ; and a set is strongly refuted by any partial interpretation.
consists of three functions: , , and . The main function, , is similar to that used in standard ASP algorithms (See, for instance, from [GelK13]). But unlike these functions which normally have two parameters  partial interpretation and program  has two additional parameters, and containing aggregate atoms that must be true and false respectively in the answer set under construction. returns where is an answer set of compatible with its parameters and if no such answer set exists. The ’s description will be omitted due to space limitations. The second function, , computes the consequences of its parameters  a program , a partial interpretation , and two above described sets and of aggregates atoms. Due to the presence of aggregates the function is sufficiently different from a typical function of ASP solvers so we describe it in some detail. The new value of , containing the desired consequences is computed by application of the following inference rules:

If the body of a rule is strongly satisfied by and all atoms in the head of except are false in then must be in .

If an atom belongs to the head of exactly one rule of then every other atom from the head of must have its complement in , the eatoms from the body of must be in and its aggregate atoms must be in .

If every atom of the head of a rule is false in , and is the only premise of which is either an undefined eatom or an aggregate atom not in , and the rest of the body is strongly satisfied by , then

if is an eatom, then the complement of must be in ,

if is an aggregate atom, then it must be in .


If the body of every rule with in the head is strongly refuted by , then must be in .
Given an interpretation , a program , inference rule and , let function return where , and are the results of applying inference rule to . (Note, that inference rule does not really use ). We also need the following terminology. We say that is compatible with if is not strongly refuted by ; is compatible with if no atom from is strongly satisfied by . A set of regular atoms is compatible with and if the set is compatible with and ; is compatible with if . The algorithm is listed below.
function Cons  
input:  partial interpretation , sets and of aggregate atoms compatible with ,  
and program with signature ;  
output:  
where is a partial interpretation such that ,  
and are sets of aggregate atoms such that and ,  
is compatible with and , and is a program with signature such that  
for every A,  
is an answer set of that is compatible with iff is an answer set of  
that is compatible with .  
if there is no answer set of compatible with ;  
var : set of eatoms; : set of aggregate atoms; : program;  
1.  Initialize , , and to be , , and respectively;  
2.  repeat  
3.  := ;  
4.  Remove from all the rules whose bodies are strongly falsified by ;  
5.  Remove from the bodies of rules of  
all negative eatoms true in and aggregate atoms strongly satisfied by ;  
6.  Nondeterministically select an inference rule from (1)–(4);  
8.  for every  
9.  := ;  
10.  := , := , := ;  
11.  until = ;  
12.  if is consistent, and are compatible with then  
13.  return ;  
14.  else return ; 
The third function, of our solver checks if interpretation is an answer set of a program . It computes the aggregate reduct of with respect to and applies usual checking algorithm (see, for instance, [KochLP03]).
Proposition 5 (Correctness of the Solver)
If, given a program , a partial interpretation , and sets and of aggregate atoms Solver() returns then is an answer set of compatible with , and . If there is no such answer set, the solver returns .
To illustrate the algorithm consider a program
: p(a). p(a) : card{X:q(X)} > 0. q(a) or p(b).
and trace where , , and are empty. starts by calling which computes the consequence (from the first rule of the program), (from the second rule of the program) and (from the fourth inference rule), and returns , and new ; is unchanged. then guesses to be true, i.e., , and calls again. does not produce any new consequences but finds that is not compatible with (line 12 of the algorithm). So, it returns , which causes to set to be false, i.e., , . then calls again which returns . finds that is complete and calls which returns true. Finally, returns as an answer set of the program.
5 Comparison with Other Approaches
There are a large number of approaches to the syntax and semantics of
extensions of ASP by aggregates. In this section we concentrate on
languages from [SonP07] and [FaberPL11] which we refer to as
and respectively. Due to multiple equivalence
results discussed in these papers
this
is sufficient to cover most of the approaches.
The main difference between the syntax of aggregates in
and is in treatment of variables
occurring in aggregate terms. uses usual logical concept of
bound and free occurrence of a variable (the occurrence of within
is bound while the occurrence of is free).
uses very different concepts of global and local
variable of a rule. A variable is local in rule if it
occurs solely in an aggregate term of ; otherwise, the variable is
global.
As the result, in , every aggregate
term can be replaced by a term
while it is not the case in .
In our opinion the approach of (and many
other languages and systems which adopted this syntax)
makes
declarative reading of aggregate terms substantially more
difficult
Example 10 (Variables in Aggregate Terms: Global versus Bound)
Consider program from Example 4. According to the meaning of an occurrence of an expression in the body of the program’s first rule changes if is replaced by a different variable. In , where is understood as bound this is not the case. This leads to substantial difference in grounding and in the semantics of the program. In has one answer set, . In answer sets of are those of . The answer set of the latter is .
Other semantic differences are due to the multiplicity of informal (and not necessarily clearly spelled out) principles underlying various semantics.
Example 11 (Vicious Circles in )
Consider the following program, , adopted from [SonP07]:
p(1) : p(0). p(0) : p(1). p(1) : count{X: p(X)} != 1.
which, if viewed as program, has one answer set . Informal argument justifying this result goes something like this: Clearly, satisfies the rules of the program. To satisfy the minimality principle no proper subset of should be able to do that, which is easily checked to be true. Faber et al use so called black box principle: “when checking stability they [aggregate literals] are either present in their entirety or missing altogether”, i.e., the semantics of does not consider the process of derivation of elements of the aggregate parameter. Note however, that the program’s definition of is given in terms of fully defined term , i.e., the definition contains a vicious circle. This explains why is not an answer set of in . In this particular example we are in agreement with which requires that the value of an aggregate atom can be computed before the rule with this atom in the body can be used in the construction of an answer set.
The absence of answer set of in may suggest that it adheres to our formalization of the VCP. The next example shows that it is not the case.
Example 12 (VCP and Constructive Semantics of aggregates)
Let us consider a program .
p(a) : count{X:p(X)} > 0. p(b) : not q. q : not p(b).
As shown in [SonP07] the program has two answer sets, and . If viewed as a program of , will have one answer set, . This happens because the construction of uses knowledge about properties of the aggregate atom of the first rule; the semantics of only takes into account the meaning of the parameter of the aggregate term. Both approaches can, probably, be successfully defended but, in our opinion, the constructive semantics has a disadvantage of being less general (it is only applicable to nondisjunctive programs), and more complex mathematically.
A key difference between our algorithm and those in the existing work [FaberPLDI08, GebserKKS09] is that the other work needs rather involved methods to ground the aggregates while our algorithm does not need to ground the aggregate atoms. As a result, the ground program used by our algorithm may be smaller, and our algorithm is simpler.
There is also a close connection between the above semantics of aggregates all of which are based on some notion of a reduct or a fixpoint computation and approaches in which aggregates are represented as special cases of more general constructs, such as propositional formulas [Ferraris05, HarLY13] and abstract constraint atoms [Marek04, LiuPST10, WangLZY12] (Our semantics can be easily extended to the latter). Some of the existing equivalence results allow us to establish the relationship between these approaches and . Others require further investigation.
6 Conclusion and Future Work
We presented an extension, , of ASP which allows for the representation of and reasoning with aggregates. We believe that the language satisfies design criteria of simplicity of syntax and formal and informal semantics. There are many ways in which this work can be continued. The first, and simplest, step is to expand by allowing choice rules similar to those of [nss02]. This can be done in a natural way by combining ideas from this paper and that from [gel02]. We also plan to investigate mapping of into logic programs with arbitrary propositional formulas. There are many interesting and, we believe, important questions related to optimization of the solver from Section 4. After clarity is reached in this area one will, of course, try to address the questions of implementation.
7 Acknowledgment
We would like to thank Amelia Harrison, Patrick Kahl, Vladimir Lifschitz, and Tran Cao Son for useful comments. The authors’ work was partially supported by NSF grant IIS1018031.
References
8 Appendix
In this appendix, given an program , a set of literals and a rule , we use to denote the rule obtained from in the aggregate reduct of with respect to . is , called an empty rule, if is discarded in the aggregate reduct. We use to denote the aggregate reduct of , i.e., .
Proposition 1 (Rule Satisfaction and Supportedness)
Let be an answer set of a ground program . Then

satisfies every rule of .

If then there is a rule from such that the body of is satisfied by and is the only atom in the head of which is true in . (It is often said that rule supports atom .)
Proof: Let
(1) be an answer set of .
We first prove satisfies every rule of . Let be a rule of such that
(2) satisfies the body of .
Statement (2) implies that every aggregate atom, if there is any, of the body of is satisfied by . By the definition of the aggregate reduct, there must be a nonempty rule such that
(3) .
By the definition of aggregate reduct, satisfies the body of iff it satisfies that of . Therefore, (2) and (3) imply that
(4) satisfies the body of .
By the definition of answer set of , (1) implies that
(5) is an answer set of .
Since is an ASP program, (3) and (5) imply that
(6) satisfies .
Statements (4) and (6) imply satisfies the head of and thus the head of because and and have the same head.
Therefore is satisfied by , which concludes our proof of the first part of the proposition.
We next prove the second part of the propostion. Consider . (1) implies that is an answer set of . By the supportedness Lemma for ASP programs [GelK13], there is a rule such that
(7) supports .
Let be a rule such that . By the definition of aggregate reduct,
(8) satisfies the body of iff satisfies that of .
Since and have the same heads, (7) and (8) imply that rule of supports in , which concludes the proof of the second part of the proposition.
Proposition 2 (Antichain Property)
Let be an answer set of an program . Then there is no answer set of such that is a proper subset of .
Proof: Let us assume that there are and such that
(1) and
(2) and are answer sets of
and show that .
Let and be the aggregate reducts of with respect to and respectively. Let us first show that satisfies the rules of . Consider
(3) .
By the definition of aggregate reduct there is such that
(4) .
Consider
(5) .
If contains no aggregate atoms then
(6) .
By (5) and (6), and hence, by (2) satisfies .
Assume now that contains one aggregate term, , i.e. is of the form
(7)
where is some property of the aggregate.
Then has the form
(8)
where
(9) and satisfies condition .
Let
(10)
and consider two cases:
(11a) .
In this case does not hold. Hence, . Since we have that , the body of rule (8) is not satisfied by , and hence the rule (8) is.
(11b) .
Then has the form
(12)
where
(13) and satisfies condition .
Assume that satisfies the body, , of rule (8). Then
(14)
This, together with (9) and (10) implies
(15) .
From (1), (9), and (10) we have . Hence
(16) .
This means that satisfies the body of and hence it satisfies and, therefore, .
Similar argument works for rules containing multiple aggregate atoms and, therefore, satisfies .
Since is a minimal set satisfying and satisfies and we have that .
This completes our proof.
Proposition 3 (Splitting Set Theorem)
Let

and be ground programs of such that no atom occurring in is unifiable with any atom occurring in the heads of ,

be a set of ground literals containing all head literals of but no head literals of ,
Then
(3) is an answer set of
iff
(4a) is an answer set of and
(4b) is an answer set of .
Proof. By the definitions of answer set and aggregate reduct
(3) holds iff
(5) is an answer set of
It is easy to see that conditions (1), (2), and the definition of imply that , , and satisfy condition of the splitting set theorem for ASP [LifschitzT94]. Hence
(5) holds iff
(6a) is an answer set of
and
(6b) is an answer set of .
To complete the proof it suffices to show that
(7) Statements (6a) and (6b) hold iff (4a) and (4b) hold.
By definition of ,
(8)
and hence, by the definition of answer set we have
(9) (6b) iff (4b).
Now notice that from (4b), clause 2 of Proposition 1, and conditions (1) and (2) of our theorem we have that for any ground instance of a literal occurring in an aggregate atom of
(10) iff
and, hence
(11) .
From (9), (11), and the definition of answer set we have that
(12) (6a) iff (4a)
which completes the proof of our theorem.
Lemma 1
Checking whether a set of literals is an answer set of , a program with aggregates, is in coNP.
Proof: To prove that is not an answer set of , we first check if is not a model of the aggregate reduct of , which is in polynomial time. If is not a model, is not an answer set of . Otherwise, we guess a set of , and check if is a model of the aggregate reduct of and . This checking is also in polynomial time. Therefore, the problem of checking whether a set of literals is an answer set of is in coNP.
Proposition 4 (Complexity)
The problem of checking if a ground atom belongs to all answer sets of an program is complete.
Proof: First we show that the cautious reasoning problem is in . We verify that a ground atom is not a cautious consequence of a program as follows: Guess a set of literals and check that (1) is an answer set for , and (2) is not true wrt . Task (2) is clearly polynomial, while (1) is in coNP by virtue of Lemma 1. The problem therefore lies in .
Next, cautious reasoning over programs without aggregates is hard by [DantsinEGV01]. Therefore, cautious reasoning over programs with aggregates is hard too.
In summary, cautious reasoning over programs with aggregates is complete.
Footnotes
 The other difference in reading of is related to the treatment of variable . In the variable is bound by an unseen existential quantifier. If all the variables are local then is really . In is free. Both approaches are reasonable but we prefer to deal with the different possible readings by introducing an explicit existential quantifier as in Prolog. It is easy semantically and we do not discuss it in the paper.