首页 | 本学科首页   官方微博 | 高级检索  
相似文献
 共查询到20条相似文献,搜索用时 678 毫秒
1.
Memoing is often used in logic programming to avoid redundant evaluation of similar goals, often on programs that are inherently recursive in nature. The interaction between memoing and recursion, however, is quite complex. There are several top-down evaluation strategies for logic programs that utilize memoing to achieve completeness in the presence of recursion. This paper’s focus, however, is on the use ofnaive memoing in Prolog. Using memoingnaively in conjunction with recursion in Prolog may not produce expected results. For example, adding naive memoing to Prolog’s evaluation of a right-recursive transitive closure may be incomplete, whereas adding naive memoing to Prolog’s evaluation of a left-recursive transitive closure may be terminating and complete. This paper examines the completeness of naive memoing in linear-recursive, function-free logic programs evaluated with Prolog’s top-down evaluation strategy. In addition, we assume that the program is definite and safe, having finite base relations and exactly one recursive predicate. The goal of the paper is a theoretical study of the completeness of naive memoing and recursion in Prolog, illustrating the limitations imposed even for this simplified class of programs. The naive memoing approach utilized for this study is based on extension tables, which provide a memo mechanism with immediate update view semantics for Prolog programs, through a source transformation known as ET. We introduce the concept ofET-complete, which refers to the completeness of the evaluation of a query over a Prolog program that memos selected predicates through the ET transformation. We show that left-linear recursions defined by a single recursive rule are ET-complete. We generalize the class of left-linear recursions that are ET-complete by introducing pseudo-left-linear recursions, which are also defined by a single linear recursive rule. To add left-linear recursions defined bymultiple linear recursive rules to the class of ET-complete recursions, we present a left-factoring algorithm that converts left-linear recursions defined by multiple recusive rules into pseudo-left-linear recursions defined by a single recursive rule. Based on these results, the paper concludes by identifying research directions for expanding the class of Prolog programs to be examined in future work. This work was partially supported by the National Science Foundation under Grant CCR-9008737. Suzanne Wagner Dietrich, Ph.D.: She is an Associate Professor in the Department of Computer Science and Engineering at Arizona State University. Her research emphasis is on the evaluation of declarative logic programs especially in the context of deductive databases, including materialized view maintenance and condition monitoring in active deductive databases. More recently, her research interests include the integration of active, object-oriented and deductive databases as well as the application of this emerging database technology to various disciplines such as software engineering. She received the B. S. degree in computer science in 1983 from the State University of New York at Stony Brook, and as the recipient of an Office of Naval Research Graduate Fellowship, earned her Ph.D. degree in computer science at Stony Brook in 1987. Changguan Fan, M.S.: He is a Ph.D. candidate in the Department of Computer Science and Engineering at Arizona State University and a software engineer at the Regenisys Corporation in Scottsdale, AZ. His research interests include the evaluation of logic programs, deductive database systems and database management systems. He received his B.S. in Computer Science from the Shanghai Institute of Railway Technology, Shanghai, China in 1982 and his M.S. in the Department of Computer Science and Engineering at Arizona State University in 1989.  相似文献   

2.
The programming tradeoffs between structure-oriented and clause-oriented operations on data structures in Prolog are limited in current implementations because the assertion of clauses that include uninstantiated variables destroys any binding between these variables and those with which they are unified in the execution of the program. Built-in predicates for Prolog that allow one to assert predicate variables pointers, which are constants, rather than uninstantiated variables, are presented. The author shows: the possible performance benefits of clause-oriented implementations of data structures over equivalent structure-oriented versions, the logical implications of the proposed built-in predicates, and their practical significance by integrating them in C-Prolog and evaluating the two different implementations of the symbol table dictionary in D.H.D. Warren's pseudo-Pascal compiler example  相似文献   

3.
Robert M. Colomb 《Software》1988,18(3):205-220
As Prolog becomes more widely used, it becomes important to provide clear and consistent implementations of the assert and retract primitives. This paper introduces a bit-map indexing system with a consistent semantics. It also considers the implementation of the interface between Prolog and an external source of clauses, concentrating on the storage of clauses on secondary storage, but considering also the presentation of data to Prolog programs by non-Prolog processes.  相似文献   

4.
Global SLS-resolution and SLG-resolution are two representative mechanisms for top-down evaluation of the well-founded semantics of general logic programs. Global SLS-resolution is linear for query evaluation but suffers from infinite loops and redundant computations. In contrast, SLG-resolution resolves infinite loops and redundant computations by means of tabling, but it is not linear. The principal disadvantage of a nonlinear approach is that it cannot be implemented by using a simple, efficient stack-based memory structure nor can it be easily extended to handle some strictly sequential operators such as cuts in Prolog. In this paper, we present a linear tabling method, called SLT-resolution, for top-down evaluation of the well-founded semantics. SLT-resolution is a substantial extension of SLDNF-resolution with tabling. Its main features are the following. First, it resolves infinite loops and redundant computations while preserving the linearity. Second, it is terminating and is sound and complete w.r.t. the well-founded semantics for programs with the bounded-term-size property with nonfloundering queries. Its time complexity is comparable with SLG-resolution and polynomial for function-free logic programs. Third, because of its linearity for query evaluation, SLT-resolution bridges the gap between the well-founded semantics and standard Prolog implementation techniques. It can be implemented by an extension to any existing Prolog abstract machines such as WAM or ATOAM.  相似文献   

5.
Saumya K. Debray 《Software》1988,18(9):821-839
Profilers play an important role in the development of efficient programs. Profiling techniques developed for traditional languages are inadequate for logic programming languages, for a number of reasons: first, the flow of control in logic programming languages, involving back-tracking and failure, is significantly more complex than in traditional languages; secondly, the time taken by a unification operation, the principal primitive operation of such languages, cannot be predicted statically because it depends on the size of the input; and finally, programs may change at run-time because clauses may be added or deleted using primitives such as assert and retract. This paper describes a simple profiler for Prolog. The ideas outlined here may be used either to implement a simple interactive profiler, or integrated into Prolog compilers.  相似文献   

6.
Jonathan J. Cook 《Software》2004,34(9):815-845
We discuss P#, our implementation of a tool that allows interoperation between a concurrent superset of the Prolog programming language and C#. This enables Prolog to be used as a native implementation language for Microsoft's .NET platform. P# compiles a linear logic extension of Prolog to C# source code. We can thus create C# objects from Prolog and use C#'s graphical, networking and other libraries. We add language constructs on the Prolog side that allow concurrent Prolog code to be written. A primitive predicate is provided that evaluates a Prolog structure on a newly forked thread. Communication between threads is based on the unification of variables contained in such a structure. It is also possible for threads to communicate through a globally accessible table. All of the new features are available to the programmer through new built-in Prolog predicates. We discuss two software engineering tools implemented using P#. Copyright © 2004 John Wiley & Sons, Ltd.  相似文献   

7.
DB-Prolog is an extended version of Prolog which allows users to access relational databases in both evaluational and non-evaluational approaches. Using the former approach, DB-Prolog offers some built-in predicates for retrieving relational databases. Using the latter approach, DB-Prolog enables relational databases to store facts (ground unit clauses) which may have compound terms in their arguments. As a result, DB-Prolog can execute Prolog programs which contain both a large set of facts, and conventional data (both numerical and character) efficiently. These Prolog programs are required for the construction of practical expert systems. DB-Prolog implementation techniques are described, and some of its available functions are discussed.  相似文献   

8.
Corecursion is the ability of defining a function that produces some infinite data in terms of the function and the data itself, as supported by lazy evaluation. However, in languages such as Haskell strict operations fail to terminate even on infinite regular data, that is, cyclic data.Regular corecursion is naturally supported by coinductive Prolog, an extension where predicates can be interpreted either inductively or coinductively, that has proved to be useful for formal verification, static analysis and symbolic evaluation of programs.In this paper we use the meta-programming facilities offered by Prolog to propose extensions to coinductive Prolog aiming to make regular corecursion more expressive and easier to program with.First, we propose a new interpreter to solve the problem of non-terminating failure as experienced with the standard semantics of coinduction (as supported, for instance, in SWI-Prolog). Another problem with the standard semantics is that predicates expressed in terms of existential quantification over a regular term cannot directly defined by coinduction; to this aim, we introduce finally clauses, to allow more flexibility in coinductive definitions.Then we investigate the possibility of annotating arguments of coinductive predicates, to restrict coinductive definitions to a subset of the arguments; this allows more efficient definitions, and further enhance the expressive power of coinductive Prolog.We investigate the effectiveness of such features by showing different example programs manipulating several kinds of cyclic values, ranging from automata and context free grammars to graphs and repeating decimals; the examples show how computations on cyclic values can be expressed with concise and relatively simple programs.The semantics defined by these vanilla meta-interpreters are an interesting starting point for a more mature design and implementation of coinductive Prolog.  相似文献   

9.
人工智能和数据库的结合是计算机技术发展的必然结果,而数据库和逻辑推理机结合的关键是逻辑推理机与传统数据库间的接口。设计了一组Prolog 访问FoxBASE数据库文件的工具谓词,具有普遍适用性。依据提出的思路和方法,很容易地实现其它逻辑推理机和数据库间的接口。  相似文献   

10.
The selection of the software development tool for the development of an expert system is a difficult and often disputed decision. This paper describes a comparison of a knowledge engineering tool, Kee, and a general purpose language, Prolog, on concrete and real life example from AGATHA, an electronic circuit board diagnosis expert system.Prolog is a high-level programming language with flexible and powerful inference mechanisms. Kee is a big tool that supports a frame-based knowledge representation, an object-oriented programming style and a built-in rule system. It also offers a window environment suitable for rapid development of user-interface prototypes.Prolog's representation is more succinct, implicit and uses problem specific predicates and therefore leaves more room for personal programming styles. Kee is more verbose, explicit and uses standard templates. The maintainability of a Prolog implementation relies heavily on good documentation. In Kee, the unavoidable ‘escapes to Lisp’ require a maintainer to be fluent in Kee and Lisp.Both Prolog and Kee require a considerable investment in learning time.  相似文献   

11.
本文给出了在逻辑程序抽象解释的理论框架下进行模式推导的方法,并就其中的别名处理问题和定点计算问题进行了详细的讨论提出了一种正确,有铲的别名自理方法以及基于”护展表“的定点求解算法。该方案已用Prolog语言实现。  相似文献   

12.
The added functionality such as contour tracking and corner detection which logic programming lends to standard image operators is described. An environment for implementing low-level imaging operations with Prolog predicates is considered. Within this environment, higher-level image predicates (contour tracking and corner detection) are constructed. The emphasis is not on building better corner detectors, but on presenting ways of using the unification and backtracking features of logic programming for these tasks. The performance of this implementation of contour tracking and corner detection has been very good in many more complex images, as it allows for feedback both ways between sensor input and symbolic models. More important is the parameter selection capability in a dynamic version where background properties change. The authors present examples of Prolog predicates for performing the contour and corner detection operations  相似文献   

13.
Unlike SLD resolution as implemented in Prolog, tabled evaluation with delaying guarantees termination for function free logic programs, avoids repeated computation of identical subqueries, and handles recursion through negation. It is often used in query processing and nonmonotonic reasoning where termination is required. The paper presents a new technique for incorporating tabled evaluation into existing Prolog systems. It requires neither time consuming modifications of a Prolog engine nor metainterpretation that can enormously slow down program execution. Instead, using a program transformation approach, the technique allows effective use of the advanced Prolog technology. The transformed program uses tabling primitives implemented externally in C that provide direct control over the search strategies. This brings efficiency as well as portability across Prolog systems. Experiences with a prototype implementation indicate that the approach results in a flexible and pragmatic method for query processing and nonmonotonic reasoning on top of Prolog. Performance measurements show that the method is efficient for practical applications  相似文献   

14.
The problem of computational completeness of Horn clause logic programs is revisited. The standard results on representability of all computable predicates by Horn clause logic programs are not related to the real universe on which logic programs operate. SLD-resolution, which is the main mechanism to execute logic programs, may give answer substitutions with variables. As the main result we prove that computability by Horn clause logic programs is equivalent to standard computability over the Herbrand universe with variables. The semantics we use isS-semantics introduced by Falaschi et al. [3]. As an application of the main result we prove the existence of a metainterpreter for a sublanguage of real Prolog, written in the language of Horn clauses with the S-semantics. We also show that the traditional semantics of Prolog do not reflect its computational behavior from the viewpoint of recursion theory.This article is a revised version of [13]. The work was essentially done during author's visit to ECRC.  相似文献   

15.
Visualization is valuable in monitoring and debugging programs. The goal of the Wand research project at the University of Saskatchewan is to provide both a framework and tools for rapid development of visualization aids for logic programming languages. The ICOLA (Incremental Constraint-based Object Layout Algorithm) system is the newest graphics facility within Wand. ICOLA positions graphical objects according to object declarations and constraints specifying relative positional relationships among the objects. Three important features of ICOLA are that it is capable of creating reasonable pictures from highly under-constrained specifications, it uses an incremental constraint solution algorithm and hence generates those pictures efficiently, and it supports incremental (i.e. progressive) insertions and deletions of objects and constraints. The ability of the incremental algorithm to support such deletions is particularly noteworthy. This paper describes: PDI, the language supported by ICOLA; the incremental constraint solution algorithm itself; a successful implementation in Prolog and C; and results of a performance evaluation of the implementation.  相似文献   

16.
We propose an extension to Prolog called the count term for controlling Prolog execution. The purpose is to allow the programmers as well as the users to have greater flexibility in controlling the execution behavior of Prolog programs and for limiting the number of answers or proofs retrieved when Prolog is used as a database query language. Both syntax and operational semantics of the count term are defined. An implementation strategy based on WAM (Warren Abstract Machine) is provided. We analyze the possible meanings one might associate with the count term. The possible replacement of cut and fail by the count term is presented. The ease of analysis of programs with count terms is discussed.  相似文献   

17.
部分计算是一种重要的程序变换方法和编译优化技术,Prolog程序特别适合于部分计算。目前,国际上已开始了几个Prolog程序部分计算的原理模型和专用工具,但其中存在以下若于问题:(1)关于Prolog程序部分计算的基本原理和特征缺乏系统的认识;(2)现有的两种检测逻辑程序中循环的方法,并没有最后解决部分计算的终止性问题》;(3)关于Prolog中内部谓词的处理不够究善,而且其中还隐含了许多语叉错误;(4)部分计算算法相当低效;(5)现有的部分计算器局限于各自的应用领域,缺乏通用性。本文结合我们研制GKD-Prolog编译系统[14]剖中一个实用源级部分计算器的工作实践,全面、系统地讨论了纯Prolog的部分计算、逻辑程序的循环检测以及全Prolog的内部谓词处理。  相似文献   

18.
We extend Horn Clause Prolog with two new primitives, new_engine (+Goal, +Answer, -Engine) and new_answer(+Engine, -Answer) for creating and exploring answer spaces of multiple interpreters (engines). We show that despite its ontological parsimony, the resulting language is comparable in practical expressiveness with conventional full Prolog, by allowing compact definitions for negation, if-then-else, all solution predicates, I/O and reflective meta-interpreters. While not really needed anymore as a workaround for the lack of expressiveness of pure Prolog, a form of dynamic database operations can be emulated as well, using the state of multiple engines. With multiple engines laying the foundation for multi-threaded execution models of logic programming languages, the surprising result that a minimal extension of Horn Clauses (with LD resolution) in fact bridges the gap to full Prolog, is significant as a basis for lightweight implementations of embedabble logic programming components. Our constructs have been used in the design of small footprint mobile code interpreters for a commercial multi-threaded agent programming language - Jinni - available from http://www.binnetcorp.com/Jinni”.  相似文献   

19.
It is shown how Horn logic programs can be implemented using database techniques, namely, mostly bottom-up in combination with certain top-down elements (as opposed to the top-down implementations of logic programs prevailing so far). The proposed method is sound and complete. It easily lends itself to a parallel implementation and is free of nonlogical features like backtracking. As an extension to the common approach to deductive databases, function symbols are allowed to appear in programs, and it is shown that much of database query optimization can be applied to optimize logic programs. An important advantage of present approach is its ability to evaluate successfully many programs that terminate under neither pure top-down nor bottom-up evaluation strategies  相似文献   

20.
Presents a framework for efficiently solving logic formulations of combinatorial optimization problems using heuristic search techniques. In order to integrate cost, lower-bound and upper-bound specifications with conventional logic programming languages, we augment a constraint logic programming (CLP) language with embedded constructs for specifying the cost function and with a few higher-order predicates for specifying the lower and upper bound functions. We illustrate how this simple extension vastly enhances the ease with which optimization problems involving combinations of Min and Max can be specified in the extended language CLP* and we show that CSLDNF (Constraint SLD resolution with Negation as Failure) resolution schemes are not efficient for solving optimization problems specified in this language. Therefore, we describe how any problem specified using CLP* can be converted into an implicit AND/OR graph, and present an algorithm called GenSolve which can branch-and-bound using upper and lower bound estimates, thus exploiting the full pruning power of heuristic search techniques. A technical analysis of GenSolve is provided. We also provide experimental results comparing various control strategies for solving CLP* programs  相似文献   

设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号