Abstract

Coinductive data structures, such as streams or infinite trees, have many applications in functional programming and type theory, and are naturally defined using recursive equations. But how do we ensure that such equations make sense, i.e. that they actually generate a productive infinite object? A standard means to achieve productivity is to use Banach's fixed-point theorem, which guarantees the unique existence of solutions to recursive equations on metric spaces under certain conditions. Functions satisfying these conditions are called contractions. In this article, we give a new characterization of contractions on streams in the form of a sound and complete representation theorem, and generalize this result to a wide class of non-well-founded structures, first to infinite binary trees, then to final coalgebras of container functors.These results have important potential applications in functional programming, where coinduction and corecursion are successfully deployed to model continuous reactive systems, dynamic interactivity, signal processing, and other tasks that require flexible manipulation of non-well-founded data. Our representation theorems provide a definition paradigm to compactly compute with such data and easily reason about them.

Highlights

  • Coinductive types, data structures with potentially in nite unfolding, are becoming a standard feature of functional programming languages and type theoretic systems

  • Given a recursive equation that speci es an element of a coinductive type in terms of itself, under what conditions is the existence of a unique solution certain? In the dual case of recursive de nitions over inductive types, we are interested in the eventual termination of the unfolding of the equation: the structure should be well-founded and the computation should eventually yield a completed element

  • We extend the characterization to richer data structures, rst to binary trees and to nal coalgebras of container functors

Read more

Summary

INTRODUCTION

Coinductive types, data structures with potentially in nite unfolding, are becoming a standard feature of functional programming languages and type theoretic systems. We can de ne a unique function into a coinductive type by giving a coalgebra on the domain This is a simple and theoretically transparent technique, but it does not apply directly to most cases of interest and forces the programmers to rewrite their code, often requiring complex intermediate data structures [10, 11, 18, 44]. We can associate to a coinductive type a notion of distance between its elements and exploit standard mathematical theorems that ensure the existence of solutions. The chief among these is Banach’s theorem, which states that every contractive function on a complete metric space has a unique xed point. Our main result provides a sound and complete representation of contractions on a wide class of nal coalgebras

METRIC SPACES AND BANACH’S THEOREM
CONTRACTIONS ON STREAMS
Recursive Equations
Fixed Points
Contractive Functions
REPRESENTATION THEOREM
EXAMPLES
CONTRACTIONS ON FINAL COALGEBRAS
CONTRACTIONS ON BINARY TREES
CONTRACTIONS ON CONTAINERS
INSTANTIATIONS FOR STREAMS AND TREES
10 SUMMARY AND CONCLUSION
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call