Skip to content

[Merged by Bors] - refactor: don't use lambdas in CoeFun instances - #21405

Closed
YaelDillies wants to merge 5 commits into
masterfrom
hales_jewett_no_head_lambda
Closed

YaelDillies wants to merge 5 commits into
masterfrom
hales_jewett_no_head_lambda

Conversation

@YaelDillies

@YaelDillies YaelDillies commented Feb 4, 2025 •

Copy link
Copy Markdown
Contributor

Hiding the lambdas behind a non-reducible toFun or changing the CoeFun instance to FunLike prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's has_coe_to_fun was not reducible. Whether or not those should have become FunLike or CoeFun := ⟨semireducibleDef⟩ back then is unclear.

Zulip


Open in Gitpod

@github-actions

github-actions Bot commented Feb 4, 2025 •

Copy link
Copy Markdown

PR summary cc3c6e85a0

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ apply_def
+ apply_ne_top
+ instance : DFunLike (FiniteAdeleRing R K) (HeightOneSpectrum R) (adicCompletion K)
+ instance : FunLike (Content G) (Compacts G) ℝ≥0∞
+ mk_apply
+ opensHom.instFunLike
+ opensNhds.instFunLike
+ toFun_eq_toNNReal_apply
++ apply_mk
++ coe_id
++ comp_apply
++ id_apply
++ val_apply
- instance : CoeFun (Content G) fun _ => Compacts G → ℝ≥0∞
- instance : CoeFun (FiniteAdeleRing R K)
- opensHomHasCoeToFun
- opensNhdsHomHasCoeToFun

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

@adomani

adomani commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

!bench

@YaelDillies YaelDillies changed the title refactor: use Line.toFun in the CoeFun instance refactor: don't use lambdas in CoeFun instances Feb 4, 2025
@adomani

adomani commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

Oops, I did not realise that this was still in progress!

@adomani

adomani commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

I wish we had a bench-after-CI automation!

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Be the automation you want to see 😇

@YaelDillies

Copy link
Copy Markdown
Contributor Author

I think I got them all!

@leanprover-bot

Copy link
Copy Markdown

Here are the benchmark results for commit c62aed9.
There were no significant changes against commit e13a712.

@github-actions

github-actions Bot commented Feb 4, 2025

Copy link
Copy Markdown
File Instructions %
lint -18.118⬝10⁹ (-0.23%)
CI run

@adomani

adomani commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

!bench

@leanprover-bot

Copy link
Copy Markdown

Here are the benchmark results for commit f0e206e.
There were no significant changes against commit e13a712.

@github-actions

github-actions Bot commented Feb 4, 2025

Copy link
Copy Markdown
File Instructions %
build -4.808⬝10⁹ (+0.00%)
lint -92.666⬝10⁹ (-1.21%)
Mathlib.AlgebraicGeometry.Modules.Tilde +3.281⬝10⁹ (+2.47%)
2 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.Topology.Category.TopCat.Opens +2.964⬝10⁹ (+5.60%)
Mathlib.AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf +2.432⬝10⁹ (+3.15%)
File Instructions %
Mathlib.MeasureTheory.Measure.Content +1.208⬝10⁹ (+6.32%)
Mathlib.Topology.Sheaves.Sheafify -1.408⬝10⁹ (-18.21%)
Mathlib.Analysis.InnerProductSpace.l2Space -5.57⬝10⁹ (-5.27%)
Mathlib.AlgebraicGeometry.StructureSheaf -9.798⬝10⁹ (-5.98%)
CI run

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Wow! -1.21% on linting

/-- `b i` is the `i`th basis vector. -/
instance instCoeFun : CoeFun (HilbertBasis ι 𝕜 E) fun _ => ι → E where
coe b i := b.repr.symm (lp.single 2 i (1 : 𝕜))
@[coe] def toFun (b : HilbertBasis ι 𝕜 E) (i : ι) : E := b.repr.symm <| lp.single 2 i (1 : 𝕜)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to not lose it from the other PR; this one should be adjusted to use FunLike, which needs the proofs in #21440 and probably the API in #21444

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.

I've reverted this. Changes were in commit 712d7f6

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.

Sorry, which "other PR" does this refer to?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"other PR" refers to comments in #21395 on lines that were moved to this PR.

@YaelDillies
YaelDillies force-pushed the hales_jewett_no_head_lambda branch from f0e206e to e3b2d1f Compare February 5, 2025 08:58
@YaelDillies YaelDillies removed the t-combinatorics Combinatorics label Feb 11, 2025
@Vierkantor

Copy link
Copy Markdown
Contributor

It looks like this was misported.

This refers to the original PR, which has grown a bit. Could you make sure it is still up to date?

@Vierkantor Vierkantor 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.

bors d+

@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Feb 11, 2025
@YaelDillies

Copy link
Copy Markdown
Contributor Author

bors merge

mathlib-bors Bot pushed a commit that referenced this pull request Feb 11, 2025
Hiding the lambdas behind a non-reducible `toFun` or changing the `CoeFun` instance to `FunLike` prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's `has_coe_to_fun` was not reducible. Whether or not those should have become `FunLike` or `CoeFun := ⟨semireducibleDef⟩` back then is unclear.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/bad.20simp.20discrimination.20tree.20keys)
@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

mathlib-bors Bot pushed a commit that referenced this pull request Feb 11, 2025
Hiding the lambdas behind a non-reducible `toFun` or changing the `CoeFun` instance to `FunLike` prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's `has_coe_to_fun` was not reducible. Whether or not those should have become `FunLike` or `CoeFun := ⟨semireducibleDef⟩` back then is unclear.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/bad.20simp.20discrimination.20tree.20keys)
@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

mathlib-bors Bot pushed a commit that referenced this pull request Feb 11, 2025
Hiding the lambdas behind a non-reducible `toFun` or changing the `CoeFun` instance to `FunLike` prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's `has_coe_to_fun` was not reducible. Whether or not those should have become `FunLike` or `CoeFun := ⟨semireducibleDef⟩` back then is unclear.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/bad.20simp.20discrimination.20tree.20keys)
@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Build failed:

@sgouezel

Copy link
Copy Markdown
Contributor

bors r-
Can you merge master and fix the build?
bors d+

@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Feb 11, 2025
@YaelDillies
YaelDillies force-pushed the hales_jewett_no_head_lambda branch from e3b2d1f to cc3c6e8 Compare February 11, 2025 14:05
@YaelDillies YaelDillies added the auto-merge-after-CI Please do not add manually. Requests for a bot to merge automatically once CI is done. label Feb 11, 2025
@ghost

ghost commented Feb 11, 2025

Copy link
Copy Markdown

As this PR is labelled auto-merge-after-CI, we are now sending it to bors:

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Feb 11, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Feb 11, 2025
Hiding the lambdas behind a non-reducible `toFun` or changing the `CoeFun` instance to `FunLike` prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's `has_coe_to_fun` was not reducible. Whether or not those should have become `FunLike` or `CoeFun := ⟨semireducibleDef⟩` back then is unclear.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/bad.20simp.20discrimination.20tree.20keys)
@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

This PR was included in a batch that was canceled, it will be automatically retried

mathlib-bors Bot pushed a commit that referenced this pull request Feb 11, 2025
Hiding the lambdas behind a non-reducible `toFun` or changing the `CoeFun` instance to `FunLike` prevents many lemmas (some simp) to have a lambda as their head symbol.

Arguably, those were misports because Lean 3's `has_coe_to_fun` was not reducible. Whether or not those should have become `FunLike` or `CoeFun := ⟨semireducibleDef⟩` back then is unclear.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/bad.20simp.20discrimination.20tree.20keys)
@mathlib-bors

mathlib-bors Bot commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title refactor: don't use lambdas in CoeFun instances [Merged by Bors] - refactor: don't use lambdas in CoeFun instances Feb 11, 2025
@mathlib-bors mathlib-bors Bot closed this Feb 11, 2025
@mathlib-bors
mathlib-bors Bot deleted the hales_jewett_no_head_lambda branch February 11, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-after-CI Please do not add manually. Requests for a bot to merge automatically once CI is done. ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants