Reasoning about codata

  • Authors:
  • Ralf Hinze

  • Affiliations:
  • Computing Laboratory, University of Oxford, Oxford, England

  • Venue:
  • CEFP'09 Proceedings of the Third summer school conference on Central European functional programming school
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

Programmers happily use induction to prove properties of recursive programs. To show properties of corecursive programs they employ coinduction, but perhaps less enthusiastically. Coinduction is often considered a rather low-level proof method, in particular, as it departs quite radically from equational reasoning. Corecursive programs are conveniently defined using recursion equations. Suitably restricted, these equations possess unique solutions. Uniqueness gives rise to a simple and attractive proof technique, which essentially brings equational reasoning to the coworld. We illustrate the approach using two major examples: streams and infinite binary trees. Both coinductive types exhibit a rich structure: they are applicative functors or idioms, and they can be seen as memo-tables or tabulations. We show that definitions and calculations benefit immensely from this additional structure.