计算机科学 > 程序设计语言
[提交于 2021年1月23日]
标题:Calculating a backtracking algorithm: an exercise in monadic program derivation
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读摘要:Equational reasoning is among the most important tools that functional programming provides us. Curiously, relatively less attention has been paid to reasoning about monadic programs. In this report we derive a backtracking algorithm for problem specifications that use a monadic unfold to generate possible solutions, which are filtered using a $\mathit{scanl}$-like predicate. We develop theorems that convert a variation of $\mathit{scanl}$ to a $\mathit{foldr}$ that uses the state monad, as well as theorems constructing hylomorphism. The algorithm is used to solve the $n$-queens puzzle, our running example. The aim is to develop theorems and patterns useful for the derivation of monadic programs, focusing on the intricate interaction between state and non-determinism.
提交历史
来自:Shin-Cheng Mu[v1] 2021年1月23日 星期六 03:27:20 UTC