Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a443d8b

Browse files
committed
feat(simp_nf): instructions for linter timeout (#3205)
1 parent 9a1c0a6 commit a443d8b

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/tactic/lint/simp.lean

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,14 @@ else if ¬ is_cond ∧ lhs = lhs' then do
117117
else
118118
pure none
119119

120-
/-- A linter for simp lemmas whose lhs is not in simp-normal form, and which hence never fire. -/
121-
@[linter] meta def linter.simp_nf : linter :=
122-
{ test := simp_nf_linter,
123-
auto_decls := tt,
124-
no_errors_found := "All left-hand sides of simp lemmas are in simp-normal form",
125-
errors_found := "SOME SIMP LEMMAS ARE REDUNDANT.
126-
That is, their left-hand side is not in simp-normal form.
120+
/--
121+
This note gives you some tips to debug any errors that the simp-normal form linter raises
122+
The reason that a lemma was considered faulty is because its left-hand side is not in simp-normal form.
127123
These lemmas are hence never used by the simplifier.
128124
129125
This linter gives you a list of other simp lemmas, look at them!
130126
131-
Here are some guidelines to get you started:
127+
Here are some tips depending on the error raised by the linter:
132128
133129
1. 'the left-hand side reduces to XYZ':
134130
you should probably use XYZ as the left-hand side.
@@ -155,6 +151,26 @@ Here are some guidelines to get you started:
155151
2d. If two lemmas are duplicates, the linter will complain about the first one.
156152
Try to fix the second one instead!
157153
(You can find it among the other simp lemmas the linter prints out!)
154+
155+
3. 'try_for tactic failed, timeout':
156+
This typically means that there is a loop of simp lemmas.
157+
Try to apply squeeze_simp to the right-hand side (removing this lemma from the simp set) to see
158+
what lemmas might be causing the loop.
159+
160+
Another trick is to `set_option trace.simplify.rewrite true` and
161+
then apply `try_for 10000 { simp }` to the right-hand side. You will
162+
see a periodic sequence of lemma applications in the trace message.
163+
-/
164+
library_note "simp-normal form"
165+
166+
/-- A linter for simp lemmas whose lhs is not in simp-normal form, and which hence never fire. -/
167+
@[linter] meta def linter.simp_nf : linter :=
168+
{ test := simp_nf_linter,
169+
auto_decls := tt,
170+
no_errors_found := "All left-hand sides of simp lemmas are in simp-normal form",
171+
errors_found := "SOME SIMP LEMMAS ARE NOT IN SIMP-NORMAL FORM.
172+
see note [simp-normal form] for tips how to debug this.
173+
https://leanprover-community.github.io/mathlib_docs/notes.html#simp-normal%20form
158174
" }
159175

160176
private meta def simp_var_head (d : declaration) : tactic (option string) := do

0 commit comments

Comments
 (0)