Codatatype: A (co)datatype package based on bounded natural functors (BNFs)

The Codatatype package provides a fully modular framework for constructing inductive and coinductive datatypes in HOL, with support for mixed mutual and nested (co)recursion. Mixed (co)recursion enables type definitions involving both datatypes and codatatypes, such as the type of finitely branching trees of possibly infinite depth. The framework draws heavily from category theory.

The package is described in the following paper:

The main entry point for applications is Codatatype.thy. The Examples directory contains various examples of (co)datatypes, including the examples from the paper.

The key notion underlying the package is that of a bounded natural functor (BNF)—an enriched type constructor satisfying specific properties preserved by interesting categorical operations (composition, least fixed point, and greatest fixed point). The Basic_BNFs.thy file registers various basic types, notably for sums, products, function spaces, finite sets, multisets, and countable sets. Custom BNFs can be registered as well.

Warning: The package is under development. Future versions are expected to support multiple constructors and selectors per (co)datatype (instead of a single fld or unf constant) and provide a nicer syntax for (co)induction and (co)recursive function definitions. Please contact any nonempty subset of the above authors if you have questions or comments.