skip to main content
research-article
Free Access

The computational power and complexity of constraint handling rules

Published:20 February 2009Publication History
Skip Abstract Section

Abstract

Constraint Handling Rules (CHR) is a high-level rule-based programming language which is increasingly used for general-purpose programming. We introduce the CHR machine, a model of computation based on the operational semantics of CHR. Its computational power and time complexity properties are compared to those of the well-understood Turing machine and Random Access Memory machine. This allows us to prove the interesting result that every algorithm can be implemented in CHR with the best known time and space complexity. We also investigate the practical relevance of this result and the constant factors involved. Finally we expand the scope of the discussion to other (declarative) programming languages.

References

  1. Adelson-Velsky, G. M. and Landis, E. M. 1962. An algorithm for the organization of information. Doklady Akademii Nauk SSSR 146, 263--266.Google ScholarGoogle Scholar
  2. Aho, A. V., Hopcroft, J. E., and Ullman, J. D. 1975. The Design and Analysis of Computer Algorithms. Addison-Wesley Longman, Boston. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Cherkassky, B. V., Goldberg, A. V., and Radzik, T. 1996. Shortest paths algorithms: Theory and experimental evaluation. Math. Program. 73, 129--174.Google ScholarGoogle ScholarCross RefCross Ref
  4. Clavel, M., Durán, F., Eker, S., Lincoln, P., et al. 2002. Maude: Specification and programming in rewriting logic. Theor. Comput. Sci. 285, 2, 187--243. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Clocksin, W. F. and Mellish, C. S. 1984. Programming in Prolog. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. De Koninck, L., Schrijvers, T., and Demoen, B. 2007. The correspondence between the Logical Algorithms language and CHR. In Proceedings of the 23rd International Conference on Logic Programming (ICLP'07), V. Dahl and I. Niemelä, Eds. Lecture Notes in Computer Science, vol. 4670. Springer, 209--223.Google ScholarGoogle Scholar
  7. Dijkstra, E. W. 1959. A note on two problems in connexion with graphs. Numerische Math. 1, 4, 269--271.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Duck, G. J. 2005. Compilation of Constraint Handling Rules. Ph.D. thesis, University of Melbourne, Victoria, Australia.Google ScholarGoogle Scholar
  9. Duck, G. J. and Schrijvers, T. 2005. Accurate functional dependency analysis for Constraint Handling Rules. In Proceedings of the 2nd Workshop on Constraint Handling Rules (CHR'05), T. Schrijvers and T. Frühwirth, Eds., 109--124.Google ScholarGoogle Scholar
  10. Duck, G. J., Stuckey, P. J., García de la Banda, M., and Holzbaur, C. 2004. The refined operational semantics of Constraint Handling Rules. In Proceedings of the 20th International Conference on Logic Programming (ICLP'04), B. Demoen and V. Lifschitz, Eds. Lecture Notes in Computer Science, vol. 3132, 90--104.Google ScholarGoogle Scholar
  11. Duck, G. J., Stuckey, P. J., and Sulzmann, M. 2006. Observable confluence for Constraint Handling Rules. In Proceedings of the 3rd Workshop on Constraint Handling Rules (CHR'06), T. Schrijvers and T. Frühwirth, Eds., 61--76.Google ScholarGoogle Scholar
  12. Eker, S. 2003. Associative-Commutative rewriting on large terms. In Proceedings of the Rewriting Techniques and Applications (RTA'03), R. Nieuwenhuis, Ed. Lecture Notes in Computer Science, vol. 2706. Springer, 14--29.Google ScholarGoogle ScholarCross RefCross Ref
  13. Forgy, C. L. 1982. Rete: A fast algorithm for the many pattern/many object pattern match problem. Artif. Intell. 19, 1, 17--37.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Fredman, M. L. and Tarjan, R. E. 1987. Fibonacci heaps and their uses in improved network optimization algorithms. J. ACM 34, 3, 596--615. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Friedman-Hill, E. 2003. Jess in Action: Java Rule-Based Systems. Manning Publications. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Frühwirth, T. 1992. Constraint simplification rules. Tech. rep. ECRC-92-18, European Computer-Industry Research Centre, Munich, Germany. July.Google ScholarGoogle Scholar
  17. Frühwirth, T. 1998. Theory and practice of Constraint Handling Rules. J. Logic Program. 37, 1--3, 95--138.Google ScholarGoogle ScholarCross RefCross Ref
  18. Frühwirth, T. 2001. As time goes by II: More automatic complexity analysis of concurrent rule programs. In Proceedings of the Quantitative Aspects of Programming Languages (QAPL'01), A. D. Pierro and H. Wiklicky, Eds. Electronic Notes in Theoretical Computer Science, vol. 59, 3. Elsevier, 185--206.Google ScholarGoogle Scholar
  19. Frühwirth, T. 2002. As time goes by: Automatic complexity analysis of concurrent rule programs. In Proceedings of the 8th International Conference on Principles of Knowledge Representation and Reasoning (KR'02), D. Fensel et al., Eds. Morgan Kaufmann, 547--557.Google ScholarGoogle Scholar
  20. Fr&uhuml;wirth, T. 2009. Constraint Handling Rules. Cambridge University Press. To appear.Google ScholarGoogle Scholar
  21. Frühwirth, T. and Abdennadher, S. 2003. Essentials of Constraint Programming. Cognitive Technologies. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Ganzinger, H. and McAllester, D. A. 2002. Logical algorithms. In Proceedings of the 18th International Conference on Logic Programming (ICLP'02). Lecture Notes in Computer Science, vol. 2401. Springer 209--223. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Giarratano, J. C. and Riley, G. 1994. Expert Systems: Principles and Programming. PWS Publishing, Boston, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Hartmanis, J. and Stearns, R. E. 1965. On the computational complexity of algorithms. Trans. Amer. Math. Soc. 117, 285--306.Google ScholarGoogle ScholarCross RefCross Ref
  25. Holzbaur, C. and Frühwirth, T. 1998. CHR reference manual. Tech. rep. TR-98-01, Österreichisches Forschungsinstitut für Artificial Intelligence, Vienna, Austria.Google ScholarGoogle Scholar
  26. Holzbaur, C. and Frühwirth, T. 1999. Compiling constraint candling rules into prolog with attributed variables. In Proceedings of the 1st International Conference on Principles and Practice of Declarative Programming (PPDP'99), G. Nadathur, Ed. Lecture Notes in Computer Science, vol. 1702. Springer, 117--133. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Holzbaur, C., García de la Banda, M., Stuckey, P. J., and Duck, G. J. 2005. Optimizing compilation of constraint handling rules in HAL. Theory Pract. Logic Program. SI Constraint Handling Rules 5, 4-5, 503--531. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Hopcroft, J. E., Motwani, R., and Ullman, J. D. 2001. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley Longman, Boston, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Hudak, P., Hughes, J., Jones, S. P., and Wadler, P. 2007. A history of Haskell: Being lazy with class. In Proceedings of the 3rd ACM SIGPLAN Conference on History of Programming Languages (HOPL-III). ACM Press, 1--55. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Marriott, K. and Stuckey, P. J. 1998. Programming with Constraints: An Introduction. MIT Press, Cambridge, MA.Google ScholarGoogle ScholarCross RefCross Ref
  31. Mazur, N. 2004. Compile-Time garbage collection for the declarative language Mercury. Ph.D. thesis, K. U. Leuven, Leuven, Belgium.Google ScholarGoogle Scholar
  32. Miranker, D. P., Brant, D. A., Lofaso, B., and Gadbois, D. 1990. On the performance of lazy matching in production systems. In Proceedings of the 8th National Conference on Artificial Intelligence (AAAI'90), T. Dietterich and W. Swartout, Eds. MIT Press, Boston, MA, 685--692.Google ScholarGoogle Scholar
  33. Morrison, D. R. 1968. PATRICIA—Practical algorithm to retrieve information coded in alphanumeric. J. ACM 15, 4, 514--534. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Okasaki, C. and Gill, A. 1998. Fast mergeable integer maps. In Proceedings of the Workshop on ML, 77--86.Google ScholarGoogle Scholar
  35. Savage, J. E. 1998. Models of Computation. Addison-Wesley Longman, Boston, MA.Google ScholarGoogle Scholar
  36. Savitch, W. J. 1978. The influence of the machine model on computational complexity. In Interfaces between Computer Science and Operations Research, J. Lenstra et al., Eds. Mathematical Centre Tracts, vol. 99. Centre for Mathematics and Computer Science, Amsterdam, 1--32.Google ScholarGoogle Scholar
  37. Schrijvers, T. 2005. Analyses, optimizations and extensions of constraint handling rules. Ph.D. thesis, K. U. Leuven, Leuven, Belgium.Google ScholarGoogle Scholar
  38. Schrijvers, T. and Demoen, B. 2004. The K. U. Leuven CHR system: Implementation and application. In Proceedings of the 1st Workshop on Constraint Handling Rules (CHR'04), Selected Contributions, T. Frühwirth and M. Meister, Eds. Ulm, Germany.Google ScholarGoogle Scholar
  39. Schrijvers, T. and Frühwirth, T. 2006. Optimal union-find in constraint handling rules. Theory Pract. Logic Program. 6, 1--2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Sneyers, J. 2008. Turing-complete subclasses of CHR. In Proceedings of the 24th International Conference on Logic Programming (ICLP'08), M. García de la Banda and E. Pontelli, Eds. Lecture Notes in Computer Science, vol. 5366. Springer, 759--763. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Sneyers, J. and Frühwirth, T. 2008. Generalized CHR machines. In Proceedings of the 5th Workshop on Constraint Handling Rules (CHR'08), T. Schrijvers et al., Eds.Google ScholarGoogle Scholar
  42. Sneyers, J., Schrijvers, T., and Demoen, B. 2006a. Dijkstra's algorithm with Fibonacci heaps: An executable description in CHR. In Proceedings of the 20th Workshop on Logic Programming (WLP'06).Google ScholarGoogle Scholar
  43. Sneyers, J., Schrijvers, T., and Demoen, B. 2006b. Memory reuse for CHR. In Proceedings of the 22nd International Conference on Logic Programming (ICLP'06), S. Etalle and M. Truszczynski, Eds. Lecture Notes in Computer Science, vol. 4079. Springer, 72--86.Google ScholarGoogle Scholar
  44. Sneyers, J., Van Weert, P., De Koninck, L., and Schrijvers, T. 2009. As time goes by: Constraint handling rules—A survey of CHR research between 1998 and 2007. Theory Pract. Logic Program. Submitted.Google ScholarGoogle Scholar
  45. Somogyi, Z., Henderson, F., and Conway, T. 1996. The execution algorithm of Mercury, An efficient purely declarative logic programming language. J. Logic Program. 29, 1-3, 17--64.Google ScholarGoogle ScholarCross RefCross Ref
  46. Tarjan, R. E. and van Leeuwen, J. 1984. Worst-Case analysis of set union algorithms. J. ACM 31, 2, 245--281. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Turing, A. M. 1936. On computable numbers, with an application to the Entscheidungsproblem. Proc. London Math. Soc. 2, 42, 230--265.Google ScholarGoogle Scholar
  48. van Emde Boas, P. 1990. Machine models and simulations. In Handbook of Theoretical Computer Science, Volume A: Algorithms and Complexity, J. van Leeuwen, Ed. Elsevier. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Van Weert, P., Schrijvers, T., and Demoen, B. 2005. K. U. Leuven JCHR: A user-friendly, flexible and efficient CHR system for Java. In Proceedings of the 2nd Workshop on Constraint Handling Rules (CHR'05), T. Schrijvers and T. Frühwirth, Eds., 47--62.Google ScholarGoogle Scholar
  50. Van Weert, P., Sneyers, J., Schrijvers, T., and Demoen, B. 2006. Extending CHR with negation as absence. In Proceedings of the 3rd Workshop on Constraint Handling Rules (CHR'06), T. Schrijvers and T. Frühwirth, Eds. K. U. Leuven, Department of Computer Science. Venice, Italy, 125--140.Google ScholarGoogle Scholar
  51. Wuille, P., Schrijvers, T., and Demoen, B. 2007. CCHR: The fastest CHR implementation, in C. In Proceedings of the 4th Workshop on Constraint Handling Rules (CHR'07), K. Djelloul et al., Eds., 123--137.Google ScholarGoogle Scholar

Index Terms

  1. The computational power and complexity of constraint handling rules

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • Published in

              cover image ACM Transactions on Programming Languages and Systems
              ACM Transactions on Programming Languages and Systems  Volume 31, Issue 2
              February 2009
              128 pages
              ISSN:0164-0925
              EISSN:1558-4593
              DOI:10.1145/1462166
              Issue’s Table of Contents

              Copyright © 2009 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 20 February 2009
              • Accepted: 1 April 2008
              • Revised: 1 March 2008
              • Received: 1 December 2006
              Published in toplas Volume 31, Issue 2

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • research-article
              • Research
              • Refereed

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!