Hostname: page-component-848d4c4894-8kt4b Total loading time: 0 Render date: 2024-07-07T08:53:05.477Z Has data issue: false hasContentIssue false

Implementing Backjumping by Means of Exception Handling

Published online by Cambridge University Press:  24 August 2023

WŁODZIMIERZ DRABENT*
Affiliation:
Institute of Computer Science, Polish Academy of Sciences, Warsaw, Poland (e-mail: drabent@ipipan.waw.pl)

Abstract

We discuss how to implement backjumping (or intelligent backtracking) in Prolog by using the built-ins throw/1 and catch/3. We show that it is impossible in a general case, contrary to a claim that “backjumping is exception handling." We provide two solutions. One works for binary programs; in a general case it imposes a restriction on where backjumping may originate. The other restricts the class of backjump targets. We also discuss implementing backjumping by using backtracking and the Prolog database. Additionally, we explain the semantics of Prolog exception handling in the presence of coroutining.

Type
Original Article
Copyright
© The Author(s), 2023. Published by Cambridge University Press

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

Thanks are due to the anonymous reviewers for their stimulating comments. Jan Wielemaker, David Geleßus and Ed Robbins commented on the content of the Appendix.

References

Apt, K. R. 1997. From Logic Programming to Prolog . International Series in Computer Science. Prentice-Hall.Google Scholar
Bruynooghe, M. 2004. Enhancing a search algorithm to perform intelligent backtracking. Theory and Practice of Logic Programming 4, 3, 371380.CrossRefGoogle Scholar
Bruynooghe, M. and Pereira, L. M. 1984. Deduction revision by intelligent backtracking. In Implementations of Prolog, Campbell, J. A., Ed. Ellis Horwood/Halsted Press/Wiley, 194215.Google Scholar
Byrd, L. 1980. Understanding control flow of Prolog programs. In Logic Programming Workshop, S.-Å. Tärnlund, Ed.Google Scholar
Deransart, P., Ed-Dbali, A. and Cervoni, L. 1996. Prolog - the Standard: Reference Manual. Springer.10.1007/978-3-642-61411-8CrossRefGoogle Scholar
Drabent, W. 2018. Logic + control: On program construction and verification. Theory and Practice of Logic Programming 18, 1, 129.CrossRefGoogle Scholar
Drabent, W. and Małuszyński, J. 1988. Inductive assertion method for logic programs. Theoretical Computer Science 59, 133155.Google Scholar
Howe, J. M. and King, A. 2012. A pearl on SAT and SMT solving in Prolog. Theoretical Computer Science 435, 4355.10.1016/j.tcs.2012.02.024CrossRefGoogle Scholar
Maher, M. J. 1988. Equivalences of logic programs. In Foundations of Deductive Databases and Logic Programming, Minker, J., Ed. Kaufmann, Morgan, 627658.Google Scholar
Robbins, E., King, A. and Howe, J. M. 2021. Backjumping is exception handling. Theory and Practice of Logic Programming 21, 2, 125144.10.1017/S1471068420000435CrossRefGoogle Scholar
Tarau, P. and Boyer, M. 1990. Elementary logic programs. In Programming Language Implementation and Logic Programming, PLILP’90, Deransart, P. and Maluszynski, J., Eds. Lecture Notes in Computer Science, vol. 456. Springer, 159173.Google Scholar