[Merged by Bors] - perf: speed up Finset.toLeft and Finset.toRight#23079
[Merged by Bors] - perf: speed up Finset.toLeft and Finset.toRight#23079eric-wieser wants to merge 4 commits intomasterfrom
Finset.toLeft and Finset.toRight#23079Conversation
This is about 10% faster, but also avoids stackoverflows: ``` \#eval ((Finset.Icc 0 100000).map (.inl (β := ℕ))).toLeft.card ``` would previously fail.
PR summary 1d68d2735c
|
| File | Base Count | Head Count | Change |
|---|---|---|---|
| Mathlib.Data.Finset.Sum | 466 | 427 | -39 (-8.37%) |
Import changes for all files
| Files | Import difference |
|---|---|
Mathlib.Data.Finset.Sum |
-39 |
Mathlib.Data.Finite.Sum Mathlib.Data.Fintype.Sum |
-38 |
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 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
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
|
Ha, this is clearly the better definition - Yaël and I were saying how we'd both prefer it if Finset.filterMap existed for this; turns out it does! |
| def toLeft (s : Finset (α ⊕ β)) : Finset α := | ||
| s.disjiUnion (Sum.elim singleton (fun _ => ∅)) <| by | ||
| simp [Set.PairwiseDisjoint, Set.Pairwise, Function.onFun, eq_comm] | ||
| s.filterMap (Sum.elim some fun _ => none) (by clear x; aesop) |
There was a problem hiding this comment.
Is there a tracking issue for aesop pulling in x here?
If aesop changes (fixes) its behaviour, this might error, right?
There was a problem hiding this comment.
A fix to aesop would make this clear unnecessary, but it wouldn't make it an error
There was a problem hiding this comment.
|
✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with |
|
As this PR is labelled bors merge |
This is about 10% faster than master, but also avoids stackoverflows: ```lean #eval ((Finset.Icc 0 100000).map (.inl (β := ℕ))).toLeft.card ``` would previously fail. `aesop` is somehow capturing an unused local variable here, but `clear` sets it straight. As a bonus, this reduces the imports needed for this file.
|
Build failed: |
|
As this PR is labelled bors merge |
This is about 10% faster than master, but also avoids stackoverflows: ```lean #eval ((Finset.Icc 0 100000).map (.inl (β := ℕ))).toLeft.card ``` would previously fail. `aesop` is somehow capturing an unused local variable here, but `clear` sets it straight. As a bonus, this reduces the imports needed for this file.
|
Pull request successfully merged into master. Build succeeded: |
Finset.toLeft and Finset.toRightFinset.toLeft and Finset.toRight
This is about 10% faster than master, but also avoids stackoverflows: ```lean #eval ((Finset.Icc 0 100000).map (.inl (β := ℕ))).toLeft.card ``` would previously fail. `aesop` is somehow capturing an unused local variable here, but `clear` sets it straight. As a bonus, this reduces the imports needed for this file.
This is about 10% faster than master, but also avoids stackoverflows:
would previously fail.
aesopis somehow capturing an unused local variable here, butclearsets it straight.As a bonus, this reduces the imports needed for this file.
This is a more minimal version of #23020 that is also twice as fast.