Incremental Evaluation of Lattice-Based Aggregates in Logic Programming Using Modular TCLP
Aggregates are used to compute single pieces of information from separate data items, such as records in a database or answers to a query to a logic program. The maximum and minimum are well-known examples of aggregates. The computation of aggregates in Prolog or variant-based tabling can loop even if the aggregate at hand can be finitely determined. When answer subsumption or mode-directed tabling is used, termination improves, but the behavior observed in existing proposals is not consistent. We present a framework to incrementally compute aggregates for elements in a lattice. We use the entailment and join relations of the lattice to define (and compute) aggregates and decide whether some atom is compatible with (entails) the aggregate. The semantics of the aggregates defined in this way is consistent with the LFP semantics of tabling with constraints. Our implementation is based on the TCLP framework available in Ciao Prolog, and improves its termination properties w.r.t. similar approaches. Defining aggregates that do not fit into the lattice structure is possible, but some properties guaranteed by the lattice may not hold. However, the flexibility provided by this possibility justifies its inclusion. We validate our design with several examples and we evaluate their performance.
- 1.Arias, J., Carro, M.: Description and evaluation of a generic design to integrate CLP and tabled execution. In: International Symposium on Principles and Practice of Declarative Programming, pp. 10–23. ACM, September 2016Google Scholar
- 2.Arias, J., Carro, M.: Description, implementation, and evaluation of a generic design for tabled CLP. Theory and Practice of Logic Programming (2018) (to appear)Google Scholar
- 5.Cui, B., Warren, D.S.: A system for tabled constraint logic programming. In: Lloyd, J., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Palamidessi, C., Pereira, L.M., Sagiv, Y., Stuckey, P.J. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 478–492. Springer, Heidelberg (2000). https://doi.org/10.1007/3-540-44957-4_32CrossRefGoogle Scholar
- 8.Kemp, D.B., Stuckey, P.J.: Semantics of logic programs with aggregates. In: Saraswat, V.A., Ueda, K. (eds.) International Symposium on Logic Programming, pp. 387–401. October 1991Google Scholar
- 10.Picard, G.: Artificial intelligence - implementing minimax with prolog. https://www.emse.fr/~picard/cours/ai/minimax/
- 17.Zhou, N.F., Kameya, Y., Sato, T.: Mode-directed tabling for dynamic programming, machine learning, and constraint solving. In: International Conference on Tools with Artificial Intelligence, No. 2, pp. 213–218. IEEE, October 2010Google Scholar