Skip to content

[Merged by Bors] - feat(Tactic): automatically replace convert with convert!#39721

Closed
Vierkantor wants to merge 17 commits into
leanprover-community:masterfrom
Vierkantor:convert-to-bang
Closed

[Merged by Bors] - feat(Tactic): automatically replace convert with convert!#39721
Vierkantor wants to merge 17 commits into
leanprover-community:masterfrom
Vierkantor:convert-to-bang

Conversation

@Vierkantor

@Vierkantor Vierkantor commented May 22, 2026

Copy link
Copy Markdown
Contributor

This PR makes any use of convert pop up a "Try this:" message replacing it with convert!. This prepares for #39039 which will make convert change behaviour and convert! retain the old behaviour.

Note that convert and convert! still do the same thing and result in the same goals after this PR is applied, except convert! does not pop up a "Try this:" afterwards.


After the code in this PR passes an initial review, I will run Skimmer to apply all the "Try this:" messages.

Open in Gitpod

This PR prepares for leanprover-community#39039 by adding the required syntax. Once this PR is in, we'll do a global find and replace for changing `convert` to `convert!` (without changing the behaviour), and finally we will enable the new behaviour for `convert`.
This PR sets up an option for `congr!` to close generated goals with configurable transparency, but does not enable this by default. Then it adds a check to `convert` where it will run the `congr!` algorithm at both reducible and default transparency. In the case the default transparency generates different goals, it pops up a "Try this:" suggestion to use `convert!`. Applying all the "Try this:" suggestions to Mathlib means we can then change the semantics of `convert` to close the goals reducibly.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.
@Vierkantor
Vierkantor requested a review from grunweg May 22, 2026 20:02
@Vierkantor Vierkantor added the t-meta Tactics, attributes or user commands label May 22, 2026
@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

PR summary 5230f2468c

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

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.


No changes to strong technical debt.
No changes to weak technical debt.

Comment thread Mathlib/Tactic/CongrExclamation.lean Outdated
@grunweg grunweg self-assigned this May 22, 2026
@grunweg

grunweg commented May 22, 2026

Copy link
Copy Markdown
Contributor

The replacement logic LGTM!

@mathlib-dependent-issues

Copy link
Copy Markdown

Since antiquotations inside the `congr()` elaborator can't be pretty-printed reliably, manually change `convert congr(...)` to `convert! congr(...)`.
@github-actions github-actions Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 22, 2026
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 22, 2026
@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

Commit Verification Summary

Warning

Some verifications failed. See details below.

Commits to Review (15)

  • 381a876: feat(Tactic): add syntax for convert!, convert_to!, ac_change!
  • 7111187: Forgot a @[tactic_alt]
  • 2de70d7: feat(Tactic): automatically replace convert with convert!
  • 64c8460: Revert
  • 0f5e8c5: Unconditionally suggest replacing convert with convert!
  • ea3e0c6: Undo most changes, just add exclamations to all converts
  • d068217: Manual fixes
  • ee2171d: Fixes
  • 39f4323: Final fixes
  • 60a7bd5: Merge remote-tracking branch 'upstream/master' into convert-to-bang
  • bc78238: [pre-commit.ci lite] apply automatic fixes
  • ff707b1: Fix the using and the number being put on separate lines
  • 6f98e11: Fix merge
  • 4e4a807: Disable the "Try this:" message
  • 5230f24: Line length

View PR diff

❌ Automated commits (2) — 0/2 verified

e9127aa: x ./scripts/runSkimmer.sh

Command exited with code 127.

Output:

Note: the functionality provided by this script is experimental and subject to change. This script will become unnecessary in the future.
Please report any issues (especially incomprehensible ones!) to Thomas Murrills on Zulip.
Running `lake update` in `SideSkimmer`. Use `runSkimmer.sh --no-update` to skip this step.
./scripts/runSkimmer.sh: line 131: lake: command not found
Note: `runSkimmer.sh` uses available oleans from the targeted package and builds necessary ones. Consider getting the cache prior to running if possible.
Running `lake build Mathlib:applyCurrentTryThis`.
./scripts/runSkimmer.sh: line 145: lake: command not found
7ab80cd: x ./scripts/runSkimmer.sh --on Archive Counterexamples MathlibTest

Command exited with code 127.

Output:

Note: the functionality provided by this script is experimental and subject to change. This script will become unnecessary in the future.
Please report any issues (especially incomprehensible ones!) to Thomas Murrills on Zulip.
Running `lake update` in `SideSkimmer`. Use `runSkimmer.sh --no-update` to skip this step.
./scripts/runSkimmer.sh: line 131: lake: command not found
Note: `runSkimmer.sh` uses available oleans from the targeted package and builds necessary ones. Consider getting the cache prior to running if possible.
Running `lake build Archive:applyCurrentTryThis`.
./scripts/runSkimmer.sh: line 145: lake: command not found
Running `lake build Counterexamples:applyCurrentTryThis`.
./scripts/runSkimmer.sh: line 145: lake: command not found
Running `lake build MathlibTest:applyCurrentTryThis`.
./scripts/runSkimmer.sh: line 145: lake: command not found

Generated by commit verification CI

@grunweg

grunweg commented May 23, 2026

Copy link
Copy Markdown
Contributor

The current status is good: let's try merging this --- and if there's a conflict in the morning, we can re-do.
bors merge

@mathlib-triage mathlib-triage Bot added the ready-to-merge This PR has been sent to bors. label May 23, 2026
mathlib-bors Bot pushed a commit that referenced this pull request May 23, 2026
This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for #39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@mathlib-bors

mathlib-bors Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Build failed:

Fix if necessary, and then someone with permission can run bors r+ or bors retry.

Comment thread Mathlib/NumberTheory/LSeries/HurwitzZeta.lean Outdated
@grunweg

grunweg commented May 23, 2026

Copy link
Copy Markdown
Contributor

Silly CI error (line length); it seems no merge conflicts yet.

@grunweg

grunweg commented May 23, 2026

Copy link
Copy Markdown
Contributor

CI error is unrelated to this PR (I've just re-run): let's try if this can just be borsed.
bors merge

mathlib-bors Bot pushed a commit that referenced this pull request May 23, 2026
This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for #39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Michael Rothgang <rothgang@math.uni-bonn.de>
@mathlib-bors

mathlib-bors Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Build failed:

Fix if necessary, and then someone with permission can run bors r+ or bors retry.

@grunweg

grunweg commented May 23, 2026

Copy link
Copy Markdown
Contributor

Once more, with feeling:
bors r+

mathlib-bors Bot pushed a commit that referenced this pull request May 23, 2026
This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for #39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Michael Rothgang <rothgang@math.uni-bonn.de>
@mathlib-bors

mathlib-bors Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(Tactic): automatically replace convert with convert! [Merged by Bors] - feat(Tactic): automatically replace convert with convert! May 23, 2026
@mathlib-bors mathlib-bors Bot closed this May 23, 2026
@grunweg

grunweg commented May 23, 2026

Copy link
Copy Markdown
Contributor

It worked 🎉

RaggedR pushed a commit to RaggedR/mathlib4 that referenced this pull request May 24, 2026
…-community#39721)

This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for leanprover-community#39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Michael Rothgang <rothgang@math.uni-bonn.de>
CBirkbeck added a commit to CBirkbeck/mathlib4 that referenced this pull request May 25, 2026
…-one

Conflict in Mathlib/NumberTheory/ModularForms/LevelOne/DimensionFormula.lean
caused by leanprover-community#39721 (convert → convert! rename). Resolved by keeping HEAD —
our refactored `dimension_level_one` proof replaced the `convert; norm_num`
block with `simpa [Nat.ModEq] using ...`, so the upstream rename doesn't
apply. `QExpansion.lean` auto-merged cleanly; `convert` calls there are
now `convert!` as intended.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b-mehta pushed a commit to b-mehta/mathlib4 that referenced this pull request Jun 2, 2026
…-community#39721)

This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for leanprover-community#39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Michael Rothgang <rothgang@math.uni-bonn.de>
Bergschaf pushed a commit to Bergschaf/mathlib4 that referenced this pull request Jun 3, 2026
…-community#39721)

This PR makes any use of `convert` pop up a "Try this:" message replacing it with `convert!`. This prepares for leanprover-community#39039 which will make `convert` change behaviour and `convert!` retain the old behaviour.

Note that `convert` and `convert!` still do the same thing and result in the same goals after this PR is applied, except `convert!` does not pop up a "Try this:" afterwards.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Michael Rothgang <rothgang@math.uni-bonn.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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