Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - refactor(AlgebraicGeometry): Introduce Scheme.Opens. #15001

Closed
wants to merge 24 commits into from

Conversation

erdOne
Copy link
Member

@erdOne erdOne commented Jul 22, 2024

Introduced Scheme.Opens as the type of open sets of a scheme. Provided instance : CoeOut X.Opens Scheme to replace the notation X ∣_ᵤ U, and renamed Scheme.ιOpens to Scheme.Opens.ι to enable dot notation.


Main changes are in Restrict.lean.

Open in Gitpod

Copy link

github-actions bot commented Jul 22, 2024

PR summary 5916387248

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Scheme.Opens.ι_image_basicOpen
+ Scheme.component_nontrivial
+ Scheme.openCoverOfSuprEqTop
+ eqToHom_eq_homOfLE
+ eq_presheaf_map_eqToHom
+ germ_stalkIso_hom
+ instance : CoeOut X.Opens Scheme := ⟨toScheme⟩
+ instance : IsOpenImmersion U.ι := inferInstanceAs (IsOpenImmersion (X.ofRestrict _))
+ instance [IrreducibleSpace X] (U : X.Opens) [Nonempty U] :
+ instance [IsAffine X] (r : Γ(X, ⊤)) : IsAffine (X.basicOpen r)
+ instance [IsIntegral X] : IsDomain Γ(X, ⊤)
+ instance {X : Scheme} [IsIntegral X] {U : X.Opens} [Nonempty U] :
+ instance {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) [IsOpenImmersion f] :
+ instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] (U : Y.Opens) : IsIso (f ∣_ U) := by
+ instance {Y : Scheme.{u}} (U : Y.affineOpens) : IsAffine U
+ instance ΓRestrictAlgebra {X : Scheme.{u}} (U : X.Opens) :
+ instance ι_appLE_isIso :
+ nonempty_iff
+ opensRange_ι
+ preimage_comp
+ range_ι
+ stalkIso
+ toScheme
+ toScheme_carrier
+ toScheme_presheaf_map
+ toScheme_presheaf_obj
+ topIso
+ ι
+ ι_app
+ ι_appIso
+ ι_appLE
+ ι_app_self
+ ι_basicOpen_preimage
+ ι_image_top
+ ι_preimage_self
- Scheme.eq_restrict_presheaf_map_eqToHom
- Scheme.map_basicOpen
- Scheme.ofRestrict_app_self
- Scheme.resTop
- Scheme.ιOpens_appLE_isIso
- Scheme.ιOpens_image_top
- instance [IrreducibleSpace X] (U : Opens X) [Nonempty U] :
- instance [IsAffine X] (r : Γ(X, ⊤)) : IsAffine (X ∣_ᵤ X.basicOpen r)
- instance [h : IsIntegral X] : IsDomain Γ(X, ⊤)
- instance {X : Scheme} [IsIntegral X] {U : Opens X} [hU : Nonempty U] :
- instance {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Opens Y) [IsOpenImmersion f] :
- instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] (U : Opens Y) : IsIso (f ∣_ U) := by
- instance {Y : Scheme.{u}} (U : Y.affineOpens) :
- instance ΓRestrictAlgebra {X : Scheme.{u}} {Y : TopCat.{u}} {f : Y ⟶ X} (hf : OpenEmbedding f) :
- openCoverOfSuprEqTop
- opensRange_ιOpens
- ιOpens_basicOpen_preimage
--++ iff_of_iSup_eq_top
--++ of_iSup_eq_top

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>

@erdOne
Copy link
Member Author

erdOne commented Jul 22, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 89bba21.
The entire run failed.
Found no significant differences.

@erdOne
Copy link
Member Author

erdOne commented Jul 22, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 2fc3307.
There were significant changes against commit a5fb11c:

  Benchmark                                                Metric         Change
  ==============================================================================
- build                                                    linting          6.4%
- ~Mathlib.AlgebraicGeometry.AffineScheme                  instructions    22.5%
+ ~Mathlib.AlgebraicGeometry.Morphisms.Basic               instructions   -46.9%
+ ~Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties   instructions   -50.6%
+ ~Mathlib.AlgebraicGeometry.Restrict                      instructions   -59.5%
+ ~Mathlib.AlgebraicGeometry.Scheme                        instructions   -22.4%

Copy link
Collaborator

@chrisflav chrisflav left a comment

Choose a reason for hiding this comment

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

I'll review more tomorrow.

Comment on lines +129 to +130
def Scheme.openCoverOfSuprEqTop {s : Type*} (X : Scheme.{u}) (U : s → X.Opens)
(hU : ⨆ i, U i = ⊤) : X.OpenCover where
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def Scheme.openCoverOfSuprEqTop {s : Type*} (X : Scheme.{u}) (U : s → X.Opens)
(hU : ⨆ i, U i = ⊤) : X.OpenCover where
def Scheme.openCoverOfiSupEqTop {s : Type*} (X : Scheme.{u}) (U : s → X.Opens)
(hU : ⨆ i, U i = ⊤) : X.OpenCover where

Copy link
Member Author

Choose a reason for hiding this comment

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

This is copy pasted from elsewhere. I'll make this change in a follow-up PR.

Copy link
Collaborator

@chrisflav chrisflav left a comment

Choose a reason for hiding this comment

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

It looks like it does not make anything worse and some things definitely look better. The old X ∣_ᵤ U looked a bit funky in some places. Also that we can use dot notation on the open set is nice and opens up a potential refactor of IsAffineOpen.

Comment on lines +148 to +150
instance ΓRestrictAlgebra {X : Scheme.{u}} (U : X.Opens) :
Algebra (Scheme.Γ.obj (op X)) (Scheme.Γ.obj (op U)) :=
(Scheme.Γ.map U.ι.op).toAlgebra
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
instance ΓRestrictAlgebra {X : Scheme.{u}} (U : X.Opens) :
Algebra (Scheme.Γ.obj (op X)) (Scheme.Γ.obj (op U)) :=
(Scheme.Γ.map U.ι.op).toAlgebra
instance ΓRestrictAlgebra {X : Scheme.{u}} (U : X.Opens) :
Algebra Γ(X, ⊤) Γ(U, ⊤) :=
(Scheme.Γ.map U.ι.op).toAlgebra

Copy link
Member Author

@erdOne erdOne Jul 23, 2024

Choose a reason for hiding this comment

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

This change will break other things. I'll make this change in a follow-up PR.

@chrisflav chrisflav added the awaiting-author A reviewer has asked the author a question or requested changes label Jul 23, 2024
Co-authored-by: Christian Merten <[email protected]>
@erdOne erdOne removed the awaiting-author A reviewer has asked the author a question or requested changes label Jul 23, 2024
Co-authored-by: Christian Merten <[email protected]>
Copy link
Collaborator

@chrisflav chrisflav left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

Comment on lines 368 to 372
rw [Scheme.comp_app, Scheme.comp_app, ΓSpecIso_obj_hom,
Scheme.ofRestrict_app_self]
simp only [Category.assoc]
dsimp only [asIso_inv, Functor.op_obj, unop_op]
rw [← Functor.map_comp_assoc, ← op_comp, eqToHom_trans, Scheme.eq_restrict_presheaf_map_eqToHom,
rw [Scheme.comp_app, Scheme.comp_app, ΓSpecIso_obj_hom, Scheme.Opens.ι_app_self]
simp only [asIso_inv, Scheme.comp_coeBase, Opens.map_comp_obj, Scheme.Opens.topIso_inv,
Opens.map_top, Functor.id_obj, Functor.comp_obj,
Functor.rightOp_obj, Scheme.Γ_obj, unop_op, Scheme.Spec_obj, Scheme.Opens.topIso_hom,
Category.assoc]
rw [← Functor.map_comp_assoc, ← op_comp, eqToHom_trans, Scheme.Opens.eq_presheaf_map_eqToHom,
Copy link
Member Author

Choose a reason for hiding this comment

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

The slowdown on this file comes from this proof and it will be improved in a later PR where the unit of the gamma-spec adjunction is specialized and be provided dedicated API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole proof can be solved by a single simp only [many things are here] and the have can be deleted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am guessing the rw are unfolding things at default transparency that are very unpleasant. At least with simp, you can control the unfolding a bit more

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean introducing intermediate lemmas? I'm not sure how to make this work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay I managed to condense it into two blobs of simp and removed the nolint and the maxheartbeat.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm. I think it is supposed to operate at reducible but I can't tell if it is doing anything atm

Copy link
Collaborator

@mattrobball mattrobball Jul 23, 2024

Choose a reason for hiding this comment

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

The actual substitution via kabstract is done at reducible transparency but there is at least one other isDefEq call that is done at default. So we start unfolding these more than is desired here

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that intended? If this happens to rw everywhere, it sounds like a performance hazard to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

With the huge caveat that I just looked at the file for a couple of minutes, no.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll check on this at office hours tomorrow at the latest

@mattrobball
Copy link
Collaborator

mattrobball commented Jul 23, 2024

You might be able to improve your performance by removing the attribute making Quiver.Hom reducible at the start of AffineScheme. It doesn't seem to do anything except make Lean work harder now

@erdOne
Copy link
Member Author

erdOne commented Jul 23, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 5916387.
There were significant changes against commit d9ce431:

  Benchmark                                    Metric         Change
  ==================================================================
+ ~Mathlib.AlgebraicGeometry.AffineScheme      instructions   -35.1%
+ ~Mathlib.AlgebraicGeometry.Morphisms.Basic   instructions   -46.0%
+ ~Mathlib.AlgebraicGeometry.Restrict          instructions   -59.2%
+ ~Mathlib.AlgebraicGeometry.Scheme            instructions   -21.7%

@mattrobball
Copy link
Collaborator

Ready to go?

@erdOne
Copy link
Member Author

erdOne commented Jul 23, 2024

Yes. Thanks! The improvements mentioned above will come in a later PR.

@mattrobball
Copy link
Collaborator

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Jul 23, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jul 23, 2024
Introduced `Scheme.Opens` as the type of open sets of a scheme.  Provided `instance : CoeOut X.Opens Scheme` to replace the notation `X ∣_ᵤ U`, and renamed `Scheme.ιOpens` to `Scheme.Opens.ι` to enable dot notation.



Co-authored-by: Andrew Yang <[email protected]>
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jul 23, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor(AlgebraicGeometry): Introduce Scheme.Opens. [Merged by Bors] - refactor(AlgebraicGeometry): Introduce Scheme.Opens. Jul 23, 2024
@mathlib-bors mathlib-bors bot closed this Jul 23, 2024
@mathlib-bors mathlib-bors bot deleted the erd1/schemeOpens2 branch July 23, 2024 21:23
@adomani adomani mentioned this pull request Aug 1, 2024
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-algebraic-geometry Algebraic geometry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants