On Compiling Linear Logic Programs with Comprehensions, Aggregates and Rule Priorities

  • Flavio Cruz
  • Ricardo Rocha
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9131)


Linear logic programs are challenging to implement efficiently because facts are asserted and retracted frequently. Implementation is made more difficult with the introduction of useful features such as rule priorities, which are used to specify the order of rule inference, and comprehensions or aggregates, which are mechanisms that make data iteration and gathering more intuitive. In this paper, we describe a compilation scheme for transforming linear logic programs enhanced with those features into efficient C++ code. Our experimental results show that compiled logic programs are less than one order of magnitude slower than hand-written C programs and much faster than interpreted languages such as Python.


Hash Table Fact Expression Rule Priority Linear Logic Abstract Syntax 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Betz, H., Frühwirth, T.: A linear-logic semantics for constraint handling rules. In: van Beek, P. (ed.) CP 2005. LNCS, vol. 3709, pp. 137–151. Springer, Heidelberg (2005) Google Scholar
  2. 2.
    Cruz, F., Rocha, R., Goldstein, S., Pfenning, F.: A Linear Logic Programming Language for Concurrent Programming over Graph Structures. Journal of Theory and Practice of Logic Programming, International Conference on Logic Programming, Special Issue pp. 493–507 (July 2014)Google Scholar
  3. 3.
    Cruz, F., Rocha, R., Goldstein, S.C.: Design and implementation of a multithreaded virtual machine for executing linear logic programs. In: International Symposium on Principles and Practice of Declarative Programming, pp. 43–53. ACM Press, September 2014Google Scholar
  4. 4.
    De Koninck, L., Stuckey, P.J., Duck, G.J.: Optimizing compilation of chr with rule priorities. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 32–47. Springer, Heidelberg (2008) Google Scholar
  5. 5.
    Frühwirth, T.: Constraint handling rules. In: Podelski, A. (ed.) Constraint Programming: Basics and Trends. LNCS, vol. 910, pp. 90–107. Springer, Heidelberg (1995) Google Scholar
  6. 6.
    Gonzalez, J., Low, Y., Guestrin, C.: Residual splash for optimally parallelizing belief propagation. In: Artificial Intelligence and Statistics (2009)Google Scholar
  7. 7.
    Holzbaur, C., de la Banda, M.J.G., Stuckey, P.J., Duck, G.J.: Optimizing compilation of constraint handling rules in HAL. CoRR cs.PL/0408025 (2004)Google Scholar
  8. 8.
    Low, Y., Gonzalez, J., Kyrola, A., Bickson, D., Guestrin, C., Hellerstein, J.M.: Graphlab: a new framework for parallel machine learning. In: Conference on Uncertainty in Artificial Intelligence (UAI), pp. 340–349 (2010)Google Scholar
  9. 9.
    Wuille, P., Schrijvers, T., Demoen, B.: CCHR: the fastest CHR implementation, in C. In: Workshop on Constraint Handling Rules, pp. 123–137 (2007)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  1. 1.Carnegie Mellon UniversityPittsburghUSA
  2. 2.CRACS and INESC TEC and Faculty of SciencesUniversity of PortoPortoPortugal

Personalised recommendations