Skip to content

[Merged by Bors] - chore: use delta deriving for #380#28498

Closed
kmill wants to merge 5 commits intomasterfrom
kmill_use_delta_derive_1
Closed

[Merged by Bors] - chore: use delta deriving for #380#28498
kmill wants to merge 5 commits intomasterfrom
kmill_use_delta_derive_1

Conversation

@kmill
Copy link
Copy Markdown
Contributor

@kmill kmill commented Aug 15, 2025

The new delta deriving handler from leanprover/lean4#9800 makes it possible to address most of issue #380. There are still some cases that are not handled:

  • Some definitions are abbreviations, so there is no point in deriving instances, since they already inherit instances. Plus, adding instances to abbreviations adds intances to the unfolded abbreviation, which might not be wanted.
  • Deriving Functor.Full and Functor.Faithful often gives the wrong instance. For example, with Skeleton and fromSkeleton, the derived instances are in terms of InducedCategory, not Skeleton. It might not ever be possible to derive instances in this situation.

Open in Gitpod

The new delta deriving handler from leanprover/lean4#9800 makes it possible to address most of issue #380. There are still some cases that are not handled:
- Some definitions are abbreviations, so there is no point in deriving instances, since they already inherit instances. Plus, adding instances to abbreviations adds intances to the unfolded abbreviation, which might not be wanted.
- Deriving `Functor.Full` and `Functor.Faithful` often gives the wrong instance. For example, with `Skeleton` and `fromSkeleton`, the derived instances are in terms of `InducedCategory`, not `Skeleton. It might not ever be possible to derive instances in this situation.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 15, 2025

PR summary 3fb2e06161

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ instance : Algebra A K := inferInstanceAs <| Algebra A.toSubring K
+ instance : CommRing A := inferInstanceAs <| CommRing A.toSubring
+ instance : IsDomain A := inferInstanceAs <| IsDomain A.toSubring
+ instance : Module (MonoidAlgebra k G) ρ.asModule
+ instance : Module (ResidueField R) (CotangentSpace R)
- Arrow.inhabited
- Cotangent.isScalarTower
- Cotangent.moduleOfTower
- KaehlerDifferential.module
- NatOrdinal.instLinearOrder
- NatOrdinal.instNoMaxOrder
- NatOrdinal.instOrderBot
- NatOrdinal.instSuccOrder
- NatOrdinal.instZeroLEOneClass
- NatOrdinal.uncountable
- ResidueFieldCommRing
- ResidueFieldInhabited
- SheafCat
- algebra
- algebra'
- commRing
- commutator_characteristic
- cotangentModule
- inhabited
- instAlgebra
- instContinuousLinearMapClass
- instContinuousMapClass
- instFintype
- instFunLike
- instGroup
- instModuleAsModule
- instMonoidHomClass
- instRing
- instance (C) [Quiver C] : Inhabited (HomRel C)
- instance (X : C) : Preorder (J.Cover X)
- instance (α : Type*) : Inhabited (SetSemiring α)
- instance (α : Type*) : OrderBot (SetSemiring α)
- instance (α : Type*) : PartialOrder (SetSemiring α)
- instance : AddCommGroup (KaehlerDifferential R S) := inferInstanceAs <|
- instance : AddCommGroup (TangentSpace I x) := inferInstanceAs (AddCommGroup E)
- instance : AddCommGroup I.Cotangent := by delta Cotangent; infer_instance
- instance : AddCommMonoid (ρ.asModule) := inferInstanceAs <| AddCommMonoid V
- instance : AlgEquivClass p.Gal F p.SplittingField p.SplittingField
- instance : Algebra (ZMod p) (GaloisField p n) := SplittingField.algebra _
- instance : Algebra A K
- instance : CanonicallyOrderedAdd PrimeMultiset
- instance : CanonicallyOrderedAdd ℕ∞ := WithTop.canonicallyOrderedAdd
- instance : Category (Arrow T) := commaCategory
- instance : Category (OpensLeCover U) := ObjectProperty.FullSubcategory.category _
- instance : Category (Skeleton C) := by
- instance : CharP (GaloisField p n) p
- instance : CharZero ℕ∞ := inferInstanceAs (CharZero (WithTop ℕ))
- instance : CommGroup (PontryaginDual A)
- instance : CommRing A
- instance : CompleteLinearOrder ENat
- instance : ContinuousConstSMul 𝕜 (TangentSpace I x) := inferInstanceAs (ContinuousConstSMul 𝕜 E)
- instance : ContinuousSMul 𝕜 (TangentSpace I x) := inferInstanceAs (ContinuousSMul 𝕜 E)
- instance : CountableInterFilter (countableGenerate g) := by
- instance : Epi (toTotalQuotientPresheaf F) := epi_toLocalizationPresheaf _
- instance : EquivLike p.Gal p.SplittingField p.SplittingField
- instance : Field (GaloisField p n)
- instance : Finite (GaloisField p n)
- instance : FiniteDimensional (ZMod p) (GaloisField p n) := by
- instance : FunLike (PontryaginDual A) A Circle
- instance : Inhabited (@GaloisField 2 (Fact.mk Nat.prime_two) 1) := ⟨37⟩
- instance : Inhabited (Monoid.CoprodI M)
- instance : Inhabited (PontryaginDual A)
- instance : Inhabited (SingleObj α)
- instance : Inhabited (TensorAlgebra R M) := RingQuot.instInhabited _
- instance : Inhabited I.Cotangent := ⟨0⟩
- instance : Injective <| syzygies f := injective_under (cokernel f)
- instance : IsDomain A
- instance : IsOrderedCancelAddMonoid PrimeMultiset
- instance : IsOrderedRing ℕ∞ := WithTop.instIsOrderedRing
- instance : IsScalarTower S (S ⊗[R] S) Ω[S⁄R]
- instance : IsSplittingField (ZMod p) (GaloisField p n) (X ^ p ^ n - X)
- instance : IsTopologicalAddGroup (TangentSpace I x) := inferInstanceAs (IsTopologicalAddGroup E)
- instance : IsTopologicalGroup (PontryaginDual A)
- instance : LinearOrderedCommGroupWithZero (ValueGroup A) := by
- instance : Module (ResidueField R) (CotangentSpace R) := Ideal.cotangentModule _
- instance : Module k ρ.asModule := inferInstanceAs <| Module k V
- instance : Module 𝕜 (TangentSpace I x) := inferInstanceAs (Module 𝕜 E)
- instance : Monoid (Monoid.CoprodI M) := by
- instance : Nonempty Ω[S⁄R] := ⟨0⟩
- instance : OrderBot PrimeMultiset
- instance : OrderBot ℕ∞ := WithTop.orderBot
- instance : OrderTop ℕ∞ := WithTop.orderTop
- instance : OrderedSub PrimeMultiset
- instance : OrderedSub ℕ∞ := inferInstanceAs (OrderedSub (WithTop ℕ))
- instance : PathConnectedSpace (TangentSpace I x) := inferInstanceAs (PathConnectedSpace E)
- instance : Semiring (TensorAlgebra R M) := RingQuot.instSemiring _
- instance : Subgroup.Normal (commutator G) := Subgroup.commutator_normal ⊤ ⊤
- instance : SuccOrder ℕ∞ := inferInstanceAs (SuccOrder (WithTop ℕ))
- instance : T2Space (PontryaginDual A)
- instance : TopologicalSpace (PontryaginDual A)
- instance : TopologicalSpace (TangentSpace I x) := inferInstanceAs (TopologicalSpace E)
- instance : WellFoundedLT ℕ∞ := inferInstanceAs (WellFoundedLT (WithTop ℕ))
- instance [DiscreteTopology A] : CompactSpace (PontryaginDual A)
- instance [Inhabited C] : Inhabited (Skeleton C)
- instance [IsNoetherian R I] : IsNoetherian R I.Cotangent
- instance {S : Type*} [DistribSMul S K] [IsScalarTower S K K] : SMul S (SplittingField f)
- instance {m : ℤ} : AddCommGroup (StandardOneDimIsocrystal p k m)
- instance {m : ℤ} : Module K(p, k) (StandardOneDimIsocrystal p k m)
- instance {α : Type*} : Unique (SingleObj α)
- instance {α} [CoeSort C α] : CoeSort (Skeleton C) α
- isScalarTower
-- instContinuousAdd
-- instInhabited
-- instTopologicalSpace
--- instAddCommMonoid
--- instModule

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

Copy link
Copy Markdown
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

I'm going to merge this. It is a very clear and substantial improvement. The cases where deriving still does not work have clear comments that can be dealt with in a follow-up PR.

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Aug 16, 2025
mathlib-bors bot pushed a commit that referenced this pull request Aug 16, 2025
The new delta deriving handler from leanprover/lean4#9800 makes it possible to address most of issue #380. There are still some cases that are not handled:
- Some definitions are abbreviations, so there is no point in deriving instances, since they already inherit instances. Plus, adding instances to abbreviations adds intances to the unfolded abbreviation, which might not be wanted.
- Deriving `Functor.Full` and `Functor.Faithful` often gives the wrong instance. For example, with `Skeleton` and `fromSkeleton`, the derived instances are in terms of `InducedCategory`, not `Skeleton`. It might not ever be possible to derive instances in this situation.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 16, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: use delta deriving for #380 [Merged by Bors] - chore: use delta deriving for #380 Aug 16, 2025
@mathlib-bors mathlib-bors bot closed this Aug 16, 2025
@mathlib-bors mathlib-bors bot deleted the kmill_use_delta_derive_1 branch August 16, 2025 08:07
Julian added a commit to Aaron1011/mathlib4 that referenced this pull request Aug 16, 2025
* origin/master: (508 commits)
  feat(Logic/Basic): forall_and_index (leanprover-community#27737)
  feat(Algebra/intNorm): `x` divides `intNorm x` (leanprover-community#28021)
  feat(RingTheory/MvPolynomial/MonomialOrder): some lemmas about degree (leanprover-community#26000)
  chore: more elementary Motzkin polynomial proof (leanprover-community#28482)
  feat: e-seminormed monoid (leanprover-community#27385)
  feat(RingTheory): ` (⊥ : Ideal R) ^ n = ⊥` (leanprover-community#28171)
  fix(LinearAlgebra/Dimension/ErdosKaplansky): authorship (leanprover-community#28513)
  chore: golf entire `X_pow_eq_monomial` (leanprover-community#28504)
  feat(RingTheory): invertible modules and Picard group (leanprover-community#25337)
  chore: use delta `deriving` for leanprover-community#380 (leanprover-community#28498)
  feat: add bilinear maps for vector/matrix products (leanprover-community#28130)
  feat(Counterexamples): topologists' sine curve (leanprover-community#25833)
  feat(Analysis/Convex): doubly stochastic matrices have operator norm at most one (leanprover-community#28453)
  chore(Topology/Compactification): deprecate duplicate `ultrafilter_pure_injective` (leanprover-community#28436)
  feat: add `@[simp]` to `Multiset.cons_le_cons` and `Finset.insert_subset_insert` (leanprover-community#28285)
  feat: make `ring` work for semifields (leanprover-community#28494)
  feat: filtering lists and bounded quantifiers are primitive recursive (leanprover-community#26295)
  chore(Analysis/Analytic): split `Analytic.Basic` (leanprover-community#26270)
  refactor: tidy `mulVec` and `vecMul` lemmas about `•` (leanprover-community#28450)
  feat(Order/WellFounded): Acc and infinite descending chain (leanprover-community#28120)
  feat(NumberTheory/Padics): {Int,Rat}.padicValuation (leanprover-community#27667)
  chore(*): address a few timeout-related porting notes (leanprover-community#28483)
  feat(Algebra): toAlgebra_algebraMap (leanprover-community#28238)
  feat(Shrink): `IsCancelMul` instance (leanprover-community#28407)
  chore(Geometry): golf entire `chart_eq'` and `orthogonalProjection_orthogonalProjection` (leanprover-community#28485)
  feat: shifted geometric series and a `ProbabilityMeasure` version of `measure_iUnion_le` (leanprover-community#28087)
  chore(LinearAlgebra/PiTensorProduct): `rw` away use of `erw` in `lifts_zero` (leanprover-community#27554)
  feat(RingTheory): faithfully flat ring maps (leanprover-community#24530)
  chore(Geometry/RingedSpace): remove use of `erw` in `stalkSpecializes_stalkMap` (leanprover-community#27656)
  chore: add the Brownian motion project to downstream_repos.yml (leanprover-community#28459)
  feat(CategoryTheory/Sites/SheafOfTypes): composition of a sheaf with uliftFunctor is still a sheaf (leanprover-community#27816)
  feat(Valuation/DiscreteValuationRel): val relations with compatible valuations to Zm0 are IsDiscrete (leanprover-community#27213)
  chore(*): process a bunch of `aesop`-related porting notes (leanprover-community#28402)
  feat(CategoryTheory): abstract argument for the stability under transfinite compositions (leanprover-community#26030)
  chore: bump toolchain to v4.23.0-rc2 (leanprover-community#28454)
  chore(FieldTheory/Finite): fermat's little theorem in Nat form (leanprover-community#27962)
  feat(Combinatorics/SimpleGraph/Paths): add theorem `SimpleGraph.Walk.IsPath.concat` (leanprover-community#27582)
  feat(Slope): slope_pos_iff_of_le and related lemmas (leanprover-community#28039)
  feat: tactic analysis framework (leanprover-community#26683)
  chore(Data/EReal): deprecate `add_pos_of_nonneg_of_pos` and `add_ne_top_iff_of_ne_bot` (duplicates) (leanprover-community#28424)
  feat(MathlibTest/FieldSimp): add a few more tests (leanprover-community#28413)
  chore(RingTheory/HahnSeries): deprecate duplicate `orderTop_add_orderTop_le_orderTop_mul` (leanprover-community#28231)
  chore(AlgebraicGeometry/IdealSheaf): deprecate duplicate `AlgebraicGeometry.Scheme.IdealSheafData.Scheme.zeroLocus_radical` (leanprover-community#28202)
  feat(Algebra/Order): ArchimedeanClass ball (leanprover-community#27885)
  chore(Geometry/RingedSpace): remove use of `erw` in `isUnit_of_isUnit_germ` (leanprover-community#27660)
  feat(SkewMonoidAlgebra): coeff_mul lemmas (leanprover-community#27255)
  chore(LinearAlgebra): golf entire `isUnit_det` (leanprover-community#28438)
  chore(FieldTheory/IntermediateField): golf entire `coe_sum` and `coe_prod` (leanprover-community#28431)
  feat: separate linter error message for empty doc-strings (leanprover-community#27895)
  feat(RingTheory/PowerSeries/Binomial): add basic lemmas, golf (leanprover-community#27497)
  ...
Paul-Lez pushed a commit to Paul-Lez/mathlib4 that referenced this pull request Aug 23, 2025
…community#28498)

The new delta deriving handler from leanprover/lean4#9800 makes it possible to address most of issue leanprover-community#380. There are still some cases that are not handled:
- Some definitions are abbreviations, so there is no point in deriving instances, since they already inherit instances. Plus, adding instances to abbreviations adds intances to the unfolded abbreviation, which might not be wanted.
- Deriving `Functor.Full` and `Functor.Faithful` often gives the wrong instance. For example, with `Skeleton` and `fromSkeleton`, the derived instances are in terms of `InducedCategory`, not `Skeleton`. It might not ever be possible to derive instances in this situation.
pechersky pushed a commit to pechersky/mathlib4 that referenced this pull request Aug 25, 2025
…community#28498)

The new delta deriving handler from leanprover/lean4#9800 makes it possible to address most of issue leanprover-community#380. There are still some cases that are not handled:
- Some definitions are abbreviations, so there is no point in deriving instances, since they already inherit instances. Plus, adding instances to abbreviations adds intances to the unfolded abbreviation, which might not be wanted.
- Deriving `Functor.Full` and `Functor.Faithful` often gives the wrong instance. For example, with `Skeleton` and `fromSkeleton`, the derived instances are in terms of `InducedCategory`, not `Skeleton`. It might not ever be possible to derive instances in this situation.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants