11

I want to provide proofs for parts of a Haskell program I'm writing as part of my thesis. So far however, I failed to find a good reference work.

Graham Hutton's introductory book Programming in Haskell (Google Books)—which I read while learning Haskell—touches on a few techniques for reasoning about programs such as

  • equational reasoning
  • using non-overlapping patterns
  • list induction

in chapter 13 but it's not very in-depth.

Are there any books or article you can recommend which provide a more detailed overview of formal proving techniques for Haskell, or other functional, code?

Raphael
  • 73,212
  • 30
  • 182
  • 400
FK82
  • 273
  • 2
  • 8

4 Answers4

6

You can start with

Topics include basic concepts of logic, computer-assisted theorem proving, the Coq proof assistant, functional programming, operational semantics, Hoare logic, and static type systems. The exposition is intended for a broad range of readers, from advanced undergraduates to PhD students and researchers. No specific background in logic or programming languages is assumed, though a degree of mathematical maturity will be helpful.

You can skip (or skim) the programming language theory parts and only learn how to deal with formal proofs starting from Preface up to IndPrinciples. The book is really well-written and illuminating.

Then you might want to proceed with

In this volume you will learn how to specify and verify (prove the correctness of) sorting algorithms, binary search trees, balanced binary search trees, and priority queues. Before using this book, you should have some understanding of these algorithms and data structures, available in any standard undergraduate algorithms textbook. You should understand all the material in Software Foundations Volume 1 (Logic Foundations)

A note of warning: VFA is still in beta-release!

Anton Trunov
  • 3,499
  • 1
  • 19
  • 26
5

One of the de facto methods for proving results in functional programming is via Richard Bird's group.

In particular, you ask for an in-depth or at least more comprehensive approach to equational reasoning and list induction and this is provided in Lectures on Constructive Functional Programming.

More generally, the text "Algebra of Programming", by Bird and de Moor, also deals with the correctness of functional algorithms such as optimisation and dynamic programming problems.


If you come across other useful resources for this problem, please mention them and perhaps we can turn this post into a wiki.

Musa Al-hassy
  • 894
  • 1
  • 5
  • 9
5

It turns out that an excellent source of proof techniques and examples for proving things about pure functional languages is proof assistants which usually include as part of their specification language a pure functional language on which it is possible to reason equationally.

One might want to consult a book like Certified Programing with Dependent Types for an in-depth introduction to this kind of reasoning in a specific proof assistant, namely Coq.

cody
  • 8,427
  • 33
  • 64
4

I suggest to use program logics. They deal much better with effects than typing systems.

There are numerous program logics for functional languages. This becomes interesting with effects. See e.g. Logical Reasoning for Higher-Order Functions with Local State.

Work by Arthur Charguéraud integrates the program logic approach with proof assistants, see e.g. this overview page.

Martin Berger
  • 8,358
  • 28
  • 47