Code generator support for recursors
Open
@zwarich is already working on this.
Since Jun 20, 2025.
P-medium
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Checked that your issue isn't already filed.
- Reduced the issue to a self-contained, reproducible test case.
Description
I couldn't see a tracking issue for this, so thought I'd create one to refer to from mathlib4.
We quite often use Nat.rec and List.rec, and neither are supported by the code generator:
Steps to Reproduce
Run
#eval (List.rec 0 (fun x xs ih => 0) ([] : List Nat) : Nat)
Expected behavior: Prints 0
Actual behavior:
code generator does not support recursor 'List.rec' yet, consider using 'match ... with' and/or structural recursion
Reproduces how often: 100%
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.