3 research outputs found

    An Application of Rational Trees in a Logic Programming Interpreter for a Procedural Language

    Full text link
    We describe here a simple application of rational trees to the implementation of an interpreter for a procedural language written in a logic programming language. This is possible in languages designed to support rational trees (such as Prolog II and its descendants), but also in traditional Prolog, whose data structures are initially based on Herbrand terms, but in which implementations often omit the occurs check needed to avoid the creation of infinite data structures. We provide code implementing two interpreters, one of which needs non-occurs-check unification, which makes it faster (and more economic). We provide experimental data supporting this, and we argue that rational trees are interesting enough as to receive thorough support inside the language.Comment: LaTeX2e, 13 pages, 2 tables, 11 figures (several of them, text). Yet unpublishe

    On the Performance of Bytecode Interpreters in Prolog

    Full text link
    The semantics and the recursive execution model of Prolog make it very natural to express language interpreters in form of AST (Abstract Syntax Tree) interpreters where the execution follows the tree representation of a program. An alternative implementation technique is that of bytecode interpreters. These interpreters transform the program into a compact and linear representation before evaluating it and are generally considered to be faster and to make better use of resources. In this paper, we discuss different ways to express the control flow of interpreters in Prolog and present several implementations of AST and bytecode interpreters. On a simple language designed for this purpose, we evaluate whether techniques best known from imperative languages are applicable in Prolog and how well they perform. Our ultimate goal is to assess which interpreter design in Prolog is the most efficient, as we intend to apply these results to a more complex language. However, we believe the analysis in this paper to be of more general interest.Comment: 15 pages. Part of WFLP 2020 pre-proceeding

    Finite-Tree Analysis for Constraint Logic-Based Languages: The Complete Unabridged Version

    Full text link
    Logic languages based on the theory of rational, possibly infinite, trees have much appeal in that rational trees allow for faster unification (due to the safe omission of the occurs-check) and increased expressivity (cyclic terms can provide very efficient representations of grammars and other useful objects). Unfortunately, the use of infinite rational trees has problems. For instance, many of the built-in and library predicates are ill-defined for such trees and need to be supplemented by run-time checks whose cost may be significant. Moreover, some widely-used program analysis and manipulation techniques are correct only for those parts of programs working over finite trees. It is thus important to obtain, automatically, a knowledge of the program variables (the finite variables) that, at the program points of interest, will always be bound to finite terms. For these reasons, we propose here a new data-flow analysis, based on abstract interpretation, that captures such information.Comment: 89 pages, 1 tabl
    corecore