Introduction
Disjunctive Logic Programming (DLP) is a powerful paradigm for knowledge representation and reasoning, capable of solving complex problems within the $\Sigma^P_2$ complexity class. However, a significant usability gap exists when modeling real-world constraints involving arithmetic, such as budget limits or team sizes. This paper introduces $DLP^{\mathcal{A}}$, an extension to the DLV system that incorporates aggregate functions like #sum, #count, #min, and #max. These additions allow for more natural problem modeling without increasing the underlying computational complexity.
The Problem: Expressivity vs. Usability
While standard DLP is theoretically expressive, simple tasks involving sets—such as calculating a total salary—are cumbersome to implement. Traditionally, programmers had to define successor relations and recursive predicates to simulate aggregation. This approach suffers from two primary drawbacks:
- Readability: The resulting code is unintuitive and difficult to maintain.
- Efficiency: The grounding process (converting abstract logic into a propositional format) often becomes quadratic relative to the number of items, leading to excessive memory consumption and slow performance.
The $DLP^{\mathcal{A}}$ Framework
The authors address these issues by defining formal semantics and a robust implementation for aggregates:
- Syntax and Semantics: The extension introduces symbolic sets and aggregate functions. Crucially, the semantics handle multisets, allowing the system to distinguish between unique entities and non-unique values (e.g., multiple employees with the same salary).
- Aggregate-Stratification: To prevent logical paradoxes where a set's contents depend on its own aggregate value, the authors implemented a stratification rule that restricts certain recursive definitions.
- Implementation in DLV: The features were integrated into the DLV system using an "Intelligent Grounding" module. This module standardizes aggregates into auxiliary rules and employs "Duplicate Sets Recognition" via hashing to avoid re-calculating the same set multiple times.
Experimental Evaluation and Results
The researchers evaluated $DLP^{\mathcal{A}}$ using two benchmark problems: university timetabling and guest seating. The results demonstrate that the use of aggregates leads to significantly more succinct groundings and faster execution.
Seating Problem Performance
The seating problem involves assigning guests to tables subject to capacity and social constraints. As shown in the comparative data, standard DLV struggles to scale, timing out after only 16 guests. In contrast, $DLP^{\mathcal{A}}$ handles up to 150 guests efficiently, maintaining a manageable instantiation size.
Timetabling Problem Performance
The timetabling problem involves scheduling lectures for various student groups. $DLP^{\mathcal{A}}$ consistently outperforms standard DLV by an order of magnitude in execution time. While standard DLV fails on the largest instances, $DLP^{\mathcal{A}}$ provides solutions in under a minute.
Key Insights
A major theoretical contribution of this work is the proof of complexity neutrality: adding aggregate functions does not increase the computational complexity of the language. The performance gains observed are primarily due to the reduction in grounding size. By avoiding the generation of millions of intermediate recursive facts, $DLP^{\mathcal{A}}$ maintains a much smaller memory footprint and higher speed.
Conclusion and Future Work
The integration of aggregate functions into DLV represents a significant step forward in making Disjunctive Logic Programming practical for real-world applications. Future work will focus on relaxing recursion restrictions (moving beyond aggregate-stratification), expanding the library of operators (e.g., #avg), and further optimizing the model generator's heuristics for aggregate-heavy programs.
Summary updated