2,314 research outputs found
Tabling as a Library with Delimited Control
Tabling is probably the most widely studied extension of Prolog. But despite
its importance and practicality, tabling is not implemented by most Prolog
systems. Existing approaches require substantial changes to the Prolog engine,
which is an investment out of reach of most systems. To enable more widespread
adoption, we present a new implementation of tabling in under 600 lines of
Prolog code. Our lightweight approach relies on delimited control and provides
reasonable performance.Comment: 15 pages. To appear in Theory and Practice of Logic Programming
(TPLP), Proceedings of ICLP 201
Termination Proofs for Logic Programs with Tabling
Tabled logic programming is receiving increasing attention in the Logic
Programming community. It avoids many of the shortcomings of SLD execution and
provides a more flexible and often extremely efficient execution mechanism for
logic programs. In particular, tabled execution of logic programs terminates
more often than execution based on SLD-resolution. In this article, we
introduce two notions of universal termination of logic programming with
Tabling: quasi-termination and (the stronger notion of) LG-termination. We
present sufficient conditions for these two notions of termination, namely
quasi-acceptability and LG-acceptability, and we show that these conditions are
also necessary in case the tabling is well-chosen. Starting from these
conditions, we give modular termination proofs, i.e., proofs capable of
combining termination proofs of separate programs to obtain termination proofs
of combined programs. Finally, in the presence of mode information, we state
sufficient conditions which form the basis for automatically proving
termination in a constraint-based way.Comment: 48 pages, 6 figures, submitted to ACM Transactions on Computational
Logic (TOCL
On Applying Linear Tabling to Logic Programs
As linguagens de Programação em Lógica que derivam da lógica de Horn, tal como oProlog, têm mecanismos de resolução baseados em inferência que são bastante conhecidos.Embora o Prolog seja uma linguagem com bastante sucesso, o seu potencial é limitadopelo seu mecanismo de resolucão, que é baseado na resolucão SLD. O mecanismode resolução SLD foi provado ser bastante ineficiente quando avalia programas logicosque têm ciclos infinitos ou sub-computações redundantes. A tabulacão é uma técnicade implementação bastante reconhecida e poderosa que permite ultrapassar essaslimitações em sistemas de Prolog que são baseados na resolução SLD. Actualmente,a técnica de tabulação pode ser dividida em dois grandes mecanismos: por suspensãodas pilhas de execução e por execução linear. Os mecanismos por suspensão daspilhas de execução são considerados terem melhores resultados, no entanto eles têmmais requisitos em termos de memória e são mais complexos de implementar do queos mecanismos lineares.O trabalho apresentado nesta tese pretende fazer um estudo aprofundado sobre osmecanismos de tabulação linear, de forma a perceber como as diferentes estratégiasde tabulação afectam o fluxo de avaliação de um programa lógico e melhoram a performancegeral do sistema. As estratégias SLDT e DRA são duas das mais conhecidase bem sucedidas estratégias implementadas em sistemas de tabulação linear. Nestetrabalho, propomos uma nova estratégia, que foi denominada de DRS, e apresentamosuma plataforma integrada, que suporta a combinação das três estratégias. A nossaimplementação partilha o ambiente de execução e a maioria das estructuras de dadosusadas pela máquina de execução do YapTab, que é o actual mecanismo de tabulaçãobaseado em suspensão de pilhas do sistema Yap Prolog. A combinação de todasas estratégias e mecanismos na nossa plataforma permitiu-nos fazer uma primeiracomparação justa entre todas as estratégias lineares, usadas sozinhas ou combinadas,e o mecanismo original do YapTab, de forma a perceber as vantagens e desvantagens decada um. Os resultados obtidos, confirmam que os mecanismos baseados em suspensão têm, no geral, melhores resultados do que os mecanismos lineares, sendo que a diferençaentre os resultados de ambos os sistemas pode ser em grande parte reduzida atravésda combinação correcta das melhores estratégias lineares.Logic programming languages, such as Prolog, are derived from Horn Clause Logicand provide a well understood resolution based inference mechanism. Although Prologis a popular and successful language, its potential is limited by the SLD resolutionmethod on which it is based. SLD resolution was proven to be inecient whendealing with innite loops and redundant subcomputations. Tabled evaluation isa recognized and powerful technique that overcomes those limitations on traditionalProlog systems based on SLD resolution. We can distinguish two main categoriesof tabling mechanisms: suspension-based tabling and linear-based tabling. Whilesuspension-based mechanisms are considered to obtain better results in general, theyhave more memory space requirements and are more complex and hard to implementthan linear tabling mechanisms.The work presented on this thesis was focused on making a deep study about lineartabling, in order to understand how dierent linear tabling strategies can aect theevaluation ow of tabled programs and improve its overall performance. Arguably,the SLDT and DRA strategies are the two most successful extensions to standardlinear tabled evaluation. In this work, we propose a new strategy, named DRS, andwe present a framework, on top of the Yap system, that supports the combinationof all these three linear tabling strategies. Our implementation shares the underlyingexecution environment and most of the data structures used to implement tablingin the YapTab engine, which is the actual suspension-based tabling mechanism ofthe Yap Prolog system. All these common features allows us to make a rst andfair comparison between the linear tabling strategies, used solely or combined withthe other, and YapTab's suspension-based mechanism, in order to better understandthe advantages and weaknesses of each feature. The obtained results conrmed thatsuspension-based mechanisms have, in general, better performance than linear tablingand that the dierence between both mechanisms can be highly reduced by using thecorrect combination of linear tabling strategies
- …