Affiliation:
1. Computer Science, University of Birmingham, Birmingham, United Kingdom of Great Britain and Northern Ireland
2. Computer Science, University of Birmingham, Birmingham United Kingdom of Great Britain and Northern Ireland
Abstract
Dynamic programming (DP) is a broadly applicable algorithmic design paradigm for the efficient, exact solution of otherwise intractable, combinatorial problems. However, the design of such algorithms is often presented informally in an ad-hoc manner. It is sometimes difficult to justify the correctness of these DP algorithms. To address this issue, this article presents a rigorous algebraic formalism for systematically deriving DP algorithms, based on semiring polymorphism. We start with a specification, construct a (brute-force) algorithm to compute the required solution which is self-evidently correct because it exhaustively generates and evaluates all possible solutions meeting the specification. We then derive, primarily through the use of shortcut fusion, an implementation of this algorithm which is both efficient and correct. We also demonstrate how, with the use of semiring lifting, the specification can be augmented with combinatorial constraints and through semiring lifting, show how these constraints can also be fused with the derived algorithm. This article furthermore demonstrates how existing DP algorithms for a given combinatorial problem can be abstracted from their original context and re-purposed to solve other combinatorial problems.
This approach can be applied to the full scope of combinatorial problems expressible in terms of semirings. This includes, for example: optimisation, optimal probability and Viterbi decoding, probabilistic marginalization, logical inference, fuzzy sets, differentiable softmax, and relational and provenance queries. The approach, building on many ideas from the existing literature on constructive algorithmics, exploits generic properties of (semiring) polymorphic functions, tupling and formal sums (lifting), and algebraic simplifications arising from constraint algebras. We demonstrate the effectiveness of this formalism for some example applications arising in signal processing, bioinformatics and reliability engineering. Python software implementing these algorithms can be downloaded from:
http://www.maxlittle.net/software/dppolyalg.zip
.
Funder
NIH grant UR-Udall Center
Publisher
Association for Computing Machinery (ACM)
Reference29 articles.
1. Semiring programming: A semantic framework for generalized sum product problems
2. Richard Bellman. 1957. Dynamic Programming. Princeton University Press.
3. Richard S. Bird and Oege de Moor. 1996. Algebra of Programming. Prentice-Hall.
4. S. Boehme. 2024. free-theorems: Automatic generation of free theorems. https://hackage.haskell.org/package/free-theorems