Skip to content

refactor(Tactic/Positivity): add a cache - #45072

Draft
HugLycan wants to merge 3 commits into
leanprover-community:masterfrom
HugLycan:feat/positivity-cache
Draft

HugLycan wants to merge 3 commits into
leanprover-community:masterfrom
HugLycan:feat/positivity-cache

Conversation

@HugLycan

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to Zulip and join the Lean community.
Thank you again for joining our community.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR summary 58cc9c8f96

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ CachedResult
+ CachedResult.toString
+ N
+ PositivityM
+ State
+ cacheFailure
+ cacheInfo
+ cacheStrictness
+ catchNone'
+ findCached?

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 -- stale, waiting for the new build)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 9060034).

  • +48 new declarations
  • −0 removed declarations
+Mathlib.Meta.Positivity.CachedResult
+Mathlib.Meta.Positivity.CachedResult.casesOn
+Mathlib.Meta.Positivity.CachedResult.ctorElim
+Mathlib.Meta.Positivity.CachedResult.ctorElimType
+Mathlib.Meta.Positivity.CachedResult.ctorIdx
+Mathlib.Meta.Positivity.CachedResult.noConfusion
+Mathlib.Meta.Positivity.CachedResult.noConfusionType
+Mathlib.Meta.Positivity.CachedResult.nonnegative
+Mathlib.Meta.Positivity.CachedResult.nonnegative.elim
+Mathlib.Meta.Positivity.CachedResult.nonnegative.inj
+Mathlib.Meta.Positivity.CachedResult.nonnegative.injEq
+Mathlib.Meta.Positivity.CachedResult.nonnegative.noConfusion
+Mathlib.Meta.Positivity.CachedResult.nonnegative.sizeOf_spec
+Mathlib.Meta.Positivity.CachedResult.nonzero
+Mathlib.Meta.Positivity.CachedResult.nonzero.elim
+Mathlib.Meta.Positivity.CachedResult.nonzero.inj
+Mathlib.Meta.Positivity.CachedResult.nonzero.injEq
+Mathlib.Meta.Positivity.CachedResult.nonzero.noConfusion
+Mathlib.Meta.Positivity.CachedResult.nonzero.sizeOf_spec
+Mathlib.Meta.Positivity.CachedResult.positive
+Mathlib.Meta.Positivity.CachedResult.positive.elim
+Mathlib.Meta.Positivity.CachedResult.positive.inj
+Mathlib.Meta.Positivity.CachedResult.positive.injEq
+Mathlib.Meta.Positivity.CachedResult.positive.noConfusion
+Mathlib.Meta.Positivity.CachedResult.positive.sizeOf_spec
+Mathlib.Meta.Positivity.CachedResult.rec
+Mathlib.Meta.Positivity.CachedResult.recOn
+Mathlib.Meta.Positivity.CachedResult.toString
+Mathlib.Meta.Positivity.PositivityM
+Mathlib.Meta.Positivity.State
+Mathlib.Meta.Positivity.State.cache
+Mathlib.Meta.Positivity.State.casesOn
+Mathlib.Meta.Positivity.State.ctorIdx
+Mathlib.Meta.Positivity.State.failureCache
+Mathlib.Meta.Positivity.State.mk
+Mathlib.Meta.Positivity.State.mk.inj
+Mathlib.Meta.Positivity.State.mk.injEq
+Mathlib.Meta.Positivity.State.mk.noConfusion
+Mathlib.Meta.Positivity.State.mk.sizeOf_spec
+Mathlib.Meta.Positivity.State.noConfusion
+Mathlib.Meta.Positivity.State.noConfusionType
+Mathlib.Meta.Positivity.State.rec
+Mathlib.Meta.Positivity.State.recOn
+Mathlib.Meta.Positivity.cacheFailure
+Mathlib.Meta.Positivity.cacheInfo
+Mathlib.Meta.Positivity.cacheStrictness
+Mathlib.Meta.Positivity.catchNone'
+Mathlib.Meta.Positivity.findCached?

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

Current commit 58cc9c8f96
Reference commit 9454a4c25a

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.py 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 Oct 20, 2026
@HugLycan

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Oct 20, 2026 •

Copy link
Copy Markdown

Benchmark results for 9060034 against 9454a4c are in. There are significant results. @HugLycan

  • 🟥 build//instructions: +19.4G (+0.02%)

Large changes (1🟥)

  • 🟥 build/module/Mathlib.Tactic.Positivity.Basic//instructions: +5.9G (+15.29%)

Small changes (26✅, 83🟥)

  • 🟥 build/module/Mathlib.Algebra.Module.CharacterModule//instructions: +153.3M (+0.72%)
  • 🟥 build/module/Mathlib.Algebra.Order.AbsoluteValue.Basic//instructions: +58.2M (+0.46%)
  • 🟥 build/module/Mathlib.Algebra.Order.Algebra//instructions: +275.6M (+3.58%) (reduced significance based on *//lines)
  • 🟥 build/module/Mathlib.Algebra.Order.BigOperators.Expect//instructions: +253.8M (+1.79%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Mathlib.Algebra.Order.BigOperators.Ring.Finset//instructions: +348.7M (+2.08%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Mathlib.Algebra.Order.Field.Basic//instructions: +523.2M (+1.36%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Mathlib.Algebra.Order.Field.Power//instructions: +342.3M (+3.64%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Mathlib.Algebra.Order.Floor.Extended//instructions: +119.8M (+1.03%) (reduced significance based on *//lines)
  • 🟥 build/module/Mathlib.Algebra.Order.Floor.Ring//instructions: +401.2M (+1.13%) (reduced significance based on *//lines)
  • 🟥 build/module/Mathlib.Algebra.Order.Interval.Basic//instructions: +101.6M (+0.52%)
  • 🟥 build/module/Mathlib.Algebra.Order.Module.Field//instructions: +233.3M (+3.26%) (reduced significance based on absolute threshold)
  • ✅ build/module/Mathlib.Algebra.Order.Monoid.Units//instructions: -47.3M (-1.27%)
  • 🟥 build/module/Mathlib.Algebra.Star.CHSH//instructions: +49.4M (+0.51%)
  • ✅ build/module/Mathlib.AlgebraicGeometry.AlgebraicCycle.Basic//instructions: -31.5M (-0.42%)
  • ✅ build/module/Mathlib.AlgebraicGeometry.EffectiveEpi//instructions: -78.6M (-0.90%)
  • ✅ build/module/Mathlib.AlgebraicGeometry.Morphisms.FiniteType//instructions: -29.2M (-0.34%)
  • ✅ build/module/Mathlib.AlgebraicGeometry.Morphisms.WeaklyEtale//instructions: -41.8M (-0.67%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Mathlib.AlgebraicGeometry.Sites.BigZariski//instructions: +34.3M (+0.48%)
  • 🟥 build/module/Mathlib.AlgebraicTopology.SimplexCategory.DeltaZeroIter//instructions: +78.3M (+0.42%)
  • 🟥 build/module/Mathlib.AlgebraicTopology.SimplexCategory.Rev//instructions: +77.9M (+1.55%) (reduced significance based on absolute threshold)
  • and 89 more

@grunweg grunweg mentioned this pull request Oct 20, 2026
1 task

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants