Skip to content

feat: improve doc-strings for differential geometry elaborators#39677

Open
grunweg wants to merge 22 commits into
leanprover-community:masterfrom
grunweg:mvfderiv-better-docs
Open

feat: improve doc-strings for differential geometry elaborators#39677
grunweg wants to merge 22 commits into
leanprover-community:masterfrom
grunweg:mvfderiv-better-docs

Conversation

@grunweg

@grunweg grunweg commented May 21, 2026

Copy link
Copy Markdown
Contributor

Right now, the custom elaborators in the manifold library have doc-strings which explain what the elaborator
expands to --- but don't show what the expanded concept means. It would be much better to show that also.
Verso allows doing so easily: this PR implements this as a proof of concept for the elaborator for mvfderiv.

This is not ready to land yet:

  • making importing doc-string across files work requires lean4#14120 (merged in mid-June)
  • the verso command should move to a better place

  • in the medium-term, there will be a Lean core command for this!

  • Right now, the concatenated doc-string is formatted as pure text (not markdown): Lean core will implement this soon, but has not done so yet.

  • this technique should be applied to all the custom elaborators

  • the doc-strings of the elaborators may need to be rewritten, to start with the subject they're defining. (Once this happens, just concatenating the doc-strings produces reasonable results. This PR does this for mvfderiv only.)

Made with in-person help of David Thrane Christiansen at the MI retreat. Thanks a lot!


Actually, leanprover/lean4#14115 implements the same functionality properly.

Open in Gitpod

@grunweg grunweg added WIP Work in progress t-meta Tactics, attributes or user commands t-differential-geometry Manifolds etc blocked-by-core-release Not relevant for the current Lean release candidate, but will be needed for the next. labels May 21, 2026
@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

PR summary b9e65c5893

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Geometry.Manifold.Notation 2172 2173 +1 (+0.05%)
Mathlib.Geometry.Manifold.MFDeriv.NormedSpace 2185 2186 +1 (+0.05%)
Import changes for all files
Files Import difference
113 files Mathlib.Analysis.Calculus.Rademacher Mathlib.Analysis.Complex.UpperHalfPlane.Manifold Mathlib.Analysis.Complex.UpperHalfPlane.Measure Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff Mathlib.Analysis.Distribution.FourierMultiplier Mathlib.Analysis.Distribution.SchwartzSpace.Basic Mathlib.Analysis.Distribution.SchwartzSpace.Deriv Mathlib.Analysis.Distribution.SchwartzSpace.Fourier Mathlib.Analysis.Distribution.SchwartzSpace Mathlib.Analysis.Distribution.Sobolev Mathlib.Analysis.Distribution.Support Mathlib.Analysis.Distribution.TemperedDistribution Mathlib.Analysis.Fourier.Convolution Mathlib.Analysis.Fourier.LpSpace Mathlib.Analysis.Fourier.PoissonSummation Mathlib.Analysis.Normed.Lp.SmoothApprox Mathlib.Analysis.SpecialFunctions.Gaussian.PoissonSummation Mathlib.Geometry.Manifold.Algebra.LeftInvariantDerivation Mathlib.Geometry.Manifold.Algebra.LieGroup Mathlib.Geometry.Manifold.Algebra.Monoid Mathlib.Geometry.Manifold.Algebra.SMul Mathlib.Geometry.Manifold.Algebra.SmoothFunctions Mathlib.Geometry.Manifold.Algebra.Structures Mathlib.Geometry.Manifold.Bordism Mathlib.Geometry.Manifold.BumpFunction Mathlib.Geometry.Manifold.Complex Mathlib.Geometry.Manifold.ContMDiffMFDeriv Mathlib.Geometry.Manifold.ContMDiffMap Mathlib.Geometry.Manifold.DerivationBundle Mathlib.Geometry.Manifold.Diffeomorph Mathlib.Geometry.Manifold.GroupLieAlgebra Mathlib.Geometry.Manifold.Immersion Mathlib.Geometry.Manifold.Instances.Icc Mathlib.Geometry.Manifold.Instances.Real Mathlib.Geometry.Manifold.Instances.Sphere Mathlib.Geometry.Manifold.Instances.UnitsOfNormedAlgebra Mathlib.Geometry.Manifold.IntegralCurve.Basic Mathlib.Geometry.Manifold.IntegralCurve.ExistUnique Mathlib.Geometry.Manifold.IntegralCurve.Transform Mathlib.Geometry.Manifold.IntegralCurve.UniformTime Mathlib.Geometry.Manifold.IsManifold.InteriorBoundary Mathlib.Geometry.Manifold.LocalDiffeomorph Mathlib.Geometry.Manifold.MFDeriv.Atlas Mathlib.Geometry.Manifold.MFDeriv.Basic Mathlib.Geometry.Manifold.MFDeriv.FDeriv Mathlib.Geometry.Manifold.MFDeriv.NormedSpace Mathlib.Geometry.Manifold.MFDeriv.SpecificFunctions Mathlib.Geometry.Manifold.MFDeriv.Tangent Mathlib.Geometry.Manifold.MFDeriv.UniqueDifferential Mathlib.Geometry.Manifold.Notation Mathlib.Geometry.Manifold.PartitionOfUnity Mathlib.Geometry.Manifold.PoincareConjecture Mathlib.Geometry.Manifold.Riemannian.Basic Mathlib.Geometry.Manifold.Riemannian.PathELength Mathlib.Geometry.Manifold.Sheaf.LocallyRingedSpace Mathlib.Geometry.Manifold.Sheaf.Smooth Mathlib.Geometry.Manifold.SmoothApprox Mathlib.Geometry.Manifold.SmoothEmbedding Mathlib.Geometry.Manifold.VectorBundle.ContMDiffSection Mathlib.Geometry.Manifold.VectorBundle.CovariantDerivative.Basic Mathlib.Geometry.Manifold.VectorBundle.CovariantDerivative.Metric Mathlib.Geometry.Manifold.VectorBundle.CovariantDerivative.Torsion Mathlib.Geometry.Manifold.VectorBundle.Hom Mathlib.Geometry.Manifold.VectorBundle.LocalFrame Mathlib.Geometry.Manifold.VectorBundle.MDifferentiable Mathlib.Geometry.Manifold.VectorBundle.Pullback Mathlib.Geometry.Manifold.VectorBundle.Riemannian Mathlib.Geometry.Manifold.VectorBundle.SmoothSection Mathlib.Geometry.Manifold.VectorBundle.Tangent Mathlib.Geometry.Manifold.VectorBundle.Tensoriality Mathlib.Geometry.Manifold.VectorField.LieBracket Mathlib.Geometry.Manifold.VectorField.Pullback Mathlib.Geometry.Manifold.WhitneyEmbedding Mathlib.NumberTheory.EulerProduct.DirichletLSeries Mathlib.NumberTheory.Harmonic.ZetaAsymp Mathlib.NumberTheory.LSeries.DirichletContinuation Mathlib.NumberTheory.LSeries.Dirichlet Mathlib.NumberTheory.LSeries.HurwitzZetaEven Mathlib.NumberTheory.LSeries.HurwitzZetaOdd Mathlib.NumberTheory.LSeries.HurwitzZetaValues Mathlib.NumberTheory.LSeries.HurwitzZeta Mathlib.NumberTheory.LSeries.Nonvanishing Mathlib.NumberTheory.LSeries.PrimesInAP Mathlib.NumberTheory.LSeries.RiemannZeta Mathlib.NumberTheory.LSeries.ZMod Mathlib.NumberTheory.LSeries.ZetaZeros Mathlib.NumberTheory.ModularForms.Basic Mathlib.NumberTheory.ModularForms.Bounds Mathlib.NumberTheory.ModularForms.CuspFormSubmodule Mathlib.NumberTheory.ModularForms.DedekindEta Mathlib.NumberTheory.ModularForms.Delta Mathlib.NumberTheory.ModularForms.Derivative Mathlib.NumberTheory.ModularForms.DimensionFormulas.LevelOne Mathlib.NumberTheory.ModularForms.Discriminant Mathlib.NumberTheory.ModularForms.EisensteinSeries.Basic Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.Defs Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.MDifferentiable Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.Summable Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.Transform Mathlib.NumberTheory.ModularForms.EisensteinSeries.MDifferentiable Mathlib.NumberTheory.ModularForms.EisensteinSeries.QExpansion Mathlib.NumberTheory.ModularForms.JacobiTheta.Bounds Mathlib.NumberTheory.ModularForms.JacobiTheta.Manifold Mathlib.NumberTheory.ModularForms.JacobiTheta.OneVariable Mathlib.NumberTheory.ModularForms.JacobiTheta.TwoVariable Mathlib.NumberTheory.ModularForms.LevelOne.Basic Mathlib.NumberTheory.ModularForms.LevelOne.DimensionFormula Mathlib.NumberTheory.ModularForms.LevelOne.GradedRing Mathlib.NumberTheory.ModularForms.LevelOne Mathlib.NumberTheory.ModularForms.NormTrace Mathlib.NumberTheory.ModularForms.Petersson Mathlib.NumberTheory.ModularForms.QExpansion Mathlib.Topology.Compactification.OnePoint.Sphere
1

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

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

Computed after the build finishes.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit b9e65c5893
Reference commit f8fd74f95c

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

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 23, 2026
@grunweg
grunweg force-pushed the mvfderiv-better-docs branch from c3f2e7b to 1dc1269 Compare May 26, 2026 22:11
@grunweg
grunweg force-pushed the mvfderiv-better-docs branch from f4a3421 to a66beb4 Compare May 30, 2026 10:17
@github-actions github-actions Bot added large-import Automatically added label for PRs with a significant increase in transitive imports file-removed A Lean module was (re)moved without a `deprecated_module` annotation and removed large-import Automatically added label for PRs with a significant increase in transitive imports file-removed A Lean module was (re)moved without a `deprecated_module` annotation labels May 30, 2026
@grunweg grunweg removed the blocked-by-core-release Not relevant for the current Lean release candidate, but will be needed for the next. label May 30, 2026
@grunweg

grunweg commented May 30, 2026

Copy link
Copy Markdown
Contributor Author

Good news: with the recent core bump, the verso command works (within vscode, in the same file now) 🎉
Bad news: I get a bizarre error about vs code building a file fine, while lake build file not working.

@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 31, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 31, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jun 22, 2026
#39729)

such as, by them beginning with the object they are defining as a subject.
This will yield much better doc-strings for the differential geometry elaborators in #39677.

It also increases conformance with the [documentation style guide](https://github.com/leanprover/lean4/blob/master/doc/style.md).

Inspired by the MI retreat in Lisbon.
grunweg added 8 commits June 22, 2026 14:36
Remove the IsManifold hypotheses, for two reasons:
- They were superfluous; the elaborators do not require such hypotheses at all.
- They would silently change behaviour with the next commit,
  as then the fromAssumption strategy would take over.
If we have an explicit IsManifold hypothesis in the local context,
we almost definitely want to use it.

I really wonder why we did not add this code before. Perhaps it was not necessary?
It was re-declaring a variable M, while N would suffice.
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 22, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

@grunweg grunweg added the blocked-by-core-release Not relevant for the current Lean release candidate, but will be needed for the next. label Jun 22, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 25, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@grunweg grunweg removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-core-release Not relevant for the current Lean release candidate, but will be needed for the next. t-differential-geometry Manifolds etc t-meta Tactics, attributes or user commands WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant