@@ -117,18 +117,14 @@ else if ¬ is_cond ∧ lhs = lhs' then do
117
117
else
118
118
pure none
119
119
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.
127
123
These lemmas are hence never used by the simplifier.
128
124
129
125
This linter gives you a list of other simp lemmas, look at them!
130
126
131
- Here are some guidelines to get you started :
127
+ Here are some tips depending on the error raised by the linter :
132
128
133
129
1. 'the left-hand side reduces to XYZ':
134
130
you should probably use XYZ as the left-hand side.
@@ -155,6 +151,26 @@ Here are some guidelines to get you started:
155
151
2d. If two lemmas are duplicates, the linter will complain about the first one.
156
152
Try to fix the second one instead!
157
153
(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
158
174
" }
159
175
160
176
private meta def simp_var_head (d : declaration) : tactic (option string) := do
0 commit comments