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): linter for commutativity lemmas that are marked si…
…mp (#2045) * feat(tactic/lint): linter for commutativity lemmas that are marked simp * chore(*): remove simp from commutativity lemmas * doc(*): document simp_comm linter Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
450dcdf
commit 089d058
Showing
12 changed files
with
102 additions
and
25 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
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,43 @@ | ||
import tactic.lint | ||
|
||
/-! ## Commutativity lemmas should be rejected -/ | ||
|
||
attribute [simp] add_comm add_left_comm | ||
|
||
open tactic | ||
#eval do | ||
decl ← get_decl ``add_comm, | ||
res ← linter.simp_comm.test decl, | ||
-- linter complains | ||
guard res.is_some | ||
|
||
open tactic | ||
#eval do | ||
decl ← get_decl ``add_left_comm, | ||
res ← linter.simp_comm.test decl, | ||
-- linter complains | ||
guard res.is_some | ||
|
||
/-! ## Floris' trick should be accepted -/ | ||
|
||
@[simp] lemma list.filter_congr_decidable {α} (s : list α) (p : α → Prop) (h : decidable_pred p) | ||
[decidable_pred p] : @list.filter α p h s = s.filter p := | ||
by congr | ||
|
||
-- lemma is unproblematic | ||
example : @list.filter _ (λ x, x > 0) (λ _, classical.prop_decidable _) [1,2,3] = [1,2,3] := | ||
begin | ||
-- can rewrite once | ||
simp only [list.filter_congr_decidable], | ||
-- but not twice | ||
success_if_fail { simp only [list.filter_congr_decidable] }, | ||
refl | ||
end | ||
|
||
open tactic | ||
set_option pp.all true | ||
#eval do | ||
decl ← get_decl ``list.filter_congr_decidable, | ||
res ← linter.simp_comm.test decl, | ||
-- linter does not complain | ||
guard res.is_none |