Skip to content

[Merged by Bors] - chore: make Rat.castHom implicit_reducible - #43242

Closed
xroblot wants to merge 7 commits into
leanprover-community:masterfrom
xroblot:reducible-rat-castHom
Closed

xroblot wants to merge 7 commits into
leanprover-community:masterfrom
xroblot:reducible-rat-castHom

Conversation

@xroblot

@xroblot xroblot commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

Mark Rat.castHom as @[implicit_reducible]. The Algebra ℚ structure coming from DivisionRing.toRatAlgebra should now agree at instance transparency, and not only at default transparency, with the algebra structure a type already carries. Two examples record this, for an intermediate field of a field of characteristic zero and for QuadraticAlgebra ℚ a b. (The second one also needs the structure map of QuadraticAlgebra.instAlgebra to be given by the constructor rather than through QuadraticAlgebra.C, which is done here as well.)

One proof needed repair, in Mathlib/FieldTheory/PrimeField.lean. The benchmark reports no significant change.

Prepared with Claude Code 🤖


@xroblot xroblot added the WIP Work in progress label Aug 30, 2026
@xroblot

xroblot commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@github-actions

github-actions Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

PR summary fb22e93973

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.FieldTheory.IntermediateField.Basic 1197 1198 +1 (+0.08%)
Mathlib.Algebra.QuadraticAlgebra.Basic 1380 1381 +1 (+0.07%)
Import changes for all files
Files Import difference
259 files Mathlib.Algebra.CharP.IntermediateField Mathlib.Algebra.Lie.AdjointAction.Basic Mathlib.Algebra.Lie.AdjointAction.JordanChevalley Mathlib.Algebra.Lie.Basis.Basic Mathlib.Algebra.Lie.Basis.Prod Mathlib.Algebra.Lie.CartanExists Mathlib.Algebra.Lie.Derivation.Killing Mathlib.Algebra.Lie.EngelSubalgebra Mathlib.Algebra.Lie.Engel Mathlib.Algebra.Lie.Killing Mathlib.Algebra.Lie.LieTheorem Mathlib.Algebra.Lie.Rank Mathlib.Algebra.Lie.Semisimple.Lemmas Mathlib.Algebra.Lie.Sl2 Mathlib.Algebra.Lie.TraceForm Mathlib.Algebra.Lie.Weights.Basic Mathlib.Algebra.Lie.Weights.Cartan Mathlib.Algebra.Lie.Weights.Chain Mathlib.Algebra.Lie.Weights.Killing Mathlib.Algebra.Lie.Weights.Linear Mathlib.Algebra.Module.Torsion.PrimaryComponent Mathlib.Algebra.Polynomial.Bivariate Mathlib.Algebra.QuadraticAlgebra.AlgHom Mathlib.Algebra.QuadraticAlgebra.Basic Mathlib.Algebra.QuadraticAlgebra.Discr Mathlib.Algebra.QuadraticAlgebra.Discriminant Mathlib.Algebra.QuadraticAlgebra.NormDeterminant Mathlib.AlgebraicGeometry.AlgClosed.Basic Mathlib.AlgebraicGeometry.ColimitsOver Mathlib.AlgebraicGeometry.EllipticCurve.Affine.AddSubMap Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Point Mathlib.AlgebraicGeometry.EllipticCurve.DivisionPolynomial.Basic Mathlib.AlgebraicGeometry.EllipticCurve.DivisionPolynomial.Degree Mathlib.AlgebraicGeometry.EllipticCurve.IsomOfJ Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian.Basic Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian.Formula Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian.Point Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Basic Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Formula Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Point Mathlib.AlgebraicGeometry.Group.Smooth Mathlib.AlgebraicGeometry.Morphisms.Etale Mathlib.AlgebraicGeometry.Morphisms.FlatDescent Mathlib.AlgebraicGeometry.Morphisms.FlatMono Mathlib.AlgebraicGeometry.Morphisms.FormallyUnramified Mathlib.AlgebraicGeometry.Morphisms.LocalFlatDescent Mathlib.AlgebraicGeometry.Morphisms.SmoothFiber Mathlib.AlgebraicGeometry.Morphisms.Smooth Mathlib.AlgebraicGeometry.Morphisms.UniversallyInjective Mathlib.AlgebraicGeometry.Morphisms.WeaklyEtale Mathlib.AlgebraicGeometry.RelativeGluing Mathlib.AlgebraicGeometry.Sites.AffineEtale Mathlib.AlgebraicGeometry.Sites.EtalePoint Mathlib.AlgebraicGeometry.Sites.Etale Mathlib.AlgebraicGeometry.Sites.Proetale Mathlib.AlgebraicGeometry.Sites.SmallAffineZariski Mathlib.CategoryTheory.Preadditive.Schur Mathlib.Combinatorics.Additive.ErdosGinzburgZiv Mathlib.FieldTheory.AbelRuffini Mathlib.FieldTheory.AbsoluteGaloisGroup Mathlib.FieldTheory.AlgebraicClosure Mathlib.FieldTheory.AxGrothendieck Mathlib.FieldTheory.CardinalEmb Mathlib.FieldTheory.Cardinality Mathlib.FieldTheory.ChevalleyWarning Mathlib.FieldTheory.Differential.Basic Mathlib.FieldTheory.Differential.Liouville Mathlib.FieldTheory.Extension Mathlib.FieldTheory.FinTrdeg Mathlib.FieldTheory.Finite.Basic Mathlib.FieldTheory.Finite.Extension Mathlib.FieldTheory.Finite.GaloisField Mathlib.FieldTheory.Finite.Polynomial Mathlib.FieldTheory.Finite.Trace Mathlib.FieldTheory.Finite.Valuation Mathlib.FieldTheory.Fixed Mathlib.FieldTheory.Galois.Abelian Mathlib.FieldTheory.Galois.Basic Mathlib.FieldTheory.Galois.GaloisClosure Mathlib.FieldTheory.Galois.Infinite Mathlib.FieldTheory.Galois.NormalBasis Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra Mathlib.FieldTheory.IntermediateField.Adjoin.Basic Mathlib.FieldTheory.IntermediateField.Adjoin.Defs Mathlib.FieldTheory.IntermediateField.Algebraic Mathlib.FieldTheory.IntermediateField.Basic Mathlib.FieldTheory.IntermediateField.ExtendRight Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure Mathlib.FieldTheory.IsAlgClosed.Basic Mathlib.FieldTheory.IsAlgClosed.Classification Mathlib.FieldTheory.IsAlgClosed.Spectrum Mathlib.FieldTheory.IsPerfectClosure Mathlib.FieldTheory.IsSepClosed Mathlib.FieldTheory.Isaacs Mathlib.FieldTheory.JacobsonNoether Mathlib.FieldTheory.KrullTopology Mathlib.FieldTheory.KummerExtension Mathlib.FieldTheory.LinearDisjoint Mathlib.FieldTheory.Minpoly.ConjRootClass Mathlib.FieldTheory.Minpoly.IsConjRoot Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed Mathlib.FieldTheory.Minpoly.MinpolyDiv Mathlib.FieldTheory.Normal.Basic Mathlib.FieldTheory.Normal.Closure Mathlib.FieldTheory.Normal.Defs Mathlib.FieldTheory.NormalizedTrace Mathlib.FieldTheory.PerfectClosure Mathlib.FieldTheory.Perfect Mathlib.FieldTheory.PolynomialGaloisGroup Mathlib.FieldTheory.PrimitiveElement Mathlib.FieldTheory.PurelyInseparable.AdjoinPthRoots Mathlib.FieldTheory.PurelyInseparable.Basic Mathlib.FieldTheory.PurelyInseparable.Exponent Mathlib.FieldTheory.PurelyInseparable.PerfectClosure Mathlib.FieldTheory.PurelyInseparable.Tower Mathlib.FieldTheory.Relrank Mathlib.FieldTheory.SeparableClosure Mathlib.FieldTheory.SeparableDegree Mathlib.FieldTheory.Separable Mathlib.FieldTheory.SeparablyGenerated Mathlib.FieldTheory.SplittingField.Construction Mathlib.FieldTheory.SplittingField.IsSplittingField Mathlib.GroupTheory.SpecificGroups.ZGroup Mathlib.LinearAlgebra.Eigenspace.Charpoly Mathlib.LinearAlgebra.Eigenspace.Pi Mathlib.LinearAlgebra.Eigenspace.Semisimple Mathlib.LinearAlgebra.Eigenspace.Triangularizable Mathlib.LinearAlgebra.JordanChevalley Mathlib.LinearAlgebra.Matrix.Charpoly.Disc Mathlib.LinearAlgebra.Matrix.Charpoly.Eigs Mathlib.LinearAlgebra.Matrix.Charpoly.FiniteField Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.FinTwo Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Projective Mathlib.LinearAlgebra.Projectivization.Action Mathlib.LinearAlgebra.Projectivization.PSL.PSL2 Mathlib.LinearAlgebra.Projectivization.PSL.Stabilizer Mathlib.LinearAlgebra.QuadraticForm.AlgClosed Mathlib.LinearAlgebra.Semisimple Mathlib.ModelTheory.Algebra.Field.IsAlgClosed Mathlib.ModelTheory.Algebra.Ring.Definability Mathlib.NumberTheory.FermatPsp Mathlib.NumberTheory.KummerDedekind Mathlib.NumberTheory.LegendreSymbol.Basic Mathlib.NumberTheory.LegendreSymbol.GaussEisensteinLemmas Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic Mathlib.NumberTheory.PowModTotient Mathlib.NumberTheory.RamificationInertia.Basic Mathlib.NumberTheory.RamificationInertia.Inertia Mathlib.NumberTheory.RamificationInertia.Unramified Mathlib.NumberTheory.SumFourSquares Mathlib.NumberTheory.SumTwoSquares Mathlib.NumberTheory.Wilson Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity Mathlib.RepresentationTheory.AlgebraRepresentation.Basic Mathlib.RepresentationTheory.Character Mathlib.RepresentationTheory.FDRep Mathlib.RepresentationTheory.FinGroupCharZero Mathlib.RepresentationTheory.Homological.GroupCohomology.FiniteCyclic Mathlib.RepresentationTheory.Homological.GroupCohomology.Functoriality Mathlib.RepresentationTheory.Homological.GroupCohomology.Hilbert90 Mathlib.RepresentationTheory.Homological.GroupCohomology.LongExactSequence Mathlib.RepresentationTheory.Homological.GroupCohomology.LowDegree Mathlib.RepresentationTheory.Homological.GroupHomology.FiniteCyclic Mathlib.RepresentationTheory.Homological.GroupHomology.Functoriality Mathlib.RepresentationTheory.Homological.GroupHomology.LongExactSequence Mathlib.RepresentationTheory.Homological.GroupHomology.LowDegree Mathlib.RepresentationTheory.Homological.TateCohomology.Basic Mathlib.RepresentationTheory.Invariants Mathlib.RepresentationTheory.Irreducible Mathlib.RepresentationTheory.Tannaka Mathlib.RingTheory.Adjoin.Polynomial.Bivariate Mathlib.RingTheory.AlgebraicIndependent.Adjoin Mathlib.RingTheory.AlgebraicIndependent.AlgebraicClosure Mathlib.RingTheory.AlgebraicIndependent.RankAndCardinality Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis Mathlib.RingTheory.DedekindDomain.Different Mathlib.RingTheory.DedekindDomain.Factorization Mathlib.RingTheory.DedekindDomain.Instances Mathlib.RingTheory.DedekindDomain.IntegralClosure Mathlib.RingTheory.DedekindDomain.LinearDisjoint Mathlib.RingTheory.Derivation.MapCoeffs Mathlib.RingTheory.Discriminant Mathlib.RingTheory.Etale.Descent Mathlib.RingTheory.Etale.Field Mathlib.RingTheory.Etale.Finite Mathlib.RingTheory.Etale.StandardEtale Mathlib.RingTheory.FractionalIdeal.Norm Mathlib.RingTheory.Frobenius Mathlib.RingTheory.Ideal.Int Mathlib.RingTheory.Ideal.Norm.AbsNorm Mathlib.RingTheory.Ideal.Quotient.HasFiniteQuotients.Basic Mathlib.RingTheory.Ideal.Quotient.HasFiniteQuotients.Norm Mathlib.RingTheory.Ideal.Quotient.HasFiniteQuotients Mathlib.RingTheory.IntegralClosure.GoingDown Mathlib.RingTheory.IntegralClosure.IntegralRestrict Mathlib.RingTheory.Invariant.Basic Mathlib.RingTheory.Invariant.Galois Mathlib.RingTheory.IsAdjoinRoot Mathlib.RingTheory.IsGaloisGroup.Basic Mathlib.RingTheory.LocalRing.Etale Mathlib.RingTheory.LocalRing.ResidueField.Instances Mathlib.RingTheory.Localization.AtPrime.Extension Mathlib.RingTheory.Localization.NormTrace Mathlib.RingTheory.MvPolynomial.Expand Mathlib.RingTheory.MvPowerSeries.Expand Mathlib.RingTheory.Nilpotent.GeometricallyReduced Mathlib.RingTheory.Norm.Basic Mathlib.RingTheory.Norm.Transitivity Mathlib.RingTheory.NormalClosure Mathlib.RingTheory.Nullstellensatz Mathlib.RingTheory.Polynomial.GaussLemma Mathlib.RingTheory.Polynomial.Resultant.Basic Mathlib.RingTheory.Polynomial.SeparableDegree Mathlib.RingTheory.Polynomial.UniversalFactorizationRing Mathlib.RingTheory.PowerSeries.Expand Mathlib.RingTheory.RamificationInertia.Inertia Mathlib.RingTheory.RamificationInertia.Ramification Mathlib.RingTheory.RingHom.Etale Mathlib.RingTheory.RingHom.LocallyStandardSmooth Mathlib.RingTheory.RingHom.PurelyInseparable Mathlib.RingTheory.RingHom.StandardSmooth Mathlib.RingTheory.RootsOfUnity.Lemmas Mathlib.RingTheory.RootsOfUnity.Minpoly Mathlib.RingTheory.SimpleModule.IsAlgClosed Mathlib.RingTheory.Smooth.Fiber Mathlib.RingTheory.Smooth.Field Mathlib.RingTheory.Spectrum.Prime.Homeomorph Mathlib.RingTheory.TotallySplit Mathlib.RingTheory.Trace.Basic Mathlib.RingTheory.Trace.Quotient Mathlib.RingTheory.Unramified.Dedekind Mathlib.RingTheory.Unramified.Field Mathlib.RingTheory.Unramified.LocalRing Mathlib.RingTheory.Valuation.FiniteField Mathlib.RingTheory.WittVector.Basic Mathlib.RingTheory.WittVector.Complete Mathlib.RingTheory.WittVector.Defs Mathlib.RingTheory.WittVector.DiscreteValuationRing Mathlib.RingTheory.WittVector.Domain Mathlib.RingTheory.WittVector.FrobeniusFractionField Mathlib.RingTheory.WittVector.Frobenius Mathlib.RingTheory.WittVector.Identities Mathlib.RingTheory.WittVector.InitTail Mathlib.RingTheory.WittVector.IsPoly Mathlib.RingTheory.WittVector.Isocrystal Mathlib.RingTheory.WittVector.MulCoeff Mathlib.RingTheory.WittVector.MulP Mathlib.RingTheory.WittVector.StructurePolynomial Mathlib.RingTheory.WittVector.TeichmullerSeries Mathlib.RingTheory.WittVector.Teichmuller Mathlib.RingTheory.WittVector.Truncated Mathlib.RingTheory.WittVector.Verschiebung Mathlib.RingTheory.ZMod.Torsion Mathlib.Topology.Algebra.Group.Matrix Mathlib.Topology.Algebra.IntermediateField Mathlib.Topology.Algebra.Ring.Compact Mathlib.Topology.Compactification.OnePoint.ProjectiveLine
1

Declarations diff (regex)

+ instance : Subsingleton (Subfield ℚ)
- instance : Subsingleton (Subfield ℚ) := subsingleton_of_top_le_bot fun x _ ↦

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)

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

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


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

Current commit fb22e93973
Reference commit b16b3be6f7

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

@leanprover-radar

leanprover-radar commented Aug 30, 2026 •

Copy link
Copy Markdown

Benchmark results for 8f110e9 against b16b3be are in. There are significant results. @xroblot

  • 🟥 main exited with code 1

No significant changes detected.

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Aug 30, 2026
@xroblot

xroblot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@leanprover-radar

leanprover-radar commented Aug 31, 2026 •

Copy link
Copy Markdown

Benchmark results for d7e8b9c against b16b3be are in. No significant results found. @xroblot

  • ✅ build//instructions: -2.9G (-0.00%)

No significant changes detected.

@xroblot xroblot changed the title chore: make Rat.castHom reducible chore: make Rat.castHom instance-reducible Aug 31, 2026
@xroblot

xroblot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@xroblot xroblot removed the WIP Work in progress label Aug 31, 2026
@leanprover-radar

leanprover-radar commented Aug 31, 2026 •

Copy link
Copy Markdown

Benchmark results for aef146a against b16b3be are in. No significant results found. @xroblot

  • 🟥 build//instructions: +9.6G (+0.01%)

Small changes (1🟥)

  • 🟥 build/module/Mathlib.Algebra.QuadraticAlgebra.Basic//instructions: +654.8M (+1.69%)

Comment thread Mathlib/FieldTheory/PrimeField.lean Resolved
@sgouezel

Copy link
Copy Markdown
Contributor

You should use implicit_reducible, not instance_reducible.

Comment thread Mathlib/FieldTheory/PrimeField.lean Resolved
@xroblot

xroblot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

You should use implicit_reducible, not instance_reducible.

I changed that but you have to admit that all these options are a bit confusing 😅

@xroblot

xroblot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@leanprover-radar

leanprover-radar commented Aug 31, 2026 •

Copy link
Copy Markdown

Benchmark results for fb22e93 against b16b3be are in. No significant results found. @xroblot

  • 🟥 build//instructions: +85.0G (+0.06%)

Small changes (3🟥)

  • 🟥 build/module/Mathlib.Algebra.QuadraticAlgebra.Basic//instructions: +702.9M (+1.81%)
  • 🟥 build/module/Mathlib.NumberTheory.NumberField.FinitePlaces//instructions: +80.8M (+1.77%)
  • 🟥 build/module/Mathlib.RingTheory.WittVector.TeichmullerSeries//instructions: +259.0M (+2.43%)

@xroblot xroblot changed the title chore: make Rat.castHom instance-reducible chore: make Rat.castHom implicit_reducible Aug 31, 2026
@xroblot
xroblot marked this pull request as ready for review August 31, 2026 12:04
@sgouezel

sgouezel commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

bors r+
Thanks!

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 2, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 2, 2026
Mark `Rat.castHom` as `@[implicit_reducible]`. The `Algebra ℚ` structure coming from `DivisionRing.toRatAlgebra` should now agree at instance transparency, and not only at default transparency, with the algebra structure a type already carries. Two examples record this, for an intermediate field of a field of characteristic zero and for `QuadraticAlgebra ℚ a b`. (The second one also needs the structure map of `QuadraticAlgebra.instAlgebra` to be given by the constructor rather than through `QuadraticAlgebra.C`, which is done here as well.)

One proof needed repair, in `Mathlib/FieldTheory/PrimeField.lean`. The benchmark reports no significant change.

Prepared with Claude Code 🤖

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 2, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title chore: make Rat.castHom implicit_reducible [Merged by Bors] - chore: make Rat.castHom implicit_reducible Sep 2, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 2, 2026
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Sep 5, 2026
Mark `Rat.castHom` as `@[implicit_reducible]`. The `Algebra ℚ` structure coming from `DivisionRing.toRatAlgebra` should now agree at instance transparency, and not only at default transparency, with the algebra structure a type already carries. Two examples record this, for an intermediate field of a field of characteristic zero and for `QuadraticAlgebra ℚ a b`. (The second one also needs the structure map of `QuadraticAlgebra.instAlgebra` to be given by the constructor rather than through `QuadraticAlgebra.C`, which is done here as well.)

One proof needed repair, in `Mathlib/FieldTheory/PrimeField.lean`. The benchmark reports no significant change.

Prepared with Claude Code 🤖

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants