← Back to Pull requests

feat(Geometry/Manifold/ContMDiffTransitions): local homeomorphisms with smooth transitions are smooth #46915

Open
pepamontero opened this pull request with 62 lines diff across 1 files
View on GitHub
pepamontero pepamontero commented on Dec 03, 2026 16:34 UTC
Author

Following up to #46414, for a local homeomorphism f : M → M' with right inverse g, and the charts on M' pushed forward from M, we prove:

IsLocalHomeomorph.contMDiffAt_of_rightInverse: f is C^n at every point g y.
IsLocalHomeomorph.contMDiff_of_rightInverse: if ContMDiffTransitions I n f holds, then f is C^n.
IsLocalHomeomorph.contMDiff: the same for a surjective f.

---
<!-- Your PR title will become the first line of the commit message.

In this box, the text above the --- (if not empty) will be appended
to the commit message, and can be used to give additional context or
details. Please leave a blank newline before the ---, otherwise GitHub
will format the text above it as a title.

For details on the "pull request lifecycle" in mathlib, please see:
https://leanprover-community.github.io/contribute/index.html

In particular, note that most reviewers will only notice your PR
if it passes the continuous integration checks.
Please ask for help on https://leanprover.zulipchat.com if needed.

When merging, all the commits will be squashed into a single commit
listing all co-authors.

Co-authors in the squash commit are gathered from two sources:

First, all authors of commits to this PR branch are included. Thus,
one way to add co-authors is to include at least one commit authored by
each co-author among the commits in the pull request. If necessary, you
may create empty commits to indicate co-authorship, using commands like so:

git commit --author="Author Name <author@email.com>" --allow-empty -m "add Author Name as coauthor"

Second, co-authors can also be listed in lines at the very bottom of
the commit message (that is, directly before the ---) using the following format:

Co-authored-by: Author Name <author@email.com>

If you are moving or deleting declarations, please include these lines
at the bottom of the commit message (before the ---, and also before
any "Co-authored-by" lines) using the following format:

Moves:

  • Vector. -> List.Vector.*

  • ...
  • Deletions:

  • Nat.bit1_add_bit1

  • ...
  • Any other comments you want to keep out of the PR commit should go
    below the ---, and placed outside this HTML comment, or else they
    will be invisible to reviewers.

    If this PR depends on other PRs, please list them below this comment,
    using the following format:

  • depends on: #abc [optional extra text]

  • depends on: #xyz [optional extra text]
  • -->

    Diff: 62 lines (+57 / -5) across 1 files Reviewer: grunweg Review duration: 1895m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.28) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.28 · 62 lines diff across 1 files
    0.28
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.248
    Real PR Conversation Timeline
    7 items
    github-actions[bot] github-actions[bot] commented on Dec 03, 2026 16:35 UTC
    Bot

    PR summary 55732fa514

    Import changes for modified files

    No significant changes to the import graph

    <details><summary>Import changes for all files</summary>

    |Files|Import difference|
    |-|-|

    </details>

    ---

    <details><summary>

    Declarations diff (regex)

    </summary>

    + contMDiff
    + contMDiffAt_of_rightInverse
    + contMDiff_of_rightInverse
    <details>
    <summary>You can run this locally as follows</summary>

    ## 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>
    

    </details>

    The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

    </details>

    <!-- DECLS_DIFF_LEAN_BEGIN -->

    Declarations diff (Lean)

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

    +3 new declarations
    −0 removed declarations

    +IsLocalHomeomorph.contMDiff
    +IsLocalHomeomorph.contMDiffAt_of_rightInverse
    +IsLocalHomeomorph.contMDiff_of_rightInverse
    

    <!-- DECLS_DIFF_LEAN_END -->

    ---

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

    Current commit 55732fa514
    Reference commit 8b31bd71d0

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

    grunweg grunweg commented on code on Dec 03, 2026 23:26 UTC
    Code Review
    Mathlib/Geometry/Manifold/ContMDiffTransitions.lean:1
    @@ -125,6 +129,54 @@ theorem isManifold [IsManifold I n M]
         IsManifold I n M' :=
       hf.isManifold_of_rightInverse _ h
     
    +/-! ### Smoothness of `f` -/
    +
    +/-- If `f : M → M'` is a local homeomorphism with right inverse `g`, then `f` is `C^n` at `g y`
    +for the charts `hf.chartedSpaceOfRightInverse hg` pushed forward from `M`. -/
    +lemma contMDiffAt_of_rightInverse
    +    (hf : IsLocalHomeomorph f) (hg : Function.RightInverse g f) (y : M') :
    +    letI : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +    CMDiffAt n f (g y) := by
    +  let : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +  suffices CMDiffAt n (hf.localInverseAt (g y)).symm (g y) by rwa [hf.localInverseAt_symm] at this
    +  rw [contMDiffAt_iff]
    +  refine ⟨OpenPartialHomeomorph.continuousAt _ (by simp), ?_⟩
    +  -- The chart of `M'` at `y` is `hf.localInverseAt (g y)` followed by the chart of `M` at `g y`.
    +  -- So in the charts at `g y` and `y`, the map `(hf.localInverseAt (g y)).symm` is the identity
    +  -- on the target of `extChartAt I y`.
    +  rw [show (hf.localInverseAt (g y)).symm (g y) = y by simpa using hg y]

    This term is far too clever: for instance, rw with show is already a code smell; this can indicate a missing lemma. In this case, the proof is also not fully trivial, so this should be factored out.

    grunweg grunweg commented on code on Dec 03, 2026 23:26 UTC
    Code Review
    Mathlib/Geometry/Manifold/ContMDiffTransitions.lean:1
    @@ -125,6 +129,54 @@ theorem isManifold [IsManifold I n M]
         IsManifold I n M' :=
       hf.isManifold_of_rightInverse _ h
     
    +/-! ### Smoothness of `f` -/
    +
    +/-- If `f : M → M'` is a local homeomorphism with right inverse `g`, then `f` is `C^n` at `g y`
    +for the charts `hf.chartedSpaceOfRightInverse hg` pushed forward from `M`. -/
    +lemma contMDiffAt_of_rightInverse
    +    (hf : IsLocalHomeomorph f) (hg : Function.RightInverse g f) (y : M') :
    +    letI : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +    CMDiffAt n f (g y) := by
    +  let : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +  suffices CMDiffAt n (hf.localInverseAt (g y)).symm (g y) by rwa [hf.localInverseAt_symm] at this
    +  rw [contMDiffAt_iff]
    +  refine ⟨OpenPartialHomeomorph.continuousAt _ (by simp), ?_⟩
    +  -- The chart of `M'` at `y` is `hf.localInverseAt (g y)` followed by the chart of `M` at `g y`.
    +  -- So in the charts at `g y` and `y`, the map `(hf.localInverseAt (g y)).symm` is the identity
    +  -- on the target of `extChartAt I y`.
    +  rw [show (hf.localInverseAt (g y)).symm (g y) = y by simpa using hg y]
    +  refine contDiffWithinAt_id.congr_of_eventuallyEq_of_mem ?_ (Set.mem_range_self _)
    +  have hgy : extChartAt I (g y) (g y) ∈ (extChartAt I y).target := by
    +    have := mem_extChartAt_target (I := I) y
    +    change extChartAt I (g y) (hf.localInverseAt (g y) y) ∈ _ at this

    Change is also a code smell, and might indicate some missing API.

    grunweg grunweg commented on code on Dec 03, 2026 23:27 UTC
    Code Review
    Mathlib/Geometry/Manifold/ContMDiffTransitions.lean:1
    @@ -125,6 +129,54 @@ theorem isManifold [IsManifold I n M]
         IsManifold I n M' :=
       hf.isManifold_of_rightInverse _ h
     
    +/-! ### Smoothness of `f` -/
    +
    +/-- If `f : M → M'` is a local homeomorphism with right inverse `g`, then `f` is `C^n` at `g y`
    +for the charts `hf.chartedSpaceOfRightInverse hg` pushed forward from `M`. -/
    +lemma contMDiffAt_of_rightInverse
    +    (hf : IsLocalHomeomorph f) (hg : Function.RightInverse g f) (y : M') :
    +    letI : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +    CMDiffAt n f (g y) := by
    +  let : ChartedSpace H M' := hf.chartedSpaceOfRightInverse hg
    +  suffices CMDiffAt n (hf.localInverseAt (g y)).symm (g y) by rwa [hf.localInverseAt_symm] at this
    +  rw [contMDiffAt_iff]
    +  refine ⟨OpenPartialHomeomorph.continuousAt _ (by simp), ?_⟩
    +  -- The chart of `M'` at `y` is `hf.localInverseAt (g y)` followed by the chart of `M` at `g y`.

    For instance, I wonder if there is a missing lemma or two about hf.localInverseAt.

    grunweg grunweg commented on Dec 03, 2026 23:28 UTC
    Reviewer

    I'm excited to see this. I took a quick look at the code and believe I can be cleaned up quite a bit. Some pointers below. (If you say you'd like more help, I'm happy to look more closely: but I believe you already make progress with this.)

    pepamontero pepamontero commented on Dec 04, 2026 10:58 UTC
    Author

    Thank you @grunweg !! I'm very excited that quotient manifolds is finally in Mathlib as well!! I will work on polishing this :)

    Reviewers
    Assignees
    pepamontero pepamontero
    Labels
    risk: low confidence: 89.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 27.8% (LOW) · Higher = larger blast radius
    27.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.8% · Lower = rushed or shallow review
    89.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 2.8% · Safe to merge
    2.8%