Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simpNF linter does not handle conditional simp lemmas correctly #365

Open
eric-wieser opened this issue Nov 15, 2023 · 0 comments
Open

simpNF linter does not handle conditional simp lemmas correctly #365

eric-wieser opened this issue Nov 15, 2023 · 0 comments

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Nov 15, 2023

The linter fails here, but I claim it should succeed:

import Std

@[simp] theorem cast_fin_h {n m : Nat} (h : m = n) (a : Fin (m + 2)) : (cast (by rw [h]) a : Fin (n + 2)) = (a : Nat) := by cases h; rfl

#lint
#check @cast_fin_h /- Left-hand side does not simplify, when using the simp lemma on itself.
This usually means that it will never apply.
 -/

-- but `simp` works just fine
example {n m : Nat} (h : m = n) (a : Fin (m + 2)) : (cast (by rw [h]) a : Fin (n + 2)) = (a : Nat) := by
  simp [h]

I think this code is falsely concluding that this is not a conditional simp lemma:
https://github.com/leanprover/std4/blob/c14f6a65b2c08caa38e1ab5db83451460d6cde3e/Std/Tactic/Lint/Simp.lean#L35-L45

The check for "appears on the LHS" should not visit Prop subexpressions, as those aren't found by unification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant