Skip to content

[Merged by Bors] - chore: use mixin ordered algebraic typeclasses (part 1)#20594

Closed
astrainfinita wants to merge 142 commits intomasterfrom
FR_ordered_mixin_lemmas
Closed

[Merged by Bors] - chore: use mixin ordered algebraic typeclasses (part 1)#20594
astrainfinita wants to merge 142 commits intomasterfrom
FR_ordered_mixin_lemmas

Conversation

@astrainfinita
Copy link
Copy Markdown
Collaborator

@astrainfinita astrainfinita commented Jan 9, 2025

commit 7561e65e55f1dbba1058c43ca1701038ceed98dc
Author: negiizhao <[email protected]>
Date:   Wed Jun 5 04:26:04 2024 +0800

    fix

commit 777db8a7d19ed4d66815f9575206992ca578cb5e
Merge: cc6eede 52b851a
Author: negiizhao <[email protected]>
Date:   Wed Jun 5 04:25:36 2024 +0800

    Merge branch 'master' into FR_canonically

commit cc6eede
Author: negiizhao <[email protected]>
Date:   Thu Dec 28 15:01:00 2023 +0800

    fix

commit ae1dfda
Merge: c1931cf 1a749e0
Author: negiizhao <[email protected]>
Date:   Thu Dec 28 14:10:05 2023 +0800

    Merge branch 'FR_covariance_instance' into FR_canonically

commit c1931cf
Merge: 9e0f667 6cab3d6
Author: negiizhao <[email protected]>
Date:   Thu Dec 28 14:09:53 2023 +0800

    Merge branch 'master' into FR_canonically

commit 1a749e0
Author: negiizhao <[email protected]>
Date:   Tue Dec 26 04:24:52 2023 +0800

    revert some instance changes

commit a6e645f
Author: negiizhao <[email protected]>
Date:   Mon Dec 25 11:01:06 2023 +0800

    fix

commit 6af13a5
Author: negiizhao <[email protected]>
Date:   Mon Dec 25 10:06:19 2023 +0800

    Revert "fix"

    This reverts commit 7ebd135.

commit 63a181b
Author: negiizhao <[email protected]>
Date:   Mon Dec 25 09:49:50 2023 +0800

    hack

commit 7ebd135
Author: negiizhao <[email protected]>
Date:   Sun Dec 24 14:25:47 2023 +0800

    fix

commit 20d2809
Author: negiizhao <[email protected]>
Date:   Sun Dec 24 14:13:08 2023 +0800

    chore: remove redundant instances

commit 9e0f667
Author: negiizhao <[email protected]>
Date:   Sun Dec 24 12:45:15 2023 +0800

    fix

commit bf51f25
Merge: bd9e5b4 e9fb5b3
Author: negiizhao <[email protected]>
Date:   Sun Dec 24 12:00:56 2023 +0800

    Merge branch 'master' into FR_canonically

commit bd9e5b4
Author: negiizhao <[email protected]>
Date:   Tue Oct 24 01:49:05 2023 +0800

    nolint again

commit 6414331
Author: negiizhao <[email protected]>
Date:   Tue Oct 24 00:36:00 2023 +0800

    reduce diffs

commit 6d1f059
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 19:41:50 2023 +0800

    Revert "remove nolint"

    This reverts commit d60fc68.

commit d60fc68
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 10:24:07 2023 +0800

    remove nolint

commit 86f6ec7
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 10:23:24 2023 +0800

    fix

commit a3d8af1
Merge: 58e2ba8 801dc0d
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 09:53:43 2023 +0800

    Merge branch 'master' into FR_canonically

commit 58e2ba8
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 09:52:49 2023 +0800

    reduce diffs

commit be2b4bb
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 08:58:03 2023 +0800

    `[Mul α] [LE α]` -> `[Monoid α] [PartialOrder α]`

commit 0777b07
Author: negiizhao <[email protected]>
Date:   Mon Oct 23 02:46:01 2023 +0800

    rerun bench please

commit 6415bc9
Author: negiizhao <[email protected]>
Date:   Sun Oct 22 18:30:20 2023 +0800

    fix

commit 14cdac7
Author: negiizhao <[email protected]>
Date:   Sun Oct 22 14:11:31 2023 +0800

    nolint

commit 5bc0815
Author: Mario Carneiro <[email protected]>
Date:   Sat Oct 21 17:30:57 2023 -0400

    chore: bump lean toolchain

commit 86c8440
Author: negiizhao <[email protected]>
Date:   Sat Oct 21 23:50:53 2023 +0800

    fix

commit f14bdc9
Author: negiizhao <[email protected]>
Date:   Sat Oct 21 23:07:59 2023 +0800

    fix

commit 5feb528
Author: negiizhao <[email protected]>
Date:   Sat Oct 21 22:41:09 2023 +0800

    fix

commit 958c4a5
Author: negiizhao <[email protected]>
Date:   Sat Oct 21 22:07:26 2023 +0800

    fix

commit fae1c85
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 21:07:44 2023 +0800

    fix

commit e6309d6
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 20:07:09 2023 +0800

    fix merge

commit a619670
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 20:06:29 2023 +0800

    oops

commit 9c3d72d
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 20:04:15 2023 +0800

    fix merge

commit 8a76d2e
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 20:01:16 2023 +0800

    fix merge

commit 7793f03
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 19:59:08 2023 +0800

    fix

commit 659f503
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 18:59:49 2023 +0800

    fix merge

commit a259cc5
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 18:54:10 2023 +0800

    fix

commit d6eb31f
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 18:18:02 2023 +0800

    fix

commit 2650679
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 16:31:11 2023 +0800

    fix

commit 5bfb9ec
Merge: c5279c0 08a8af0
Author: negiizhao <[email protected]>
Date:   Fri Oct 20 16:19:14 2023 +0800

    Merge branch 'master' into FR_canonically

commit c5279c0
Author: negiizhao <[email protected]>
Date:   Mon Aug 7 02:47:06 2023 +0800

    lint

commit 19a377f
Author: negiizhao <[email protected]>
Date:   Thu Aug 3 16:57:10 2023 +0800

    lint

commit 048b120
Author: negiizhao <[email protected]>
Date:   Thu Aug 3 15:43:32 2023 +0800

    fix counterexamples

commit 94663ee
Author: negiizhao <[email protected]>
Date:   Thu Aug 3 14:22:22 2023 +0800

    lint style

commit 426dd03
Author: negiizhao <[email protected]>
Date:   Thu Aug 3 14:00:46 2023 +0800

    refactor: make `CanonicallyOrdered...` mixin

    I think this is the proposed refactor.

    However it seems that all things get slower... :(

    Need more love to speed it up.
@jcommelin
Copy link
Copy Markdown
Member

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit df1585b.
There were significant changes against commit d635d41:

  Benchmark                                                           Metric         Change
  =========================================================================================
- ~Mathlib.Algebra.Lie.Nilpotent                                      instructions    12.4%
+ ~Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order   instructions    -8.2%
- ~Mathlib.Topology.Algebra.Field                                     instructions    41.5%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2025

File Instructions %
build +226.444⬝10⁹ (+0.13%)
Mathlib.Algebra.Lie.Nilpotent +12.328⬝10⁹ (+12.37%)
Mathlib.Topology.Algebra.Field +11.100⬝10⁹ (+41.48%)
3 files, Instructions +9.0⬝10⁹
File Instructions %
Mathlib.Algebra.Order.Module.Defs +9.295⬝10⁹ (+9.57%)
Mathlib.Algebra.Order.Monovary +9.126⬝10⁹ (+15.34%)
Mathlib.Analysis.MeanInequalitiesPow +9.92⬝10⁹ (+18.37%)
File Instructions %
Mathlib.Algebra.Order.Ring.Abs +8.971⬝10⁹ (+33.16%)
Mathlib.Data.Rat.Cast.Order +7.875⬝10⁹ (+29.49%)
Mathlib.Algebra.Order.Nonneg.Field +6.928⬝10⁹ (+37.07%)
4 files, Instructions +5.0⬝10⁹
File Instructions %
Mathlib.RingTheory.LaurentSeries +5.639⬝10⁹ (+2.37%)
Mathlib.Algebra.Order.Rearrangement +5.506⬝10⁹ (+12.01%)
Mathlib.Order.Filter.AtTopBot.Field +5.411⬝10⁹ (+27.83%)
Mathlib.Topology.Order.LeftRightNhds +5.360⬝10⁹ (+10.86%)
3 files, Instructions +4.0⬝10⁹
File Instructions %
Mathlib.Algebra.Lie.Weights.Killing +4.956⬝10⁹ (+2.34%)
Mathlib.Algebra.Order.Interval.Set.Group +4.575⬝10⁹ (+23.65%)
Mathlib.Combinatorics.SimpleGraph.Density +4.111⬝10⁹ (+15.70%)
8 files, Instructions +3.0⬝10⁹
File Instructions %
Mathlib.Algebra.Lie.Weights.Basic +3.890⬝10⁹ (+3.21%)
Mathlib.Algebra.Order.Field.Power +3.645⬝10⁹ (+10.44%)
Mathlib.Algebra.Order.Group.Abs +3.482⬝10⁹ (+19.62%)
Mathlib.Combinatorics.SimpleGraph.Triangle.Basic +3.398⬝10⁹ (+10.68%)
Mathlib.Algebra.Order.Interval.Basic +3.366⬝10⁹ (+8.81%)
Mathlib.Topology.Algebra.Order.Field +3.226⬝10⁹ (+10.06%)
Mathlib.Combinatorics.SetFamily.FourFunctions +3.176⬝10⁹ (+5.39%)
Mathlib.Analysis.Convex.Function +3.146⬝10⁹ (+2.73%)
14 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.LinearAlgebra.AffineSpace.Ordered +2.922⬝10⁹ (+6.38%)
Mathlib.Topology.Algebra.Valued.LocallyCompact +2.903⬝10⁹ (+5.70%)
Mathlib.RingTheory.HahnSeries.HEval +2.793⬝10⁹ (+6.51%)
Mathlib.RingTheory.HahnSeries.Summable +2.755⬝10⁹ (+3.71%)
Mathlib.Analysis.InnerProductSpace.Projection +2.709⬝10⁹ (+1.36%)
Mathlib.NumberTheory.NumberField.CanonicalEmbedding.FundamentalCone +2.690⬝10⁹ (+2.47%)
Mathlib.Combinatorics.Pigeonhole +2.656⬝10⁹ (+23.49%)
Mathlib.Combinatorics.SimpleGraph.Triangle.Tripartite +2.507⬝10⁹ (+7.54%)
Mathlib.LinearAlgebra.RootSystem.Irreducible +2.504⬝10⁹ (+8.79%)
Mathlib.Order.KrullDimension +2.353⬝10⁹ (+3.76%)
Mathlib.RingTheory.DedekindDomain.Ideal +2.311⬝10⁹ (+1.22%)
Mathlib.Algebra.Order.Monoid.Prod +2.116⬝10⁹ (+35.93%)
Mathlib.Analysis.Convex.Basic +2.42⬝10⁹ (+3.36%)
Mathlib.LinearAlgebra.Eigenspace.Pi +2.32⬝10⁹ (+5.16%)
39 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.Order.Interval.Set.IsoIoo +1.917⬝10⁹ (+18.64%)
Mathlib.Tactic.Positivity.Basic +1.891⬝10⁹ (+3.19%)
Mathlib.Topology.UnitInterval +1.747⬝10⁹ (+6.01%)
Mathlib.Combinatorics.SetFamily.LYM +1.667⬝10⁹ (+10.09%)
Mathlib.RingTheory.Valuation.LocalSubring +1.651⬝10⁹ (+3.48%)
Mathlib.Algebra.Lie.Submodule +1.651⬝10⁹ (+1.20%)
Mathlib.Data.Sign +1.643⬝10⁹ (+4.49%)
Mathlib.Algebra.Order.Group.Defs +1.617⬝10⁹ (+17.62%)
Mathlib.Algebra.Order.Ring.Cast +1.586⬝10⁹ (+11.25%)
Mathlib.Analysis.InnerProductSpace.Defs +1.572⬝10⁹ (+3.25%)
Mathlib.Algebra.Lie.Solvable +1.547⬝10⁹ (+3.73%)
Mathlib.Algebra.Order.Pi +1.529⬝10⁹ (+13.27%)
Mathlib.Algebra.Order.AbsoluteValue.Basic +1.448⬝10⁹ (+5.53%)
Mathlib.RingTheory.FractionalIdeal.Operations +1.447⬝10⁹ (+1.33%)
Mathlib.LinearAlgebra.TensorProduct.Quotient +1.427⬝10⁹ (+1.97%)
Mathlib.Tactic.Positivity.Core +1.401⬝10⁹ (+5.26%)
Mathlib.Algebra.Order.Module.Pointwise +1.391⬝10⁹ (+14.50%)
Mathlib.LinearAlgebra.Dual.Lemmas +1.334⬝10⁹ (+0.38%)
Mathlib.Combinatorics.SimpleGraph.Regularity.Uniform +1.334⬝10⁹ (+3.03%)
Mathlib.Data.EReal.Operations +1.314⬝10⁹ (+1.94%)
Mathlib.Data.NNReal.Defs +1.308⬝10⁹ (+2.46%)
Mathlib.Algebra.Lie.Weights.RootSystem +1.226⬝10⁹ (+0.75%)
Mathlib.RingTheory.FractionalIdeal.Basic +1.207⬝10⁹ (+1.92%)
Mathlib.Computability.AkraBazzi.GrowsPolynomially +1.205⬝10⁹ (+1.88%)
Mathlib.Algebra.QuadraticDiscriminant +1.181⬝10⁹ (+4.64%)
Mathlib.LinearAlgebra.PerfectPairing.Basic +1.178⬝10⁹ (+1.63%)
Mathlib.Analysis.Convex.Quasiconvex +1.171⬝10⁹ (+7.21%)
Mathlib.RingTheory.Ideal.Quotient.Operations +1.154⬝10⁹ (+0.65%)
Mathlib.Analysis.Normed.Algebra.Spectrum +1.153⬝10⁹ (+0.77%)
Mathlib.Analysis.BoxIntegral.Box.Basic +1.145⬝10⁹ (+6.49%)
Mathlib.NumberTheory.NumberField.FinitePlaces +1.117⬝10⁹ (+1.17%)
Mathlib.Data.EReal.Basic +1.110⬝10⁹ (+4.59%)
Mathlib.NumberTheory.NumberField.ProductFormula +1.108⬝10⁹ (+6.64%)
Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional +1.83⬝10⁹ (+2.07%)
Mathlib.LinearAlgebra.Eigenspace.Basic +1.63⬝10⁹ (+0.76%)
Mathlib.RingTheory.HahnSeries.PowerSeries +1.63⬝10⁹ (+5.74%)
Mathlib.Algebra.Order.BigOperators.Expect +1.55⬝10⁹ (+3.34%)
Mathlib.NumberTheory.Cyclotomic.Basic +1.51⬝10⁹ (+1.41%)
Mathlib.Algebra.Lie.TraceForm +1.35⬝10⁹ (+0.55%)
23 files, Instructions -2.0⬝10⁹
File Instructions %
Mathlib.Combinatorics.SimpleGraph.Path -1.53⬝10⁹ (-2.36%)
Mathlib.Order.LiminfLimsup -1.87⬝10⁹ (-2.43%)
Mathlib.RingTheory.HahnSeries.Multiplication -1.133⬝10⁹ (-1.17%)
Mathlib.Analysis.Meromorphic.Divisor -1.140⬝10⁹ (-4.84%)
Mathlib.Algebra.MonoidAlgebra.Division -1.150⬝10⁹ (-9.39%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances -1.155⬝10⁹ (-0.47%)
Mathlib.CategoryTheory.SmallObject.TransfiniteCompositionLifting -1.165⬝10⁹ (-3.21%)
Mathlib.LinearAlgebra.Orientation -1.181⬝10⁹ (-1.36%)
Mathlib.Algebra.Order.Interval.Finset.Basic -1.302⬝10⁹ (-18.98%)
Mathlib.Tactic.Positivity.Finset -1.388⬝10⁹ (-10.05%)
Mathlib.Algebra.MvPolynomial.Eval -1.394⬝10⁹ (-2.43%)
Mathlib.Algebra.MvPolynomial.Basic -1.420⬝10⁹ (-2.25%)
Mathlib.RingTheory.Polynomial.Bernstein -1.441⬝10⁹ (-3.11%)
Mathlib.Combinatorics.SimpleGraph.Subgraph -1.592⬝10⁹ (-3.12%)
Mathlib.LinearAlgebra.Ray -1.603⬝10⁹ (-2.21%)
Mathlib.Combinatorics.SimpleGraph.Circulant -1.662⬝10⁹ (-15.14%)
Mathlib.LinearAlgebra.AffineSpace.Combination -1.681⬝10⁹ (-2.27%)
Mathlib.NumberTheory.LSeries.ZMod -1.806⬝10⁹ (-3.19%)
Mathlib.Dynamics.TopologicalEntropy.NetEntropy -1.831⬝10⁹ (-7.97%)
Mathlib.Algebra.Order.Floor.Div -1.844⬝10⁹ (-7.73%)
Mathlib.Analysis.Asymptotics.ExpGrowth -1.868⬝10⁹ (-3.28%)
Mathlib.LinearAlgebra.Matrix.PosDef -1.910⬝10⁹ (-2.78%)
Mathlib.Topology.Algebra.Group.Basic -1.947⬝10⁹ (-3.08%)
12 files, Instructions -3.0⬝10⁹
File Instructions %
Mathlib.NumberTheory.Modular -2.184⬝10⁹ (-2.51%)
Mathlib.CategoryTheory.Limits.Shapes.Preorder.TransfiniteCompositionOfShape -2.222⬝10⁹ (-7.47%)
Mathlib.Combinatorics.SimpleGraph.Triangle.Removal -2.302⬝10⁹ (-4.83%)
Mathlib.Dynamics.TopologicalEntropy.Semiconj -2.366⬝10⁹ (-15.08%)
Mathlib.Tactic.LinearCombination.Lemmas -2.397⬝10⁹ (-13.26%)
Mathlib.Combinatorics.SimpleGraph.Clique -2.423⬝10⁹ (-5.76%)
Mathlib.LinearAlgebra.AffineSpace.AffineEquiv -2.429⬝10⁹ (-3.74%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.NonUnital -2.502⬝10⁹ (-0.87%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric -2.580⬝10⁹ (-1.28%)
Mathlib.LinearAlgebra.TensorProduct.Submodule -2.582⬝10⁹ (-3.67%)
Mathlib.Data.Real.Basic -2.769⬝10⁹ (-8.37%)
Mathlib.Dynamics.TopologicalEntropy.CoverEntropy -2.933⬝10⁹ (-10.11%)
4 files, Instructions -4.0⬝10⁹
File Instructions %
Mathlib.Algebra.Order.Ring.Basic -3.71⬝10⁹ (-9.84%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital -3.312⬝10⁹ (-2.10%)
Mathlib.Combinatorics.Schnirelmann -3.775⬝10⁹ (-16.07%)
Mathlib.Order.Interval.Finset.Box -3.901⬝10⁹ (-16.64%)
2 files, Instructions -5.0⬝10⁹
File Instructions %
Mathlib.LinearAlgebra.AffineSpace.AffineMap -4.29⬝10⁹ (-3.57%)
Mathlib.Algebra.Algebra.Quasispectrum -4.878⬝10⁹ (-5.80%)
2 files, Instructions -6.0⬝10⁹
File Instructions %
Mathlib.Data.NNRat.Floor -5.102⬝10⁹ (-25.28%)
Mathlib.Algebra.Order.Group.Pointwise.Interval -5.434⬝10⁹ (-3.86%)
File Instructions %
Mathlib.Analysis.Convex.Mul -8.379⬝10⁹ (-10.19%)
Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Rpow.Basic -9.471⬝10⁹ (-5.75%)
Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order -16.232⬝10⁹ (-8.22%)
CI run

Copy link
Copy Markdown
Contributor

@sgouezel sgouezel left a comment

Choose a reason for hiding this comment

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

Review of the beginning of the file, I have to stop for now. Thanks a lot for doing this!

let _a ← synthInstanceQ (q(Semifield $α) : Q(Type u))
let _a ← synthInstanceQ (q(LinearOrder $α) : Q(Type u))
let _a ← synthInstanceQ (q(IsStrictOrderedRing $α) : Q(Prop))
assumeInstancesCommute
Copy link
Copy Markdown
Contributor

@sgouezel sgouezel Apr 4, 2025

Choose a reason for hiding this comment

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

Just spotting things which are not "obviously" correct. I don't know anything about metaprogramming, so I don't know why you have inserted an assumeInstancesCommute here.

theorem antitone_iff_map_nonneg : Antitone (f : α → β) ↔ ∀ a ≤ 0, 0 ≤ f a :=
monotone_comp_ofDual_iff.symm.trans <| monotone_iff_map_nonneg (α := αᵒᵈ) (iamhc := iamhc) _

variable [AddLeftStrictMono β]
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.

Just to point out that there is a strict improvement here: this typeclass was not necessary before, but this wasn't known to typeclass inference at this stage of the library.

let _a ← synthInstanceQ (q(Semifield $α) : Q(Type u))
let _a ← synthInstanceQ (q(LinearOrder $α) : Q(Type u))
let _a ← synthInstanceQ (q(IsStrictOrderedRing $α) : Q(Prop))
assumeInstancesCommute
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.

I don't feel confident to sign off on this addition of assumeInstancesCommute because I don't understand the code.

let ra ← core zα pα a
let ofNonneg (pa : Q(0 ≤ $a)) (_oα : Q(LinearOrderedSemifield $α)) :
let ofNonneg (pa : Q(0 ≤ $a))
(_oα : Q(Semifield $α)) (_oα : Q(LinearOrder $α)) (_oα : Q(IsStrictOrderedRing $α)) :
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.

Is it OK here and in other places to use the same variable names?

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.

Do we even need variable names here and elsewhere?

eval {u α} _ _ e := do
let ~q(@NonemptyInterval.length _ $ig $ipo $a) := e |
throwError "not NonemptyInterval.length"
let _i ← synthInstanceQ q(IsOrderedAddMonoid $α)
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.

Again I don't want to sign off on this part of the PR because I don't understand it.

let _oα ← synthInstanceQ q(LinearOrderedField $α)
let _oα ← synthInstanceQ q(Field $α)
let _oα ← synthInstanceQ q(LinearOrder $α)
let _oα ← synthInstanceQ q(IsStrictOrderedRing $α)
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.

(again is it fine that all these instances have the same name? I don't know enough about metaprogramming to know if this is an issue)

let _oα ← synthInstanceQ q(LinearOrderedField $α)
let _oα ← synthInstanceQ q(Field $α)
let _oα ← synthInstanceQ q(LinearOrder $α)
let _oα ← synthInstanceQ q(IsStrictOrderedRing $α)
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.

(again is it fine that all these instances have the same name? I don't know enough about metaprogramming to know if this is an issue)

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.

Note to self let __ ← synthInstanceQ works.

⟨by simp [hbc.trans (le_mabs_self c)], by
simp [(inv_le_inv_iff.mpr hab).trans (inv_le_mabs a)]⟩

omit [IsOrderedMonoid G] in
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.

These indicate that they are in the wrong module. Something to address on clean up.

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.

At least one could add a TODO maybe?

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 think that grepping for omit is enough since any omit has the same signal.

section OrderedCommMonoid

variable { : OrderedCommMonoid α} { : OrderedCommMonoid β}
variable {_ : Preorder α} {_ : Preorder β} {_ : MulOneClass α} {_ : MulOneClass β}
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.

Not for this PR, but there should be a systematic review of this pattern at some point.

Copy link
Copy Markdown
Member

@kbuzzard kbuzzard left a comment

Choose a reason for hiding this comment

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

Modulo my comments on code which I don't understand, LGTM. I would just merge but I just want some assurances that the meta code is OK.

@mattrobball
Copy link
Copy Markdown
Contributor

Thanks! \n bors merge

@mattrobball
Copy link
Copy Markdown
Contributor

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Apr 4, 2025
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 4, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: use mixin ordered algebraic typeclasses (part 1) [Merged by Bors] - chore: use mixin ordered algebraic typeclasses (part 1) Apr 4, 2025
@mathlib-bors mathlib-bors bot closed this Apr 4, 2025
@mathlib-bors mathlib-bors bot deleted the FR_ordered_mixin_lemmas branch April 4, 2025 17:53
mathlib-bors bot pushed a commit that referenced this pull request Jun 4, 2025
This restores a change from #22284 that was accidentally reverted in #20594.

Also avoid using IsAddUnit when the unit can be constructed directly, which gives better defeqs.
joelriou pushed a commit that referenced this pull request Jun 8, 2025
This restores a change from #22284 that was accidentally reverted in #20594.

Also avoid using IsAddUnit when the unit can be constructed directly, which gives better defeqs.
TOMILO87 pushed a commit that referenced this pull request Jun 8, 2025
This restores a change from #22284 that was accidentally reverted in #20594.

Also avoid using IsAddUnit when the unit can be constructed directly, which gives better defeqs.
callesonne pushed a commit to callesonne/mathlib4 that referenced this pull request Jul 24, 2025
…-community#25412)

This restores a change from leanprover-community#22284 that was accidentally reverted in leanprover-community#20594.

Also avoid using IsAddUnit when the unit can be constructed directly, which gives better defeqs.
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-algebra Algebra (groups, rings, fields, etc) t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants