This paper specifies an observational semantics and gives an original presentation of the Byrd box model. The approach accounts for the semantics of Prolog tracers independently of a particular Prolog implementation. Prolog traces are, in general, considered as rather obscure and difficult to use. The proposed formal presentation of its trace constitutes a simple and pedagogical approach for teaching Prolog or for implementing Prolog tracers. It is a form of declarative specification for the tracers. The trace model introduced here is only one example to illustrate general problems relating to tracers and observing processes. Observing processes know, from observed processes, only their traces. The issue is then to be able to reconstitute, by the sole analysis of the trace, part of the behaviour of the observed process, and if possible, without any loss of information. As a matter of fact, our approach highlights qualities of the Prolog resolution box model which made its success, but also its insufficiencies.
This paper presents a Prolog trace model, often called Byrd box model, in an original way, based on the concept of Observational Semantics (OS). This semantics was introduced in [1] in order to account for the semantics of tracers independently of the semantics of the traced process.
The objective of this paper is to illustrate the merits of an observational semantics with a simple but non trivial example. The result is an original semantics of the Prolog trace as usually implemented, but without either taking into account any particular implementation or describing the totality of the resolution process. Such a semantics also constitutes a form of formal specification of Prolog tracers and makes it possible to easily understand some of their essential properties.
The “box model” was introduced for the first time by Lawrence Byrd in 1980 [2] to help users of the “new” Prolog language 4 to master the operational reading of program executions. Indeed, since the very beginning, users have been complaining about how difficult it is to understand control mechanisms related to the non-determinism of the solutions. Even if thereafter other models were adopted with more complex strategies5 , the four “ports” introduced by Byrd (Call, Exit, Redo and Fail), associated to the four corners of a box and easy to handle in a kind of algebra of Russian headstocks, remained famous and are more or less in all the traces of the still existing Prolog systems.
The Byrd box model fascinates by his apparent simplicity. Often quoted but seldomly well explained, it remains the object of sporadic but regular publications since 1980, for example [5] (1984), [6] (1993), [7] (2000), [8] (2003). Yet, it remains difficult to explain, its various definitions are either too abstract or drowned in a complete formalization of Prolog operational semantics.
In this article, we propose a formal description of a variant of the initial model of Byrd. The originality of this description lies in the fact that it is formally complete, although it contains the ingredients of the original model and it refers as little as possible to the Prolog mechanisms of clause choice and unification.
After an introduction to the traces and the observational semantics (Sections 2 and 3) which outlines the context of this study, we present an observational semantics which specifies the box model (Section 4) and the trace extraction (Section 5). Finally, we give a faithful reconstruction model (Section 6), which establishes a possible reading guideline for the trace, based on the OS. This paper is based on the full report [9] (same title and authors, in French). More details on the motivations can be found in [1] and [10].
We are interested in the observation of dynamic processes starting from the traces which they produce.
One can always consider that between an observer and an observed phenomenon there is an object that we call trace. The trace is the recognized print left by a process and it is thus “readable” by other processes. The observed phenomenon will be regarded here as a closed process, its data and functions are not visible from the outside. External processes can only know its trace. This trace is called the actual trace. It is a sequence of trace events defined on some state. The actual trace is thus a kind of continuous data flow produced by some process.
A trace can also be interpreted as the evolution of an “abstract” state which contains all what one can or wants to know from the process. The sequence of the abstract states can be viewed as a more abstract but meaningful trace. Such a trace is called the full virtual trace.
A full virtual trace is defined on a set of full virtual states S and a finite set of event type R. It is an unbounded sequence of trace events of the form e t : (t, a t , S t+1 ) where:
e t : is a unique identifier of the event.
t: is the chrono, a time stamp of the event. It is an integer, incremented by 1 at each event.
-S t+1 = p 1,t+1 …, p n,t+1 is the reached state of S represented by the new values of parameters p 1 …, p n . -a t : an identifier characterizing the kind of actions performed during the transition from state S t to state S t+1 , also called event type.
A full virtual trace is denoted T v =< S 0 , v * t >, t ≥ 0 , where S 0 is an initial state and v * t a possibly empty sequence (if t = 0) of trace events or a sequence of length t + 1 of the form e t , e t-1 , …, e 0 (if t ≥ 0).
Example 1. In the Section 4 the box model is introduced with its full virtual trace. The main “virtual objets” described in the parameters consists of a tree whose nodes are labeled by predications and clauses. Such a tree allows to follow the evolution of the proofs during Prolog execution. Starting from a tree reduced to one root node labeled by a unique predication goal and the clauses likely used to solve it, the full virtual trace is the sequence of trees until all possible proof trees have been obtained, inc
This content is AI-processed based on open access ArXiv data.