In the dynamic programming paradigm the value of an optimal solution is recursively defined in terms of optimal solutions to subproblems. Such dynamic programming definitions can be tricky and error-prone to specify. This paper presents an elegant method based on tabled logic programming (TLP) that simplifies the specification of such dynamic programming solutions. Our method introduces a new mode declaration for tabled predicates. The arguments of each tabled predicate are divided into indexed and non-indexed arguments so that tabled predicates can be regarded as functions: indexed arguments represent input values and non-indexed arguments represent output values. The non-indexed arguments in a tabled predicate can be further declared to be aggregated, for example, the minimum, so that while generating answers, the global table will dynamically maintain the smallest value for that argument. This mode-declaration scheme, coupled with recursion, provides an easy-to-use method for dynamic programming: there is no need to define the value of an optimal solution recursively, as the definition of a general solution suffices. The optimal value as well as its corresponding concrete solution can be derived implicitly and automatically using tabled logic programming systems. Our experimental results show that mode declarations improve performance in solving dynamic programming problems on TLP systems. Copyright © 2007 John Wiley & Sons, Ltd.
This is an expanded version of the authors' paper ‘Simplifying Dynamic Programming via Tabling’ that appeared in the Proceedings of the 6th International Symposium on Practical Aspects of Declarative Languages, 2004, pp. 163–177
[1]
David Scott Warren,et al.
Tabled evaluation with delaying for general logic programs
,
1996,
JACM.
[2]
Theresa Swift.
Tabling for non‐monotonic programming
,
2004,
Annals of Mathematics and Artificial Intelligence.
[3]
Ronald L. Rivest,et al.
Introduction to Algorithms
,
1990
.
[4]
Giridhar Pemmasani,et al.
Online Justification for Tabled Logic Programs
,
2004,
FLOPS.
[5]
John Wylie Lloyd,et al.
Foundations of Logic Programming
,
1987,
Symbolic Computation.
[6]
Konstantinos Sagonas,et al.
An abstract machine for tabled execution of fixed-order stratified logic programs
,
1998,
TOPL.
[7]
C. R. Ramakrishnan,et al.
Justifying proofs using memo tables
,
2000,
PPDP '00.
[8]
Ricardo Rocha,et al.
On a Tabling Engine That Can Exploit Or-Parallelism
,
2001,
ICLP.
[9]
Günther Specht.
Generating Explanation Trees even for Negations in Deductive DataBase Systems
,
1993,
LPE.
[10]
Gopal Gupta,et al.
A Simple Scheme for Implementing Tabled Logic Programming Systems Based on Dynamic Reordering of Alternatives
,
2001,
ICLP.
[11]
Li-Yan Yuan,et al.
Linear tabulated resolution based on Prolog control strategy
,
2000,
Theory and Practice of Logic Programming.
[12]
C. R. Ramakrishnan,et al.
Efficient Model Checking Using Tabled Resolution
,
1997,
CAV.
[13]
Li-Yan Yuan,et al.
Implementation of a Linear Tabling Mechanism
,
2001,
J. Funct. Log. Program..