You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current output messages in the flexible linter are:
- If the stained location is a hypothesis:
`'exact h' uses 'h'!`
- If the stained location is the goal:
`'exact Nat.le_succ_of_le h' uses '⊢'!`
I think the first is not very informative and the second is additionally confusing. So this PR changes them to read:
- For a hypothesis:
`'exact h' uses 'h', which was modified by the flexible tactic 'simp' on line 40!`
- And for the goal:
`'exact Nat.le_succ_of_le h' modifies the current goal, which was modified by the flexible tactic 'simp_all' on line 56!`
I also added some more explanation to the messages in the case that all the hypotheses and the goal were stained by `simp at *`.
This file contains basic tests for the flexible linter, which do not require any advanced imports.
16
16
Anything which requires groups, rings or algebraic structures is considered advanced, and
17
-
tests for these can be found in `MathlibTest/ImportHeavyFlexibleLinter.lean`
17
+
tests for these can be found in `MathlibTest/Linter/Flexible/ImportHeavy.lean`
18
18
19
+
TODO: make output message appear only once for wildcard
19
20
-/
20
21
22
+
21
23
defn : Nat := 1
22
24
defm : Nat := 1
23
25
@@ -27,18 +29,33 @@ example : n = m := by
27
29
simp [n]
28
30
simp [m]
29
31
32
+
-- the given line number is correct
30
33
/--
31
34
warning: `simp at h` is a flexible tactic modifying `h`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
32
35
33
36
Note: This linter can be disabled with `set_option linter.flexible false`
34
37
---
35
-
info: `exact h` uses `h`!
38
+
info: `exact h`
39
+
uses `h`, which was modified by the flexible tactic `simp` on line 43!
36
40
-/
37
41
#guard_msgs in
38
42
example (h : 0 + 0 = 0) : True := by
39
43
simp at h
40
44
try exact h
41
45
46
+
/--
47
+
warning: `simp at h` is a flexible tactic modifying `h`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
48
+
49
+
Note: This linter can be disabled with `set_option linter.flexible false`
50
+
---
51
+
info: `exact h`
52
+
uses `h`, which was modified by the flexible tactic `simp` on line
53
+
-/
54
+
#guard_msgs (substring := true) in
55
+
example (h : 0 + 0 = 0) : True := by
56
+
simp at h
57
+
try exact h
58
+
42
59
/--
43
60
warning: `simp_all` is a flexible tactic modifying `⊢`. Try `simp_all?` and use the suggested `simp_all only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
44
61
@@ -47,13 +64,106 @@ Note: This linter can be disabled with `set_option linter.flexible false`
47
64
info: Try this:
48
65
[apply] simp_all only [Nat.add_zero]
49
66
---
50
-
info: `exact Nat.le_succ_of_le h` uses `⊢`!
67
+
info: `exact Nat.le_succ_of_le h`
68
+
modifies the current goal, which was modified by the flexible tactic `simp_all` on line
51
69
-/
52
-
#guard_msgs in
70
+
#guard_msgs (substring := true) in
53
71
example {a b : Nat} (h : a ≤ b) : a + 0 ≤ b + 1 := by
54
72
simp_all
55
73
exact Nat.le_succ_of_le h
56
74
75
+
/--
76
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
77
+
78
+
Note: This linter can be disabled with `set_option linter.flexible false`
79
+
---
80
+
info: Try this:
81
+
[apply] simp only [Nat.add_zero] at *
82
+
---
83
+
info: `exact Nat.le_succ_of_le h`
84
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line 98.
85
+
---
86
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
87
+
88
+
Note: This linter can be disabled with `set_option linter.flexible false`
89
+
---
90
+
info: Try this:
91
+
[apply] simp only [Nat.add_zero] at *
92
+
---
93
+
info: `exact Nat.le_succ_of_le h`
94
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line
95
+
-/
96
+
#guard_msgs (substring := true) in
97
+
example {a b : Nat} (h : a ≤ b) : a + 0 ≤ b + 1 := by
98
+
simp at *
99
+
exact Nat.le_succ_of_le h
100
+
101
+
/--
102
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
103
+
104
+
Note: This linter can be disabled with `set_option linter.flexible false`
105
+
---
106
+
info: `exact h2`
107
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line 118.
108
+
---
109
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
110
+
111
+
Note: This linter can be disabled with `set_option linter.flexible false`
112
+
---
113
+
info: `exact h2`
114
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line
115
+
-/
116
+
#guard_msgs (substring := true) in
117
+
example {a b : Nat} (h1 : 0 + 0 = 0) (h2 : a ≤ b) : a ≤ b := by
118
+
simp at *
119
+
exact h2
120
+
121
+
/--
122
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
123
+
124
+
Note: This linter can be disabled with `set_option linter.flexible false`
125
+
---
126
+
info: `exact h2`
127
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line 138.
128
+
---
129
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
130
+
131
+
Note: This linter can be disabled with `set_option linter.flexible false`
132
+
---
133
+
info: `exact h2`
134
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line
135
+
-/
136
+
#guard_msgs (substring := true) in
137
+
example {a b : Nat} (h1 : 0 + 0 = 0) (h2 : a ≤ b) : a ≤ b := by
138
+
simp at *
139
+
exact h2
140
+
141
+
/--
142
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
143
+
144
+
Note: This linter can be disabled with `set_option linter.flexible false`
145
+
---
146
+
info: Try this:
147
+
[apply] simp only [Nat.add_zero] at *
148
+
---
149
+
info: `exact h`
150
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line 164.
151
+
---
152
+
warning: `simp at *` is a flexible tactic that potentially modifies all hypotheses and the current goal with a wildcard `*`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
153
+
154
+
Note: This linter can be disabled with `set_option linter.flexible false`
155
+
---
156
+
info: Try this:
157
+
[apply] simp only [Nat.add_zero] at *
158
+
---
159
+
info: `exact h`
160
+
uses a rigid tactic. Previously, the flexible tactic `simp`, which potentially modified all hypotheses and the goal with a wildcard `*`, was used on line
161
+
-/
162
+
#guard_msgs (substring := true) in
163
+
example {a b : Nat} (h : a = b) : a + 0 = b := by
164
+
simp at *
165
+
exact h
166
+
57
167
-- `subst` does not use the goal
58
168
#guard_msgs in
59
169
example {a b : Nat} (h : a = b) : a + 0 = b := by
@@ -78,7 +188,8 @@ Note: This linter can be disabled with `set_option linter.flexible false`
78
188
info: Try this:
79
189
[apply] simp only [Nat.add_zero]
80
190
---
81
-
info: `assumption` uses `⊢`!
191
+
info: `assumption`
192
+
modifies the current goal, which was modified by the flexible tactic `simp` on line 206!
82
193
---
83
194
warning: `simp` is a flexible tactic modifying `⊢`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
84
195
@@ -87,9 +198,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
87
198
info: Try this:
88
199
[apply] simp only [Nat.add_zero]
89
200
---
90
-
info: `assumption` uses `⊢`!
201
+
info: `assumption`
202
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
91
203
-/
92
-
#guard_msgs in
204
+
#guard_msgs (substring := true) in
93
205
example {a b : Nat} (h : a = b) : a + 0 = b := by
94
206
simp
95
207
induction a <;> assumption
@@ -99,9 +211,10 @@ warning: `simp at h` is a flexible tactic modifying `h`. Try `simp?` and use the
99
211
100
212
Note: This linter can be disabled with `set_option linter.flexible false`
101
213
---
102
-
info: `exact h` uses `h`!
214
+
info: `exact h`
215
+
uses `h`, which was modified by the flexible tactic `simp` on line
103
216
-/
104
-
#guard_msgs in
217
+
#guard_msgs (substring := true) in
105
218
example (h : 0 = 0 ∨ 0 = 0) : True := by
106
219
cases h <;>
107
220
rename_i h <;>
@@ -117,7 +230,8 @@ Note: This linter can be disabled with `set_option linter.flexible false`
117
230
info: Try this:
118
231
[apply] simp only [Nat.zero_ne_one, and_self]
119
232
---
120
-
info: `on_goal 2 => · contradiction` uses `⊢`!
233
+
info: `on_goal 2 => · contradiction`
234
+
modifies the current goal, which was modified by the flexible tactic `simp` on line 248!
121
235
---
122
236
warning: `simp` is a flexible tactic modifying `⊢`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
123
237
@@ -126,9 +240,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
126
240
info: Try this:
127
241
[apply] simp only [Nat.zero_ne_one, and_self]
128
242
---
129
-
info: `contradiction` uses `⊢`!
243
+
info: `contradiction`
244
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
130
245
-/
131
-
#guard_msgs in
246
+
#guard_msgs (substring := true) in
132
247
example (h : 0 = 1 ∨ 0 = 1) : 0 = 1 ∧ 0 = 1 := by
133
248
cases h <;> simp
134
249
on_goal 2 => · contradiction
@@ -146,7 +261,8 @@ Note: This linter can be disabled with `set_option linter.flexible false`
146
261
info: Try this:
147
262
[apply] simp only [Nat.zero_ne_one, and_self]
148
263
---
149
-
info: `contradiction` uses `⊢`!
264
+
info: `contradiction`
265
+
modifies the current goal, which was modified by the flexible tactic `simp` on line 279!
150
266
---
151
267
warning: `simp` is a flexible tactic modifying `⊢`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
152
268
@@ -155,9 +271,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
155
271
info: Try this:
156
272
[apply] simp only [Nat.zero_ne_one, and_self]
157
273
---
158
-
info: `contradiction` uses `⊢`!
274
+
info: `contradiction`
275
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
159
276
-/
160
-
#guard_msgs in
277
+
#guard_msgs (substring := true) in
161
278
example (h : 0 = 1 ∨ 0 = 1) : 0 = 1 ∧ 0 = 1 := by
162
279
cases h <;> simp
163
280
· contradiction
@@ -168,15 +285,17 @@ warning: `simp at h k` is a flexible tactic modifying `k`. Try `simp?` and use t
168
285
169
286
Note: This linter can be disabled with `set_option linter.flexible false`
170
287
---
171
-
info: `rw [← Classical.not_not (a := True)] at k` uses `k`!
288
+
info: `rw [← Classical.not_not (a := True)] at k`
289
+
uses `k`, which was modified by the flexible tactic `simp` on line 301!
172
290
---
173
291
warning: `simp at h k` is a flexible tactic modifying `h`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
174
292
175
293
Note: This linter can be disabled with `set_option linter.flexible false`
176
294
---
177
-
info: `rw [← Classical.not_not (a := True)] at h` uses `h`!
295
+
info: `rw [← Classical.not_not (a := True)] at h`
296
+
uses `h`, which was modified by the flexible tactic `simp` on line
178
297
-/
179
-
#guard_msgs in
298
+
#guard_msgs (substring := true) in
180
299
-- `simp at h` stains `h` but not other locations
181
300
example {h : 0 = 0} {k : 1 = 1} : True := by
182
301
simp at h k;
@@ -201,9 +320,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
201
320
info: Try this:
202
321
[apply] simp only [Nat.add_zero]
203
322
---
204
-
info: `exact h.symm` uses `⊢`!
323
+
info: `exact h.symm`
324
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
205
325
-/
206
-
#guard_msgs in
326
+
#guard_msgs (substring := true) in
207
327
-- `congr` is allowed after `simp`, but "passes along the stain".
208
328
example {a b : Nat} (h : a = b) : a + b + 0 = b + a := by
209
329
simp
@@ -248,9 +368,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
248
368
info: Try this:
249
369
[apply] simp only [Nat.zero_ne_one, and_self]
250
370
---
251
-
info: `contradiction` uses `⊢`!
371
+
info: `contradiction`
372
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
252
373
-/
253
-
#guard_msgs in
374
+
#guard_msgs (substring := true) in
254
375
example (h : 0 = 1 ∨ 0 = 1) : 0 = 1 ∧ 0 = 1 := by
255
376
cases h <;> simp
256
377
· simp_all
@@ -277,9 +398,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
277
398
info: Try this:
278
399
[apply] simp only [not_true_eq_false, not_false_eq_true] at h
279
400
---
280
-
info: `rw [← Classical.not_not (a := True)] at h` uses `h`!
401
+
info: `rw [← Classical.not_not (a := True)] at h`
402
+
uses `h`, which was modified by the flexible tactic `simp` on line
281
403
-/
282
-
#guard_msgs in
404
+
#guard_msgs (substring := true) in
283
405
-- `simp at h` stains `h` but not other locations
284
406
example {h : 0 = 0} {k : 1 = 1} : ¬ ¬ True := by
285
407
simp at h
@@ -294,15 +416,17 @@ warning: `simp at h k` is a flexible tactic modifying `k`. Try `simp?` and use t
294
416
295
417
Note: This linter can be disabled with `set_option linter.flexible false`
296
418
---
297
-
info: `rw [← Classical.not_not (a := True)] at k` uses `k`!
419
+
info: `rw [← Classical.not_not (a := True)] at k`
420
+
uses `k`, which was modified by the flexible tactic `simp` on line 432!
298
421
---
299
422
warning: `simp at h k` is a flexible tactic modifying `h`. Try `simp?` and use the suggested `simp only [...]`. Alternatively, use `suffices` to explicitly state the simplified form.
300
423
301
424
Note: This linter can be disabled with `set_option linter.flexible false`
302
425
---
303
-
info: `rw [← Classical.not_not (a := True)] at h` uses `h`!
426
+
info: `rw [← Classical.not_not (a := True)] at h`
427
+
uses `h`, which was modified by the flexible tactic `simp` on line
304
428
-/
305
-
#guard_msgs in
429
+
#guard_msgs (substring := true) in
306
430
-- `simp at h` stains `h` but not other locations
307
431
example {h : 0 = 0} {k : 1 = 1} : True := by
308
432
simp at h k
@@ -317,9 +441,10 @@ warning: `simp at h` is a flexible tactic modifying `h`. Try `simp?` and use the
317
441
318
442
Note: This linter can be disabled with `set_option linter.flexible false`
319
443
---
320
-
info: `rw [← Classical.not_not (a := True)] at h` uses `h`!
444
+
info: `rw [← Classical.not_not (a := True)] at h`
445
+
uses `h`, which was modified by the flexible tactic `simp` on line
321
446
-/
322
-
#guard_msgs in
447
+
#guard_msgs (substring := true) in
323
448
-- `simp at h` stains `h` but not other locations
324
449
example {h : 0 = 0} : True := by
325
450
simp at h
@@ -336,9 +461,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
336
461
info: Try this:
337
462
[apply] simp only [Nat.zero_ne_one]
338
463
---
339
-
info: `rwa [← Classical.not_not (a := False)]` uses `⊢`!
464
+
info: `rwa [← Classical.not_not (a := False)]`
465
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
340
466
-/
341
-
#guard_msgs in
467
+
#guard_msgs (substring := true) in
342
468
example {h : False} : 0 = 1 := by
343
469
simp
344
470
rw [← Classical.not_not (a := False)] at h
@@ -353,9 +479,10 @@ Note: This linter can be disabled with `set_option linter.flexible false`
353
479
info: Try this:
354
480
[apply] simp only [Nat.zero_ne_one]
355
481
---
356
-
info: `rwa [← Classical.not_not (a := False)]` uses `⊢`!
482
+
info: `rwa [← Classical.not_not (a := False)]`
483
+
modifies the current goal, which was modified by the flexible tactic `simp` on line
0 commit comments