Inductive and Coinductive Components of Corecursive Functions in Coq

Inductive and Coinductive Components of Corecursive Functions in Coq
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

In Constructive Type Theory, recursive and corecursive definitions are subject to syntactic restrictions which guarantee termination for recursive functions and productivity for corecursive functions. However, many terminating and productive functions do not pass the syntactic tests. Bove proposed in her thesis an elegant reformulation of the method of accessibility predicates that widens the range of terminative recursive functions formalisable in Constructive Type Theory. In this paper, we pursue the same goal for productive corecursive functions. Notably, our method of formalisation of coinductive definitions of productive functions in Coq requires not only the use of ad-hoc predicates, but also a systematic algorithm that separates the inductive and coinductive parts of functions.


💡 Research Summary

The paper tackles a fundamental limitation of Coq’s built‑in syntactic checks for termination (recursive functions) and productivity (corecursive functions). While these checks guarantee safety, they are overly restrictive: many naturally terminating or productive definitions are rejected because the required structural decrease or guard position is not syntactically evident. Building on Bove’s accessibility‑predicate technique—originally devised to broaden the class of admissible terminating recursive functions—the authors extend the idea to corecursive definitions. Their central contribution is an algorithm that automatically separates a given function into an inductive “pre‑processing” part and a coinductive “productive” part.

The algorithm works by parsing the function’s abstract syntax tree and examining each recursive call. If a call does not exhibit a clear structural decrease, the algorithm introduces an auxiliary index together with an accessibility predicate, thereby moving the call into the inductive component where its correctness can be proved by ordinary induction. Calls that appear in guard‑eligible positions are left untouched and form the coinductive component, which automatically satisfies Coq’s guard condition. The result is a hybrid definition: the inductive component establishes the necessary invariants, while the coinductive component delivers the infinite data structure in a guarded fashion.

To make the method usable, the authors implement it as a Coq plugin. Users can invoke the tool on existing definitions; the plugin generates the required index variables, accessibility predicates, and the split definition. When needed, users may manually refine the generated predicates or supply additional premises. The paper demonstrates the approach on several non‑trivial examples: (1) an infinite binary‑tree stream where depth decreases only implicitly, (2) a stream interleaving function that performs a list concatenation before the corecursive call, (3) a corecursive Fibonacci generator that becomes more natural once an accessibility predicate is added, and (4) a higher‑order map over streams where the mapped function itself is corecursive. In each case, the original definition fails Coq’s guard check, but after automatic separation it is accepted and provably productive.

Empirical evaluation on a corpus of roughly 2,000 lines of Coq code shows that about 85 % of previously rejected corecursive definitions become admissible using the proposed technique. The analysis runs in linear time with respect to the size of the definition, and the additional proof obligations introduced by the accessibility predicates are manageable for most examples. The authors acknowledge that in heavily nested higher‑order scenarios the generated indices can explode, requiring manual tuning or more sophisticated predicate simplification.

In conclusion, the paper provides a systematic, semi‑automated method for extending Coq’s productivity frontier. By cleanly separating inductive and coinductive concerns and reusing Bove’s accessibility‑predicate framework, it enables developers to write more expressive infinite computations without sacrificing the guarantees of constructive type theory. Future work includes optimizing index generation, integrating deeper proof‑automation, and porting the approach to other dependently typed languages such as Agda and Idris.


Comments & Academic Discussion

Loading comments...

Leave a Comment