Skip to content

[Merged by Bors] - refactor: mixin class for norm_smul with strict equality#24003

Closed
eric-wieser wants to merge 27 commits intomasterfrom
DL_norm_smul-alternative
Closed

[Merged by Bors] - refactor: mixin class for norm_smul with strict equality#24003
eric-wieser wants to merge 27 commits intomasterfrom
DL_norm_smul-alternative

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented Apr 13, 2025

Define a typeclass for normed modules where the norm is exactly multiplicative (not just sub-multiplicative like IsBoundedSMul, or just over fields like NormedSpace).

This is a subset of #23787, leaving out the changes to NormedSpace.


Open in Gitpod

The comments below used to be in the PR description, but future changes mean that this is no longer true; the performance drop was fixed.


This results in a reasonably significant performance drop (~0.5T instructions or 0.3%), but no obvious tweaking of priorities seems to help much. Some further discussion took place in #mathlib4 > Normed modules @ 💬, though for now there are no actionable suggestions without further experimentation.

A somewhat realistic benchmark can be constructed as

import Mathlib

variable (𝕜 F : Type*) [NontriviallyNormedField 𝕜] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
set_option linter.style.setOption false
set_option trace.profiler.useHeartbeats true
set_option trace.profiler true
#synth ContinuousConstSMul 𝕜 F

where the number of heartbeats changes from 1477626 to 1858556 (+25%) due to this PR.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2025

PR summary 9c1b3099b5

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

@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 0ac28ed.
There were significant changes against commit 28daac2:

  Benchmark                                             Metric         Change
  ===========================================================================
- ~Mathlib.Analysis.Analytic.Basic                      instructions    17.1%
- ~Mathlib.Analysis.Analytic.CPolynomialDef             instructions    18.8%
- ~Mathlib.Analysis.Analytic.ChangeOrigin               instructions    10.2%
- ~Mathlib.Analysis.Analytic.Constructions              instructions    13.0%
- ~Mathlib.Analysis.Analytic.Inverse                    instructions     8.8%
- ~Mathlib.Analysis.Calculus.ContDiff.Basic             instructions    11.4%
- ~Mathlib.Analysis.Calculus.ContDiff.Defs              instructions    14.9%
- ~Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries     instructions    10.6%
- ~Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno        instructions     9.0%
- ~Mathlib.Analysis.Calculus.ContDiff.Operations        instructions    15.3%
- ~Mathlib.Analysis.Calculus.Deriv.Basic                instructions    12.7%
- ~Mathlib.Analysis.Calculus.Deriv.Mul                  instructions     9.8%
- ~Mathlib.Analysis.Calculus.FDeriv.Analytic            instructions     7.0%
- ~Mathlib.Analysis.Calculus.FDeriv.Mul                 instructions     3.0%
- ~Mathlib.Analysis.Convolution                         instructions     5.8%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Basic       instructions     3.9%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Curry       instructions     5.2%
- ~Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear   instructions     6.7%

@github-actions
Copy link
Copy Markdown

File Instructions %
build +512.30⬝10⁹ (+0.32%)
lint +36.240⬝10⁹ (+0.47%)
Mathlib.Analysis.Analytic.Basic +46.497⬝10⁹ (+17.07%)
Mathlib.Analysis.Calculus.ContDiff.Basic +33.499⬝10⁹ (+11.36%)
2 files, Instructions +30.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries +30.987⬝10⁹ (+10.55%)
Mathlib.Analysis.Calculus.ContDiff.Defs +30.932⬝10⁹ (+14.87%)
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.Operations +29.247⬝10⁹ (+15.31%)
Mathlib.Analysis.Analytic.Constructions +24.303⬝10⁹ (+12.95%)
2 files, Instructions +21.0⬝10⁹
File Instructions %
Mathlib.Analysis.Convolution +21.405⬝10⁹ (+5.75%)
Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno +21.77⬝10⁹ (+9.03%)
2 files, Instructions +19.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.FDeriv.Analytic +19.835⬝10⁹ (+7.00%)
Mathlib.Analysis.Analytic.CPolynomialDef +19.799⬝10⁹ (+18.84%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Mul +16.532⬝10⁹ (+9.82%)
Mathlib.Analysis.Analytic.Inverse +13.47⬝10⁹ (+8.84%)
Mathlib.Analysis.Calculus.FDeriv.Mul +12.834⬝10⁹ (+3.02%)
3 files, Instructions +11.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear +11.717⬝10⁹ (+6.71%)
Mathlib.Analysis.Calculus.Deriv.Basic +11.507⬝10⁹ (+12.72%)
Mathlib.Analysis.NormedSpace.Multilinear.Curry +11.499⬝10⁹ (+5.22%)
2 files, Instructions +10.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.ChangeOrigin +10.983⬝10⁹ (+10.16%)
Mathlib.Analysis.NormedSpace.Multilinear.Basic +10.392⬝10⁹ (+3.91%)
File Instructions %
Mathlib.Analysis.Analytic.Composition +9.503⬝10⁹ (+6.16%)
2 files, Instructions +8.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.CPolynomial +8.922⬝10⁹ (+16.98%)
Mathlib.Analysis.InnerProductSpace.Adjoint +8.781⬝10⁹ (+3.54%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Comp +7.255⬝10⁹ (+8.73%)
Mathlib.Geometry.Manifold.MFDeriv.NormedSpace +6.335⬝10⁹ (+2.86%)
3 files, Instructions +5.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.IteratedFDeriv +5.754⬝10⁹ (+8.03%)
Mathlib.Analysis.Calculus.Deriv.Prod +5.466⬝10⁹ (+14.33%)
Mathlib.Geometry.Manifold.ContMDiff.NormedSpace +5.427⬝10⁹ (+3.16%)
4 files, Instructions +4.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Add +4.670⬝10⁹ (+10.89%)
Mathlib.Analysis.Calculus.FormalMultilinearSeries +4.663⬝10⁹ (+5.88%)
Mathlib.Analysis.NormedSpace.PiTensorProduct.InjectiveSeminorm +4.496⬝10⁹ (+2.47%)
Mathlib.Analysis.Calculus.Implicit +4.212⬝10⁹ (+3.26%)
8 files, Instructions +3.0⬝10⁹
File Instructions %
Mathlib.MeasureTheory.Function.Holder +3.932⬝10⁹ (+4.05%)
Mathlib.Analysis.Analytic.IsolatedZeros +3.895⬝10⁹ (+5.09%)
Mathlib.Analysis.Distribution.SchwartzSpace +3.761⬝10⁹ (+1.64%)
Mathlib.Analysis.Calculus.ContDiff.Bounds +3.529⬝10⁹ (+2.25%)
Mathlib.Analysis.CStarAlgebra.Matrix +3.202⬝10⁹ (+2.41%)
Mathlib.Analysis.Calculus.FDeriv.Symmetric +3.162⬝10⁹ (+2.61%)
Mathlib.Analysis.Normed.Operator.BoundedLinearMaps +3.155⬝10⁹ (+4.23%)
Mathlib.Analysis.CStarAlgebra.Multiplier +3.88⬝10⁹ (+2.10%)
7 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.OperatorNorm.Prod +2.877⬝10⁹ (+4.01%)
Mathlib.Analysis.Analytic.Linear +2.727⬝10⁹ (+5.34%)
Mathlib.Analysis.NormedSpace.OperatorNorm.Mul +2.634⬝10⁹ (+4.17%)
Mathlib.Analysis.InnerProductSpace.l2Space +2.527⬝10⁹ (+2.84%)
Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions +2.505⬝10⁹ (+6.12%)
Mathlib.Analysis.Normed.Module.FiniteDimension +2.393⬝10⁹ (+2.36%)
Mathlib.Analysis.Calculus.SmoothSeries +2.295⬝10⁹ (+4.67%)
22 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.FDeriv.Equiv +1.993⬝10⁹ (+2.43%)
Mathlib.MeasureTheory.Integral.SetIntegral +1.882⬝10⁹ (+1.47%)
Mathlib.Analysis.Normed.MulAction +1.865⬝10⁹ (+11.72%)
Mathlib.Analysis.Calculus.LineDeriv.Basic +1.830⬝10⁹ (+3.27%)
Mathlib.Analysis.SpecialFunctions.Exponential +1.671⬝10⁹ (+2.71%)
Mathlib.Analysis.Calculus.VectorField +1.648⬝10⁹ (+1.87%)
Mathlib.MeasureTheory.Integral.IntegralEqImproper +1.482⬝10⁹ (+1.69%)
Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 +1.395⬝10⁹ (+1.35%)
Mathlib.Topology.VectorBundle.Hom +1.365⬝10⁹ (+1.72%)
Mathlib.Analysis.InnerProductSpace.Projection +1.361⬝10⁹ (+0.71%)
Mathlib.Analysis.Calculus.FDeriv.Bilinear +1.333⬝10⁹ (+4.06%)
Mathlib.Analysis.Calculus.ParametricIntegral +1.324⬝10⁹ (+2.30%)
Mathlib.Analysis.CStarAlgebra.Unitization +1.292⬝10⁹ (+2.30%)
Mathlib.Analysis.Calculus.MeanValue +1.261⬝10⁹ (+1.30%)
Mathlib.Analysis.Analytic.Uniqueness +1.238⬝10⁹ (+3.67%)
Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus +1.189⬝10⁹ (+1.78%)
Mathlib.Analysis.Normed.Algebra.Unitization +1.147⬝10⁹ (+1.70%)
Mathlib.Analysis.Analytic.Within +1.135⬝10⁹ (+7.35%)
Mathlib.Analysis.Calculus.Deriv.Slope +1.92⬝10⁹ (+5.07%)
Mathlib.MeasureTheory.VectorMeasure.WithDensity +1.49⬝10⁹ (+6.02%)
Mathlib.Analysis.InnerProductSpace.Calculus +1.37⬝10⁹ (+1.43%)
Mathlib.Analysis.NormedSpace.ConformalLinearMap +1.9⬝10⁹ (+6.98%)
7 files, Instructions -2.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension -1.3⬝10⁹ (-1.70%)
Mathlib.Analysis.CStarAlgebra.Module.Defs -1.13⬝10⁹ (-1.62%)
Mathlib.MeasureTheory.Integral.CircleIntegral -1.94⬝10⁹ (-1.62%)
Mathlib.Analysis.Normed.Affine.ContinuousAffineMap -1.100⬝10⁹ (-1.99%)
Mathlib.Analysis.Normed.Affine.AddTorsor -1.108⬝10⁹ (-3.91%)
Mathlib.Analysis.InnerProductSpace.Basic -1.264⬝10⁹ (-1.31%)
Mathlib.Analysis.Asymptotics.Lemmas -1.400⬝10⁹ (-2.39%)
File Instructions %
Mathlib.Analysis.InnerProductSpace.NormPow -2.122⬝10⁹ (-5.93%)
Mathlib.Analysis.Fourier.FourierTransformDeriv -3.901⬝10⁹ (-1.07%)
CI run

@kbuzzard
Copy link
Copy Markdown
Member

kbuzzard commented Apr 13, 2025

I can see that certain things are slower in traces on this branch. For example

import Mathlib

variable (𝕜 F : Type*) [NontriviallyNormedField 𝕜] [NormedAddCommGroup F]
  [NormedSpace 𝕜 F]

set_option trace.profiler.useHeartbeats true in
set_option trace.profiler true in
set_option trace.Meta.synthInstance true in
#synth ContinuousConstSMul 𝕜 F 

takes 1479817 mHeartbeats on master and 1866830 mHeartbeats on this branch (a 25% slowdown). Matt has suggested on the Zulip thread #mathlib4 > Normed modules @ 💬 that there are now two paths to (0 : 𝕜), taking two different routes from NormedCommRing to NonUnitalNonAssocSemiring (explicitly NormedCommRing->NonUnitalNormedCommRing->NonUnitalCommRing->NonUnitalNonAssocCommRing->NonUnitalNonAssocCommSemiring->NonUnitalNonAssocSemiring vs NormedCommRing->SeminormedCommRing->SeminormedRing->Ring->NonAssocRing->NonUnitalNonAssocRing->NonUnitalNonAssocSemiring) but these routes are rfl even with with_reducible_and_instances on. The big difference in the traces comes when trying to check that two instances of IsBoundedSMul 𝕜 F are defeq; this needs a 0 on 𝕜 and we have

                  [] [37879.000000] ✅️ MulZeroClass.toZero =?= MulZeroClass.toZero ▶

on this branch vs

                  [] [39.000000] ✅️ MulZeroClass.toZero =?= MulZeroClass.toZero 

on master. Digging further into the slow trace the only times things don't look syntactically identical is right at the end:

                                                  [] [5318.000000] ✅️ Ring.toSemiring =?= Ring.toSemiring ▼
                                                    [] [5051.000000] ✅️ NormedRing.toRing.1 =?= SeminormedRing.toRing.1 ▼
                                                      [whnf] [27.000000] Non-easy whnf: Ring 𝕜 
                                                      [whnf] [992.000000] Non-easy whnf: NormedRing.toRing ▶
                                                      [whnf] [1434.000000] Non-easy whnf: SeminormedRing.toRing ▶
                                                      [] [1448.000000] ✅️ NormedRing.toRing =?= SeminormedRing.toRing ▼
                                                        [whnf] [310.000000] Non-easy whnf: NormedCommRing.toNormedRing ▶
                                                        [whnf] [368.000000] Non-easy whnf: Field.toCommRing ▶
                                                        [whnf] [289.000000] Non-easy whnf: SeminormedCommRing.toSeminormedRing ▶
                                                        [] [23.000000] ✅️ NormedRing.toRing =?= NormedRing.toRing 

where Lean has made two ring structures on 𝕜, one through NormedRing and one through SeminormedRing. I kind of feel like this is one of these situations where one line of code might fix everything up but I don't yet know what that line is.

@loefflerd
Copy link
Copy Markdown
Contributor

Thanks Eric for making this PR! I am going to set #23787 to draft, and this PR to non-draft, since it contains the "first stage" of what I planned for that PR. Thanks to everyone who has contributed so far to trying to diagnose the slow-downs!

@loefflerd loefflerd marked this pull request as ready for review April 14, 2025 07:29
@loefflerd loefflerd changed the title refactor: mixin class for norm_smul with strict equality (alternative) refactor: mixin class for norm_smul with strict equality Apr 14, 2025
@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 1007e3a.
There were significant changes against commit 9c6a148:

  Benchmark                                             Metric         Change
  ===========================================================================
- ~Mathlib.Analysis.Analytic.Basic                      instructions    16.9%
- ~Mathlib.Analysis.Analytic.CPolynomialDef             instructions    19.0%
- ~Mathlib.Analysis.Analytic.ChangeOrigin               instructions     9.5%
- ~Mathlib.Analysis.Analytic.Constructions              instructions    12.9%
- ~Mathlib.Analysis.Analytic.Inverse                    instructions     8.8%
- ~Mathlib.Analysis.Calculus.ContDiff.Basic             instructions    11.3%
- ~Mathlib.Analysis.Calculus.ContDiff.Defs              instructions    14.8%
- ~Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries     instructions    10.6%
- ~Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno        instructions     9.3%
- ~Mathlib.Analysis.Calculus.ContDiff.Operations        instructions    15.3%
- ~Mathlib.Analysis.Calculus.Deriv.Basic                instructions    12.6%
- ~Mathlib.Analysis.Calculus.Deriv.Mul                  instructions     9.8%
- ~Mathlib.Analysis.Calculus.FDeriv.Analytic            instructions     7.0%
- ~Mathlib.Analysis.Calculus.FDeriv.Mul                 instructions     3.0%
- ~Mathlib.Analysis.Convolution                         instructions     5.7%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Basic       instructions     4.0%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Curry       instructions     5.2%
- ~Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear   instructions     6.7%

@github-actions
Copy link
Copy Markdown

File Instructions %
build +518.62⬝10⁹ (+0.32%)
lint +36.229⬝10⁹ (+0.46%)
Mathlib.Analysis.Analytic.Basic +46.97⬝10⁹ (+16.94%)
Mathlib.Analysis.Calculus.ContDiff.Basic +33.452⬝10⁹ (+11.34%)
Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries +31.49⬝10⁹ (+10.56%)
Mathlib.Analysis.Calculus.ContDiff.Defs +30.872⬝10⁹ (+14.83%)
Mathlib.Analysis.Calculus.ContDiff.Operations +29.281⬝10⁹ (+15.32%)
Mathlib.Analysis.Analytic.Constructions +24.286⬝10⁹ (+12.94%)
2 files, Instructions +21.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno +21.969⬝10⁹ (+9.28%)
Mathlib.Analysis.Convolution +21.152⬝10⁹ (+5.67%)
2 files, Instructions +19.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.CPolynomialDef +19.966⬝10⁹ (+18.99%)
Mathlib.Analysis.Calculus.FDeriv.Analytic +19.797⬝10⁹ (+6.98%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Mul +16.446⬝10⁹ (+9.77%)
Mathlib.Analysis.Analytic.Inverse +13.12⬝10⁹ (+8.79%)
Mathlib.Analysis.Calculus.FDeriv.Mul +12.794⬝10⁹ (+3.00%)
3 files, Instructions +11.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear +11.557⬝10⁹ (+6.68%)
Mathlib.Analysis.Calculus.Deriv.Basic +11.508⬝10⁹ (+12.56%)
Mathlib.Analysis.NormedSpace.Multilinear.Curry +11.467⬝10⁹ (+5.20%)
2 files, Instructions +10.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.Multilinear.Basic +10.938⬝10⁹ (+4.00%)
Mathlib.Analysis.Analytic.ChangeOrigin +10.267⬝10⁹ (+9.45%)
File Instructions %
Mathlib.Analysis.Analytic.Composition +9.529⬝10⁹ (+6.17%)
2 files, Instructions +8.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.CPolynomial +8.925⬝10⁹ (+16.96%)
Mathlib.Analysis.InnerProductSpace.Adjoint +8.770⬝10⁹ (+3.53%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Comp +7.361⬝10⁹ (+8.86%)
Mathlib.Geometry.Manifold.MFDeriv.NormedSpace +6.381⬝10⁹ (+2.88%)
3 files, Instructions +5.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.IteratedFDeriv +5.770⬝10⁹ (+8.04%)
Mathlib.Analysis.Calculus.Deriv.Prod +5.621⬝10⁹ (+14.62%)
Mathlib.Geometry.Manifold.ContMDiff.NormedSpace +5.406⬝10⁹ (+3.14%)
4 files, Instructions +4.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Add +4.918⬝10⁹ (+11.60%)
Mathlib.Analysis.Calculus.FormalMultilinearSeries +4.615⬝10⁹ (+5.81%)
Mathlib.Analysis.NormedSpace.PiTensorProduct.InjectiveSeminorm +4.462⬝10⁹ (+2.45%)
Mathlib.Analysis.Calculus.Implicit +4.396⬝10⁹ (+3.39%)
9 files, Instructions +3.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.IsolatedZeros +3.915⬝10⁹ (+5.11%)
Mathlib.MeasureTheory.Function.Holder +3.905⬝10⁹ (+4.02%)
Mathlib.Analysis.Distribution.SchwartzSpace +3.657⬝10⁹ (+1.59%)
Mathlib.Analysis.Calculus.ContDiff.Bounds +3.556⬝10⁹ (+2.26%)
Mathlib.Analysis.NormedSpace.OperatorNorm.Mul +3.389⬝10⁹ (+5.40%)
Mathlib.Analysis.CStarAlgebra.Matrix +3.306⬝10⁹ (+2.47%)
Mathlib.Analysis.Calculus.FDeriv.Symmetric +3.220⬝10⁹ (+2.66%)
Mathlib.Analysis.CStarAlgebra.Multiplier +3.127⬝10⁹ (+2.13%)
Mathlib.Analysis.Normed.Operator.BoundedLinearMaps +3.57⬝10⁹ (+4.09%)
5 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.OperatorNorm.Prod +2.948⬝10⁹ (+4.10%)
Mathlib.Analysis.Analytic.Linear +2.925⬝10⁹ (+5.72%)
Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions +2.481⬝10⁹ (+6.04%)
Mathlib.Analysis.InnerProductSpace.l2Space +2.466⬝10⁹ (+2.76%)
Mathlib.Analysis.Calculus.SmoothSeries +2.304⬝10⁹ (+4.67%)
23 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.Analysis.Normed.Module.FiniteDimension +1.950⬝10⁹ (+1.91%)
Mathlib.Analysis.Normed.MulAction +1.869⬝10⁹ (+11.69%)
Mathlib.MeasureTheory.Integral.IntegralEqImproper +1.732⬝10⁹ (+1.94%)
Mathlib.Analysis.Calculus.FDeriv.Equiv +1.721⬝10⁹ (+2.08%)
Mathlib.Analysis.Calculus.VectorField +1.670⬝10⁹ (+1.89%)
Mathlib.Analysis.Calculus.MeanValue +1.632⬝10⁹ (+2.10%)
Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap +1.599⬝10⁹ (+2.75%)
Mathlib.Analysis.Calculus.LineDeriv.Basic +1.597⬝10⁹ (+2.84%)
Mathlib.Analysis.SpecialFunctions.Exponential +1.595⬝10⁹ (+2.57%)
Mathlib.Analysis.Calculus.FDeriv.Bilinear +1.426⬝10⁹ (+4.34%)
Mathlib.Topology.VectorBundle.Hom +1.422⬝10⁹ (+1.79%)
Mathlib.Analysis.InnerProductSpace.Projection +1.399⬝10⁹ (+0.73%)
Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 +1.338⬝10⁹ (+1.29%)
Mathlib.Analysis.Analytic.Within +1.301⬝10⁹ (+8.37%)
Mathlib.Analysis.Calculus.ParametricIntegral +1.267⬝10⁹ (+2.19%)
Mathlib.Analysis.CStarAlgebra.Unitization +1.261⬝10⁹ (+2.24%)
Mathlib.MeasureTheory.Function.ConditionalExpectation.AEMeasurable +1.248⬝10⁹ (+2.55%)
Mathlib.Analysis.Calculus.Deriv.Slope +1.180⬝10⁹ (+5.61%)
Mathlib.Analysis.Normed.Algebra.Unitization +1.178⬝10⁹ (+1.75%)
Mathlib.Tactic.CategoryTheory.Coherence.Normalize +1.135⬝10⁹ (+0.79%)
Mathlib.Analysis.InnerProductSpace.Calculus +1.126⬝10⁹ (+1.55%)
Mathlib.MeasureTheory.Integral.Bochner.Set +1.7⬝10⁹ (+1.29%)
Mathlib.Analysis.NormedSpace.ConformalLinearMap +1.7⬝10⁹ (+6.91%)
7 files, Instructions -2.0⬝10⁹
File Instructions %
Mathlib.Geometry.Manifold.Instances.Sphere -1.74⬝10⁹ (-0.77%)
Mathlib.Analysis.Normed.Affine.ContinuousAffineMap -1.98⬝10⁹ (-1.99%)
Mathlib.Analysis.InnerProductSpace.Basic -1.300⬝10⁹ (-1.33%)
Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension -1.345⬝10⁹ (-2.27%)
Mathlib.Analysis.Normed.Affine.AddTorsor -1.440⬝10⁹ (-5.06%)
Mathlib.Analysis.Asymptotics.Lemmas -1.551⬝10⁹ (-2.70%)
Mathlib.Analysis.InnerProductSpace.NormPow -1.957⬝10⁹ (-5.45%)
File Instructions %
Mathlib.Analysis.Fourier.FourierTransformDeriv -4.244⬝10⁹ (-1.16%)
CI run

@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 559a5ff.
There were significant changes against commit 5b76dec:

  Benchmark                                             Metric         Change
  ===========================================================================
- ~Mathlib.Analysis.Analytic.Basic                      instructions    16.8%
- ~Mathlib.Analysis.Analytic.CPolynomialDef             instructions    18.6%
- ~Mathlib.Analysis.Analytic.ChangeOrigin               instructions     9.6%
- ~Mathlib.Analysis.Analytic.Constructions              instructions    12.8%
- ~Mathlib.Analysis.Analytic.Inverse                    instructions     8.7%
- ~Mathlib.Analysis.Calculus.ContDiff.Basic             instructions    11.2%
- ~Mathlib.Analysis.Calculus.ContDiff.Defs              instructions    14.7%
- ~Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries     instructions    10.4%
- ~Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno        instructions     9.2%
- ~Mathlib.Analysis.Calculus.ContDiff.Operations        instructions    15.1%
- ~Mathlib.Analysis.Calculus.Deriv.Basic                instructions    12.9%
- ~Mathlib.Analysis.Calculus.Deriv.Mul                  instructions     9.7%
- ~Mathlib.Analysis.Calculus.FDeriv.Analytic            instructions     7.0%
- ~Mathlib.Analysis.Calculus.FDeriv.Mul                 instructions     3.0%
- ~Mathlib.Analysis.Convolution                         instructions     5.6%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Basic       instructions     3.9%
- ~Mathlib.Analysis.NormedSpace.Multilinear.Curry       instructions     5.3%
- ~Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear   instructions     6.6%

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 2, 2025

File Instructions %
build +497.968⬝10⁹ (+0.31%)
lint +36.699⬝10⁹ (+0.46%)
Mathlib.Analysis.Analytic.Basic +45.717⬝10⁹ (+16.80%)
Mathlib.Analysis.Calculus.ContDiff.Basic +32.969⬝10⁹ (+11.17%)
2 files, Instructions +30.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.Defs +30.540⬝10⁹ (+14.67%)
Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries +30.480⬝10⁹ (+10.37%)
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.Operations +28.896⬝10⁹ (+15.12%)
Mathlib.Analysis.Analytic.Constructions +24.81⬝10⁹ (+12.83%)
2 files, Instructions +21.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno +21.686⬝10⁹ (+9.16%)
Mathlib.Analysis.Convolution +21.1⬝10⁹ (+5.63%)
2 files, Instructions +19.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.FDeriv.Analytic +19.788⬝10⁹ (+6.98%)
Mathlib.Analysis.Analytic.CPolynomialDef +19.580⬝10⁹ (+18.61%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Mul +16.289⬝10⁹ (+9.68%)
2 files, Instructions +12.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.Inverse +12.872⬝10⁹ (+8.69%)
Mathlib.Analysis.Calculus.FDeriv.Mul +12.590⬝10⁹ (+2.96%)
3 files, Instructions +11.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Basic +11.762⬝10⁹ (+12.91%)
Mathlib.Analysis.NormedSpace.Multilinear.Curry +11.680⬝10⁹ (+5.30%)
Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear +11.442⬝10⁹ (+6.62%)
2 files, Instructions +10.0⬝10⁹
File Instructions %
Mathlib.Analysis.NormedSpace.Multilinear.Basic +10.760⬝10⁹ (+3.94%)
Mathlib.Analysis.Analytic.ChangeOrigin +10.438⬝10⁹ (+9.63%)
File Instructions %
Mathlib.Analysis.Analytic.Composition +9.502⬝10⁹ (+6.16%)
2 files, Instructions +8.0⬝10⁹
File Instructions %
Mathlib.Analysis.InnerProductSpace.Adjoint +8.854⬝10⁹ (+3.57%)
Mathlib.Analysis.Analytic.CPolynomial +8.759⬝10⁹ (+16.62%)
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Comp +7.299⬝10⁹ (+8.79%)
Mathlib.Geometry.Manifold.MFDeriv.NormedSpace +6.399⬝10⁹ (+2.89%)
4 files, Instructions +5.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.IteratedFDeriv +5.687⬝10⁹ (+7.92%)
Mathlib.Analysis.Calculus.Deriv.Prod +5.468⬝10⁹ (+14.31%)
Mathlib.Geometry.Manifold.ContMDiff.NormedSpace +5.356⬝10⁹ (+3.11%)
Mathlib.Analysis.NormedSpace.PiTensorProduct.InjectiveSeminorm +5.93⬝10⁹ (+2.80%)
3 files, Instructions +4.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.Deriv.Add +4.876⬝10⁹ (+11.52%)
Mathlib.Analysis.Calculus.FormalMultilinearSeries +4.540⬝10⁹ (+5.71%)
Mathlib.Analysis.Calculus.Implicit +4.317⬝10⁹ (+3.33%)
6 files, Instructions +3.0⬝10⁹
File Instructions %
Mathlib.Analysis.Analytic.IsolatedZeros +3.865⬝10⁹ (+5.05%)
Mathlib.MeasureTheory.Function.Holder +3.755⬝10⁹ (+3.86%)
Mathlib.Analysis.Distribution.SchwartzSpace +3.607⬝10⁹ (+1.57%)
Mathlib.Analysis.Calculus.ContDiff.Bounds +3.583⬝10⁹ (+2.28%)
Mathlib.Analysis.NormedSpace.OperatorNorm.Prod +3.81⬝10⁹ (+4.30%)
Mathlib.Analysis.CStarAlgebra.Multiplier +3.4⬝10⁹ (+2.04%)
8 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.Analysis.Calculus.FDeriv.Symmetric +2.983⬝10⁹ (+2.46%)
Mathlib.Analysis.Normed.Operator.BoundedLinearMaps +2.968⬝10⁹ (+3.96%)
Mathlib.Analysis.Analytic.Linear +2.926⬝10⁹ (+5.71%)
Mathlib.Analysis.NormedSpace.OperatorNorm.Mul +2.521⬝10⁹ (+3.98%)
Mathlib.Analysis.Calculus.SmoothSeries +2.463⬝10⁹ (+4.99%)
Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions +2.441⬝10⁹ (+5.94%)
Mathlib.Analysis.InnerProductSpace.l2Space +2.344⬝10⁹ (+2.63%)
Mathlib.Analysis.Normed.MulAction +2.12⬝10⁹ (+12.58%)
22 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.Analysis.Normed.Module.FiniteDimension +1.981⬝10⁹ (+1.94%)
Mathlib.Analysis.Calculus.FDeriv.Equiv +1.818⬝10⁹ (+2.20%)
Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap +1.715⬝10⁹ (+2.95%)
Mathlib.Analysis.Calculus.LineDeriv.Basic +1.650⬝10⁹ (+2.93%)
Mathlib.Analysis.Calculus.VectorField +1.640⬝10⁹ (+1.86%)
Mathlib.MeasureTheory.Integral.IntegralEqImproper +1.599⬝10⁹ (+1.79%)
Mathlib.Analysis.SpecialFunctions.Exponential +1.591⬝10⁹ (+2.57%)
Mathlib.Analysis.Calculus.MeanValue +1.449⬝10⁹ (+1.86%)
Mathlib.Analysis.Calculus.FDeriv.Bilinear +1.400⬝10⁹ (+4.25%)
Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 +1.367⬝10⁹ (+1.32%)
Mathlib.MeasureTheory.Integral.Bochner.Set +1.349⬝10⁹ (+1.74%)
Mathlib.Topology.VectorBundle.Hom +1.304⬝10⁹ (+1.64%)
Mathlib.Analysis.CStarAlgebra.Unitization +1.276⬝10⁹ (+2.27%)
Mathlib.Analysis.InnerProductSpace.Projection +1.260⬝10⁹ (+0.66%)
Mathlib.Analysis.Calculus.Deriv.Slope +1.244⬝10⁹ (+5.94%)
Mathlib.Topology.MetricSpace.Holder +1.192⬝10⁹ (+7.53%)
Mathlib.Analysis.Calculus.ParametricIntegral +1.187⬝10⁹ (+2.06%)
Mathlib.Analysis.Normed.Algebra.Unitization +1.177⬝10⁹ (+1.75%)
Mathlib.Analysis.Analytic.Within +1.119⬝10⁹ (+7.12%)
Mathlib.Analysis.Calculus.Deriv.Linear +1.59⬝10⁹ (+8.10%)
Mathlib.Analysis.Calculus.ContDiff.RCLike +1.20⬝10⁹ (+5.00%)
Mathlib.Analysis.InnerProductSpace.Calculus +1.0⬝10⁹ (+1.37%)
7 files, Instructions -2.0⬝10⁹
File Instructions %
Mathlib.Geometry.Manifold.Instances.Sphere -1.13⬝10⁹ (-0.73%)
Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension -1.70⬝10⁹ (-1.81%)
Mathlib.MeasureTheory.Integral.CircleIntegral -1.111⬝10⁹ (-1.64%)
Mathlib.Analysis.Normed.Affine.ContinuousAffineMap -1.120⬝10⁹ (-2.03%)
Mathlib.Analysis.Normed.Affine.AddTorsor -1.186⬝10⁹ (-4.19%)
Mathlib.Analysis.InnerProductSpace.Basic -1.611⬝10⁹ (-1.65%)
Mathlib.Analysis.Asymptotics.Lemmas -1.725⬝10⁹ (-3.00%)
2 files, Instructions -3.0⬝10⁹
File Instructions %
Mathlib.Analysis.InnerProductSpace.NormPow -2.38⬝10⁹ (-5.68%)
Mathlib.Analysis.CStarAlgebra.Matrix -2.119⬝10⁹ (-1.58%)
File Instructions %
Mathlib.Analysis.Fourier.FourierTransformDeriv -4.433⬝10⁹ (-1.21%)
CI run

@eric-wieser
Copy link
Copy Markdown
Member Author

@urkud, @kbuzzard, does the PR description look like enough information to you?

@urkud
Copy link
Copy Markdown
Member

urkud commented May 2, 2025

For me, yes

@loefflerd
Copy link
Copy Markdown
Contributor

This looks ready to me (I am also happy with the commit message, fwiw, although my opinion was not asked!). Shall we merge?

@eric-wieser
Copy link
Copy Markdown
Member Author

@kbuzzard plans to look at the performance one last time in the next few days, but after that, hopefully yes!

@kbuzzard
Copy link
Copy Markdown
Member

kbuzzard commented May 7, 2025

OK my final round of thoughts on this PR are #mathlib4 > Normed modules @ 💬 and I feel like we're going to converge shortly. Basically I propose what I think is a speedup involving a typeclass shortcut and I'd be interested to hear anyone's opinion as to whether it's acceptable or whether it's a hack.

@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 71b5341.
The entire run failed.
Found no significant differences.

@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 9c1b309.
There were no significant changes against commit 5b76dec.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 8, 2025

File Instructions %
build -87.12⬝10⁹ (-0.05%)
lint -2.176⬝10⁹ (-0.02%)
2 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.CategoryTheory.Sums.Products +2.757⬝10⁹ (+1.02%)
Mathlib.Analysis.Normed.MulAction +2.100⬝10⁹ (+13.13%)
File Instructions %
Mathlib.Topology.MetricSpace.Holder +1.92⬝10⁹ (+6.90%)
15 files, Instructions -2.0⬝10⁹
File Instructions %
Mathlib.Analysis.CStarAlgebra.Module.Defs -1.15⬝10⁹ (-1.60%)
Mathlib.Analysis.Calculus.Rademacher -1.18⬝10⁹ (-1.59%)
Mathlib.Analysis.Seminorm -1.29⬝10⁹ (-0.72%)
Mathlib.Analysis.Analytic.OfScalars -1.50⬝10⁹ (-2.11%)
Mathlib.Analysis.Normed.Module.FiniteDimension -1.99⬝10⁹ (-1.08%)
Mathlib.Analysis.InnerProductSpace.Basic -1.109⬝10⁹ (-1.14%)
Mathlib.Analysis.Normed.Affine.AddTorsor -1.154⬝10⁹ (-4.08%)
Mathlib.Analysis.Calculus.UniformLimitsDeriv -1.165⬝10⁹ (-2.22%)
Mathlib.Analysis.Analytic.Basic -1.177⬝10⁹ (-0.43%)
Mathlib.Analysis.Normed.Module.Basic -1.229⬝10⁹ (-2.42%)
Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension -1.313⬝10⁹ (-2.22%)
Mathlib.Analysis.Asymptotics.Lemmas -1.377⬝10⁹ (-2.39%)
Mathlib.MeasureTheory.Integral.CircleIntegral -1.511⬝10⁹ (-2.23%)
Mathlib.Analysis.CStarAlgebra.CStarMatrix -1.746⬝10⁹ (-1.25%)
Mathlib.Analysis.Normed.Affine.ContinuousAffineMap -1.932⬝10⁹ (-3.51%)
2 files, Instructions -3.0⬝10⁹
File Instructions %
Mathlib.Analysis.InnerProductSpace.NormPow -2.44⬝10⁹ (-5.70%)
Mathlib.Topology.ContinuousMap.Compact -2.886⬝10⁹ (-5.83%)
File Instructions %
Mathlib.Analysis.CStarAlgebra.Matrix -3.947⬝10⁹ (-2.95%)
Mathlib.Analysis.Fourier.FourierTransformDeriv -7.205⬝10⁹ (-1.97%)
CI run

@kbuzzard
Copy link
Copy Markdown
Member

kbuzzard commented May 8, 2025

Thanks everyone for your patience!

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label May 8, 2025
@kbuzzard kbuzzard removed delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). ready-to-merge This PR has been sent to bors. labels May 8, 2025
@kbuzzard
Copy link
Copy Markdown
Member

kbuzzard commented May 8, 2025

Hmm, I just realised that the description of the PR is now out of date (it describes a problem which no longer exists...). I thought that perhaps moving quickly was the best approach so I cut and pasted the comments "below the line". Sorry for the confusion.

@eric-wieser eric-wieser added the t-analysis Analysis (normed *, calculus) label May 8, 2025
@eric-wieser
Copy link
Copy Markdown
Member Author

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label May 8, 2025
mathlib-bors bot pushed a commit that referenced this pull request May 8, 2025
Define a typeclass for normed modules where the norm is exactly multiplicative (not just sub-multiplicative like `IsBoundedSMul`, or just over fields like `NormedSpace`).

This is a subset of #23787, leaving out the changes to `NormedSpace`.



Co-authored-by: Eric Wieser <efw@google.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented May 8, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor: mixin class for norm_smul with strict equality [Merged by Bors] - refactor: mixin class for norm_smul with strict equality May 8, 2025
@mathlib-bors mathlib-bors bot closed this May 8, 2025
@mathlib-bors mathlib-bors bot deleted the DL_norm_smul-alternative branch May 8, 2025 16:35
tannerduve pushed a commit that referenced this pull request May 13, 2025
Define a typeclass for normed modules where the norm is exactly multiplicative (not just sub-multiplicative like `IsBoundedSMul`, or just over fields like `NormedSpace`).

This is a subset of #23787, leaving out the changes to `NormedSpace`.



Co-authored-by: Eric Wieser <efw@google.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
bwehlin pushed a commit to bwehlin/mathlib4 that referenced this pull request May 31, 2025
…r-community#24003)

Define a typeclass for normed modules where the norm is exactly multiplicative (not just sub-multiplicative like `IsBoundedSMul`, or just over fields like `NormedSpace`).

This is a subset of leanprover-community#23787, leaving out the changes to `NormedSpace`.



Co-authored-by: Eric Wieser <efw@google.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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-analysis Analysis (normed *, calculus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants