Skip to content

[Merged by Bors] - chore(Geometry/Manifold): avoid some underscore soup - #42205

Closed
grunweg wants to merge 3 commits into
leanprover-community:masterfrom
grunweg:diffgeo-underscoresoup
Closed

[Merged by Bors] - chore(Geometry/Manifold): avoid some underscore soup#42205
grunweg wants to merge 3 commits into
leanprover-community:masterfrom
grunweg:diffgeo-underscoresoup

Conversation

@grunweg

@grunweg grunweg commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Open in Gitpod

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

PR summary ddb9a51c5e

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

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)

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

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit ddb9a51c5e
Reference commit 0ce898f5af

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

@grunweg grunweg added the t-differential-geometry Manifolds etc label Jul 28, 2026
haveI := h.singletonChartedSpace; ContMDiff I I n e := by
have := h.isManifold_singleton (I := I) (n := ω)
rw [@contMDiff_iff _ _ _ _ _ _ _ _ _ _ h.singletonChartedSpace]
rw [@contMDiff_iff]

@grunweg grunweg Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The underscores/specifying the instance is no longer required (but removing the @ would break the proof).

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 thought that rw [x] and rw [@x] are equivalent if x is a theorem. Are you sure of this?

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.

yes i also tested this

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.

Aha, very interesting! It turn out that the rewrite does work successfully, but it unnecessarily logs an error message.

I wrote a little tactic combinator that erases logged messages, and using this, we see that the rewrite did work:

import Mathlib

open Topology ContDiff

variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
  {E : Type*}
  [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H]
  {I : ModelWithCorners 𝕜 E H} {M : Type*} [TopologicalSpace M]
  
variable {e : M → H} (h : IsOpenEmbedding e) {n : ℕ∞ω}

elab "withoutErrors" tac:tactic : tactic => do
  Lean.Elab.Tactic.evalTactic tac
  modifyThe Lean.Core.State fun s => { s with messages := {} }

lemma contMDiff_isOpenEmbedding' [Nonempty M] :
    haveI := h.singletonChartedSpace; ContMDiff I I n e := by
  have := h.isManifold_singleton (I := I) (n := ω)
  withoutErrors rw [contMDiff_iff] -- succeeds!
  sorry

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.

This is a bug in the elaboration part of rw. It is trying to syntesize an instance that it doesn't need to synthesize anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, the current code is correct - and rw throwing an error is a bug in rw (i.e., out of scope for this PR)?

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.

Indeed.

Maybe calling it a bug is phrased too strongly, but I think it would be better if this worked without the @. I've tried to fix this in leanprover/lean4#14593

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

💡 Thanks for clarifying.

Comment thread Mathlib/Geometry/Manifold/IsManifold/Basic.lean Outdated
Comment thread Mathlib/Geometry/Manifold/ContMDiff/Basic.lean Outdated
Comment thread Mathlib/Geometry/Manifold/ContMDiff/Basic.lean Outdated
mathlib-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
Inspired by #42205.

I searched for ` _ _ _]` in vscode and manually went through all ~25 and see if they could be removed (and in some cases some minor style improvement). For ` _ _]` it is already over 100, so that work ought to be automatised

Co-authored-by: Batixx <s59fpern@uni-bonn.de>
@JovanGerb

Copy link
Copy Markdown
Contributor

Thanks, this PR looks good to me

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by JovanGerb.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jul 29, 2026

@ocfnash ocfnash left a comment

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.

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Aug 10, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Aug 10, 2026
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Aug 10, 2026
@mathlib-bors

mathlib-bors Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title chore(Geometry/Manifold): avoid some underscore soup [Merged by Bors] - chore(Geometry/Manifold): avoid some underscore soup Aug 10, 2026
@mathlib-bors mathlib-bors Bot closed this Aug 10, 2026
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-differential-geometry Manifolds etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants