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): Rework Morphisms/Basic to phase away from TFAEs #14430

Closed
wants to merge 54 commits into from

Conversation

erdOne
Copy link
Member

@erdOne erdOne commented Jul 4, 2024

Previously the contents of Morphism/Basic were all implementation detail that needed to be copied over to each new morphism class. In this PR we clean up the file and promote it into a proper interface of the API. We also phase away from TFAEs in favor of easier to use iff lemmas. We introduce the following two interfaces:

IsLocalAtTarget

  • AlgebraicGeometry.IsLocalAtTarget: We say that IsLocalAtTarget P for
    P : MorphismProperty Scheme if
  1. P respects isomorphisms.
  2. If P holds for f : X ⟶ Y, then P holds for f ∣_ U for any open U of Y.
  3. If P holds for f ∣_ U for an open cover U of Y, then P holds for f.

For a morphism property P local at the target and f : X ⟶ Y, we provide these API lemmas:

  • AlgebraicGeometry.IsLocalAtTarget.of_isPullback:
    P is preserved under pullback along open immersions.
  • AlgebraicGeometry.IsLocalAtTarget.restrict:
    P f → P (f ∣_ U) for an open U of Y.
  • AlgebraicGeometry.IsLocalAtTarget.iff_of_iSup_eq_top:
    P f ↔ ∀ i, P (f ∣_ U i) for a family U i of open sets covering Y.
  • AlgebraicGeometry.IsLocalAtTarget.iff_of_openCover:
    P f ↔ ∀ i, P (𝒰.pullbackHom f i) for 𝒰 : Y.openCover.

HasAffineProperty

  • AlgebraicGeometry.HasAffineProperty:
    HasAffineProperty P Q is a type class asserting that P is local at the target,
    and over affine schemes, it is equivalent to Q : AffineTargetMorphismProperty.

For HasAffineProperty P Q and f : X ⟶ Y, we provide these API lemmas:

  • AlgebraicGeometry.HasAffineProperty.of_isPullback:
    P is preserved under pullback along open immersions from affine schemes.
  • AlgebraicGeometry.HasAffineProperty.restrict:
    P f → Q (f ∣_ U) for affine U of Y.
  • AlgebraicGeometry.HasAffineProperty.iff_of_iSup_eq_top:
    P f ↔ ∀ i, Q (f ∣_ U i) for a family U i of affine open sets covering Y.
  • AlgebraicGeometry.HasAffineProperty.iff_of_openCover:
    P f ↔ ∀ i, P (𝒰.pullbackHom f i) for affine open covers 𝒰 of Y.
  • AlgebraicGeometry.HasAffineProperty.stableUnderBaseChange_mk:
    If Q is stable under affine base change, then P is stable under arbitrary base change.

Open in Gitpod

@erdOne erdOne added the WIP Work in progress label Jul 4, 2024
Copy link

github-actions bot commented Jul 4, 2024

PR summary a67d97bfc5

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ HasAffineProperty
+ HasAffineProperty.diagonal_affineProperty_isLocal
+ HasAffineProperty.diagonal_iff
+ HasAffineProperty.diagonal_of_diagonal_of_isPullback
+ HasAffineProperty.diagonal_of_openCover
+ HasAffineProperty.diagonal_of_openCover_diagonal
+ IsLocal
+ IsLocalAtTarget
+ OpenCover.pullbackCoverAffineRefinementObjIso
+ OpenCover.pullbackCoverAffineRefinementObjIso_inv_map
+ OpenCover.pullbackCoverAffineRefinementObjIso_inv_pullbackHom
+ OpenCover.pullbackHom
+ OpenCover.pullbackHom_map
+ QuasiSeparated.of_comp
+ Scheme.resTop
+ StableUnderBaseChange.mk
+ arrow_mk_iso_iff
+ cancel_left_of_respectsIso
+ cancel_right_of_respectsIso
+ copy
+ eq_targetAffineLocally
+ ext
+ hasAffinePropertyAffineLocally
+ id_apply
+ iff
+ iff_of_isAffine
+ instance (P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso] :
+ instance (P : MorphismProperty Scheme) [IsLocalAtTarget P] : (of P).IsLocal
+ instance (P) [IsLocalAtTarget P] : IsLocalAtTarget P.diagonal
+ instance (P) {Q} [HasAffineProperty P Q] : HasAffineProperty P.diagonal Q.diagonal
+ instance (Q : AffineTargetMorphismProperty) [Q.IsLocal] :
+ instance (priority := 900) : IsLocalAtTarget P := by
+ instance (priority := 900) : P.RespectsIso := by
+ instance : HasAffineProperty @QuasiCompact (fun X _ _ _ ↦ CompactSpace X)
+ instance : HasAffineProperty @QuasiSeparated (fun X _ _ _ ↦ QuasiSeparatedSpace X)
+ instance [IsAffine X] (r : Γ(X, ⊤)) : IsAffine (X ∣_ᵤ X.basicOpen r)
+ instance {X} [IsAffine X] (i) : IsAffine ((Scheme.openCoverOfIsIso (𝟙 X)).obj i) := by
+ locallyOfFiniteType_isLocalAtTarget
+ mk'
+ of
+ of_isLocalAtTarget
+ of_targetAffineLocally_of_isPullback
+ preimage_of_isIso
+ quasiCompact_affineProperty_iff_quasiSeparatedSpace
+ respectsIso_mk
+ respectsIso_of
+ stableUnderBaseChange
+ toProperty
+ toProperty_apply
+ topologically_isLocalAtTarget
+ universallyClosed_fst
+ universallyClosed_snd
++ iff_of_iSup_eq_top
++ iff_of_openCover
++ of_iSup_eq_top
++ of_id_fst
++ of_id_snd
++ of_isPullback
++ of_openCover
++ restrict
- AffineTargetMorphismProperty.IsLocal
- AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
- AffineTargetMorphismProperty.IsLocal.affine_openCover_iff
- AffineTargetMorphismProperty.IsLocal.affine_target_iff
- AffineTargetMorphismProperty.IsLocal.diagonal
- AffineTargetMorphismProperty.IsLocal.diagonal_affine_openCover_TFAE
- AffineTargetMorphismProperty.IsLocal.targetAffineLocally_isLocal
- AffineTargetMorphismProperty.cancel_left_of_respectsIso
- AffineTargetMorphismProperty.cancel_right_of_respectsIso
- AffineTargetMorphismProperty.diagonal_of_targetAffineLocally
- AffineTargetMorphismProperty.isLocalOfOpenCoverImply
- AffineTargetMorphismProperty.of
- AffineTargetMorphismProperty.respectsIso_mk
- AffineTargetMorphismProperty.toProperty
- AffineTargetMorphismProperty.toProperty_apply
- CommRingCat.id_apply
- IsAffineOpen.preimage_of_isIso
- IsLocal.stableUnderBaseChange
- IsLocal.targetAffineLocally_pullback_fst_of_right_of_stableUnderBaseChange
- IsOpenImmersion.openCover_TFAE
- IsOpenImmersion.openCover_iff
- LocallyOfFiniteType.openCover_iff
- PropertyIsLocalAtTarget
- PropertyIsLocalAtTarget.openCover_TFAE
- PropertyIsLocalAtTarget.openCover_iff
- QuasiCompact.affineProperty
- QuasiCompact.affineProperty_isLocal
- QuasiCompact.affineProperty_stableUnderBaseChange
- QuasiCompact.affineProperty_toProperty
- QuasiCompact.affine_openCover_iff
- QuasiCompact.affine_openCover_tfae
- QuasiCompact.isLocalAtTarget
- QuasiCompact.openCover_iff
- QuasiCompact.openCover_tfae
- QuasiSeparated.affineProperty
- QuasiSeparated.affineProperty_isLocal
- QuasiSeparated.affine_openCover_TFAE
- QuasiSeparated.affine_openCover_iff
- QuasiSeparated.isLocalAtTarget
- QuasiSeparated.openCover_TFAE
- QuasiSeparated.openCover_iff
- Scheme.affineTargetIsIso
- Scheme.isIso
- UniversallyClosed.openCover_iff
- diagonal_targetAffineLocally_eq_targetAffineLocally
- diagonal_targetAffineLocally_of_openCover
- instance : Inhabited AffineTargetMorphismProperty := ⟨Scheme.affineTargetIsIso⟩
- instance : QuasiCompact.affineProperty.toProperty.RespectsIso := by
- instance {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiSeparated f] [QuasiSeparated g] :
- is_local_affineLocally
- locallyOfFiniteType_respectsIso
- of_isLocal_of_isLocalAtTarget
- propertyIsLocalAtTarget_of_morphismRestrict
- quasiCompact_eq_affineProperty
- quasiCompact_iff_affineProperty
- quasiCompact_respectsIso
- quasiSeparatedOfComp
- quasiSeparated_eq_affineProperty
- quasiSeparated_eq_affineProperty_diagonal
- quasiSeparated_respectsIso
- quasi_compact_affineProperty_diagonal_eq
- quasi_compact_affineProperty_iff_quasiSeparatedSpace
- targetAffineLocallyIsLocal
- targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
- targetAffineLocally_of_eq_of_isLocalAtTarget
- targetAffineLocally_of_openCover
- targetAffineLocally_respectsIso
- topologically_propertyIsLocalAtTarget
- universallyClosedFst
- universallyClosedSnd
- universally_isLocalAtTarget_of_morphismRestrict

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 15, 2024

I think I have addressed all the comments. Thanks for the swift review!

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.

As I said earlier, I really like this change.

Comment on lines -225 to -230
theorem QuasiCompact.affine_openCover_iff {X Y : Scheme.{u}} (𝒰 : Scheme.OpenCover.{u} Y)
[∀ i, IsAffine (𝒰.obj i)] (f : X ⟶ Y) :
QuasiCompact f ↔ ∀ i, CompactSpace (pullback f (𝒰.map i) : _) :=
quasiCompact_eq_affineProperty.symm ▸ QuasiCompact.affineProperty_isLocal.affine_openCover_iff f 𝒰
#align algebraic_geometry.quasi_compact.affine_open_cover_iff AlgebraicGeometry.QuasiCompact.affine_openCover_iff

Copy link
Collaborator

Choose a reason for hiding this comment

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

What did come out of this?

@erdOne erdOne added the awaiting-author A reviewer has asked the author a question or requested changes label Jul 16, 2024
@erdOne erdOne removed the awaiting-author A reviewer has asked the author a question or requested changes label Jul 16, 2024
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.

LGTM, thanks a lot!

@erdOne
Copy link
Member Author

erdOne commented Jul 18, 2024

Thanks for the swift review!

@mattrobball
Copy link
Collaborator

!bench

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the ready-to-merge This PR has been sent to bors. label Jul 18, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jul 18, 2024
…rom TFAEs (#14430)

Previously the contents of `Morphism/Baisic` were all implementation detail that needed to be copied over to each new morphism class. In this PR we clean up the file and promote it into a proper interface of the API. We also phase away from TFAEs in favor of easier to use iff lemmas. We introduce the following two interfaces:

## `IsLocalAtTarget`

- `AlgebraicGeometry.IsLocalAtTarget`: We say that `IsLocalAtTarget P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any open `U` of `Y`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.

For a morphism property `P` local at the target and `f : X ⟶ Y`, we provide these API lemmas:

- `AlgebraicGeometry.IsLocalAtTarget.of_isPullback`:
    `P` is preserved under pullback along open immersions.
- `AlgebraicGeometry.IsLocalAtTarget.restrict`:
    `P f → P (f ∣_ U)` for an open `U` of `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_iSup_eq_top`:
    `P f ↔ ∀ i, P (f ∣_ U i)` for a family `U i` of open sets covering `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_openCover`:
    `P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for `𝒰 : Y.openCover`.

## `HasAffineProperty`

- `AlgebraicGeometry.HasAffineProperty`:
  `HasAffineProperty P Q` is a type class asserting that `P` is local at the target,
  and over affine schemes, it is equivalent to `Q : AffineTargetMorphismProperty`.

For `HasAffineProperty P Q` and `f : X ⟶ Y`, we provide these API lemmas:

- `AlgebraicGeometry.HasAffineProperty.of_isPullback`:
    `P` is preserved under pullback along open immersions from affine schemes.
- `AlgebraicGeometry.HasAffineProperty.restrict`:
    `P f → Q (f ∣_ U)` for affine `U` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_iSup_eq_top`:
    `P f ↔ ∀ i, Q (f ∣_ U i)` for a family `U i` of affine open sets covering `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_openCover`:
    `P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for affine open covers `𝒰` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.stableUnderBaseChange_mk`:
    If `Q` is stable under affine base change, then `P` is stable under arbitrary base change.



Co-authored-by: Andrew Yang <[email protected]>
Co-authored-by: Joël Riou <[email protected]>
@mattrobball
Copy link
Collaborator

Let's wait for the benchmarking to finish. AG is a finicky area currently.

bors r-

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jul 18, 2024

Canceled.

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit a67d97b.
There were significant changes against commit af10129:

  Benchmark                               Metric         Change
  =============================================================
- ~Mathlib.AlgebraicGeometry.Cover.Open   instructions    31.8%

@mattrobball
Copy link
Collaborator

Seems minor. I will see if I can track that down later.

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Jul 18, 2024
…rom TFAEs (#14430)

Previously the contents of `Morphism/Baisic` were all implementation detail that needed to be copied over to each new morphism class. In this PR we clean up the file and promote it into a proper interface of the API. We also phase away from TFAEs in favor of easier to use iff lemmas. We introduce the following two interfaces:

## `IsLocalAtTarget`

- `AlgebraicGeometry.IsLocalAtTarget`: We say that `IsLocalAtTarget P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any open `U` of `Y`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.

For a morphism property `P` local at the target and `f : X ⟶ Y`, we provide these API lemmas:

- `AlgebraicGeometry.IsLocalAtTarget.of_isPullback`:
    `P` is preserved under pullback along open immersions.
- `AlgebraicGeometry.IsLocalAtTarget.restrict`:
    `P f → P (f ∣_ U)` for an open `U` of `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_iSup_eq_top`:
    `P f ↔ ∀ i, P (f ∣_ U i)` for a family `U i` of open sets covering `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_openCover`:
    `P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for `𝒰 : Y.openCover`.

## `HasAffineProperty`

- `AlgebraicGeometry.HasAffineProperty`:
  `HasAffineProperty P Q` is a type class asserting that `P` is local at the target,
  and over affine schemes, it is equivalent to `Q : AffineTargetMorphismProperty`.

For `HasAffineProperty P Q` and `f : X ⟶ Y`, we provide these API lemmas:

- `AlgebraicGeometry.HasAffineProperty.of_isPullback`:
    `P` is preserved under pullback along open immersions from affine schemes.
- `AlgebraicGeometry.HasAffineProperty.restrict`:
    `P f → Q (f ∣_ U)` for affine `U` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_iSup_eq_top`:
    `P f ↔ ∀ i, Q (f ∣_ U i)` for a family `U i` of affine open sets covering `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_openCover`:
    `P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for affine open covers `𝒰` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.stableUnderBaseChange_mk`:
    If `Q` is stable under affine base change, then `P` is stable under arbitrary base change.



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

mathlib-bors bot commented Jul 18, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor(AlgebraicGeometry): Rework Morphisms/Basic to phase away from TFAEs [Merged by Bors] - refactor(AlgebraicGeometry): Rework Morphisms/Basic to phase away from TFAEs Jul 18, 2024
@mathlib-bors mathlib-bors bot closed this Jul 18, 2024
@mathlib-bors mathlib-bors bot deleted the erd1/morphismRework branch July 18, 2024 12:18
@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.

7 participants