Skip to content

[Merged by Bors] - feat: further extensions of the differential geometry elaborators#30413

Closed
grunweg wants to merge 30 commits intoleanprover-community:masterfrom
grunweg:diffgeo-custom-elaborators-more
Closed

[Merged by Bors] - feat: further extensions of the differential geometry elaborators#30413
grunweg wants to merge 30 commits intoleanprover-community:masterfrom
grunweg:diffgeo-custom-elaborators-more

Conversation

@grunweg
Copy link
Copy Markdown
Contributor

@grunweg grunweg commented Oct 10, 2025

Also infer the model with corners on

  • a space of continuous linear equivalences
  • a closed real interval (Set.Icc)
  • the complex upper half plane

And add elaborators for HasMFDeriv(Within)At analogous to the mfderiv(Within) ones.

Further cases, as well as products, disjoint unions or open subsets, will be covered in future PRs.


Open in Gitpod

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 10, 2025

PR summary 50c7f343a1

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ RealCopy
+ RealCopy'
+ id'
+ instance : ChartedSpace (EuclideanHalfSpace 1) ↑(Set.Icc x y)
+ instance : NontriviallyNormedField RealCopy := inferInstanceAs (NontriviallyNormedField ℝ)
+ instance : NormedField RealCopy := inferInstanceAs (NormedField ℝ)
+ instance : Preorder RealCopy' := inferInstanceAs (Preorder ℝ)
+ instance : TopologicalSpace RealCopy' := inferInstanceAs (TopologicalSpace ℝ)

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/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 force-pushed the diffgeo-custom-elaborators-more branch from e667c0b to f803f97 Compare October 10, 2025 17:17
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 10, 2025
@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

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

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 16, 2025
@mathlib4-dependent-issues-bot
Copy link
Copy Markdown
Collaborator

@grunweg grunweg force-pushed the diffgeo-custom-elaborators-more branch from 079afd9 to 2c86a5a Compare October 16, 2025 09:50
@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 Oct 16, 2025
@grunweg grunweg force-pushed the diffgeo-custom-elaborators-more branch from 2c86a5a to 4f360bd Compare October 16, 2025 09:52
Copy link
Copy Markdown
Contributor

@thorimur thorimur left a comment

Choose a reason for hiding this comment

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

A first pass (hopefully most of the way there!); I've got to step away from my machine for a bit, but wanted to make these visible. :)

fromCLM : TermElabM Expr := do
match_expr e with
| ContinuousLinearMap k S _ _ _σ _E _ _ _F _ _ _ _ =>
if ← isDefEq k S then
Copy link
Copy Markdown
Contributor

@thorimur thorimur Oct 16, 2025

Choose a reason for hiding this comment

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

Hmm, I want to be sure that isDefEq at this transparency doesn't make any necessary instance synthesis break. Can you please write a test for this and for the one in fromRealInterval where isDefEq nontrivially succeeds (but withReducible <| isDefEq wouldn't)? E.g., wrapping in a def, such as using def RealCopy := Real for α in the fromRealInterval test.

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.

Good point, thanks! I'll add such a test (but possibly only after your second review pass).

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.

Great! Also, if isDefEq turns out to be fine, we should document that we know it's fine near its invocation in a short comment. :)

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.

I added a test for the fromRealInterval case --- I needed to re-add the TopologicalSpace, Preorder and ChartedSpace instances manually (as these work for Real, but not RealCopy) - then the elaborator worked fine. I'm not sure if that's the desired behaviour; what do you think?

Copy link
Copy Markdown
Contributor Author

@grunweg grunweg Oct 18, 2025

Choose a reason for hiding this comment

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

I also pushed a test for the continuousLinearMap case; this already breaks earlier (at the synthesis of a NormedSpace instance for the space of maps. 🤔
(Edit: I pushed a modification; my first attempt failed at a really basic level. I don't understand any more why the instances fail now.)

Copy link
Copy Markdown
Contributor

@thorimur thorimur Oct 22, 2025

Choose a reason for hiding this comment

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

I added a test for the fromRealInterval case --- I needed to re-add the TopologicalSpace, Preorder and ChartedSpace instances manually (as these work for Real, but not RealCopy) - then the elaborator worked fine. I'm not sure if that's the desired behaviour; what do you think?

Hmmm, I'm not sure. Suppose there's a type WeirdReal that's defined as Real, but with a totally different topology/preorder/etc.--is modelWithCornersEuclideanHalfSpace still the right model with corners for a closed interval on it? My thought is "no": the type of modelWithCornersEuclideanHalfSpace refers to the topology on Real, not WeirdReal.

But I'm still familiarizing myself with how exactly ModelWithCorners work on a formal level, so I could be wrong. Do you feel confident one way or the other about whether it would be the correct model with corners in this case?

Copy link
Copy Markdown
Contributor Author

@grunweg grunweg Oct 23, 2025

Choose a reason for hiding this comment

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

Thanks; that's the right question to ask!
The answers is indeed no. (Consider for example WeirdReal, the real numbers endowed with the indiscrete topology. Everything is still a normed space over WeirdReal (as that doesn't use the topology on R), but modelWithCornersEuclideanHalfSpace is not a model with corners any more, as continuous_toFun fails: the only continuous functions from the indiscrete topology are the constant ones.

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.

I'm not sure what this means, though: when the base field is the real numbers, I would expect it to really be the real numbers (not "the real numbers with a weird topology"), so inferring the same model makes sense.

I have added a comment in those locations.

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.

After more thinking and talking to Floris, it's become clear that the defeq check should be changed to withReducible (not semi-reducible transparency). Using a type synonym to put a different topology/algebraic structure (or, in this case, smooth structure) on a type is a standard mathlib pattern. Seeing through that would be counter-productive. Indeed, apparently there was a past exercise defining a different smooth structure on the interval, and we want to allow this. I'll change the check, again.

Thanks a lot for asking the right question here!

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.

Changed the check and updated the tests to clearly test this.

@grunweg grunweg force-pushed the diffgeo-custom-elaborators-more branch 2 times, most recently from 6023cef to d719ae8 Compare October 17, 2025 12:03
@thorimur
Copy link
Copy Markdown
Contributor

LGTM pending these changes and those isDefEq tests! :) I'll give those isDefEq tests a once-over when they appear, then request a merge. :)

@grunweg grunweg force-pushed the diffgeo-custom-elaborators-more branch from 478c9e8 to 54885c4 Compare October 21, 2025 08:26
@grunweg grunweg force-pushed the diffgeo-custom-elaborators-more branch from 229a890 to a5db2dd Compare October 24, 2025 13:41
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Oct 24, 2025

I updated the defEq check and the tests: now, they are finally testing what they are supposed to test (and are failing accordingly). I've chosen to also test the trace errors (since they should indicate what is going on), and this made the diff grow by another 100 lines. But I hope this PR is now, finally, ready for good.

@thorimur
Copy link
Copy Markdown
Contributor

Wonderful! I gave it a final once-over, and it indeed looks ready to me. :)

maintainer merge

@github-actions
Copy link
Copy Markdown

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

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Oct 27, 2025
@grunweg grunweg added t-meta Tactics, attributes or user commands t-differential-geometry Manifolds etc labels Oct 27, 2025
@sgouezel
Copy link
Copy Markdown
Contributor

bors r+
Thanks!

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Oct 28, 2025
mathlib-bors bot pushed a commit that referenced this pull request Oct 28, 2025
…0413)

Also infer the model with corners on
- a space of continuous linear equivalences
- a closed real interval (Set.Icc)
- the complex upper half plane

And add elaborators for `HasMFDeriv(Within)At` analogous to the `mfderiv(Within)` ones.

Further cases, as well as products, disjoint unions or open subsets, will be covered in future PRs.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Oct 28, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: further extensions of the differential geometry elaborators [Merged by Bors] - feat: further extensions of the differential geometry elaborators Oct 28, 2025
@mathlib-bors mathlib-bors bot closed this Oct 28, 2025
@grunweg grunweg deleted the diffgeo-custom-elaborators-more branch October 28, 2025 10:21
BeibeiX0 pushed a commit to BeibeiX0/mathlib4 that referenced this pull request Nov 7, 2025
…anprover-community#30413)

Also infer the model with corners on
- a space of continuous linear equivalences
- a closed real interval (Set.Icc)
- the complex upper half plane

And add elaborators for `HasMFDeriv(Within)At` analogous to the `mfderiv(Within)` ones.

Further cases, as well as products, disjoint unions or open subsets, will be covered in future PRs.
FormulaRabbit81 pushed a commit to FormulaRabbit81/mathlib4 that referenced this pull request Nov 8, 2025
…anprover-community#30413)

Also infer the model with corners on
- a space of continuous linear equivalences
- a closed real interval (Set.Icc)
- the complex upper half plane

And add elaborators for `HasMFDeriv(Within)At` analogous to the `mfderiv(Within)` ones.

Further cases, as well as products, disjoint unions or open subsets, will be covered in future PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-differential-geometry Manifolds etc t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants