-
Notifications
You must be signed in to change notification settings - Fork 717
feat: port Batteries.WF for executable well-founded fixpoints #11620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
Do we have an issue tracking this? But assuming the compiled code you get from using this here is reasonable, I'm happy to have this in core. We should make |
|
No issue tracking -- happy to add one if that is helpful. For performance, I did a little bit of testing with a function defined using this and another defined relying on the elaborator introducing well-founded induction; profiling results in #eval were similar. I'd naively expect the compiler may do better with the elaborator generated code, since I assume that generates better code, but I haven't really tested it. |
|
Happy to merge without an issue once CI is happy. |
|
CI checks seem to be working. I looked into the Batteries failure, and it is the expected name failures. I think that's a trivial fix, but I don't have permission to push to batteries. |
This PR ports Batteries.WF to Init.WFC for executable well-founded fixpoints. It introduces
csimptheorems to replace the recursors and non-executable definitions with executable definitions.This ocassionally comes up on Zulip as it prevents admiting definitions generated from well-founded induction. (e.g., #lean4 > Computable WellFounded.fix and #mathlib4 > Why Nat.find is computable, when Wellfounded.fix isn't?).
This was motivated by running into poor elaboration performance with recursive definitions involving complex inductive types generated by a custom elaborator. It would be helpful to explore bypassing the elaborator and generating elaborated terms directly, but this requires an executable fixpoint (such as
WellFounded.fixCintroduced in batteries).