Skip to content

[Merged by Bors] - feat(Tactic/Linter/UnusedTactic): also lint inside conv => - #42416

Closed
JovanGerb wants to merge 6 commits into
leanprover-community:masterfrom
JovanGerb:Jovan-unusedTactics-conv
Closed

[Merged by Bors] - feat(Tactic/Linter/UnusedTactic): also lint inside conv =>#42416
JovanGerb wants to merge 6 commits into
leanprover-community:masterfrom
JovanGerb:Jovan-unusedTactics-conv

Conversation

@JovanGerb

@JovanGerb JovanGerb commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This PR extends the unused tactic linter to also lint inside conv =>/conv_lhs =>/slice_lhs i j =>. It is sometimes neccessary to use the skip conv mode tactic to skip goals you don't want to conv into, so I added the conv mode skip to the list of exception tactics.

I also added a test, and did some general cleanup:

  • The warning message of the linter is improved.
  • The hard-coded exception that #show_kind had, is replaced with just adding it to the list of exceptions.

After this, the unused tactic linter will (almost entirely) subsume the unreachable tactic linter. So, we will be able to turn it off, which will gain us quite a bit of performance.


Open in Gitpod

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

PR summary fdd74a788a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit fdd74a7).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit fdd74a788a
Reference commit 8cbb95e6e0

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for doing this. This seems reasonable - I just have three minor comments.

Comment thread MathlibTest/Linter/UnusedTactic.lean Outdated
Comment thread MathlibTest/Linter/UnusedTactic.lean Outdated
Comment thread Mathlib/Tactic/Linter/UnusedTactic.lean Outdated
@grunweg grunweg added awaiting-author A reviewer has asked the author a question or requested changes. t-meta Tactics, attributes or user commands labels Aug 4, 2026
@JovanGerb JovanGerb removed the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 4, 2026

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for doing this! I'd like another pair of eyes in the changes to Fubini.lean; the linter changes LGTM.
maintainer merge?

@grunweg

grunweg commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Oh, and can you update the PR description to mention the wording tweaks also?

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by grunweg.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Aug 4, 2026
(colimit.ι _ j ≫ colimit.ι (F.flip ⋙ colim) k : _ ⟶ colimit (F.flip ⋙ colim)) := by
dsimp [colimitFlipCompColimIsoColimitCompColim]
slice_lhs 1 3 => simp only
conv_lhs => slice 1 3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This can also be written as slice_lhs 1 3 => skip. I'm not sure which is preferred.

@adomani

adomani commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Thanks!

A very minor omission is a test for the guardHyp/guardTarget behaviour.

bors d+

@mathlib-bors mathlib-bors Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Aug 7, 2026
@mathlib-bors

mathlib-bors Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

✌️ JovanGerb can now approve this pull request until 2026-08-21 07:25 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

⚠️ This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Aug 7, 2026
@JovanGerb

JovanGerb commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

The test file is very small - most things aren't tested. Should I add tests for all the exceptions?

@adomani

adomani commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Not all necessarily, but it seems like the guards are excepted via a slightly different route than, say, skip in conv mode, so one unlinted guard is probably enough.

Thanks!

@JovanGerb

Copy link
Copy Markdown
Contributor Author

It looks like the guards are excepted via a different mechanism than the skip, but it is secretly the same mechanism. I will make another PR cleaning this up, and that PR will also remove the UnusedTacticExtension file, since it is not needed to have this separate file.

bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Aug 7, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Aug 7, 2026
This PR extends the unused tactic linter to also lint inside `conv =>`/`conv_lhs =>`/`slice_lhs i j =>`. It is sometimes neccessary to use the `skip` conv mode tactic to skip goals you don't want to conv into, so I added the conv mode skip to the list of exception tactics.

I also added a test, and did some general cleanup:
- The warning message of the linter is improved.
- The hard-coded exception that `#show_kind` had, is replaced with just adding it to the list of exceptions.

After this, the unused tactic linter will (almost entirely) subsume the unreachable tactic linter. So, we will be able to turn it off, which will gain us quite a bit of performance.
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Aug 7, 2026
@mathlib-bors

mathlib-bors Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat(Tactic/Linter/UnusedTactic): also lint inside conv => [Merged by Bors] - feat(Tactic/Linter/UnusedTactic): also lint inside conv => Aug 7, 2026
@mathlib-bors mathlib-bors Bot closed this Aug 7, 2026
@mathlib-bors mathlib-bors Bot removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants