### Abstract

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 of naive memoing in Prolog. Using memoing naively 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 of ET-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 by multiple 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.

Original language | English (US) |
---|---|

Pages (from-to) | 141-162 |

Number of pages | 22 |

Journal | New Generation Computing |

Volume | 15 |

Issue number | 2 |

DOIs | |

State | Published - Jan 1 1997 |

### Keywords

- Logic Programming
- Memoing
- Recursion

### ASJC Scopus subject areas

- Software
- Theoretical Computer Science
- Hardware and Architecture
- Computer Networks and Communications

## Fingerprint Dive into the research topics of 'On the completeness of naive memoing in prolog'. Together they form a unique fingerprint.

## Cite this

*New Generation Computing*,

*15*(2), 141-162. https://doi.org/10.1007/BF03037235