Implement `grind_propagator` for downstream / mathlib use
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
The grind_propagator command is declared as syntax in src/Init/Grind/Propagator.lean:19, but there is no macro_rules and the comment says -- TODO: not implemented yet. Only builtin_grind_propagator is implemented, and it's intended for use inside lean4 core.
In practice this means downstream users (e.g. mathlib) currently have no working command-level way to register a grind propagator. Concretely:
grind_propagator— parses but has no elab; using it does nothing.builtin_grind_propagatorfrom a mathlibmodule-mode file — the macro emits a non-meta_regBuiltin._declare(viadeclareBuiltin) that references the propagator function. Under the new module system this either fails at compile time ("non-meta declaration cannot access meta declaration") or compiles but crashes the interpreter at module-load time withLEAN ASSERTION VIOLATION ... fn_body_tag(...) != fn_body_kind::Unreachable, because the propagator's IR body isUnreachable. The registration goes through but the propagator can't be invoked.- Calling
registerBuiltinUpwardPropagatordirectly from aninitializeblock (passing the propagator function as an argument) — works, and is what we ended up doing.
We hit this writing a grind propagator on CategoryTheory.CategoryStruct.comp to normalize morphism composition without the Catalan-blowup of e-matching Category.assoc. The propagator + helpers live in Mathlib/CategoryTheory/Tactic/GrindCatNorm.lean (mathlib branch grind_cat_assoc).
Request: implement grind_propagator so it works from downstream module-mode files — likely as a macro_rules that expands to an initialize calling registerBuiltinUpwardPropagator / registerBuiltinDownwardPropagator, rather than going through declareBuiltin. If the "builtin"/"non-builtin" distinction is meant to remain meaningful, the docstring should also explain which form mathlib-style downstream code should use.
cc @leodemoura
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.
Research direction
Start in src/Init/Grind/Propagator.lean at the grind_propagator syntax and compare it with builtin_grind_propagator. Use Mathlib/CategoryTheory/Tactic/GrindCatNorm.lean and its initialize-based registration as the downstream example. Done means a propagator registers and can be invoked from a downstream module-mode file, with the builtin distinction documented if it remains relevant.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100