Hostname: page-component-74656f9884-kv2lp Total loading time: 0 Render date: 2026-11-06T06:08:26.443Z 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)
Rights & Permissions [Opens in a new window]

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.

Information

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

Fig. 1. Backjumping to Q from the subtree ${\cal S}$ rooted in $Q_i$ (when $i) is followed by visiting $Q_{i+1}$. For $i=k$ the backjumping is followed by visiting the parent of Q.Consider exception handling (implemented by making N to be catch(Q,s,H)). Exception s raised in ${\cal S}$ (and not caught in ${\cal S}$) results in skipping $Q_{i+1},\ldots,Q_k$ and all their descendants. Additionally, the LD-tree is extended by a subtree corresponding to executing the exception handler H.

Figure 1

Fig. 2. Dotted lines connect an atom sequence with a query from its execution. N,N’ are of the form $N=A,\ldots,(B_1,Q_0)\theta\rho$, $ N'={\it throw(id)},\ldots,Q_0\theta\rho\varphi$.