Design and Implementation of Aggregate Functions in the DLV System
Disjunctive Logic Programming (DLP) is a very expressive formalism: it allows for expressing every property of finite structures that is decidable in the complexity class SigmaP2 (= NP^NP). Despite this high expressiveness, there are some simple properties, often arising in real-world applications, which cannot be encoded in a simple and natural manner. Especially properties that require the use of arithmetic operators (like sum, times, or count) on a set or multiset of elements, which satisfy some conditions, cannot be naturally expressed in classic DLP. To overcome this deficiency, we extend DLP by aggregate functions in a conservative way. In particular, we avoid the introduction of constructs with disputed semantics, by requiring aggregates to be stratified. We formally define the semantics of the extended language (called DLP^A), and illustrate how it can be profitably used for representing knowledge. Furthermore, we analyze the computational complexity of DLP^A, showing that the addition of aggregates does not bring a higher cost in that respect. Finally, we provide an implementation of DLP^A in DLV – a state-of-the-art DLP system – and report on experiments which confirm the usefulness of the proposed extension also for the efficiency of computation.
💡 Research Summary
The paper addresses a well‑known limitation of classic Disjunctive Logic Programming (DLP): while DLP is expressive enough to capture every property of finite structures decidable in Σ₂^P (NP^NP), it lacks a natural way to express arithmetic aggregations such as sum, count, or product over sets or multisets that satisfy certain conditions. To fill this gap, the authors introduce an extension called DLP^A, which adds aggregate functions in a conservative, semantics‑preserving manner. The key design principle is stratification: aggregates may only appear in rules that do not participate in cyclic dependencies, thereby eliminating ambiguous interpretations and keeping the language’s semantics well‑defined.
Formally, an aggregate atom (e.g., sum{X : p(X)} >= 10) is associated with a multiset of values derived from the underlying predicate and a guard condition. The semantics of DLP^A is defined in two steps. First, for each aggregate atom the possible multisets are generated. Second, a minimal model (or stable model) is sought that simultaneously satisfies all ordinary atoms and those aggregate atoms whose associated multisets meet the guard. This construction extends the standard stable‑model semantics of DLP without altering its fundamental properties.
Complexity analysis shows that the addition of aggregates does not raise the computational difficulty of the language. The decision problem for the existence of an answer set remains Σ₂^P‑complete, and model checking stays in Π₂^P, exactly as in plain DLP. Consequently, from a theoretical standpoint, DLP^A offers richer modeling capabilities at no extra cost in worst‑case complexity.
On the implementation side, the authors integrate DLP^A into the state‑of‑the‑art DLV system. A new parser recognises aggregate syntax, and a preprocessing phase (“aggregate preprocessing”) builds the relevant multisets, sorts them, and prunes irrelevant candidates before grounding. This reduces the size of the grounded program dramatically, leading to lower memory consumption and faster solving. The existing SAT‑based solver is then used unchanged, with the only addition being constraints that enforce the aggregate conditions.
Experimental evaluation on benchmark problems that naturally involve aggregation—such as scheduling, network flow, and graph coloring—compares classic DLP encodings with the new DLP^A encodings. The results demonstrate that DLP^A yields more concise programs (often a 30 % reduction in rule count), produces smaller groundings (up to 50 % fewer ground rules), and, in many cases, speeds up solving by a factor of two or more. In scenarios where aggregates are central, the performance gap widens, confirming that the extension is not only expressive but also practically beneficial.
In summary, the paper presents a rigorous, stratified approach to adding aggregates to DLP, proves that the extension preserves the original complexity class, and validates the design with a concrete implementation in DLV that improves both usability and efficiency. Future work is suggested on relaxing the stratification requirement, exploring alternative semantics for non‑stratified aggregates, and applying DLP^A to large‑scale data‑intensive applications.
Comments & Academic Discussion
Loading comments...
Leave a Comment