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

feat(tactic/lint): add linter for simp lemmas whose lhs has a variable as head symbol #2038

Merged
merged 2 commits into from Feb 24, 2020

Conversation

gebner
Copy link
Member

@gebner gebner commented Feb 22, 2020

Motivation: you write a very useful simp lemma ∀ f : ℕ → ℕ, ∀ x, f x = 0. But it doesn't work. What happened? The simplifier indexes each simp lemma by the head symbol of the left-hand side. In this case it is f---however it is a fresh temporary meta variable created when adding the simp lemma to the simp set. Since this meta variable does not occur anywhere else, the lemma will never fire.

This PR introduces a linter for such simp lemmas and fixes all issues in mathlib.

Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm happy there were only a few failing declarations here.

scripts/mk_all.sh Outdated Show resolved Hide resolved
src/tactic/lint.lean Outdated Show resolved Hide resolved
@robertylewis
Copy link
Member

I think this is ready too, but #2041 will cause merge conflicts, so let's update this after that one lands.

@robertylewis robertylewis added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Feb 24, 2020
@robertylewis
Copy link
Member

robertylewis commented Feb 24, 2020

Wait, does this still add the new linter to CI?

Edit -- yes, I think it does, all good.

@gebner
Copy link
Member Author

gebner commented Feb 24, 2020

Since #2041, the CI automatically uses all the default linters. There was one linter that we didn't run in CI, namely has_inhabited_instance, which I originally didn't enable by default because I didn't know how to update nolints.txt.

If we want to run fewer or more linters in CI than in the default set, the mathlib_linters definition should be modified here (by erasing/adding elements from/to the list):

let ls := ls.map (λ ⟨n, _⟩, `linter ++ n),

@robertylewis
Copy link
Member

I think we originally set it up to list the CI linters explicitly, in case someone wanted to add a new linter that we didn't want in CI. But this can be done just by not tagging it with @[linter].

@mergify mergify bot merged commit fb878e7 into master Feb 24, 2020
@mergify mergify bot deleted the simp-lc-lint branch February 24, 2020 19:58
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
…e as head symbol (leanprover-community#2038)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
…e as head symbol (leanprover-community#2038)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants