Found 52 bookmarks
Newest
Indexing dif/2
Indexing dif/2

Many Prolog programs are unnecessarily impure because of inadequate means to express syntactic inequality. While the frequently provided built-in dif/2 is able to correctly describe expected answers, its direct use in programs often leads to overly complex and inefficient definitions — mainly due to the lack of adequate indexing mechanisms. We propose to overcome these problems by using a new predicate that subsumes both equality and inequality via reification. Code complexity is reduced with a monotonic, higher-order if-then-else construct based on call/N. For comparable correct uses of impure definitions, our approach is as determinate and similarly efficient as its impure counterparts.

·up.raindrop.io·
Indexing dif/2
Portability of Prolog programs: theory and case-studies
Portability of Prolog programs: theory and case-studies
(Non-)portability of Prolog programs is widely considered as an important factor in the lack of acceptance of the language. Since 1995, the core of the language is covered by the ISO standard 13211-1. Since 2007, YAP and SWI-Prolog have established a basic compatibility framework. This article describes and evaluates this framework. The aim of the framework is running the same code on both systems rather than migrating an application. We show that today, the portability within the family of Edinburgh/Quintus derived Prolog implementations is good enough to allow for maintaining portable real-world applications.
·up.raindrop.io·
Portability of Prolog programs: theory and case-studies
Lambdas in ISO Prolog
Lambdas in ISO Prolog

Higher order programming is possible in Prolog. There is no need to extend the language for that. See Richard O'Keefe's arguments in comp.lang.prolog more than ten years ago. What is missing are lambda expressions.

We present a very simple implementation of lambda expressions in ISO Prolog that fits into the existing conventions for higher order predicates based on call/N. No syntax or compiler extension is needed.

·up.raindrop.io·
Lambdas in ISO Prolog
DCGs + Memoing = Packrat Parsing. But is it worth it?
DCGs + Memoing = Packrat Parsing. But is it worth it?
Packrat parsing is a newly popular technique for efficiently implementing recursive descent parsers. Packrat parsing avoids the potential exponential costs of recursive descent parsing with backtracking by ensuring that each production rule in the grammar is tested at most once against each position in the input stream. This paper argues that (a) packrat parsers can be trivially implemented using a combination of definite clause grammar rules and memoing, and that (b) packrat parsing may actually be significantly less efficient than plain recursive descent with backtracking, but (c) memoing the recognizers of just one or two nonterminals, selected in accordance with Amdahl’s law, can sometimes yield speedups. We present experimental evidence to support these claims.
·up.raindrop.io·
DCGs + Memoing = Packrat Parsing. But is it worth it?
Applying Constraint Programming to Minimal Lottery Designs
Applying Constraint Programming to Minimal Lottery Designs
We develop and deploy a set of constraints for the purpose of calculating minimal sizes of lottery designs. Specifically, we find the minimum number of tickets of size six which are needed to match at least two balls on any draw of size six, whenever there are at most 70 balls.
·up.raindrop.io·
Applying Constraint Programming to Minimal Lottery Designs