Skip to content

[Merged by Bors] - feat: deprecate Expr.isConstantApplication#35267

Closed
JovanGerb wants to merge 3 commits intoleanprover-community:masterfrom
JovanGerb:Jovan-Expr.isConstantApplication
Closed

[Merged by Bors] - feat: deprecate Expr.isConstantApplication#35267
JovanGerb wants to merge 3 commits intoleanprover-community:masterfrom
JovanGerb:Jovan-Expr.isConstantApplication

Conversation

@JovanGerb
Copy link
Copy Markdown
Contributor

@JovanGerb JovanGerb commented Feb 13, 2026

The function Expr.isConstantApplication does its de bruijn index managenent incorrectly, so this PR deprecates it. It was added in #1861. It should have used de bruijn index 0, but it actually used de bruijn index n - 2. This means that it would works correctly for the number of arguments being at most 2.

This PR removes the call to Expr.isConstantApplication used by to_additive, which is not needed anymore. It turns out that the check is simply not necessary.


Open in Gitpod

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 13, 2026

PR summary 37d2101b79

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
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for scripts/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/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).

@github-actions github-actions Bot added the t-meta Tactics, attributes or user commands label Feb 13, 2026
Copy link
Copy Markdown
Contributor

@joneugster joneugster left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

How do we see that

[...] we don't treat (fun x => α) (n + 1) as a type that depends on Nat

?

Is there an test/example/anything which illustrates this is working as intended without the check?

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 Feb 13, 2026
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Feb 13, 2026

Can you fix the test failures, please? Thanks!

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 13, 2026
@JovanGerb
Copy link
Copy Markdown
Contributor Author

(I've added some more details to the PR description. The function was working as intended for the most common cases, but as can be seen from this PR, the check is not necessary. I can't tell whether it was never necessary, or if some improvements have been made to Lean in the meantime that have made it unnecessary. I'll fix the test tomorrow)

@JovanGerb
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Feb 13, 2026

Benchmark results for e08549f against 37d2101 are in! @JovanGerb

  • build//instructions: -20.8G (-0.01%)

No significant changes detected.

@JovanGerb JovanGerb removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 14, 2026
Comment thread Mathlib/Tactic/Translate/Core.lean Outdated
Comment on lines -338 to -339
-- make sure that we don't treat `(fun x => α) (n + 1)` as a type that depends on `Nat`
guard !x.isConstantApplication
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 agree with @joneugster that it's not obvious why this check is no longer needed, and I'd like to see a test case.

@Vierkantor Vierkantor self-assigned this Feb 16, 2026
@Vierkantor Vierkantor added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 16, 2026
@JovanGerb
Copy link
Copy Markdown
Contributor Author

What sort of test case would you like? I claim that this is simply not relevant, because it doesn't come up in practice.

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@JovanGerb
Copy link
Copy Markdown
Contributor Author

The relevant history is that this particular test was added at some point early in the port, in order to fix a basic use case. However, since CI is green on this PR, the check isn't necessary anymore.

@JovanGerb JovanGerb removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 16, 2026
@Vierkantor
Copy link
Copy Markdown
Contributor

Okay, looking at the history in detail, commit f0a4e27e added the test case myFin.foo alongside the isConstantFun check. So that answers my question: myFin.foo is this test case.

bors r+

@mathlib-triage mathlib-triage Bot added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Feb 17, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Feb 17, 2026
The function `Expr.isConstantApplication` does its de bruijn index managenent incorrectly, so this PR deprecates it. It was added in #1861. It should have used de bruijn index 0, but it actually used de bruijn index `n - 2`. This means that it would works correctly for the number of arguments being at most 2.

This PR removes the call to `Expr.isConstantApplication` used by `to_additive`, which is not needed anymore. It turns out that the check is simply not necessary.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors Bot commented Feb 17, 2026

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat: deprecate Expr.isConstantApplication [Merged by Bors] - feat: deprecate Expr.isConstantApplication Feb 17, 2026
@mathlib-bors mathlib-bors Bot closed this Feb 17, 2026
Maldooor pushed a commit to Maldooor/mathlib4 that referenced this pull request Feb 25, 2026
)

The function `Expr.isConstantApplication` does its de bruijn index managenent incorrectly, so this PR deprecates it. It was added in leanprover-community#1861. It should have used de bruijn index 0, but it actually used de bruijn index `n - 2`. This means that it would works correctly for the number of arguments being at most 2.

This PR removes the call to `Expr.isConstantApplication` used by `to_additive`, which is not needed anymore. It turns out that the check is simply not necessary.
pfaffelh pushed a commit to pfaffelh/mathlib4 that referenced this pull request Mar 2, 2026
)

The function `Expr.isConstantApplication` does its de bruijn index managenent incorrectly, so this PR deprecates it. It was added in leanprover-community#1861. It should have used de bruijn index 0, but it actually used de bruijn index `n - 2`. This means that it would works correctly for the number of arguments being at most 2.

This PR removes the call to `Expr.isConstantApplication` used by `to_additive`, which is not needed anymore. It turns out that the check is simply not necessary.
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.

5 participants