fix(Analysis/Matrix): anchor the elementwise matrix norm's topology to instTopologicalSpaceMatrix#41991
Conversation
…o instTopologicalSpaceMatrix With open scoped Matrix.Norms.Elementwise, Norm (Matrix m n R →L[R] Matrix m n R) failed to synthesize even though the norm-induced topology is definitionally equal to instTopologicalSpaceMatrix: continuous-linear-map types elaborate with the direct Matrix topology instance, while ContinuousLinearMap.hasOpNorm's conclusion carries topologies projected from its SeminormedAddCommGroup arguments, and the projection through fast_instance% Pi.seminormedAddCommGroup does not reduce to the same term. Anchor the topology field of Matrix.seminormedAddCommGroup and Matrix.normedAddCommGroup to instTopologicalSpaceMatrix via PseudoMetricSpace.replaceTopology / MetricSpace.replaceTopology with rfl proofs (forgetful-inheritance pattern; the Frobenius family already achieves this through PiLp.seminormedAddCommGroupToPi). norm, dist, and the uniformity are unchanged. Add regression tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 6441797742Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
With
open scoped Matrix.Norms.Elementwise,fails to synthesize, even though the norm-induced topology on
Matrix m n ℝis definitionally equal to the ambientinstTopologicalSpaceMatrix(rflproves the equality).What goes wrong: the
→L[ℝ]type is elaborated with the direct instanceinstTopologicalSpaceMatrix, whileContinuousLinearMap.hasOpNorm's conclusion carries topologies that are projections of itsSeminormedAddCommGrouparguments. During resolution, pending synthesis does findMatrix.seminormedAddCommGroup, but the projected topology then has to unify withinstTopologicalSpaceMatrix, and the projection chain throughfast_instance% Pi.seminormedAddCommGroupdoes not reduce to the same term. (Types likeℝorEuclideanSpacedon't hit this because they have no directTopologicalSpaceinstance competing with the projection path — matrices do.)Fix: anchor the topology field of
Matrix.seminormedAddCommGroup/Matrix.normedAddCommGrouptoinstTopologicalSpaceMatrixviaPseudoMetricSpace.replaceTopology/MetricSpace.replaceTopologywithrflproofs — the standard forgetful-inheritance pattern; the Frobenius family in the same file already achieves this throughPiLp.seminormedAddCommGroupToPi. Anchoring to a freshly-elaboratedinferInstanceAs <| TopologicalSpace (m → n → α)is not sufficient — the anchor must be the same instance term that appears in elaborated goal types, which is why this also addspublic import Mathlib.Topology.Instances.Matrix(no cycle; that file only importsLinearAlgebra.Matrix.*andTopology.Algebra.*).norm,dist, and the uniformity are untouched — only the packaging of the topology field changes, in the direction of the canonical instance. The fix works at Lean's defaultmaxSynthPendingDepth. It also unblocks smul-continuity resolution in Fréchet-derivative developments over matrix codomains (HasFDerivAt.const_smulsites), where the goal's topology argument is the same non-reducing projection.Motivation: hit in a downstream project (~4300 build jobs of matrix-valued Fréchet calculus) where ten files currently need local high-priority compat instances to work around this. A downstream repair cannot be shipped safely: boosting a repaired
SeminormedAddCommGroup's priority steals‖·‖resolution from files mixing norm scopes (e.g.Matrix.Norms.L2Operatorsections of a Davis–Kahan development silently re-resolve to the elementwise norm). The fix has to live in the instance definitions.Validation: full
lake build Mathlibpasses with the change (8666 jobs), plus new regression tests inMathlibTest/MatrixNormTopology.lean(bothrflagreements, theNormsynthesis above,‖f‖usage,ContinuousConstSMulunification).Open questions for reviewers:
linftyOp*family get the same anchor for uniformity of design?letI I := fast_instance% …; { I with … }the preferred spelling here?Topology.Instances.Matrix?Disclosure: this PR was prepared with AI assistance (Claude); the diagnosis and fix were validated by the full mathlib build and the included regression tests.
🤖 Generated with Claude Code