leanprover-community / leanprover-community/mathlib4
Noisy `unusedSimpArgs` linter with `field` simproc
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 4.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
The field simproc has an internal simp call to discharge nonzeroness goals. It shares a simp-context with the ambient simp (the simp which called the simproc), but it doesn't share tracking of the simp-lemmas used.
This means:
- The query
simp? [field, ...]may not work: if it fails, the simp trace needs to be manually inspected to find the simp-lemmas being called by the discharger; - In a proof with a
simp [field, ...]call, theunusedSimpArgslinter may be noisy, because it can incorrectly report simp-lemmas as not being used (when in fact they're used in the discharger).
The discarding of the "simp-lemma memory" occurs when the discharger's internal simp call (which is naturally in SimpM) gets packaged as a MetaM program, the discharger type for the core field(_simp) methods (reduceExpr and reduceEq).
In principle this could be fixed by having reduceExpr and reduceEq take dischargers which live in SimpM (rather than MetaM). However, I personally think the long-term plan for the field(_simp) discharger should be get rid of the simp call inside that discharger. Given that, it doesn't make sense to refactor the field_simp code to be SimpM-friendly in the short term.
(The reason we currently include a simp call in the discharger is that it gives a cheap approximation to positivity's nonzeroness-proving in fields without a partial order.)
TL;DR This issue records the behaviour, but we do not want to fix it directly. Hopefully a future refactor will render it moot.
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 by reading the core field(_simp) discharger methods, reduceExpr and reduceEq, and trace how their MetaM dischargers interact with SimpM tracking. Compare the simp? query and unusedSimpArgs behavior described here; no standalone fix is defined, since the issue expects a future discharger refactor to make the behavior moot.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100