Calculating a backtracking algorithm: an exercise in monadic program derivation

by   Shin-Cheng Mu, et al.

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 π‘ π‘π‘Žπ‘›π‘™-like predicate. We develop theorems that convert a variation of π‘ π‘π‘Žπ‘›π‘™ to a π‘“π‘œπ‘™π‘‘π‘Ÿ 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.



There are no comments yet.


page 1

page 2

page 3

page 4

βˆ™ 01/27/2021

Deriving monadic quicksort (Declarative Pearl)

To demonstrate derivation of monadic programs, we present a specificatio...
βˆ™ 07/16/2021

SMLtoCoq: Automated Generation of Coq Specifications and Proof Obligations from SML Programs with Contracts

Formally reasoning about functional programs is supposed to be straightf...
βˆ™ 03/05/2002

Two results for proiritized logic programming

Prioritized default reasoning has illustrated its rich expressiveness an...
βˆ™ 08/21/2019

Free Theorems Simply, via Dinaturality

Free theorems are a popular tool in reasoning about parametrically polym...
βˆ™ 05/17/2020

A Practical Algorithm for the Computation of the Genus

We describe a practical algorithm to compute the (oriented) genus of a g...
βˆ™ 06/24/2021

Consistent ultrafinitist logic

Ultrafinitism postulates that we can only compute on relatively short ob...
βˆ™ 09/29/2020

Isomorphic Data Type Transformations

In stepwise derivations of programs from specifications, data type refin...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.