Skip to content

[Merged by Bors] - feat(Convert): less aggressive congruence#38071

Closed
JovanGerb wants to merge 9 commits into
leanprover-community:masterfrom
JovanGerb:Jovan-convert-config
Closed

[Merged by Bors] - feat(Convert): less aggressive congruence#38071
JovanGerb wants to merge 9 commits into
leanprover-community:masterfrom
JovanGerb:Jovan-convert-config

Conversation

@JovanGerb

@JovanGerb JovanGerb commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This PR tries to make convert behave more predictably, disabling some of the aggressive congruence steps that congr! does. In particular, when the two sides have a different head constants, then we should not use congruence on these applications.


Open in Gitpod

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

PR summary c631f6e5f1

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

- Convert.CheapConfig.unfoldSameFun
- Convert.ExpensiveConfig.unfoldSameFun

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 c631f6e).

  • +1 new declarations
  • −3 removed declarations
-Convert.CheapConfig.unfoldSameFun
-Convert.ExpensiveConfig.toCheapConfig
+Convert.ExpensiveConfig.toConfig
-Convert.ExpensiveConfig.unfoldSameFun

No changes to strong technical debt.

No changes to weak technical debt.

Current commit c631f6e5f1
Reference commit 833b1ec7ee

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 added the t-meta Tactics, attributes or user commands label Apr 15, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts 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 Apr 21, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@Vierkantor

Copy link
Copy Markdown
Contributor

This change makes sense to me! If it were possible, I'd like to get it in before the very drastic changes of #39039. Could you fix the merge conflict and the build? Or do you want to have the convert! machinery up and working first? (Feel free to copy parts of my PR into this one in that case!)

@mathlib-merge-conflicts mathlib-merge-conflicts 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 26, 2026

@joneugster joneugster 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!

maintainer merge

@github-actions

Copy link
Copy Markdown

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

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label May 29, 2026
@joneugster

Copy link
Copy Markdown
Contributor

oh I missed that CI is failing

@joneugster joneugster self-assigned this May 29, 2026
@joneugster joneugster added awaiting-author A reviewer has asked the author a question or requested changes. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels May 29, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jun 5, 2026
This PR implements the main behaviour change from #39039: `convert` now discharges side goals at reducible transparency. `convert!`, which we previously switched all calls inside Mathlib to, keeps the old behaviour of working at default transparency. (Everything discussed in this PR holds analogously for the other tactics in the family: `convert_to` and `ac_change`).

The main trick in this PR is in allowing `convert!` to have different configuration options than `convert`, but still allow the user to override those options too. So `convert! (postTransparency := .instances)` will have transparency set to `.instances`, not `.default`. We achieve this by having two new structures that copy `Congr!.Config` but set different default values, and choosing between the corresponding elaborators for those configs based on the presence of an `!`. I got this trick from Jovan's #38071 which also changes settings in `Convert.Config`.

This PR should be mostly compatible with #38071 and I'd like to get both this one and #38071 in before wrapping up #39039 by replacing unnecessary calls to `convert!` with `convert`.
mathlib-bors Bot pushed a commit that referenced this pull request Jun 5, 2026
This PR implements the main behaviour change from #39039: `convert` now discharges side goals at reducible transparency. `convert!`, which we previously switched all calls inside Mathlib to, keeps the old behaviour of working at default transparency. (Everything discussed in this PR holds analogously for the other tactics in the family: `convert_to` and `ac_change`).

The main trick in this PR is in allowing `convert!` to have different configuration options than `convert`, but still allow the user to override those options too. So `convert! (postTransparency := .instances)` will have transparency set to `.instances`, not `.default`. We achieve this by having two new structures that copy `Congr!.Config` but set different default values, and choosing between the corresponding elaborators for those configs based on the presence of an `!`. I got this trick from Jovan's #38071 which also changes settings in `Convert.Config`.

This PR should be mostly compatible with #38071 and I'd like to get both this one and #38071 in before wrapping up #39039 by replacing unnecessary calls to `convert!` with `convert`.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
@JovanGerb

Copy link
Copy Markdown
Contributor Author

The trouble with the new convert congruence setting is that the doc-string examples of convert using now don't need the using clause anymore. So either we'll need to come up with new examples to explain what using does, or we can decide that convert using will probably we less common in the future, so we don't need to explain it so prominently anymore, and the variant explanation at the bottom will suffice.

@JovanGerb

Copy link
Copy Markdown
Contributor Author

@kmill, as the original author, do you have some opinions on this PR?

@JovanGerb
JovanGerb temporarily deployed to cache-upload-forks June 5, 2026 16:19 — with GitHub Actions Inactive
@JovanGerb
JovanGerb temporarily deployed to cache-upload-forks June 6, 2026 11:54 — with GitHub Actions Inactive
@JovanGerb JovanGerb removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jun 6, 2026
Examples:

```lean
-- `convert using` controls the depth of congruence.

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.

I'm okay with removing the emphasis on using, since it seems that there are indeed many cases where we no longer need to use using.

@Vierkantor

Copy link
Copy Markdown
Contributor

Thanks!

bors r+

@mathlib-triage mathlib-triage Bot added the ready-to-merge This PR has been sent to bors. label Jun 17, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
This PR tries to make `convert` behave more predictably, disabling some of the aggressive congruence steps that `congr!` does. In particular, when the two sides have a different head constants, then we should not use congruence on these applications.

Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
@mathlib-bors

mathlib-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(Convert): less aggressive congruence [Merged by Bors] - feat(Convert): less aggressive congruence Jun 17, 2026
@mathlib-bors mathlib-bors Bot closed this Jun 17, 2026
xroblot pushed a commit to xroblot/mathlib4 that referenced this pull request Jun 18, 2026
This PR tries to make `convert` behave more predictably, disabling some of the aggressive congruence steps that `congr!` does. In particular, when the two sides have a different head constants, then we should not use congruence on these applications.

Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
ReemMelamed pushed a commit to ReemMelamed/mathlib4 that referenced this pull request Jun 20, 2026
…ommunity#39928)

This PR implements the main behaviour change from leanprover-community#39039: `convert` now discharges side goals at reducible transparency. `convert!`, which we previously switched all calls inside Mathlib to, keeps the old behaviour of working at default transparency. (Everything discussed in this PR holds analogously for the other tactics in the family: `convert_to` and `ac_change`).

The main trick in this PR is in allowing `convert!` to have different configuration options than `convert`, but still allow the user to override those options too. So `convert! (postTransparency := .instances)` will have transparency set to `.instances`, not `.default`. We achieve this by having two new structures that copy `Congr!.Config` but set different default values, and choosing between the corresponding elaborators for those configs based on the presence of an `!`. I got this trick from Jovan's leanprover-community#38071 which also changes settings in `Convert.Config`.

This PR should be mostly compatible with leanprover-community#38071 and I'd like to get both this one and leanprover-community#38071 in before wrapping up leanprover-community#39039 by replacing unnecessary calls to `convert!` with `convert`.

Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
ReemMelamed pushed a commit to ReemMelamed/mathlib4 that referenced this pull request Jun 20, 2026
This PR tries to make `convert` behave more predictably, disabling some of the aggressive congruence steps that `congr!` does. In particular, when the two sides have a different head constants, then we should not use congruence on these applications.

Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
bryangingechen pushed a commit to jcommelin/mathlib4 that referenced this pull request Jun 22, 2026
This PR tries to make `convert` behave more predictably, disabling some of the aggressive congruence steps that `congr!` does. In particular, when the two sides have a different head constants, then we should not use congruence on these applications.

Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
mathlib-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
This PR fixes a regression introduced in #38071, which had caused the congruence algorithm of `convert` to not support over-applications.

I added a test to show this now works again.
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Jul 4, 2026
…unity#40740)

This PR fixes a regression introduced in leanprover-community#38071, which had caused the congruence algorithm of `convert` to not support over-applications.

I added a test to show this now works again.
michaellee94 pushed a commit to michaellee94/mathlib4 that referenced this pull request Jul 11, 2026
…unity#40740)

This PR fixes a regression introduced in leanprover-community#38071, which had caused the congruence algorithm of `convert` to not support over-applications.

I added a test to show this now works again.
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.

4 participants