Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tactic/lint): add linter for simp lemmas whose lhs has a variabl…
…e as head symbol (#2038) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cb4bdd8
commit fb878e7
Showing
6 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import tactic.lint | ||
|
||
-- The following simp lemma has the variable `f` as head symbol of the left-hand side: | ||
@[simp] axiom const_zero_eq_zero (f : ℕ → ℕ) (x) : f x = 0 | ||
|
||
example (f : ℕ → ℕ) : f 42 = 0 := | ||
begin | ||
-- Hence it doesn't work: | ||
success_if_fail {simp}, | ||
|
||
-- BTW, rw doesn't work either: | ||
success_if_fail {rw const_zero_eq_zero}, | ||
|
||
-- It only works if explicitly instantiate with `f`: | ||
simp only [const_zero_eq_zero f] | ||
end | ||
|
||
|
||
open tactic | ||
#eval do | ||
decl ← get_decl ``const_zero_eq_zero, | ||
res ← linter.simp_var_head.test decl, | ||
-- linter complains | ||
guard $ res.is_some |