Why Can’t You Behave? Non-termination Analysis of Direct Recursive Rules with Constraints

  • Thom Frühwirth
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9718)


This paper is concerned with rule-based programs that go wrong. The unwanted behavior of rule applications is non-termination or failure of a computation. We propose a static program analysis of the non-termination problem for recursion in the Constraint Handling Rules (CHR) language.

CHR is an advanced concurrent declarative language involving constraint reasoning. It has been closely related to many other rule-based approaches, so the results are of a more general interest. In such languages, non-termination is due to infinite applications of recursive rules. Failure is due to accumulation of contradicting constraints during the computation.

We give theorems with so-called misbehavior conditions for potential non-termination and failure (as well as definite termination) of linear direct recursive simplification rules. Logical relationships between the constraints in a recursive rule play a crucial role in this kind of program analysis. We think that our approach can be extended to other types of recursion and to a more general class of rules. Therefore this paper can serve as a basic reference and a starting point for further research.


Logic Programming Operational Semantic Rule Application Constraint Logic Programming Recursive Rule 
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.



We thank the anonymous referees for their helpful suggestions on how to improve the paper.


  1. 1.
    Betz, H., Raiser, F., Frühwirth, T.: A complete and terminating execution model for constraint handling rules. Theor. Pract. Log. Program. 10, 597–610 (2010)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Brockschmidt, M., Ströder, T., Otto, C., Giesl, J.: Automated detection of non-termination and NullPointerExceptions for Java bytecode. In: Beckert, B., Damiani, F., Gurov, D. (eds.) FoVeOOS 2011. LNCS, vol. 7421, pp. 123–141. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  3. 3.
    Endrullis, J., Zantema, H.: Proving non-termination by finite automata. In: LIPIcs-Leibniz International Proceedings in Informatics, vol. 36. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2015)Google Scholar
  4. 4.
    Frühwirth, T.: Constraint Handling Rules (Monography). Cambridge University Press, Cambridge (2009)CrossRefzbMATHGoogle Scholar
  5. 5.
    Frühwirth, T.: Constraint handling rules - what else? In: Bassiliades, N., Gottlob, G., Sadri, F., Paschke, A., Roman, D. (eds.) RuleML 2015. LNCS, vol. 9202, pp. 13–34. Springer, Heidelberg (2015)CrossRefGoogle Scholar
  6. 6.
    Frühwirth, T.: A devil’s advocate against termination of direct recursion. In: Proceedings of the 17th International Symposium on Principles and Practice of Declarative Programming, pp. 103–113. ACM (2015)Google Scholar
  7. 7.
    Frühwirth, T.: The CHR Web Site. Ulm University (2016).
  8. 8.
    Gupta, A., Henzinger, T.A., Majumdar, R., Rybalchenko, A., Xu, R.-G.: Proving non-termination. ACM Sigplan Not. 43(1), 147–158 (2008)CrossRefzbMATHGoogle Scholar
  9. 9.
    Le, T.C., Qin, S., Chin, W.-N.: Termination and non-termination specification inference. In: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 489–498. ACM (2015)Google Scholar
  10. 10.
    Liang, S., Kifer, M.: A practical analysis of non-termination in large logic programs. Theor. Practi. Log. Program. 13(4–5), 705–719 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Payet, É.: Loop detection in term rewriting using the eliminating unfoldings. Theoret. Comput. Sci. 403(2), 307–327 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Payet, É., Mesnard, F.: A non-termination criterion for binary constraint logic programs. Theor. Pract. Log. Program. 9(02), 145–164 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Payet, É., Mesnard, F., Spoto, F.: Non-termination analysis of Java bytecode (2014). CoRR abs/1401.5292Google Scholar
  14. 14.
    Voets, D., De Schreye, D.: A new approach to non-termination analysis of logic programs. In: Hill, P.M., Warren, D.S. (eds.) ICLP 2009. LNCS, vol. 5649, pp. 220–234. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  1. 1.Ulm UniversityUlmGermany

Personalised recommendations