Loop Detection in Prolog in the Case of Possible Backtracking
نویسنده
چکیده
A method will be proposed for the detection of some periodic loops during the execution of Prolog programs, and an implementation of this method will be described. The method is an extension of another one presented in the paper [3]. Namely, that method was intended for the detection of loops only during depth-first search, whereas the new one will work essentially in the same way in that case, but the combination of depth-first search with backtracking will be no more an obstacle. As in [3], we shall consider only Prolog programs consisting of Horn clauses and goals consisting of atomic formulas. For describing our loop detection method and specifying the class of the detected loops, we use a mathematical model of Prolog execution with backtracking. The model takes into account only such features of the execution process which are of interest for our purpose; due to this, it is much simpler than, for example, the D. H. D. Warren Prolog Engine (cf. [1], pp. 447-471). From now on, we suppose a Prolog program P is given. Let C1, . . . , Cm be the clauses of this program. We shall consider objects called marked goals. By definition, a marked goal is an ordered pair , where k is some of the numbers 0, 1, . . . , m, and G is an ordinary goal (if G is the goal consisting of the atomic formulas A1, . . . , Al, then will be denoted also by k − A1, . . . , Al. ). Roughly speaking, the number k is intended to forbid using clauses Ci with i ≤ k for a resolution with G. The number of the atomic formulas in G will be called the length of . The beginnings of are, by definition, the marked goals , where G′ is a beginning of G. Two marked goals and will be called to be essentially the same if k = k′, and G coincides with G′ up to some renaming of variables. Any finite sequence of marked goals will be called an execution state (such a sequence (M1, M2, . . . , Md) will be denoted also by M1 M2 . . . Md , and thus the one-term sequence (M1) will be identified with its only member M1). Intuitively speaking, an execution state is intended to represent some current content of a stack needed for the execution of P . We assume that the direction from top to bottom in the stack is represented by the one from left
منابع مشابه
A General-Purpose Conjunctive Iterative Control Structure for Prolog
A loop-like control structure without using backtracking, or conjunctive iteration, is expressed using recursion in Prolog. However, recursion is too powerful to express an iteration, which needs more restrictive syntax and semantics. This paper presents a general-purpose iteration predicate do. Predicate do enables a programmer to write most iterations, such as arithmetical iterations, append,...
متن کاملOptimal Backtracking based on Failure-bindings in Prolog
This paper describes a method for optimal backtracking Prolog based on failure-bindings of literals. A modified unification algorithm is presented in order to identify all possible causes of failure during execution. Methods to select optimal back-point and the use of Failure Binding Tables at run-time are presented. Forwardand Backwardexecution algorithms are also given. keywords: prolog, inte...
متن کاملProgramming Paradigms of the Andorra Kernel Language
The Andorra Kernel Language (AKL) is introduced. We show how AKL provides the programming paradigms of both Prolog and GHC. This is the original goal of the design. It has also been possible to provide capabilities beyond that of Prolog and GHC. There are means to structure search, more powerful than plain backtracking. It is possible to encapsulate search in concurrent reactive processes. It i...
متن کاملProgramming Paradigms ofthe Andorra Kernel
The Andorra Kernel Language (AKL) is introduced. It is shown how AKL provides the programming paradigms of both Prolog and GHC. This is the original goal of the design. However, it has also been possible to provide capabilities beyond that of Prolog and GHC. There are means to structure search, more powerful than plain backtracking. It is possible to encapsulate search in concurrent reactive pr...
متن کاملAdvantages of ACT-R over Prolog for Natural Language Analysis
This paper discusses the advantages of using the ACT-R cognitive architecture over the Prolog programming language for the research and development of a large-scale, functional, cognitively motivated model of natural language analysis. Although Prolog was developed for Natural Language Processing (NLP), it lacks any probabilistic mechanisms for dealing with ambiguity and relies on failure detec...
متن کامل