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

The BNF 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 BNF.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 and More_BNFs.thy files register 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. Please contact any nonempty subset of the above authors if you have questions or comments.