Abstract
We present a lightweight framework in Isabelle/HOL for the automatic verified (functional or imperative) memoization of recursive functions. Our tool constructs a memoized version of the recursive function and proves a correspondence theorem between the two functions. A number of simple techniques allow us to achieve bottom-up computation and space-efficient memoization. The framework’s utility is demonstrated on a number of representative dynamic programming problems.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
If f has type \(\tau _1 \rightarrow \cdots \rightarrow \tau _n\) and x has type \(\tau \), the variables \( f _\textsf {m}'\) and \( x _\textsf {m}\) are assumed to have types \(M'(\tau _1)\rightarrow \cdots \rightarrow M'(\tau _n)\) and \(M(\tau )\), respectively. For a term \(x\,{:}{:}\,\tau \) that satisfies \(M'(\tau )=\tau \), x and \( x _\textsf {m}'\) are used interchangeably.
- 2.
- 3.
References
Berghofer, S., Nipkow, T.: Executing higher order logic. In: Callaghan, P., Luo, Z., McKinna, J., Pollack, R., Pollack, R. (eds.) TYPES 2000. LNCS, vol. 2277, pp. 24–40. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45842-5_2
Bortin, M.: A formalisation of the Cocke-Younger-Kasami algorithm. Archive of Formal Proofs (2016). http://isa-afp.org/entries/CYK.html, Formal proof development
Braibant, T., Jourdan, J., Monniaux, D.: Implementing and reasoning about hash-consed data structures in Coq. J. Autom. Reasoning 53(3), 271–304 (2014). https://doi.org/10.1007/s10817-014-9306-0
Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L., Matthews, J.: Imperative functional programming with Isabelle/HOL. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 134–149. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-71067-7_14
Erwig, M., Ren, D.: Monadification of functional programs. Sci. Comput. Program. 52(1), 101–129 (2004). http://www.sciencedirect.com/science/article/pii/S0167642304000486, special Issue on Program Transformation
Haftmann, F., Krauss, A., Kunčar, O., Nipkow, T.: Data refinement in Isabelle/HOL. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 100–115. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-39634-2_10
Haftmann, F., Nipkow, T.: Code generation via higher-order rewrite systems. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 103–117. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-12251-4_9
Hatcliff, J., Danvy, O.: A generic account of continuation-passing styles. In: Conf. Record of POPL’94: 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 458–471 (1994), http://doi.acm.org/10.1145/174675.178053
Itzhaky, S., Singh, R., Solar-Lezama, A., Yessenov, K., Lu, Y., Leiserson, C., Chowdhury, R.: Deriving divide-and-conquer dynamic programming algorithms using solver-aided transformations. In: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, pp. 145–164. ACM (2016). http://doi.acm.org/10.1145/2983990.2983993
Kleinberg, J.M., Tardos, É.: Algorithm Design. Addison-Wesley (2006)
Krauss, A.: Automating recursive definitions and termination proofs in higher-order logic. Ph.D. thesis, Technical University Munich (2009). http://mediatum2.ub.tum.de/doc/681651/document.pdf
Kuncar, O.: Types, abstraction and parametric polymorphism in higher-order logic. Ph.D. thesis, Technical University Munich, Germany (2016). http://nbn-resolving.de/urn:nbn:de:bvb:91-diss-20160408-1285267-1-5
Lammich, P.: Refinement to Imperative/HOL. In: Urban, C., Zhang, X. (eds.) ITP 2015. LNCS, vol. 9236, pp. 253–269. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-22102-1_17
Lammich, P., Wimmer, S.: VerifyThis 2018 – Polished Isabelle solutions. Archive of Formal Proofs, April 2018. http://isa-afp.org/entries/VerifyThis2018.html, Formal proof development
Michie, D.: Memo functions and machine learning. Nature 218, 19–22 (1968)
Nipkow, T., Klein, G.: Concrete Semantics with Isabelle/HOL. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-10542-0. http://concrete-semantics.org
Nipkow, T., Wenzel, M., Paulson, L.C. (eds.): Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9
Nipkow, T., Somogyi, D.: Optimal binary search tree. Archive of Formal Proofs (2018). http://isa-afp.org/entries/Optimal_BST.html, Formal proof development
Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: IFIP Congress, pp. 513–523 (1983)
Slind, K.: Reasoning about terminating functional programs. Ph.D. thesis, Technical University Munich, Germany (1999). https://mediatum.ub.tum.de/node?id=601660
Verma, K.N., Goubault-Larrecq, J., Prasad, S., Arun-Kumar, S.: Reflecting BDDs in Coq. In: Jifeng, H., Sato, M. (eds.) ASIAN 2000. LNCS, vol. 1961, pp. 162–181. Springer, Heidelberg (2000). https://doi.org/10.1007/3-540-44464-5_13
Wadler, P.: Theorems for free! In: Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, FPCA 1989, pp. 347–359. ACM (1989). http://doi.acm.org.eaccess.ub.tum.de/10.1145/99370.99404
Wimmer, S.: Hidden Markov models. Archive of Formal Proofs (2018). http://isa-afp.org/entries/Hidden_Markov_Models.html, Formal proof development
Wimmer, S., Hu, S., Nipkow, T.: Monadification, memoization and dynamic programming. Archive of Formal Proofs (2018). http://isa-afp.org/entries/Monad_Memo_DP.html, Formal proof development
Acknowledgments
Tobias Nipkow is supported by DFG Koselleck grant NI 491/16-1. The authors would like to thank Andreas Lochbihler for a fruitful discussion on monadification.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG, part of Springer Nature
About this paper
Cite this paper
Wimmer, S., Hu, S., Nipkow, T. (2018). Verified Memoization and Dynamic Programming. In: Avigad, J., Mahboubi, A. (eds) Interactive Theorem Proving. ITP 2018. Lecture Notes in Computer Science(), vol 10895. Springer, Cham. https://doi.org/10.1007/978-3-319-94821-8_34
Download citation
DOI: https://doi.org/10.1007/978-3-319-94821-8_34
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-94820-1
Online ISBN: 978-3-319-94821-8
eBook Packages: Computer ScienceComputer Science (R0)