source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/FieldTheory/IntermediateField/Algebraic.lean | import Mathlib.FieldTheory.IntermediateField.Basic
import Mathlib.FieldTheory.Minpoly.Basic
import Mathlib.FieldTheory.Tower
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.RingTheory.Algebraic.Integral
/-!
# Results on finite dimensionality and algebraicity of intermediate fields.
-/
open Module
variable {K L : Type*} [Field K] [Field L] [Algebra K L]
{S : IntermediateField K L}
theorem IntermediateField.coe_isIntegral_iff {R : Type*} [CommRing R] [Algebra R K] [Algebra R L]
[IsScalarTower R K L] {x : S} : IsIntegral R (x : L) ↔ IsIntegral R x :=
isIntegral_algHom_iff (S.val.restrictScalars R) Subtype.val_injective
/-- Turn an algebraic subalgebra into an intermediate field, `Subalgebra.IsAlgebraic` version. -/
def Subalgebra.IsAlgebraic.toIntermediateField {S : Subalgebra K L} (hS : S.IsAlgebraic) :
IntermediateField K L where
toSubalgebra := S
inv_mem' x hx := Algebra.adjoin_le_iff.mpr
(Set.singleton_subset_iff.mpr hx) (hS x hx).isIntegral.inv_mem_adjoin
/-- Turn an algebraic subalgebra into an intermediate field, `Algebra.IsAlgebraic` version. -/
abbrev Algebra.IsAlgebraic.toIntermediateField (S : Subalgebra K L) [Algebra.IsAlgebraic K S] :
IntermediateField K L := (S.isAlgebraic_iff.mpr ‹_›).toIntermediateField
namespace IntermediateField
instance isAlgebraic_tower_bot [Algebra.IsAlgebraic K L] : Algebra.IsAlgebraic K S :=
Algebra.IsAlgebraic.of_injective S.val S.val.injective
instance isAlgebraic_tower_top [Algebra.IsAlgebraic K L] : Algebra.IsAlgebraic S L :=
Algebra.IsAlgebraic.tower_top (K := K) S
section FiniteDimensional
variable (F E : IntermediateField K L)
instance finiteDimensional_left [FiniteDimensional K L] : FiniteDimensional K F := .left K F L
instance finiteDimensional_right [FiniteDimensional K L] : FiniteDimensional F L := .right K F L
@[simp]
theorem rank_eq_rank_subalgebra : Module.rank K F.toSubalgebra = Module.rank K F :=
rfl
@[simp]
theorem finrank_eq_finrank_subalgebra : finrank K F.toSubalgebra = finrank K F :=
rfl
variable {F} {E}
/-- If `F ≤ E` are two intermediate fields of `L / K` such that `[E : K] ≤ [F : K]` are finite,
then `F = E`. -/
theorem eq_of_le_of_finrank_le [hfin : FiniteDimensional K E] (h_le : F ≤ E)
(h_finrank : finrank K E ≤ finrank K F) : F = E :=
haveI : Module.Finite K E.toSubalgebra := hfin
toSubalgebra_injective <| Subalgebra.eq_of_le_of_finrank_le h_le h_finrank
/-- If `F ≤ E` are two intermediate fields of `L / K` such that `[F : K] = [E : K]` are finite,
then `F = E`. -/
theorem eq_of_le_of_finrank_eq [FiniteDimensional K E] (h_le : F ≤ E)
(h_finrank : finrank K F = finrank K E) : F = E :=
eq_of_le_of_finrank_le h_le h_finrank.ge
-- If `F ≤ E` are two intermediate fields of a finite extension `L / K` such that
-- `[L : F] ≤ [L : E]`, then `F = E`. Marked as private since it's a direct corollary of
-- `eq_of_le_of_finrank_le'` (the `FiniteDimensional K L` implies `FiniteDimensional F L`
-- automatically by typeclass resolution).
private theorem eq_of_le_of_finrank_le'' [FiniteDimensional K L] (h_le : F ≤ E)
(h_finrank : finrank F L ≤ finrank E L) : F = E := by
apply eq_of_le_of_finrank_le h_le
have h1 := finrank_mul_finrank K F L
have h2 := finrank_mul_finrank K E L
have h3 : 0 < finrank E L := finrank_pos
nlinarith
/-- If `F ≤ E` are two intermediate fields of `L / K` such that `[L : F] ≤ [L : E]` are finite,
then `F = E`. -/
theorem eq_of_le_of_finrank_le' [FiniteDimensional F L] (h_le : F ≤ E)
(h_finrank : finrank F L ≤ finrank E L) : F = E := by
refine le_antisymm h_le (fun l hl ↦ ?_)
rwa [← mem_extendScalars (le_refl F), eq_of_le_of_finrank_le''
((extendScalars_le_extendScalars_iff (le_refl F) h_le).2 h_le) h_finrank, mem_extendScalars]
/-- If `F ≤ E` are two intermediate fields of `L / K` such that `[L : F] = [L : E]` are finite,
then `F = E`. -/
theorem eq_of_le_of_finrank_eq' [FiniteDimensional F L] (h_le : F ≤ E)
(h_finrank : finrank F L = finrank E L) : F = E :=
eq_of_le_of_finrank_le' h_le h_finrank.le
theorem finrank_dvd_of_le_left (h : F ≤ E) : finrank E L ∣ finrank F L := by
let _ := (inclusion h).toRingHom.toAlgebra
have : IsScalarTower F E L := IsScalarTower.of_algebraMap_eq fun x ↦ rfl
exact Dvd.intro_left (finrank F E) (finrank_mul_finrank F E L)
theorem finrank_dvd_of_le_right (h : F ≤ E) : finrank K F ∣ finrank K E := by
let _ := (inclusion h).toRingHom.toAlgebra
exact Dvd.intro (finrank F E) (finrank_mul_finrank K F E)
theorem finrank_le_of_le_left [FiniteDimensional F L] (h : F ≤ E) : finrank E L ≤ finrank F L :=
Nat.le_of_dvd Module.finrank_pos (finrank_dvd_of_le_left h)
theorem finrank_le_of_le_right [FiniteDimensional K E] (h : F ≤ E) : finrank K F ≤ finrank K E :=
Nat.le_of_dvd Module.finrank_pos (finrank_dvd_of_le_right h)
/-- Mapping a finite-dimensional intermediate field along an algebra equivalence gives
a finite-dimensional intermediate field. -/
instance finiteDimensional_map (f : L →ₐ[K] L) [FiniteDimensional K E] :
FiniteDimensional K (E.map f) :=
LinearEquiv.finiteDimensional (IntermediateField.equivMap E f).toLinearEquiv
@[deprecated (since := "2025-05-02")]
alias _root_.im_finiteDimensional := IntermediateField.finiteDimensional_map
end FiniteDimensional
theorem isAlgebraic_iff {x : S} : IsAlgebraic K x ↔ IsAlgebraic K (x : L) :=
(isAlgebraic_algebraMap_iff (algebraMap S L).injective).symm
theorem isIntegral_iff {x : S} : IsIntegral K x ↔ IsIntegral K (x : L) :=
(isIntegral_algHom_iff S.val S.val.injective).symm
theorem minpoly_eq (x : S) : minpoly K x = minpoly K (x : L) :=
(minpoly.algebraMap_eq (algebraMap S L).injective x).symm
end IntermediateField
/-- If `L/K` is algebraic, the `K`-subalgebras of `L` are all fields. -/
def subalgebraEquivIntermediateField [Algebra.IsAlgebraic K L] :
Subalgebra K L ≃o IntermediateField K L where
toFun S := S.toIntermediateField fun x hx => S.inv_mem_of_algebraic
(Algebra.IsAlgebraic.isAlgebraic ((⟨x, hx⟩ : S) : L))
invFun S := S.toSubalgebra
left_inv _ := toSubalgebra_toIntermediateField _ _
right_inv := toIntermediateField_toSubalgebra
map_rel_iff' := Iff.rfl
@[simp]
theorem mem_subalgebraEquivIntermediateField [Algebra.IsAlgebraic K L] {S : Subalgebra K L}
{x : L} : x ∈ subalgebraEquivIntermediateField S ↔ x ∈ S :=
Iff.rfl
@[simp]
theorem mem_subalgebraEquivIntermediateField_symm [Algebra.IsAlgebraic K L]
{S : IntermediateField K L} {x : L} :
x ∈ subalgebraEquivIntermediateField.symm S ↔ x ∈ S :=
Iff.rfl |
.lake/packages/mathlib/Mathlib/FieldTheory/IntermediateField/Basic.lean | import Mathlib.Algebra.Algebra.Subalgebra.Tower
import Mathlib.Algebra.Field.IsField
import Mathlib.Algebra.Field.Subfield.Basic
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.LocalRing.Basic
/-!
# Intermediate fields
Let `L / K` be a field extension, given as an instance `Algebra K L`.
This file defines the type of fields in between `K` and `L`, `IntermediateField K L`.
An `IntermediateField K L` is a subfield of `L` which contains (the image of) `K`,
i.e. it is a `Subfield L` and a `Subalgebra K L`.
## Main definitions
* `IntermediateField K L` : the type of intermediate fields between `K` and `L`.
* `Subalgebra.to_intermediateField`: turns a subalgebra closed under `⁻¹`
into an intermediate field
* `Subfield.to_intermediateField`: turns a subfield containing the image of `K`
into an intermediate field
* `IntermediateField.map`: map an intermediate field along an `AlgHom`
* `IntermediateField.restrict_scalars`: restrict the scalars of an intermediate field to a smaller
field in a tower of fields.
## Implementation notes
Intermediate fields are defined with a structure extending `Subfield` and `Subalgebra`.
A `Subalgebra` is closed under all operations except `⁻¹`,
## Tags
intermediate field, field extension
-/
open Polynomial
variable (K L L' : Type*) [Field K] [Field L] [Field L'] [Algebra K L] [Algebra K L']
/-- `S : IntermediateField K L` is a subset of `L` such that there is a field
tower `L / S / K`. -/
structure IntermediateField extends Subalgebra K L where
inv_mem' : ∀ x ∈ carrier, x⁻¹ ∈ carrier
/-- Reinterpret an `IntermediateField` as a `Subalgebra`. -/
add_decl_doc IntermediateField.toSubalgebra
variable {K L L'}
variable (S : IntermediateField K L)
namespace IntermediateField
instance : SetLike (IntermediateField K L) L :=
⟨fun S => S.toSubalgebra.carrier, by
rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩
simp ⟩
protected theorem neg_mem {x : L} (hx : x ∈ S) : -x ∈ S := by
change -x ∈S.toSubalgebra; simpa
/-- Reinterpret an `IntermediateField` as a `Subfield`. -/
def toSubfield : Subfield L :=
{ S.toSubalgebra with
neg_mem' := S.neg_mem,
inv_mem' := S.inv_mem' }
instance : SubfieldClass (IntermediateField K L) L where
add_mem {s} := s.add_mem'
zero_mem {s} := s.zero_mem'
neg_mem {s} := s.neg_mem
mul_mem {s} := s.mul_mem'
one_mem {s} := s.one_mem'
inv_mem {s} := s.inv_mem' _
theorem mem_carrier {s : IntermediateField K L} {x : L} : x ∈ s.carrier ↔ x ∈ s :=
Iff.rfl
/-- Two intermediate fields are equal if they have the same elements. -/
@[ext]
theorem ext {S T : IntermediateField K L} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=
SetLike.ext h
@[simp]
theorem coe_toSubalgebra : (S.toSubalgebra : Set L) = S :=
rfl
@[simp]
theorem coe_toSubfield : (S.toSubfield : Set L) = S :=
rfl
@[simp]
theorem coe_type_toSubalgebra : (S.toSubalgebra : Type _) = S :=
rfl
@[simp]
theorem coe_type_toSubfield : (S.toSubfield : Type _) = S :=
rfl
@[simp]
theorem mem_mk (s : Subsemiring L) (hK : ∀ x, algebraMap K L x ∈ s) (hi) (x : L) :
x ∈ IntermediateField.mk (Subalgebra.mk s hK) hi ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem mem_toSubalgebra (s : IntermediateField K L) (x : L) : x ∈ s.toSubalgebra ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem mem_toSubfield (s : IntermediateField K L) (x : L) : x ∈ s.toSubfield ↔ x ∈ s :=
Iff.rfl
theorem toSubalgebra_strictMono :
StrictMono (IntermediateField.toSubalgebra : _ → Subalgebra K L) := fun _ _ h ↦ h
/-- Copy of an intermediate field with a new `carrier` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) :
IntermediateField K L where
toSubalgebra := S.toSubalgebra.copy s hs
inv_mem' := hs.symm ▸ S.inv_mem'
@[simp]
theorem coe_copy (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) :
(S.copy s hs : Set L) = s :=
rfl
theorem copy_eq (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) : S.copy s hs = S :=
SetLike.coe_injective hs
section InheritedLemmas
/-! ### Lemmas inherited from more general structures
The declarations in this section derive from the fact that an `IntermediateField` is also a
subalgebra or subfield. Their use should be replaceable with the corresponding lemma from a
subobject class.
-/
/-- An intermediate field contains the image of the smaller field. -/
theorem algebraMap_mem (x : K) : algebraMap K L x ∈ S :=
S.algebraMap_mem' x
/-- An intermediate field is closed under scalar multiplication. -/
theorem smul_mem {y : L} : y ∈ S → ∀ {x : K}, x • y ∈ S :=
S.toSubalgebra.smul_mem
/-- An intermediate field contains the ring's 1. -/
protected theorem one_mem : (1 : L) ∈ S :=
one_mem S
/-- An intermediate field contains the ring's 0. -/
protected theorem zero_mem : (0 : L) ∈ S :=
zero_mem S
/-- An intermediate field is closed under multiplication. -/
protected theorem mul_mem {x y : L} : x ∈ S → y ∈ S → x * y ∈ S :=
mul_mem
/-- An intermediate field is closed under addition. -/
protected theorem add_mem {x y : L} : x ∈ S → y ∈ S → x + y ∈ S :=
add_mem
/-- An intermediate field is closed under subtraction. -/
protected theorem sub_mem {x y : L} : x ∈ S → y ∈ S → x - y ∈ S :=
sub_mem
/-- An intermediate field is closed under inverses. -/
protected theorem inv_mem {x : L} : x ∈ S → x⁻¹ ∈ S :=
inv_mem
/-- An intermediate field is closed under division. -/
protected theorem div_mem {x y : L} : x ∈ S → y ∈ S → x / y ∈ S :=
div_mem
/-- Product of a list of elements in an intermediate field is in the intermediate field. -/
protected theorem list_prod_mem {l : List L} : (∀ x ∈ l, x ∈ S) → l.prod ∈ S :=
list_prod_mem
/-- Sum of a list of elements in an intermediate field is in the intermediate field. -/
protected theorem list_sum_mem {l : List L} : (∀ x ∈ l, x ∈ S) → l.sum ∈ S :=
list_sum_mem
/-- Product of a multiset of elements in an intermediate field is in the intermediate field. -/
protected theorem multiset_prod_mem (m : Multiset L) : (∀ a ∈ m, a ∈ S) → m.prod ∈ S :=
multiset_prod_mem m
/-- Sum of a multiset of elements in an `IntermediateField` is in the `IntermediateField`. -/
protected theorem multiset_sum_mem (m : Multiset L) : (∀ a ∈ m, a ∈ S) → m.sum ∈ S :=
multiset_sum_mem m
/-- Product of elements of an intermediate field indexed by a `Finset` is in the intermediate field.
-/
protected theorem prod_mem {ι : Type*} {t : Finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) :
(∏ i ∈ t, f i) ∈ S :=
prod_mem h
/-- Sum of elements in an `IntermediateField` indexed by a `Finset` is in the `IntermediateField`.
-/
protected theorem sum_mem {ι : Type*} {t : Finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) :
(∑ i ∈ t, f i) ∈ S :=
sum_mem h
protected theorem pow_mem {x : L} (hx : x ∈ S) (n : ℤ) : x ^ n ∈ S :=
zpow_mem hx n
protected theorem zsmul_mem {x : L} (hx : x ∈ S) (n : ℤ) : n • x ∈ S :=
zsmul_mem hx n
protected theorem intCast_mem (n : ℤ) : (n : L) ∈ S :=
intCast_mem S n
protected theorem coe_add (x y : S) : (↑(x + y) : L) = ↑x + ↑y :=
rfl
protected theorem coe_neg (x : S) : (↑(-x) : L) = -↑x :=
rfl
protected theorem coe_mul (x y : S) : (↑(x * y) : L) = ↑x * ↑y :=
rfl
protected theorem coe_inv (x : S) : (↑x⁻¹ : L) = (↑x)⁻¹ :=
rfl
protected theorem coe_zero : ((0 : S) : L) = 0 :=
rfl
protected theorem coe_one : ((1 : S) : L) = 1 :=
rfl
protected theorem coe_pow (x : S) (n : ℕ) : (↑(x ^ n : S) : L) = (x : L) ^ n :=
SubmonoidClass.coe_pow x n
end InheritedLemmas
theorem natCast_mem (n : ℕ) : (n : L) ∈ S := by simp
instance instSMulMemClass : SMulMemClass (IntermediateField K L) K L where
smul_mem := fun _ _ hx ↦ IntermediateField.smul_mem _ hx
end IntermediateField
/-- Turn a subalgebra closed under inverses into an intermediate field. -/
def Subalgebra.toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) :
IntermediateField K L :=
{ S with
inv_mem' := inv_mem }
@[simp]
theorem toSubalgebra_toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) :
(S.toIntermediateField inv_mem).toSubalgebra = S := by
ext
rfl
@[simp]
theorem toIntermediateField_toSubalgebra (S : IntermediateField K L) :
(S.toSubalgebra.toIntermediateField fun _ => S.inv_mem) = S := by
ext
rfl
/-- Turn a subalgebra satisfying `IsField` into an intermediate field. -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
S.toIntermediateField fun x hx => by
by_cases hx0 : x = 0
· rw [hx0, inv_zero]
exact S.zero_mem
letI hS' := hS.toField
obtain ⟨y, hy⟩ := hS.mul_inv_cancel (show (⟨x, hx⟩ : S) ≠ 0 from Subtype.coe_ne_coe.1 hx0)
rw [Subtype.ext_iff, S.coe_mul, S.coe_one, Subtype.coe_mk, mul_eq_one_iff_inv_eq₀ hx0] at hy
exact hy.symm ▸ y.2
@[simp]
theorem toSubalgebra_toIntermediateField' (S : Subalgebra K L) (hS : IsField S) :
(S.toIntermediateField' hS).toSubalgebra = S := by
ext
rfl
@[simp]
theorem toIntermediateField'_toSubalgebra (S : IntermediateField K L) :
S.toSubalgebra.toIntermediateField' (Field.toIsField S) = S := by
ext
rfl
/-- Turn a subfield of `L` containing the image of `K` into an intermediate field. -/
def Subfield.toIntermediateField (S : Subfield L) (algebra_map_mem : ∀ x, algebraMap K L x ∈ S) :
IntermediateField K L :=
{ S with
algebraMap_mem' := algebra_map_mem }
@[simp]
theorem Subfield.toIntermediateField_toSubfield (S : Subfield L)
(algebra_map_mem : ∀ x, (algebraMap K L) x ∈ S) :
(S.toIntermediateField algebra_map_mem).toSubfield = S := rfl
@[simp]
theorem Subfield.coe_toIntermediateField (S : Subfield L)
(algebra_map_mem : ∀ x, (algebraMap K L) x ∈ S) :
((S.toIntermediateField algebra_map_mem) : Set L) = S := rfl
namespace IntermediateField
/-- An intermediate field inherits a field structure. -/
instance toField : Field S :=
S.toSubfield.toField
@[norm_cast]
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) :=
AddSubmonoidClass.coe_finset_sum f Finset.univ
@[norm_cast]
theorem coe_prod {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∏ i, f i) : L) = ∏ i, (f i : L) :=
SubmonoidClass.coe_finset_prod f Finset.univ
/-!
`IntermediateField`s inherit structure from their `Subfield` coercions.
-/
variable {X Y}
/-- The action by an intermediate field is the action by the underlying field. -/
instance [SMul L X] (F : IntermediateField K L) : SMul F X :=
inferInstanceAs (SMul F.toSubfield X)
theorem smul_def [SMul L X] {F : IntermediateField K L} (g : F) (m : X) : g • m = (g : L) • m :=
rfl
instance smulCommClass_left [SMul L Y] [SMul X Y] [SMulCommClass L X Y]
(F : IntermediateField K L) : SMulCommClass F X Y :=
inferInstanceAs (SMulCommClass F.toSubfield X Y)
instance smulCommClass_right [SMul X Y] [SMul L Y] [SMulCommClass X L Y]
(F : IntermediateField K L) : SMulCommClass X F Y :=
inferInstanceAs (SMulCommClass X F.toSubfield Y)
-- note: giving this instance the default priority may trigger trouble with synthesizing instances
-- for field extensions with more than one intermediate field. For example, in a field extension
-- `E/F`, and with `K₁ ≤ K₂` of type `IntermediateField F E`, this instance will cause a search
-- for `IsScalarTower K₁ K₂ E` to trigger a search for `IsScalarTower E K₂ E` which may
-- take a long time to fail.
/-- Note that this provides `IsScalarTower F K K` which is needed by `smul_mul_assoc`. -/
instance (priority := 900) [SMul X Y] [SMul L X] [SMul L Y] [IsScalarTower L X Y]
(F : IntermediateField K L) : IsScalarTower F X Y :=
inferInstanceAs (IsScalarTower F.toSubfield X Y)
instance [SMul L X] [FaithfulSMul L X] (F : IntermediateField K L) : FaithfulSMul F X :=
inferInstanceAs (FaithfulSMul F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [MulAction L X] (F : IntermediateField K L) : MulAction F X :=
inferInstanceAs (MulAction F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [AddMonoid X] [DistribMulAction L X] (F : IntermediateField K L) : DistribMulAction F X :=
inferInstanceAs (DistribMulAction F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [Monoid X] [MulDistribMulAction L X] (F : IntermediateField K L) :
MulDistribMulAction F X :=
inferInstanceAs (MulDistribMulAction F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [Zero X] [SMulWithZero L X] (F : IntermediateField K L) : SMulWithZero F X :=
inferInstanceAs (SMulWithZero F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [Zero X] [MulActionWithZero L X] (F : IntermediateField K L) : MulActionWithZero F X :=
inferInstanceAs (MulActionWithZero F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [AddCommMonoid X] [Module L X] (F : IntermediateField K L) : Module F X :=
inferInstanceAs (Module F.toSubfield X)
/-- The action by an intermediate field is the action by the underlying field. -/
instance [Semiring X] [MulSemiringAction L X] (F : IntermediateField K L) : MulSemiringAction F X :=
inferInstanceAs (MulSemiringAction F.toSubfield X)
/-! `IntermediateField`s inherit structure from their `Subalgebra` coercions. -/
instance toAlgebra : Algebra S L :=
inferInstanceAs (Algebra S.toSubalgebra L)
instance module' {R} [Semiring R] [SMul R K] [Module R L] [IsScalarTower R K L] : Module R S :=
inferInstanceAs (Module R S.toSubalgebra)
instance algebra' {R' K L : Type*} [Field K] [Field L] [Algebra K L] (S : IntermediateField K L)
[CommSemiring R'] [SMul R' K] [Algebra R' L] [IsScalarTower R' K L] : Algebra R' S :=
inferInstanceAs (Algebra R' S.toSubalgebra)
instance isScalarTower {R} [Semiring R] [SMul R K] [Module R L] [IsScalarTower R K L] :
IsScalarTower R K S :=
inferInstanceAs (IsScalarTower R K S.toSubalgebra)
@[simp]
theorem coe_smul {R} [SMul R K] [SMul R L] [IsScalarTower R K L] (r : R) (x : S) :
↑(r • x : S) = (r • (x : L)) :=
rfl
@[simp] lemma algebraMap_apply (x : S) : algebraMap S L x = x := rfl
@[simp] lemma coe_algebraMap_apply (x : K) : ↑(algebraMap K S x) = algebraMap K L x := rfl
instance isScalarTower_bot {R : Type*} [Semiring R] [Algebra L R] : IsScalarTower S L R :=
IsScalarTower.subalgebra _ _ _ S.toSubalgebra
instance isScalarTower_mid {R : Type*} [Semiring R] [Algebra L R] [Algebra K R]
[IsScalarTower K L R] : IsScalarTower K S R :=
IsScalarTower.subalgebra' _ _ _ S.toSubalgebra
/-- Specialize `isScalarTower_mid` to the common case where the top field is `L`. -/
instance isScalarTower_mid' : IsScalarTower K S L :=
inferInstance
instance {E} [Semiring E] [Algebra L E] : Algebra S E := inferInstanceAs (Algebra S.toSubalgebra E)
section shortcut_instances
variable {E} [Field E] [Algebra L E] (T : IntermediateField S E) {S}
instance : Algebra S T := T.algebra
instance : Module S T := Algebra.toModule
instance : SMul S T := Algebra.toSMul
instance [Algebra K E] [IsScalarTower K L E] : IsScalarTower K S T := T.isScalarTower
end shortcut_instances
/-- Given `f : L →ₐ[K] L'`, `S.comap f` is the intermediate field between `K` and `L`
such that `f x ∈ S ↔ x ∈ S.comap f`. -/
def comap (f : L →ₐ[K] L') (S : IntermediateField K L') : IntermediateField K L where
__ := S.toSubalgebra.comap f
inv_mem' x hx := show f x⁻¹ ∈ S by rw [map_inv₀ f x]; exact S.inv_mem hx
/-- Given `f : L →ₐ[K] L'`, `S.map f` is the intermediate field between `K` and `L'`
such that `x ∈ S ↔ f x ∈ S.map f`. -/
def map (f : L →ₐ[K] L') (S : IntermediateField K L) : IntermediateField K L' where
__ := S.toSubalgebra.map f
inv_mem' := by
rintro _ ⟨x, hx, rfl⟩
exact ⟨x⁻¹, S.inv_mem hx, map_inv₀ f x⟩
@[simp]
theorem coe_map (f : L →ₐ[K] L') : (S.map f : Set L') = f '' S :=
rfl
@[simp]
theorem toSubalgebra_map (f : L →ₐ[K] L') : (S.map f).toSubalgebra = S.toSubalgebra.map f :=
rfl
@[simp]
theorem toSubfield_map (f : L →ₐ[K] L') : (S.map f).toSubfield = S.toSubfield.map f :=
rfl
/-- Mapping intermediate fields along the identity does not change them. -/
theorem map_id : S.map (AlgHom.id K L) = S :=
SetLike.coe_injective <| Set.image_id _
theorem map_map {K L₁ L₂ L₃ : Type*} [Field K] [Field L₁] [Algebra K L₁] [Field L₂] [Algebra K L₂]
[Field L₃] [Algebra K L₃] (E : IntermediateField K L₁) (f : L₁ →ₐ[K] L₂) (g : L₂ →ₐ[K] L₃) :
(E.map f).map g = E.map (g.comp f) :=
SetLike.coe_injective <| Set.image_image _ _ _
theorem map_mono (f : L →ₐ[K] L') {S T : IntermediateField K L} (h : S ≤ T) :
S.map f ≤ T.map f :=
SetLike.coe_mono (Set.image_mono h)
theorem map_le_iff_le_comap {f : L →ₐ[K] L'}
{s : IntermediateField K L} {t : IntermediateField K L'} :
s.map f ≤ t ↔ s ≤ t.comap f :=
Set.image_subset_iff
theorem gc_map_comap (f : L →ₐ[K] L') : GaloisConnection (map f) (comap f) :=
fun _ _ ↦ map_le_iff_le_comap
/-- Given an equivalence `e : L ≃ₐ[K] L'` of `K`-field extensions and an intermediate
field `E` of `L/K`, `intermediateFieldMap e E` is the induced equivalence
between `E` and `E.map e`. -/
def intermediateFieldMap (e : L ≃ₐ[K] L') (E : IntermediateField K L) : E ≃ₐ[K] E.map e.toAlgHom :=
e.subalgebraMap E.toSubalgebra
theorem intermediateFieldMap_apply_coe (e : L ≃ₐ[K] L') (E : IntermediateField K L) (a : E) :
↑(intermediateFieldMap e E a) = e a :=
rfl
theorem intermediateFieldMap_symm_apply_coe (e : L ≃ₐ[K] L') (E : IntermediateField K L)
(a : E.map e.toAlgHom) : ↑((intermediateFieldMap e E).symm a) = e.symm a :=
rfl
end IntermediateField
namespace AlgHom
variable (f : L →ₐ[K] L')
/-- The range of an algebra homomorphism, as an intermediate field. -/
@[simps toSubalgebra]
def fieldRange : IntermediateField K L' :=
{ f.range, (f : L →+* L').fieldRange with }
@[simp]
theorem coe_fieldRange : ↑f.fieldRange = Set.range f :=
rfl
@[simp]
theorem fieldRange_toSubfield : f.fieldRange.toSubfield = (f : L →+* L').fieldRange :=
rfl
variable {f}
@[simp]
theorem mem_fieldRange {y : L'} : y ∈ f.fieldRange ↔ ∃ x, f x = y :=
Iff.rfl
end AlgHom
namespace IntermediateField
/-- The embedding from an intermediate field of `L / K` to `L`. -/
def val : S →ₐ[K] L :=
S.toSubalgebra.val
@[simp]
theorem coe_val : ⇑S.val = ((↑) : S → L) :=
rfl
@[simp]
theorem val_mk {x : L} (hx : x ∈ S) : S.val ⟨x, hx⟩ = x :=
rfl
theorem range_val : S.val.range = S.toSubalgebra :=
S.toSubalgebra.range_val
@[simp]
theorem fieldRange_val : S.val.fieldRange = S :=
SetLike.ext' Subtype.range_val
instance AlgHom.inhabited : Inhabited (S →ₐ[K] L) :=
⟨S.val⟩
theorem aeval_coe {R : Type*} [CommSemiring R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
(x : S) (P : R[X]) : aeval (x : L) P = aeval x P :=
aeval_algHom_apply (S.val.restrictScalars R) x P
/-- The map `E → F` when `E` is an intermediate field contained in the intermediate field `F`.
This is the intermediate field version of `Subalgebra.inclusion`. -/
def inclusion {E F : IntermediateField K L} (hEF : E ≤ F) : E →ₐ[K] F :=
Subalgebra.inclusion hEF
theorem inclusion_injective {E F : IntermediateField K L} (hEF : E ≤ F) :
Function.Injective (inclusion hEF) :=
Subalgebra.inclusion_injective hEF
@[simp]
theorem inclusion_self {E : IntermediateField K L} : inclusion (le_refl E) = AlgHom.id K E :=
Subalgebra.inclusion_self
@[simp]
theorem inclusion_inclusion {E F G : IntermediateField K L} (hEF : E ≤ F) (hFG : F ≤ G) (x : E) :
inclusion hFG (inclusion hEF x) = inclusion (le_trans hEF hFG) x :=
Subalgebra.inclusion_inclusion hEF hFG x
@[simp]
theorem coe_inclusion {E F : IntermediateField K L} (hEF : E ≤ F) (e : E) :
(inclusion hEF e : L) = e :=
rfl
variable {S}
theorem toSubalgebra_injective : Function.Injective (toSubalgebra : IntermediateField K L → _) := by
intro _ _ h
ext
simp_rw [← mem_toSubalgebra, h]
theorem toSubfield_injective : Function.Injective (toSubfield : IntermediateField K L → _) := by
intro _ _ h
ext
simp_rw [← mem_toSubfield, h]
variable {F E : IntermediateField K L}
@[simp]
theorem toSubalgebra_inj : F.toSubalgebra = E.toSubalgebra ↔ F = E := toSubalgebra_injective.eq_iff
@[simp]
theorem toSubfield_inj : F.toSubfield = E.toSubfield ↔ F = E := toSubfield_injective.eq_iff
theorem map_injective (f : L →ₐ[K] L') : Function.Injective (map f) := by
intro _ _ h
rwa [← toSubalgebra_injective.eq_iff, toSubalgebra_map, toSubalgebra_map,
(Subalgebra.map_injective f.injective).eq_iff, toSubalgebra_inj] at h
variable (S)
theorem set_range_subset : Set.range (algebraMap K L) ⊆ S :=
S.toSubalgebra.range_subset
theorem fieldRange_le : (algebraMap K L).fieldRange ≤ S.toSubfield := fun x hx =>
S.toSubalgebra.range_subset (by rwa [Set.mem_range, ← RingHom.mem_fieldRange])
@[simp]
theorem toSubalgebra_le_toSubalgebra {S S' : IntermediateField K L} :
S.toSubalgebra ≤ S'.toSubalgebra ↔ S ≤ S' :=
Iff.rfl
@[simp]
theorem toSubalgebra_lt_toSubalgebra {S S' : IntermediateField K L} :
S.toSubalgebra < S'.toSubalgebra ↔ S < S' :=
Iff.rfl
variable {S}
section Tower
/-- Lift an intermediate field of an intermediate field. -/
def lift {F : IntermediateField K L} (E : IntermediateField K F) : IntermediateField K L :=
E.map (val F)
theorem lift_injective (F : IntermediateField K L) : Function.Injective F.lift :=
map_injective F.val
@[simp]
theorem lift_inj {F : IntermediateField K L} (E E' : IntermediateField K F) :
lift E = lift E' ↔ E = E' :=
(lift_injective F).eq_iff
theorem lift_le {F : IntermediateField K L} (E : IntermediateField K F) : lift E ≤ F := by
rintro _ ⟨x, _, rfl⟩
exact x.2
theorem mem_lift {F : IntermediateField K L} {E : IntermediateField K F} (x : F) :
x.1 ∈ lift E ↔ x ∈ E :=
Subtype.val_injective.mem_set_image
/-- The algEquiv between an intermediate field and its lift. -/
def liftAlgEquiv {E : IntermediateField K L} (F : IntermediateField K E) : ↥F ≃ₐ[K] lift F where
toFun x := ⟨x.1.1, (mem_lift x.1).mpr x.2⟩
invFun x := ⟨⟨x.1, lift_le F x.2⟩, (mem_lift ⟨x.1, lift_le F x.2⟩).mp x.2⟩
left_inv := congrFun rfl
right_inv := congrFun rfl
map_mul' _ _ := rfl
map_add' _ _ := rfl
commutes' _ := rfl
lemma liftAlgEquiv_apply {E : IntermediateField K L} (F : IntermediateField K E) (x : F) :
(liftAlgEquiv F x).1 = x := rfl
section RestrictScalars
variable (K)
variable [Algebra L' L] [IsScalarTower K L' L]
/-- Given a tower `L / ↥E / L' / K` of field extensions, where `E` is an `L'`-intermediate field of
`L`, reinterpret `E` as a `K`-intermediate field of `L`. -/
def restrictScalars (E : IntermediateField L' L) : IntermediateField K L :=
{ E.toSubfield, E.toSubalgebra.restrictScalars K with
carrier := E.carrier }
@[simp]
theorem coe_restrictScalars {E : IntermediateField L' L} :
(restrictScalars K E : Set L) = (E : Set L) :=
rfl
@[simp]
theorem restrictScalars_toSubalgebra {E : IntermediateField L' L} :
(E.restrictScalars K).toSubalgebra = E.toSubalgebra.restrictScalars K :=
SetLike.coe_injective rfl
@[simp]
theorem restrictScalars_toSubfield {E : IntermediateField L' L} :
(E.restrictScalars K).toSubfield = E.toSubfield :=
SetLike.coe_injective rfl
@[simp]
theorem mem_restrictScalars {E : IntermediateField L' L} {x : L} :
x ∈ restrictScalars K E ↔ x ∈ E :=
Iff.rfl
theorem restrictScalars_injective :
Function.Injective (restrictScalars K : IntermediateField L' L → IntermediateField K L) :=
fun U V H => ext fun x => by rw [← mem_restrictScalars K, H, mem_restrictScalars]
@[simp]
theorem restrictScalars_inj {E E' : IntermediateField L' L} :
E.restrictScalars K = E'.restrictScalars K ↔ E = E' :=
(restrictScalars_injective K).eq_iff
end RestrictScalars
/-- This was formerly an instance called `lift2_alg`, but an instance above already provides it. -/
example {F : IntermediateField K L} {E : IntermediateField F L} : Algebra K E := by infer_instance
end Tower
section equivMap
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E]
{K : Type*} [Field K] [Algebra F K] (L : IntermediateField F E) (f : E →ₐ[F] K)
/-- Construct an algebra isomorphism from an equality of intermediate fields. -/
@[simps! apply]
def equivOfEq {S T : IntermediateField F E} (h : S = T) : S ≃ₐ[F] T :=
Subalgebra.equivOfEq _ _ (congr_arg toSubalgebra h)
@[simp]
theorem equivOfEq_symm {S T : IntermediateField F E} (h : S = T) :
(equivOfEq h).symm = equivOfEq h.symm :=
rfl
@[simp]
theorem equivOfEq_rfl (S : IntermediateField F E) : equivOfEq (rfl : S = S) = AlgEquiv.refl :=
AlgEquiv.ext fun _ ↦ rfl
@[simp]
theorem equivOfEq_trans {S T U : IntermediateField F E} (hST : S = T) (hTU : T = U) :
(equivOfEq hST).trans (equivOfEq hTU) = equivOfEq (hST.trans hTU) :=
rfl
theorem fieldRange_comp_val : (f.comp L.val).fieldRange = L.map f := toSubalgebra_injective <| by
rw [toSubalgebra_map, AlgHom.fieldRange_toSubalgebra, AlgHom.range_comp, range_val]
/-- An intermediate field is isomorphic to its image under an `AlgHom`
(which is automatically injective). -/
noncomputable def equivMap : L ≃ₐ[F] L.map f :=
(AlgEquiv.ofInjective _ (f.comp L.val).injective).trans (equivOfEq (fieldRange_comp_val L f))
@[simp]
theorem coe_equivMap_apply (x : L) : ↑(equivMap L f x) = f x := rfl
end equivMap
end IntermediateField
section ExtendScalars
namespace Subfield
variable {F E E' : Subfield L} (h : F ≤ E) (h' : F ≤ E') {x : L}
/-- If `F ≤ E` are two subfields of `L`, then `E` is also an intermediate field of
`L / F`. It can be viewed as an inverse to `IntermediateField.toSubfield`. -/
def extendScalars : IntermediateField F L := E.toIntermediateField fun ⟨_, hf⟩ ↦ h hf
@[simp]
theorem coe_extendScalars : (extendScalars h : Set L) = (E : Set L) := rfl
@[simp]
theorem extendScalars_toSubfield : (extendScalars h).toSubfield = E := SetLike.coe_injective rfl
@[simp]
theorem mem_extendScalars : x ∈ extendScalars h ↔ x ∈ E := Iff.rfl
theorem extendScalars_le_extendScalars_iff : extendScalars h ≤ extendScalars h' ↔ E ≤ E' := Iff.rfl
theorem extendScalars_le_iff (E' : IntermediateField F L) :
extendScalars h ≤ E' ↔ E ≤ E'.toSubfield := Iff.rfl
theorem le_extendScalars_iff (E' : IntermediateField F L) :
E' ≤ extendScalars h ↔ E'.toSubfield ≤ E := Iff.rfl
variable (F)
/-- `Subfield.extendScalars.orderIso` bundles `Subfield.extendScalars`
into an order isomorphism from
`{ E : Subfield L // F ≤ E }` to `IntermediateField F L`. Its inverse is
`IntermediateField.toSubfield`. -/
@[simps]
def extendScalars.orderIso :
{ E : Subfield L // F ≤ E } ≃o IntermediateField F L where
toFun E := extendScalars E.2
invFun E := ⟨E.toSubfield, fun x hx ↦ E.algebraMap_mem ⟨x, hx⟩⟩
map_rel_iff' {E E'} := by
simp only [Equiv.coe_fn_mk]
exact extendScalars_le_extendScalars_iff _ _
theorem extendScalars_injective :
Function.Injective fun E : { E : Subfield L // F ≤ E } ↦ extendScalars E.2 :=
(extendScalars.orderIso F).injective
end Subfield
namespace IntermediateField
variable {F E E' : IntermediateField K L} (h : F ≤ E) (h' : F ≤ E') {x : L}
/-- If `F ≤ E` are two intermediate fields of `L / K`, then `E` is also an intermediate field of
`L / F`. It can be viewed as an inverse to `IntermediateField.restrictScalars`. -/
def extendScalars : IntermediateField F L :=
Subfield.extendScalars (show F.toSubfield ≤ E.toSubfield from h)
@[simp]
theorem coe_extendScalars : (extendScalars h : Set L) = (E : Set L) := rfl
@[simp]
theorem extendScalars_toSubfield : (extendScalars h).toSubfield = E.toSubfield :=
SetLike.coe_injective rfl
@[simp]
theorem mem_extendScalars : x ∈ extendScalars h ↔ x ∈ E := Iff.rfl
@[simp]
theorem extendScalars_restrictScalars : (extendScalars h).restrictScalars K = E := rfl
theorem extendScalars_le_extendScalars_iff : extendScalars h ≤ extendScalars h' ↔ E ≤ E' := Iff.rfl
theorem extendScalars_le_iff (E' : IntermediateField F L) :
extendScalars h ≤ E' ↔ E ≤ E'.restrictScalars K := Iff.rfl
theorem le_extendScalars_iff (E' : IntermediateField F L) :
E' ≤ extendScalars h ↔ E'.restrictScalars K ≤ E := Iff.rfl
variable (F)
/-- `IntermediateField.extendScalars.orderIso` bundles `IntermediateField.extendScalars`
into an order isomorphism from
`{ E : IntermediateField K L // F ≤ E }` to `IntermediateField F L`. Its inverse is
`IntermediateField.restrictScalars`. -/
@[simps]
def extendScalars.orderIso : { E : IntermediateField K L // F ≤ E } ≃o IntermediateField F L where
toFun E := extendScalars E.2
invFun E := ⟨E.restrictScalars K, fun x hx ↦ E.algebraMap_mem ⟨x, hx⟩⟩
map_rel_iff' {E E'} := by
simp only [Equiv.coe_fn_mk]
exact extendScalars_le_extendScalars_iff _ _
theorem extendScalars_injective :
Function.Injective fun E : { E : IntermediateField K L // F ≤ E } ↦ extendScalars E.2 :=
(extendScalars.orderIso F).injective
end IntermediateField
end ExtendScalars
namespace IntermediateField
variable {S}
section Tower
section Restrict
variable {F E : IntermediateField K L} (h : F ≤ E)
/--
If `F ≤ E` are two intermediate fields of `L / K`, then `F` is also an intermediate field of
`E / K`. It is an inverse of `IntermediateField.lift`, and can be viewed as a dual to
`IntermediateField.extendScalars`.
-/
def restrict : IntermediateField K E :=
(IntermediateField.inclusion h).fieldRange
theorem mem_restrict (x : E) : x ∈ restrict h ↔ x.1 ∈ F :=
Set.ext_iff.mp (Set.range_inclusion h) x
@[simp]
theorem lift_restrict : lift (restrict h) = F := by
ext x
refine ⟨fun hx ↦ ?_, fun hx ↦ ?_⟩
· let y : E := ⟨x, lift_le (restrict h) hx⟩
exact (mem_restrict h y).1 ((mem_lift y).1 hx)
· let y : E := ⟨x, h hx⟩
exact (mem_lift y).2 ((mem_restrict h y).2 hx)
/--
`F` is equivalent to `F` as an intermediate field of `E / K`.
-/
noncomputable def restrict_algEquiv :
F ≃ₐ[K] ↥(IntermediateField.restrict h) :=
AlgEquiv.ofInjectiveField _
end Restrict
end Tower
end IntermediateField |
.lake/packages/mathlib/Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean | import Mathlib.Algebra.Algebra.Subalgebra.Directed
import Mathlib.Algebra.Algebra.Subalgebra.IsSimpleOrder
import Mathlib.FieldTheory.Separable
import Mathlib.FieldTheory.SplittingField.IsSplittingField
import Mathlib.LinearAlgebra.Dual.Lemmas
import Mathlib.RingTheory.Adjoin.Dimension
import Mathlib.RingTheory.TensorProduct.Finite
/-!
# Adjoining Elements to Fields
This file contains many results about adjoining elements to fields.
-/
open Module Polynomial
namespace IntermediateField
section
lemma restrictScalars_le_iff (K : Type*) {L E : Type*} [Field K] [Field L]
[Field E] [Algebra K L] [Algebra K E] [Algebra L E] [IsScalarTower K L E]
{E₁ E₂ : IntermediateField L E} : E₁.restrictScalars K ≤ E₂.restrictScalars K ↔ E₁ ≤ E₂ := .rfl
lemma FG.of_restrictScalars {K L E : Type*} [Field K] [Field L] [Field E]
[Algebra K L] [Algebra K E] [Algebra L E] [IsScalarTower K L E]
{E' : IntermediateField L E} (H : (E'.restrictScalars K).FG) : E'.FG := by
obtain ⟨s, hs⟩ := H
refine ⟨s, le_antisymm ?_ ?_⟩
· rw [adjoin_le_iff]
exact (subset_adjoin K _).trans_eq congr(($hs : Set E))
· rw [← restrictScalars_le_iff K, ← hs, adjoin_le_iff]
exact subset_adjoin L _
end
section AdjoinDef
variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] {S : Set E}
theorem mem_adjoin_range_iff {ι : Type*} (i : ι → E) (x : E) :
x ∈ adjoin F (Set.range i) ↔ ∃ r s : MvPolynomial ι F,
x = MvPolynomial.aeval i r / MvPolynomial.aeval i s := by
simp_rw [mem_adjoin_iff_div, Algebra.adjoin_range_eq_range_aeval,
AlgHom.mem_range, exists_exists_eq_and]
theorem mem_adjoin_iff (x : E) :
x ∈ adjoin F S ↔ ∃ r s : MvPolynomial S F,
x = MvPolynomial.aeval Subtype.val r / MvPolynomial.aeval Subtype.val s := by
rw [← mem_adjoin_range_iff, Subtype.range_coe]
theorem mem_adjoin_simple_iff {α : E} (x : E) :
x ∈ adjoin F {α} ↔ ∃ r s : F[X], x = aeval α r / aeval α s := by
simp only [mem_adjoin_iff_div, Algebra.adjoin_singleton_eq_range_aeval,
AlgHom.mem_range, exists_exists_eq_and]
variable {F}
section Supremum
variable {K L : Type*} [Field K] [Field L] [Algebra K L] (E1 E2 : IntermediateField K L)
instance finiteDimensional_sup [FiniteDimensional K E1] [FiniteDimensional K E2] :
FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
let g := Algebra.TensorProduct.productMap E1.val E2.val
suffices g.range = (E1 ⊔ E2).toSubalgebra by
have h : FiniteDimensional K (Subalgebra.toSubmodule g.range) :=
g.toLinearMap.finiteDimensional_range
rwa [this] at h
rw [Algebra.TensorProduct.productMap_range, E1.range_val, E2.range_val, sup_toSubalgebra_of_left]
/-- If `E1` and `E2` are intermediate fields, and at least one them are algebraic, then the rank of
the compositum of `E1` and `E2` is less than or equal to the product of that of `E1` and `E2`.
Note that this result is also true without algebraic assumption,
but the proof becomes very complicated. -/
theorem rank_sup_le_of_isAlgebraic
(halg : Algebra.IsAlgebraic K E1 ∨ Algebra.IsAlgebraic K E2) :
Module.rank K ↥(E1 ⊔ E2) ≤ Module.rank K E1 * Module.rank K E2 := by
have := E1.toSubalgebra.rank_sup_le_of_free E2.toSubalgebra
rwa [← sup_toSubalgebra_of_isAlgebraic E1 E2 halg] at this
/-- If `E1` and `E2` are intermediate fields, then the `Module.finrank` of
the compositum of `E1` and `E2` is less than or equal to the product of that of `E1` and `E2`. -/
theorem finrank_sup_le :
finrank K ↥(E1 ⊔ E2) ≤ finrank K E1 * finrank K E2 := by
by_cases h : FiniteDimensional K E1
· have := E1.toSubalgebra.finrank_sup_le_of_free E2.toSubalgebra
change _ ≤ finrank K E1 * finrank K E2 at this
rwa [← sup_toSubalgebra_of_left] at this
rw [FiniteDimensional, ← rank_lt_aleph0_iff, not_lt] at h
have := LinearMap.rank_le_of_injective _ <| Submodule.inclusion_injective <|
show Subalgebra.toSubmodule E1.toSubalgebra ≤ Subalgebra.toSubmodule (E1 ⊔ E2).toSubalgebra by
simp
rw [show finrank K E1 = 0 from Cardinal.toNat_apply_of_aleph0_le h,
show finrank K ↥(E1 ⊔ E2) = 0 from Cardinal.toNat_apply_of_aleph0_le (h.trans this), zero_mul]
variable {ι : Type*} {t : ι → IntermediateField K L}
theorem coe_iSup_of_directed [Nonempty ι] (dir : Directed (· ≤ ·) t) :
↑(iSup t) = ⋃ i, (t i : Set L) :=
let M : IntermediateField K L :=
{ __ := Subalgebra.copy _ _ (Subalgebra.coe_iSup_of_directed dir).symm
inv_mem' := fun _ hx ↦ have ⟨i, hi⟩ := Set.mem_iUnion.mp hx
Set.mem_iUnion.mpr ⟨i, (t i).inv_mem hi⟩ }
have : iSup t = M := le_antisymm
(iSup_le fun i ↦ le_iSup (fun i ↦ (t i : Set L)) i) (Set.iUnion_subset fun _ ↦ le_iSup t _)
this.symm ▸ rfl
theorem toSubalgebra_iSup_of_directed (dir : Directed (· ≤ ·) t) :
(iSup t).toSubalgebra = ⨆ i, (t i).toSubalgebra := by
cases isEmpty_or_nonempty ι
· simp_rw [iSup_of_empty, bot_toSubalgebra]
· exact SetLike.ext' ((coe_iSup_of_directed dir).trans (Subalgebra.coe_iSup_of_directed dir).symm)
instance finiteDimensional_iSup_of_finite [h : Finite ι] [∀ i, FiniteDimensional K (t i)] :
FiniteDimensional K (⨆ i, t i : IntermediateField K L) := by
rw [← iSup_univ]
induction Set.univ, Set.finite_univ (α := ι) using Set.Finite.induction_on with
| empty =>
rw [iSup_emptyset]
exact (botEquiv K L).symm.toLinearEquiv.finiteDimensional
| insert s hs =>
rw [iSup_insert]
exact IntermediateField.finiteDimensional_sup _ _
/-- See `finiteDimensional_iSup_of_finset'` for a stronger version,
that was the one used in mathlib3. -/
instance finiteDimensional_iSup_of_finset
{s : Finset ι} [∀ i, FiniteDimensional K (t i)] :
FiniteDimensional K (⨆ i ∈ s, t i : IntermediateField K L) :=
iSup_subtype'' s t ▸ IntermediateField.finiteDimensional_iSup_of_finite
theorem finiteDimensional_iSup_of_finset'
{s : Finset ι} (h : ∀ i ∈ s, FiniteDimensional K (t i)) :
FiniteDimensional K (⨆ i ∈ s, t i : IntermediateField K L) :=
have := Subtype.forall'.mp h
iSup_subtype'' s t ▸ IntermediateField.finiteDimensional_iSup_of_finite
/-- A compositum of splitting fields is a splitting field -/
theorem isSplittingField_iSup {p : ι → K[X]}
{s : Finset ι} (h0 : ∏ i ∈ s, p i ≠ 0) (h : ∀ i ∈ s, (p i).IsSplittingField K (t i)) :
(∏ i ∈ s, p i).IsSplittingField K (⨆ i ∈ s, t i : IntermediateField K L) := by
let F : IntermediateField K L := ⨆ i ∈ s, t i
have hF : ∀ i ∈ s, t i ≤ F := fun i hi ↦ le_iSup_of_le i (le_iSup (fun _ ↦ t i) hi)
simp only [isSplittingField_iff] at h ⊢
refine
⟨splits_prod (algebraMap K F) fun i hi ↦
splits_comp_of_splits (algebraMap K (t i)) (inclusion (hF i hi)).toRingHom
(h i hi).1,
?_⟩
simp only [rootSet_prod p s h0, ← Set.iSup_eq_iUnion, (@gc K _ L _ _).l_iSup₂]
exact iSup_congr fun i ↦ iSup_congr fun hi ↦ (h i hi).2
end Supremum
section Tower
variable (E)
variable {K : Type*} [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K]
/-- If `K / E / F` is a field extension tower, `L` is an intermediate field of `K / F`, such that
either `E / F` or `L / F` is algebraic, then `[E(L) : E] ≤ [L : F]`. A corollary of
`Subalgebra.adjoin_rank_le` since in this case `E(L) = E[L]`. -/
theorem adjoin_rank_le_of_isAlgebraic (L : IntermediateField F K)
(halg : Algebra.IsAlgebraic F E ∨ Algebra.IsAlgebraic F L) :
Module.rank E (adjoin E (L : Set K)) ≤ Module.rank F L := by
have h : (adjoin E (L.toSubalgebra : Set K)).toSubalgebra =
Algebra.adjoin E (L.toSubalgebra : Set K) :=
L.adjoin_toSubalgebra_of_isAlgebraic E halg
have := L.toSubalgebra.adjoin_rank_le E
rwa [(Subalgebra.equivOfEq _ _ h).symm.toLinearEquiv.rank_eq] at this
theorem adjoin_rank_le_of_isAlgebraic_left (L : IntermediateField F K)
[halg : Algebra.IsAlgebraic F E] :
Module.rank E (adjoin E (L : Set K)) ≤ Module.rank F L :=
adjoin_rank_le_of_isAlgebraic E L (Or.inl halg)
theorem adjoin_rank_le_of_isAlgebraic_right (L : IntermediateField F K)
[halg : Algebra.IsAlgebraic F L] :
Module.rank E (adjoin E (L : Set K)) ≤ Module.rank F L :=
adjoin_rank_le_of_isAlgebraic E L (Or.inr halg)
end Tower
open Set CompleteLattice
/-- Adjoining a single element is compact in the lattice of intermediate fields. -/
theorem adjoin_simple_isCompactElement (x : E) : IsCompactElement F⟮x⟯ := by
simp_rw [isCompactElement_iff_le_of_directed_sSup_le,
adjoin_simple_le_iff, sSup_eq_iSup', ← exists_prop]
intro s hne hs hx
have := hne.to_subtype
rwa [← SetLike.mem_coe, coe_iSup_of_directed hs.directed_val, mem_iUnion, Subtype.exists] at hx
/-- Adjoining a finite subset is compact in the lattice of intermediate fields. -/
theorem adjoin_finset_isCompactElement (S : Finset E) :
IsCompactElement (adjoin F S : IntermediateField F E) := by
rw [← biSup_adjoin_simple]
simp_rw [Finset.mem_coe, ← Finset.sup_eq_iSup]
exact isCompactElement_finsetSup S fun x _ => adjoin_simple_isCompactElement x
/-- Adjoining a finite subset is compact in the lattice of intermediate fields. -/
theorem adjoin_finite_isCompactElement {S : Set E} (h : S.Finite) : IsCompactElement (adjoin F S) :=
Finite.coe_toFinset h ▸ adjoin_finset_isCompactElement h.toFinset
/-- The lattice of intermediate fields is compactly generated. -/
instance : IsCompactlyGenerated (IntermediateField F E) :=
⟨fun s =>
⟨(fun x => F⟮x⟯) '' s,
⟨by rintro t ⟨x, _, rfl⟩; exact adjoin_simple_isCompactElement x,
sSup_image.trans <| (biSup_adjoin_simple _).trans <|
le_antisymm (adjoin_le_iff.mpr le_rfl) <| subset_adjoin F (s : Set E)⟩⟩⟩
theorem exists_finset_of_mem_iSup {ι : Type*} {f : ι → IntermediateField F E} {x : E}
(hx : x ∈ ⨆ i, f i) : ∃ s : Finset ι, x ∈ ⨆ i ∈ s, f i := by
have := (adjoin_simple_isCompactElement x).exists_finset_of_le_iSup (IntermediateField F E) f
simp only [adjoin_simple_le_iff] at this
exact this hx
theorem exists_finset_of_mem_supr' {ι : Type*} {f : ι → IntermediateField F E} {x : E}
(hx : x ∈ ⨆ i, f i) : ∃ s : Finset (Σ i, f i), x ∈ ⨆ i ∈ s, F⟮(i.2 : E)⟯ := by
refine exists_finset_of_mem_iSup (SetLike.le_def.mp (iSup_le fun i x h ↦ ?_) hx)
exact SetLike.le_def.mp (le_iSup_of_le ⟨i, x, h⟩ (by simp)) (mem_adjoin_simple_self F x)
theorem exists_finset_of_mem_supr'' {ι : Type*} {f : ι → IntermediateField F E}
(h : ∀ i, Algebra.IsAlgebraic F (f i)) {x : E} (hx : x ∈ ⨆ i, f i) :
∃ s : Finset (Σ i, f i), x ∈ ⨆ i ∈ s, adjoin F ((minpoly F (i.2 :)).rootSet E) := by
refine exists_finset_of_mem_iSup (SetLike.le_def.mp (iSup_le (fun i x1 hx1 => ?_)) hx)
refine SetLike.le_def.mp (le_iSup_of_le ⟨i, x1, hx1⟩ ?_)
(subset_adjoin F (rootSet (minpoly F x1) E) ?_)
· rw [IntermediateField.minpoly_eq, Subtype.coe_mk]
· rw [mem_rootSet_of_ne, minpoly.aeval]
exact minpoly.ne_zero (isIntegral_iff.mp (Algebra.IsIntegral.isIntegral (⟨x1, hx1⟩ : f i)))
theorem exists_finset_of_mem_adjoin {S : Set E} {x : E} (hx : x ∈ adjoin F S) :
∃ T : Finset E, (T : Set E) ⊆ S ∧ x ∈ adjoin F (T : Set E) := by
simp_rw [← biSup_adjoin_simple S, ← iSup_subtype''] at hx
obtain ⟨s, hx'⟩ := exists_finset_of_mem_iSup hx
classical
refine ⟨s.image Subtype.val, by simp, SetLike.le_def.mp ?_ hx'⟩
simp_rw [Finset.coe_image, iSup_le_iff, adjoin_le_iff]
rintro _ h _ rfl
exact subset_adjoin F _ ⟨_, h, rfl⟩
end AdjoinDef
section AdjoinIntermediateFieldLattice
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] {α : E} {S : Set E}
section AdjoinRank
open Module Module
variable {K L : IntermediateField F E}
@[simp]
theorem rank_eq_one_iff : Module.rank F K = 1 ↔ K = ⊥ := by
rw [← toSubalgebra_inj, ← rank_eq_rank_subalgebra, Subalgebra.rank_eq_one_iff,
bot_toSubalgebra]
@[simp]
theorem finrank_eq_one_iff : finrank F K = 1 ↔ K = ⊥ := by
rw [← toSubalgebra_inj, ← finrank_eq_finrank_subalgebra, Subalgebra.finrank_eq_one_iff,
bot_toSubalgebra]
@[simp]
protected theorem rank_bot : Module.rank F (⊥ : IntermediateField F E) = 1 := by
rw [rank_eq_one_iff]
@[simp]
protected theorem finrank_bot : finrank F (⊥ : IntermediateField F E) = 1 := by
rw [finrank_eq_one_iff]
@[simp] theorem rank_bot' : Module.rank (⊥ : IntermediateField F E) E = Module.rank F E := by
rw [← rank_mul_rank F (⊥ : IntermediateField F E) E, IntermediateField.rank_bot, one_mul]
@[simp] theorem finrank_bot' : finrank (⊥ : IntermediateField F E) E = finrank F E :=
congr(Cardinal.toNat $(rank_bot'))
@[simp] protected theorem rank_top : Module.rank (⊤ : IntermediateField F E) E = 1 :=
Subalgebra.bot_eq_top_iff_rank_eq_one.mp <| top_le_iff.mp fun x _ ↦ ⟨⟨x, trivial⟩, rfl⟩
@[simp] protected theorem finrank_top : finrank (⊤ : IntermediateField F E) E = 1 :=
rank_eq_one_iff_finrank_eq_one.mp IntermediateField.rank_top
@[simp] theorem rank_top' : Module.rank F (⊤ : IntermediateField F E) = Module.rank F E :=
rank_top F E
@[simp] theorem finrank_top' : finrank F (⊤ : IntermediateField F E) = finrank F E :=
finrank_top F E
lemma finrank_eq_one_iff_eq_top {K : IntermediateField F E} :
Module.finrank K E = 1 ↔ K = ⊤ := by
refine ⟨?_, (· ▸ IntermediateField.finrank_top)⟩
rw [← Subalgebra.bot_eq_top_iff_finrank_eq_one, ← top_le_iff, ← top_le_iff]
intro H x _
obtain ⟨x, rfl⟩ := @H x IntermediateField.mem_top
exact x.2
theorem bot_eq_top_iff_finrank_eq_one :
(⊥ : IntermediateField F E) = ⊤ ↔ Module.finrank F E = 1 := by
rw [← IntermediateField.finrank_bot', ← finrank_eq_one_iff_eq_top]
variable (F E) in
theorem isSimpleOrder_of_finrank_prime (hp : Nat.Prime (Module.finrank F E)) :
IsSimpleOrder (IntermediateField F E) := by
refine { toNontrivial := ?_, eq_bot_or_eq_top := ?_ }
· exact ⟨⊥, ⊤, fun h ↦ Nat.prime_one_false (bot_eq_top_iff_finrank_eq_one.mp h ▸ hp)⟩
· intro K
simpa [← toSubalgebra_strictMono.apply_eq_bot_iff, ← toSubalgebra_strictMono.apply_eq_top_iff]
using (Subalgebra.isSimpleOrder_of_finrank_prime _ _ hp).eq_bot_or_eq_top K.toSubalgebra
theorem rank_adjoin_eq_one_iff : Module.rank F (adjoin F S) = 1 ↔ S ⊆ (⊥ : IntermediateField F E) :=
Iff.trans rank_eq_one_iff adjoin_eq_bot_iff
theorem rank_adjoin_simple_eq_one_iff :
Module.rank F F⟮α⟯ = 1 ↔ α ∈ (⊥ : IntermediateField F E) := by
rw [rank_adjoin_eq_one_iff]; exact Set.singleton_subset_iff
theorem finrank_adjoin_eq_one_iff : finrank F (adjoin F S) = 1 ↔ S ⊆ (⊥ : IntermediateField F E) :=
Iff.trans finrank_eq_one_iff adjoin_eq_bot_iff
theorem finrank_adjoin_simple_eq_one_iff :
finrank F F⟮α⟯ = 1 ↔ α ∈ (⊥ : IntermediateField F E) := by
rw [finrank_adjoin_eq_one_iff]; exact Set.singleton_subset_iff
/-- If `F⟮x⟯` has dimension `1` over `F` for every `x ∈ E` then `F = E`. -/
theorem bot_eq_top_of_rank_adjoin_eq_one (h : ∀ x : E, Module.rank F F⟮x⟯ = 1) :
(⊥ : IntermediateField F E) = ⊤ := by
ext y
rw [iff_true_right IntermediateField.mem_top]
exact rank_adjoin_simple_eq_one_iff.mp (h y)
theorem bot_eq_top_of_finrank_adjoin_eq_one (h : ∀ x : E, finrank F F⟮x⟯ = 1) :
(⊥ : IntermediateField F E) = ⊤ := by
ext y
rw [iff_true_right IntermediateField.mem_top]
exact finrank_adjoin_simple_eq_one_iff.mp (h y)
theorem subsingleton_of_rank_adjoin_eq_one (h : ∀ x : E, Module.rank F F⟮x⟯ = 1) :
Subsingleton (IntermediateField F E) :=
subsingleton_of_bot_eq_top (bot_eq_top_of_rank_adjoin_eq_one h)
theorem subsingleton_of_finrank_adjoin_eq_one (h : ∀ x : E, finrank F F⟮x⟯ = 1) :
Subsingleton (IntermediateField F E) :=
subsingleton_of_bot_eq_top (bot_eq_top_of_finrank_adjoin_eq_one h)
/-- If `F⟮x⟯` has dimension `≤1` over `F` for every `x ∈ E` then `F = E`. -/
theorem bot_eq_top_of_finrank_adjoin_le_one [FiniteDimensional F E]
(h : ∀ x : E, finrank F F⟮x⟯ ≤ 1) : (⊥ : IntermediateField F E) = ⊤ := by
apply bot_eq_top_of_finrank_adjoin_eq_one
exact fun x => by linarith [h x, show 0 < finrank F F⟮x⟯ from finrank_pos]
theorem subsingleton_of_finrank_adjoin_le_one [FiniteDimensional F E]
(h : ∀ x : E, finrank F F⟮x⟯ ≤ 1) : Subsingleton (IntermediateField F E) :=
subsingleton_of_bot_eq_top (bot_eq_top_of_finrank_adjoin_le_one h)
end AdjoinRank
end AdjoinIntermediateFieldLattice
section AdjoinIntegralElement
universe u
variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] {α : E}
variable {K : Type u} [Field K] [Algebra F K]
theorem minpoly_gen (α : E) :
minpoly F (AdjoinSimple.gen F α) = minpoly F α := by
rw [← minpoly.algebraMap_eq (algebraMap F⟮α⟯ E).injective, AdjoinSimple.algebraMap_gen]
theorem aeval_gen_minpoly (α : E) : aeval (AdjoinSimple.gen F α) (minpoly F α) = 0 := by
ext
convert minpoly.aeval F α
conv in aeval α => rw [← AdjoinSimple.algebraMap_gen F α]
exact (aeval_algebraMap_apply E (AdjoinSimple.gen F α) _).symm
/-- algebra isomorphism between `AdjoinRoot` and `F⟮α⟯` -/
@[stacks 09G1 "Algebraic case"]
noncomputable def adjoinRootEquivAdjoin (h : IsIntegral F α) :
AdjoinRoot (minpoly F α) ≃ₐ[F] F⟮α⟯ :=
AlgEquiv.ofBijective
(AdjoinRoot.liftAlgHom (minpoly F α) _ (AdjoinSimple.gen F α) (aeval_gen_minpoly F α))
(by
set f := AdjoinRoot.lift _ _ (aeval_gen_minpoly F α :)
haveI := Fact.mk (minpoly.irreducible h)
constructor
· exact RingHom.injective f
· suffices F⟮α⟯.toSubfield ≤ RingHom.fieldRange (F⟮α⟯.toSubfield.subtype.comp f) by
intro x
obtain ⟨y, hy⟩ := this (Subtype.mem x)
exact ⟨y, Subtype.ext hy⟩
refine Subfield.closure_le.mpr (Set.union_subset (fun x hx => ?_) ?_)
· obtain ⟨y, hy⟩ := hx
refine ⟨y, ?_⟩
rw [RingHom.comp_apply]
dsimp only [coe_type_toSubfield]
rw [AdjoinRoot.lift_of (aeval_gen_minpoly F α)]
exact hy
· refine Set.singleton_subset_iff.mpr ⟨AdjoinRoot.root (minpoly F α), ?_⟩
rw [RingHom.comp_apply]
dsimp only [coe_type_toSubfield]
rw [AdjoinRoot.lift_root (aeval_gen_minpoly F α)]
rfl)
theorem adjoinRootEquivAdjoin_apply_root (h : IsIntegral F α) :
adjoinRootEquivAdjoin F h (AdjoinRoot.root (minpoly F α)) = AdjoinSimple.gen F α :=
AdjoinRoot.lift_root (aeval_gen_minpoly F α)
@[simp]
theorem adjoinRootEquivAdjoin_symm_apply_gen (h : IsIntegral F α) :
(adjoinRootEquivAdjoin F h).symm (AdjoinSimple.gen F α) = AdjoinRoot.root (minpoly F α) := by
rw [AlgEquiv.symm_apply_eq, adjoinRootEquivAdjoin_apply_root]
theorem adjoin_root_eq_top (p : K[X]) [Fact (Irreducible p)] : K⟮AdjoinRoot.root p⟯ = ⊤ :=
(eq_adjoin_of_eq_algebra_adjoin K _ ⊤ (AdjoinRoot.adjoinRoot_eq_top (f := p)).symm).symm
section PowerBasis
variable {L : Type*} [Field L] [Algebra K L]
/-- The elements `1, x, ..., x ^ (d - 1)` form a basis for `K⟮x⟯`,
where `d` is the degree of the minimal polynomial of `x`. -/
noncomputable def powerBasisAux {x : L} (hx : IsIntegral K x) :
Basis (Fin (minpoly K x).natDegree) K K⟮x⟯ :=
(AdjoinRoot.powerBasis (minpoly.ne_zero hx)).basis
|>.map (adjoinRootEquivAdjoin K hx).toLinearEquiv
|>.reindex (finCongr rfl)
/-- The power basis `1, x, ..., x ^ (d - 1)` for `K⟮x⟯`,
where `d` is the degree of the minimal polynomial of `x`. -/
@[simps]
noncomputable def adjoin.powerBasis {x : L} (hx : IsIntegral K x) : PowerBasis K K⟮x⟯ where
gen := AdjoinSimple.gen K x
dim := (minpoly K x).natDegree
basis := powerBasisAux hx
basis_eq_pow i := by
rw [powerBasisAux, Basis.reindex_apply, Basis.map_apply, PowerBasis.basis_eq_pow,
finCongr_symm, finCongr_apply, Fin.cast_eq_self, AlgEquiv.toLinearEquiv_apply,
map_pow, AdjoinRoot.powerBasis_gen, adjoinRootEquivAdjoin_apply_root]
theorem adjoin.finiteDimensional {x : L} (hx : IsIntegral K x) : FiniteDimensional K K⟮x⟯ :=
(adjoin.powerBasis hx).finite
theorem isAlgebraic_adjoin_simple {x : L} (hx : IsIntegral K x) : Algebra.IsAlgebraic K K⟮x⟯ :=
have := adjoin.finiteDimensional hx; Algebra.IsAlgebraic.of_finite K K⟮x⟯
/-- If `x` is an algebraic element of field `K`, then its minimal polynomial has degree
`[K(x) : K]`. -/
@[stacks 09GN]
theorem adjoin.finrank {x : L} (hx : IsIntegral K x) :
Module.finrank K K⟮x⟯ = (minpoly K x).natDegree := by
rw [PowerBasis.finrank (adjoin.powerBasis hx :)]
rfl
/-- If `K / E / F` is a field extension tower, `S ⊂ K` is such that `F(S) = K`,
then `E(S) = K`. -/
theorem adjoin_eq_top_of_adjoin_eq_top [Algebra E K] [IsScalarTower F E K]
{S : Set K} (hprim : adjoin F S = ⊤) : adjoin E S = ⊤ :=
restrictScalars_injective F <| by
rw [restrictScalars_top, ← top_le_iff, ← hprim, adjoin_le_iff,
coe_restrictScalars, ← adjoin_le_iff]
/-- If `E / F` is a finite extension such that `E = F(α)`, then for any intermediate field `K`, the
`F` adjoin the coefficients of `minpoly K α` is equal to `K` itself. -/
theorem adjoin_minpoly_coeff_of_exists_primitive_element
[FiniteDimensional F E] (hprim : adjoin F {α} = ⊤) (K : IntermediateField F E) :
adjoin F ((minpoly K α).map (algebraMap K E)).coeffs = K := by
set g := (minpoly K α).map (algebraMap K E)
set K' : IntermediateField F E := adjoin F g.coeffs
have hsub : K' ≤ K := by
refine adjoin_le_iff.mpr fun x ↦ ?_
rw [Finset.mem_coe, mem_coeffs_iff]
rintro ⟨n, -, rfl⟩
rw [coeff_map]
apply Subtype.mem
have dvd_g : minpoly K' α ∣ g.toSubring K'.toSubring (subset_adjoin F _) := by
apply minpoly.dvd
rw [aeval_def, eval₂_eq_eval_map]
erw [g.map_toSubring K'.toSubring]
rw [eval_map, ← aeval_def]
exact minpoly.aeval K α
have finrank_eq : ∀ K : IntermediateField F E, finrank K E = natDegree (minpoly K α) := by
intro K
have := adjoin.finrank (.of_finite K α)
rw [adjoin_eq_top_of_adjoin_eq_top F hprim] at this
simp_all
refine eq_of_le_of_finrank_le' hsub ?_
simp_rw [finrank_eq]
convert natDegree_le_of_dvd dvd_g
((g.monic_toSubring _ _).mpr <| (minpoly.monic <| .of_finite K α).map _).ne_zero using 1
rw [natDegree_toSubring, natDegree_map]
instance : Module.Finite F (⊥ : IntermediateField F E) := Subalgebra.finite_bot
variable {F} in
/-- If `E / F` is an infinite algebraic extension, then there exists an intermediate field
`L / F` with arbitrarily large finite extension degree. -/
theorem exists_lt_finrank_of_infinite_dimensional
[Algebra.IsAlgebraic F E] (hnfd : ¬ FiniteDimensional F E) (n : ℕ) :
∃ L : IntermediateField F E, FiniteDimensional F L ∧ n < finrank F L := by
induction n with
| zero => exact ⟨⊥, Subalgebra.finite_bot, finrank_pos⟩
| succ n ih =>
obtain ⟨L, fin, hn⟩ := ih
obtain ⟨x, hx⟩ : ∃ x : E, x ∉ L := by
contrapose! hnfd
rw [show L = ⊤ from eq_top_iff.2 fun x _ ↦ hnfd x] at fin
exact topEquiv.toLinearEquiv.finiteDimensional
let L' := L ⊔ F⟮x⟯
haveI := adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral (R := F) x)
refine ⟨L', inferInstance, by_contra fun h ↦ ?_⟩
have h1 : L = L' := eq_of_le_of_finrank_le le_sup_left ((not_lt.1 h).trans hn)
have h2 : F⟮x⟯ ≤ L' := le_sup_right
exact hx <| (h1.symm ▸ h2) <| mem_adjoin_simple_self F x
theorem _root_.minpoly.natDegree_le (x : L) [FiniteDimensional K L] :
(minpoly K x).natDegree ≤ finrank K L :=
le_of_eq_of_le (IntermediateField.adjoin.finrank (.of_finite _ _)).symm
K⟮x⟯.toSubmodule.finrank_le
theorem _root_.minpoly.degree_le (x : L) [FiniteDimensional K L] :
(minpoly K x).degree ≤ finrank K L :=
degree_le_of_natDegree_le (minpoly.natDegree_le x)
/-- If `x : L` is an integral element in a field extension `L` over `K`, then the degree of the
minimal polynomial of `x` over `K` divides `[L : K]`. -/
theorem _root_.minpoly.degree_dvd {x : L} (hx : IsIntegral K x) :
(minpoly K x).natDegree ∣ finrank K L := by
rw [dvd_iff_exists_eq_mul_left, ← IntermediateField.adjoin.finrank hx]
use finrank K⟮x⟯ L
rw [mul_comm, finrank_mul_finrank]
-- TODO: generalize to `Sort`
/-- A compositum of algebraic extensions is algebraic -/
theorem isAlgebraic_iSup {ι : Type*} {t : ι → IntermediateField K L}
(h : ∀ i, Algebra.IsAlgebraic K (t i)) :
Algebra.IsAlgebraic K (⨆ i, t i : IntermediateField K L) := by
constructor
rintro ⟨x, hx⟩
obtain ⟨s, hx⟩ := exists_finset_of_mem_supr' hx
rw [isAlgebraic_iff, Subtype.coe_mk, ← Subtype.coe_mk (p := (· ∈ _)) x hx, ← isAlgebraic_iff]
haveI : ∀ i : Σ i, t i, FiniteDimensional K K⟮(i.2 : L)⟯ := fun ⟨i, x⟩ ↦
adjoin.finiteDimensional (isIntegral_iff.1 (Algebra.IsIntegral.isIntegral x))
apply IsAlgebraic.of_finite
theorem isAlgebraic_adjoin {S : Set L} (hS : ∀ x ∈ S, IsIntegral K x) :
Algebra.IsAlgebraic K (adjoin K S) := by
rw [← biSup_adjoin_simple, ← iSup_subtype'']
exact isAlgebraic_iSup fun x ↦ isAlgebraic_adjoin_simple (hS x x.2)
/-- If `L / K` is a field extension, `S` is a finite subset of `L`, such that every element of `S`
is integral (= algebraic) over `K`, then `K(S) / K` is a finite extension.
A direct corollary of `finiteDimensional_iSup_of_finite`. -/
theorem finiteDimensional_adjoin {S : Set L} [Finite S] (hS : ∀ x ∈ S, IsIntegral K x) :
FiniteDimensional K (adjoin K S) := by
rw [← biSup_adjoin_simple, ← iSup_subtype'']
haveI (x : S) := adjoin.finiteDimensional (hS x.1 x.2)
exact finiteDimensional_iSup_of_finite
end PowerBasis
/-- Algebra homomorphism `F⟮α⟯ →ₐ[F] K` are in bijection with the set of roots
of `minpoly α` in `K`. -/
noncomputable def algHomAdjoinIntegralEquiv (h : IsIntegral F α) :
(F⟮α⟯ →ₐ[F] K) ≃ { x // x ∈ (minpoly F α).aroots K } :=
(adjoin.powerBasis h).liftEquiv'.trans
((Equiv.refl _).subtypeEquiv fun x => by
rw [adjoin.powerBasis_gen, minpoly_gen, Equiv.refl_apply])
lemma algHomAdjoinIntegralEquiv_symm_apply_gen (h : IsIntegral F α)
(x : { x // x ∈ (minpoly F α).aroots K }) :
(algHomAdjoinIntegralEquiv F h).symm x (AdjoinSimple.gen F α) = x :=
(adjoin.powerBasis h).lift_gen x.val <| by
rw [adjoin.powerBasis_gen, minpoly_gen]; exact (mem_aroots.mp x.2).2
/-- Fintype of algebra homomorphism `F⟮α⟯ →ₐ[F] K` -/
noncomputable def fintypeOfAlgHomAdjoinIntegral (h : IsIntegral F α) : Fintype (F⟮α⟯ →ₐ[F] K) :=
PowerBasis.AlgHom.fintype (adjoin.powerBasis h)
theorem card_algHom_adjoin_integral (h : IsIntegral F α) (h_sep : IsSeparable F α)
(h_splits : (minpoly F α).Splits (algebraMap F K)) :
Nat.card (F⟮α⟯ →ₐ[F] K) = (minpoly F α).natDegree := by
let _ : Fintype (F⟮α⟯ →ₐ[F] K) := fintypeOfAlgHomAdjoinIntegral F h
rw [Nat.card_eq_fintype_card, AlgHom.card_of_powerBasis] <;>
simp only [IsSeparable, adjoin.powerBasis_dim, adjoin.powerBasis_gen, minpoly_gen, h_splits]
exact h_sep
-- Apparently `K⟮root f⟯ →+* K⟮root f⟯` is expensive to unify during instance synthesis.
open Module AdjoinRoot in
/-- Let `f, g` be monic polynomials over `K`. If `f` is irreducible, and `g(x) - α` is irreducible
in `K⟮α⟯` with `α` a root of `f`, then `f(g(x))` is irreducible. -/
theorem _root_.Polynomial.irreducible_comp {f g : K[X]} (hfm : f.Monic) (hgm : g.Monic)
(hf : Irreducible f)
(hg : ∀ (E : Type u) [Field E] [Algebra K E] (x : E) (_ : minpoly K x = f),
Irreducible (g.map (algebraMap _ _) - C (AdjoinSimple.gen K x))) :
Irreducible (f.comp g) := by
have hf' : natDegree f ≠ 0 :=
fun e ↦ not_irreducible_C (f.coeff 0) (eq_C_of_natDegree_eq_zero e ▸ hf)
have hg' : natDegree g ≠ 0 := by
have := Fact.mk hf
intro e
apply not_irreducible_C ((g.map (algebraMap _ _)).coeff 0 - AdjoinSimple.gen K (root f))
-- Needed to specialize `map_sub` to avoid a timeout https://github.com/leanprover-community/mathlib4/pull/8386
rw [RingHom.map_sub, coeff_map, ← map_C, ← eq_C_of_natDegree_eq_zero e]
apply hg (AdjoinRoot f)
rw [AdjoinRoot.minpoly_root hf.ne_zero, hfm, inv_one, map_one, mul_one]
have H₁ : f.comp g ≠ 0 := fun h ↦ by simpa [hf', hg', natDegree_comp] using congr_arg natDegree h
have H₂ : ¬ IsUnit (f.comp g) := fun h ↦
by simpa [hf', hg', natDegree_comp] using natDegree_eq_zero_of_isUnit h
have ⟨p, hp₁, hp₂⟩ := WfDvdMonoid.exists_irreducible_factor H₂ H₁
suffices natDegree p = natDegree f * natDegree g from (associated_of_dvd_of_natDegree_le hp₂ H₁
(this.trans natDegree_comp.symm).ge).irreducible hp₁
have := Fact.mk hp₁
let Kx := AdjoinRoot p
letI := (AdjoinRoot.powerBasis hp₁.ne_zero).finite
have key₁ : f = minpoly K (aeval (root p) g) := by
refine minpoly.eq_of_irreducible_of_monic hf ?_ hfm
rw [← aeval_comp]
exact aeval_eq_zero_of_dvd_aeval_eq_zero hp₂ (AdjoinRoot.eval₂_root p)
have key₁' : finrank K K⟮aeval (root p) g⟯ = natDegree f := by
rw [adjoin.finrank, ← key₁]
exact IsIntegral.of_finite _ _
have key₂ : g.map (algebraMap _ _) - C (AdjoinSimple.gen K (aeval (root p) g)) =
minpoly K⟮aeval (root p) g⟯ (root p) :=
minpoly.eq_of_irreducible_of_monic (hg _ _ key₁.symm) (by simp [AdjoinSimple.gen])
(Monic.sub_of_left (hgm.map _) (degree_lt_degree (by simpa [Nat.pos_iff_ne_zero] using hg')))
have key₂' : finrank K⟮aeval (root p) g⟯ Kx = natDegree g := by
trans natDegree (minpoly K⟮aeval (root p) g⟯ (root p))
· have : K⟮aeval (root p) g⟯⟮root p⟯ = ⊤ := by
apply restrictScalars_injective K
rw [restrictScalars_top, adjoin_adjoin_left, Set.union_comm, ← adjoin_adjoin_left,
adjoin_root_eq_top p, restrictScalars_adjoin]
simp
rw [← finrank_top', ← this, adjoin.finrank]
exact IsIntegral.of_finite _ _
· simp [← key₂]
have := Module.finrank_mul_finrank K K⟮aeval (root p) g⟯ Kx
rwa [key₁', key₂', (AdjoinRoot.powerBasis hp₁.ne_zero).finrank, powerBasis_dim, eq_comm] at this
end AdjoinIntegralElement
end IntermediateField
namespace minpoly
variable {K L : Type*} [Field K] [Field L] [Algebra K L]
open AlgEquiv IntermediateField
/-- If `y : L` is a root of `minpoly K x`, then `minpoly K y = minpoly K x`. -/
theorem eq_of_root {x y : L} (hx : IsAlgebraic K x)
(h_ev : Polynomial.aeval y (minpoly K x) = 0) : minpoly K y = minpoly K x :=
((eq_iff_aeval_minpoly_eq_zero hx.isIntegral).mpr h_ev).symm
/-- The canonical `algEquiv` between `K⟮x⟯`and `K⟮y⟯`, sending `x` to `y`, where `x` and `y` have
the same minimal polynomial over `K`. -/
noncomputable def algEquiv {x y : L} (hx : IsAlgebraic K x)
(h_mp : minpoly K x = minpoly K y) : K⟮x⟯ ≃ₐ[K] K⟮y⟯ := by
have hy : IsAlgebraic K y := ⟨minpoly K x, ne_zero hx.isIntegral, (h_mp ▸ aeval _ _)⟩
exact AlgEquiv.trans (adjoinRootEquivAdjoin K hx.isIntegral).symm
(AlgEquiv.trans (AdjoinRoot.algEquivOfEq _ _ h_mp)
(adjoinRootEquivAdjoin K hy.isIntegral))
/-- `minpoly.algEquiv` sends the generator of `K⟮x⟯` to the generator of `K⟮y⟯`. -/
theorem algEquiv_apply {x y : L} (hx : IsAlgebraic K x) (h_mp : minpoly K x = minpoly K y) :
algEquiv hx h_mp (AdjoinSimple.gen K x) = AdjoinSimple.gen K y := by
have hy : IsAlgebraic K y := ⟨minpoly K x, ne_zero hx.isIntegral, (h_mp ▸ aeval _ _)⟩
rw [algEquiv, trans_apply, ← adjoinRootEquivAdjoin_apply_root K hx.isIntegral,
symm_apply_apply, trans_apply, AdjoinRoot.algEquivOfEq_root,
adjoinRootEquivAdjoin_apply_root K hy.isIntegral]
end minpoly
namespace PowerBasis
variable {K L : Type*} [Field K] [Field L] [Algebra K L]
open IntermediateField
/-- `pb.equivAdjoinSimple` is the equivalence between `K⟮pb.gen⟯` and `L` itself. -/
noncomputable def equivAdjoinSimple (pb : PowerBasis K L) : K⟮pb.gen⟯ ≃ₐ[K] L :=
(adjoin.powerBasis pb.isIntegral_gen).equivOfMinpoly pb <| by
rw [adjoin.powerBasis_gen, minpoly_gen]
@[simp]
theorem equivAdjoinSimple_aeval (pb : PowerBasis K L) (f : K[X]) :
pb.equivAdjoinSimple (aeval (AdjoinSimple.gen K pb.gen) f) = aeval pb.gen f :=
equivOfMinpoly_aeval _ pb _ f
@[simp]
theorem equivAdjoinSimple_gen (pb : PowerBasis K L) :
pb.equivAdjoinSimple (AdjoinSimple.gen K pb.gen) = pb.gen :=
equivOfMinpoly_gen _ pb _
@[simp]
theorem equivAdjoinSimple_symm_aeval (pb : PowerBasis K L) (f : K[X]) :
pb.equivAdjoinSimple.symm (aeval pb.gen f) = aeval (AdjoinSimple.gen K pb.gen) f := by
rw [equivAdjoinSimple, equivOfMinpoly_symm, equivOfMinpoly_aeval, adjoin.powerBasis_gen]
@[simp]
theorem equivAdjoinSimple_symm_gen (pb : PowerBasis K L) :
pb.equivAdjoinSimple.symm pb.gen = AdjoinSimple.gen K pb.gen := by
rw [equivAdjoinSimple, equivOfMinpoly_symm, equivOfMinpoly_gen, adjoin.powerBasis_gen]
end PowerBasis
namespace IntermediateField
universe u v
open Cardinal
variable (F : Type u) [Field F]
theorem lift_cardinalMk_adjoin_le {E : Type v} [Field E] [Algebra F E] (s : Set E) :
Cardinal.lift.{u} #(adjoin F s) ≤ Cardinal.lift.{v} #F ⊔ Cardinal.lift.{u} #s ⊔ ℵ₀ := by
rw [show ↥(adjoin F s) = (adjoin F s).toSubfield from rfl, adjoin_toSubfield]
apply (Cardinal.lift_le.mpr (Subfield.cardinalMk_closure_le_max _)).trans
rw [lift_max, sup_le_iff, lift_aleph0]
refine ⟨(Cardinal.lift_le.mpr ((mk_union_le _ _).trans <| add_le_max _ _)).trans ?_, le_sup_right⟩
simp_rw [lift_max, lift_aleph0]
grw [mk_range_le_lift]
theorem cardinalMk_adjoin_le {E : Type u} [Field E] [Algebra F E] (s : Set E) :
#(adjoin F s) ≤ #F ⊔ #s ⊔ ℵ₀ := by
simpa using lift_cardinalMk_adjoin_le F s
section AdjoinPair
variable {K L : Type*} [Field K] [Field L] [Algebra K L] {x y : L}
theorem isAlgebraic_adjoin_pair (hx : IsIntegral K x) (hy : IsIntegral K y) :
Algebra.IsAlgebraic K K⟮x, y⟯ := by
apply IntermediateField.isAlgebraic_adjoin
simp [hx, hy]
theorem finiteDimensional_adjoin_pair (hx : IsIntegral K x) (hy : IsIntegral K y) :
FiniteDimensional K K⟮x, y⟯ := by
have := adjoin.finiteDimensional hx
have := adjoin.finiteDimensional hy
rw [← Set.singleton_union, adjoin_union]
exact finiteDimensional_sup K⟮x⟯ K⟮y⟯
variable (K x y)
theorem mem_adjoin_pair_left : x ∈ K⟮x, y⟯ := subset_adjoin K {x, y} (Set.mem_insert x {y})
theorem mem_adjoin_pair_right : y ∈ K⟮x, y⟯ :=
subset_adjoin K {x, y} (Set.mem_insert_of_mem x (Set.mem_singleton y))
/-- The first generator of an intermediate field of the form `K⟮x, y⟯`. -/
def AdjoinPair.gen₁ : K⟮x, y⟯ := ⟨x, mem_adjoin_pair_left K x y⟩
/-- The second generator of an intermediate field of the form `K⟮x, y⟯`. -/
def AdjoinPair.gen₂ : K⟮x, y⟯ := ⟨y, mem_adjoin_pair_right K x y⟩
theorem AdjoinPair.algebraMap_gen₁ : (algebraMap (↥K⟮x, y⟯) L) (gen₁ K x y) = x := rfl
theorem AdjoinPair.algebraMap_gen₂ : (algebraMap (↥K⟮x, y⟯) L) (gen₂ K x y) = y := rfl
end AdjoinPair
end IntermediateField |
.lake/packages/mathlib/Mathlib/FieldTheory/IntermediateField/Adjoin/Defs.lean | import Mathlib.FieldTheory.IntermediateField.Basic
/-!
# Adjoining Elements to Fields
In this file we introduce the notion of adjoining elements to fields.
This isn't quite the same as adjoining elements to rings.
For example, `Algebra.adjoin K {x}` might not include `x⁻¹`.
## Notation
- `F⟮α⟯`: adjoin a single element `α` to `F` (in scope `IntermediateField`).
-/
open Module Polynomial
namespace IntermediateField
section AdjoinDef
variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] (S : Set E)
/-- `adjoin F S` extends a field `F` by adjoining a set `S ⊆ E`. -/
@[stacks 09FZ "first part"]
def adjoin : IntermediateField F E :=
{ Subfield.closure (Set.range (algebraMap F E) ∪ S) with
algebraMap_mem' := fun x => Subfield.subset_closure (Or.inl (Set.mem_range_self x)) }
@[simp]
theorem adjoin_toSubfield :
(adjoin F S).toSubfield = Subfield.closure (Set.range (algebraMap F E) ∪ S) := rfl
variable {F S} in
theorem mem_adjoin_iff_div {x : E} : x ∈ adjoin F S ↔
∃ r ∈ Algebra.adjoin F S, ∃ s ∈ Algebra.adjoin F S, x = r / s := by
simp_rw [adjoin, mem_mk, Subring.mem_toSubsemiring, Subfield.mem_toSubring,
Subfield.mem_closure_iff, ← Algebra.adjoin_eq_ring_closure, Subalgebra.mem_toSubring, eq_comm]
end AdjoinDef
section Lattice
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E]
@[simp]
theorem adjoin_le_iff {S : Set E} {T : IntermediateField F E} : adjoin F S ≤ T ↔ S ⊆ T :=
⟨fun H => le_trans (le_trans Set.subset_union_right Subfield.subset_closure) H, fun H =>
(@Subfield.closure_le E _ (Set.range (algebraMap F E) ∪ S) T.toSubfield).mpr
(Set.union_subset (IntermediateField.set_range_subset T) H)⟩
theorem gc : GaloisConnection (adjoin F : Set E → IntermediateField F E)
(fun (x : IntermediateField F E) => (x : Set E)) := fun _ _ =>
adjoin_le_iff
/-- Galois insertion between `adjoin` and `coe`. -/
def gi : GaloisInsertion (adjoin F : Set E → IntermediateField F E)
(fun (x : IntermediateField F E) => (x : Set E)) where
choice s hs := (adjoin F s).copy s <| le_antisymm (gc.le_u_l s) hs
gc := IntermediateField.gc
le_l_u S := (IntermediateField.gc (S : Set E) (adjoin F S)).1 <| le_rfl
choice_eq _ _ := copy_eq _ _ _
instance : CompleteLattice (IntermediateField F E) where
__ := GaloisInsertion.liftCompleteLattice IntermediateField.gi
bot :=
{ toSubalgebra := ⊥
inv_mem' := by rintro x ⟨r, rfl⟩; exact ⟨r⁻¹, map_inv₀ _ _⟩ }
bot_le x := (bot_le : ⊥ ≤ x.toSubalgebra)
instance (K₁ K₂ : IntermediateField F E) : Algebra ↥(K₁ ⊓ K₂) K₁ :=
inferInstanceAs (Algebra ↑(K₁.toSubalgebra ⊓ K₂.toSubalgebra) K₁.toSubalgebra)
instance (K₁ K₂ : IntermediateField F E) : Algebra ↥(K₁ ⊓ K₂) K₂ :=
inferInstanceAs (Algebra ↑(K₁.toSubalgebra ⊓ K₂.toSubalgebra) K₂.toSubalgebra)
theorem sup_def (S T : IntermediateField F E) : S ⊔ T = adjoin F (S ∪ T : Set E) := rfl
theorem sSup_def (S : Set (IntermediateField F E)) :
sSup S = adjoin F (⋃₀ (SetLike.coe '' S)) := rfl
instance : Inhabited (IntermediateField F E) :=
⟨⊤⟩
instance : Unique (IntermediateField F F) :=
{ inferInstanceAs (Inhabited (IntermediateField F F)) with
uniq := fun _ ↦ toSubalgebra_injective <| Subsingleton.elim _ _ }
theorem coe_bot : ↑(⊥ : IntermediateField F E) = Set.range (algebraMap F E) := rfl
theorem mem_bot {x : E} : x ∈ (⊥ : IntermediateField F E) ↔ x ∈ Set.range (algebraMap F E) :=
Iff.rfl
@[simp]
theorem bot_toSubalgebra : (⊥ : IntermediateField F E).toSubalgebra = ⊥ := rfl
theorem bot_toSubfield : (⊥ : IntermediateField F E).toSubfield = (algebraMap F E).fieldRange :=
rfl
@[simp]
theorem coe_top : ↑(⊤ : IntermediateField F E) = (Set.univ : Set E) :=
rfl
@[simp]
theorem mem_top {x : E} : x ∈ (⊤ : IntermediateField F E) :=
trivial
@[simp]
theorem top_toSubalgebra : (⊤ : IntermediateField F E).toSubalgebra = ⊤ :=
rfl
@[simp]
theorem top_toSubfield : (⊤ : IntermediateField F E).toSubfield = ⊤ :=
rfl
@[simp, norm_cast]
theorem coe_inf (S T : IntermediateField F E) : (↑(S ⊓ T) : Set E) = (S : Set E) ∩ T :=
rfl
@[simp]
theorem mem_inf {S T : IntermediateField F E} {x : E} : x ∈ S ⊓ T ↔ x ∈ S ∧ x ∈ T :=
Iff.rfl
@[simp]
theorem inf_toSubalgebra (S T : IntermediateField F E) :
(S ⊓ T).toSubalgebra = S.toSubalgebra ⊓ T.toSubalgebra :=
rfl
@[simp]
theorem inf_toSubfield (S T : IntermediateField F E) :
(S ⊓ T).toSubfield = S.toSubfield ⊓ T.toSubfield :=
rfl
@[simp]
theorem sup_toSubfield (S T : IntermediateField F E) :
(S ⊔ T).toSubfield = S.toSubfield ⊔ T.toSubfield := by
rw [← S.toSubfield.closure_eq, ← T.toSubfield.closure_eq, ← Subfield.closure_union]
simp_rw [sup_def, adjoin_toSubfield, coe_toSubfield]
congr 1
rw [Set.union_eq_right]
rintro _ ⟨x, rfl⟩
exact Set.mem_union_left _ (algebraMap_mem S x)
@[simp, norm_cast]
theorem coe_sInf (S : Set (IntermediateField F E)) : (↑(sInf S) : Set E) =
sInf ((fun (x : IntermediateField F E) => (x : Set E)) '' S) :=
rfl
@[simp]
theorem sInf_toSubalgebra (S : Set (IntermediateField F E)) :
(sInf S).toSubalgebra = sInf (toSubalgebra '' S) :=
SetLike.coe_injective <| by simp
@[simp]
theorem sInf_toSubfield (S : Set (IntermediateField F E)) :
(sInf S).toSubfield = sInf (toSubfield '' S) :=
SetLike.coe_injective <| by simp
@[simp]
theorem sSup_toSubfield (S : Set (IntermediateField F E)) (hS : S.Nonempty) :
(sSup S).toSubfield = sSup (toSubfield '' S) := by
have h : toSubfield '' S = Subfield.closure '' (SetLike.coe '' S) := by
rw [Set.image_image]
congr! with x
exact x.toSubfield.closure_eq.symm
rw [h, sSup_image, ← Subfield.closure_sUnion, sSup_def, adjoin_toSubfield]
congr 1
rw [Set.union_eq_right]
rintro _ ⟨x, rfl⟩
obtain ⟨y, hy⟩ := hS
simp only [Set.mem_sUnion, Set.mem_image, exists_exists_and_eq_and, SetLike.mem_coe]
exact ⟨y, hy, algebraMap_mem y x⟩
@[simp, norm_cast]
theorem coe_iInf {ι : Sort*} (S : ι → IntermediateField F E) : (↑(iInf S) : Set E) = ⋂ i, S i := by
simp [iInf]
@[simp]
theorem iInf_toSubalgebra {ι : Sort*} (S : ι → IntermediateField F E) :
(iInf S).toSubalgebra = ⨅ i, (S i).toSubalgebra :=
SetLike.coe_injective <| by simp [iInf]
@[simp]
theorem iInf_toSubfield {ι : Sort*} (S : ι → IntermediateField F E) :
(iInf S).toSubfield = ⨅ i, (S i).toSubfield :=
SetLike.coe_injective <| by simp [iInf]
@[simp]
theorem iSup_toSubfield {ι : Sort*} [Nonempty ι] (S : ι → IntermediateField F E) :
(iSup S).toSubfield = ⨆ i, (S i).toSubfield := by
simp only [iSup, Set.range_nonempty, sSup_toSubfield, ← Set.range_comp, Function.comp_def]
variable (F E)
/-- The bottom intermediate_field is isomorphic to the field. -/
noncomputable def botEquiv : (⊥ : IntermediateField F E) ≃ₐ[F] F :=
(Subalgebra.equivOfEq _ _ bot_toSubalgebra).trans (Algebra.botEquiv F E)
variable {F E}
theorem botEquiv_def (x : F) : botEquiv F E (algebraMap F (⊥ : IntermediateField F E) x) = x := by
simp
@[simp]
theorem botEquiv_symm (x : F) : (botEquiv F E).symm x = algebraMap F _ x :=
rfl
noncomputable instance algebraOverBot : Algebra (⊥ : IntermediateField F E) F :=
(IntermediateField.botEquiv F E).toAlgHom.toRingHom.toAlgebra
theorem coe_algebraMap_over_bot :
(algebraMap (⊥ : IntermediateField F E) F : (⊥ : IntermediateField F E) → F) =
IntermediateField.botEquiv F E :=
rfl
instance isScalarTower_over_bot : IsScalarTower (⊥ : IntermediateField F E) F E :=
IsScalarTower.of_algebraMap_eq
(by
intro x
obtain ⟨y, rfl⟩ := (botEquiv F E).symm.surjective x
rw [coe_algebraMap_over_bot, (botEquiv F E).apply_symm_apply, botEquiv_symm,
IsScalarTower.algebraMap_apply F (⊥ : IntermediateField F E) E])
/-- The top `IntermediateField` is isomorphic to the field.
This is the intermediate field version of `Subalgebra.topEquiv`. -/
@[simps!]
def topEquiv : (⊤ : IntermediateField F E) ≃ₐ[F] E :=
Subalgebra.topEquiv
section RestrictScalars
@[simp]
theorem restrictScalars_bot_eq_self (K : IntermediateField F E) :
(⊥ : IntermediateField K E).restrictScalars _ = K :=
SetLike.coe_injective Subtype.range_coe
variable {K : Type*} [Field K] [Algebra K E] [Algebra K F] [IsScalarTower K F E]
@[simp]
theorem restrictScalars_top : (⊤ : IntermediateField F E).restrictScalars K = ⊤ :=
rfl
@[simp]
theorem restrictScalars_eq_top_iff {L : IntermediateField F E} :
L.restrictScalars K = ⊤ ↔ L = ⊤ := by
simp [SetLike.ext_iff]
variable (K)
variable (L L' : IntermediateField F E)
theorem restrictScalars_sup :
L.restrictScalars K ⊔ L'.restrictScalars K = (L ⊔ L').restrictScalars K :=
toSubfield_injective (by simp)
theorem restrictScalars_inf :
L.restrictScalars K ⊓ L'.restrictScalars K = (L ⊓ L').restrictScalars K := rfl
end RestrictScalars
variable {K : Type*} [Field K] [Algebra F K]
@[simp]
theorem map_bot (f : E →ₐ[F] K) :
IntermediateField.map f ⊥ = ⊥ :=
toSubalgebra_injective <| Algebra.map_bot _
theorem map_sup (s t : IntermediateField F E) (f : E →ₐ[F] K) : (s ⊔ t).map f = s.map f ⊔ t.map f :=
(gc_map_comap f).l_sup
theorem map_iSup {ι : Sort*} (f : E →ₐ[F] K) (s : ι → IntermediateField F E) :
(iSup s).map f = ⨆ i, (s i).map f :=
(gc_map_comap f).l_iSup
theorem map_inf (s t : IntermediateField F E) (f : E →ₐ[F] K) :
(s ⊓ t).map f = s.map f ⊓ t.map f := SetLike.coe_injective (Set.image_inter f.injective)
theorem map_iInf {ι : Sort*} [Nonempty ι] (f : E →ₐ[F] K) (s : ι → IntermediateField F E) :
(iInf s).map f = ⨅ i, (s i).map f := by
apply SetLike.coe_injective
simpa using (Set.injOn_of_injective f.injective).image_iInter_eq (s := SetLike.coe ∘ s)
theorem _root_.AlgHom.fieldRange_eq_map (f : E →ₐ[F] K) :
f.fieldRange = IntermediateField.map f ⊤ :=
SetLike.ext' Set.image_univ.symm
theorem _root_.AlgHom.map_fieldRange {L : Type*} [Field L] [Algebra F L]
(f : E →ₐ[F] K) (g : K →ₐ[F] L) : f.fieldRange.map g = (g.comp f).fieldRange :=
SetLike.ext' (Set.range_comp g f).symm
theorem _root_.AlgHom.fieldRange_eq_top {f : E →ₐ[F] K} :
f.fieldRange = ⊤ ↔ Function.Surjective f :=
SetLike.ext'_iff.trans Set.range_eq_univ
@[simp]
theorem _root_.AlgEquiv.fieldRange_eq_top (f : E ≃ₐ[F] K) :
(f : E →ₐ[F] K).fieldRange = ⊤ :=
AlgHom.fieldRange_eq_top.mpr f.surjective
end Lattice
section AdjoinDef
variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] (S : Set E)
theorem adjoin_eq_range_algebraMap_adjoin :
(adjoin F S : Set E) = Set.range (algebraMap (adjoin F S) E) :=
Subtype.range_coe.symm
theorem adjoin.algebraMap_mem (x : F) : algebraMap F E x ∈ adjoin F S :=
IntermediateField.algebraMap_mem (adjoin F S) x
theorem adjoin.range_algebraMap_subset : Set.range (algebraMap F E) ⊆ adjoin F S :=
set_range_subset (adjoin F S)
instance adjoin.fieldCoe : CoeTC F (adjoin F S) where
coe x := ⟨algebraMap F E x, adjoin.algebraMap_mem F S x⟩
theorem subset_adjoin : S ⊆ adjoin F S := fun _ hx => Subfield.subset_closure (Or.inr hx)
instance adjoin.setCoe : CoeTC S (adjoin F S) where coe x := ⟨x, subset_adjoin F S (Subtype.mem x)⟩
@[mono, gcongr]
theorem adjoin.mono (T : Set E) (h : S ⊆ T) : adjoin F S ≤ adjoin F T :=
GaloisConnection.monotone_l gc h
theorem adjoin_contains_field_as_subfield (F : Subfield E) : (F : Set E) ⊆ adjoin F S := fun x hx =>
adjoin.algebraMap_mem F S ⟨x, hx⟩
theorem subset_adjoin_of_subset_left {F : Subfield E} {T : Set E} (HT : T ⊆ F) : T ⊆ adjoin F S :=
fun x hx => (adjoin F S).algebraMap_mem ⟨x, HT hx⟩
theorem subset_adjoin_of_subset_right {T : Set E} (H : T ⊆ S) : T ⊆ adjoin F S := fun _ hx =>
subset_adjoin F S (H hx)
@[simp]
theorem adjoin_empty (F E : Type*) [Field F] [Field E] [Algebra F E] : adjoin F (∅ : Set E) = ⊥ :=
eq_bot_iff.mpr (adjoin_le_iff.mpr (Set.empty_subset _))
@[simp]
theorem adjoin_univ (F E : Type*) [Field F] [Field E] [Algebra F E] :
adjoin F (Set.univ : Set E) = ⊤ :=
eq_top_iff.mpr <| subset_adjoin _ _
/-- If `K` is a field with `F ⊆ K` and `S ⊆ K` then `adjoin F S ≤ K`. -/
theorem adjoin_le_subfield {K : Subfield E} (HF : Set.range (algebraMap F E) ⊆ K) (HS : S ⊆ K) :
(adjoin F S).toSubfield ≤ K := by
apply Subfield.closure_le.mpr
rw [Set.union_subset_iff]
exact ⟨HF, HS⟩
theorem adjoin_subset_adjoin_iff {F' : Type*} [Field F'] [Algebra F' E] {S S' : Set E} :
(adjoin F S : Set E) ⊆ adjoin F' S' ↔
Set.range (algebraMap F E) ⊆ adjoin F' S' ∧ S ⊆ adjoin F' S' :=
⟨fun h => ⟨(adjoin.range_algebraMap_subset _ _).trans h,
(subset_adjoin _ _).trans h⟩, fun ⟨hF, hS⟩ =>
(Subfield.closure_le (t := (adjoin F' S').toSubfield)).mpr (Set.union_subset hF hS)⟩
/-- Adjoining S and then T is the same as adjoining `S ∪ T`. -/
theorem adjoin_adjoin_left (T : Set E) :
(adjoin (adjoin F S) T).restrictScalars _ = adjoin F (S ∪ T) := by
rw [SetLike.ext'_iff]
change (adjoin (adjoin F S) T : Set E) = _
apply subset_antisymm <;> rw [adjoin_subset_adjoin_iff] <;> constructor
· rintro _ ⟨⟨x, hx⟩, rfl⟩; exact adjoin.mono _ _ _ Set.subset_union_left hx
· exact subset_adjoin_of_subset_right _ _ Set.subset_union_right
· exact Set.range_subset_iff.mpr fun f ↦ Subfield.subset_closure (.inl ⟨f, rfl⟩)
· exact Set.union_subset
(fun x hx ↦ Subfield.subset_closure <| .inl ⟨⟨x, Subfield.subset_closure (.inr hx)⟩, rfl⟩)
(fun x hx ↦ Subfield.subset_closure <| .inr hx)
@[simp]
theorem adjoin_insert_adjoin (x : E) :
adjoin F (insert x (adjoin F S : Set E)) = adjoin F (insert x S) :=
le_antisymm
(adjoin_le_iff.mpr
(Set.insert_subset_iff.mpr
⟨subset_adjoin _ _ (Set.mem_insert _ _),
adjoin_le_iff.mpr (subset_adjoin_of_subset_right _ _ (Set.subset_insert _ _))⟩))
(by grw [← subset_adjoin])
/-- `F[S][T] = F[T][S]` -/
theorem adjoin_adjoin_comm (T : Set E) :
(adjoin (adjoin F S) T).restrictScalars F = (adjoin (adjoin F T) S).restrictScalars F := by
rw [adjoin_adjoin_left, adjoin_adjoin_left, Set.union_comm]
theorem adjoin_map {E' : Type*} [Field E'] [Algebra F E'] (f : E →ₐ[F] E') :
(adjoin F S).map f = adjoin F (f '' S) :=
le_antisymm
(map_le_iff_le_comap.mpr <| adjoin_le_iff.mpr fun x hx ↦ subset_adjoin _ _ ⟨x, hx, rfl⟩)
(adjoin_le_iff.mpr <| Set.monotone_image <| subset_adjoin _ _)
@[simp]
theorem lift_adjoin (K : IntermediateField F E) (S : Set K) :
lift (adjoin F S) = adjoin F (Subtype.val '' S) :=
adjoin_map _ _ _
theorem lift_adjoin_simple (K : IntermediateField F E) (α : K) :
lift (adjoin F {α}) = adjoin F {α.1} := by
simp only [lift_adjoin, Set.image_singleton]
@[simp]
theorem lift_bot (K : IntermediateField F E) :
lift (F := K) ⊥ = ⊥ := map_bot _
@[simp]
theorem lift_top (K : IntermediateField F E) :
lift (F := K) ⊤ = K := by rw [lift, ← AlgHom.fieldRange_eq_map, fieldRange_val]
theorem lift_sup (K : IntermediateField F E) (L L' : IntermediateField F K) :
lift (L ⊔ L') = lift L ⊔ lift L' := by
simp [lift, map_sup]
theorem lift_inf (K : IntermediateField F E) (L L' : IntermediateField F K) :
lift (L ⊓ L') = lift L ⊓ lift L' := by
simp [lift, map_inf]
@[simp]
theorem adjoin_self (K : IntermediateField F E) :
adjoin F K = K := le_antisymm (adjoin_le_iff.2 fun _ ↦ id) (subset_adjoin F _)
theorem restrictScalars_adjoin (K : IntermediateField F E) (S : Set E) :
restrictScalars F (adjoin K S) = adjoin F (K ∪ S) := by
rw [← adjoin_self _ K, adjoin_adjoin_left, adjoin_self _ K]
variable {F} in
theorem extendScalars_adjoin {K : IntermediateField F E} {S : Set E} (h : K ≤ adjoin F S) :
extendScalars h = adjoin K S := restrictScalars_injective F <| by
rw [extendScalars_restrictScalars, restrictScalars_adjoin]
exact le_antisymm (adjoin.mono F S _ Set.subset_union_right) <| adjoin_le_iff.2 <|
Set.union_subset h (subset_adjoin F S)
theorem adjoin_union {S T : Set E} : adjoin F (S ∪ T) = adjoin F S ⊔ adjoin F T :=
gc.l_sup
theorem restrictScalars_adjoin_eq_sup (K : IntermediateField F E) (S : Set E) :
restrictScalars F (adjoin K S) = K ⊔ adjoin F S := by
rw [restrictScalars_adjoin, adjoin_union, adjoin_self]
theorem adjoin_iUnion {ι} (f : ι → Set E) : adjoin F (⋃ i, f i) = ⨆ i, adjoin F (f i) :=
gc.l_iSup
theorem iSup_eq_adjoin {ι} (f : ι → IntermediateField F E) :
⨆ i, f i = adjoin F (⋃ i, f i : Set E) := by
simp_rw [adjoin_iUnion, adjoin_self]
variable {F} in
/-- If `E / L / F` and `E / L' / F` are two field extension towers, `L ≃ₐ[F] L'` is an isomorphism
compatible with `E / L` and `E / L'`, then for any subset `S` of `E`, `L(S)` and `L'(S)` are
equal as intermediate fields of `E / F`. -/
theorem restrictScalars_adjoin_of_algEquiv
{L L' : Type*} [Field L] [Field L']
[Algebra F L] [Algebra L E] [Algebra F L'] [Algebra L' E]
[IsScalarTower F L E] [IsScalarTower F L' E] (i : L ≃ₐ[F] L')
(hi : algebraMap L E = (algebraMap L' E) ∘ i) (S : Set E) :
(adjoin L S).restrictScalars F = (adjoin L' S).restrictScalars F := by
apply_fun toSubfield using (fun K K' h ↦ by
ext x; change x ∈ K.toSubfield ↔ x ∈ K'.toSubfield; rw [h])
change Subfield.closure _ = Subfield.closure _
congr
ext x
exact ⟨fun ⟨y, h⟩ ↦ ⟨i y, by rw [← h, hi]; rfl⟩,
fun ⟨y, h⟩ ↦ ⟨i.symm y, by rw [← h, hi, Function.comp_apply, AlgEquiv.apply_symm_apply]⟩⟩
@[elab_as_elim]
theorem adjoin_induction {s : Set E} {p : ∀ x ∈ adjoin F s, Prop}
(mem : ∀ x hx, p x (subset_adjoin _ _ hx))
(algebraMap : ∀ x, p (algebraMap F E x) (algebraMap_mem _ _))
(add : ∀ x y hx hy, p x hx → p y hy → p (x + y) (add_mem hx hy))
(inv : ∀ x hx, p x hx → p x⁻¹ (inv_mem hx))
(mul : ∀ x y hx hy, p x hx → p y hy → p (x * y) (mul_mem hx hy))
{x} (h : x ∈ adjoin F s) : p x h :=
Subfield.closure_induction
(fun x hx ↦ Or.casesOn hx (fun ⟨x, hx⟩ ↦ hx ▸ algebraMap x) (mem x))
(by simp_rw [← (_root_.algebraMap F E).map_one]; exact algebraMap 1) add
(fun x _ h ↦ by
simp_rw [← neg_one_smul F x, Algebra.smul_def]; exact mul _ _ _ _ (algebraMap _) h) inv mul h
section
variable {K : Type*} [Semiring K] [Algebra F K]
theorem adjoin_algHom_ext {s : Set E} ⦃φ₁ φ₂ : adjoin F s →ₐ[F] K⦄
(h : ∀ x hx, φ₁ ⟨x, subset_adjoin _ _ hx⟩ = φ₂ ⟨x, subset_adjoin _ _ hx⟩) :
φ₁ = φ₂ :=
AlgHom.ext fun ⟨x, hx⟩ ↦ adjoin_induction _ h (fun _ ↦ φ₂.commutes _ ▸ φ₁.commutes _)
(fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· + ·) h₁ h₂ <;> rw [← map_add] <;> rfl)
(fun _ _ ↦ eq_on_inv₀ _ _)
(fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· * ·) h₁ h₂ <;> rw [← map_mul] <;> rfl)
hx
theorem algHom_ext_of_eq_adjoin {S : IntermediateField F E} {s : Set E} (hS : S = adjoin F s)
⦃φ₁ φ₂ : S →ₐ[F] K⦄
(h : ∀ x hx, φ₁ ⟨x, hS.ge (subset_adjoin _ _ hx)⟩ = φ₂ ⟨x, hS.ge (subset_adjoin _ _ hx)⟩) :
φ₁ = φ₂ := by
subst hS; exact adjoin_algHom_ext F h
end
open Lean in
/-- Supporting function for the `F⟮x₁,x₂,...,xₙ⟯` adjunction notation. -/
private partial def mkInsertTerm {m : Type → Type} [Monad m] [MonadQuotation m]
(xs : TSyntaxArray `term) : m Term := run 0 where
run (i : Nat) : m Term := do
if h : i + 1 = xs.size then
``(singleton $(xs[i]))
else if h : i < xs.size then
``(insert $(xs[i]) $(← run (i + 1)))
else
``(EmptyCollection.emptyCollection)
/-- If `x₁ x₂ ... xₙ : E` then `F⟮x₁,x₂,...,xₙ⟯` is the `IntermediateField F E`
generated by these elements. -/
scoped macro:max K:term "⟮" xs:term,* "⟯" : term => do ``(adjoin $K $(← mkInsertTerm xs.getElems))
open Lean PrettyPrinter.Delaborator SubExpr in
@[app_delab IntermediateField.adjoin]
partial def delabAdjoinNotation : Delab := whenPPOption getPPNotation do
let e ← getExpr
guard <| e.isAppOfArity ``adjoin 6
let F ← withNaryArg 0 delab
let xs ← withNaryArg 5 delabInsertArray
`($F⟮$(xs.toArray),*⟯)
where
delabInsertArray : DelabM (List Term) := do
let e ← getExpr
if e.isAppOfArity ``EmptyCollection.emptyCollection 2 then
return []
else if e.isAppOfArity ``singleton 4 then
let x ← withNaryArg 3 delab
return [x]
else if e.isAppOfArity ``insert 5 then
let x ← withNaryArg 3 delab
let xs ← withNaryArg 4 delabInsertArray
return x :: xs
else failure
section AdjoinSimple
variable (α : E)
theorem mem_adjoin_simple_self : α ∈ F⟮α⟯ :=
subset_adjoin F {α} (Set.mem_singleton α)
/-- generator of `F⟮α⟯` -/
def AdjoinSimple.gen : F⟮α⟯ :=
⟨α, mem_adjoin_simple_self F α⟩
@[simp]
theorem AdjoinSimple.coe_gen : (AdjoinSimple.gen F α : E) = α :=
rfl
theorem AdjoinSimple.algebraMap_gen : algebraMap F⟮α⟯ E (AdjoinSimple.gen F α) = α :=
rfl
theorem adjoin_simple_adjoin_simple (β : E) : F⟮α⟯⟮β⟯.restrictScalars F = F⟮α, β⟯ :=
adjoin_adjoin_left _ _ _
theorem adjoin_simple_comm (β : E) : F⟮α⟯⟮β⟯.restrictScalars F = F⟮β⟯⟮α⟯.restrictScalars F :=
adjoin_adjoin_comm _ _ _
variable {F} {α}
theorem adjoin_simple_le_iff {K : IntermediateField F E} : F⟮α⟯ ≤ K ↔ α ∈ K := by simp
theorem biSup_adjoin_simple : ⨆ x ∈ S, F⟮x⟯ = adjoin F S := by
rw [← iSup_subtype'', ← gc.l_iSup, iSup_subtype'']; congr; exact S.biUnion_of_singleton
end AdjoinSimple
end AdjoinDef
section AdjoinIntermediateFieldLattice
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] {α : E} {S : Set E}
@[simp]
theorem adjoin_eq_bot_iff : adjoin F S = ⊥ ↔ S ⊆ (⊥ : IntermediateField F E) := by
rw [eq_bot_iff, adjoin_le_iff]
theorem adjoin_simple_eq_bot_iff : F⟮α⟯ = ⊥ ↔ α ∈ (⊥ : IntermediateField F E) := by
simp
@[simp]
theorem adjoin_zero : F⟮(0 : E)⟯ = ⊥ :=
adjoin_simple_eq_bot_iff.mpr (zero_mem ⊥)
@[simp]
theorem adjoin_one : F⟮(1 : E)⟯ = ⊥ :=
adjoin_simple_eq_bot_iff.mpr (one_mem ⊥)
@[simp]
theorem adjoin_intCast (n : ℤ) : F⟮(n : E)⟯ = ⊥ := by
exact adjoin_simple_eq_bot_iff.mpr (intCast_mem ⊥ n)
@[simp]
theorem adjoin_natCast (n : ℕ) : F⟮(n : E)⟯ = ⊥ :=
adjoin_simple_eq_bot_iff.mpr (natCast_mem ⊥ n)
end AdjoinIntermediateFieldLattice
section Induction
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E]
/-- An intermediate field `S` is finitely generated if there exists `t : Finset E` such that
`IntermediateField.adjoin F t = S`. -/
@[stacks 09FZ "second part"]
def FG (S : IntermediateField F E) : Prop :=
∃ t : Finset E, adjoin F ↑t = S
theorem fg_adjoin_finset (t : Finset E) : (adjoin F (↑t : Set E)).FG :=
⟨t, rfl⟩
theorem fg_def {S : IntermediateField F E} : S.FG ↔ ∃ t : Set E, Set.Finite t ∧ adjoin F t = S :=
Iff.symm Set.exists_finite_iff_finset
theorem fg_adjoin_of_finite {t : Set E} (h : Set.Finite t) : (adjoin F t).FG :=
fg_def.mpr ⟨t, h, rfl⟩
theorem fg_bot : (⊥ : IntermediateField F E).FG :=
⟨∅, by simp only [Finset.coe_empty, adjoin_empty]⟩
theorem fg_sup {S T : IntermediateField F E} (hS : S.FG) (hT : T.FG) : (S ⊔ T).FG := by
obtain ⟨s, rfl⟩ := hS; obtain ⟨t, rfl⟩ := hT
classical rw [← adjoin_union, ← Finset.coe_union]
exact fg_adjoin_finset _
theorem fg_iSup {ι : Sort*} [Finite ι] {S : ι → IntermediateField F E} (h : ∀ i, (S i).FG) :
(⨆ i, S i).FG := by
choose s hs using h
simp_rw [← hs, ← adjoin_iUnion]
exact fg_adjoin_of_finite (Set.finite_iUnion fun _ ↦ Finset.finite_toSet _)
theorem induction_on_adjoin_finset (S : Finset E) (P : IntermediateField F E → Prop) (base : P ⊥)
(ih : ∀ (K : IntermediateField F E), ∀ x ∈ S, P K → P (K⟮x⟯.restrictScalars F)) :
P (adjoin F S) := by
classical
refine Finset.induction_on' S ?_ (fun _ _ ha _ _ h => ?_)
· simp [base]
· rw [Finset.coe_insert, Set.insert_eq, Set.union_comm, ← adjoin_adjoin_left]
exact ih (adjoin F _) _ ha h
theorem induction_on_adjoin_fg (P : IntermediateField F E → Prop) (base : P ⊥)
(ih : ∀ (K : IntermediateField F E) (x : E), P K → P (K⟮x⟯.restrictScalars F))
(K : IntermediateField F E) (hK : K.FG) : P K := by
obtain ⟨S, rfl⟩ := hK
exact induction_on_adjoin_finset S P base fun K x _ hK => ih K x hK
end Induction
end IntermediateField
namespace IntermediateField
variable {K L L' : Type*} [Field K] [Field L] [Field L'] [Algebra K L] [Algebra K L']
theorem map_comap_eq (f : L →ₐ[K] L') (S : IntermediateField K L') :
(S.comap f).map f = S ⊓ f.fieldRange :=
SetLike.coe_injective Set.image_preimage_eq_inter_range
theorem map_comap_eq_self {f : L →ₐ[K] L'} {S : IntermediateField K L'} (h : S ≤ f.fieldRange) :
(S.comap f).map f = S := by
simpa only [inf_of_le_left h] using map_comap_eq f S
theorem map_comap_eq_self_of_surjective {f : L →ₐ[K] L'} (hf : Function.Surjective f)
(S : IntermediateField K L') : (S.comap f).map f = S :=
SetLike.coe_injective (Set.image_preimage_eq _ hf)
theorem comap_map (f : L →ₐ[K] L') (S : IntermediateField K L) : (S.map f).comap f = S :=
SetLike.coe_injective (Set.preimage_image_eq _ f.injective)
end IntermediateField
section ExtendScalars
variable {K : Type*} [Field K] {L : Type*} [Field L] [Algebra K L]
namespace Subfield
variable (F : Subfield L)
@[simp]
theorem extendScalars_self : extendScalars (le_refl F) = ⊥ := by
ext x
rw [mem_extendScalars, IntermediateField.mem_bot]
refine ⟨fun h ↦ ⟨⟨x, h⟩, rfl⟩, ?_⟩
rintro ⟨y, rfl⟩
exact y.2
@[simp]
theorem extendScalars_top : extendScalars (le_top : F ≤ ⊤) = ⊤ :=
IntermediateField.toSubfield_injective (by simp)
variable {F}
variable {E E' : Subfield L} (h : F ≤ E) (h' : F ≤ E')
theorem extendScalars_sup :
extendScalars h ⊔ extendScalars h' = extendScalars (le_sup_of_le_left h : F ≤ E ⊔ E') :=
((extendScalars.orderIso F).map_sup ⟨_, h⟩ ⟨_, h'⟩).symm
theorem extendScalars_inf : extendScalars h ⊓ extendScalars h' = extendScalars (le_inf h h') :=
((extendScalars.orderIso F).map_inf ⟨_, h⟩ ⟨_, h'⟩).symm
end Subfield
namespace IntermediateField
variable (F : IntermediateField K L)
@[simp]
theorem extendScalars_self : extendScalars (le_refl F) = ⊥ :=
restrictScalars_injective K (by simp)
@[simp]
theorem extendScalars_top : extendScalars (le_top : F ≤ ⊤) = ⊤ :=
restrictScalars_injective K (by simp)
variable {F}
variable {E E' : IntermediateField K L} (h : F ≤ E) (h' : F ≤ E')
theorem extendScalars_sup :
extendScalars h ⊔ extendScalars h' = extendScalars (le_sup_of_le_left h : F ≤ E ⊔ E') :=
((extendScalars.orderIso F).map_sup ⟨_, h⟩ ⟨_, h'⟩).symm
theorem extendScalars_inf : extendScalars h ⊓ extendScalars h' = extendScalars (le_inf h h') :=
((extendScalars.orderIso F).map_inf ⟨_, h⟩ ⟨_, h'⟩).symm
end IntermediateField
end ExtendScalars |
.lake/packages/mathlib/Mathlib/FieldTheory/IntermediateField/Adjoin/Algebra.lean | import Mathlib.FieldTheory.Finiteness
import Mathlib.FieldTheory.IntermediateField.Adjoin.Defs
import Mathlib.FieldTheory.IntermediateField.Algebraic
/-!
# Adjoining Elements to Fields
This file relates `IntermediateField.adjoin` to `Algebra.adjoin`.
-/
open Module Polynomial
namespace IntermediateField
section AdjoinDef
variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] (S : Set E)
theorem algebra_adjoin_le_adjoin : Algebra.adjoin F S ≤ (adjoin F S).toSubalgebra :=
Algebra.adjoin_le (subset_adjoin _ _)
namespace algebraAdjoinAdjoin
/-- `IntermediateField.adjoin` as an algebra over `Algebra.adjoin`. -/
scoped instance : Algebra (Algebra.adjoin F S) (adjoin F S) :=
(Subalgebra.inclusion <| algebra_adjoin_le_adjoin F S).toAlgebra
scoped instance (X) [SMul X F] [SMul X E] [IsScalarTower X F E] :
IsScalarTower X (Algebra.adjoin F S) (adjoin F S) :=
Subalgebra.inclusion.isScalarTower_left (algebra_adjoin_le_adjoin F S) _
scoped instance (X) [MulAction E X] : IsScalarTower (Algebra.adjoin F S) (adjoin F S) X :=
Subalgebra.inclusion.isScalarTower_right (algebra_adjoin_le_adjoin F S) _
scoped instance : FaithfulSMul (Algebra.adjoin F S) (adjoin F S) :=
Subalgebra.inclusion.faithfulSMul (algebra_adjoin_le_adjoin F S)
scoped instance : IsFractionRing (Algebra.adjoin F S) (adjoin F S) :=
.of_field _ _ fun ⟨_, h⟩ ↦ have ⟨x, hx, y, hy, eq⟩ := mem_adjoin_iff_div.mp h
⟨⟨x, hx⟩, ⟨y, hy⟩, Subtype.ext eq⟩
scoped instance : Algebra.IsAlgebraic (Algebra.adjoin F S) (adjoin F S) :=
IsLocalization.isAlgebraic _ (nonZeroDivisors (Algebra.adjoin F S))
end algebraAdjoinAdjoin
theorem adjoin_eq_algebra_adjoin (inv_mem : ∀ x ∈ Algebra.adjoin F S, x⁻¹ ∈ Algebra.adjoin F S) :
(adjoin F S).toSubalgebra = Algebra.adjoin F S :=
le_antisymm
(show adjoin F S ≤
{ Algebra.adjoin F S with
inv_mem' := inv_mem }
from adjoin_le_iff.mpr Algebra.subset_adjoin)
(algebra_adjoin_le_adjoin _ _)
theorem eq_adjoin_of_eq_algebra_adjoin (K : IntermediateField F E)
(h : K.toSubalgebra = Algebra.adjoin F S) : K = adjoin F S := by
apply toSubalgebra_injective
rw [h]
refine (adjoin_eq_algebra_adjoin F _ fun x ↦ ?_).symm
rw [← h]
exact K.inv_mem
theorem adjoin_eq_top_of_algebra (hS : Algebra.adjoin F S = ⊤) : adjoin F S = ⊤ :=
top_le_iff.mp (hS.symm.trans_le <| algebra_adjoin_le_adjoin F S)
section AdjoinSimple
variable (α : E)
@[simp]
theorem AdjoinSimple.isIntegral_gen : IsIntegral F (AdjoinSimple.gen F α) ↔ IsIntegral F α := by
conv_rhs => rw [← AdjoinSimple.algebraMap_gen F α]
rw [isIntegral_algebraMap_iff (algebraMap F⟮α⟯ E).injective]
variable {F} {α}
theorem adjoin_algebraic_toSubalgebra {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x) :
(IntermediateField.adjoin F S).toSubalgebra = Algebra.adjoin F S :=
adjoin_eq_algebra_adjoin _ _ fun _ ↦
(Algebra.IsIntegral.adjoin fun x hx ↦ (hS x hx).isIntegral).inv_mem
theorem adjoin_simple_toSubalgebra_of_integral (hα : IsIntegral F α) :
F⟮α⟯.toSubalgebra = Algebra.adjoin F {α} :=
adjoin_algebraic_toSubalgebra <| by simpa [isAlgebraic_iff_isIntegral]
lemma _root_.Algebra.adjoin_eq_top_of_intermediateField {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x)
(hS₂ : IntermediateField.adjoin F S = ⊤) : Algebra.adjoin F S = ⊤ := by
simp [*, ← IntermediateField.adjoin_algebraic_toSubalgebra hS]
lemma _root_.Algebra.adjoin_eq_top_of_primitive_element {α : E} (hα : IsIntegral F α)
(hα₂ : F⟮α⟯ = ⊤) : Algebra.adjoin F {α} = ⊤ :=
Algebra.adjoin_eq_top_of_intermediateField (by simpa [isAlgebraic_iff_isIntegral]) hα₂
lemma finite_of_fg_of_isAlgebraic
(h : IntermediateField.FG (⊤ : IntermediateField F E)) [Algebra.IsAlgebraic F E] :
Module.Finite F E := by
obtain ⟨s, hs⟩ := h
have : Algebra.FiniteType F E := by
use s
rw [← IntermediateField.adjoin_algebraic_toSubalgebra
(fun x hx ↦ Algebra.IsAlgebraic.isAlgebraic x)]
simpa [← IntermediateField.toSubalgebra_inj] using hs
exact Algebra.IsIntegral.finite
section Supremum
variable {K L : Type*} [Field K] [Field L] [Algebra K L] (E1 E2 : IntermediateField K L)
theorem le_sup_toSubalgebra : E1.toSubalgebra ⊔ E2.toSubalgebra ≤ (E1 ⊔ E2).toSubalgebra :=
sup_le (show E1 ≤ E1 ⊔ E2 from le_sup_left) (show E2 ≤ E1 ⊔ E2 from le_sup_right)
theorem sup_toSubalgebra_of_isAlgebraic_right [Algebra.IsAlgebraic K E2] :
(E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
have : (adjoin E1 (E2 : Set L)).toSubalgebra = _ := adjoin_algebraic_toSubalgebra fun x h ↦
IsAlgebraic.tower_top E1 (isAlgebraic_iff.1
(Algebra.IsAlgebraic.isAlgebraic (⟨x, h⟩ : E2)))
apply_fun Subalgebra.restrictScalars K at this
rw [← restrictScalars_toSubalgebra, restrictScalars_adjoin] at this
-- TODO: rather than using `← coe_type_toSubalgera` here, perhaps we should restate another
-- version of `Algebra.restrictScalars_adjoin` for intermediate fields?
simp only [← coe_type_toSubalgebra] at this
rw [Algebra.restrictScalars_adjoin] at this
exact this
theorem sup_toSubalgebra_of_isAlgebraic_left [Algebra.IsAlgebraic K E1] :
(E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
have := sup_toSubalgebra_of_isAlgebraic_right E2 E1
rwa [sup_comm (a := E1), sup_comm (a := E1.toSubalgebra)]
/-- The compositum of two intermediate fields is equal to the compositum of them
as subalgebras, if one of them is algebraic over the base field. -/
theorem sup_toSubalgebra_of_isAlgebraic
(halg : Algebra.IsAlgebraic K E1 ∨ Algebra.IsAlgebraic K E2) :
(E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra :=
halg.elim (fun _ ↦ sup_toSubalgebra_of_isAlgebraic_left E1 E2)
(fun _ ↦ sup_toSubalgebra_of_isAlgebraic_right E1 E2)
theorem sup_toSubalgebra_of_left [FiniteDimensional K E1] :
(E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra :=
sup_toSubalgebra_of_isAlgebraic_left E1 E2
theorem sup_toSubalgebra_of_right [FiniteDimensional K E2] :
(E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra :=
sup_toSubalgebra_of_isAlgebraic_right E1 E2
end Supremum
section Tower
variable (E)
variable {K : Type*} [Field K] [Algebra F K] [Algebra E K] [IsScalarTower F E K]
/-- If `K / E / F` is a field extension tower, `L` is an intermediate field of `K / F`, such that
either `E / F` or `L / F` is algebraic, then `E(L) = E[L]`. -/
theorem adjoin_toSubalgebra_of_isAlgebraic (L : IntermediateField F K)
(halg : Algebra.IsAlgebraic F E ∨ Algebra.IsAlgebraic F L) :
(adjoin E (L : Set K)).toSubalgebra = Algebra.adjoin E (L : Set K) := by
let i := IsScalarTower.toAlgHom F E K
let E' := i.fieldRange
let i' : E ≃ₐ[F] E' := AlgEquiv.ofInjectiveField i
have hi : algebraMap E K = (algebraMap E' K) ∘ i' := by ext x; rfl
apply_fun _ using Subalgebra.restrictScalars_injective F
rw [← restrictScalars_toSubalgebra, restrictScalars_adjoin_of_algEquiv i' hi,
Algebra.restrictScalars_adjoin_of_algEquiv i' hi, restrictScalars_adjoin]
dsimp only [← E'.coe_type_toSubalgebra]
rw [Algebra.restrictScalars_adjoin F E'.toSubalgebra]
exact E'.sup_toSubalgebra_of_isAlgebraic L (halg.imp
(fun (_ : Algebra.IsAlgebraic F E) ↦ i'.isAlgebraic) id)
theorem adjoin_toSubalgebra_of_isAlgebraic_left (L : IntermediateField F K)
[halg : Algebra.IsAlgebraic F E] :
(adjoin E (L : Set K)).toSubalgebra = Algebra.adjoin E (L : Set K) :=
adjoin_toSubalgebra_of_isAlgebraic E L (Or.inl halg)
theorem adjoin_toSubalgebra_of_isAlgebraic_right (L : IntermediateField F K)
[halg : Algebra.IsAlgebraic F L] :
(adjoin E (L : Set K)).toSubalgebra = Algebra.adjoin E (L : Set K) :=
adjoin_toSubalgebra_of_isAlgebraic E L (Or.inr halg)
end Tower
end AdjoinSimple
end AdjoinDef
section Induction
variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E]
theorem fg_of_fg_toSubalgebra (S : IntermediateField F E) (h : S.toSubalgebra.FG) : S.FG := by
obtain ⟨t, ht⟩ := h
exact ⟨t, (eq_adjoin_of_eq_algebra_adjoin _ _ _ ht.symm).symm⟩
theorem fg_of_noetherian (S : IntermediateField F E) [IsNoetherian F E] : S.FG :=
S.fg_of_fg_toSubalgebra S.toSubalgebra.fg_of_noetherian
theorem induction_on_adjoin [FiniteDimensional F E] (P : IntermediateField F E → Prop)
(base : P ⊥) (ih : ∀ (K : IntermediateField F E) (x : E), P K → P (K⟮x⟯.restrictScalars F))
(K : IntermediateField F E) : P K :=
letI : IsNoetherian F E := IsNoetherian.iff_fg.2 inferInstance
induction_on_adjoin_fg P base ih K K.fg_of_noetherian
end Induction
end IntermediateField
namespace IsFractionRing
variable {F A K L : Type*} [Field F] [CommRing A] [Algebra F A]
[Field K] [Algebra F K] [Algebra A K] [IsFractionRing A K] [Field L] [Algebra F L]
{g : A →ₐ[F] L} {f : K →ₐ[F] L}
/-- If `F` is a field, `A` is an `F`-algebra with fraction field `K`, `L` is a field,
`g : A →ₐ[F] L` lifts to `f : K →ₐ[F] L`,
then the image of `f` is the field generated by the image of `g`.
Note: this does not require `IsScalarTower F A K`. -/
theorem algHom_fieldRange_eq_of_comp_eq (h : RingHom.comp f (algebraMap A K) = (g : A →+* L)) :
f.fieldRange = IntermediateField.adjoin F g.range := by
apply IntermediateField.toSubfield_injective
simp_rw [AlgHom.fieldRange_toSubfield, IntermediateField.adjoin_toSubfield]
convert ringHom_fieldRange_eq_of_comp_eq h using 2
exact Set.union_eq_self_of_subset_left fun _ ⟨x, hx⟩ ↦ ⟨algebraMap F A x, by simp [← hx]⟩
/-- If `F` is a field, `A` is an `F`-algebra with fraction field `K`, `L` is a field,
`g : A →ₐ[F] L` lifts to `f : K →ₐ[F] L`,
`s` is a set such that the image of `g` is the subalgebra generated by `s`,
then the image of `f` is the intermediate field generated by `s`.
Note: this does not require `IsScalarTower F A K`. -/
theorem algHom_fieldRange_eq_of_comp_eq_of_range_eq
(h : RingHom.comp f (algebraMap A K) = (g : A →+* L))
{s : Set L} (hs : g.range = Algebra.adjoin F s) :
f.fieldRange = IntermediateField.adjoin F s := by
apply IntermediateField.toSubfield_injective
simp_rw [AlgHom.fieldRange_toSubfield, IntermediateField.adjoin_toSubfield]
refine ringHom_fieldRange_eq_of_comp_eq_of_range_eq h ?_
rw [← Algebra.adjoin_eq_ring_closure, ← hs]; rfl
variable [IsScalarTower F A K]
/-- The image of `IsFractionRing.liftAlgHom` is the intermediate field generated by the image
of the algebra hom. -/
theorem liftAlgHom_fieldRange (hg : Function.Injective g) :
(liftAlgHom hg : K →ₐ[F] L).fieldRange = IntermediateField.adjoin F g.range :=
algHom_fieldRange_eq_of_comp_eq (by ext; simp)
/-- The image of `IsFractionRing.liftAlgHom` is the intermediate field generated by `s`,
if the image of the algebra hom is the subalgebra generated by `s`. -/
theorem liftAlgHom_fieldRange_eq_of_range_eq (hg : Function.Injective g)
{s : Set L} (hs : g.range = Algebra.adjoin F s) :
(liftAlgHom hg : K →ₐ[F] L).fieldRange = IntermediateField.adjoin F s :=
algHom_fieldRange_eq_of_comp_eq_of_range_eq (by ext; simp) hs
end IsFractionRing |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/AffineScheme.lean | import Mathlib.AlgebraicGeometry.Cover.Open
import Mathlib.AlgebraicGeometry.GammaSpecAdjunction
import Mathlib.AlgebraicGeometry.Restrict
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.RingTheory.Localization.InvSubmonoid
import Mathlib.RingTheory.LocalProperties.Basic
import Mathlib.Topology.Sheaves.CommRingCat
import Mathlib.CategoryTheory.Monad.Limits
/-!
# Affine schemes
We define the category of `AffineScheme`s as the essential image of `Spec`.
We also define predicates about affine schemes and affine open sets.
## Main definitions
* `AlgebraicGeometry.AffineScheme`: The category of affine schemes.
* `AlgebraicGeometry.IsAffine`: A scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an
isomorphism.
* `AlgebraicGeometry.Scheme.isoSpec`: The canonical isomorphism `X ≅ Spec Γ(X)` for an affine
scheme.
* `AlgebraicGeometry.AffineScheme.equivCommRingCat`: The equivalence of categories
`AffineScheme ≌ CommRingᵒᵖ` given by `AffineScheme.Spec : CommRingᵒᵖ ⥤ AffineScheme` and
`AffineScheme.Γ : AffineSchemeᵒᵖ ⥤ CommRingCat`.
* `AlgebraicGeometry.IsAffineOpen`: An open subset of a scheme is affine if the open subscheme is
affine.
* `AlgebraicGeometry.IsAffineOpen.fromSpec`: The immersion `Spec 𝒪ₓ(U) ⟶ X` for an affine `U`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
namespace AlgebraicGeometry
open Spec (structureSheaf)
/-- The category of affine schemes -/
def AffineScheme :=
Scheme.Spec.EssImageSubcategory
deriving Category
/-- A Scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an isomorphism. -/
class IsAffine (X : Scheme) : Prop where
affine : IsIso X.toSpecΓ
attribute [instance] IsAffine.affine
instance (X : Scheme.{u}) [IsAffine X] : IsIso (ΓSpec.adjunction.unit.app X) := @IsAffine.affine X _
/-- The canonical isomorphism `X ≅ Spec Γ(X)` for an affine scheme. -/
@[simps! -isSimp hom]
def Scheme.isoSpec (X : Scheme) [IsAffine X] : X ≅ Spec Γ(X, ⊤) :=
asIso X.toSpecΓ
@[reassoc]
theorem Scheme.isoSpec_hom_naturality {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :
X.isoSpec.hom ≫ Spec.map (f.appTop) = f ≫ Y.isoSpec.hom := by
simp only [isoSpec, asIso_hom, Scheme.toSpecΓ_naturality]
@[reassoc]
theorem Scheme.isoSpec_inv_naturality {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :
Spec.map (f.appTop) ≫ Y.isoSpec.inv = X.isoSpec.inv ≫ f := by
rw [Iso.eq_inv_comp, isoSpec, asIso_hom, ← Scheme.toSpecΓ_naturality_assoc, isoSpec,
asIso_inv, IsIso.hom_inv_id, Category.comp_id]
@[reassoc (attr := simp)]
lemma Scheme.toSpecΓ_isoSpec_inv (X : Scheme.{u}) [IsAffine X] :
X.toSpecΓ ≫ X.isoSpec.inv = 𝟙 _ :=
X.isoSpec.hom_inv_id
@[reassoc (attr := simp)]
lemma Scheme.isoSpec_inv_toSpecΓ (X : Scheme.{u}) [IsAffine X] :
X.isoSpec.inv ≫ X.toSpecΓ = 𝟙 _ :=
X.isoSpec.inv_hom_id
/-- Construct an affine scheme from a scheme and the information that it is affine.
Also see `AffineScheme.of` for a typeclass version. -/
@[simps]
def AffineScheme.mk (X : Scheme) (_ : IsAffine X) : AffineScheme :=
⟨X, ΓSpec.adjunction.mem_essImage_of_unit_isIso _⟩
/-- Construct an affine scheme from a scheme. Also see `AffineScheme.mk` for a non-typeclass
version. -/
def AffineScheme.of (X : Scheme) [h : IsAffine X] : AffineScheme :=
AffineScheme.mk X h
/-- Type check a morphism of schemes as a morphism in `AffineScheme`. -/
def AffineScheme.ofHom {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :
AffineScheme.of X ⟶ AffineScheme.of Y :=
f
@[simp]
theorem essImage_Spec {X : Scheme} : Scheme.Spec.essImage X ↔ IsAffine X :=
⟨fun h => ⟨Functor.essImage.unit_isIso h⟩,
fun _ => ΓSpec.adjunction.mem_essImage_of_unit_isIso _⟩
instance isAffine_affineScheme (X : AffineScheme.{u}) : IsAffine X.obj :=
⟨Functor.essImage.unit_isIso X.property⟩
instance (R : CommRingCatᵒᵖ) : IsAffine (Scheme.Spec.obj R) :=
AlgebraicGeometry.isAffine_affineScheme ⟨_, Scheme.Spec.obj_mem_essImage R⟩
instance isAffine_Spec (R : CommRingCat) : IsAffine (Spec R) :=
AlgebraicGeometry.isAffine_affineScheme ⟨_, Scheme.Spec.obj_mem_essImage (op R)⟩
theorem IsAffine.of_isIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] [h : IsAffine Y] : IsAffine X := by
rw [← essImage_Spec] at h ⊢; exact Functor.essImage.ofIso (asIso f).symm h
theorem IsAffine.iff_of_isIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : IsAffine X ↔ IsAffine Y :=
⟨fun _ ↦ .of_isIso (inv f), fun _ ↦ .of_isIso f⟩
/-- If `f : X ⟶ Y` is a morphism between affine schemes, the corresponding arrow is isomorphic
to the arrow of the morphism on prime spectra induced by the map on global sections. -/
noncomputable
def arrowIsoSpecΓOfIsAffine {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :
Arrow.mk f ≅ Arrow.mk (Spec.map f.appTop) :=
Arrow.isoMk X.isoSpec Y.isoSpec (ΓSpec.adjunction.unit_naturality _)
/-- If `f : A ⟶ B` is a ring homomorphism, the corresponding arrow is isomorphic
to the arrow of the morphism induced on global sections by the map on prime spectra. -/
def arrowIsoΓSpecOfIsAffine {A B : CommRingCat} (f : A ⟶ B) :
Arrow.mk f ≅ Arrow.mk ((Spec.map f).appTop) :=
Arrow.isoMk (Scheme.ΓSpecIso _).symm (Scheme.ΓSpecIso _).symm
(Scheme.ΓSpecIso_inv_naturality f).symm
theorem Scheme.isoSpec_Spec (R : CommRingCat.{u}) :
(Spec R).isoSpec = Scheme.Spec.mapIso (Scheme.ΓSpecIso R).op :=
Iso.ext (SpecMap_ΓSpecIso_hom R).symm
@[simp] theorem Scheme.isoSpec_Spec_hom (R : CommRingCat.{u}) :
(Spec R).isoSpec.hom = Spec.map (Scheme.ΓSpecIso R).hom :=
(SpecMap_ΓSpecIso_hom R).symm
@[simp] theorem Scheme.isoSpec_Spec_inv (R : CommRingCat.{u}) :
(Spec R).isoSpec.inv = Spec.map (Scheme.ΓSpecIso R).inv :=
congr($(isoSpec_Spec R).inv)
lemma ext_of_isAffine {X Y : Scheme} [IsAffine Y] {f g : X ⟶ Y} (e : f.appTop = g.appTop) :
f = g := by
rw [← cancel_mono Y.toSpecΓ, Scheme.toSpecΓ_naturality, Scheme.toSpecΓ_naturality, e]
/-- `Scheme.Γ.rightOp : Scheme ⥤ CommRingCatᵒᵖ` preserves limits of diagrams consisting of
affine schemes. -/
instance preservesLimit_rightOp_Γ.{v, w}
{I : Type w} [Category.{v} I] (D : I ⥤ Scheme.{u}) [∀ i, IsAffine (D.obj i)] :
PreservesLimit D Scheme.Γ.rightOp := by
let α : D ⟶ (D ⋙ Scheme.Γ.rightOp) ⋙ Scheme.Spec := D.whiskerLeft ΓSpec.adjunction.unit
have (i : _) : IsIso (α.app i) := IsAffine.affine
have : IsIso α := NatIso.isIso_of_isIso_app α
suffices PreservesLimit ((D ⋙ Scheme.Γ.rightOp) ⋙ Scheme.Spec) Scheme.Γ.rightOp from
preservesLimit_of_iso_diagram _ (asIso α).symm
have := monadicCreatesLimits.{v, w} Scheme.Spec.{u}
suffices PreservesLimit (D ⋙ Scheme.Γ.rightOp) (Scheme.Spec ⋙ Scheme.Γ.rightOp) from
preservesLimit_comp_of_createsLimit _ _
exact preservesLimit_of_natIso _ (NatIso.op Scheme.SpecΓIdentity)
/-- `Scheme.Γ : Schemeᵒᵖ ⥤ CommRingCat` preserves colimits of diagrams consisting of
affine schemes. -/
instance preservesColimit_Γ.{v, w}
{I : Type w} [Category.{v} I] (D : I ⥤ Scheme.{u}ᵒᵖ) [∀ i, IsAffine (D.obj i).unop] :
PreservesColimit D Scheme.Γ := by
have (i : _) : IsAffine (D.leftOp.obj i) := Functor.leftOp_obj D _ ▸ inferInstance
exact preservesColimit_of_rightOp D Scheme.Γ
namespace AffineScheme
/-- The `Spec` functor into the category of affine schemes. -/
def Spec : CommRingCatᵒᵖ ⥤ AffineScheme :=
Scheme.Spec.toEssImage
/-! We copy over instances from `Scheme.Spec.toEssImage`. -/
instance Spec_full : Spec.Full := Functor.Full.toEssImage _
instance Spec_faithful : Spec.Faithful := Functor.Faithful.toEssImage _
instance Spec_essSurj : Spec.EssSurj := Functor.EssSurj.toEssImage (F := _)
/-- The forgetful functor `AffineScheme ⥤ Scheme`. -/
@[simps!]
def forgetToScheme : AffineScheme ⥤ Scheme :=
Scheme.Spec.essImage.ι
/-! We copy over instances from `Scheme.Spec.essImageInclusion`. -/
instance forgetToScheme_full : forgetToScheme.Full :=
inferInstanceAs Scheme.Spec.essImage.ι.Full
instance forgetToScheme_faithful : forgetToScheme.Faithful :=
inferInstanceAs Scheme.Spec.essImage.ι.Faithful
/-- The global section functor of an affine scheme. -/
def Γ : AffineSchemeᵒᵖ ⥤ CommRingCat :=
forgetToScheme.op ⋙ Scheme.Γ
/-- The category of affine schemes is equivalent to the category of commutative rings. -/
def equivCommRingCat : AffineScheme ≌ CommRingCatᵒᵖ :=
equivEssImageOfReflective.symm
instance : Γ.{u}.rightOp.IsEquivalence := equivCommRingCat.isEquivalence_functor
instance : Γ.{u}.rightOp.op.IsEquivalence := equivCommRingCat.op.isEquivalence_functor
instance ΓIsEquiv : Γ.{u}.IsEquivalence :=
inferInstanceAs (Γ.{u}.rightOp.op ⋙ (opOpEquivalence _).functor).IsEquivalence
instance hasColimits : HasColimits AffineScheme.{u} :=
haveI := Adjunction.has_limits_of_equivalence.{u} Γ.{u}
Adjunction.has_colimits_of_equivalence.{u} (opOpEquivalence AffineScheme.{u}).inverse
instance hasLimits : HasLimits AffineScheme.{u} := by
haveI := Adjunction.has_colimits_of_equivalence Γ.{u}
haveI : HasLimits AffineScheme.{u}ᵒᵖᵒᵖ := Limits.hasLimits_op_of_hasColimits
exact Adjunction.has_limits_of_equivalence (opOpEquivalence AffineScheme.{u}).inverse
noncomputable instance Γ_preservesLimits : PreservesLimits Γ.{u}.rightOp := inferInstance
noncomputable instance forgetToScheme_preservesLimits : PreservesLimits forgetToScheme := by
apply (config := { allowSynthFailures := true })
@preservesLimits_of_natIso _ _ _ _ _ _
(Functor.isoWhiskerRight equivCommRingCat.unitIso forgetToScheme).symm
change PreservesLimits (equivCommRingCat.functor ⋙ Scheme.Spec)
infer_instance
/-- The forgetful functor `AffineScheme ⥤ Scheme` creates small limits. -/
instance createsLimitsForgetToScheme : CreatesLimits forgetToScheme.{u} :=
⟨⟨createsLimitOfReflectsIsomorphismsOfPreserves⟩⟩
end AffineScheme
/-- An open subset of a scheme is affine if the open subscheme is affine. -/
def IsAffineOpen {X : Scheme} (U : X.Opens) : Prop :=
IsAffine U
/-- The set of affine opens as a subset of `opens X`. -/
def Scheme.affineOpens (X : Scheme) : Set X.Opens :=
{U : X.Opens | IsAffineOpen U}
instance {Y : Scheme.{u}} (U : Y.affineOpens) : IsAffine U :=
U.property
theorem isAffineOpen_opensRange {X Y : Scheme} [IsAffine X] (f : X ⟶ Y)
[H : IsOpenImmersion f] : IsAffineOpen f.opensRange := by
refine .of_isIso (IsOpenImmersion.isoOfRangeEq f (Y.ofRestrict _) ?_).inv
exact Subtype.range_val.symm
theorem isAffineOpen_top (X : Scheme) [IsAffine X] : IsAffineOpen (⊤ : X.Opens) := by
convert isAffineOpen_opensRange (𝟙 X)
ext1
exact Set.range_id.symm
theorem exists_isAffineOpen_mem_and_subset {X : Scheme.{u}} {x : X}
{U : X.Opens} (hxU : x ∈ U) : ∃ W : X.Opens, IsAffineOpen W ∧ x ∈ W ∧ W.1 ⊆ U := by
obtain ⟨R, f, hf⟩ := AlgebraicGeometry.Scheme.exists_affine_mem_range_and_range_subset hxU
exact ⟨Scheme.Hom.opensRange f (H := hf.1),
⟨AlgebraicGeometry.isAffineOpen_opensRange f (H := hf.1), hf.2.1, hf.2.2⟩⟩
instance Scheme.isAffine_affineCover (X : Scheme) (i : X.affineCover.I₀) :
IsAffine (X.affineCover.X i) :=
isAffine_Spec _
instance Scheme.isAffine_affineBasisCover (X : Scheme) (i : X.affineBasisCover.I₀) :
IsAffine (X.affineBasisCover.X i) :=
isAffine_Spec _
instance Scheme.isAffine_affineOpenCover (X : Scheme) (𝒰 : X.AffineOpenCover) (i : 𝒰.I₀) :
IsAffine (𝒰.openCover.X i) :=
inferInstanceAs (IsAffine (Spec (𝒰.X i)))
instance (X : Scheme) [CompactSpace X] (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.X i)] (i) :
IsAffine (𝒰.finiteSubcover.X i) :=
inferInstanceAs (IsAffine (𝒰.X _))
instance {X} [IsAffine X] (i) :
IsAffine ((Scheme.coverOfIsIso (P := @IsOpenImmersion) (𝟙 X)).X i) := by
dsimp; infer_instance
theorem Scheme.isBasis_affineOpens (X : Scheme) : Opens.IsBasis X.affineOpens := by
rw [Opens.isBasis_iff_nbhd]
rintro U x (hU : x ∈ (U : Set X))
obtain ⟨S, hS, hxS, hSU⟩ := X.affineBasisCover_is_basis.exists_subset_of_mem_open hU U.isOpen
refine ⟨⟨S, X.affineBasisCover_is_basis.isOpen hS⟩, ?_, hxS, hSU⟩
rcases hS with ⟨i, rfl⟩
exact isAffineOpen_opensRange _
@[deprecated (since := "2025-10-07")] alias isBasis_affine_open := Scheme.isBasis_affineOpens
theorem iSup_affineOpens_eq_top (X : Scheme) : ⨆ i : X.affineOpens, (i : X.Opens) = ⊤ := by
apply Opens.ext
rw [Opens.coe_iSup]
apply IsTopologicalBasis.sUnion_eq
rw [← Set.image_eq_range]
exact X.isBasis_affineOpens
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
(X : Scheme) [IsAffine X] (f : Γ(X, ⊤)) :
X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f :=
Scheme.toSpecΓ_preimage_basicOpen _ _
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
Opens.IsBasis (Set.range (X.basicOpen : Γ(X, ⊤) → X.Opens)) := by
convert PrimeSpectrum.isBasis_basic_opens.of_isInducing
(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).isInducing using 1
ext V
simp only [Set.mem_range, exists_exists_eq_and, Set.mem_setOf,
← Opens.coe_inj (V := V), ← Scheme.toSpecΓ_preimage_basicOpen]
rfl
/-- The canonical map `U ⟶ Spec Γ(X, U)` for an open `U ⊆ X`. -/
noncomputable
def Scheme.Opens.toSpecΓ {X : Scheme.{u}} (U : X.Opens) :
U.toScheme ⟶ Spec Γ(X, U) :=
U.toScheme.toSpecΓ ≫ Spec.map U.topIso.inv
@[reassoc (attr := simp)]
lemma Scheme.Opens.toSpecΓ_SpecMap_presheaf_map {X : Scheme} (U V : X.Opens) (h : U ≤ V) :
U.toSpecΓ ≫ Spec.map (X.presheaf.map (homOfLE h).op) = X.homOfLE h ≫ V.toSpecΓ := by
delta Scheme.Opens.toSpecΓ
simp [← Spec.map_comp, ← X.presheaf.map_comp, toSpecΓ_naturality_assoc]
@[deprecated (since := "2025-10-07")]
alias Scheme.Opens.toSpecΓ_SpecMap_map := Scheme.Opens.toSpecΓ_SpecMap_presheaf_map
@[deprecated (since := "2025-10-07")]
alias Scheme.Opens.toSpecΓ_SpecMap_map_assoc := Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_assoc
@[reassoc] -- not simp because simp can prove this.
lemma Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_top {X : Scheme} (U : X.Opens) :
U.toSpecΓ ≫ Spec.map (X.presheaf.map (homOfLE le_top).op) = U.ι ≫ X.toSpecΓ := by
delta Scheme.Opens.toSpecΓ
simp [← Spec.map_comp, ← X.presheaf.map_comp, toSpecΓ_naturality]
@[simp]
lemma Scheme.Opens.toSpecΓ_top {X : Scheme} :
(⊤ : X.Opens).toSpecΓ = (⊤ : X.Opens).ι ≫ X.toSpecΓ := by
simp [Scheme.Opens.toSpecΓ, toSpecΓ_naturality]; rfl
@[reassoc]
lemma Scheme.Opens.toSpecΓ_appTop {X : Scheme.{u}} (U : X.Opens) :
U.toSpecΓ.appTop = (Scheme.ΓSpecIso Γ(X, U)).hom ≫ U.topIso.inv := by
simp [Scheme.Opens.toSpecΓ]
@[reassoc (attr := simp)]
lemma Scheme.Opens.toSpecΓ_naturality {X Y : Scheme} (f : X ⟶ Y) (U : Y.Opens) :
(f ⁻¹ᵁ U).toSpecΓ ≫ Spec.map (f.app U) = f ∣_ U ≫ U.toSpecΓ := by
simp only [toSpecΓ, topIso, Functor.op_obj, Functor.mapIso_inv, Iso.op_inv, eqToIso.inv,
eqToHom_op, Hom.app_eq_appLE, Category.assoc, ← Spec.map_comp, Hom.appLE_map,
toSpecΓ_naturality_assoc, TopologicalSpace.Opens.map_top, morphismRestrict_appLE, Hom.map_appLE]
namespace IsAffineOpen
variable {X Y : Scheme.{u}} {U : X.Opens} (hU : IsAffineOpen U) (f : Γ(X, U))
attribute [-simp] eqToHom_op in
/-- The isomorphism `U ≅ Spec Γ(X, U)` for an affine `U`. -/
@[simps! -isSimp inv]
def isoSpec :
↑U ≅ Spec Γ(X, U) :=
haveI : IsAffine U := hU
U.toScheme.isoSpec ≪≫ Scheme.Spec.mapIso U.topIso.symm.op
lemma isoSpec_hom : hU.isoSpec.hom = U.toSpecΓ := rfl
@[reassoc (attr := simp)]
lemma toSpecΓ_isoSpec_inv : U.toSpecΓ ≫ hU.isoSpec.inv = 𝟙 _ := hU.isoSpec.hom_inv_id
@[reassoc (attr := simp)]
lemma isoSpec_inv_toSpecΓ : hU.isoSpec.inv ≫ U.toSpecΓ = 𝟙 _ := hU.isoSpec.inv_hom_id
open IsLocalRing in
lemma isoSpec_hom_apply (x : U) :
hU.isoSpec.hom x = Spec.map (X.presheaf.germ U x x.2) (closedPoint _) := by
dsimp [IsAffineOpen.isoSpec_hom, Scheme.isoSpec_hom, Scheme.toSpecΓ_apply, Scheme.Opens.toSpecΓ,
TopCat.Presheaf.Γgerm]
rw [← Scheme.Hom.comp_apply, ← Spec.map_comp,
(Iso.eq_comp_inv _).mpr (Scheme.Opens.germ_stalkIso_hom U (V := ⊤) x trivial),
X.presheaf.germ_res_assoc, Spec.map_comp, Scheme.Hom.comp_apply]
congr 1
exact IsLocalRing.comap_closedPoint (U.stalkIso x).inv.hom
@[deprecated (since := "2025-10-07")] alias isoSpec_hom_base_apply := isoSpec_hom_apply
lemma isoSpec_hom_appTop :
hU.isoSpec.hom.appTop = (Scheme.ΓSpecIso Γ(X, U)).hom ≫ U.topIso.inv := by
simp [isoSpec, Scheme.isoSpec]
lemma isoSpec_inv_appTop :
hU.isoSpec.inv.appTop = U.topIso.hom ≫ (Scheme.ΓSpecIso Γ(X, U)).inv := by
rw [← cancel_mono hU.isoSpec.hom.appTop, ← Scheme.Hom.comp_appTop, isoSpec_hom_appTop]
simp
rfl
/-- The open immersion `Spec Γ(X, U) ⟶ X` for an affine `U`. -/
def fromSpec :
Spec Γ(X, U) ⟶ X :=
haveI : IsAffine U := hU
hU.isoSpec.inv ≫ U.ι
instance isOpenImmersion_fromSpec :
IsOpenImmersion hU.fromSpec := by
delta fromSpec
infer_instance
@[reassoc (attr := simp)]
lemma isoSpec_inv_ι : hU.isoSpec.inv ≫ U.ι = hU.fromSpec := rfl
@[reassoc (attr := simp)]
lemma toSpecΓ_fromSpec : U.toSpecΓ ≫ hU.fromSpec = U.ι := toSpecΓ_isoSpec_inv_assoc _ _
@[simp]
theorem range_fromSpec :
Set.range hU.fromSpec = U := by
delta IsAffineOpen.fromSpec; dsimp [IsAffineOpen.isoSpec_inv]
rw [Set.range_comp, Set.range_eq_univ.mpr, Set.image_univ]
· exact Subtype.range_coe
rw [← TopCat.coe_comp, ← TopCat.epi_iff_surjective]
infer_instance
@[reassoc (attr := simp)]
lemma fromSpec_toSpecΓ {X : Scheme} {U : X.Opens} (hU : IsAffineOpen U) :
hU.fromSpec ≫ X.toSpecΓ = Spec.map (X.presheaf.map (homOfLE le_top).op) := by
rw [fromSpec, Category.assoc, ← Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_top,
isoSpec_inv_toSpecΓ_assoc]
@[simp]
theorem opensRange_fromSpec : hU.fromSpec.opensRange = U := Opens.ext (range_fromSpec hU)
@[reassoc (attr := simp)]
theorem map_fromSpec {V : X.Opens} (hV : IsAffineOpen V) (f : op U ⟶ op V) :
Spec.map (X.presheaf.map f) ≫ hU.fromSpec = hV.fromSpec := by
have : IsAffine U := hU
haveI : IsAffine _ := hV
conv_rhs =>
rw [fromSpec, ← X.homOfLE_ι (V := U) f.unop.le, isoSpec_inv, Category.assoc,
← Scheme.isoSpec_inv_naturality_assoc,
← Spec.map_comp_assoc, Scheme.homOfLE_appTop, ← Functor.map_comp]
rw [fromSpec, isoSpec_inv, Category.assoc, ← Spec.map_comp_assoc, ← Functor.map_comp]
rfl
@[reassoc]
lemma SpecMap_appLE_fromSpec (f : X ⟶ Y) {V : X.Opens} {U : Y.Opens}
(hU : IsAffineOpen U) (hV : IsAffineOpen V) (i : V ≤ f ⁻¹ᵁ U) :
Spec.map (f.appLE U V i) ≫ hU.fromSpec = hV.fromSpec ≫ f := by
have : IsAffine U := hU
simp only [IsAffineOpen.fromSpec, Category.assoc, isoSpec_inv]
simp_rw [← Scheme.homOfLE_ι _ i]
rw [Category.assoc, ← morphismRestrict_ι,
← Category.assoc _ (f ∣_ U) U.ι, ← @Scheme.isoSpec_inv_naturality_assoc,
← Spec.map_comp_assoc, ← Spec.map_comp_assoc, Scheme.Hom.comp_appTop, morphismRestrict_appTop,
Scheme.homOfLE_appTop, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_map,
Scheme.Hom.appLE_map, Scheme.Hom.appLE_map, Scheme.Hom.map_appLE]
@[deprecated (since := "2025-10-07")] alias Spec_map_appLE_fromSpec := SpecMap_appLE_fromSpec
@[deprecated (since := "2025-10-07")]
alias Spec_map_appLE_fromSpec_assoc := SpecMap_appLE_fromSpec_assoc
lemma fromSpec_top [IsAffine X] : (isAffineOpen_top X).fromSpec = X.isoSpec.inv := by
rw [fromSpec, Iso.inv_comp_eq]
simp [isoSpec_hom]
lemma fromSpec_app_of_le (V : X.Opens) (h : U ≤ V) :
hU.fromSpec.app V = X.presheaf.map (homOfLE h).op ≫
(Scheme.ΓSpecIso Γ(X, U)).inv ≫ (Spec _).presheaf.map (homOfLE le_top).op := by
have : U.ι ⁻¹ᵁ V = ⊤ := eq_top_iff.mpr fun x _ ↦ h x.2
rw [IsAffineOpen.fromSpec, Scheme.Hom.comp_app, Scheme.Opens.ι_app, Scheme.Hom.app_eq _ this,
← Scheme.Hom.appTop, IsAffineOpen.isoSpec_inv_appTop]
simp only [Scheme.Opens.toScheme_presheaf_map, Scheme.Opens.topIso_hom,
Category.assoc, ← X.presheaf.map_comp_assoc]
rfl
include hU in
protected theorem isCompact :
IsCompact (U : Set X) := by
convert @IsCompact.image _ _ _ _ Set.univ hU.fromSpec PrimeSpectrum.compactSpace.1
(by fun_prop)
convert hU.range_fromSpec.symm
exact Set.image_univ
theorem _root_.AlgebraicGeometry.Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion
(f : X ⟶ Y) [H : IsOpenImmersion f] {U : X.Opens} :
IsAffineOpen (f ''ᵁ U) ↔ IsAffineOpen U :=
IsAffine.iff_of_isIso (IsOpenImmersion.isoOfRangeEq (U.ι ≫ f) (f ''ᵁ U).ι
(by simp [Scheme.Hom.comp_base, Set.range_comp])).inv
include hU in
theorem image_of_isOpenImmersion (f : X ⟶ Y) [H : IsOpenImmersion f] :
IsAffineOpen (f ''ᵁ U) := by
rwa [f.isAffineOpen_iff_of_isOpenImmersion]
theorem preimage_of_isIso {U : Y.Opens} (hU : IsAffineOpen U) (f : X ⟶ Y) [IsIso f] :
IsAffineOpen (f ⁻¹ᵁ U) :=
haveI : IsAffine _ := hU
.of_isIso (f ∣_ U)
theorem preimage_of_isOpenImmersion {U : Y.Opens} (hU : IsAffineOpen U)
(f : X ⟶ Y) [IsOpenImmersion f] (hU' : U ≤ f.opensRange) :
IsAffineOpen (f ⁻¹ᵁ U) := by
rwa [← f.isAffineOpen_iff_of_isOpenImmersion, f.image_preimage_eq_opensRange_inf,
inf_eq_right.mpr hU']
/-- The affine open sets of an open subscheme corresponds to
the affine open sets containing in the image. -/
@[simps]
def _root_.AlgebraicGeometry.IsOpenImmersion.affineOpensEquiv (f : X ⟶ Y) [H : IsOpenImmersion f] :
X.affineOpens ≃o { U : Y.affineOpens // U ≤ f.opensRange } where
toFun U := ⟨⟨f ''ᵁ U, U.2.image_of_isOpenImmersion f⟩, Set.image_subset_range _ _⟩
invFun U := ⟨f ⁻¹ᵁ U, U.1.2.preimage_of_isOpenImmersion _ U.2⟩
left_inv _ := Subtype.ext (f.preimage_image_eq _)
right_inv U := Subtype.ext (Subtype.ext (Opens.ext (Set.image_preimage_eq_of_subset U.2)))
map_rel_iff' := f.image_le_image_iff _ _
/-- The affine open sets of an open subscheme
corresponds to the affine open sets containing in the subset. -/
@[simps! apply_coe_coe]
def _root_.AlgebraicGeometry.affineOpensRestrict {X : Scheme.{u}} (U : X.Opens) :
U.toScheme.affineOpens ≃ { V : X.affineOpens // V ≤ U } :=
(IsOpenImmersion.affineOpensEquiv U.ι).toEquiv.trans (Equiv.subtypeEquivProp (by simp))
@[simp]
lemma _root_.AlgebraicGeometry.affineOpensRestrict_symm_apply_coe
{X : Scheme.{u}} (U : X.Opens) (V) :
((affineOpensRestrict U).symm V).1 = U.ι ⁻¹ᵁ V := rfl
instance (priority := 100) _root_.AlgebraicGeometry.Scheme.compactSpace_of_isAffine
(X : Scheme) [IsAffine X] :
CompactSpace X :=
⟨(isAffineOpen_top X).isCompact⟩
@[simp]
theorem fromSpec_preimage_self :
hU.fromSpec ⁻¹ᵁ U = ⊤ := by
simp_rw [← hU.opensRange_fromSpec, Scheme.Hom.preimage_opensRange]
theorem ΓSpecIso_hom_fromSpec_app :
(Scheme.ΓSpecIso Γ(X, U)).hom ≫ hU.fromSpec.app U =
(Spec Γ(X, U)).presheaf.map (eqToHom hU.fromSpec_preimage_self).op := by
change _ = (Spec Γ(X, U)).presheaf.map (homOfLE le_top).op
simp [IsAffineOpen.fromSpec_app_of_le]
@[elementwise]
theorem fromSpec_app_self :
hU.fromSpec.app U = (Scheme.ΓSpecIso Γ(X, U)).inv ≫
(Spec Γ(X, U)).presheaf.map (eqToHom hU.fromSpec_preimage_self).op := by
rw [← hU.ΓSpecIso_hom_fromSpec_app, Iso.inv_hom_id_assoc]
theorem fromSpec_preimage_basicOpen' :
hU.fromSpec ⁻¹ᵁ X.basicOpen f = (Spec Γ(X, U)).basicOpen ((Scheme.ΓSpecIso Γ(X, U)).inv f) := by
rw [Scheme.preimage_basicOpen, hU.fromSpec_app_self]
exact Scheme.basicOpen_res_eq _ _ (eqToHom hU.fromSpec_preimage_self).op
theorem fromSpec_preimage_basicOpen :
hU.fromSpec ⁻¹ᵁ X.basicOpen f = PrimeSpectrum.basicOpen f := by
rw [fromSpec_preimage_basicOpen', ← basicOpen_eq_of_affine]
theorem fromSpec_image_basicOpen :
hU.fromSpec ''ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
rw [← hU.fromSpec_preimage_basicOpen]
ext1
change hU.fromSpec '' (hU.fromSpec ⁻¹' (X.basicOpen f : Set X)) = _
rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left, hU.range_fromSpec]
exact Scheme.basicOpen_le _ _
@[simp]
theorem basicOpen_fromSpec_app :
(Spec Γ(X, U)).basicOpen (hU.fromSpec.app U f) = PrimeSpectrum.basicOpen f := by
rw [← hU.fromSpec_preimage_basicOpen, Scheme.preimage_basicOpen]
include hU in
theorem basicOpen :
IsAffineOpen (X.basicOpen f) := by
rw [← hU.fromSpec_image_basicOpen, Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion]
convert isAffineOpen_opensRange
(Spec.map (CommRingCat.ofHom <| algebraMap Γ(X, U) (Localization.Away f)))
exact Opens.ext (PrimeSpectrum.localization_away_comap_range (Localization.Away f) f).symm
lemma Spec_basicOpen {R : CommRingCat} (f : R) :
IsAffineOpen (X := Spec R) (PrimeSpectrum.basicOpen f) :=
basicOpen_eq_of_affine f ▸ (isAffineOpen_top (Spec <| .of R)).basicOpen _
instance [IsAffine X] (r : Γ(X, ⊤)) : IsAffine (X.basicOpen r) :=
(isAffineOpen_top X).basicOpen _
include hU in
theorem ι_basicOpen_preimage (r : Γ(X, ⊤)) :
IsAffineOpen ((X.basicOpen r).ι ⁻¹ᵁ U) := by
apply (X.basicOpen r).ι.isAffineOpen_iff_of_isOpenImmersion.mp
rw [Scheme.Hom.image_preimage_eq_opensRange_inf, Scheme.Opens.opensRange_ι, inf_comm,
← Scheme.basicOpen_res _ _ (homOfLE le_top).op]
exact hU.basicOpen _
include hU in
theorem exists_basicOpen_le {V : X.Opens} (x : V) (h : ↑x ∈ U) :
∃ f : Γ(X, U), X.basicOpen f ≤ V ∧ ↑x ∈ X.basicOpen f := by
have : IsAffine _ := hU
obtain ⟨_, ⟨_, ⟨r, rfl⟩, rfl⟩, h₁, h₂ : _ ≤ U.ι ⁻¹ᵁ V⟩ :=
(isBasis_basicOpen U).exists_subset_of_mem_open (x.2 : (⟨x, h⟩ : U) ∈ _) (U.ι ⁻¹ᵁ V).isOpen
replace h₁ : x.1 ∈ X.basicOpen r := by simpa [U.mem_basicOpen_toScheme] using h₁
replace h₂ : X.basicOpen r ≤ V := by
simpa [Scheme.image_basicOpen] using (U.ι.image_mono h₂).trans (U.ι.image_preimage_le _)
exact ⟨U.topIso.hom.hom r, by simp [Scheme.Opens.toScheme_presheaf_obj, h₁, h₂]⟩
noncomputable
instance {R : CommRingCat} {U} : Algebra R Γ(Spec R, U) :=
((Scheme.ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op).hom.toAlgebra
@[simp]
lemma algebraMap_Spec_obj {R : CommRingCat} {U} : algebraMap R Γ(Spec R, U) =
((Scheme.ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op).hom := rfl
instance {R : CommRingCat} {f : R} :
IsLocalization.Away f Γ(Spec R, PrimeSpectrum.basicOpen f) :=
inferInstanceAs (IsLocalization.Away f
((Spec.structureSheaf R).val.obj (op <| PrimeSpectrum.basicOpen f)))
/-- Given an affine open U and some `f : U`,
this is the canonical map `Γ(𝒪ₓ, D(f)) ⟶ Γ(Spec 𝒪ₓ(U), D(f))`
This is an isomorphism, as witnessed by an `IsIso` instance. -/
def basicOpenSectionsToAffine :
Γ(X, X.basicOpen f) ⟶ Γ(Spec Γ(X, U), PrimeSpectrum.basicOpen f) :=
hU.fromSpec.app (X.basicOpen f) ≫
(Spec Γ(X, U)).presheaf.map (eqToHom (hU.fromSpec_preimage_basicOpen f).symm).op
instance basicOpenSectionsToAffine_isIso :
IsIso (basicOpenSectionsToAffine hU f) :=
(hU.fromSpec.isIso_app _ (hU.opensRange_fromSpec.symm ▸ X.basicOpen_le f)).comp_isIso'
inferInstance
include hU in
theorem isLocalization_basicOpen :
IsLocalization.Away f Γ(X, X.basicOpen f) := by
apply
(IsLocalization.isLocalization_iff_of_ringEquiv (Submonoid.powers f)
(asIso <| basicOpenSectionsToAffine hU f).commRingCatIsoToRingEquiv).mpr
convert StructureSheaf.IsLocalization.to_basicOpen _ f using 1
-- Porting note: more hand holding is required here, the next 3 lines were not necessary
congr 1
dsimp [CommRingCat.ofHom, RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp,
basicOpenSectionsToAffine]
rw [hU.fromSpec.naturality_assoc, hU.fromSpec_app_self]
simp only [Category.assoc, ← Functor.map_comp, ← op_comp]
exact CommRingCat.hom_ext_iff.mp (StructureSheaf.toOpen_res _ _ _ _)
instance _root_.AlgebraicGeometry.isLocalization_away_of_isAffine
[IsAffine X] (r : Γ(X, ⊤)) :
IsLocalization.Away r Γ(X, X.basicOpen r) :=
isLocalization_basicOpen (isAffineOpen_top X) r
lemma appLE_eq_away_map {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens} (hU : IsAffineOpen U)
{V : X.Opens} (hV : IsAffineOpen V) (e) (r : Γ(Y, U)) :
letI := hU.isLocalization_basicOpen r
letI := hV.isLocalization_basicOpen (f.appLE U V e r)
f.appLE (Y.basicOpen r) (X.basicOpen (f.appLE U V e r)) (by simp [Scheme.Hom.appLE]) =
CommRingCat.ofHom (IsLocalization.Away.map _ _ (f.appLE U V e).hom r) := by
letI := hU.isLocalization_basicOpen r
letI := hV.isLocalization_basicOpen (f.appLE U V e r)
ext : 1
apply IsLocalization.ringHom_ext (.powers r)
rw [IsLocalization.Away.map, CommRingCat.hom_ofHom, IsLocalization.map_comp,
RingHom.algebraMap_toAlgebra, RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp,
← CommRingCat.hom_comp, Scheme.Hom.appLE_map, Scheme.Hom.map_appLE]
lemma app_basicOpen_eq_away_map {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens}
(hU : IsAffineOpen U) (h : IsAffineOpen (f ⁻¹ᵁ U)) (r : Γ(Y, U)) :
haveI := hU.isLocalization_basicOpen r
haveI := h.isLocalization_basicOpen (f.app U r)
f.app (Y.basicOpen r) =
(CommRingCat.ofHom
(IsLocalization.Away.map Γ(Y, Y.basicOpen r) Γ(X, X.basicOpen (f.app U r)) (f.app U).hom r)
≫ X.presheaf.map (eqToHom (by simp)).op) := by
haveI := hU.isLocalization_basicOpen r
haveI := h.isLocalization_basicOpen (f.app U r)
ext : 1
apply IsLocalization.ringHom_ext (.powers r)
rw [IsLocalization.Away.map, CommRingCat.hom_comp, RingHom.comp_assoc, CommRingCat.hom_ofHom,
IsLocalization.map_comp, RingHom.algebraMap_toAlgebra,
RingHom.algebraMap_toAlgebra, ← RingHom.comp_assoc, ← CommRingCat.hom_comp,
← CommRingCat.hom_comp, ← X.presheaf.map_comp]
simp
/-- `f.app (Y.basicOpen r)` is isomorphic to map induced on localizations
`Γ(Y, Y.basicOpen r) ⟶ Γ(X, X.basicOpen (f.app U r))` -/
def appBasicOpenIsoAwayMap {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens}
(hU : IsAffineOpen U) (h : IsAffineOpen (f ⁻¹ᵁ U)) (r : Γ(Y, U)) :
haveI := hU.isLocalization_basicOpen r
haveI := h.isLocalization_basicOpen (f.app U r)
Arrow.mk (f.app (Y.basicOpen r)) ≅
Arrow.mk (CommRingCat.ofHom (IsLocalization.Away.map Γ(Y, Y.basicOpen r)
Γ(X, X.basicOpen (f.app U r)) (f.app U).hom r)) :=
Arrow.isoMk (Iso.refl _) (X.presheaf.mapIso (eqToIso (by simp)).op) <| by
simp [hU.app_basicOpen_eq_away_map f h]
include hU in
theorem isLocalization_of_eq_basicOpen {V : X.Opens} (i : V ⟶ U) (e : V = X.basicOpen f) :
@IsLocalization.Away _ _ f Γ(X, V) _ (X.presheaf.map i.op).hom.toAlgebra := by
subst e; exact isLocalization_basicOpen hU f
instance _root_.AlgebraicGeometry.Γ_restrict_isLocalization
(X : Scheme.{u}) [IsAffine X] (r : Γ(X, ⊤)) :
IsLocalization.Away r Γ(X.basicOpen r, ⊤) :=
(isAffineOpen_top X).isLocalization_of_eq_basicOpen r _ (Opens.isOpenEmbedding_obj_top _)
include hU in
theorem basicOpen_basicOpen_is_basicOpen (g : Γ(X, X.basicOpen f)) :
∃ f' : Γ(X, U), X.basicOpen f' = X.basicOpen g := by
have := isLocalization_basicOpen hU f
obtain ⟨x, ⟨_, n, rfl⟩, rfl⟩ := IsLocalization.surj'' (Submonoid.powers f) g
use f * x
rw [Algebra.smul_def, Scheme.basicOpen_mul, Scheme.basicOpen_mul, RingHom.algebraMap_toAlgebra,
Scheme.basicOpen_res]
refine (inf_eq_left.mpr (inf_le_left.trans_eq (Scheme.basicOpen_of_isUnit _ ?_).symm)).symm
exact
Submonoid.leftInv_le_isUnit _
(IsLocalization.toInvSubmonoid (Submonoid.powers f) (Γ(X, X.basicOpen f))
_).prop
include hU in
theorem _root_.AlgebraicGeometry.exists_basicOpen_le_affine_inter
{V : X.Opens} (hV : IsAffineOpen V) (x : X) (hx : x ∈ U ⊓ V) :
∃ (f : Γ(X, U)) (g : Γ(X, V)), X.basicOpen f = X.basicOpen g ∧ x ∈ X.basicOpen f := by
obtain ⟨f, hf₁, hf₂⟩ := hU.exists_basicOpen_le ⟨x, hx.2⟩ hx.1
obtain ⟨g, hg₁, hg₂⟩ := hV.exists_basicOpen_le ⟨x, hf₂⟩ hx.2
obtain ⟨f', hf'⟩ :=
basicOpen_basicOpen_is_basicOpen hU f (X.presheaf.map (homOfLE hf₁ : _ ⟶ V).op g)
replace hf' := (hf'.trans (RingedSpace.basicOpen_res _ _ _)).trans (inf_eq_right.mpr hg₁)
exact ⟨f', g, hf', hf'.symm ▸ hg₂⟩
/-- The prime ideal of `𝒪ₓ(U)` corresponding to a point `x : U`. -/
noncomputable def primeIdealOf (x : U) :
PrimeSpectrum Γ(X, U) :=
hU.isoSpec.hom x
theorem fromSpec_primeIdealOf (x : U) :
hU.fromSpec (hU.primeIdealOf x) = x.1 := by
dsimp only [IsAffineOpen.fromSpec, Subtype.coe_mk, IsAffineOpen.primeIdealOf]
rw [← Scheme.Hom.comp_apply, Iso.hom_inv_id_assoc]
rfl
open IsLocalRing in
theorem primeIdealOf_eq_map_closedPoint (x : U) :
hU.primeIdealOf x = Spec.map (X.presheaf.germ _ x x.2) (closedPoint _) :=
hU.isoSpec_hom_apply _
/-- If a point `x : U` is a closed point, then its corresponding prime ideal is maximal. -/
theorem primeIdealOf_isMaximal_of_isClosed (x : U) (hx : IsClosed {(x : X)}) :
(hU.primeIdealOf x).asIdeal.IsMaximal := by
have hx₀ : IsClosed {x} := by
simpa [← Set.image_singleton, Set.preimage_image_eq _ Subtype.val_injective]
using hx.preimage U.isOpenEmbedding'.continuous
apply (hU.primeIdealOf x).isClosed_singleton_iff_isMaximal.mp
rw [primeIdealOf, ← Set.image_singleton]
refine (Topology.IsClosedEmbedding.isClosed_iff_image_isClosed <|
IsHomeomorph.isClosedEmbedding ?_).mp hx₀
apply (TopCat.isIso_iff_isHomeomorph _).mp
infer_instance
theorem isLocalization_stalk' (y : PrimeSpectrum Γ(X, U)) (hy : hU.fromSpec y ∈ U) :
@IsLocalization.AtPrime
(R := Γ(X, U))
(S := X.presheaf.stalk <| hU.fromSpec y) _ _
((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
apply
(@IsLocalization.isLocalization_iff_of_ringEquiv (R := Γ(X, U))
(S := X.presheaf.stalk (hU.fromSpec y)) _ y.asIdeal.primeCompl _
(TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec y, hy⟩) _ _
(asIso <| hU.fromSpec.stalkMap y).commRingCatIsoToRingEquiv).mpr
convert StructureSheaf.IsLocalization.to_stalk Γ(X, U) y using 1
delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
congr!
simp [RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp, IsAffineOpen.fromSpec_app_self]
rfl
theorem isLocalization_stalk (x : U) :
IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
rcases x with ⟨x, hx⟩
set y := hU.primeIdealOf ⟨x, hx⟩ with hy
have : hU.fromSpec y = x := hy ▸ hU.fromSpec_primeIdealOf ⟨x, hx⟩
clear_value y
subst this
exact hU.isLocalization_stalk' y hx
lemma stalkMap_injective (f : X ⟶ Y) {U : Opens Y} (hU : IsAffineOpen U) (x : X)
(hx : f x ∈ U)
(h : ∀ g, f.stalkMap x (Y.presheaf.germ U (f x) hx g) = 0 →
Y.presheaf.germ U (f x) hx g = 0) :
Function.Injective (f.stalkMap x) := by
letI := Y.presheaf.algebra_section_stalk ⟨f x, hx⟩
apply (hU.isLocalization_stalk ⟨f x, hx⟩).injective_of_map_algebraMap_zero
exact h
include hU in
lemma mem_ideal_iff {s : Γ(X, U)} {I : Ideal Γ(X, U)} :
s ∈ I ↔ ∀ (x : X) (h : x ∈ U), X.presheaf.germ U x h s ∈ I.map (X.presheaf.germ U x h).hom := by
refine ⟨fun hs x hxU ↦ Ideal.mem_map_of_mem _ hs, fun H ↦ ?_⟩
letI (x : _) : Algebra Γ(X, U) (X.presheaf.stalk (hU.fromSpec x)) :=
TopCat.Presheaf.algebra_section_stalk X.presheaf _
have (P : Ideal Γ(X, U)) [hP : P.IsPrime] : IsLocalization.AtPrime _ P :=
hU.isLocalization_stalk' ⟨P, hP⟩ (hU.isoSpec.inv _).2
refine Submodule.mem_of_localization_maximal
(fun P hP ↦ X.presheaf.stalk (hU.fromSpec ⟨P, hP.isPrime⟩))
(fun P hP ↦ Algebra.linearMap _ _) _ _ ?_
intro P hP
rw [Ideal.localized₀_eq_restrictScalars_map]
exact H _ _
include hU in
lemma ideal_le_iff {I J : Ideal Γ(X, U)} :
I ≤ J ↔ ∀ (x : X) (h : x ∈ U),
I.map (X.presheaf.germ U x h).hom ≤ J.map (X.presheaf.germ U x h).hom :=
⟨fun h _ _ ↦ Ideal.map_mono h,
fun H _ hs ↦ hU.mem_ideal_iff.mpr fun x hx ↦ H x hx (Ideal.mem_map_of_mem _ hs)⟩
include hU in
lemma ideal_ext_iff {I J : Ideal Γ(X, U)} :
I = J ↔ ∀ (x : X) (h : x ∈ U),
I.map (X.presheaf.germ U x h).hom = J.map (X.presheaf.germ U x h).hom := by
simp_rw [le_antisymm_iff, hU.ideal_le_iff, forall_and]
/-- The basic open set of a section `f` on an affine open as an `X.affineOpens`. -/
@[simps]
def _root_.AlgebraicGeometry.Scheme.affineBasicOpen
(X : Scheme) {U : X.affineOpens} (f : Γ(X, U)) : X.affineOpens :=
⟨X.basicOpen f, U.prop.basicOpen f⟩
lemma _root_.AlgebraicGeometry.Scheme.affineBasicOpen_le
(X : Scheme) {V : X.affineOpens} (f : Γ(X, V.1)) : X.affineBasicOpen f ≤ V :=
X.basicOpen_le f
include hU in
/--
In an affine open set `U`, a family of basic open covers `U` iff the sections span `Γ(X, U)`.
See `iSup_basicOpen_of_span_eq_top` for the inverse direction without the affine-ness assumption.
-/
theorem iSup_basicOpen_eq_self_iff {s : Set Γ(X, U)} :
⨆ f : s, X.basicOpen (f : Γ(X, U)) = U ↔ Ideal.span s = ⊤ := by
trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
· trans hU.fromSpec ⁻¹' (⨆ f : s, X.basicOpen (f : Γ(X, U))).1 = hU.fromSpec ⁻¹' U.1
· refine ⟨fun h => by rw [h], ?_⟩
intro h
apply_fun Set.image hU.fromSpec at h
rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.range_fromSpec]
at h
simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
ext1
refine Set.Subset.antisymm ?_ h
simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
intro x _
exact X.basicOpen_le x
· simp only [Opens.iSup_def, Set.preimage_iUnion]
congr! 1
· refine congr_arg (Set.iUnion ·) ?_
ext1 x
exact congr_arg Opens.carrier (hU.fromSpec_preimage_basicOpen _)
· exact congr_arg Opens.carrier hU.fromSpec_preimage_self
· simp only [Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
rw [← Set.compl_iInter, Set.compl_univ_iff, ← PrimeSpectrum.zeroLocus_iUnion, ←
PrimeSpectrum.zeroLocus_empty_iff_eq_top, PrimeSpectrum.zeroLocus_span]
simp only [Set.iUnion_singleton_eq_range, Subtype.range_val_subtype, Set.setOf_mem_eq]
@[deprecated (since := "2025-10-07")]
alias basicOpen_union_eq_self_iff := iSup_basicOpen_eq_self_iff
include hU in
theorem self_le_iSup_basicOpen_iff {s : Set Γ(X, U)} :
(U ≤ ⨆ f : s, X.basicOpen f.1) ↔ Ideal.span s = ⊤ := by
rw [← hU.iSup_basicOpen_eq_self_iff, @comm _ Eq]
refine ⟨fun h => le_antisymm h ?_, le_of_eq⟩
simp only [iSup_le_iff, SetCoe.forall]
intro x _
exact X.basicOpen_le x
@[deprecated (since := "2025-10-07")]
alias self_le_basicOpen_union_iff := self_le_iSup_basicOpen_iff
end IsAffineOpen
open _root_.PrimeSpectrum in
/-- The restriction of `Spec.map f` to a basic open `D(r)` is isomorphic to `Spec.map` of the
localization of `f` away from `r`. -/
noncomputable
def SpecMapRestrictBasicOpenIso {R S : CommRingCat} (f : R ⟶ S) (r : R) :
Arrow.mk (Spec.map f ∣_ (PrimeSpectrum.basicOpen r)) ≅
Arrow.mk (Spec.map <| CommRingCat.ofHom (Localization.awayMap f.hom r)) := by
letI e₁ : Localization.Away r ≃ₐ[R] Γ(Spec R, basicOpen r) :=
IsLocalization.algEquiv (Submonoid.powers r) _ _
letI e₂ : Localization.Away (f.hom r) ≃ₐ[S] Γ(Spec S, basicOpen (f.hom r)) :=
IsLocalization.algEquiv (Submonoid.powers (f.hom r)) _ _
refine Arrow.isoMk ?_ ?_ ?_
· exact (Spec _).isoOfEq (comap_basicOpen _ _) ≪≫
(IsAffineOpen.Spec_basicOpen (f.hom r)).isoSpec ≪≫ Scheme.Spec.mapIso e₂.toCommRingCatIso.op
· exact (IsAffineOpen.Spec_basicOpen r).isoSpec ≪≫ Scheme.Spec.mapIso e₁.toCommRingCatIso.op
· have := AlgebraicGeometry.IsOpenImmersion.of_isLocalization
(S := (Localization.Away r)) r
rw [← cancel_mono (Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away r))))]
simp only [Arrow.mk_left, Arrow.mk_right, Functor.id_obj, Scheme.isoOfEq_rfl, Iso.refl_trans,
Iso.trans_hom, Functor.mapIso_hom, Iso.op_hom, Scheme.Spec_map, Quiver.Hom.unop_op,
Arrow.mk_hom, Category.assoc, ← Spec.map_comp]
conv =>
congr
· enter [2, 1]; tactic =>
change _ =
(f ≫ (Scheme.ΓSpecIso S).inv ≫ (Spec S).presheaf.map (homOfLE le_top).op)
ext
simp only [Localization.awayMap, IsLocalization.Away.map, AlgEquiv.toRingEquiv_eq_coe,
RingEquiv.toCommRingCatIso_hom, AlgEquiv.toRingEquiv_toRingHom, CommRingCat.hom_comp,
CommRingCat.hom_ofHom, RingHom.comp_apply, IsLocalization.map_eq, RingHom.coe_coe,
AlgEquiv.commutes, IsAffineOpen.algebraMap_Spec_obj]
· enter [2, 2, 1]; tactic =>
change _ = (Scheme.ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op
ext
simp only [AlgEquiv.toRingEquiv_eq_coe, RingEquiv.toCommRingCatIso_hom,
AlgEquiv.toRingEquiv_toRingHom, CommRingCat.hom_comp, CommRingCat.hom_ofHom,
RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, AlgEquiv.commutes,
IsAffineOpen.algebraMap_Spec_obj, homOfLE_leOfHom]
simp only [IsAffineOpen.isoSpec_hom, homOfLE_leOfHom, Spec.map_comp, Category.assoc,
Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_assoc, Scheme.Opens.toSpecΓ_top,
Scheme.homOfLE_ι_assoc, morphismRestrict_ι_assoc]
simp only [← SpecMap_ΓSpecIso_hom, ← Spec.map_comp, Category.assoc, Iso.inv_hom_id,
Category.comp_id, Category.id_comp]
rfl
lemma stalkMap_injective_of_isAffine {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] (x : X)
(h : ∀ g, f.stalkMap x (Y.presheaf.Γgerm (f x) g) = 0 → Y.presheaf.Γgerm (f x) g = 0) :
Function.Injective (f.stalkMap x) :=
(isAffineOpen_top Y).stalkMap_injective f x trivial h
/--
Given a spanning set of `Γ(X, U)`, the corresponding basic open sets cover `U`.
See `IsAffineOpen.basicOpen_union_eq_self_iff` for the inverse direction for affine open sets.
-/
lemma iSup_basicOpen_of_span_eq_top {X : Scheme} (U) (s : Set Γ(X, U))
(hs : Ideal.span s = ⊤) : (⨆ i ∈ s, X.basicOpen i) = U := by
apply le_antisymm
· rw [iSup₂_le_iff]
exact fun i _ ↦ X.basicOpen_le i
· intro x hx
obtain ⟨_, ⟨V, hV, rfl⟩, hxV, hVU⟩ := X.isBasis_affineOpens.exists_subset_of_mem_open hx U.2
refine SetLike.mem_of_subset ?_ hxV
rw [← (hV.iSup_basicOpen_eq_self_iff (s := X.presheaf.map (homOfLE hVU).op '' s)).mpr
(by rw [← Ideal.map_span, hs, Ideal.map_top])]
simp only [Opens.iSup_mk, Opens.carrier_eq_coe, Set.iUnion_coe_set, Set.mem_image,
Set.iUnion_exists, Set.biUnion_and', Set.iUnion_iUnion_eq_right, Scheme.basicOpen_res,
Opens.coe_inf, Opens.coe_mk, Set.iUnion_subset_iff]
exact fun i hi ↦ (Set.inter_subset_right.trans
(Set.subset_iUnion₂ (s := fun x _ ↦ (X.basicOpen x : Set X)) i hi))
/-- Let `P` be a predicate on the affine open sets of `X` satisfying
1. If `P` holds on `U`, then `P` holds on the basic open set of every section on `U`.
2. If `P` holds for a family of basic open sets covering `U`, then `P` holds for `U`.
3. There exists an affine open cover of `X` each satisfying `P`.
Then `P` holds for every affine open of `X`.
This is also known as the **Affine communication lemma** in [*The rising sea*][RisingSea]. -/
@[elab_as_elim]
theorem of_affine_open_cover {X : Scheme} {P : X.affineOpens → Prop}
{ι} (U : ι → X.affineOpens) (iSup_U : (⨆ i, U i : X.Opens) = ⊤)
(V : X.affineOpens)
(basicOpen : ∀ (U : X.affineOpens) (f : Γ(X, U)), P U → P (X.affineBasicOpen f))
(openCover :
∀ (U : X.affineOpens) (s : Finset (Γ(X, U)))
(_ : Ideal.span (s : Set (Γ(X, U))) = ⊤),
(∀ f : s, P (X.affineBasicOpen f.1)) → P U)
(hU : ∀ i, P (U i)) : P V := by
classical
have : ∀ (x : V.1), ∃ f : Γ(X, V), ↑x ∈ X.basicOpen f ∧ P (X.affineBasicOpen f) := by
intro x
obtain ⟨i, hi⟩ := Opens.mem_iSup.mp (iSup_U.ge (Set.mem_univ x))
obtain ⟨f, g, e, hf⟩ := exists_basicOpen_le_affine_inter V.prop (U i).prop x ⟨x.prop, hi⟩
refine ⟨f, hf, ?_⟩
convert basicOpen _ g (hU i) using 1
ext1
exact e
choose f hf₁ hf₂ using this
suffices Ideal.span (Set.range f) = ⊤ by
obtain ⟨t, ht₁, ht₂⟩ := (Ideal.span_eq_top_iff_finite _).mp this
apply openCover V t ht₂
rintro ⟨i, hi⟩
obtain ⟨x, rfl⟩ := ht₁ hi
exact hf₂ x
rw [← V.prop.self_le_iSup_basicOpen_iff]
intro x hx
rw [iSup_range', SetLike.mem_coe, Opens.mem_iSup]
exact ⟨_, hf₁ ⟨x, hx⟩⟩
section ZeroLocus
namespace Scheme
open ConcreteCategory
variable (X : Scheme.{u})
/-- On a scheme `X`, the preimage of the zero locus of the prime spectrum
of `Γ(X, ⊤)` under `X.toSpecΓ : X ⟶ Spec Γ(X, ⊤)` agrees with the associated zero locus on `X`. -/
lemma toSpecΓ_preimage_zeroLocus (s : Set Γ(X, ⊤)) :
X.toSpecΓ ⁻¹' PrimeSpectrum.zeroLocus s = X.zeroLocus s :=
LocallyRingedSpace.toΓSpec_preimage_zeroLocus_eq s
/-- If `X` is affine, the image of the zero locus of global sections of `X` under `X.isoSpec`
is the zero locus in terms of the prime spectrum of `Γ(X, ⊤)`. -/
lemma isoSpec_image_zeroLocus [IsAffine X]
(s : Set Γ(X, ⊤)) :
X.isoSpec.hom '' X.zeroLocus s = PrimeSpectrum.zeroLocus s := by
rw [← X.toSpecΓ_preimage_zeroLocus]
erw [Set.image_preimage_eq]
exact (bijective_of_isIso X.isoSpec.hom.base).surjective
lemma toSpecΓ_image_zeroLocus [IsAffine X] (s : Set Γ(X, ⊤)) :
X.toSpecΓ '' X.zeroLocus s = PrimeSpectrum.zeroLocus s :=
X.isoSpec_image_zeroLocus _
lemma isoSpec_inv_preimage_zeroLocus [IsAffine X] (s : Set Γ(X, ⊤)) :
X.isoSpec.inv ⁻¹' X.zeroLocus s = PrimeSpectrum.zeroLocus s := by
rw [← toSpecΓ_preimage_zeroLocus, ← Set.preimage_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base,
X.isoSpec_inv_toSpecΓ]
rfl
lemma isoSpec_inv_image_zeroLocus [IsAffine X] (s : Set Γ(X, ⊤)) :
X.isoSpec.inv '' PrimeSpectrum.zeroLocus s = X.zeroLocus s := by
rw [← isoSpec_inv_preimage_zeroLocus, Set.image_preimage_eq]
exact (bijective_of_isIso X.isoSpec.inv.base).surjective
/-- If `X` is an affine scheme, every closed set of `X` is the zero locus
of a set of global sections. -/
lemma eq_zeroLocus_of_isClosed_of_isAffine [IsAffine X] (s : Set X) :
IsClosed s ↔ ∃ I : Ideal Γ(X, ⊤), s = X.zeroLocus (U := ⊤) I := by
refine ⟨fun hs ↦ ?_, ?_⟩
· let Z : Set (Spec Γ(X, ⊤)) := X.toΓSpecFun '' s
have hZ : IsClosed Z := (X.isoSpec.hom.homeomorph).isClosedMap _ hs
obtain ⟨I, (hI : Z = _)⟩ := (PrimeSpectrum.isClosed_iff_zeroLocus_ideal _).mp hZ
use I
simp only [← Scheme.toSpecΓ_preimage_zeroLocus, ← hI, Z]
symm
exact Set.preimage_image_eq _ (bijective_of_isIso X.isoSpec.hom.base).injective
· rintro ⟨I, rfl⟩
exact zeroLocus_isClosed X I.carrier
lemma Opens.toSpecΓ_preimage_basicOpen {X : Scheme.{u}} (U : X.Opens) (r : Γ(X, U)) :
U.toSpecΓ ⁻¹ᵁ PrimeSpectrum.basicOpen r = U.ι ⁻¹ᵁ X.basicOpen r := by
dsimp [toSpecΓ]
simp only [Scheme.toSpecΓ_preimage_basicOpen, preimage_basicOpen, ι_app, homOfLE_leOfHom]
rw [← Scheme.basicOpen_res_eq _ _ (eqToHom U.ι_preimage_self.symm).op,
← ConcreteCategory.comp_apply]
congr 3
simp [← Functor.map_comp]
rfl
open Set.Notation in
lemma Opens.toSpecΓ_preimage_zeroLocus {X : Scheme.{u}} (U : X.Opens) (s : Set Γ(X, U)) :
U.toSpecΓ ⁻¹' PrimeSpectrum.zeroLocus s = U.1 ↓∩ X.zeroLocus s := by
ext x
refine .trans (forall₂_congr fun y hy ↦ ?_) Set.mem_iInter₂.symm
exact iff_not_comm.mp congr(x ∈ $(Opens.toSpecΓ_preimage_basicOpen U y)).to_iff.symm
end Scheme
lemma IsAffineOpen.fromSpec_preimage_zeroLocus {X : Scheme.{u}} {U : X.Opens}
(hU : IsAffineOpen U) (s : Set Γ(X, U)) :
hU.fromSpec ⁻¹' X.zeroLocus s = PrimeSpectrum.zeroLocus s := by
ext x
suffices (∀ f ∈ s, ¬f ∉ x.asIdeal) ↔ s ⊆ x.asIdeal by
simpa [← hU.fromSpec_image_basicOpen, -not_not] using this
simp_rw [not_not]
rfl
lemma IsAffineOpen.fromSpec_image_zeroLocus {X : Scheme.{u}} {U : X.Opens}
(hU : IsAffineOpen U) (s : Set Γ(X, U)) :
hU.fromSpec '' PrimeSpectrum.zeroLocus s = X.zeroLocus s ∩ U := by
rw [← hU.fromSpec_preimage_zeroLocus, Set.image_preimage_eq_inter_range, range_fromSpec]
open Set.Notation in
lemma Scheme.zeroLocus_inf (X : Scheme.{u}) {U : X.Opens} (I J : Ideal Γ(X, U)) :
X.zeroLocus (U := U) ↑(I ⊓ J) = X.zeroLocus (U := U) I ∪ X.zeroLocus (U := U) J := by
suffices U.1 ↓∩ (X.zeroLocus (U := U) ↑(I ⊓ J)) =
U.1 ↓∩ (X.zeroLocus (U := U) I ∪ X.zeroLocus (U := U) J) by
ext x
by_cases hxU : x ∈ U
· simpa [hxU] using congr(⟨x, hxU⟩ ∈ $this)
· simp only [Submodule.coe_inf, Set.mem_union,
codisjoint_iff_compl_le_left.mp (X.codisjoint_zeroLocus (U := U) (I ∩ J)) hxU,
codisjoint_iff_compl_le_left.mp (X.codisjoint_zeroLocus (U := U) I) hxU, true_or]
simp only [← U.toSpecΓ_preimage_zeroLocus, PrimeSpectrum.zeroLocus_inf I J,
Set.preimage_union]
lemma Scheme.zeroLocus_biInf
{X : Scheme.{u}} {U : X.Opens} {ι : Type*}
(I : ι → Ideal Γ(X, U)) {t : Set ι} (ht : t.Finite) :
X.zeroLocus (U := U) ↑(⨅ i ∈ t, I i) = (⋃ i ∈ t, X.zeroLocus (U := U) (I i)) ∪ (↑U)ᶜ := by
refine ht.induction_on _ (by simp) fun {i t} hit ht IH ↦ ?_
simp only [Set.mem_insert_iff, Set.iUnion_iUnion_eq_or_left, ← IH, ← zeroLocus_inf,
Submodule.coe_inf, Set.union_assoc]
congr!
simp
lemma Scheme.zeroLocus_biInf_of_nonempty
{X : Scheme.{u}} {U : X.Opens} {ι : Type*}
(I : ι → Ideal Γ(X, U)) {t : Set ι} (ht : t.Finite) (ht' : t.Nonempty) :
X.zeroLocus (U := U) ↑(⨅ i ∈ t, I i) = ⋃ i ∈ t, X.zeroLocus (U := U) (I i) := by
rw [zeroLocus_biInf I ht, Set.union_eq_left]
obtain ⟨i, hi⟩ := ht'
exact fun x hx ↦ Set.mem_iUnion₂_of_mem hi
(codisjoint_iff_compl_le_left.mp (X.codisjoint_zeroLocus (U := U) (I i)) hx)
lemma Scheme.zeroLocus_iInf
{X : Scheme.{u}} {U : X.Opens} {ι : Type*}
(I : ι → Ideal Γ(X, U)) [Finite ι] :
X.zeroLocus (U := U) ↑(⨅ i, I i) = (⋃ i, X.zeroLocus (U := U) (I i)) ∪ (↑U)ᶜ := by
simpa using zeroLocus_biInf I Set.finite_univ
lemma Scheme.zeroLocus_iInf_of_nonempty
{X : Scheme.{u}} {U : X.Opens} {ι : Type*}
(I : ι → Ideal Γ(X, U)) [Finite ι] [Nonempty ι] :
X.zeroLocus (U := U) ↑(⨅ i, I i) = ⋃ i, X.zeroLocus (U := U) (I i) := by
simpa using zeroLocus_biInf_of_nonempty I Set.finite_univ
end ZeroLocus
section Factorization
variable {X : Scheme.{u}} {A : CommRingCat}
/-- Given `f : X ⟶ Spec A` and some ideal `I ≤ ker(A ⟶ Γ(X, ⊤))`,
this is the lift to `X ⟶ Spec (A ⧸ I)`. -/
def Scheme.Hom.liftQuotient (f : X.Hom (Spec A)) (I : Ideal A)
(hI : I ≤ RingHom.ker ((Scheme.ΓSpecIso A).inv ≫ f.appTop).hom) :
X ⟶ Spec <| .of (A ⧸ I) :=
X.toSpecΓ ≫ Spec.map (CommRingCat.ofHom
(Ideal.Quotient.lift _ ((Scheme.ΓSpecIso _).inv ≫ f.appTop).hom hI))
@[reassoc]
lemma Scheme.Hom.liftQuotient_comp (f : X.Hom (Spec A)) (I : Ideal A)
(hI : I ≤ RingHom.ker ((Scheme.ΓSpecIso A).inv ≫ f.appTop).hom) :
f.liftQuotient I hI ≫ Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk _)) = f := by
rw [Scheme.Hom.liftQuotient, Category.assoc, ← Spec.map_comp, ← CommRingCat.ofHom_comp,
Ideal.Quotient.lift_comp_mk]
simp only [CommRingCat.hom_comp, CommRingCat.ofHom_comp, CommRingCat.ofHom_hom, Spec.map_comp, ←
Scheme.toSpecΓ_naturality_assoc, ← SpecMap_ΓSpecIso_hom]
simp only [← Spec.map_comp, Iso.inv_hom_id, Spec.map_id, Category.comp_id]
/-- If `X ⟶ Spec A` is a morphism of schemes, then `Spec` of `A ⧸ specTargetImage f`
is the scheme-theoretic image of `f`. For this quotient as an object of `CommRingCat` see
`specTargetImage` below. -/
def specTargetImageIdeal (f : X ⟶ Spec A) : Ideal A :=
(RingHom.ker <| (((ΓSpec.adjunction).homEquiv X (op A)).symm f).unop.hom)
/-- If `X ⟶ Spec A` is a morphism of schemes, then `Spec` of `specTargetImage f` is the
scheme-theoretic image of `f` and `f` factors as
`specTargetImageFactorization f ≫ Spec.map (specTargetImageRingHom f)`
(see `specTargetImageFactorization_comp`). -/
def specTargetImage (f : X ⟶ Spec A) : CommRingCat :=
CommRingCat.of (A ⧸ specTargetImageIdeal f)
/-- If `f : X ⟶ Spec A` is a morphism of schemes, then `f` factors via
the inclusion of `Spec (specTargetImage f)` into `X`. -/
def specTargetImageFactorization (f : X ⟶ Spec A) : X ⟶ Spec (specTargetImage f) :=
f.liftQuotient _ le_rfl
/-- If `f : X ⟶ Spec A` is a morphism of schemes, the induced morphism on spectra of
`specTargetImageRingHom f` is the inclusion of the scheme-theoretic image of `f` into `Spec A`. -/
def specTargetImageRingHom (f : X ⟶ Spec A) : A ⟶ specTargetImage f :=
CommRingCat.ofHom (Ideal.Quotient.mk (specTargetImageIdeal f))
variable (f : X ⟶ Spec A)
lemma specTargetImageRingHom_surjective : Function.Surjective (specTargetImageRingHom f) :=
Ideal.Quotient.mk_surjective
lemma specTargetImageFactorization_app_injective :
Function.Injective <| (specTargetImageFactorization f).appTop := by
let φ : A ⟶ Γ(X, ⊤) := (((ΓSpec.adjunction).homEquiv X (op A)).symm f).unop
let φ' : specTargetImage f ⟶ Scheme.Γ.obj (op X) := CommRingCat.ofHom (RingHom.kerLift φ.hom)
change Function.Injective <| ((ΓSpec.adjunction.homEquiv X _) φ'.op).appTop
rw [ΓSpec_adjunction_homEquiv_eq]
apply (RingHom.kerLift_injective φ.hom).comp
exact ((ConcreteCategory.isIso_iff_bijective (Scheme.ΓSpecIso _).hom).mp inferInstance).injective
@[reassoc (attr := simp)]
lemma specTargetImageFactorization_comp :
specTargetImageFactorization f ≫ Spec.map (specTargetImageRingHom f) = f :=
f.liftQuotient_comp _ _
open RingHom
end Factorization
section Stalks
/-- Variant of `AlgebraicGeometry.localRingHom_comp_stalkIso` for `Spec.map`. -/
@[elementwise]
lemma Scheme.localRingHom_comp_stalkIso {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
(StructureSheaf.stalkIso R (PrimeSpectrum.comap f.hom p)).hom ≫
(CommRingCat.ofHom <| Localization.localRingHom
(PrimeSpectrum.comap f.hom p).asIdeal p.asIdeal f.hom rfl) ≫
(StructureSheaf.stalkIso S p).inv = (Spec.map f).stalkMap p :=
AlgebraicGeometry.localRingHom_comp_stalkIso f p
/-- Given a morphism of rings `f : R ⟶ S`, the stalk map of `Spec S ⟶ Spec R` at
a prime of `S` is isomorphic to the localized ring homomorphism. -/
def Scheme.arrowStalkMapSpecIso {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
Arrow.mk ((Spec.map f).stalkMap p) ≅ Arrow.mk (CommRingCat.ofHom <| Localization.localRingHom
(p.comap f.hom).asIdeal p.asIdeal f.hom rfl) := Arrow.isoMk
(StructureSheaf.stalkIso R (PrimeSpectrum.comap f.hom p))
(StructureSheaf.stalkIso S p) <| by
rw [← Scheme.localRingHom_comp_stalkIso]
simp
end Stalks
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Fiber.lean | import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.AlgebraicGeometry.Morphisms.Finite
import Mathlib.RingTheory.Spectrum.Prime.Jacobson
/-!
# Scheme-theoretic fiber
## Main result
- `AlgebraicGeometry.Scheme.Hom.fiber`: `f.fiber y` is the scheme-theoretic fiber of `f` at `y`.
- `AlgebraicGeometry.Scheme.Hom.fiberHomeo`: `f.fiber y` is homeomorphic to `f ⁻¹' {y}`.
- `AlgebraicGeometry.Scheme.Hom.finite_preimage`: Finite morphisms have finite fibers.
- `AlgebraicGeometry.Scheme.Hom.discrete_fiber`: Finite morphisms have discrete fibers.
-/
universe u
noncomputable section
open CategoryTheory Limits
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}}
/-- `f.fiber y` is the scheme-theoretic fiber of `f` at `y`. -/
def Scheme.Hom.fiber (f : X ⟶ Y) (y : Y) : Scheme := pullback f (Y.fromSpecResidueField y)
/-- `f.fiberι y : f.fiber y ⟶ X` is the embedding of the scheme-theoretic fiber into `X`. -/
def Scheme.Hom.fiberι (f : X ⟶ Y) (y : Y) : f.fiber y ⟶ X := pullback.fst _ _
instance (f : X ⟶ Y) (y : Y) : (f.fiber y).CanonicallyOver X where hom := f.fiberι y
/-- The canonical map from the scheme-theoretic fiber to the residue field. -/
def Scheme.Hom.fiberToSpecResidueField (f : X ⟶ Y) (y : Y) :
f.fiber y ⟶ Spec (Y.residueField y) :=
pullback.snd _ _
/-- The fiber of `f` at `y` is naturally a `κ(y)`-scheme. -/
@[reducible] def Scheme.Hom.fiberOverSpecResidueField
(f : X ⟶ Y) (y : Y) : (f.fiber y).Over (Spec (Y.residueField y)) where
hom := f.fiberToSpecResidueField y
lemma Scheme.Hom.fiberToSpecResidueField_apply (f : X ⟶ Y) (y : Y) (x : f.fiber y) :
f.fiberToSpecResidueField y x = IsLocalRing.closedPoint (Y.residueField y) :=
Subsingleton.elim (α := PrimeSpectrum _) _ _
lemma Scheme.Hom.range_fiberι (f : X ⟶ Y) (y : Y) :
Set.range (f.fiberι y) = f ⁻¹' {y} := by
simp [fiber, fiberι, Scheme.Pullback.range_fst, Scheme.range_fromSpecResidueField]
instance (f : X ⟶ Y) (y : Y) : IsPreimmersion (f.fiberι y) :=
MorphismProperty.pullback_fst _ _ inferInstance
/-- The scheme-theoretic fiber of `f` at `y` is homeomorphic to `f ⁻¹' {y}`. -/
def Scheme.Hom.fiberHomeo (f : X ⟶ Y) (y : Y) : f.fiber y ≃ₜ f ⁻¹' {y} :=
.trans (f.fiberι y).isEmbedding.toHomeomorph (.setCongr (f.range_fiberι y))
@[simp]
lemma Scheme.Hom.fiberHomeo_apply (f : X ⟶ Y) (y : Y) (x : f.fiber y) :
(f.fiberHomeo y x).1 = f.fiberι y x := rfl
@[simp]
lemma Scheme.Hom.fiberι_fiberHomeo_symm (f : X ⟶ Y) (y : Y) (x : f ⁻¹' {y}) :
f.fiberι y ((f.fiberHomeo y).symm x) = x :=
congr($((f.fiberHomeo y).apply_symm_apply x).1)
/-- A point `x` as a point in the fiber of `f` at `f x`. -/
def Scheme.Hom.asFiber (f : X ⟶ Y) (x : X) : f.fiber (f x) :=
(f.fiberHomeo (f x)).symm ⟨x, rfl⟩
@[simp]
lemma Scheme.Hom.fiberι_asFiber (f : X ⟶ Y) (x : X) : f.fiberι _ (f.asFiber x) = x :=
f.fiberι_fiberHomeo_symm _ _
instance (f : X ⟶ Y) [QuasiCompact f] (y : Y) : CompactSpace (f.fiber y) :=
haveI : QuasiCompact (f.fiberToSpecResidueField y) :=
MorphismProperty.pullback_snd _ _ inferInstance
HasAffineProperty.iff_of_isAffine (P := @QuasiCompact)
(f := f.fiberToSpecResidueField y).mp inferInstance
lemma QuasiCompact.isCompact_preimage_singleton (f : X ⟶ Y) [QuasiCompact f] (y : Y) :
IsCompact (f ⁻¹' {y}) :=
f.range_fiberι y ▸ isCompact_range (f.fiberι y).continuous
instance (f : X ⟶ Y) [IsAffineHom f] (y : Y) : IsAffine (f.fiber y) :=
haveI : IsAffineHom (f.fiberToSpecResidueField y) :=
MorphismProperty.pullback_snd _ _ inferInstance
isAffine_of_isAffineHom (f.fiberToSpecResidueField y)
instance (f : X ⟶ Y) (y : Y) [LocallyOfFiniteType f] : JacobsonSpace (f.fiber y) :=
have : LocallyOfFiniteType (f.fiberToSpecResidueField y) :=
MorphismProperty.pullback_snd _ _ inferInstance
LocallyOfFiniteType.jacobsonSpace (f.fiberToSpecResidueField y)
instance (f : X ⟶ Y) (y : Y) [IsFinite f] : Finite (f.fiber y) := by
have H : IsFinite (f.fiberToSpecResidueField y) := MorphismProperty.pullback_snd _ _ inferInstance
have : IsArtinianRing Γ(f.fiber y, ⊤) :=
@IsArtinianRing.of_finite (Y.residueField y) Γ(f.fiber y, ⊤) _ _ (show _ from _) _ _
((HasAffineProperty.iff_of_isAffine.mp H).2.comp (.of_surjective _ (Scheme.ΓSpecIso
(Y.residueField y)).commRingCatIsoToRingEquiv.symm.surjective))
exact .of_injective (β := PrimeSpectrum _) _ (f.fiber y).isoSpec.hom.homeomorph.injective
lemma IsFinite.finite_preimage_singleton (f : X ⟶ Y) [IsFinite f] (y : Y) :
(f ⁻¹' {y}).Finite :=
f.range_fiberι y ▸ Set.finite_range (f.fiberι y)
lemma Scheme.Hom.finite_preimage (f : X ⟶ Y) [IsFinite f] {s : Set Y} (hs : s.Finite) :
(f ⁻¹' s).Finite := by
rw [← Set.biUnion_of_singleton s, Set.preimage_iUnion₂]
exact hs.biUnion fun _ _ ↦ IsFinite.finite_preimage_singleton f _
instance Scheme.Hom.discrete_fiber (f : X ⟶ Y) (y : Y) [IsFinite f] :
DiscreteTopology (f.fiber y) := inferInstance
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/SpreadingOut.lean | import Mathlib.AlgebraicGeometry.Morphisms.FiniteType
import Mathlib.AlgebraicGeometry.Noetherian
import Mathlib.AlgebraicGeometry.Stalk
import Mathlib.AlgebraicGeometry.Properties
/-!
# Spreading out morphisms
Under certain conditions, a morphism on stalks `Spec 𝒪_{X, x} ⟶ Spec 𝒪_{Y, y}` can be spread
out into a neighborhood of `x`.
## Main result
Given `S`-schemes `X Y` and points `x : X` `y : Y` over `s : S`.
Suppose we have the following diagram of `S`-schemes
```
Spec 𝒪_{X, x} ⟶ X
|
Spec(φ)
↓
Spec 𝒪_{Y, y} ⟶ Y
```
We would like to spread `Spec(φ)` out to an `S`-morphism on an open subscheme `U ⊆ X`
```
Spec 𝒪_{X, x} ⟶ U ⊆ X
| |
Spec(φ) |
↓ ↓
Spec 𝒪_{Y, y} ⟶ Y
```
- `AlgebraicGeometry.spread_out_unique_of_isGermInjective`:
The lift is "unique" if the germ map is injective at `x`.
- `AlgebraicGeometry.spread_out_of_isGermInjective`:
The lift exists if `Y` is locally of finite type and the germ map is injective at `x`.
## TODO
Show that certain morphism properties can also be spread out.
-/
universe u
open CategoryTheory
namespace AlgebraicGeometry
variable {X Y S : Scheme.{u}} (f : X ⟶ Y) (sX : X ⟶ S) (sY : Y ⟶ S) {R A : CommRingCat.{u}}
/-- The germ map at `x` is injective if there exists some affine `U ∋ x`
such that the map `Γ(X, U) ⟶ X_x` is injective -/
class Scheme.IsGermInjectiveAt (X : Scheme.{u}) (x : X) : Prop where
cond : ∃ (U : X.Opens) (hx : x ∈ U), IsAffineOpen U ∧ Function.Injective (X.presheaf.germ U x hx)
lemma injective_germ_basicOpen (U : X.Opens) (hU : IsAffineOpen U)
(x : X) (hx : x ∈ U) (f : Γ(X, U))
(hf : x ∈ X.basicOpen f)
(H : Function.Injective (X.presheaf.germ U x hx)) :
Function.Injective (X.presheaf.germ (X.basicOpen f) x hf) := by
rw [RingHom.injective_iff_ker_eq_bot, RingHom.ker_eq_bot_iff_eq_zero] at H ⊢
intro t ht
have := hU.isLocalization_basicOpen f
obtain ⟨t, s, rfl⟩ := IsLocalization.exists_mk'_eq (.powers f) t
rw [← RingHom.mem_ker, IsLocalization.mk'_eq_mul_mk'_one, Ideal.mul_unit_mem_iff_mem,
RingHom.mem_ker, RingHom.algebraMap_toAlgebra, TopCat.Presheaf.germ_res_apply] at ht
swap; · exact @isUnit_of_invertible _ _ _ (@IsLocalization.invertible_mk'_one ..)
rw [H _ ht, IsLocalization.mk'_zero]
lemma Scheme.exists_germ_injective (X : Scheme.{u}) (x : X) [X.IsGermInjectiveAt x] :
∃ (U : X.Opens) (hx : x ∈ U),
IsAffineOpen U ∧ Function.Injective (X.presheaf.germ U x hx) :=
Scheme.IsGermInjectiveAt.cond
lemma Scheme.exists_le_and_germ_injective (X : Scheme.{u}) (x : X) [X.IsGermInjectiveAt x]
(V : X.Opens) (hxV : x ∈ V) :
∃ (U : X.Opens) (hx : x ∈ U),
IsAffineOpen U ∧ U ≤ V ∧ Function.Injective (X.presheaf.germ U x hx) := by
obtain ⟨U, hx, hU, H⟩ := Scheme.IsGermInjectiveAt.cond (x := x)
obtain ⟨f, hf, hxf⟩ := hU.exists_basicOpen_le ⟨x, hxV⟩ hx
exact ⟨X.basicOpen f, hxf, hU.basicOpen f, hf, injective_germ_basicOpen U hU x hx f hxf H⟩
instance (x : X) [X.IsGermInjectiveAt x] [IsOpenImmersion f] :
Y.IsGermInjectiveAt (f x) := by
obtain ⟨U, hxU, hU, H⟩ := X.exists_germ_injective x
refine ⟨⟨f ''ᵁ U, ⟨x, hxU, rfl⟩, hU.image_of_isOpenImmersion f, ?_⟩⟩
refine ((MorphismProperty.injective CommRingCat).cancel_right_of_respectsIso _
(f.stalkMap x)).mp ?_
refine ((MorphismProperty.injective CommRingCat).cancel_left_of_respectsIso
(f.appIso U).inv _).mp ?_
simpa
variable {f} in
lemma isGermInjectiveAt_iff_of_isOpenImmersion {x : X} [IsOpenImmersion f] :
Y.IsGermInjectiveAt (f x) ↔ X.IsGermInjectiveAt x := by
refine ⟨fun H ↦ ?_, fun _ ↦ inferInstance⟩
obtain ⟨U, hxU, hU, hU', H⟩ :=
Y.exists_le_and_germ_injective (f x) (V := f.opensRange) ⟨x, rfl⟩
obtain ⟨V, hV⟩ := (IsOpenImmersion.affineOpensEquiv f).surjective ⟨⟨U, hU⟩, hU'⟩
obtain rfl : f ''ᵁ V = U := Subtype.eq_iff.mp (Subtype.eq_iff.mp hV)
obtain ⟨y, hy, e : f y = f x⟩ := hxU
obtain rfl := f.isOpenEmbedding.injective e
refine ⟨V, hy, V.2, ?_⟩
replace H := ((MorphismProperty.injective CommRingCat).cancel_right_of_respectsIso _
(f.stalkMap y)).mpr H
replace H := ((MorphismProperty.injective CommRingCat).cancel_left_of_respectsIso
(f.appIso V).inv _).mpr H
simpa using H
/--
The class of schemes such that for each `x : X`,
`Γ(X, U) ⟶ X_x` is injective for some affine `U` containing `x`.
This is typically satisfied when `X` is integral or locally Noetherian.
-/
abbrev Scheme.IsGermInjective (X : Scheme.{u}) := ∀ x : X, X.IsGermInjectiveAt x
lemma Scheme.IsGermInjective.of_openCover
{X : Scheme.{u}} (𝒰 : X.OpenCover) [∀ i, (𝒰.X i).IsGermInjective] : X.IsGermInjective := by
intro x
rw [← (𝒰.covers x).choose_spec]
infer_instance
protected
lemma Scheme.IsGermInjective.Spec
(H : ∀ I : Ideal R, I.IsPrime →
∃ f : R, f ∉ I ∧ ∀ (x y : R), y * x = 0 → y ∉ I → ∃ n, f ^ n * x = 0) :
(Spec R).IsGermInjective := by
refine fun p ↦ ⟨?_⟩
obtain ⟨f, hf, H⟩ := H p.asIdeal p.2
refine ⟨PrimeSpectrum.basicOpen f, hf, ?_, ?_⟩
· rw [← basicOpen_eq_of_affine]
exact (isAffineOpen_top (Spec R)).basicOpen _
rw [RingHom.injective_iff_ker_eq_bot, RingHom.ker_eq_bot_iff_eq_zero]
intro x hx
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq
(S := ((Spec.structureSheaf R).val.obj (.op <| PrimeSpectrum.basicOpen f))) (.powers f) x
rw [← RingHom.mem_ker, IsLocalization.mk'_eq_mul_mk'_one, Ideal.mul_unit_mem_iff_mem,
RingHom.mem_ker, RingHom.algebraMap_toAlgebra] at hx
swap; · exact @isUnit_of_invertible _ _ _ (@IsLocalization.invertible_mk'_one ..)
-- There is an `Opposite.unop (Opposite.op _)` in `hx` which doesn't seem removable using
-- `simp`/`rw`.
erw [StructureSheaf.germ_toOpen] at hx
obtain ⟨⟨y, hy⟩, hy'⟩ := (IsLocalization.map_eq_zero_iff p.asIdeal.primeCompl
((Spec.structureSheaf R).presheaf.stalk p) _).mp hx
obtain ⟨n, hn⟩ := H x y hy' hy
refine (@IsLocalization.mk'_eq_zero_iff ..).mpr ?_
exact ⟨⟨_, n, rfl⟩, hn⟩
instance (priority := 100) [IsIntegral X] : X.IsGermInjective := by
refine fun x ↦ ⟨⟨(X.affineCover.f _).opensRange, X.affineCover.covers x,
(isAffineOpen_opensRange (X.affineCover.f _)), ?_⟩⟩
have : Nonempty (X.affineCover.f _).opensRange := ⟨⟨_, X.affineCover.covers x⟩⟩
have := (isAffineOpen_opensRange (X.affineCover.f _)).isLocalization_stalk
⟨_, X.affineCover.covers x⟩
exact @IsLocalization.injective _ _ _ _ _ (show _ from _) this
(Ideal.primeCompl_le_nonZeroDivisors _)
instance (priority := 100) [IsLocallyNoetherian X] : X.IsGermInjective := by
suffices ∀ (R : CommRingCat.{u}) (_ : IsNoetherianRing R), (Spec R).IsGermInjective by
refine @Scheme.IsGermInjective.of_openCover _ (X.affineOpenCover.openCover) (fun i ↦ this _ ?_)
have := isLocallyNoetherian_of_isOpenImmersion (X.affineOpenCover.f i)
infer_instance
refine fun R hR ↦ Scheme.IsGermInjective.Spec fun I hI ↦ ?_
let J := RingHom.ker <| algebraMap R (Localization.AtPrime I)
have hJ (x) : x ∈ J ↔ ∃ y : I.primeCompl, y * x = 0 :=
IsLocalization.map_eq_zero_iff I.primeCompl _ x
choose f hf using fun x ↦ (hJ x).mp
obtain ⟨s, hs⟩ := (isNoetherianRing_iff_ideal_fg R).mp ‹_› J
have hs' : (s : Set R) ⊆ J := hs ▸ Ideal.subset_span
refine ⟨_, (s.attach.prod fun x ↦ f x (hs' x.2)).2, fun x y e hy ↦ ⟨1, ?_⟩⟩
rw [pow_one, mul_comm, ← smul_eq_mul, ← Submodule.mem_annihilator_span_singleton]
refine SetLike.le_def.mp ?_ ((hJ x).mpr ⟨⟨y, hy⟩, e⟩)
rw [← hs, Ideal.span_le]
intro i hi
rw [SetLike.mem_coe, Submodule.mem_annihilator_span_singleton, smul_eq_mul,
mul_comm, ← smul_eq_mul, ← Submodule.mem_annihilator_span_singleton, Submonoid.coe_finset_prod]
refine Ideal.mem_of_dvd _ (Finset.dvd_prod_of_mem _ (s.mem_attach ⟨i, hi⟩)) ?_
rw [Submodule.mem_annihilator_span_singleton, smul_eq_mul]
exact hf i _
/--
Let `x : X` and `f g : X ⟶ Y` be two morphisms such that `f x = g x`.
If `f` and `g` agree on the stalk of `x`, then they agree on an open neighborhood of `x`,
provided `X` is "germ-injective" at `x` (e.g. when it's integral or locally Noetherian).
TODO: The condition on `X` is unnecessary when `Y` is locally of finite type.
-/
@[stacks 0BX6]
lemma spread_out_unique_of_isGermInjective {x : X} [X.IsGermInjectiveAt x]
(f g : X ⟶ Y) (e : f x = g x)
(H : f.stalkMap x =
Y.presheaf.stalkSpecializes (Inseparable.of_eq e.symm).specializes ≫ g.stalkMap x) :
∃ (U : X.Opens), x ∈ U ∧ U.ι ≫ f = U.ι ≫ g := by
obtain ⟨_, ⟨V : Y.Opens, hV, rfl⟩, hxV, -⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ (f x)) isOpen_univ
have hxV' : g x ∈ V := e ▸ hxV
obtain ⟨U, hxU, _, hUV, HU⟩ := X.exists_le_and_germ_injective x (f ⁻¹ᵁ V ⊓ g ⁻¹ᵁ V) ⟨hxV, hxV'⟩
refine ⟨U, hxU, ?_⟩
rw [← Scheme.Hom.resLE_comp_ι _ (hUV.trans inf_le_left),
← Scheme.Hom.resLE_comp_ι _ (hUV.trans inf_le_right)]
congr 1
have : IsAffine V := hV
suffices ∀ (U₀ V₀) (eU : U = U₀) (eV : V = V₀),
f.appLE V₀ U₀ (eU ▸ eV ▸ hUV.trans inf_le_left) =
g.appLE V₀ U₀ (eU ▸ eV ▸ hUV.trans inf_le_right) by
rw [← cancel_mono V.toScheme.isoSpec.hom]
simp only [Scheme.isoSpec, asIso_hom, Scheme.toSpecΓ_naturality,
Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE]
congr 2
apply this <;> simp
rintro U V rfl rfl
have := ConcreteCategory.mono_of_injective _ HU
rw [← cancel_mono (X.presheaf.germ U x hxU)]
simp only [Scheme.Hom.appLE, Category.assoc, X.presheaf.germ_res', ← Scheme.Hom.germ_stalkMap, H]
simp only [TopCat.Presheaf.germ_stalkSpecializes_assoc, Scheme.Hom.germ_stalkMap]
/--
A variant of `spread_out_unique_of_isGermInjective`
whose condition is an equality of scheme morphisms instead of ring homomorphisms.
-/
lemma spread_out_unique_of_isGermInjective' {x : X} [X.IsGermInjectiveAt x]
(f g : X ⟶ Y)
(e : X.fromSpecStalk x ≫ f = X.fromSpecStalk x ≫ g) :
∃ (U : X.Opens), x ∈ U ∧ U.ι ≫ f = U.ι ≫ g := by
fapply spread_out_unique_of_isGermInjective
· simpa using congr($e (IsLocalRing.closedPoint _))
· apply Spec.map_injective
rw [← cancel_mono (Y.fromSpecStalk _)]
simpa [Scheme.SpecMap_stalkSpecializes_fromSpecStalk]
lemma exists_lift_of_germInjective_aux {U : X.Opens} {x : X} (hxU)
(φ : A ⟶ X.presheaf.stalk x) (φRA : R ⟶ A) (φRX : R ⟶ Γ(X, U))
(hφRA : RingHom.FiniteType φRA.hom)
(e : φRA ≫ φ = φRX ≫ X.presheaf.germ U x hxU) :
∃ (V : X.Opens) (hxV : x ∈ V),
V ≤ U ∧ RingHom.range φ.hom ≤ RingHom.range (X.presheaf.germ V x hxV).hom := by
letI := φRA.hom.toAlgebra
obtain ⟨s, hs⟩ := hφRA
choose W hxW f hf using fun t ↦ X.presheaf.germ_exist x (φ t)
have H : x ∈ s.inf W ⊓ U := by
rw [← SetLike.mem_coe, TopologicalSpace.Opens.coe_inf, TopologicalSpace.Opens.coe_finset_inf]
exact ⟨by simpa using fun x _ ↦ hxW x, hxU⟩
refine ⟨s.inf W ⊓ U, H, inf_le_right, ?_⟩
letI := φRX.hom.toAlgebra
letI := (φRX ≫ X.presheaf.germ U x hxU).hom.toAlgebra
letI := (φRX ≫ X.presheaf.map (homOfLE (inf_le_right (a := s.inf W))).op).hom.toAlgebra
let φ' : A →ₐ[R] X.presheaf.stalk x :=
{ φ.hom with commutes' := DFunLike.congr_fun (congr_arg CommRingCat.Hom.hom e) }
let ψ : Γ(X, s.inf W ⊓ U) →ₐ[R] X.presheaf.stalk x :=
{ (X.presheaf.germ _ x H).hom with commutes' := fun x ↦ X.presheaf.germ_res_apply _ _ _ _ }
change AlgHom.range φ' ≤ AlgHom.range ψ
rw [← Algebra.map_top, ← hs, AlgHom.map_adjoin, Algebra.adjoin_le_iff]
rintro _ ⟨i, hi, rfl : φ i = _⟩
refine ⟨X.presheaf.map (homOfLE (inf_le_left.trans (Finset.inf_le hi))).op (f i), ?_⟩
exact (X.presheaf.germ_res_apply _ _ _ _).trans (hf _)
/--
Suppose `X` is a scheme, `x : X` such that the germ map at `x` is (locally) injective,
and `U` is a neighborhood of `x`.
Given a commutative diagram of `CommRingCat`
```
R ⟶ Γ(X, U)
↓ ↓
A ⟶ 𝒪_{X, x}
```
such that `R` is of finite type over `A`, we may lift `A ⟶ 𝒪_{X, x}` to some `A ⟶ Γ(X, V)`.
-/
lemma exists_lift_of_germInjective {x : X} [X.IsGermInjectiveAt x] {U : X.Opens} (hxU : x ∈ U)
(φ : A ⟶ X.presheaf.stalk x) (φRA : R ⟶ A) (φRX : R ⟶ Γ(X, U))
(hφRA : RingHom.FiniteType φRA.hom)
(e : φRA ≫ φ = φRX ≫ X.presheaf.germ U x hxU) :
∃ (V : X.Opens) (hxV : x ∈ V) (φ' : A ⟶ Γ(X, V)) (i : V ≤ U), IsAffineOpen V ∧
φ = φ' ≫ X.presheaf.germ V x hxV ∧ φRX ≫ X.presheaf.map i.hom.op = φRA ≫ φ' := by
obtain ⟨V, hxV, iVU, hV⟩ := exists_lift_of_germInjective_aux hxU φ φRA φRX hφRA e
obtain ⟨V', hxV', hV', iV'V, H⟩ := X.exists_le_and_germ_injective x V hxV
let f := X.presheaf.germ V' x hxV'
have hf' : RingHom.range (X.presheaf.germ V x hxV).hom ≤ RingHom.range f.hom := by
rw [← X.presheaf.germ_res iV'V.hom _ hxV']
exact Set.range_comp_subset_range (X.presheaf.map iV'V.hom.op) f
let e := RingEquiv.ofLeftInverse H.hasLeftInverse.choose_spec
refine ⟨V', hxV', CommRingCat.ofHom (e.symm.toRingHom.comp
(φ.hom.codRestrict _ (fun x ↦ hf' (hV ⟨x, rfl⟩)))), iV'V.trans iVU, hV', ?_, ?_⟩
· ext a
change φ a = (e (e.symm _)).1
simp only [RingEquiv.apply_symm_apply]
rfl
· ext a
apply e.injective
change e _ = e (e.symm _)
rw [RingEquiv.apply_symm_apply]
ext
change X.presheaf.germ _ _ _ (X.presheaf.map _ _) = (φRA ≫ φ) a
rw [TopCat.Presheaf.germ_res_apply, ‹φRA ≫ φ = _›]
rfl
/--
Given `S`-schemes `X Y` and points `x : X` `y : Y` over `s : S`.
Suppose we have the following diagram of `S`-schemes
```
Spec 𝒪_{X, x} ⟶ X
|
Spec(φ)
↓
Spec 𝒪_{Y, y} ⟶ Y
```
Then the map `Spec(φ)` spreads out to an `S`-morphism on an open subscheme `U ⊆ X`,
```
Spec 𝒪_{X, x} ⟶ U ⊆ X
| |
Spec(φ) |
↓ ↓
Spec 𝒪_{Y, y} ⟶ Y
```
provided that `Y` is locally of finite type over `S` and
`X` is "germ-injective" at `x` (e.g. when it's integral or locally Noetherian).
TODO: The condition on `X` is unnecessary when `Y` is locally of finite presentation.
-/
@[stacks 0BX6]
lemma spread_out_of_isGermInjective [LocallyOfFiniteType sY] {x : X} [X.IsGermInjectiveAt x] {y : Y}
(e : sX x = sY y) (φ : Y.presheaf.stalk y ⟶ X.presheaf.stalk x)
(h : sY.stalkMap y ≫ φ =
S.presheaf.stalkSpecializes (Inseparable.of_eq e).specializes ≫ sX.stalkMap x) :
∃ (U : X.Opens) (hxU : x ∈ U) (f : U.toScheme ⟶ Y),
Spec.map φ ≫ Y.fromSpecStalk y = U.fromSpecStalkOfMem x hxU ≫ f ∧
f ≫ sY = U.ι ≫ sX := by
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
S.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ (sX x)) isOpen_univ
have hyU : sY y ∈ U := e ▸ hxU
obtain ⟨_, ⟨V : Y.Opens, hV, rfl⟩, hyV, iVU⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open hyU (sY ⁻¹ᵁ U).2
have : sY.appLE U V iVU ≫ Y.presheaf.germ V y hyV ≫ φ =
sX.app U ≫ X.presheaf.germ (sX ⁻¹ᵁ U) x hxU := by
rw [Scheme.Hom.appLE, Category.assoc, Y.presheaf.germ_res_assoc,
← Scheme.Hom.germ_stalkMap_assoc, h]
simp
obtain ⟨W, hxW, φ', i, hW, h₁, h₂⟩ :=
exists_lift_of_germInjective (R := Γ(S, U)) (A := Γ(Y, V)) (U := sX ⁻¹ᵁ U) (x := x) hxU
(Y.presheaf.germ _ y hyV ≫ φ) (sY.appLE U V iVU) (sX.app U)
(LocallyOfFiniteType.finiteType_of_affine_subset ⟨_, hU⟩ ⟨_, hV⟩ _) this
refine ⟨W, hxW, W.toSpecΓ ≫ Spec.map φ' ≫ hV.fromSpec, ?_, ?_⟩
· rw [W.fromSpecStalkOfMem_toSpecΓ_assoc x hxW, ← Spec.map_comp_assoc, ← h₁,
Spec.map_comp, Category.assoc, ← IsAffineOpen.fromSpecStalk,
IsAffineOpen.fromSpecStalk_eq_fromSpecStalk]
· simp only [Category.assoc]
rw [← IsAffineOpen.SpecMap_appLE_fromSpec sY hU hV iVU, ← Spec.map_comp_assoc, ← h₂,
← Scheme.Hom.appLE, ← hW.isoSpec_hom, IsAffineOpen.SpecMap_appLE_fromSpec sX hU hW i,
← Iso.eq_inv_comp, IsAffineOpen.isoSpec_inv_ι_assoc]
/--
Given `S`-schemes `X Y`, a point `x : X`, and a `S`-morphism `φ : Spec 𝒪_{X, x} ⟶ Y`,
we may spread it out to an `S`-morphism `f : U ⟶ Y`
provided that `Y` is locally of finite type over `S` and
`X` is "germ-injective" at `x` (e.g. when it's integral or locally Noetherian).
TODO: The condition on `X` is unnecessary when `Y` is locally of finite presentation.
-/
lemma spread_out_of_isGermInjective' [LocallyOfFiniteType sY] {x : X} [X.IsGermInjectiveAt x]
(φ : Spec (X.presheaf.stalk x) ⟶ Y)
(h : φ ≫ sY = X.fromSpecStalk x ≫ sX) :
∃ (U : X.Opens) (hxU : x ∈ U) (f : U.toScheme ⟶ Y),
φ = U.fromSpecStalkOfMem x hxU ≫ f ∧ f ≫ sY = U.ι ≫ sX := by
have := spread_out_of_isGermInjective sX sY ?_ (Scheme.stalkClosedPointTo φ) ?_
· simpa only [Scheme.Spec_stalkClosedPointTo_fromSpecStalk] using this
· rw [← Scheme.Hom.comp_apply, h, Scheme.Hom.comp_apply, Scheme.fromSpecStalk_closedPoint]
· apply Spec.map_injective
rw [← cancel_mono (S.fromSpecStalk _)]
simpa only [Spec.map_comp, Category.assoc, Scheme.SpecMap_stalkMap_fromSpecStalk,
Scheme.Spec_stalkClosedPointTo_fromSpecStalk_assoc,
Scheme.SpecMap_stalkSpecializes_fromSpecStalk]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Stalk.lean | import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Morphisms.Preimmersion
/-!
# Stalks of a Scheme
## Main definitions and results
- `AlgebraicGeometry.Scheme.fromSpecStalk`: The canonical morphism `Spec 𝒪_{X, x} ⟶ X`.
- `AlgebraicGeometry.Scheme.range_fromSpecStalk`: The range of the map `Spec 𝒪_{X, x} ⟶ X` is
exactly the `y`s that specialize to `x`.
- `AlgebraicGeometry.SpecToEquivOfLocalRing`:
Given a local ring `R` and scheme `X`, morphisms `Spec R ⟶ X` corresponds to pairs
`(x, f)` where `x : X` and `f : 𝒪_{X, x} ⟶ R` is a local ring homomorphism.
-/
namespace AlgebraicGeometry
open CategoryTheory Opposite TopologicalSpace IsLocalRing
universe u
variable {X Y : Scheme.{u}} (f : X ⟶ Y) {U V : X.Opens} (hU : IsAffineOpen U) (hV : IsAffineOpen V)
section fromSpecStalk
/--
A morphism from `Spec(O_x)` to `X`, which is defined with the help of an affine open
neighborhood `U` of `x`.
-/
noncomputable def IsAffineOpen.fromSpecStalk
{X : Scheme} {U : X.Opens} (hU : IsAffineOpen U) {x : X} (hxU : x ∈ U) :
Spec (X.presheaf.stalk x) ⟶ X :=
Spec.map (X.presheaf.germ _ x hxU) ≫ hU.fromSpec
/--
The morphism from `Spec(O_x)` to `X` given by `IsAffineOpen.fromSpec` does not depend on the affine
open neighborhood of `x` we choose.
-/
theorem IsAffineOpen.fromSpecStalk_eq (x : X) (hxU : x ∈ U) (hxV : x ∈ V) :
hU.fromSpecStalk hxU = hV.fromSpecStalk hxV := by
obtain ⟨U', h₁, h₂, h₃ : U' ≤ U ⊓ V⟩ :=
Opens.isBasis_iff_nbhd.mp X.isBasis_affineOpens (show x ∈ U ⊓ V from ⟨hxU, hxV⟩)
transitivity fromSpecStalk h₁ h₂
· delta fromSpecStalk
rw [← hU.map_fromSpec h₁ (homOfLE <| h₃.trans inf_le_left).op]
erw [← Scheme.Spec_map (X.presheaf.map _).op, ← Scheme.Spec_map (X.presheaf.germ _ x h₂).op]
rw [← Functor.map_comp_assoc, ← op_comp, TopCat.Presheaf.germ_res, Scheme.Spec_map,
Quiver.Hom.unop_op]
· delta fromSpecStalk
rw [← hV.map_fromSpec h₁ (homOfLE <| h₃.trans inf_le_right).op]
erw [← Scheme.Spec_map (X.presheaf.map _).op, ← Scheme.Spec_map (X.presheaf.germ _ x h₂).op]
rw [← Functor.map_comp_assoc, ← op_comp, TopCat.Presheaf.germ_res, Scheme.Spec_map,
Quiver.Hom.unop_op]
/--
If `x` is a point of `X`, this is the canonical morphism from `Spec(O_x)` to `X`.
-/
noncomputable def Scheme.fromSpecStalk (X : Scheme) (x : X) :
Spec (X.presheaf.stalk x) ⟶ X :=
(isAffineOpen_opensRange (X.affineCover.f (X.affineCover.idx x))).fromSpecStalk
(X.affineCover.covers x)
@[simps over] noncomputable
instance (X : Scheme.{u}) (x : X) : (Spec (X.presheaf.stalk x)).Over X := ⟨X.fromSpecStalk x⟩
noncomputable
instance (X : Scheme.{u}) (x : X) : (Spec (X.presheaf.stalk x)).CanonicallyOver X where
@[simp]
theorem IsAffineOpen.fromSpecStalk_eq_fromSpecStalk {x : X} (hxU : x ∈ U) :
hU.fromSpecStalk hxU = X.fromSpecStalk x := fromSpecStalk_eq ..
instance IsAffineOpen.fromSpecStalk_isPreimmersion {X : Scheme.{u}} {U : Opens X}
(hU : IsAffineOpen U) (x : X) (hx : x ∈ U) : IsPreimmersion (hU.fromSpecStalk hx) := by
dsimp [IsAffineOpen.fromSpecStalk]
haveI : IsPreimmersion (Spec.map (X.presheaf.germ U x hx)) :=
letI : Algebra Γ(X, U) (X.presheaf.stalk x) := (X.presheaf.germ U x hx).hom.toAlgebra
haveI := hU.isLocalization_stalk ⟨x, hx⟩
IsPreimmersion.of_isLocalization (R := Γ(X, U)) (S := X.presheaf.stalk x)
(hU.primeIdealOf ⟨x, hx⟩).asIdeal.primeCompl
apply IsPreimmersion.comp
instance {X : Scheme.{u}} (x : X) : IsPreimmersion (X.fromSpecStalk x) :=
IsAffineOpen.fromSpecStalk_isPreimmersion _ _ _
lemma IsAffineOpen.fromSpecStalk_closedPoint {U : Opens X} (hU : IsAffineOpen U)
{x : X} (hxU : x ∈ U) :
hU.fromSpecStalk hxU (closedPoint (X.presheaf.stalk x)) = x := by
rw [IsAffineOpen.fromSpecStalk, Scheme.Hom.comp_apply]
rw [← hU.primeIdealOf_eq_map_closedPoint ⟨x, hxU⟩, hU.fromSpec_primeIdealOf ⟨x, hxU⟩]
namespace Scheme
@[simp]
lemma fromSpecStalk_closedPoint {x : X} :
X.fromSpecStalk x (closedPoint (X.presheaf.stalk x)) = x :=
IsAffineOpen.fromSpecStalk_closedPoint _ _
lemma fromSpecStalk_app {x : X} (hxU : x ∈ U) :
(X.fromSpecStalk x).app U =
X.presheaf.germ U x hxU ≫
(ΓSpecIso (X.presheaf.stalk x)).inv ≫
(Spec (X.presheaf.stalk x)).presheaf.map (homOfLE le_top).op := by
obtain ⟨_, ⟨V : X.Opens, hV, rfl⟩, hxV, hVU⟩ := X.isBasis_affineOpens.exists_subset_of_mem_open
hxU U.2
rw [← hV.fromSpecStalk_eq_fromSpecStalk hxV, IsAffineOpen.fromSpecStalk, Scheme.Hom.comp_app,
hV.fromSpec_app_of_le _ hVU, ← X.presheaf.germ_res (homOfLE hVU) x hxV]
simp [Category.assoc, ← ΓSpecIso_inv_naturality_assoc]
lemma fromSpecStalk_appTop {x : X} :
(X.fromSpecStalk x).appTop =
X.presheaf.germ ⊤ x trivial ≫
(ΓSpecIso (X.presheaf.stalk x)).inv ≫
(Spec (X.presheaf.stalk x)).presheaf.map (homOfLE le_top).op :=
fromSpecStalk_app ..
@[reassoc (attr := simp)]
lemma SpecMap_stalkSpecializes_fromSpecStalk {x y : X} (h : x ⤳ y) :
Spec.map (X.presheaf.stalkSpecializes h) ≫ X.fromSpecStalk y = X.fromSpecStalk x := by
obtain ⟨_, ⟨U, hU, rfl⟩, hyU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ y) isOpen_univ
have hxU : x ∈ U := h.mem_open U.2 hyU
rw [← hU.fromSpecStalk_eq_fromSpecStalk hyU, ← hU.fromSpecStalk_eq_fromSpecStalk hxU,
IsAffineOpen.fromSpecStalk, IsAffineOpen.fromSpecStalk, ← Category.assoc, ← Spec.map_comp,
TopCat.Presheaf.germ_stalkSpecializes]
@[deprecated (since := "2025-10-07")]
alias Spec_map_stalkSpecializes_fromSpecStalk := SpecMap_stalkSpecializes_fromSpecStalk
@[deprecated (since := "2025-10-07")]
alias Spec_map_stalkSpecializes_fromSpecStalk_assoc := SpecMap_stalkSpecializes_fromSpecStalk_assoc
instance {x y : X} (h : x ⤳ y) : (Spec.map (X.presheaf.stalkSpecializes h)).IsOver X where
@[reassoc (attr := simp)]
lemma SpecMap_stalkMap_fromSpecStalk {x} :
Spec.map (f.stalkMap x) ≫ Y.fromSpecStalk _ = X.fromSpecStalk x ≫ f := by
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ := Y.isBasis_affineOpens.exists_subset_of_mem_open
(Set.mem_univ (f x)) isOpen_univ
obtain ⟨_, ⟨V, hV, rfl⟩, hxV, hVU⟩ := X.isBasis_affineOpens.exists_subset_of_mem_open
hxU (f ⁻¹ᵁ U).2
rw [← hU.fromSpecStalk_eq_fromSpecStalk hxU, ← hV.fromSpecStalk_eq_fromSpecStalk hxV,
IsAffineOpen.fromSpecStalk, ← Spec.map_comp_assoc, Scheme.Hom.germ_stalkMap f _ x hxU,
IsAffineOpen.fromSpecStalk, Spec.map_comp_assoc, ← X.presheaf.germ_res (homOfLE hVU) x hxV,
Spec.map_comp_assoc, Category.assoc, ← Spec.map_comp_assoc (f.app _),
Hom.app_eq_appLE, Hom.appLE_map, IsAffineOpen.SpecMap_appLE_fromSpec]
@[deprecated (since := "2025-10-07")]
alias Spec_map_stalkMap_fromSpecStalk := SpecMap_stalkMap_fromSpecStalk
@[deprecated (since := "2025-10-07")]
alias Spec_map_stalkMap_fromSpecStalk_assoc := SpecMap_stalkMap_fromSpecStalk_assoc
instance [X.Over Y] {x} : Spec.map ((X ↘ Y).stalkMap x) |>.IsOver Y where
lemma Spec_fromSpecStalk (R : CommRingCat) (x) :
(Spec R).fromSpecStalk x =
Spec.map ((ΓSpecIso R).inv ≫ (Spec R).presheaf.germ ⊤ x trivial) := by
rw [← (isAffineOpen_top (Spec R)).fromSpecStalk_eq_fromSpecStalk (x := x) trivial,
IsAffineOpen.fromSpecStalk, IsAffineOpen.fromSpec_top, isoSpec_Spec_inv,
← Spec.map_comp]
-- This is not a simp lemma to respect the abstraction boundaries
/-- A variant of `Spec_fromSpecStalk` that breaks abstraction boundaries. -/
lemma Spec_fromSpecStalk' (R : CommRingCat) (x) :
(Spec R).fromSpecStalk x = Spec.map (StructureSheaf.toStalk R _) :=
Spec_fromSpecStalk _ _
@[stacks 01J7]
lemma range_fromSpecStalk {x : X} :
Set.range (X.fromSpecStalk x) = { y | y ⤳ x } := by
ext y
constructor
· rintro ⟨y, rfl⟩
exact ((IsLocalRing.specializes_closedPoint y).map (X.fromSpecStalk x).continuous).trans
(specializes_of_eq fromSpecStalk_closedPoint)
· rintro (hy : y ⤳ x)
have := fromSpecStalk_closedPoint (x := y)
rw [← SpecMap_stalkSpecializes_fromSpecStalk hy] at this
exact ⟨_, this⟩
/-- The canonical map `Spec 𝒪_{X, x} ⟶ U` given `x ∈ U ⊆ X`. -/
noncomputable
def Opens.fromSpecStalkOfMem {X : Scheme.{u}} (U : X.Opens) (x : X) (hxU : x ∈ U) :
Spec (X.presheaf.stalk x) ⟶ U :=
Spec.map (inv (U.ι.stalkMap ⟨x, hxU⟩)) ≫ U.toScheme.fromSpecStalk ⟨x, hxU⟩
@[reassoc (attr := simp)]
lemma Opens.fromSpecStalkOfMem_ι {X : Scheme.{u}} (U : X.Opens) (x : X) (hxU : x ∈ U) :
U.fromSpecStalkOfMem x hxU ≫ U.ι = X.fromSpecStalk x := by
simp only [Opens.fromSpecStalkOfMem, Spec.map_inv, Category.assoc, IsIso.inv_comp_eq]
exact (Scheme.SpecMap_stalkMap_fromSpecStalk U.ι (x := ⟨x, hxU⟩)).symm
instance {X : Scheme.{u}} (U : X.Opens) (x : X) (hxU : x ∈ U) :
(U.fromSpecStalkOfMem x hxU).IsOver X where
@[reassoc]
lemma fromSpecStalk_toSpecΓ (X : Scheme.{u}) (x : X) :
X.fromSpecStalk x ≫ X.toSpecΓ = Spec.map (X.presheaf.germ ⊤ x trivial) := by
rw [Scheme.toSpecΓ_naturality, ← SpecMap_ΓSpecIso_hom, ← Spec.map_comp,
Scheme.fromSpecStalk_appTop]
simp
@[reassoc (attr := simp)]
lemma Opens.fromSpecStalkOfMem_toSpecΓ {X : Scheme.{u}} (U : X.Opens) (x : X) (hxU : x ∈ U) :
U.fromSpecStalkOfMem x hxU ≫ U.toSpecΓ = Spec.map (X.presheaf.germ U x hxU) := by
rw [fromSpecStalkOfMem, Opens.toSpecΓ, Category.assoc, fromSpecStalk_toSpecΓ_assoc,
← Spec.map_comp, ← Spec.map_comp]
congr 1
rw [IsIso.comp_inv_eq, Iso.inv_comp_eq]
erw [Hom.germ_stalkMap U.ι U ⟨x, hxU⟩]
rw [Opens.ι_app, Opens.topIso_hom, ← Functor.map_comp_assoc]
exact (U.toScheme.presheaf.germ_res (homOfLE le_top) ⟨x, hxU⟩ (U := U.ι ⁻¹ᵁ U) hxU).symm
end Scheme
end fromSpecStalk
variable (R : CommRingCat.{u}) [IsLocalRing R]
section stalkClosedPointIso
/-- For a local ring `(R, 𝔪)`,
this is the isomorphism between the stalk of `Spec R` at `𝔪` and `R`. -/
noncomputable
def stalkClosedPointIso :
(Spec R).presheaf.stalk (closedPoint R) ≅ R :=
StructureSheaf.stalkIso _ _ ≪≫ (IsLocalization.atUnits R
(closedPoint R).asIdeal.primeCompl fun _ ↦ not_not.mp).toRingEquiv.toCommRingCatIso.symm
lemma stalkClosedPointIso_inv :
(stalkClosedPointIso R).inv = StructureSheaf.toStalk R _ := by
ext x
exact StructureSheaf.localizationToStalk_of _ _ _
lemma ΓSpecIso_hom_stalkClosedPointIso_inv :
(Scheme.ΓSpecIso R).hom ≫ (stalkClosedPointIso R).inv =
(Spec R).presheaf.germ ⊤ (closedPoint _) trivial := by
rw [stalkClosedPointIso_inv, ← Iso.eq_inv_comp]
rfl
@[reassoc (attr := simp)]
lemma germ_stalkClosedPointIso_hom :
(Spec R).presheaf.germ ⊤ (closedPoint _) trivial ≫ (stalkClosedPointIso R).hom =
(Scheme.ΓSpecIso R).hom := by
rw [← ΓSpecIso_hom_stalkClosedPointIso_inv, Category.assoc, Iso.inv_hom_id, Category.comp_id]
lemma Spec_stalkClosedPointIso :
Spec.map (stalkClosedPointIso R).inv = (Spec R).fromSpecStalk (closedPoint R) := by
rw [stalkClosedPointIso_inv, Scheme.Spec_fromSpecStalk']
end stalkClosedPointIso
section stalkClosedPointTo
variable {R} (f : Spec R ⟶ X)
namespace Scheme
/--
Given a local ring `(R, 𝔪)` and a morphism `f : Spec R ⟶ X`,
they induce a (local) ring homomorphism `φ : 𝒪_{X, f 𝔪} ⟶ R`.
This is inverse to `φ ↦ Spec.map φ ≫ X.fromSpecStalk (f 𝔪)`. See `SpecToEquivOfLocalRing`.
-/
noncomputable
def stalkClosedPointTo :
X.presheaf.stalk (f (closedPoint R)) ⟶ R :=
f.stalkMap (closedPoint R) ≫ (stalkClosedPointIso R).hom
instance isLocalHom_stalkClosedPointTo :
IsLocalHom (stalkClosedPointTo f).hom :=
inferInstanceAs <| IsLocalHom (f.stalkMap (closedPoint R) ≫ (stalkClosedPointIso R).hom).hom
/-- Copy of `isLocalHom_stalkClosedPointTo` which unbundles the comm ring.
Useful for use in combination with `CommRingCat.of K` for a field `K`.
-/
instance isLocalHom_stalkClosedPointTo' {R : Type u} [CommRing R] [IsLocalRing R]
(f : Spec (.of R) ⟶ X) :
IsLocalHom (stalkClosedPointTo f).hom :=
isLocalHom_stalkClosedPointTo f
lemma preimage_eq_top_of_closedPoint_mem
{U : Opens X} (hU : f (closedPoint R) ∈ U) : f ⁻¹ᵁ U = ⊤ :=
IsLocalRing.closed_point_mem_iff.mp hU
lemma stalkClosedPointTo_comp (g : X ⟶ Y) :
stalkClosedPointTo (f ≫ g) = g.stalkMap _ ≫ stalkClosedPointTo f := by
rw [stalkClosedPointTo, Scheme.Hom.stalkMap_comp]
exact Category.assoc _ _ _
lemma germ_stalkClosedPointTo_Spec {R S : CommRingCat} [IsLocalRing S] (φ : R ⟶ S) :
(Spec R).presheaf.germ ⊤ _ trivial ≫ stalkClosedPointTo (Spec.map φ) =
(ΓSpecIso R).hom ≫ φ := by
rw [stalkClosedPointTo, Scheme.Hom.germ_stalkMap_assoc, ← Iso.inv_comp_eq,
← ΓSpecIso_inv_naturality_assoc]
simp_rw [Opens.map_top]
rw [germ_stalkClosedPointIso_hom, Iso.inv_hom_id, Category.comp_id]
@[reassoc]
lemma germ_stalkClosedPointTo (U : Opens X) (hU : f (closedPoint R) ∈ U) :
X.presheaf.germ U _ hU ≫ stalkClosedPointTo f = f.app U ≫
((Spec R).presheaf.mapIso (eqToIso (preimage_eq_top_of_closedPoint_mem f hU).symm).op ≪≫
ΓSpecIso R).hom := by
rw [stalkClosedPointTo, Scheme.Hom.germ_stalkMap_assoc, Iso.trans_hom]
congr 1
rw [← Iso.eq_comp_inv, Category.assoc, ΓSpecIso_hom_stalkClosedPointIso_inv]
simp only [Functor.mapIso_hom, Iso.op_hom, eqToIso.hom,
TopCat.Presheaf.germ_res]
@[reassoc]
lemma germ_stalkClosedPointTo_Spec_fromSpecStalk
{x : X} (f : X.presheaf.stalk x ⟶ R) [IsLocalHom f.hom] (U : Opens X) (hU) :
X.presheaf.germ U _ hU ≫ stalkClosedPointTo (Spec.map f ≫ X.fromSpecStalk x) =
X.presheaf.germ U x (by simpa using hU) ≫ f := by
have : (Spec.map f ≫ X.fromSpecStalk x) (closedPoint R) = x := by
rw [Hom.comp_apply, Spec_closedPoint, fromSpecStalk_closedPoint]
have : x ∈ U := this ▸ hU
simp only [germ_stalkClosedPointTo, Hom.comp_app,
fromSpecStalk_app (X := X) (x := x) this, Category.assoc, Iso.trans_hom, Functor.mapIso_hom,
(Spec.map f).app_eq_appLE, Hom.appLE_map_assoc, Hom.map_appLE_assoc]
simp_rw [← Opens.map_top (Spec.map f).base]
rw [← (Spec.map f).app_eq_appLE, ΓSpecIso_naturality, Iso.inv_hom_id_assoc]
lemma stalkClosedPointTo_fromSpecStalk (x : X) :
stalkClosedPointTo (X.fromSpecStalk x) =
(X.presheaf.stalkCongr (by rw [fromSpecStalk_closedPoint]; rfl)).hom := by
refine TopCat.Presheaf.stalk_hom_ext _ fun U hxU ↦ ?_
simp only [TopCat.Presheaf.stalkCongr_hom, TopCat.Presheaf.germ_stalkSpecializes]
have : X.fromSpecStalk x = Spec.map (𝟙 (X.presheaf.stalk x)) ≫ X.fromSpecStalk x := by simp
convert germ_stalkClosedPointTo_Spec_fromSpecStalk (𝟙 (X.presheaf.stalk x)) U hxU
@[reassoc]
lemma Spec_stalkClosedPointTo_fromSpecStalk :
Spec.map (stalkClosedPointTo f) ≫ X.fromSpecStalk _ = f := by
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ := X.isBasis_affineOpens.exists_subset_of_mem_open
(Set.mem_univ (f (closedPoint R))) isOpen_univ
have := IsAffineOpen.SpecMap_appLE_fromSpec f hU (isAffineOpen_top _)
(preimage_eq_top_of_closedPoint_mem f hxU).ge
rw [IsAffineOpen.fromSpec_top, Iso.eq_inv_comp, isoSpec_Spec_hom] at this
rw [← hU.fromSpecStalk_eq_fromSpecStalk hxU, IsAffineOpen.fromSpecStalk, ← Spec.map_comp_assoc,
germ_stalkClosedPointTo]
simpa only [Iso.trans_hom, Functor.mapIso_hom, Iso.op_hom, Category.assoc,
Hom.app_eq_appLE, Hom.appLE_map_assoc, Spec.map_comp_assoc]
end Scheme
end stalkClosedPointTo
variable {R}
omit [IsLocalRing R] in
/-- useful lemma for applications of `SpecToEquivOfLocalRing` -/
lemma SpecToEquivOfLocalRing_eq_iff
{f₁ f₂ : Σ x, { f : X.presheaf.stalk x ⟶ R // IsLocalHom f.hom }} :
f₁ = f₂ ↔ ∃ h₁ : f₁.1 = f₂.1, f₁.2.1 =
(X.presheaf.stalkCongr (by rw [h₁]; rfl)).hom ≫ f₂.2.1 := by
constructor
· rintro rfl; simp
· obtain ⟨x₁, ⟨f₁, h₁⟩⟩ := f₁
obtain ⟨x₂, ⟨f₂, h₂⟩⟩ := f₂
rintro ⟨rfl : x₁ = x₂, e : f₁ = _⟩
simp [e]
variable (X R)
/--
Given a local ring `R` and scheme `X`, morphisms `Spec R ⟶ X` corresponds to pairs
`(x, f)` where `x : X` and `f : 𝒪_{X, x} ⟶ R` is a local ring homomorphism.
-/
@[simps]
noncomputable
def SpecToEquivOfLocalRing :
(Spec R ⟶ X) ≃ Σ x, { f : X.presheaf.stalk x ⟶ R // IsLocalHom f.hom } where
toFun f := ⟨f (closedPoint R), Scheme.stalkClosedPointTo f, inferInstance⟩
invFun xf := Spec.map xf.2.1 ≫ X.fromSpecStalk xf.1
left_inv := Scheme.Spec_stalkClosedPointTo_fromSpecStalk
right_inv xf := by
obtain ⟨x, ⟨f, hf⟩⟩ := xf
symm
refine SpecToEquivOfLocalRing_eq_iff.mpr ⟨?_, ?_⟩
· simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Function.comp_apply, Spec_closedPoint,
Scheme.fromSpecStalk_closedPoint]
· refine TopCat.Presheaf.stalk_hom_ext _ fun U hxU ↦ ?_
simp only [Scheme.germ_stalkClosedPointTo_Spec_fromSpecStalk,
TopCat.Presheaf.stalkCongr_hom, TopCat.Presheaf.germ_stalkSpecializes_assoc]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/OpenImmersion.lean | import Mathlib.Geometry.RingedSpace.OpenImmersion
import Mathlib.AlgebraicGeometry.Scheme
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.MorphismProperty.Limits
/-!
# Open immersions of schemes
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
noncomputable section
open TopologicalSpace CategoryTheory Opposite Topology
open CategoryTheory.Limits
namespace AlgebraicGeometry
universe v v₁ v₂ u
variable {C : Type u} [Category.{v} C]
/-- A morphism of Schemes is an open immersion if it is an open immersion as a morphism
of LocallyRingedSpaces
-/
abbrev IsOpenImmersion : MorphismProperty (Scheme.{u}) :=
fun _ _ f ↦ LocallyRingedSpace.IsOpenImmersion f.toLRSHom
instance IsOpenImmersion.comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
[IsOpenImmersion f] [IsOpenImmersion g] : IsOpenImmersion (f ≫ g) :=
LocallyRingedSpace.IsOpenImmersion.comp f.toLRSHom g.toLRSHom
namespace LocallyRingedSpace.IsOpenImmersion
/-- To show that a locally ringed space is a scheme, it suffices to show that it has a jointly
surjective family of open immersions from affine schemes. -/
protected def scheme (X : LocallyRingedSpace.{u})
(h :
∀ x : X,
∃ (R : CommRingCat) (f : Spec.toLocallyRingedSpace.obj (op R) ⟶ X),
(x ∈ Set.range f.base :) ∧ LocallyRingedSpace.IsOpenImmersion f) :
Scheme where
toLocallyRingedSpace := X
local_affine := by
intro x
obtain ⟨R, f, h₁, h₂⟩ := h x
refine ⟨⟨⟨_, h₂.base_open.isOpen_range⟩, h₁⟩, R, ⟨?_⟩⟩
apply LocallyRingedSpace.isoOfSheafedSpaceIso
refine SheafedSpace.forgetToPresheafedSpace.preimageIso ?_
apply PresheafedSpace.IsOpenImmersion.isoOfRangeEq (PresheafedSpace.ofRestrict _ _) f.1
· exact Subtype.range_coe_subtype
· exact Opens.isOpenEmbedding _
end LocallyRingedSpace.IsOpenImmersion
theorem IsOpenImmersion.isOpen_range {X Y : Scheme.{u}} (f : X ⟶ Y) [H : IsOpenImmersion f] :
IsOpen (Set.range f) :=
H.base_open.isOpen_range
namespace Scheme.Hom
variable {X Y : Scheme.{u}} (f : X ⟶ Y) [H : IsOpenImmersion f]
theorem isOpenEmbedding : IsOpenEmbedding f :=
H.base_open
/-- The image of an open immersion as an open set. -/
@[simps]
def opensRange : Y.Opens :=
⟨_, f.isOpenEmbedding.isOpen_range⟩
/-- The functor `opens X ⥤ opens Y` associated with an open immersion `f : X ⟶ Y`. -/
def opensFunctor : X.Opens ⥤ Y.Opens :=
LocallyRingedSpace.IsOpenImmersion.opensFunctor f.toLRSHom
/-- `f ''ᵁ U` is notation for the image (as an open set) of `U` under an open immersion `f`.
The preferred name in lemmas is `image` and it should be treated as an infix. -/
scoped[AlgebraicGeometry] notation3:90 f:91 " ''ᵁ " U:90 => (Scheme.Hom.opensFunctor f).obj U
@[simp] lemma coe_image {U : X.Opens} : f ''ᵁ U = f '' U := rfl
lemma image_mono {U V : X.Opens} (e : U ≤ V) : f ''ᵁ U ≤ f ''ᵁ V := Set.image_mono e
@[deprecated (since := "2025-10-07")] alias image_le_image_of_le := image_mono
@[simp]
lemma opensFunctor_map_homOfLE {U V : X.Opens} (e : U ≤ V) :
(Scheme.Hom.opensFunctor f).map (homOfLE e) = homOfLE (f.image_mono e) :=
rfl
@[simp]
lemma image_top_eq_opensRange : f ''ᵁ ⊤ = f.opensRange := by
apply Opens.ext
simp
lemma opensRange_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[IsOpenImmersion f] [IsOpenImmersion g] : (f ≫ g).opensRange = g ''ᵁ f.opensRange :=
TopologicalSpace.Opens.ext (Set.range_comp g f)
lemma opensRange_of_isIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
f.opensRange = ⊤ :=
TopologicalSpace.Opens.ext (Set.range_eq_univ.mpr f.homeomorph.surjective)
lemma opensRange_comp_of_isIso {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[IsIso f] [IsOpenImmersion g] : (f ≫ g).opensRange = g.opensRange := by
rw [opensRange_comp, opensRange_of_isIso, image_top_eq_opensRange]
lemma image_le_opensRange (U : X.Opens) : f ''ᵁ U ≤ f.opensRange := by
simpa using f.image_mono le_top
@[simp]
lemma preimage_image_eq (U : X.Opens) : f ⁻¹ᵁ f ''ᵁ U = U := by
apply Opens.ext
simp [Set.preimage_image_eq _ f.isOpenEmbedding.injective]
lemma image_le_image_iff (f : X ⟶ Y) [IsOpenImmersion f] (U U' : X.Opens) :
f ''ᵁ U ≤ f ''ᵁ U' ↔ U ≤ U' := by
refine ⟨fun h ↦ ?_, f.image_mono⟩
rw [← preimage_image_eq f U, ← preimage_image_eq f U']
apply f.preimage_mono h
lemma image_preimage_eq_opensRange_inf (U : Y.Opens) : f ''ᵁ f ⁻¹ᵁ U = f.opensRange ⊓ U := by
apply Opens.ext
simp [Set.image_preimage_eq_range_inter]
@[deprecated (since := "2025-10-07")]
alias image_preimage_eq_opensRange_inter := image_preimage_eq_opensRange_inf
lemma image_preimage_le (U : Y.Opens) : f ''ᵁ f ⁻¹ᵁ U ≤ U :=
(f.image_preimage_eq_opensRange_inf U).trans_le inf_le_right
lemma image_injective : Function.Injective (f ''ᵁ ·) := by
intro U V hUV
simpa using congrArg (f ⁻¹ᵁ ·) hUV
lemma image_iSup {ι : Sort*} (s : ι → X.Opens) :
(f ''ᵁ ⨆ (i : ι), s i) = ⨆ (i : ι), f ''ᵁ s i := by
ext : 1
simp [Set.image_iUnion]
lemma image_iSup₂ {ι : Sort*} {κ : ι → Sort*} (s : (i : ι) → κ i → X.Opens) :
(f ''ᵁ ⨆ (i : ι), ⨆ (j : κ i), s i j) = ⨆ (i : ι), ⨆ (j : κ i), f ''ᵁ s i j := by
ext : 1
simp [Set.image_iUnion₂]
@[simp]
lemma comp_image {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : X.Opens)
[IsOpenImmersion f] [IsOpenImmersion g] : (f ≫ g) ''ᵁ U = g ''ᵁ f ''ᵁ U :=
TopologicalSpace.Opens.ext (Set.image_comp g f U)
@[simp]
lemma id_image {X : Scheme} (U : X.Opens) : 𝟙 X ''ᵁ U = U :=
TopologicalSpace.Opens.ext (Set.image_id _)
@[simp]
lemma inv_image {X Y : Scheme} (e : X ≅ Y) (U : Y.Opens) : e.inv ''ᵁ U = e.hom ⁻¹ᵁ U :=
TopologicalSpace.Opens.ext <| (Scheme.homeoOfIso e.symm).toEquiv.image_eq_preimage_symm _
@[simp]
lemma apply_mem_image_iff {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f]
{U : X.Opens} {x : X} : f x ∈ f ''ᵁ U ↔ x ∈ U :=
f.isOpenEmbedding.injective.mem_set_image
@[deprecated (since := "2025-10-07")] alias map_mem_image_iff := apply_mem_image_iff
@[simp]
lemma preimage_opensRange {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
f ⁻¹ᵁ f.opensRange = ⊤ := by
simp [Scheme.Hom.opensRange]
instance (U : X.Opens) : IsIso (f.app (f ''ᵁ U)) := by delta opensFunctor; infer_instance
lemma isIso_app (V : Y.Opens) (hV : V ≤ f.opensRange) : IsIso (f.app V) := by
rw [show V = f ''ᵁ f ⁻¹ᵁ V from Opens.ext (Set.image_preimage_eq_of_subset hV).symm]
infer_instance
/-- The isomorphism `Γ(Y, f(U)) ≅ Γ(X, U)` induced by an open immersion `f : X ⟶ Y`. -/
def appIso (U) : Γ(Y, f ''ᵁ U) ≅ Γ(X, U) :=
(asIso <| LocallyRingedSpace.IsOpenImmersion.invApp f.toLRSHom U).symm
@[reassoc (attr := simp)]
theorem appIso_inv_naturality {U V : X.Opens} (i : op U ⟶ op V) :
X.presheaf.map i ≫ (f.appIso V).inv =
(f.appIso U).inv ≫ Y.presheaf.map (f.opensFunctor.op.map i) :=
PresheafedSpace.IsOpenImmersion.inv_naturality _ _
theorem appIso_hom (U) :
(f.appIso U).hom = f.app (f ''ᵁ U) ≫ X.presheaf.map
(eqToHom (preimage_image_eq f U).symm).op :=
(PresheafedSpace.IsOpenImmersion.inv_invApp f.toPshHom U).trans (by rw [eqToHom_op]; rfl)
/-- A variant of `appIso_hom` that uses `Hom.appLE`. -/
theorem appIso_hom' (U) :
(f.appIso U).hom = f.appLE (f ''ᵁ U) U (preimage_image_eq f U).ge :=
f.appIso_hom U
@[reassoc (attr := simp)]
theorem app_appIso_inv (U) :
f.app U ≫ (f.appIso (f ⁻¹ᵁ U)).inv =
Y.presheaf.map (homOfLE (Set.image_preimage_subset f U.1)).op :=
PresheafedSpace.IsOpenImmersion.app_invApp _ _
/-- A variant of `app_invApp` that gives an `eqToHom` instead of `homOfLE`. -/
@[reassoc]
theorem app_invApp' (U) (hU : U ≤ f.opensRange) :
f.app U ≫ (f.appIso (f ⁻¹ᵁ U)).inv =
Y.presheaf.map (eqToHom (Opens.ext <| by simpa [Set.image_preimage_eq_inter_range])).op :=
PresheafedSpace.IsOpenImmersion.app_invApp _ _
@[reassoc (attr := simp), elementwise nosimp]
theorem appIso_inv_app (U) :
(f.appIso U).inv ≫ f.app (f ''ᵁ U) = X.presheaf.map (eqToHom (preimage_image_eq f U)).op :=
(PresheafedSpace.IsOpenImmersion.invApp_app _ _).trans (by rw [eqToHom_op])
@[reassoc (attr := simp), elementwise nosimp]
lemma appLE_appIso_inv {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] {U : Y.Opens}
{V : X.Opens} (e : V ≤ f ⁻¹ᵁ U) :
f.appLE U V e ≫ (f.appIso V).inv =
Y.presheaf.map (homOfLE <| (f.image_mono e).trans
(f.image_preimage_eq_opensRange_inf U ▸ inf_le_right)).op := by
simp only [appLE, Category.assoc, appIso_inv_naturality, Functor.op_obj, Functor.op_map,
Quiver.Hom.unop_op, opensFunctor_map_homOfLE, app_appIso_inv_assoc, Opens.carrier_eq_coe]
rw [← Functor.map_comp]
rfl
@[reassoc (attr := simp)]
lemma appIso_inv_appLE {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] {U V : X.Opens}
(e : V ≤ f ⁻¹ᵁ f ''ᵁ U) :
(f.appIso U).inv ≫ f.appLE (f ''ᵁ U) V e =
X.presheaf.map (homOfLE (by rwa [preimage_image_eq] at e)).op := by
simp only [appLE, appIso_inv_app_assoc, eqToHom_op]
rw [← Functor.map_comp]
rfl
end Scheme.Hom
/-- The open sets of an open subscheme corresponds to the open sets containing in the image. -/
@[simps]
def IsOpenImmersion.opensEquiv {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
X.Opens ≃ { U : Y.Opens // U ≤ f.opensRange } where
toFun U := ⟨f ''ᵁ U, Set.image_subset_range _ _⟩
invFun U := f ⁻¹ᵁ U
left_inv _ := Opens.ext (Set.preimage_image_eq _ f.isOpenEmbedding.injective)
right_inv U := Subtype.ext (Opens.ext (Set.image_preimage_eq_of_subset U.2))
namespace Scheme
instance isOpenImmersion_SpecMap_localizationAway {R : CommRingCat.{u}} (f : R) :
IsOpenImmersion (Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f)))) := by
apply SheafedSpace.IsOpenImmersion.of_stalk_iso (H := ?_)
· exact (PrimeSpectrum.localization_away_isOpenEmbedding (Localization.Away f) f :)
· intro x
exact isIso_SpecMap_stakMap_localization R (Submonoid.powers f) x
@[deprecated (since := "2025-10-07")]
alias basic_open_isOpenImmersion := isOpenImmersion_SpecMap_localizationAway
instance {R} [CommRing R] (f : R) :
IsOpenImmersion (Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f)))) :=
isOpenImmersion_SpecMap_localizationAway (R := .of R) f
lemma _root_.AlgebraicGeometry.IsOpenImmersion.of_isLocalization {R S} [CommRing R] [CommRing S]
[Algebra R S] (f : R) [IsLocalization.Away f S] :
IsOpenImmersion (Spec.map (CommRingCat.ofHom (algebraMap R S))) := by
have e := (IsLocalization.algEquiv (.powers f) S
(Localization.Away f)).symm.toAlgHom.comp_algebraMap
rw [← e, CommRingCat.ofHom_comp, Spec.map_comp]
have H : IsIso (CommRingCat.ofHom (IsLocalization.algEquiv
(Submonoid.powers f) S (Localization.Away f)).symm.toAlgHom.toRingHom) := by
exact inferInstanceAs (IsIso <| (IsLocalization.algEquiv
(Submonoid.powers f) S (Localization.Away f)).toRingEquiv.toCommRingCatIso.inv)
simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toAlgHom_toRingHom] at H ⊢
infer_instance
theorem exists_affine_mem_range_and_range_subset
{X : Scheme.{u}} {x : X} {U : X.Opens} (hxU : x ∈ U) :
∃ R, ∃ (f : Spec R ⟶ X), IsOpenImmersion f ∧ x ∈ Set.range f ∧ Set.range f ⊆ U := by
obtain ⟨⟨V, hxV⟩, R, ⟨e⟩⟩ := X.2 x
have : e.hom.base ⟨x, hxV⟩ ∈ (Opens.map (e.inv.base ≫ V.inclusion')).obj U :=
show ((e.hom ≫ e.inv).base ⟨x, hxV⟩).1 ∈ U from e.hom_inv_id ▸ hxU
obtain ⟨_, ⟨_, ⟨r : R, rfl⟩, rfl⟩, hr, hr'⟩ :=
PrimeSpectrum.isBasis_basic_opens.exists_subset_of_mem_open this (Opens.is_open' _)
let f : Spec (.of <| Localization.Away r) ⟶ X :=
Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away r))) ≫ ⟨e.inv ≫ X.ofRestrict _⟩
refine ⟨.of (Localization.Away r), f, inferInstance, ?_⟩
rw [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp]
erw [PrimeSpectrum.localization_away_comap_range (Localization.Away r) r]
exact ⟨⟨_, hr, congr(($(e.hom_inv_id).base ⟨x, hxV⟩).1)⟩, Set.image_subset_iff.mpr hr'⟩
end Scheme
namespace PresheafedSpace.IsOpenImmersion
section ToScheme
variable {X : PresheafedSpace CommRingCat.{u}} (Y : Scheme.{u})
variable (f : X ⟶ Y.toPresheafedSpace) [H : PresheafedSpace.IsOpenImmersion f]
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
intro x
obtain ⟨R, i, _, h₁, h₂⟩ :=
Scheme.exists_affine_mem_range_and_range_subset (U := ⟨_, H.base_open.isOpen_range⟩) ⟨x, rfl⟩
refine ⟨R, LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom _ f) _ h₂, ?_, ?_⟩
· rw [LocallyRingedSpace.IsOpenImmersion.lift_range]; exact h₁
· delta LocallyRingedSpace.IsOpenImmersion.lift; infer_instance
@[simp]
theorem toScheme_toLocallyRingedSpace :
(toScheme Y f).toLocallyRingedSpace = toLocallyRingedSpace Y.1 f :=
rfl
/-- If `X ⟶ Y` is an open immersion of PresheafedSpaces, and `Y` is a Scheme, we can
upgrade it into a morphism of Schemes.
-/
def toSchemeHom : toScheme Y f ⟶ Y :=
⟨toLocallyRingedSpaceHom _ f⟩
@[simp]
theorem toSchemeHom_toPshHom : (toSchemeHom Y f).toPshHom = f :=
rfl
instance toSchemeHom_isOpenImmersion : AlgebraicGeometry.IsOpenImmersion (toSchemeHom Y f) :=
H
theorem scheme_eq_of_locallyRingedSpace_eq {X Y : Scheme.{u}}
(H : X.toLocallyRingedSpace = Y.toLocallyRingedSpace) : X = Y := by
cases X; cases Y; congr
theorem scheme_toScheme {X Y : Scheme.{u}} (f : X ⟶ Y) [AlgebraicGeometry.IsOpenImmersion f] :
toScheme Y f.toPshHom = X := by
apply scheme_eq_of_locallyRingedSpace_eq
exact locallyRingedSpace_toLocallyRingedSpace f.toLRSHom
end ToScheme
end PresheafedSpace.IsOpenImmersion
section Restrict
variable {U : TopCat.{u}} (X : Scheme.{u}) {f : U ⟶ TopCat.of X} (h : IsOpenEmbedding f)
/-- The restriction of a Scheme along an open embedding. -/
@[simps! -isSimp carrier, simps! presheaf_obj]
def Scheme.restrict : Scheme :=
{ PresheafedSpace.IsOpenImmersion.toScheme X (X.toPresheafedSpace.ofRestrict h) with
toPresheafedSpace := X.toPresheafedSpace.restrict h }
lemma Scheme.restrict_toPresheafedSpace :
(X.restrict h).toPresheafedSpace = X.toPresheafedSpace.restrict h := rfl
/-- The canonical map from the restriction to the subspace. -/
@[simps! toLRSHom_base, simps! -isSimp toLRSHom_c_app]
def Scheme.ofRestrict : X.restrict h ⟶ X :=
⟨X.toLocallyRingedSpace.ofRestrict h⟩
@[simp]
lemma Scheme.ofRestrict_app (V) :
(X.ofRestrict h).app V = X.presheaf.map (h.isOpenMap.adjunction.counit.app V).op :=
rfl
instance IsOpenImmersion.ofRestrict : IsOpenImmersion (X.ofRestrict h) :=
show PresheafedSpace.IsOpenImmersion (X.toPresheafedSpace.ofRestrict h) by infer_instance
@[simp]
lemma Scheme.ofRestrict_appLE (V W e) :
(X.ofRestrict h).appLE V W e = X.presheaf.map
(homOfLE (show X.ofRestrict h ''ᵁ _ ≤ _ by exact Set.image_subset_iff.mpr e)).op := by
dsimp [Hom.appLE]
exact (X.presheaf.map_comp _ _).symm
@[simp]
lemma Scheme.ofRestrict_appIso (U) :
(X.ofRestrict h).appIso U = Iso.refl _ := by
ext1
simp only [restrict_presheaf_obj, Hom.appIso_hom', ofRestrict_appLE, homOfLE_refl, op_id,
CategoryTheory.Functor.map_id, Iso.refl_hom]
@[simp]
lemma Scheme.restrict_presheaf_map (V W) (i : V ⟶ W) :
(X.restrict h).presheaf.map i = X.presheaf.map (homOfLE (show X.ofRestrict h ''ᵁ W.unop ≤
X.ofRestrict h ''ᵁ V.unop from Set.image_mono i.unop.le)).op := rfl
end Restrict
namespace IsOpenImmersion
variable {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z)
variable [H : IsOpenImmersion f]
instance (priority := 100) of_isIso [IsIso g] : IsOpenImmersion g :=
LocallyRingedSpace.IsOpenImmersion.of_isIso _
theorem isIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] [Epi f.base] : IsIso f :=
@isIso_of_reflects_iso _ _ _ _ _ _ f
(Scheme.forgetToLocallyRingedSpace ⋙
LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace)
(@PresheafedSpace.IsOpenImmersion.to_iso _ _ _ _ f.toPshHom ‹_› _) _
@[deprecated (since := "2025-10-07")] alias to_iso := isIso
theorem of_isIso_stalkMap {X Y : Scheme.{u}} (f : X ⟶ Y) (hf : IsOpenEmbedding f)
[∀ x, IsIso (f.stalkMap x)] : IsOpenImmersion f :=
haveI (x : X) : IsIso (f.toShHom.stalkMap x) := inferInstanceAs <| IsIso (f.stalkMap x)
SheafedSpace.IsOpenImmersion.of_stalk_iso f.toShHom hf
@[deprecated (since := "2025-10-07")] alias of_stalk_iso := of_isIso_stalkMap
instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (x : X) :
IsIso (f.stalkMap x) :=
inferInstanceAs <| IsIso (f.toLRSHom.stalkMap x)
lemma of_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) [IsOpenImmersion g]
[IsOpenImmersion (f ≫ g)] : IsOpenImmersion f :=
haveI (x : X) : IsIso (f.stalkMap x) :=
haveI : IsIso (g.stalkMap (f x) ≫ f.stalkMap x) := by
rw [← Scheme.Hom.stalkMap_comp]
infer_instance
IsIso.of_isIso_comp_left (f := g.stalkMap (f x)) _
IsOpenImmersion.of_isIso_stalkMap _ <|
IsOpenEmbedding.of_comp _ (Scheme.Hom.isOpenEmbedding g) (Scheme.Hom.isOpenEmbedding (f ≫ g))
instance : MorphismProperty.HasOfPostcompProperty @IsOpenImmersion @IsOpenImmersion where
of_postcomp f g _ _ := .of_comp f g
theorem iff_isIso_stalkMap {X Y : Scheme.{u}} (f : X ⟶ Y) :
IsOpenImmersion f ↔ IsOpenEmbedding f ∧ ∀ x, IsIso (f.stalkMap x) :=
⟨fun H ↦ ⟨H.1, fun x ↦ inferInstanceAs <| IsIso (f.toPshHom.stalkMap x)⟩,
fun ⟨h, _⟩ ↦ .of_isIso_stalkMap f h⟩
@[deprecated (since := "2025-10-07")] alias iff_stalk_iso := iff_isIso_stalkMap
theorem _root_.AlgebraicGeometry.isIso_iff_isOpenImmersion_and_epi_base
{X Y : Scheme.{u}} (f : X ⟶ Y) :
IsIso f ↔ IsOpenImmersion f ∧ Epi f.base :=
⟨fun _ => ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ => IsOpenImmersion.isIso f⟩
@[deprecated (since := "2025-10-07")]
alias _root_.AlgebraicGeometry.isIso_iff_isOpenImmersion := isIso_iff_isOpenImmersion_and_epi_base
theorem _root_.AlgebraicGeometry.isIso_iff_isIso_stalkMap {X Y : Scheme.{u}} (f : X ⟶ Y) :
IsIso f ↔ IsIso f.base ∧ ∀ x, IsIso (f.stalkMap x) := by
rw [isIso_iff_isOpenImmersion_and_epi_base,
IsOpenImmersion.iff_isIso_stalkMap, and_comm, ← and_assoc]
refine and_congr ⟨?_, ?_⟩ Iff.rfl
· rintro ⟨h₁, h₂⟩
convert_to
IsIso
(TopCat.isoOfHomeo
(Equiv.toHomeomorphOfContinuousOpen
(.ofBijective _ ⟨h₂.injective, (TopCat.epi_iff_surjective _).mp h₁⟩) h₂.continuous
h₂.isOpenMap)).hom
infer_instance
· intro H; exact ⟨inferInstance, (TopCat.homeoOfIso (asIso f.base)).isOpenEmbedding⟩
@[deprecated (since := "2025-10-07")]
alias _root_.AlgebraicGeometry.isIso_iff_stalk_iso := isIso_iff_isIso_stalkMap
/-- An open immersion induces an isomorphism from the domain onto the image -/
def isoRestrict : X ≅ Z.restrict f.isOpenEmbedding :=
Scheme.fullyFaithfulForgetToLocallyRingedSpace.preimageIso
(LocallyRingedSpace.IsOpenImmersion.isoRestrict f.toLRSHom)
local notation "forget" => Scheme.forgetToLocallyRingedSpace
instance mono : Mono f :=
(forget).mono_of_mono_map (inferInstanceAs (Mono f.toLRSHom))
lemma le_monomorphisms :
IsOpenImmersion ≤ MorphismProperty.monomorphisms Scheme.{u} := fun _ _ _ _ ↦
MorphismProperty.monomorphisms.infer_property _
instance : LocallyRingedSpace.IsOpenImmersion ((forget).map f) :=
⟨H.base_open, H.c_iso⟩
instance hasLimit_cospan_forget_of_left :
HasLimit (cospan f g ⋙ forget) := by
rw [hasLimit_iff_of_iso (diagramIsoCospan _)]
exact inferInstanceAs (HasLimit (cospan ((forget).map f) ((forget).map g)))
open CategoryTheory.Limits.WalkingCospan
instance hasLimit_cospan_forget_of_left' :
HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr)) :=
show HasLimit (cospan ((forget).map f) ((forget).map g)) from inferInstance
instance hasLimit_cospan_forget_of_right : HasLimit (cospan g f ⋙ forget) := by
rw [hasLimit_iff_of_iso (diagramIsoCospan _)]
exact inferInstanceAs (HasLimit (cospan ((forget).map g) ((forget).map f)))
instance hasLimit_cospan_forget_of_right' :
HasLimit (cospan ((cospan g f ⋙ forget).map Hom.inl) ((cospan g f ⋙ forget).map Hom.inr)) :=
show HasLimit (cospan ((forget).map g) ((forget).map f)) from inferInstance
instance forgetCreatesPullbackOfLeft : CreatesLimit (cospan f g) forget :=
createsLimitOfFullyFaithfulOfIso
(PresheafedSpace.IsOpenImmersion.toScheme Y (pullback.snd f.toLRSHom g.toLRSHom).toShHom)
(eqToIso (by simp) ≪≫ HasLimit.isoOfNatIso (diagramIsoCospan _).symm)
instance forgetCreatesPullbackOfRight : CreatesLimit (cospan g f) forget :=
createsLimitOfFullyFaithfulOfIso
(PresheafedSpace.IsOpenImmersion.toScheme Y (pullback.fst g.toLRSHom f.toLRSHom).1)
(eqToIso (by simp) ≪≫ HasLimit.isoOfNatIso (diagramIsoCospan _).symm)
instance : PreservesLimit (cospan f g) forget :=
CategoryTheory.preservesLimit_of_createsLimit_and_hasLimit _ _
instance : PreservesLimit (cospan g f) forget :=
preservesPullback_symmetry _ _ _
instance hasPullback_of_left : HasPullback f g :=
hasLimit_of_created (cospan f g) forget
instance hasPullback_of_right : HasPullback g f :=
hasLimit_of_created (cospan g f) forget
instance : IsOpenImmersion (pullback.snd f g) := by
have := PreservesPullback.iso_hom_snd forget f g
dsimp only [Scheme.forgetToLocallyRingedSpace, inducedFunctor_map] at this
change LocallyRingedSpace.IsOpenImmersion _
rw [← this]
infer_instance
instance : IsOpenImmersion (pullback.fst g f) := by
rw [← pullbackSymmetry_hom_comp_snd]
infer_instance
instance [IsOpenImmersion g] :
IsOpenImmersion (limit.π (cospan f g) WalkingCospan.one) := by
rw [← limit.w (cospan f g) WalkingCospan.Hom.inl]
change IsOpenImmersion (_ ≫ f)
infer_instance
instance : PreservesLimit (cospan f g) Scheme.forgetToTop := by
delta Scheme.forgetToTop
refine @Limits.comp_preservesLimit _ _ _ _ _ _ (K := cospan f g) _ _ (F := forget)
(G := LocallyRingedSpace.forgetToTop) ?_ ?_
· infer_instance
refine @preservesLimit_of_iso_diagram _ _ _ _ _ _ _ _ _ (diagramIsoCospan.{u} _).symm ?_
dsimp [LocallyRingedSpace.forgetToTop]
infer_instance
instance : PreservesLimit (cospan g f) Scheme.forgetToTop :=
preservesPullback_symmetry _ _ _
instance : PreservesLimit (cospan f g) Scheme.forget := by delta Scheme.forget; infer_instance
instance : PreservesLimit (cospan g f) Scheme.forget := by delta Scheme.forget; infer_instance
theorem range_pullbackSnd :
Set.range (pullback.snd f g) = g ⁻¹ᵁ f.opensRange := by
rw [← show _ = (pullback.snd f g).base from
PreservesPullback.iso_hom_snd Scheme.forgetToTop f g, TopCat.coe_comp, Set.range_comp,
Set.range_eq_univ.mpr, ← @Set.preimage_univ _ _ (pullback.fst f.base g.base)]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11224): was `rw`
· erw [TopCat.pullback_snd_image_fst_preimage]
rw [Set.image_univ]
rfl
rw [← TopCat.epi_iff_surjective]
infer_instance
@[deprecated (since := "2025-10-07")] alias range_pullback_snd_of_left := range_pullbackSnd
theorem _root_.AlgebraicGeometry.Scheme.Hom.opensRange_pullbackSnd :
(pullback.snd f g).opensRange = g ⁻¹ᵁ f.opensRange :=
Opens.ext (range_pullbackSnd f g)
@[deprecated (since := "2025-10-07")]
alias opensRange_pullback_snd_of_left := Scheme.Hom.opensRange_pullbackSnd
theorem range_pullbackFst :
Set.range (pullback.fst g f) = g ⁻¹ᵁ f.opensRange := by
rw [← show _ = (pullback.fst g f).base from
PreservesPullback.iso_hom_fst Scheme.forgetToTop g f, TopCat.coe_comp, Set.range_comp,
Set.range_eq_univ.mpr, ← @Set.preimage_univ _ _ (pullback.snd g.base f.base)]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11224): was `rw`
· erw [TopCat.pullback_fst_image_snd_preimage]
rw [Set.image_univ]
rfl
rw [← TopCat.epi_iff_surjective]
infer_instance
@[deprecated (since := "2025-10-07")] alias range_pullback_fst_of_right := range_pullbackFst
theorem _root_.AlgebraicGeometry.Scheme.Hom.opensRange_pullbackFst :
(pullback.fst g f).opensRange = g ⁻¹ᵁ f.opensRange :=
Opens.ext (range_pullbackFst f g)
@[deprecated (since := "2025-10-07")]
alias opensRange_pullback_fst_of_right := Scheme.Hom.opensRange_pullbackFst
theorem range_pullback_to_base_of_left :
Set.range (pullback.fst f g ≫ f) = Set.range f ∩ Set.range g := by
rw [pullback.condition, Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp,
range_pullbackSnd, Opens.map_obj, Opens.coe_mk,
Set.image_preimage_eq_inter_range, Opens.carrier_eq_coe, Scheme.Hom.coe_opensRange]
theorem range_pullback_to_base_of_right :
Set.range (pullback.fst g f ≫ g) = Set.range g ∩ Set.range f := by
rw [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp, range_pullbackFst,
Opens.map_obj, Opens.coe_mk, Set.image_preimage_eq_inter_range,
Set.inter_comm, Opens.carrier_eq_coe, Scheme.Hom.coe_opensRange]
lemma image_preimage_eq_preimage_image_of_isPullback {X Y U V : Scheme.{u}}
{f : X ⟶ Y} {f' : U ⟶ V} {iU : U ⟶ X} {iV : V ⟶ Y} [IsOpenImmersion iV] [IsOpenImmersion iU]
(H : IsPullback f' iU iV f) (W : V.Opens) : iU ''ᵁ f' ⁻¹ᵁ W = f ⁻¹ᵁ iV ''ᵁ W := by
ext x
by_cases hx : x ∈ Set.range iU
· obtain ⟨x, rfl⟩ := hx
simp only [SetLike.mem_coe, Opens.map_coe, Set.mem_preimage, ← Scheme.Hom.comp_apply, ← H.w]
simp
· constructor
· rintro ⟨x, hx, rfl⟩; cases hx ⟨x, rfl⟩
· rintro ⟨y, hy, e : iV y = f x⟩
obtain ⟨x, rfl⟩ := (IsOpenImmersion.range_pullbackSnd iV f).ge ⟨y, e⟩
rw [← H.isoPullback_inv_snd] at hx
cases hx ⟨_, rfl⟩
/-- The universal property of open immersions:
For an open immersion `f : X ⟶ Z`, given any morphism of schemes `g : Y ⟶ Z` whose topological
image is contained in the image of `f`, we can lift this morphism to a unique `Y ⟶ X` that
commutes with these maps.
-/
def lift (H' : Set.range g ⊆ Set.range f) : Y ⟶ X :=
⟨LocallyRingedSpace.IsOpenImmersion.lift f.toLRSHom g.toLRSHom H'⟩
@[reassoc (attr := simp)]
theorem lift_fac (H' : Set.range g ⊆ Set.range f) : lift f g H' ≫ f = g :=
Scheme.Hom.ext' <| LocallyRingedSpace.IsOpenImmersion.lift_fac f.toLRSHom g.toLRSHom H'
theorem lift_uniq (H' : Set.range g ⊆ Set.range f) (l : Y ⟶ X) (hl : l ≫ f = g) :
l = lift f g H' :=
Scheme.Hom.ext' <| LocallyRingedSpace.IsOpenImmersion.lift_uniq
f.toLRSHom g.toLRSHom H' l.toLRSHom congr(($hl).toLRSHom)
@[reassoc]
lemma comp_lift {Y' : Scheme} (g' : Y' ⟶ Y) (H : Set.range g ⊆ Set.range f) :
g' ≫ lift f g H = lift f (g' ≫ g) (.trans (by simp [Set.range_comp_subset_range]) H) := by
simp [← cancel_mono f]
theorem isPullback_lift_id
{X U Y : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y) [IsOpenImmersion g]
(H : Set.range f ⊆ Set.range g) :
IsPullback (IsOpenImmersion.lift g f H) (𝟙 _) g f := by
convert IsPullback.of_id_snd.paste_horiz (IsKernelPair.id_of_mono g)
· exact (Category.comp_id _).symm
· simp
/-- Two open immersions with equal range are isomorphic. -/
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f = Set.range g) : X ≅ Y where
hom := lift g f (le_of_eq e)
inv := lift f g (le_of_eq e.symm)
hom_inv_id := by rw [← cancel_mono f]; simp
inv_hom_id := by rw [← cancel_mono g]; simp
@[reassoc (attr := simp)]
lemma isoOfRangeEq_hom_fac {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z)
[IsOpenImmersion f] [IsOpenImmersion g] (e : Set.range f = Set.range g) :
(isoOfRangeEq f g e).hom ≫ g = f :=
lift_fac _ _ (le_of_eq e)
@[reassoc (attr := simp)]
lemma isoOfRangeEq_inv_fac {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z)
[IsOpenImmersion f] [IsOpenImmersion g] (e : Set.range f = Set.range g) :
(isoOfRangeEq f g e).inv ≫ f = g :=
lift_fac _ _ (le_of_eq e.symm)
theorem app_eq_invApp_app_of_comp_eq_aux {X Y U : Scheme.{u}} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
(H : fg = f ≫ g) [h : IsOpenImmersion g] (V : U.Opens) :
f ⁻¹ᵁ V = fg ⁻¹ᵁ (g ''ᵁ V) := by
simp_all
/-- The `fg` argument is to avoid nasty stuff about dependent types. -/
theorem app_eq_appIso_inv_app_of_comp_eq {X Y U : Scheme.{u}} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
(H : fg = f ≫ g) [h : IsOpenImmersion g] (V : U.Opens) :
f.app V = (g.appIso V).inv ≫ fg.app (g ''ᵁ V) ≫ Y.presheaf.map
(eqToHom <| IsOpenImmersion.app_eq_invApp_app_of_comp_eq_aux f g fg H V).op := by
subst H
rw [Scheme.Hom.comp_app, Category.assoc, Scheme.Hom.appIso_inv_app_assoc, f.naturality_assoc,
← Functor.map_comp, ← op_comp, Quiver.Hom.unop_op, eqToHom_map, eqToHom_trans,
eqToHom_op, eqToHom_refl, CategoryTheory.Functor.map_id, Category.comp_id]
theorem lift_app {X Y U : Scheme.{u}} (f : U ⟶ Y) (g : X ⟶ Y) [IsOpenImmersion f] (H)
(V : U.Opens) :
(lift f g H).app V = (f.appIso V).inv ≫ g.app (f ''ᵁ V) ≫
X.presheaf.map (eqToHom <| app_eq_invApp_app_of_comp_eq_aux _ _ _ (lift_fac ..).symm V).op :=
IsOpenImmersion.app_eq_appIso_inv_app_of_comp_eq _ _ _ (lift_fac _ _ _).symm _
lemma isPullback {U V X Y : Scheme.{u}} (g : U ⟶ V) (iU : U ⟶ X) (iV : V ⟶ Y) (f : X ⟶ Y)
[IsOpenImmersion iU] [IsOpenImmersion iV] (H : iU ≫ f = g ≫ iV)
(H' : f ⁻¹ᵁ iV.opensRange = iU.opensRange) : IsPullback g iU iV f := by
let e := IsOpenImmersion.isoOfRangeEq (pullback.snd iV f) iU
(by simpa [range_pullbackSnd] using congr(($H').1))
convert (IsPullback.of_horiz_isIso (show CommSq e.inv iU (pullback.snd iV f) (𝟙 X) from
⟨by simp [e]⟩)).paste_horiz (IsPullback.of_hasPullback iV f)
simp [← cancel_mono iV, e, pullback.condition, H]
/-- If `f` is an open immersion `X ⟶ Y`, the global sections of `X`
are naturally isomorphic to the sections of `Y` over the image of `f`. -/
noncomputable
def ΓIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : Y.Opens) :
Γ(X, f ⁻¹ᵁ U) ≅ Γ(Y, f.opensRange ⊓ U) :=
(f.appIso (f⁻¹ᵁ U)).symm ≪≫
Y.presheaf.mapIso (eqToIso <| (f.image_preimage_eq_opensRange_inf U).symm).op
@[simp]
lemma ΓIso_inv {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : Y.Opens) :
(ΓIso f U).inv = f.appLE (f.opensRange ⊓ U) (f⁻¹ᵁ U)
(by rw [← f.image_preimage_eq_opensRange_inf, f.preimage_image_eq]) := by
simp only [ΓIso, Iso.trans_inv, Functor.mapIso_inv, Iso.op_inv, eqToIso.inv, eqToHom_op,
Iso.symm_inv, Scheme.Hom.appIso_hom', Scheme.Hom.map_appLE]
@[reassoc, elementwise]
lemma map_ΓIso_inv {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : Y.Opens) :
Y.presheaf.map (homOfLE inf_le_right).op ≫ (ΓIso f U).inv = f.app U := by
simp [Scheme.Hom.appLE_eq_app]
@[reassoc, elementwise]
lemma app_ΓIso_hom {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : Y.Opens) :
f.app U ≫ (ΓIso f U).hom = Y.presheaf.map (homOfLE inf_le_right).op := by
rw [← map_ΓIso_inv]
simp [-ΓIso_inv]
@[deprecated (since := "2025-10-07")] alias map_ΓIso_hom := app_ΓIso_hom
/-- Given an open immersion `f : U ⟶ X`, the isomorphism between global sections
of `U` and the sections of `X` at the image of `f`. -/
noncomputable
def ΓIsoTop {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
Γ(X, ⊤) ≅ Γ(Y, f.opensRange) :=
(f.appIso ⊤).symm ≪≫ Y.presheaf.mapIso (eqToIso f.image_top_eq_opensRange.symm).op
instance {Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) [IsOpenImmersion f]
(H' : Set.range g ⊆ Set.range f) [IsOpenImmersion g] :
IsOpenImmersion (IsOpenImmersion.lift f g H') :=
haveI : IsOpenImmersion (IsOpenImmersion.lift f g H' ≫ f) := by simpa
IsOpenImmersion.of_comp _ f
end IsOpenImmersion
lemma isIso_of_isOpenImmersion_of_opensRange_eq_top {X Y : Scheme.{u}} (f : X ⟶ Y)
[IsOpenImmersion f] (hf : f.opensRange = ⊤) : IsIso f := by
rw [isIso_iff_isOpenImmersion_and_epi_base]
refine ⟨inferInstance, ?_⟩
rw [TopCat.epi_iff_surjective, ← Set.range_eq_univ]
exact TopologicalSpace.Opens.ext_iff.mp hf
section MorphismProperty
instance isOpenImmersion_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @IsOpenImmersion where
comp_mem f g _ _ := LocallyRingedSpace.IsOpenImmersion.comp f.toLRSHom g.toLRSHom
instance isOpenImmersion_respectsIso : MorphismProperty.RespectsIso @IsOpenImmersion := by
apply MorphismProperty.respectsIso_of_isStableUnderComposition
intro _ _ f (hf : IsIso f)
have : IsIso f := hf
infer_instance
instance isOpenImmersion_isMultiplicative :
MorphismProperty.IsMultiplicative @IsOpenImmersion where
id_mem _ := inferInstance
instance isOpenImmersion_stableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @IsOpenImmersion :=
MorphismProperty.IsStableUnderBaseChange.mk' <| by
intro X Y Z f g _ H; infer_instance
end MorphismProperty
namespace Scheme
variable {X Y : Scheme.{u}} (f : X ⟶ Y) [H : IsOpenImmersion f]
theorem image_basicOpen {U : X.Opens} (r : Γ(X, U)) :
f ''ᵁ X.basicOpen r = Y.basicOpen ((f.appIso U).inv r) := by
have e := Scheme.preimage_basicOpen f ((f.appIso U).inv r)
rw [Scheme.Hom.appIso_inv_app_apply, Scheme.basicOpen_res, inf_eq_right.mpr _] at e
· rw [← e, f.image_preimage_eq_opensRange_inf, inf_eq_right]
refine Set.Subset.trans (Scheme.basicOpen_le _ _) (Set.image_subset_range _ _)
· exact (X.basicOpen_le r).trans (f.preimage_image_eq _).ge
lemma image_zeroLocus {U : X.Opens} (s : Set Γ(X, U)) :
f '' X.zeroLocus s = Y.zeroLocus ((f.appIso U).inv.hom '' s) ∩ Set.range f := by
ext x
by_cases hx : x ∈ Set.range f
· obtain ⟨x, rfl⟩ := hx
simp [f.isOpenEmbedding.injective.mem_set_image, ← Scheme.image_basicOpen]
· simp only [Set.mem_inter_iff, hx, and_false, iff_false]
exact fun H ↦ hx (Set.image_subset_range _ _ H)
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/IdealSheaf.lean | import Mathlib.AlgebraicGeometry.IdealSheaf.Subscheme
deprecated_module (since := "2025-04-13") |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Over.lean | import Mathlib.AlgebraicGeometry.Scheme
import Mathlib.CategoryTheory.Comma.Over.OverClass
/-!
# Typeclasses for `S`-schemes and `S`-morphisms
We define these as thin wrappers around `CategoryTheory/Comma/OverClass`.
## Main definition
- `AlgebraicGeometry.Scheme.Over`: `X.Over S` equips `X` with a `S`-scheme structure.
`X ↘ S : X ⟶ S` is the structure morphism.
- `AlgebraicGeometry.Scheme.Hom.IsOver`: `f.IsOver S` asserts that `f` is a `S`-morphism.
-/
namespace AlgebraicGeometry.Scheme
universe u
open CategoryTheory
variable {X Y : Scheme.{u}} (f : X.Hom Y) (S S' : Scheme.{u})
/--
`X.Over S` is the typeclass containing the data of a structure morphism `X ↘ S : X ⟶ S`.
-/
protected abbrev Over (X S : Scheme.{u}) := OverClass X S
/--
`X.CanonicallyOver S` is the typeclass containing the data of a structure morphism `X ↘ S : X ⟶ S`,
and that `S` is (uniquely) inferable from the structure of `X`.
-/
abbrev CanonicallyOver (X S : Scheme.{u}) := CanonicallyOverClass X S
/-- Given `X.Over S` and `Y.Over S` and `f : X ⟶ Y`,
`f.IsOver S` is the typeclass asserting `f` commutes with the structure morphisms. -/
abbrev Hom.IsOver (f : X.Hom Y) (S : Scheme.{u}) [X.Over S] [Y.Over S] := HomIsOver f S
@[simp]
lemma Hom.isOver_iff [X.Over S] [Y.Over S] {f : X ⟶ Y} : f.IsOver S ↔ f ≫ Y ↘ S = X ↘ S :=
⟨fun H ↦ H.1, fun h ↦ ⟨h⟩⟩
/-! Also note the existence of `CategoryTheory.IsOverTower X Y S`. -/
/-- Given `X.Over S`, this is the bundled object of `Over S`. -/
abbrev asOver (X S : Scheme.{u}) [X.Over S] := OverClass.asOver X S
/-- Given a morphism `X ⟶ Y` with `f.IsOver S`, this is the bundled morphism in `Over S`. -/
abbrev Hom.asOver (f : X.Hom Y) (S : Scheme.{u}) [X.Over S] [Y.Over S] [f.IsOver S] :=
OverClass.asOverHom S f
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/PointsPi.lean | import Mathlib.AlgebraicGeometry.Morphisms.Immersion
/-!
# `Π Rᵢ`-Points of Schemes
We show that the canonical map `X(Π Rᵢ) ⟶ Π X(Rᵢ)` (`AlgebraicGeometry.pointsPi`)
is injective and surjective under various assumptions.
-/
open CategoryTheory Limits PrimeSpectrum
namespace AlgebraicGeometry
universe u v
variable {ι : Type u} (R : ι → CommRingCat.{u})
lemma Ideal.span_eq_top_of_span_image_evalRingHom
{ι} {R : ι → Type*} [∀ i, CommRing (R i)] (s : Set (Π i, R i))
(hs : s.Finite) (hs' : ∀ i, Ideal.span (Pi.evalRingHom (R ·) i '' s) = ⊤) :
Ideal.span s = ⊤ := by
simp only [Ideal.eq_top_iff_one, ← Subtype.range_val (s := s), ← Set.range_comp,
Finsupp.mem_ideal_span_range_iff_exists_finsupp] at hs' ⊢
choose f hf using hs'
have : Fintype s := hs.fintype
refine ⟨Finsupp.equivFunOnFinite.symm fun i x ↦ f x i, ?_⟩
ext i
simpa [Finsupp.sum_fintype] using hf i
lemma eq_top_of_sigmaSpec_subset_of_isCompact
(U : (Spec <| .of <| Π i, R i).Opens) (V : Set (Spec <| .of <| Π i, R i))
(hV : ↑(sigmaSpec R).opensRange ⊆ V)
(hV' : IsCompact (X := Spec (.of <| Π i, R i)) V)
(hVU : V ⊆ U) : U = ⊤ := by
obtain ⟨s, hs⟩ := (PrimeSpectrum.isOpen_iff _).mp U.2
obtain ⟨t, hts, ht, ht'⟩ : ∃ t ⊆ s, t.Finite ∧ V ⊆ ⋃ i ∈ t, (basicOpen i).1 := by
obtain ⟨t, ht⟩ := hV'.elim_finite_subcover
(fun i : s ↦ (basicOpen i.1).1) (fun _ ↦ (basicOpen _).2)
(by simpa [← Set.compl_iInter, ← zeroLocus_iUnion₂ (κ := (· ∈ s)), ← hs])
exact ⟨t.map (Function.Embedding.subtype _), by simp, Finset.finite_toSet _, by simpa using ht⟩
replace ht' : V ⊆ (zeroLocus t)ᶜ := by
simpa [← Set.compl_iInter, ← zeroLocus_iUnion₂ (κ := (· ∈ t))] using ht'
have (i : _) : Ideal.span (Pi.evalRingHom (R ·) i '' t) = ⊤ := by
rw [← zeroLocus_empty_iff_eq_top, zeroLocus_span, ← preimage_comap_zeroLocus,
← Set.compl_univ_iff, ← Set.preimage_compl, Set.preimage_eq_univ_iff]
trans (Sigma.ι _ i ≫ sigmaSpec R).opensRange.1
· simp; rfl
· rw [Scheme.Hom.opensRange_comp]
exact (Set.image_subset_range _ _).trans (hV.trans ht')
have : Ideal.span s = ⊤ := top_le_iff.mp
((Ideal.span_eq_top_of_span_image_evalRingHom _ ht this).ge.trans (Ideal.span_mono hts))
simpa [← zeroLocus_span s, zeroLocus_empty_iff_eq_top.mpr this] using hs
lemma eq_bot_of_comp_quotientMk_eq_sigmaSpec (I : Ideal (Π i, R i))
(f : (∐ fun i ↦ Spec (R i)) ⟶ Spec (.of <| (Π i, R i) ⧸ I))
(hf : f ≫ Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk I)) = sigmaSpec R) :
I = ⊥ := by
refine le_bot_iff.mp fun x hx ↦ ?_
ext i
simpa [← Category.assoc, Ideal.Quotient.eq_zero_iff_mem.mpr hx] using
congr((Spec.preimage (Sigma.ι (Spec <| R ·) i ≫ $hf)).hom x).symm
/-- If `V` is a locally closed subscheme of `Spec (Π Rᵢ)` containing `∐ Spec Rᵢ`, then
`V = Spec (Π Rᵢ)`. -/
lemma isIso_of_comp_eq_sigmaSpec {V : Scheme}
(f : (∐ fun i ↦ Spec (R i)) ⟶ V) (g : V ⟶ Spec (.of <| Π i, R i))
[IsImmersion g] [CompactSpace V]
(hU' : f ≫ g = sigmaSpec R) : IsIso g := by
have : g.coborderRange = ⊤ := by
apply eq_top_of_sigmaSpec_subset_of_isCompact (hVU := subset_coborder)
· simpa only [← hU'] using Set.range_comp_subset_range f g
· exact isCompact_range g.continuous
have : IsClosedImmersion g := by
have : IsIso g.coborderRange.ι := by rw [this, ← Scheme.topIso_hom]; infer_instance
rw [← g.liftCoborder_ι]
infer_instance
obtain ⟨I, e, rfl⟩ := IsClosedImmersion.Spec_iff.mp this
obtain rfl := eq_bot_of_comp_quotientMk_eq_sigmaSpec R I (f ≫ e.hom) (by rwa [Category.assoc])
convert_to IsIso (e.hom ≫ Spec.map (RingEquiv.quotientBot _).toCommRingCatIso.inv)
infer_instance
variable (X : Scheme)
/-- The canonical map `X(Π Rᵢ) ⟶ Π X(Rᵢ)`.
This is injective if `X` is quasi-separated, surjective if `X` is affine,
or if `X` is compact and each `Rᵢ` is local. -/
noncomputable
def pointsPi : (Spec (.of <| Π i, R i) ⟶ X) → Π i, Spec (R i) ⟶ X :=
fun f i ↦ Spec.map (CommRingCat.ofHom (Pi.evalRingHom (R ·) i)) ≫ f
lemma pointsPi_injective [QuasiSeparatedSpace X] : Function.Injective (pointsPi R X) := by
rintro f g e
have := isIso_of_comp_eq_sigmaSpec R (V := equalizer f g)
(equalizer.lift (sigmaSpec R) (by ext1 i; simpa using congr_fun e i))
(equalizer.ι f g) (by simp)
rw [← cancel_epi (equalizer.ι f g), equalizer.condition]
lemma pointsPi_surjective_of_isAffine [IsAffine X] : Function.Surjective (pointsPi R X) := by
rintro f
refine ⟨Spec.map (CommRingCat.ofHom
(Pi.ringHom fun i ↦ (Spec.preimage (f i ≫ X.isoSpec.hom)).1)) ≫ X.isoSpec.inv, ?_⟩
ext i : 1
simp only [pointsPi, ← Spec.map_comp_assoc, Iso.comp_inv_eq]
exact Spec.map_preimage _
lemma pointsPi_surjective [CompactSpace X] [∀ i, IsLocalRing (R i)] :
Function.Surjective (pointsPi R X) := by
intro f
let 𝒰 : X.OpenCover := X.affineCover.finiteSubcover
have (i : _) : ∃ j, Set.range (f i) ⊆ (𝒰.f j).opensRange := by
refine ⟨𝒰.idx ((f i) (IsLocalRing.closedPoint (R i))), ?_⟩
rintro _ ⟨x, rfl⟩
exact ((IsLocalRing.specializes_closedPoint x).map (f i).continuous).mem_open
(𝒰.f _).opensRange.2 (𝒰.covers _)
choose j hj using this
have (j₀ : _) := pointsPi_surjective_of_isAffine (ι := { i // j i = j₀ }) (R ·) (𝒰.X j₀)
(fun i ↦ IsOpenImmersion.lift (𝒰.f j₀) (f i.1) (by rcases i with ⟨i, rfl⟩; exact hj i))
choose g hg using this
simp_rw [funext_iff, pointsPi] at hg
let R' (j₀) := CommRingCat.of (Π i : { i // j i = j₀ }, R i)
let e : (Π i, R i) ≃+* Π j₀, R' j₀ :=
{ toFun f _ i := f i
invFun f i := f _ ⟨i, rfl⟩
right_inv _ := funext₂ fun j₀ i ↦ by rcases i with ⟨i, rfl⟩; rfl
map_mul' _ _ := rfl
map_add' _ _ := rfl }
refine ⟨Spec.map (CommRingCat.ofHom e.symm.toRingHom) ≫ inv (sigmaSpec R') ≫
Sigma.desc fun j₀ ↦ g j₀ ≫ 𝒰.f j₀, ?_⟩
ext i : 1
have : (Pi.evalRingHom (R ·) i).comp e.symm.toRingHom =
(Pi.evalRingHom _ ⟨i, rfl⟩).comp (Pi.evalRingHom (R' ·) (j i)) := rfl
rw [pointsPi, ← Spec.map_comp_assoc, ← CommRingCat.ofHom_comp, this, CommRingCat.ofHom_comp,
Spec.map_comp_assoc, ← ι_sigmaSpec R', Category.assoc, IsIso.hom_inv_id_assoc,
Sigma.ι_desc, ← Category.assoc, hg, IsOpenImmersion.lift_fac]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Restrict.lean | import Mathlib.AlgebraicGeometry.Cover.Open
import Mathlib.AlgebraicGeometry.Over
/-!
# Restriction of Schemes and Morphisms
## Main definition
- `AlgebraicGeometry.Scheme.restrict`: The restriction of a scheme along an open embedding.
The map `X.restrict f ⟶ X` is `AlgebraicGeometry.Scheme.ofRestrict`.
`U : X.Opens` has a coercion to `Scheme` and `U.ι` is a shorthand
for `X.restrict U.open_embedding : U ⟶ X`.
- `AlgebraicGeometry.morphismRestrict`: The restriction of `X ⟶ Y` to `X ∣_ᵤ f ⁻¹ᵁ U ⟶ Y ∣_ᵤ U`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
noncomputable section
open TopologicalSpace CategoryTheory Opposite CategoryTheory.Limits
namespace AlgebraicGeometry
universe v v₁ v₂ u u₁
variable {C : Type u₁} [Category.{v} C]
section
variable {X : Scheme.{u}} (U : X.Opens)
namespace Scheme.Opens
/-- Open subset of a scheme as a scheme. -/
@[coe]
def toScheme {X : Scheme.{u}} (U : X.Opens) : Scheme.{u} :=
X.restrict U.isOpenEmbedding
instance : CoeOut X.Opens Scheme := ⟨toScheme⟩
/-- The restriction of a scheme to an open subset. -/
def ι : ↑U ⟶ X := X.ofRestrict _
@[simp]
lemma ι_apply (x : U) : U.ι x = x.val := rfl
@[deprecated (since := "2025-10-07")] alias ι_base_apply := ι_apply
instance : IsOpenImmersion U.ι := inferInstanceAs (IsOpenImmersion (X.ofRestrict _))
@[simps! over] instance : U.toScheme.CanonicallyOver X where
hom := U.ι
instance (U : X.Opens) : U.ι.IsOver X where
lemma toScheme_carrier : (U : Type u) = (U : Set X) := rfl
lemma toScheme_presheaf_obj (V) : Γ(U, V) = Γ(X, U.ι ''ᵁ V) := rfl
@[simp]
lemma toScheme_presheaf_map {V W} (i : V ⟶ W) :
U.toScheme.presheaf.map i = X.presheaf.map (U.ι.opensFunctor.map i.unop).op := rfl
@[simp]
lemma ι_app (V) : U.ι.app V = X.presheaf.map
(homOfLE (x := U.ι ''ᵁ U.ι ⁻¹ᵁ V) (Set.image_preimage_subset _ _)).op :=
rfl
@[simp]
lemma ι_appTop :
U.ι.appTop = X.presheaf.map (homOfLE (x := U.ι ''ᵁ ⊤) le_top).op :=
rfl
@[simp]
lemma ι_appLE (V W e) :
U.ι.appLE V W e =
X.presheaf.map (homOfLE (x := U.ι ''ᵁ W) (Set.image_subset_iff.mpr ‹_›)).op := by
simp only [Hom.appLE, ι_app, toScheme_presheaf_map, Quiver.Hom.unop_op,
Hom.opensFunctor_map_homOfLE, ← Functor.map_comp]
rfl
@[simp]
lemma ι_appIso (V) : U.ι.appIso V = Iso.refl _ :=
X.ofRestrict_appIso _ _
@[simp]
lemma opensRange_ι : U.ι.opensRange = U :=
Opens.ext Subtype.range_val
@[simp]
lemma range_ι : Set.range U.ι = U :=
Subtype.range_val
lemma ι_image_top : U.ι ''ᵁ ⊤ = U :=
U.isOpenEmbedding_obj_top
lemma ι_image_le (W : U.toScheme.Opens) : U.ι ''ᵁ W ≤ U := by
simp_rw [← U.ι_image_top]
exact U.ι.image_mono le_top
@[simp]
lemma ι_preimage_self : U.ι ⁻¹ᵁ U = ⊤ :=
Opens.inclusion'_map_eq_top _
@[simp]
lemma mem_ι_image_iff {x : U} {V : Opens U} : (x : X) ∈ U.ι ''ᵁ V ↔ x ∈ V :=
U.ι.apply_mem_image_iff
instance : IsIso (U.ι.appLE U ⊤ U.ι_preimage_self.ge) := by
simp only [ι, ofRestrict_appLE]
change IsIso (X.presheaf.map (eqToIso U.ι_image_top).hom.op)
infer_instance
lemma ι_app_self : U.ι.app U = X.presheaf.map (eqToHom (X := U.ι ''ᵁ _) (by simp)).op := rfl
lemma eq_presheaf_map_eqToHom {V W : Opens U} (e : U.ι ''ᵁ V = U.ι ''ᵁ W) :
X.presheaf.map (eqToHom e).op =
U.toScheme.presheaf.map (eqToHom <| U.isOpenEmbedding.functor_obj_injective e).op := rfl
@[simp]
lemma nonempty_iff : Nonempty U.toScheme ↔ (U : Set X).Nonempty := by
simp only [toScheme_carrier, SetLike.coe_sort_coe, nonempty_subtype]
rfl
attribute [-simp] eqToHom_op in
/-- The global sections of the restriction is isomorphic to the sections on the open set. -/
@[simps!]
def topIso : Γ(U, ⊤) ≅ Γ(X, U) :=
X.presheaf.mapIso (eqToIso U.ι_image_top.symm).op
/-- The stalks of an open subscheme are isomorphic to the stalks of the original scheme. -/
def stalkIso {X : Scheme.{u}} (U : X.Opens) (x : U) :
U.toScheme.presheaf.stalk x ≅ X.presheaf.stalk x.1 :=
X.restrictStalkIso (Opens.isOpenEmbedding _) _
@[reassoc (attr := simp)]
lemma germ_stalkIso_hom {X : Scheme.{u}} (U : X.Opens)
{V : U.toScheme.Opens} (x : U) (hx : x ∈ V) :
U.toScheme.presheaf.germ V x hx ≫ (U.stalkIso x).hom =
X.presheaf.germ (U.ι ''ᵁ V) x.1 ⟨x, hx, rfl⟩ :=
PresheafedSpace.restrictStalkIso_hom_eq_germ _ U.isOpenEmbedding _ _ _
@[reassoc]
lemma germ_stalkIso_inv {X : Scheme.{u}} (U : X.Opens) (V : U.toScheme.Opens) (x : U)
(hx : x ∈ V) : X.presheaf.germ (U.ι ''ᵁ V) x ⟨x, hx, rfl⟩ ≫
(U.stalkIso x).inv = U.toScheme.presheaf.germ V x hx :=
PresheafedSpace.restrictStalkIso_inv_eq_germ X.toPresheafedSpace U.isOpenEmbedding V x hx
lemma stalkIso_inv {X : Scheme.{u}} (U : X.Opens) (x : U) :
(U.stalkIso x).inv = U.ι.stalkMap x := by
rw [← Category.comp_id (U.stalkIso x).inv, Iso.inv_comp_eq]
apply TopCat.Presheaf.stalk_hom_ext
intro W hxW
simp only [Category.comp_id, U.germ_stalkIso_hom_assoc]
convert (Scheme.Hom.germ_stalkMap U.ι (U.ι ''ᵁ W) x ⟨_, hxW, rfl⟩).symm
refine (U.toScheme.presheaf.germ_res (homOfLE ?_) _ _).symm
exact (Set.preimage_image_eq _ Subtype.val_injective).le
end Scheme.Opens
/-- If `U` is a family of open sets that covers `X`, then `X.restrict U` forms an `X.open_cover`. -/
@[simps! I₀ X f]
def Scheme.openCoverOfIsOpenCover {s : Type*} (X : Scheme.{u}) (U : s → X.Opens)
(hU : IsOpenCover U) : X.OpenCover where
I₀ := s
X i := U i
f i := (U i).ι
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ?_, inferInstance⟩
have hx : x ∈ ⨆ i, U i := hU.symm ▸ show x ∈ (⊤ : X.Opens) by trivial
rw [Opens.mem_iSup] at hx
obtain ⟨i, hi⟩ := hx
use i
simpa
@[deprecated (since := "2025-09-30")]
noncomputable alias Scheme.openCoverOfISupEqTop := Scheme.openCoverOfIsOpenCover
/-- The open sets of an open subscheme corresponds to the open sets containing in the subset. -/
@[simps!]
def opensRestrict :
Scheme.Opens U ≃ { V : X.Opens // V ≤ U } :=
(IsOpenImmersion.opensEquiv (U.ι)).trans (Equiv.subtypeEquivProp (by simp))
instance ΓRestrictAlgebra {X : Scheme.{u}} (U : X.Opens) :
Algebra Γ(X, ⊤) Γ(U, ⊤) :=
U.ι.appTop.hom.toAlgebra
/-- A variant where `r` is first mapped into `Γ(X, U)` before taking the basic open. -/
lemma Scheme.Opens.ι_image_basicOpen' (r : Γ(U, ⊤)) :
U.ι ''ᵁ U.toScheme.basicOpen r = X.basicOpen
(X.presheaf.map (eqToHom U.ι_image_top.symm).op r) := by
refine (Scheme.image_basicOpen (X.ofRestrict U.isOpenEmbedding) r).trans ?_
rw [← Scheme.basicOpen_res_eq _ _ (eqToHom U.isOpenEmbedding_obj_top).op]
rw [← CommRingCat.comp_apply, ← CategoryTheory.Functor.map_comp, ← op_comp, eqToHom_trans,
eqToHom_refl, op_id]
congr
exact (PresheafedSpace.IsOpenImmersion.ofRestrict_invApp _ _ _).trans
(CategoryTheory.Functor.map_id _ _).symm
@[deprecated (since := "2025-10-07")] alias Scheme.map_basicOpen := Scheme.Opens.ι_image_basicOpen'
lemma Scheme.Opens.ι_image_basicOpen (r : Γ(U, ⊤)) :
U.ι ''ᵁ U.toScheme.basicOpen r = X.basicOpen r := by
rw [Scheme.Opens.ι_image_basicOpen', Scheme.basicOpen_res_eq]
lemma Scheme.Opens.ι_image_basicOpen_topIso_inv (r : Γ(X, U)) :
U.ι ''ᵁ U.toScheme.basicOpen (U.topIso.inv r) = X.basicOpen r := by
simp only [Scheme.Opens.toScheme_presheaf_obj]
rw [ι_image_basicOpen', basicOpen_res_eq, topIso_inv, basicOpen_res_eq X]
@[deprecated (since := "2025-10-07")]
alias Scheme.map_basicOpen_map := Scheme.Opens.ι_image_basicOpen_topIso_inv
@[simp]
lemma Scheme.Opens.mem_basicOpen_toScheme {U : X.Opens} {V : Scheme.Opens U} {r : Γ(U, V)} {x : U} :
x ∈ U.toScheme.basicOpen r ↔ (x : X) ∈ X.basicOpen r := by
rw [← U.toScheme.basicOpen_res_eq _ (eqToHom (U.ι.preimage_image_eq V)).op]
exact congr(x ∈ $(U.ι.preimage_basicOpen r)).to_iff.symm
/-- If `U ≤ V`, then `U` is also a subscheme of `V`. -/
protected noncomputable
def Scheme.homOfLE (X : Scheme.{u}) {U V : X.Opens} (e : U ≤ V) : (U : Scheme.{u}) ⟶ V :=
IsOpenImmersion.lift V.ι U.ι (by simpa using e)
@[reassoc (attr := simp)]
lemma Scheme.homOfLE_ι (X : Scheme.{u}) {U V : X.Opens} (e : U ≤ V) :
X.homOfLE e ≫ V.ι = U.ι :=
IsOpenImmersion.lift_fac _ _ _
instance {U V : X.Opens} (h : U ≤ V) : (X.homOfLE h).IsOver X where
@[simp]
lemma Scheme.homOfLE_rfl (X : Scheme.{u}) (U : X.Opens) : X.homOfLE (refl U) = 𝟙 _ := by
rw [← cancel_mono U.ι, Scheme.homOfLE_ι, Category.id_comp]
@[reassoc (attr := simp)]
lemma Scheme.homOfLE_homOfLE (X : Scheme.{u}) {U V W : X.Opens} (e₁ : U ≤ V) (e₂ : V ≤ W) :
X.homOfLE e₁ ≫ X.homOfLE e₂ = X.homOfLE (e₁.trans e₂) := by
rw [← cancel_mono W.ι, Category.assoc, Scheme.homOfLE_ι, Scheme.homOfLE_ι, Scheme.homOfLE_ι]
theorem Scheme.homOfLE_base {U V : X.Opens} (e : U ≤ V) :
(X.homOfLE e).base = (Opens.toTopCat _).map (homOfLE e) := by
ext a; refine Subtype.ext ?_ -- Porting note: `ext` did not pick up `Subtype.ext`
exact congr($(X.homOfLE_ι e) a)
@[simp]
theorem Scheme.homOfLE_apply {U V : X.Opens} (e : U ≤ V) (x : U) :
(X.homOfLE e x).1 = x := by
rw [homOfLE_base]
rfl
theorem Scheme.ι_image_homOfLE_le_ι_image {U V : X.Opens} (e : U ≤ V) (W : Opens V) :
U.ι ''ᵁ X.homOfLE e ⁻¹ᵁ W ≤ V.ι ''ᵁ W := by
simp only [homOfLE_base, homOfLE_leOfHom, ← SetLike.coe_subset_coe, Hom.coe_image, Opens.ι_apply,
Opens.map_coe, Set.image_subset_iff]
rintro _ h
exact ⟨_, h, rfl⟩
@[simp]
theorem Scheme.homOfLE_app {U V : X.Opens} (e : U ≤ V) (W : Opens V) :
(X.homOfLE e).app W = X.presheaf.map (homOfLE <| X.ι_image_homOfLE_le_ι_image e W).op := by
have e₁ := Scheme.Hom.congr_app (X.homOfLE_ι e) (V.ι ''ᵁ W)
have : V.ι ⁻¹ᵁ V.ι ''ᵁ W = W := W.map_functor_eq (U := V)
have e₂ := (X.homOfLE e).naturality (eqToIso this).hom.op
have e₃ := e₂.symm.trans e₁
dsimp at e₃ ⊢
rw [← IsIso.eq_comp_inv, ← Functor.map_inv, ← Functor.map_comp] at e₃
rw [e₃, ← Functor.map_comp]
congr 1
@[simp]
theorem Scheme.homOfLE_appLE {U V : X.Opens} (e : U ≤ V) (W : Opens V) (W' : Opens U) (e') :
(X.homOfLE e).appLE W W' e' = X.presheaf.map
(homOfLE ((U.ι.image_mono e').trans (Scheme.ι_image_homOfLE_le_ι_image ..))).op := by
simp [Scheme.Hom.appLE, Scheme.homOfLE_app, ← Functor.map_comp, ← op_comp]
theorem Scheme.homOfLE_appTop {U V : X.Opens} (e : U ≤ V) :
(X.homOfLE e).appTop = X.presheaf.map (homOfLE <| X.ι_image_homOfLE_le_ι_image e ⊤).op :=
homOfLE_app ..
instance (X : Scheme.{u}) {U V : X.Opens} (e : U ≤ V) : IsOpenImmersion (X.homOfLE e) := by
delta Scheme.homOfLE
infer_instance
@[simp]
lemma Scheme.opensRange_homOfLE {U V : X.Opens} (e : U ≤ V) :
(X.homOfLE e).opensRange = V.ι ⁻¹ᵁ U :=
V.ι.image_injective (by simp [← Hom.opensRange_comp, Hom.image_preimage_eq_opensRange_inf, e])
/-- The open cover of `⋃ Vᵢ` by `Vᵢ`. -/
def Scheme.Opens.iSupOpenCover {J : Type*} {X : Scheme} (U : J → X.Opens) :
(⨆ i, U i).toScheme.OpenCover where
I₀ := J
X i := U i
f j := X.homOfLE (le_iSup _ _)
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ?_, inferInstance⟩
obtain ⟨i, hi⟩ := TopologicalSpace.Opens.mem_iSup.mp x.2
use i, ⟨x.1, hi⟩
apply Subtype.ext
simp
variable (X) in
/-- The functor taking open subsets of `X` to open subschemes of `X`. -/
@[simps! obj_left obj_hom map_left]
def Scheme.restrictFunctor : X.Opens ⥤ Over X where
obj U := Over.mk U.ι
map {U V} i := Over.homMk (X.homOfLE i.le) (by simp)
map_id U := by
ext1
exact Scheme.homOfLE_rfl _ _
map_comp {U V W} i j := by
ext1
exact (X.homOfLE_homOfLE i.le j.le).symm
/-- The functor that restricts to open subschemes and then takes global section is
isomorphic to the structure sheaf. -/
@[simps!]
def Scheme.restrictFunctorΓ : X.restrictFunctor.op ⋙ (Over.forget X).op ⋙ Scheme.Γ ≅ X.presheaf :=
NatIso.ofComponents
(fun U => X.presheaf.mapIso ((eqToIso (unop U).isOpenEmbedding_obj_top).symm.op :))
(by
intro U V i
dsimp
rw [X.homOfLE_appTop, ← Functor.map_comp, ← Functor.map_comp]
congr 1)
/-- `X ∣_ U ∣_ V` is isomorphic to `X ∣_ V ∣_ U` -/
noncomputable
def Scheme.restrictRestrictComm (X : Scheme.{u}) (U V : X.Opens) :
(U.ι ⁻¹ᵁ V).toScheme ≅ V.ι ⁻¹ᵁ U :=
IsOpenImmersion.isoOfRangeEq (Opens.ι _ ≫ U.ι) (Opens.ι _ ≫ V.ι) <| by
simp only [Hom.comp_base, TopCat.coe_comp, Set.range_comp, Opens.range_ι, Opens.map_coe,
Set.image_preimage_eq_inter_range, Set.inter_comm (U : Set X)]
/-- If `f : X ⟶ Y` is an open immersion, then for any `U : X.Opens`,
we have the isomorphism `U ≅ f ''ᵁ U`. -/
noncomputable
def Scheme.Hom.isoImage
{X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : X.Opens) :
U.toScheme ≅ f ''ᵁ U :=
IsOpenImmersion.isoOfRangeEq (Opens.ι _ ≫ f) (Opens.ι _) (by simp [Set.range_comp])
@[reassoc (attr := simp)]
lemma Scheme.Hom.isoImage_hom_ι
{X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : X.Opens) :
(f.isoImage U).hom ≫ (f ''ᵁ U).ι = U.ι ≫ f :=
IsOpenImmersion.isoOfRangeEq_hom_fac _ _ _
@[reassoc (attr := simp)]
lemma Scheme.Hom.isoImage_inv_ι
{X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U : X.Opens) :
(f.isoImage U).inv ≫ U.ι ≫ f = (f ''ᵁ U).ι :=
IsOpenImmersion.isoOfRangeEq_inv_fac _ _ _
/-- If `f : X ⟶ Y` is an open immersion, then `X` is isomorphic to its image in `Y`. -/
def Scheme.Hom.isoOpensRange {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
X ≅ f.opensRange :=
IsOpenImmersion.isoOfRangeEq f f.opensRange.ι (by simp)
@[reassoc (attr := simp)]
lemma Scheme.Hom.isoOpensRange_hom_ι {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
f.isoOpensRange.hom ≫ f.opensRange.ι = f := by
simp [isoOpensRange]
@[reassoc (attr := simp)]
lemma Scheme.Hom.isoOpensRange_inv_comp {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] :
f.isoOpensRange.inv ≫ f = f.opensRange.ι := by
simp [isoOpensRange]
/-- `(⊤ : X.Opens)` as a scheme is isomorphic to `X`. -/
@[simps hom]
def Scheme.topIso (X : Scheme) : ↑(⊤ : X.Opens) ≅ X where
hom := Scheme.Opens.ι _
inv := ⟨X.restrictTopIso.inv⟩
hom_inv_id := Hom.ext' X.restrictTopIso.hom_inv_id
inv_hom_id := Hom.ext' X.restrictTopIso.inv_hom_id
@[reassoc (attr := simp)]
lemma Scheme.toIso_inv_ι (X : Scheme.{u}) : X.topIso.inv ≫ Opens.ι _ = 𝟙 _ :=
X.topIso.inv_hom_id
@[reassoc (attr := simp)]
lemma Scheme.ι_toIso_inv (X : Scheme.{u}) : Opens.ι _ ≫ X.topIso.inv = 𝟙 _ :=
X.topIso.hom_inv_id
/-- If `U = V`, then `X ∣_ U` is isomorphic to `X ∣_ V`. -/
noncomputable
def Scheme.isoOfEq (X : Scheme.{u}) {U V : X.Opens} (e : U = V) :
(U : Scheme.{u}) ≅ V :=
IsOpenImmersion.isoOfRangeEq U.ι V.ι (by rw [e])
@[reassoc (attr := simp)]
lemma Scheme.isoOfEq_hom_ι (X : Scheme.{u}) {U V : X.Opens} (e : U = V) :
(X.isoOfEq e).hom ≫ V.ι = U.ι :=
IsOpenImmersion.isoOfRangeEq_hom_fac _ _ _
@[reassoc (attr := simp)]
lemma Scheme.isoOfEq_inv_ι (X : Scheme.{u}) {U V : X.Opens} (e : U = V) :
(X.isoOfEq e).inv ≫ U.ι = V.ι :=
IsOpenImmersion.isoOfRangeEq_inv_fac _ _ _
lemma Scheme.isoOfEq_hom (X : Scheme.{u}) {U V : X.Opens} (e : U = V) :
(X.isoOfEq e).hom = X.homOfLE e.le := rfl
lemma Scheme.isoOfEq_inv (X : Scheme.{u}) {U V : X.Opens} (e : U = V) :
(X.isoOfEq e).inv = X.homOfLE e.ge := rfl
@[simp]
lemma Scheme.isoOfEq_rfl (X : Scheme.{u}) (U : X.Opens) : X.isoOfEq (refl U) = Iso.refl _ := by
ext1
rw [← cancel_mono U.ι, Scheme.isoOfEq_hom_ι, Iso.refl_hom, Category.id_comp]
end
/-- The restriction of an isomorphism onto an open set. -/
noncomputable def Scheme.Hom.preimageIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso (C := Scheme) f]
(U : Y.Opens) : (f ⁻¹ᵁ U).toScheme ≅ U := by
apply IsOpenImmersion.isoOfRangeEq (f := (f ⁻¹ᵁ U).ι ≫ f) U.ι _
dsimp
rw [Set.range_comp, Opens.range_ι, Opens.range_ι]
refine @Set.image_preimage_eq _ _ f U.1 f.homeomorph.surjective
@[reassoc (attr := simp)]
lemma Scheme.Hom.preimageIso_hom_ι {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso (C := Scheme) f]
(U : Y.Opens) : (f.preimageIso U).hom ≫ U.ι = (f ⁻¹ᵁ U).ι ≫ f :=
IsOpenImmersion.isoOfRangeEq_hom_fac _ _ _
@[reassoc (attr := simp)]
lemma Scheme.Hom.preimageIso_inv_ι {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso (C := Scheme) f]
(U : Y.Opens) : (f.preimageIso U).inv ≫ (f ⁻¹ᵁ U).ι ≫ f = U.ι :=
IsOpenImmersion.isoOfRangeEq_inv_fac _ _ _
/-- If `U ≤ V` are opens of `X`, the restriction of `U` to `V` is isomorphic to `U`. -/
noncomputable def Scheme.Opens.isoOfLE {X : Scheme.{u}} {U V : X.Opens} (hUV : U ≤ V) :
(V.ι ⁻¹ᵁ U).toScheme ≅ U :=
IsOpenImmersion.isoOfRangeEq ((V.ι ⁻¹ᵁ U).ι ≫ V.ι) U.ι <| by
have : V.ι ''ᵁ (V.ι ⁻¹ᵁ U) = U := by simpa [Scheme.Hom.image_preimage_eq_opensRange_inf]
rw [Scheme.Hom.comp_base, TopCat.coe_comp, Scheme.Opens.range_ι, Set.range_comp, ← this]
simp
@[reassoc (attr := simp)]
lemma Scheme.Opens.isoOfLE_hom_ι {X : Scheme.{u}} {U V : X.Opens} (hUV : U ≤ V) :
(isoOfLE hUV).hom ≫ U.ι = (V.ι ⁻¹ᵁ U).ι ≫ V.ι := by
simp [isoOfLE]
@[reassoc (attr := simp)]
lemma Scheme.Opens.isoOfLE_inv_ι {X : Scheme.{u}} {U V : X.Opens} (hUV : U ≤ V) :
(isoOfLE hUV).inv ≫ (V.ι ⁻¹ᵁ U).ι ≫ V.ι = U.ι := by
simp [isoOfLE]
/-- For `f : R`, `D(f)` as an open subscheme of `Spec R` is isomorphic to `Spec R[1/f]`. -/
def basicOpenIsoSpecAway {R : CommRingCat.{u}} (f : R) :
Scheme.Opens.toScheme (X := Spec R) (PrimeSpectrum.basicOpen f) ≅
Spec (.of <| Localization.Away f) :=
IsOpenImmersion.isoOfRangeEq (Scheme.Opens.ι _) (Spec.map (CommRingCat.ofHom (algebraMap _ _)))
(by
simp only [Scheme.Opens.range_ι]
exact (PrimeSpectrum.localization_away_comap_range _ _).symm)
@[reassoc]
lemma basicOpenIsoSpecAway_inv_homOfLE {R : CommRingCat.{u}} (f g x : R) (hx : x = f * g) :
haveI : IsLocalization.Away (f * g) (Localization.Away x) := by rw [hx]; infer_instance
(basicOpenIsoSpecAway x).inv ≫ (Spec R).homOfLE (by simp [hx, PrimeSpectrum.basicOpen_mul]) =
Spec.map (CommRingCat.ofHom (IsLocalization.Away.awayToAwayRight f g)) ≫
(basicOpenIsoSpecAway f).inv := by
subst hx
rw [← cancel_mono (Scheme.Opens.ι _)]
simp only [basicOpenIsoSpecAway, Category.assoc, Scheme.homOfLE_ι,
IsOpenImmersion.isoOfRangeEq_inv_fac]
simp only [← Spec.map_comp, ← CommRingCat.ofHom_comp]
congr
ext x
exact (IsLocalization.Away.awayToAwayRight_eq f g x).symm
section MorphismRestrict
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
pullback f U.ι ≅ f ⁻¹ᵁ U := by
refine IsOpenImmersion.isoOfRangeEq (pullback.fst f _) (Scheme.Opens.ι _) ?_
simp [IsOpenImmersion.range_pullbackFst]
@[simp, reassoc]
theorem pullbackRestrictIsoRestrict_inv_fst {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
(pullbackRestrictIsoRestrict f U).inv ≫ pullback.fst f _ = (f ⁻¹ᵁ U).ι := by
delta pullbackRestrictIsoRestrict; simp
@[reassoc (attr := simp)]
theorem pullbackRestrictIsoRestrict_hom_ι {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
(pullbackRestrictIsoRestrict f U).hom ≫ (f ⁻¹ᵁ U).ι = pullback.fst f _ := by
delta pullbackRestrictIsoRestrict; simp
/-- The restriction of a morphism `X ⟶ Y` onto `X |_{f ⁻¹ U} ⟶ Y |_ U`. -/
def morphismRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) : (f ⁻¹ᵁ U).toScheme ⟶ U :=
(pullbackRestrictIsoRestrict f U).inv ≫ pullback.snd _ _
/-- the notation for restricting a morphism of scheme to an open subset of the target scheme -/
infixl:85 " ∣_ " => morphismRestrict
@[reassoc (attr := simp)]
theorem pullbackRestrictIsoRestrict_hom_morphismRestrict {X Y : Scheme.{u}} (f : X ⟶ Y)
(U : Y.Opens) : (pullbackRestrictIsoRestrict f U).hom ≫ f ∣_ U = pullback.snd _ _ :=
Iso.hom_inv_id_assoc _ _
@[reassoc (attr := simp)]
theorem morphismRestrict_ι {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
f ∣_ U ≫ U.ι = (f ⁻¹ᵁ U).ι ≫ f := by
delta morphismRestrict
rw [Category.assoc, pullback.condition.symm, pullbackRestrictIsoRestrict_inv_fst_assoc]
theorem isPullback_morphismRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
IsPullback (f ∣_ U) (f ⁻¹ᵁ U).ι U.ι f := by
delta morphismRestrict
rw [← Category.id_comp f]
refine
(IsPullback.of_horiz_isIso ⟨?_⟩).paste_horiz
(IsPullback.of_hasPullback f (Y.ofRestrict U.isOpenEmbedding)).flip
erw [pullbackRestrictIsoRestrict_inv_fst]
rw [Category.comp_id]
lemma isPullback_opens_inf_le {X : Scheme} {U V W : X.Opens} (hU : U ≤ W) (hV : V ≤ W) :
IsPullback (X.homOfLE inf_le_left) (X.homOfLE inf_le_right) (X.homOfLE hU) (X.homOfLE hV) := by
refine (isPullback_morphismRestrict (X.homOfLE hV) (W.ι ⁻¹ᵁ U)).of_iso (V.ι.isoImage _ ≪≫
X.isoOfEq ?_) (W.ι.isoImage _ ≪≫ X.isoOfEq ?_) (Iso.refl _) (Iso.refl _) ?_ ?_ ?_ ?_
· rw [← TopologicalSpace.Opens.map_comp_obj, ← Scheme.Hom.comp_base, Scheme.homOfLE_ι]
exact V.functor_map_eq_inf U
· exact (W.functor_map_eq_inf U).trans (by simpa)
all_goals { simp [← cancel_mono (Scheme.Opens.ι _)] }
lemma isPullback_opens_inf {X : Scheme} (U V : X.Opens) :
IsPullback (X.homOfLE inf_le_left) (X.homOfLE inf_le_right) U.ι V.ι :=
(isPullback_morphismRestrict V.ι U).of_iso (V.ι.isoImage _ ≪≫ X.isoOfEq
(V.functor_map_eq_inf U)) (Iso.refl _) (Iso.refl _) (Iso.refl _) (by simp [← cancel_mono U.ι])
(by simp [← cancel_mono V.ι]) (by simp) (by simp)
@[simp]
lemma morphismRestrict_id {X : Scheme.{u}} (U : X.Opens) : 𝟙 X ∣_ U = 𝟙 _ := by
rw [← cancel_mono U.ι, morphismRestrict_ι, Category.comp_id, Category.id_comp]
rfl
theorem morphismRestrict_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
(f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
delta morphismRestrict
rw [← pullbackRightPullbackFstIso_inv_snd_snd]
simp_rw [← Category.assoc]
congr 1
rw [← cancel_mono (pullback.fst _ _)]
simp_rw [Category.assoc]
rw [pullbackRestrictIsoRestrict_inv_fst, pullbackRightPullbackFstIso_inv_snd_fst, ←
pullback.condition, pullbackRestrictIsoRestrict_inv_fst_assoc,
pullbackRestrictIsoRestrict_inv_fst_assoc]
rfl
instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] (U : Y.Opens) : IsIso (f ∣_ U) := by
delta morphismRestrict; infer_instance
@[simp]
theorem morphismRestrict_base_coe {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (x) :
((f ∣_ U) x).1 = f x.1 :=
congr_arg (fun f => (Scheme.Hom.toLRSHom f).base x)
(morphismRestrict_ι f U)
theorem morphismRestrict_base {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
⇑(f ∣_ U) = U.1.restrictPreimage f :=
funext fun x => Subtype.ext (morphismRestrict_base_coe f U x)
theorem image_morphismRestrict_preimage {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : Opens U) :
(f ⁻¹ᵁ U).ι ''ᵁ ((f ∣_ U) ⁻¹ᵁ V) = f ⁻¹ᵁ (U.ι ''ᵁ V) :=
IsOpenImmersion.image_preimage_eq_preimage_image_of_isPullback (isPullback_morphismRestrict f U) V
open Scheme in
theorem morphismRestrict_app {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : U.toScheme.Opens) :
(f ∣_ U).app V = f.app (U.ι ''ᵁ V) ≫
X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
obtain ⟨V, rfl⟩ : ∃ V', U.ι ⁻¹ᵁ U.ι ''ᵁ V' = V := ⟨_, U.ι.preimage_image_eq V⟩
simpa [← Functor.map_comp_assoc, ← Functor.map_comp] using
congr(Y.presheaf.map (eqToHom (congr_arg (U.ι ''ᵁ ·) (U.ι.preimage_image_eq V).symm)).op ≫
$(Scheme.Hom.congr_app (morphismRestrict_ι f U) (U.ι ''ᵁ V)))
theorem morphismRestrict_appTop {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) :
(f ∣_ U).appTop = f.app (U.ι ''ᵁ ⊤) ≫
X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U ⊤)).op :=
morphismRestrict_app ..
@[simp]
theorem morphismRestrict_app' {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : Opens U) :
(f ∣_ U).app V = f.appLE _ _ (image_morphismRestrict_preimage f U V).le :=
morphismRestrict_app f U V
@[simp]
theorem morphismRestrict_appLE {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V W e) :
(f ∣_ U).appLE V W e = f.appLE (U.ι ''ᵁ V) ((f ⁻¹ᵁ U).ι ''ᵁ W)
((Set.image_mono e).trans (image_morphismRestrict_preimage f U V).le) := by
rw [Scheme.Hom.appLE, morphismRestrict_app', Scheme.Opens.toScheme_presheaf_map,
Scheme.Hom.appLE_map]
@[deprecated (since := "2025-10-14")] alias Γ_map_morphismRestrict := morphismRestrict_appTop
/-- Restricting a morphism onto the image of an open immersion is isomorphic to the base change
along the immersion. -/
def morphismRestrictOpensRange {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y) [IsOpenImmersion g] :
Arrow.mk (f ∣_ g.opensRange) ≅ Arrow.mk (pullback.snd f g) := by
let V : Y.Opens := g.opensRange
let e :=
IsOpenImmersion.isoOfRangeEq g V.ι Subtype.range_coe.symm
let t : pullback f g ⟶ pullback f V.ι :=
pullback.map _ _ _ _ (𝟙 _) e.hom (𝟙 _) (by rw [Category.comp_id, Category.id_comp])
(by rw [Category.comp_id, IsOpenImmersion.isoOfRangeEq_hom_fac])
symm
refine Arrow.isoMk (asIso t ≪≫ pullbackRestrictIsoRestrict f V) e ?_
rw [Iso.trans_hom, asIso_hom, ← Iso.comp_inv_eq, ← cancel_mono g, Arrow.mk_hom, Arrow.mk_hom,
Category.assoc, Category.assoc, Category.assoc, IsOpenImmersion.isoOfRangeEq_inv_fac,
← pullback.condition, morphismRestrict_ι,
pullbackRestrictIsoRestrict_hom_ι_assoc, pullback.lift_fst_assoc, Category.comp_id]
/-- The restrictions onto two equal open sets are isomorphic. This currently has bad defeqs when
unfolded, but it should not matter for now. Replace this definition if better defeqs are needed. -/
def morphismRestrictEq {X Y : Scheme.{u}} (f : X ⟶ Y) {U V : Y.Opens} (e : U = V) :
Arrow.mk (f ∣_ U) ≅ Arrow.mk (f ∣_ V) :=
eqToIso (by subst e; rfl)
/-- Restricting a morphism twice is isomorphic to one restriction. -/
def morphismRestrictRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : U.toScheme.Opens) :
Arrow.mk (f ∣_ U ∣_ V) ≅ Arrow.mk (f ∣_ U.ι ''ᵁ V) := by
refine Arrow.isoMk' _ _ ((Scheme.Opens.ι _).isoImage _ ≪≫ Scheme.isoOfEq _ ?_)
((Scheme.Opens.ι _).isoImage _) ?_
· exact image_morphismRestrict_preimage f U V
· rw [← cancel_mono (Scheme.Opens.ι _), Iso.trans_hom, Category.assoc, Category.assoc,
Category.assoc, morphismRestrict_ι, Scheme.isoOfEq_hom_ι_assoc,
Scheme.Hom.isoImage_hom_ι_assoc,
Scheme.Hom.isoImage_hom_ι,
morphismRestrict_ι_assoc, morphismRestrict_ι]
/-- Restricting a morphism twice onto a basic open set is isomorphic to one restriction. -/
def morphismRestrictRestrictBasicOpen {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (r : Γ(Y, U)) :
Arrow.mk (f ∣_ U ∣_
U.toScheme.basicOpen (Y.presheaf.map (eqToHom U.isOpenEmbedding_obj_top).op r)) ≅
Arrow.mk (f ∣_ Y.basicOpen r) := by
refine morphismRestrictRestrict _ _ _ ≪≫ morphismRestrictEq _ ?_
have e := Scheme.preimage_basicOpen U.ι r
rw [Scheme.Opens.ι_app] at e
rw [← U.toScheme.basicOpen_res_eq _ (eqToHom U.inclusion'_map_eq_top).op]
erw [← elementwise_of% Y.presheaf.map_comp]
rw [eqToHom_op, eqToHom_op, eqToHom_map, eqToHom_trans]
erw [← e]
ext1
dsimp [Opens.map_coe]
rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left, Scheme.Opens.range_ι]
exact Y.basicOpen_le r
/-- The stalk map of a restriction of a morphism is isomorphic to the stalk map of the original map.
-/
def morphismRestrictStalkMap {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (x) :
Arrow.mk ((f ∣_ U).stalkMap x) ≅ Arrow.mk (f.stalkMap x.1) := Arrow.isoMk' _ _
(U.stalkIso ((f ∣_ U) x) ≪≫
(TopCat.Presheaf.stalkCongr _ <| Inseparable.of_eq <| morphismRestrict_base_coe f U x))
((f ⁻¹ᵁ U).stalkIso x) <| TopCat.Presheaf.stalk_hom_ext _ fun V hxV ↦ by
simp [Scheme.Hom.germ_stalkMap_assoc, Scheme.Hom.appLE]
instance {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) [IsOpenImmersion f] :
IsOpenImmersion (f ∣_ U) := by
delta morphismRestrict
exact PresheafedSpace.IsOpenImmersion.comp _ _
variable {X Y : Scheme.{u}}
namespace Scheme.Hom
/-- The restriction of a morphism `f : X ⟶ Y` to open sets on the source and target. -/
def resLE (f : Hom X Y) (U : Y.Opens) (V : X.Opens) (e : V ≤ f ⁻¹ᵁ U) : V.toScheme ⟶ U.toScheme :=
X.homOfLE e ≫ f ∣_ U
variable (f : X ⟶ Y) {U U' : Y.Opens} {V V' : X.Opens} (e : V ≤ f ⁻¹ᵁ U)
lemma resLE_eq_morphismRestrict : f.resLE U (f ⁻¹ᵁ U) le_rfl = f ∣_ U := by
simp [resLE]
@[simp]
lemma resLE_id (i : V ≤ V') : resLE (𝟙 X) V' V i = X.homOfLE i := by
simp only [resLE, morphismRestrict_id]
rfl
@[reassoc (attr := simp)]
lemma resLE_comp_ι : f.resLE U V e ≫ U.ι = V.ι ≫ f := by
simp [resLE]
@[reassoc]
lemma resLE_comp_resLE {Z : Scheme.{u}} (g : Y ⟶ Z) {W : Z.Opens} (e') :
f.resLE U V e ≫ g.resLE W U e' = (f ≫ g).resLE W V
(e.trans ((Opens.map f.base).map (homOfLE e')).le) := by
simp [← cancel_mono W.ι]
@[reassoc (attr := simp)]
lemma map_resLE (i : V' ≤ V) :
X.homOfLE i ≫ f.resLE U V e = f.resLE U V' (i.trans e) := by
simp_rw [← resLE_id, resLE_comp_resLE, Category.id_comp]
@[reassoc (attr := simp)]
lemma resLE_map (i : U ≤ U') :
f.resLE U V e ≫ Y.homOfLE i =
f.resLE U' V (e.trans ((Opens.map f.base).map i.hom).le) := by
simp_rw [← resLE_id, resLE_comp_resLE, Category.comp_id]
lemma resLE_congr (e₁ : U = U') (e₂ : V = V') (P : MorphismProperty Scheme.{u}) :
P (f.resLE U V e) ↔ P (f.resLE U' V' (e₁ ▸ e₂ ▸ e)) := by
subst e₁; subst e₂; rfl
lemma resLE_preimage (f : X ⟶ Y) {U : Y.Opens} {V : X.Opens} (e : V ≤ f ⁻¹ᵁ U)
(O : U.toScheme.Opens) :
f.resLE U V e ⁻¹ᵁ O = V.ι ⁻¹ᵁ (f ⁻¹ᵁ U.ι ''ᵁ O) := by
rw [← comp_preimage, ← resLE_comp_ι f e, comp_preimage, preimage_image_eq]
lemma le_resLE_preimage_iff {U : Y.Opens} {V : X.Opens} (e : V ≤ f ⁻¹ᵁ U)
(O : U.toScheme.Opens) (W : V.toScheme.Opens) :
W ≤ (f.resLE U V e) ⁻¹ᵁ O ↔ V.ι ''ᵁ W ≤ f ⁻¹ᵁ U.ι ''ᵁ O := by
simp [resLE_preimage, ← image_le_image_iff V.ι, image_preimage_eq_opensRange_inf, V.ι_image_le]
@[deprecated (since := "2025-10-07")] alias le_preimage_resLE_iff := le_resLE_preimage_iff
lemma resLE_appLE {U : Y.Opens} {V : X.Opens} (e : V ≤ f ⁻¹ᵁ U)
(O : U.toScheme.Opens) (W : V.toScheme.Opens) (e' : W ≤ resLE f U V e ⁻¹ᵁ O) :
(f.resLE U V e).appLE O W e' =
f.appLE (U.ι ''ᵁ O) (V.ι ''ᵁ W) ((le_resLE_preimage_iff f e O W).mp e') := by
dsimp [appLE, resLE]
simp only [morphismRestrict_app', appLE, homOfLE_leOfHom, homOfLE_app, Category.assoc]
rw [← X.presheaf.map_comp, ← X.presheaf.map_comp]
rfl
@[simp]
lemma coe_resLE_apply (x : V) : (f.resLE U V e x).1 = f x := by
simp [resLE, morphismRestrict_base]
@[deprecated (since := "2025-10-07")] alias coe_resLE_base := coe_resLE_apply
/-- The stalk map of `f.resLE U V` at `x : V` is the stalk map of `f` at `x`. -/
def resLEStalkMap (x : V) :
Arrow.mk ((f.resLE U V e).stalkMap x) ≅ Arrow.mk (f.stalkMap x) :=
Arrow.isoMk (U.stalkIso _ ≪≫
(Y.presheaf.stalkCongr <| Inseparable.of_eq <| by simp)) (V.stalkIso x) <| by
dsimp
rw [Category.assoc, ← Iso.eq_inv_comp, ← Category.assoc, ← Iso.comp_inv_eq,
Opens.stalkIso_inv, Opens.stalkIso_inv, ← stalkMap_comp,
stalkMap_congr_hom _ _ (resLE_comp_ι f e), stalkMap_comp]
simp
end Scheme.Hom
/-- `f.resLE U V` induces `f.appLE U V` on global sections. -/
noncomputable def arrowResLEAppIso (f : X ⟶ Y) (U : Y.Opens) (V : X.Opens) (e : V ≤ f ⁻¹ᵁ U) :
Arrow.mk ((f.resLE U V e).appTop) ≅ Arrow.mk (f.appLE U V e) :=
Arrow.isoMk U.topIso V.topIso <| by
simp only [Arrow.mk_left, Arrow.mk_right, Functor.id_obj, Scheme.Opens.topIso_hom,
eqToHom_op, Arrow.mk_hom, Scheme.Hom.map_appLE]
rw [Scheme.Hom.appTop, ← Scheme.Hom.appLE_eq_app, Scheme.Hom.resLE_appLE, Scheme.Hom.appLE_map]
end MorphismRestrict
/-- The restriction of an open cover to an open subset. -/
@[simps! I₀ X f]
noncomputable
def Scheme.OpenCover.restrict {X : Scheme.{u}} (𝒰 : X.OpenCover) (U : Opens X) :
U.toScheme.OpenCover := by
refine Cover.copy (𝒰.pullback₁ U.ι) 𝒰.I₀ _ (𝒰.f · ∣_ U) (Equiv.refl _)
(fun i ↦ IsOpenImmersion.isoOfRangeEq (Opens.ι _) (pullback.snd _ _) ?_) ?_
· dsimp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_I₀, Equiv.refl_apply, PreZeroHypercover.pullback₁_X]
rw [IsOpenImmersion.range_pullbackSnd U.ι (𝒰.f i), Opens.opensRange_ι]
exact Subtype.range_val
· intro i
rw [← cancel_mono U.ι]
simp [morphismRestrict_ι, Equiv.refl_apply, Category.assoc, pullback.condition]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/StructureSheaf.lean | import Mathlib.Algebra.Category.Ring.Colimits
import Mathlib.Algebra.Category.Ring.Instances
import Mathlib.Algebra.Category.Ring.Limits
import Mathlib.Algebra.Ring.Subring.Basic
import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.Spectrum.Prime.Topology
import Mathlib.Topology.Sheaves.LocalPredicate
/-!
# The structure sheaf on `PrimeSpectrum R`.
We define the structure sheaf on `TopCat.of (PrimeSpectrum R)`, for a commutative ring `R` and prove
basic properties about it. We define this as a subsheaf of the sheaf of dependent functions into the
localizations, cut out by the condition that the function must be locally equal to a ratio of
elements of `R`.
Because the condition "is equal to a fraction" passes to smaller open subsets,
the subset of functions satisfying this condition is automatically a subpresheaf.
Because the condition "is locally equal to a fraction" is local,
it is also a subsheaf.
(It may be helpful to refer back to `Mathlib/Topology/Sheaves/SheafOfFunctions.lean`,
where we show that dependent functions into any type family form a sheaf,
and also `Mathlib/Topology/Sheaves/LocalPredicate.lean`, where we characterise the predicates
which pick out sub-presheaves and sub-sheaves of these sheaves.)
We also set up the ring structure, obtaining
`structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R)`.
We then construct two basic isomorphisms, relating the structure sheaf to the underlying ring `R`.
First, `StructureSheaf.stalkIso` gives an isomorphism between the stalk of the structure sheaf
at a point `p` and the localization of `R` at the prime ideal `p`. Second,
`StructureSheaf.basicOpenIso` gives an isomorphism between the structure sheaf on `basicOpen f`
and the localization of `R` at the submonoid of powers of `f`.
## References
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
universe u
noncomputable section
variable (R : Type u) [CommRing R]
open TopCat
open TopologicalSpace
open CategoryTheory
open Opposite
namespace AlgebraicGeometry
/-- The prime spectrum, just as a topological space.
-/
def PrimeSpectrum.Top : TopCat :=
TopCat.of (PrimeSpectrum R)
namespace StructureSheaf
/-- The type family over `PrimeSpectrum R` consisting of the localization over each point.
-/
def Localizations (P : PrimeSpectrum.Top R) : Type u :=
Localization.AtPrime P.asIdeal
instance commRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
inferInstanceAs <| CommRing <| Localization.AtPrime P.asIdeal
instance localRingLocalizations (P : PrimeSpectrum.Top R) : IsLocalRing <| Localizations R P :=
inferInstanceAs <| IsLocalRing <| Localization.AtPrime P.asIdeal
instance (P : PrimeSpectrum.Top R) : Inhabited (Localizations R P) :=
⟨1⟩
instance (U : Opens (PrimeSpectrum.Top R)) (x : U) : Algebra R (Localizations R x) :=
inferInstanceAs <| Algebra R (Localization.AtPrime x.1.asIdeal)
instance (U : Opens (PrimeSpectrum.Top R)) (x : U) :
IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.Top R).asIdeal :=
Localization.isLocalization
variable {R}
/-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
`r / s` in each of the stalks (which are localizations at various prime ideals).
-/
def IsFraction {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) : Prop :=
∃ r s : R, ∀ x : U, s ∉ x.1.asIdeal ∧ f x * algebraMap _ _ s = algebraMap _ _ r
theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Localizations R x}
(hf : IsFraction f) :
∃ r s : R,
∀ x : U,
∃ hs : s ∉ x.1.asIdeal,
f x =
IsLocalization.mk' (Localization.AtPrime _) r
(⟨s, hs⟩ : (x : PrimeSpectrum.Top R).asIdeal.primeCompl) := by
rcases hf with ⟨r, s, h⟩
refine ⟨r, s, fun x => ⟨(h x).1, (IsLocalization.mk'_eq_iff_eq_mul.mpr ?_).symm⟩⟩
exact (h x).2.symm
variable (R)
/-- The predicate `IsFraction` is "prelocal",
in the sense that if it holds on `U` it holds on any open subset `V` of `U`.
-/
def isFractionPrelocal : PrelocalPredicate (Localizations R) where
pred {_} f := IsFraction f
res := by rintro V U i f ⟨r, s, w⟩; exact ⟨r, s, fun x => w (i x)⟩
/-- We will define the structure sheaf as
the subsheaf of all dependent functions in `Π x : U, Localizations R x`
consisting of those functions which can locally be expressed as a ratio of
(the images in the localization of) elements of `R`.
Quoting Hartshorne:
For an open set $U ⊆ Spec A$, we define $𝒪(U)$ to be the set of functions
$s : U → ⨆_{𝔭 ∈ U} A_𝔭$, such that $s(𝔭) ∈ A_𝔭$ for each $𝔭$,
and such that $s$ is locally a quotient of elements of $A$:
to be precise, we require that for each $𝔭 ∈ U$, there is a neighborhood $V$ of $𝔭$,
contained in $U$, and elements $a, f ∈ A$, such that for each $𝔮 ∈ V, f ∉ 𝔮$,
and $s(𝔮) = a/f$ in $A_𝔮$.
Now Hartshorne had the disadvantage of not knowing about dependent functions,
so we replace his circumlocution about functions into a disjoint union with
`Π x : U, Localizations x`.
-/
def isLocallyFraction : LocalPredicate (Localizations R) :=
(isFractionPrelocal R).sheafify
@[simp]
theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) :
(isLocallyFraction R).pred f =
∀ x : U,
∃ (V : _) (_ : x.1 ∈ V) (i : V ⟶ U),
∃ r s : R,
∀ y : V, s ∉ y.1.asIdeal ∧ f (i y : U) * algebraMap _ _ s = algebraMap _ _ r :=
rfl
/-- The functions satisfying `isLocallyFraction` form a subring.
-/
def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
Subring (∀ x : U.unop, Localizations R x) where
carrier := { f | (isLocallyFraction R).pred f }
zero_mem' := by
refine fun x => ⟨unop U, x.2, 𝟙 _, 0, 1, fun y => ⟨?_, ?_⟩⟩
· rw [← Ideal.ne_top_iff_one]; exact y.1.isPrime.1
· simp
one_mem' := by
refine fun x => ⟨unop U, x.2, 𝟙 _, 1, 1, fun y => ⟨?_, ?_⟩⟩
· rw [← Ideal.ne_top_iff_one]; exact y.1.isPrime.1
· simp
add_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ra * sb + rb * sa, sa * sb, ?_⟩
intro ⟨y, hy⟩
rcases wa (Opens.infLELeft _ _ ⟨y, hy⟩) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ ⟨y, hy⟩) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.isPrime.mem_or_mem H <;> contradiction
· simp only [Opens.apply_mk, Pi.add_apply, RingHom.map_mul, add_mul, RingHom.map_add] at wa wb ⊢
grind
neg_mem' := by
intro a ha x
rcases ha x with ⟨V, m, i, r, s, w⟩
refine ⟨V, m, i, -r, s, ?_⟩
intro y
rcases w y with ⟨nm, w⟩
fconstructor
· exact nm
· simp only [RingHom.map_neg, Pi.neg_apply]
rw [← w]
simp only [neg_mul]
mul_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ra * rb, sa * sb, ?_⟩
intro ⟨y, hy⟩
rcases wa (Opens.infLELeft _ _ ⟨y, hy⟩) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ ⟨y, hy⟩) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.isPrime.mem_or_mem H <;> contradiction
· simp only [Opens.apply_mk, Pi.mul_apply, RingHom.map_mul] at wa wb ⊢
rw [← wa, ← wb]
simp only [mul_left_comm, mul_assoc, mul_comm]
end StructureSheaf
open StructureSheaf
/-- The structure sheaf (valued in `Type`, not yet `CommRingCat`) is the subsheaf consisting of
functions satisfying `isLocallyFraction`.
-/
def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
subsheafToTypes (isLocallyFraction R)
instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
CommRing ((structureSheafInType R).1.obj U) :=
(sectionsSubring R U).toCommRing
open PrimeSpectrum
/-- The structure presheaf, valued in `CommRingCat`, constructed by dressing up the `Type`-valued
structure presheaf.
-/
@[simps obj_carrier]
def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) where
obj U := CommRingCat.of ((structureSheafInType R).1.obj U)
map {_ _} i := CommRingCat.ofHom
{ toFun := (structureSheafInType R).1.map i
map_zero' := rfl
map_add' := fun _ _ => rfl
map_one' := rfl
map_mul' := fun _ _ => rfl }
/-- Some glue, verifying that the structure presheaf valued in `CommRingCat` agrees
with the `Type`-valued structure presheaf.
-/
def structurePresheafCompForget :
structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 :=
NatIso.ofComponents fun _ => Iso.refl _
open TopCat.Presheaf
/-- The structure sheaf on $Spec R$, valued in `CommRingCat`.
This is provided as a bundled `SheafedSpace` as `Spec.SheafedSpace R` later.
-/
def Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R) :=
⟨structurePresheafInCommRing R,
(-- We check the sheaf condition under `forget CommRingCat`.
isSheaf_iff_isSheaf_comp
_ _).mpr
(isSheaf_of_iso (structurePresheafCompForget R).symm (structureSheafInType R).cond)⟩
open Spec (structureSheaf)
namespace StructureSheaf
@[simp]
theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U)
(s : (structureSheaf R).1.obj (op U)) (x : V) :
((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) :) :=
rfl
/-
Notation in this comment
X = Spec R
OX = structure sheaf
In the following we construct an isomorphism between OX_p and R_p given any point p corresponding
to a prime ideal in R.
We do this via 8 steps:
1. def const (f g : R) (V) (hv : V ≤ D_g) : OX(V) [for api]
2. def toOpen (U) : R ⟶ OX(U)
3. [2] def toStalk (p : Spec R) : R ⟶ OX_p
4. [2] def toBasicOpen (f : R) : R_f ⟶ OX(D_f)
5. [3] def localizationToStalk (p : Spec R) : R_p ⟶ OX_p
6. def openToLocalization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p
7. [6] def stalkToFiberRingHom (p : Spec R) : OX_p ⟶ R_p
8. [5,7] def stalkIso (p : Spec R) : OX_p ≅ R_p
In the square brackets we list the dependencies of a construction on the previous steps.
-/
/-- The section of `structureSheaf R` on an open `U` sending each `x ∈ U` to the element
`f/g` in the localization of `R` at `x`. -/
def const (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
(structureSheaf R).1.obj (op U) :=
⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x =>
⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩
@[simp]
theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) :
(const R f g U hu).1 x =
IsLocalization.mk' (Localization.AtPrime x.1.asIdeal) f ⟨g, hu x x.2⟩ :=
rfl
theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U)
(hx : g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
(const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ :=
rfl
theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) :
∃ (V : Opens (PrimeSpectrum.Top R)) (_ : x ∈ V) (i : V ⟶ U) (f g : R) (hg : _),
const R f g V hg = (structureSheaf R).1.map i.op s :=
let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩
⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1,
Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2⟩
@[simp]
theorem res_const (f g : R) (U hu V hv i) :
(structureSheaf R).1.map i (const R f g U hu) = const R f g V hv :=
rfl
theorem res_const' (f g : R) (V hv) :
(structureSheaf R).1.map (homOfLE hv).op (const R f g (PrimeSpectrum.basicOpen g) fun _ => id) =
const R f g V hv :=
rfl
theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
Subtype.eq <| funext fun x => IsLocalization.mk'_eq_iff_eq_mul.2 <| by
rw [RingHom.map_zero]
exact (mul_eq_zero_of_left rfl ((algebraMap R (Localizations R x)) _)).symm
theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
Subtype.eq <| funext fun _ => IsLocalization.mk'_self _ _
theorem const_one (U) : (const R 1 1 U fun _ _ => Submonoid.one_mem _) = 1 :=
const_self R 1 U _
theorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ =
const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U fun x hx =>
Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=
Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_add _ _
⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
theorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ =
const R (f₁ * f₂) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=
Subtype.eq <|
funext fun x =>
Eq.symm <| IsLocalization.mk'_mul _ f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
theorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) :
const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ :=
Subtype.eq <|
funext fun x =>
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk])
theorem const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) :
const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) := by substs hf hg; rfl
theorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R g f U hu₂ = 1 := by
rw [const_mul, const_congr R rfl (mul_comm g f), const_self]
theorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :
const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ := by
rw [const_mul, const_ext]; rw [mul_assoc]
theorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :
const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ := by
rw [mul_comm, const_mul_cancel]
/-- The canonical ring homomorphism interpreting an element of `R` as
a section of the structure sheaf. -/
def toOpen (U : Opens (PrimeSpectrum.Top R)) :
CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U) := CommRingCat.ofHom
{ toFun f :=
⟨fun _ => algebraMap R _ f, fun x =>
⟨U, x.2, 𝟙 _, f, 1, fun y =>
⟨(Ideal.ne_top_iff_one _).1 y.1.2.1, by simp [RingHom.map_one, mul_one]⟩⟩⟩
map_one' := Subtype.eq <| funext fun _ => RingHom.map_one _
map_mul' _ _ := Subtype.eq <| funext fun _ => RingHom.map_mul _ _ _
map_zero' := Subtype.eq <| funext fun _ => RingHom.map_zero _
map_add' _ _ := Subtype.eq <| funext fun _ => RingHom.map_add _ _ _ }
@[simp]
theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) :
toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V :=
rfl
@[simp]
theorem toOpen_apply (U : Opens (PrimeSpectrum.Top R)) (f : R) (x : U) :
(toOpen R U f).1 x = algebraMap _ _ f :=
rfl
theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) :
toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 :=
Subtype.eq <| funext fun _ => Eq.symm <| IsLocalization.mk'_one _ f
/-- The canonical ring homomorphism interpreting an element of `R` as an element of
the stalk of `structureSheaf R` at `x`. -/
def toStalk (x : PrimeSpectrum.Top R) : CommRingCat.of R ⟶ (structureSheaf R).presheaf.stalk x :=
(toOpen R ⊤ ≫ (structureSheaf R).presheaf.germ _ x (by trivial))
@[simp]
theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) :
toOpen R U ≫ (structureSheaf R).presheaf.germ U x hx = toStalk R x := by
rw [← toOpen_res R ⊤ U (homOfLE le_top : U ⟶ ⊤), Category.assoc, Presheaf.germ_res]; rfl
@[simp]
theorem germ_toOpen
(U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) (f : R) :
(structureSheaf R).presheaf.germ U x hx (toOpen R U f) = toStalk R x f := by
rw [← toOpen_germ]; rfl
theorem toOpen_Γgerm_apply (x : PrimeSpectrum.Top R) (f : R) :
(structureSheaf R).presheaf.Γgerm x (toOpen R ⊤ f) = toStalk R x f :=
rfl
theorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (PrimeSpectrum.basicOpen f) f) :=
.of_mul_eq_one (const R 1 f (PrimeSpectrum.basicOpen f) fun _ => id) <| by
rw [toOpen_eq_const, const_mul_rev]
theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : x.asIdeal.primeCompl) :
IsUnit (toStalk R x (f : R)) := by
rw [← germ_toOpen R (PrimeSpectrum.basicOpen (f : R)) x f.2 (f : R)]
exact RingHom.isUnit_map _ (isUnit_to_basicOpen_self R f)
/-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk
of the structure sheaf at the point `p`. -/
def localizationToStalk (x : PrimeSpectrum.Top R) :
CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).presheaf.stalk x :=
CommRingCat.ofHom <|
show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x)
@[simp]
theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) :
localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=
IsLocalization.lift_eq (S := Localization x.asIdeal.primeCompl) _ f
@[simp]
theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : x.asIdeal.primeCompl) :
localizationToStalk R x (IsLocalization.mk' (Localization.AtPrime x.asIdeal) f s) =
(structureSheaf R).presheaf.germ (PrimeSpectrum.basicOpen (s : R)) x s.2
(const R f s (PrimeSpectrum.basicOpen s) fun _ => id) :=
(IsLocalization.lift_mk'_spec (S := Localization.AtPrime x.asIdeal) _ _ _ _).2 <| by
rw [← germ_toOpen R (PrimeSpectrum.basicOpen s) x s.2,
← germ_toOpen R (PrimeSpectrum.basicOpen s) x s.2, ← RingHom.map_mul, toOpen_eq_const,
toOpen_eq_const, const_mul_cancel']
/-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,
implemented as a subtype of dependent functions to localizations at prime ideals, and evaluates
the section on the point corresponding to a given prime ideal. -/
def openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) :
(structureSheaf R).1.obj (op U) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
CommRingCat.ofHom
{ toFun s := (s.1 ⟨x, hx⟩ :)
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl }
@[simp]
theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) :
(openToLocalization R U x hx :
(structureSheaf R).1.obj (op U) → Localization.AtPrime x.asIdeal) =
fun s => s.1 ⟨x, hx⟩ :=
rfl
theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
openToLocalization R U x hx s = s.1 ⟨x, hx⟩ :=
rfl
/-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to
a prime ideal `p` to the localization of `R` at `p`,
formed by gluing the `openToLocalization` maps. -/
def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
(structureSheaf R).presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
{ pt := _
ι := { app := fun U =>
openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } }
@[simp]
theorem germ_comp_stalkToFiberRingHom
(U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) :
(structureSheaf R).presheaf.germ U x hx ≫ stalkToFiberRingHom R x =
openToLocalization R U x hx :=
Limits.colimit.ι_desc _ _
@[simp]
theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R))
(x : PrimeSpectrum.Top R) (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
stalkToFiberRingHom R x ((structureSheaf R).presheaf.germ U x hx s) = s.1 ⟨x, hx⟩ :=
RingHom.ext_iff.mp (CommRingCat.hom_ext_iff.mp (germ_comp_stalkToFiberRingHom R U x hx)) s
@[simp]
theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
toStalk R x ≫ stalkToFiberRingHom R x = CommRingCat.ofHom (algebraMap _ _) := by
rw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
@[simp]
theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
stalkToFiberRingHom R x (toStalk R x f) = algebraMap _ _ f :=
RingHom.ext_iff.1 (CommRingCat.hom_ext_iff.mp (toStalk_comp_stalkToFiberRingHom R x)) _
/-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`
corresponding to a prime ideal in `R` and the localization of `R` at `p`. -/
@[simps]
def stalkIso (x : PrimeSpectrum.Top R) :
(structureSheaf R).presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal) where
hom := stalkToFiberRingHom R x
inv := localizationToStalk R x
hom_inv_id := by
apply stalk_hom_ext
intro U hxU
ext s
dsimp only [CommRingCat.hom_comp, RingHom.coe_comp, Function.comp_apply, CommRingCat.hom_id,
RingHom.coe_id, id_eq]
rw [stalkToFiberRingHom_germ]
obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
exists_const _ _ s x hxU
have := res_apply R U V iVU s ⟨x, hxV⟩
dsimp only [isLocallyFraction_pred, Opens.apply_mk] at this
rw [← this, ← hs, const_apply, localizationToStalk_mk']
refine (structureSheaf R).presheaf.germ_ext V hxV (homOfLE hg) iVU ?_
rw [← hs, res_const']
inv_hom_id := CommRingCat.hom_ext <| IsLocalization.ringHom_ext x.asIdeal.primeCompl <| by
ext f
rw [CommRingCat.hom_comp, CommRingCat.hom_id,
RingHom.comp_apply, RingHom.comp_apply, localizationToStalk_of,
stalkToFiberRingHom_toStalk, RingHom.comp_apply, RingHom.id_apply]
instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
(stalkIso R x).isIso_hom
instance (x : PrimeSpectrum R) : IsLocalHom (stalkToFiberRingHom R x).hom :=
isLocalHom_of_isIso _
instance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) :=
(stalkIso R x).isIso_inv
instance (x : PrimeSpectrum R) : IsLocalHom (localizationToStalk R x).hom :=
isLocalHom_of_isIso _
@[simp, reassoc]
theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.Top R) :
stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ :=
(stalkIso R x).hom_inv_id
@[simp, reassoc]
theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=
(stalkIso R x).inv_hom_id
/-- The canonical ring homomorphism interpreting `s ∈ R_f` as a section of the structure sheaf
on the basic open defined by `f ∈ R`. -/
def toBasicOpen (f : R) :
Localization.Away f →+* (structureSheaf R).1.obj (op <| PrimeSpectrum.basicOpen f) :=
IsLocalization.Away.lift f (isUnit_to_basicOpen_self R f)
@[simp]
theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
const R f g (PrimeSpectrum.basicOpen s) fun _ hx => Submonoid.powers_le.2 hx g.2 :=
(IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
rw [toOpen_eq_const, toOpen_eq_const, const_mul_cancel']
@[simp]
theorem localization_toBasicOpen (f : R) :
RingHom.comp (toBasicOpen R f) (algebraMap R (Localization.Away f)) =
(toOpen R (PrimeSpectrum.basicOpen f)).hom :=
RingHom.ext fun g => by
rw [toBasicOpen, IsLocalization.Away.lift, RingHom.comp_apply, IsLocalization.lift_eq]
@[simp]
theorem toBasicOpen_to_map (s f : R) :
toBasicOpen R s (algebraMap R (Localization.Away s) f) =
const R f 1 (PrimeSpectrum.basicOpen s) fun _ _ => Submonoid.one_mem _ :=
(IsLocalization.lift_eq _ _).trans <| toOpen_eq_const _ _ _
-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) := by
intro s t h_eq
obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.exists_mk'_eq (Submonoid.powers f) s
obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.exists_mk'_eq (Submonoid.powers f) t
simp only [toBasicOpen_mk'] at h_eq
rw [IsLocalization.eq]
-- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on
-- `basicOpen f`. We need to show that they agree as elements in the localization of `R` at `f`.
-- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`.
-- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
let I : Ideal R :=
{ carrier := { r : R | r * (d * a) = r * (b * c) }
zero_mem' := by simp only [Set.mem_setOf_eq, zero_mul]
add_mem' := fun {r₁ r₂} hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂]
smul_mem' := fun {r₁ r₂} hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] }
-- Our claim now reduces to showing that `f` is contained in the radical of `I`
suffices f ∈ I.radical by
obtain ⟨n, hn⟩ := this
exact ⟨⟨f ^ n, n, rfl⟩, hn⟩
rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.mem_vanishingIdeal]
intro p hfp
contrapose hfp
rw [PrimeSpectrum.mem_zeroLocus, Set.not_subset]
have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
dsimp at this
rw [IsLocalization.eq (S := Localization.AtPrime p.asIdeal)] at this
obtain ⟨r, hr⟩ := this
exact ⟨r.1, hr, r.2⟩
/-
Auxiliary lemma for surjectivity of `toBasicOpen`.
Every section can locally be represented on basic opens `basicOpen g` as a fraction `f/g`
-/
theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
(s : (structureSheaf R).1.obj (op U)) (x : U) :
∃ (f g : R) (i : PrimeSpectrum.basicOpen g ⟶ U), x.1 ∈ PrimeSpectrum.basicOpen g ∧
(const R f g (PrimeSpectrum.basicOpen g) fun _ hy => hy) =
(structureSheaf R).1.map i.op s := by
-- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x`
-- and we may pass to a `basicOpen h`, since these form a basis
obtain ⟨V, hxV : x.1 ∈ V.1, iVU, f, g, hVDg : V ≤ PrimeSpectrum.basicOpen g, s_eq⟩ :=
exists_const R U s x.1 x.2
obtain ⟨_, ⟨h, rfl⟩, hxDh, hDhV : PrimeSpectrum.basicOpen h ≤ V⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open hxV V.2
-- The problem is of course, that `g` and `h` don't need to coincide.
-- But, since `basicOpen h ≤ basicOpen g`, some power of `h` must be a multiple of `g`
obtain ⟨n, hn⟩ := (PrimeSpectrum.basicOpen_le_basicOpen_iff h g).mp (Set.Subset.trans hDhV hVDg)
-- Actually, we will need a *nonzero* power of `h`.
-- This is because we will need the equality `basicOpen (h ^ n) = basicOpen h`, which only
-- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
replace hn := Ideal.mul_mem_right h (Ideal.span {g}) hn
rw [← pow_succ, Ideal.mem_span_singleton'] at hn
obtain ⟨c, hc⟩ := hn
have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by cutsat)
have i_basic_open := eqToHom basic_opens_eq ≫ homOfLE hDhV
-- We claim that `(f * c) / h ^ (n + 1)` is our desired representation
use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le :) hxDh
rw [op_comp, Functor.map_comp, ConcreteCategory.comp_apply, ← s_eq, res_const]
-- Note that the last rewrite here generated an additional goal, which was a parameter
-- of `res_const`. We prove this goal first
swap
· intro y hy
rw [basic_opens_eq] at hy
exact (Set.Subset.trans hDhV hVDg :) hy
-- All that is left is a simple calculation
apply const_ext
rw [mul_assoc f c g, hc]
/-
Auxiliary lemma for surjectivity of `toBasicOpen`.
A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
`basicOpen (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
-/
theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R))
(s : (structureSheaf R).1.obj (op U)) {ι : Type*} (t : Finset ι) (a h : ι → R)
(iDh : ∀ i : ι, PrimeSpectrum.basicOpen (h i) ⟶ U)
(h_cover : U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h i))
(hs :
∀ i : ι,
(const R (a i) (h i) (PrimeSpectrum.basicOpen (h i)) fun _ hy => hy) =
(structureSheaf R).1.map (iDh i).op s) :
∃ (a' h' : ι → R) (iDh' : ∀ i : ι, PrimeSpectrum.basicOpen (h' i) ⟶ U),
(U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h' i)) ∧
(∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧
∀ i ∈ t,
(structureSheaf R).1.map (iDh' i).op s =
const R (a' i) (h' i) (PrimeSpectrum.basicOpen (h' i)) fun _ hy => hy := by
-- First we show that the fractions `(a i * h j) / (h i * h j)` and `(h i * a j) / (h i * h j)`
-- coincide in the localization of `R` at `h i * h j`
have fractions_eq :
∀ i j : ι,
IsLocalization.mk' (Localization.Away (h i * h j))
(a i * h j) ⟨h i * h j, Submonoid.mem_powers _⟩ =
IsLocalization.mk' _ (h i * a j) ⟨h i * h j, Submonoid.mem_powers _⟩ := by
intro i j
let D := PrimeSpectrum.basicOpen (h i * h j)
let iDi : D ⟶ PrimeSpectrum.basicOpen (h i) := homOfLE (PrimeSpectrum.basicOpen_mul_le_left _ _)
let iDj : D ⟶ PrimeSpectrum.basicOpen (h j) :=
homOfLE (PrimeSpectrum.basicOpen_mul_le_right _ _)
-- Crucially, we need injectivity of `toBasicOpen`
apply toBasicOpen_injective R (h i * h j)
rw [toBasicOpen_mk', toBasicOpen_mk']
simp only []
-- Here, both sides of the equation are equal to a restriction of `s`
trans
on_goal 1 =>
convert congr_arg ((structureSheaf R).1.map iDj.op) (hs j).symm using 1
convert congr_arg ((structureSheaf R).1.map iDi.op) (hs i) using 1
all_goals rw [res_const]; apply const_ext; ring
-- The remaining two goals were generated during the rewrite of `res_const`
-- These can be solved immediately
exacts [PrimeSpectrum.basicOpen_mul_le_left _ _, PrimeSpectrum.basicOpen_mul_le_right _ _]
-- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n`
-- which equalizes `a i * h j` and `h i * a j`
have exists_power :
∀ i j : ι, ∃ n : ℕ, a i * h j * (h i * h j) ^ n = h i * a j * (h i * h j) ^ n := by
intro i j
obtain ⟨⟨c, n, rfl⟩, hc⟩ := IsLocalization.eq.mp (fractions_eq i j)
use n + 1
rw [pow_succ]
dsimp at hc
convert hc using 1 <;> ring
let n := fun p : ι × ι => (exists_power p.1 p.2).choose
have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec
-- We need one power `(h i * h j) ^ N` that works for *all* pairs `(i,j)`
-- Since there are only finitely many indices involved, we can pick the supremum.
let N := (t ×ˢ t).sup n
have basic_opens_eq : ∀ i : ι, PrimeSpectrum.basicOpen (h i ^ (N + 1)) =
PrimeSpectrum.basicOpen (h i) := fun i => PrimeSpectrum.basicOpen_pow _ _ (by cutsat)
-- Expanding the fraction `a i / h i` by the power `(h i) ^ n` gives the desired normalization
refine
⟨fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eqToHom (basic_opens_eq i) ≫ iDh i,
?_, ?_, ?_⟩
· simpa only [basic_opens_eq] using h_cover
· intro i hi j hj
-- Here we need to show that our new fractions `a i / h i` satisfy the normalization condition
-- Of course, the power `N` we used to expand the fractions might be bigger than the power
-- `n (i, j)` which was originally chosen. We denote their difference by `k`
have n_le_N : n (i, j) ≤ N := Finset.le_sup (Finset.mem_product.mpr ⟨hi, hj⟩)
obtain ⟨k, hk⟩ := Nat.le.dest n_le_N
simp only [← hk, pow_add, pow_one]
-- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)`
-- by `(h i * h j) ^ k`
convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;>
· simp only [n, mul_pow]; ring
-- Lastly, we need to show that the new fractions still represent our original `s`
intro i _
rw [op_comp, Functor.map_comp, ConcreteCategory.comp_apply, ← hs, res_const]
-- additional goal spit out by `res_const`
swap
· exact (basic_opens_eq i).le
apply const_ext
dsimp
rw [pow_succ]
ring
-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) := by
intro s
-- In this proof, `basicOpen f` will play two distinct roles: Firstly, it is an open set in the
-- prime spectrum. Secondly, it is used as an indexing type for various families of objects
-- (open sets, ring elements, ...). In order to make the distinction clear, we introduce a type
-- alias `ι` that is used whenever we want think of it as an indexing type.
let ι : Type u := PrimeSpectrum.basicOpen f
-- First, we pick some cover of basic opens, on which we can represent `s` as a fraction
choose a' h' iDh' hxDh' s_eq' using locally_const_basicOpen R (PrimeSpectrum.basicOpen f) s
-- Since basic opens are compact, we can pass to a finite subcover
obtain ⟨t, ht_cover'⟩ :=
(PrimeSpectrum.isCompact_basicOpen f).elim_finite_subcover
(fun i : ι => PrimeSpectrum.basicOpen (h' i)) (fun i => PrimeSpectrum.isOpen_basicOpen)
-- Here, we need to show that our basic opens actually form a cover of `basicOpen f`
fun x hx => by rw [Set.mem_iUnion]; exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
simp only [← Opens.coe_iSup, SetLike.coe_subset_coe] at ht_cover'
-- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ :=
normalize_finite_fraction_representation R (PrimeSpectrum.basicOpen f)
s t a' h' iDh' ht_cover' s_eq'
clear s_eq' iDh' hxDh' ht_cover' a' h'
simp only [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover
replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆
⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _) := ht_cover
-- Next we show that some power of `f` is a linear combination of the `h i`
obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by
rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.zeroLocus_span]
simp only [PrimeSpectrum.basicOpen_eq_zeroLocus_compl] at ht_cover
replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆
⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ := ht_cover
rw [Set.compl_subset_comm] at ht_cover
-- Why doesn't `simp_rw` do this?
simp_rw [Set.compl_iUnion, compl_compl, ← PrimeSpectrum.zeroLocus_iUnion,
← Finset.set_biUnion_coe, ← Set.image_eq_iUnion] at ht_cover
apply PrimeSpectrum.vanishingIdeal_anti_mono ht_cover
exact PrimeSpectrum.subset_vanishingIdeal_zeroLocus {f} (Set.mem_singleton f)
replace hn := Ideal.mul_mem_right f _ hn
rw [← pow_succ, Ideal.span, Finsupp.mem_span_image_iff_linearCombination] at hn
rcases hn with ⟨b, b_supp, hb⟩
rw [Finsupp.linearCombination_apply_of_mem_supported R b_supp] at hb
dsimp at hb
-- Finally, we have all the ingredients.
-- We claim that our preimage is given by `(∑ (i : ι) ∈ t, b i * a i) / f ^ (n + 1)`
use
IsLocalization.mk' (Localization.Away f) (∑ i ∈ t, b i * a i)
(⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
rw [toBasicOpen_mk']
-- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-- Annoyingly, `Sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
-- coerce our finset `t` to a type first.
let tt := ((t : Set (PrimeSpectrum.basicOpen f)) : Type u)
apply
(structureSheaf R).eq_of_locally_eq' (fun i : tt => PrimeSpectrum.basicOpen (h i))
(PrimeSpectrum.basicOpen f) fun i : tt => iDh i
· -- This feels a little redundant, since already have `ht_cover` as a hypothesis
-- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the
-- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other
intro x hx
rw [SetLike.mem_coe, TopologicalSpace.Opens.mem_iSup]
have := ht_cover hx
rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
rcases this with ⟨i, i_mem, x_mem⟩
exact ⟨⟨i, i_mem⟩, x_mem⟩
rintro ⟨i, hi⟩
dsimp
change (structureSheaf R).1.map (iDh i).op _ = (structureSheaf R).1.map (iDh i).op _
rw [s_eq i hi, res_const]
-- Again, `res_const` spits out an additional goal
swap
· intro y hy
change y ∈ PrimeSpectrum.basicOpen (f ^ (n + 1))
rw [PrimeSpectrum.basicOpen_pow f (n + 1) (by cutsat)]
exact (leOfHom (iDh i) :) hy
-- The rest of the proof is just computation
apply const_ext
rw [← hb, Finset.sum_mul, Finset.mul_sum]
apply Finset.sum_congr rfl
intro j hj
rw [mul_assoc, ah_ha j hj i hi]
ring
instance isIso_toBasicOpen (f : R) :
IsIso (CommRingCat.ofHom (toBasicOpen R f)) :=
haveI : IsIso ((forget CommRingCat).map (CommRingCat.ofHom (toBasicOpen R f))) :=
(isIso_iff_bijective _).mpr ⟨toBasicOpen_injective R f, toBasicOpen_surjective R f⟩
isIso_of_reflects_iso _ (forget CommRingCat)
/-- The ring isomorphism between the structure sheaf on `basicOpen f` and the localization of `R`
at the submonoid of powers of `f`. -/
def basicOpenIso (f : R) :
(structureSheaf R).1.obj (op (PrimeSpectrum.basicOpen f)) ≅
CommRingCat.of (Localization.Away f) :=
(asIso (CommRingCat.ofHom (toBasicOpen R f))).symm
instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).presheaf.stalk p) :=
(toStalk R p).hom.toAlgebra
@[simp]
theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
algebraMap R ((structureSheaf R).presheaf.stalk p) r = toStalk R p r :=
rfl
/-- Stalk of the structure sheaf at a prime p as localization of R -/
instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
IsLocalization.AtPrime ((structureSheaf R).presheaf.stalk p) p.asIdeal := by
convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.AtPrime p.asIdeal) _
(stalkIso R p).symm.commRingCatIsoToRingEquiv).mp
Localization.isLocalization
apply Algebra.algebra_ext
intro
rw [stalkAlgebra_map]
congr 2
change toStalk R p = _ ≫ (stalkIso R p).inv
rw [Iso.eq_comp_inv]
exact toStalk_comp_stalkToFiberRingHom R p
instance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) :=
(toOpen R (unop U)).hom.toAlgebra
@[simp]
theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :
algebraMap R ((structureSheaf R).val.obj U) r = toOpen R (unop U) r :=
rfl
/-- Sections of the structure sheaf of Spec R on a basic open as localization of R -/
instance IsLocalization.to_basicOpen (r : R) :
IsLocalization.Away r ((structureSheaf R).val.obj (op <| PrimeSpectrum.basicOpen r)) := by
convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.Away r) _
(basicOpenIso R r).symm.commRingCatIsoToRingEquiv).mp
Localization.isLocalization
apply Algebra.algebra_ext
intro x
congr 1
exact (localization_toBasicOpen R r).symm
instance to_basicOpen_epi (r : R) : Epi (toOpen R (PrimeSpectrum.basicOpen r)) :=
⟨fun _ _ h => CommRingCat.hom_ext (IsLocalization.ringHom_ext (Submonoid.powers r)
(CommRingCat.hom_ext_iff.mp h))⟩
@[elementwise]
theorem to_global_factors :
toOpen R ⊤ =
CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) ≫
CommRingCat.ofHom (toBasicOpen R (1 : R)) ≫
(structureSheaf R).1.map (eqToHom PrimeSpectrum.basicOpen_one.symm).op := by
rw [← Category.assoc]
change toOpen R ⊤ =
(CommRingCat.ofHom <| (toBasicOpen R 1).comp (algebraMap R (Localization.Away 1))) ≫
(structureSheaf R).1.map (eqToHom _).op
rw [localization_toBasicOpen R, CommRingCat.ofHom_hom, toOpen_res]
instance isIso_to_global : IsIso (toOpen R ⊤) := by
let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R)))
haveI : IsIso hom :=
(IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingCatIso.isIso_hom
rw [to_global_factors R]
infer_instance
/-- The ring isomorphism between the ring `R` and the global sections `Γ(X, 𝒪ₓ)`. -/
@[simps! inv]
def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :=
asIso (toOpen R ⊤)
@[simp]
theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
rfl
@[simp, reassoc, elementwise nosimp]
theorem toStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
toStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h = toStalk R x := by
dsimp [toStalk]; simp [-toOpen_germ]
@[simp, reassoc, elementwise nosimp]
theorem localizationToStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
(h : x ⤳ y) :
StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h =
CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) ≫
StructureSheaf.localizationToStalk R x := by
ext : 1
apply IsLocalization.ringHom_ext (S := Localization.AtPrime y.asIdeal) y.asIdeal.primeCompl
rw [CommRingCat.hom_comp, RingHom.comp_assoc, CommRingCat.hom_comp, RingHom.comp_assoc]
dsimp [localizationToStalk, PrimeSpectrum.localizationMapOfSpecializes]
rw [IsLocalization.lift_comp, IsLocalization.lift_comp, IsLocalization.lift_comp]
exact CommRingCat.hom_ext_iff.mp (toStalk_stalkSpecializes h)
@[simp, reassoc, elementwise nosimp]
theorem stalkSpecializes_stalk_to_fiber {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
(h : x ⤳ y) :
(structureSheaf R).presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =
StructureSheaf.stalkToFiberRingHom R y ≫
(CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h)) := by
change _ ≫ (StructureSheaf.stalkIso R x).hom = (StructureSheaf.stalkIso R y).hom ≫ _
rw [← Iso.eq_comp_inv, Category.assoc, ← Iso.inv_comp_eq]
exact localizationToStalk_stalkSpecializes h
section Comap
variable {R} {S : Type u} [CommRing S] {P : Type u} [CommRing P]
/--
Given a ring homomorphism `f : R →+* S`, an open set `U` of the prime spectrum of `R` and an open
set `V` of the prime spectrum of `S`, such that `V ⊆ (comap f) ⁻¹' U`, we can push a section `s`
on `U` to a section on `V`, by composing with `Localization.localRingHom _ _ f` from the left and
`comap f` from the right. Explicitly, if `s` evaluates on `comap f p` to `a / b`, its image on `V`
evaluates on `p` to `f(a) / f(b)`.
At the moment, we work with arbitrary dependent functions `s : Π x : U, Localizations R x`. Below,
we prove the predicate `isLocallyFraction` is preserved by this map, hence it can be extended to
a morphism between the structure sheaves of `R` and `S`.
-/
def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
(hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (y : V) :
Localizations S y :=
Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl
(s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ :)
theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
(s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
(isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) := by
rintro ⟨p, hpV⟩
-- Since `s` is locally fraction, we can find a neighborhood `W` of `PrimeSpectrum.comap f p`
-- in `U`, such that `s = a / b` on `W`, for some ring elements `a, b : R`.
rcases hs ⟨PrimeSpectrum.comap f p, hUV hpV⟩ with ⟨W, m, iWU, a, b, h_frac⟩
-- We claim that we can write our new section as the fraction `f a / f b` on the neighborhood
-- `(comap f) ⁻¹ W ⊓ V` of `p`.
refine ⟨Opens.comap (PrimeSpectrum.comap f) W ⊓ V, ⟨m, hpV⟩, Opens.infLERight _ _, f a, f b, ?_⟩
rintro ⟨q, ⟨hqW, hqV⟩⟩
specialize h_frac ⟨PrimeSpectrum.comap f q, hqW⟩
refine ⟨h_frac.1, ?_⟩
dsimp only [comapFun]
erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal _ _ rfl,
← RingHom.map_mul, h_frac.2, Localization.localRingHom_to_map]
rfl
/-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
`S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
at `U` to the structure sheaf of `S` at `V`.
Explicitly, this map is given as follows: For a point `p : V`, if the section `s` evaluates on `p`
to the fraction `a / b`, its image on `V` evaluates on `p` to the fraction `f(a) / f(b)`.
-/
def comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
(hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :
(structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V) where
toFun s := ⟨comapFun f U V hUV s.1, comapFunIsLocallyFraction f U V hUV s.1 s.2⟩
map_one' :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_one, Pi.one_apply, RingHom.map_one]
rfl
map_zero' :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_zero, Pi.zero_apply, RingHom.map_zero]
rfl
map_add' s t :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_add, Pi.add_apply, RingHom.map_add]
rfl
map_mul' s t :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_mul, Pi.mul_apply, RingHom.map_mul]
rfl
@[simp]
theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
(s : (structureSheaf R).1.obj (op U)) (p : V) :
(comap f U V hUV s).1 p =
Localization.localRingHom (PrimeSpectrum.comap f p.1).asIdeal _ f rfl
(s.1 ⟨PrimeSpectrum.comap f p.1, hUV p.2⟩ :) :=
rfl
theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)
(hb : ∀ x : PrimeSpectrum R, x ∈ U → b ∈ x.asIdeal.primeCompl) :
comap f U V hUV (const R a b U hb) =
const S (f a) (f b) V fun p hpV => hb (PrimeSpectrum.comap f p) (hUV hpV) :=
Subtype.eq <|
funext fun p => by
rw [comap_apply, const_apply, const_apply, Localization.localRingHom_mk']
/-- For an inclusion `i : V ⟶ U` between open sets of the prime spectrum of `R`, the comap of the
identity from OO_X(U) to OO_X(V) equals as the restriction map of the structure sheaf.
This is a generalization of the fact that, for fixed `U`, the comap of the identity from OO_X(U)
to OO_X(U) is the identity.
-/
theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
(comap (RingHom.id R) U V fun _ hpV => leOfHom iVU <| hpV) =
((structureSheaf R).1.map iVU.op).hom :=
RingHom.ext fun s => Subtype.eq <| funext fun p => by
rw [comap_apply]
-- Unfortunately, we cannot use `Localization.localRingHom_id` here, because
-- `PrimeSpectrum.comap (RingHom.id R) p` is not *definitionally* equal to `p`. Instead, we use
-- that we can write `s` as a fraction `a/b` in a small neighborhood around `p`. Since
-- `PrimeSpectrum.comap (RingHom.id R) p` equals `p`, it is also contained in the same
-- neighborhood, hence `s` equals `a/b` there too.
obtain ⟨W, hpW, iWU, h⟩ := s.2 (iVU p)
obtain ⟨a, b, h'⟩ := h.eq_mk'
obtain ⟨hb₁, s_eq₁⟩ := h' ⟨p, hpW⟩
obtain ⟨hb₂, s_eq₂⟩ :=
h' ⟨PrimeSpectrum.comap (RingHom.id _) p.1, hpW⟩
dsimp only at s_eq₁ s_eq₂
erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply _ _ _ iVU]
/--
The comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and
`V` are given as arguments, together with a proof that `U = V`. This is useful when `U` and `V`
are not definitionally equal.
-/
theorem comap_id {U V : Opens (PrimeSpectrum.Top R)} (hUV : U = V) :
(comap (RingHom.id R) U V fun p hpV => by rwa [hUV, PrimeSpectrum.comap_id]) =
(eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV])).hom := by
rw [comap_id_eq_map U V (eqToHom hUV.symm), eqToHom_op, eqToHom_map]
@[simp]
theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
(comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
rw [comap_id rfl]; rfl
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
(hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
(comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
(comap g V W hVW).comp (comap f U V hUV) :=
RingHom.ext fun s =>
Subtype.eq <|
funext fun p => by
rw [comap_apply, Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal] <;>
simp
@[elementwise, reassoc]
theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) :
(toOpen R U ≫ CommRingCat.ofHom (comap f U (Opens.comap (PrimeSpectrum.comap f) U)
fun _ => id)) =
CommRingCat.ofHom f ≫ toOpen S _ :=
CommRingCat.hom_ext <| RingHom.ext fun _ => Subtype.eq <| funext fun _ =>
Localization.localRingHom_to_map _ _ _ _ _
lemma comap_basicOpen (f : R →+* S) (x : R) :
comap f (PrimeSpectrum.basicOpen x) (PrimeSpectrum.basicOpen (f x))
(PrimeSpectrum.comap_basicOpen f x).le =
IsLocalization.map (M := .powers x) (T := .powers (f x)) _ f
(Submonoid.powers_le.mpr (Submonoid.mem_powers _)) :=
IsLocalization.ringHom_ext (.powers x) <| by
simpa [CommRingCat.hom_ext_iff] using toOpen_comp_comap f _
end Comap
end StructureSheaf
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/PullbackCarrier.lean | import Mathlib.Algebra.Category.Ring.LinearAlgebra
import Mathlib.AlgebraicGeometry.ResidueField
/-!
# Underlying topological space of fibre product of schemes
Let `f : X ⟶ S` and `g : Y ⟶ S` be morphisms of schemes. In this file we describe the underlying
topological space of `pullback f g`, i.e. the fiber product `X ×[S] Y`.
## Main results
- `AlgebraicGeometry.Scheme.Pullback.carrierEquiv`: The bijective correspondence between the points
of `X ×[S] Y` and pairs `(z, p)` of triples `z = (x, y, s)` with `f x = s = g y` and
prime ideals `q` of `κ(x) ⊗[κ(s)] κ(y)`.
- `AlgebraicGeometry.Scheme.Pullback.exists_preimage`: For every triple `(x, y, s)` with
`f x = s = g y`, there exists `z : X ×[S] Y` lying above `x` and `y`.
We also give the ranges of `pullback.fst`, `pullback.snd` and `pullback.map`.
-/
open CategoryTheory Limits TopologicalSpace IsLocalRing TensorProduct
noncomputable section
universe u
namespace AlgebraicGeometry.Scheme.Pullback
/-- A `Triplet` over `f : X ⟶ S` and `g : Y ⟶ S` is a triple of points `x : X`, `y : Y`,
`s : S` such that `f x = s = f y`. -/
structure Triplet {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) where
/-- The point of `X`. -/
x : X
/-- The point of `Y`. -/
y : Y
/-- The point of `S` below `x` and `y`. -/
s : S
hx : f x = s
hy : g y = s
variable {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S}
namespace Triplet
@[ext]
protected lemma ext {t₁ t₂ : Triplet f g} (ex : t₁.x = t₂.x) (ey : t₁.y = t₂.y) : t₁ = t₂ := by
cases t₁; cases t₂; simp; aesop
/-- Make a triplet from `x : X` and `y : Y` such that `f x = g y`. -/
@[simps]
def mk' (x : X) (y : Y) (h : f x = g y) : Triplet f g where
x := x
y := y
s := g y
hx := h
hy := rfl
/-- Given `x : X` and `y : Y` such that `f x = s = g y`, this is `κ(x) ⊗[κ(s)] κ(y)`. -/
def tensor (T : Triplet f g) : CommRingCat :=
pushout ((S.residueFieldCongr T.hx).inv ≫ f.residueFieldMap T.x)
((S.residueFieldCongr T.hy).inv ≫ g.residueFieldMap T.y)
instance (T : Triplet f g) : Nontrivial T.tensor :=
CommRingCat.nontrivial_of_isPushout_of_isField (Field.toIsField _)
(IsPushout.of_hasPushout _ _)
/-- Given `x : X` and `y : Y` such that `f x = s = g y`, this is the
canonical map `κ(x) ⟶ κ(x) ⊗[κ(s)] κ(y)`. -/
def tensorInl (T : Triplet f g) : X.residueField T.x ⟶ T.tensor := pushout.inl _ _
/-- Given `x : X` and `y : Y` such that `f x = s = g y`, this is the
canonical map `κ(y) ⟶ κ(x) ⊗[κ(s)] κ(y)`. -/
def tensorInr (T : Triplet f g) : Y.residueField T.y ⟶ T.tensor := pushout.inr _ _
lemma isPullback_SpecMap_tensor (T : Triplet f g) : CategoryTheory.IsPullback
(Spec.map T.tensorInl) (Spec.map T.tensorInr)
(Spec.map ((S.residueFieldCongr T.hx).inv ≫ f.residueFieldMap T.x))
(Spec.map ((S.residueFieldCongr T.hy).inv ≫ g.residueFieldMap T.y)) :=
isPullback_SpecMap_pushout _ _
@[deprecated (since := "2025-10-07")] alias Spec_map_tensor_isPullback := isPullback_SpecMap_tensor
section Congr
/-- Given propositionally equal triplets `T₁` and `T₂` over `f` and `g`, the corresponding
`T₁.tensor` and `T₂.tensor` are isomorphic. -/
def tensorCongr {T₁ T₂ : Triplet f g} (e : T₁ = T₂) :
T₁.tensor ≅ T₂.tensor :=
eqToIso (by subst e; rfl)
@[simp]
lemma tensorCongr_refl {x : Triplet f g} :
tensorCongr (refl x) = Iso.refl _ := rfl
@[simp]
lemma tensorCongr_symm {x y : Triplet f g} (e : x = y) :
(tensorCongr e).symm = tensorCongr e.symm := rfl
@[simp]
lemma tensorCongr_inv {x y : Triplet f g} (e : x = y) :
(tensorCongr e).inv = (tensorCongr e.symm).hom := rfl
@[simp]
lemma tensorCongr_trans {x y z : Triplet f g} (e : x = y) (e' : y = z) :
tensorCongr e ≪≫ tensorCongr e' =
tensorCongr (e.trans e') := by
subst e e'
rfl
@[reassoc (attr := simp)]
lemma tensorCongr_trans_hom {x y z : Triplet f g} (e : x = y) (e' : y = z) :
(tensorCongr e).hom ≫ (tensorCongr e').hom =
(tensorCongr (e.trans e')).hom := by
subst e e'
rfl
end Congr
variable (T : Triplet f g)
lemma SpecMap_tensorInl_fromSpecResidueField :
(Spec.map T.tensorInl ≫ X.fromSpecResidueField T.x) ≫ f =
(Spec.map T.tensorInr ≫ Y.fromSpecResidueField T.y) ≫ g := by
simp only [residueFieldCongr_inv, Category.assoc, tensorInl, tensorInr,
← Hom.SpecMap_residueFieldMap_fromSpecResidueField]
rw [← residueFieldCongr_fromSpecResidueField T.hx.symm,
← residueFieldCongr_fromSpecResidueField T.hy.symm]
simp only [← Category.assoc, ← Spec.map_comp, pushout.condition]
@[deprecated (since := "2025-10-07")]
alias Spec_map_tensorInl_fromSpecResidueField := SpecMap_tensorInl_fromSpecResidueField
/-- Given `x : X`, `y : Y` and `s : S` such that `f x = s = g y`,
this is `Spec (κ(x) ⊗[κ(s)] κ(y)) ⟶ X ×ₛ Y`. -/
def SpecTensorTo : Spec T.tensor ⟶ pullback f g :=
pullback.lift (Spec.map T.tensorInl ≫ X.fromSpecResidueField T.x)
(Spec.map T.tensorInr ≫ Y.fromSpecResidueField T.y)
(SpecMap_tensorInl_fromSpecResidueField _)
@[simp]
lemma fst_SpecTensorTo_apply (p : Spec T.tensor) :
pullback.fst f g (T.SpecTensorTo p) = T.x := by
simp only [SpecTensorTo]
rw [← Scheme.Hom.comp_apply]
simp
@[deprecated (since := "2025-10-11")] alias specTensorTo_base_fst := fst_SpecTensorTo_apply
@[simp]
lemma snd_SpecTensorTo_apply (p : Spec T.tensor) :
pullback.snd f g (T.SpecTensorTo p) = T.y := by
simp only [SpecTensorTo]
rw [← Scheme.Hom.comp_apply]
simp
@[deprecated (since := "2025-10-11")] alias specTensorTo_base_snd := snd_SpecTensorTo_apply
@[reassoc (attr := simp)]
lemma specTensorTo_fst :
T.SpecTensorTo ≫ pullback.fst f g = Spec.map T.tensorInl ≫ X.fromSpecResidueField T.x :=
pullback.lift_fst _ _ _
@[reassoc (attr := simp)]
lemma specTensorTo_snd :
T.SpecTensorTo ≫ pullback.snd f g = Spec.map T.tensorInr ≫ Y.fromSpecResidueField T.y :=
pullback.lift_snd _ _ _
/-- Given `t : X ×[S] Y`, it maps to `X` and `Y` with same image in `S`, yielding a
`Triplet f g`. -/
@[simps]
def ofPoint (t : ↑(pullback f g)) : Triplet f g :=
⟨pullback.fst f g t, pullback.snd f g t, _, rfl,
congr($(pullback.condition (f := f) (g := g)) t).symm⟩
@[simp]
lemma ofPoint_SpecTensorTo (T : Triplet f g) (p : Spec T.tensor) :
ofPoint (T.SpecTensorTo p) = T := by
ext <;> simp
end Triplet
lemma residueFieldCongr_inv_residueFieldMap_ofPoint (t : ↑(pullback f g)) :
((S.residueFieldCongr (Triplet.ofPoint t).hx).inv ≫ f.residueFieldMap (Triplet.ofPoint t).x) ≫
(pullback.fst f g).residueFieldMap t = ((S.residueFieldCongr (Triplet.ofPoint t).hy).inv ≫
g.residueFieldMap (Triplet.ofPoint t).y) ≫ (pullback.snd f g).residueFieldMap t := by
simp [← residueFieldMap_comp, Scheme.Hom.residueFieldMap_congr pullback.condition]
/-- Given `t : X ×[S] Y` with projections to `X`, `Y` and `S` denoted by `x`, `y` and `s`
respectively, this is the canonical map `κ(x) ⊗[κ(s)] κ(y) ⟶ κ(t)`. -/
def ofPointTensor (t : ↑(pullback f g)) :
(Triplet.ofPoint t).tensor ⟶ (pullback f g).residueField t :=
pushout.desc
((pullback.fst f g).residueFieldMap t)
((pullback.snd f g).residueFieldMap t)
(residueFieldCongr_inv_residueFieldMap_ofPoint t)
@[reassoc]
lemma ofPointTensor_SpecTensorTo (t : ↑(pullback f g)) :
Spec.map (ofPointTensor t) ≫ (Triplet.ofPoint t).SpecTensorTo =
(pullback f g).fromSpecResidueField t := by
apply pullback.hom_ext
· rw [← Scheme.Hom.SpecMap_residueFieldMap_fromSpecResidueField]
simp only [Category.assoc, Triplet.specTensorTo_fst, Triplet.ofPoint_x]
rw [← pushout.inl_desc _ _ (residueFieldCongr_inv_residueFieldMap_ofPoint t), Spec.map_comp]
rfl
· rw [← Scheme.Hom.SpecMap_residueFieldMap_fromSpecResidueField]
simp only [Category.assoc, Triplet.specTensorTo_snd, Triplet.ofPoint_y]
rw [← pushout.inr_desc _ _ (residueFieldCongr_inv_residueFieldMap_ofPoint t), Spec.map_comp]
rfl
/-- If `t` is a point in `X ×[S] Y` above `(x, y, s)`, then this is the image of the unique
point of `Spec κ(s)` in `Spec κ(x) ⊗[κ(s)] κ(y)`. -/
def SpecOfPoint (t : ↑(pullback f g)) : Spec (Triplet.ofPoint t).tensor :=
Spec.map (ofPointTensor t) (⊥ : PrimeSpectrum _)
@[simp]
lemma SpecTensorTo_SpecOfPoint (t : ↑(pullback f g)) :
(Triplet.ofPoint t).SpecTensorTo (SpecOfPoint t) = t := by
simp [SpecOfPoint, ← Scheme.Hom.comp_apply, ofPointTensor_SpecTensorTo]
@[reassoc (attr := simp)]
lemma tensorCongr_SpecTensorTo {T T' : Triplet f g} (h : T = T') :
Spec.map (Triplet.tensorCongr h).hom ≫ T.SpecTensorTo = T'.SpecTensorTo := by
subst h
simp only [Triplet.tensorCongr_refl, Iso.refl_hom, Spec.map_id, Category.id_comp]
lemma Triplet.Spec_ofPointTensor_SpecTensorTo (T : Triplet f g) (p : Spec T.tensor) :
Spec.map (Hom.residueFieldMap T.SpecTensorTo p) ≫
Spec.map (ofPointTensor (T.SpecTensorTo p)) ≫
Spec.map (tensorCongr (T.ofPoint_SpecTensorTo p).symm).hom =
(Spec T.tensor).fromSpecResidueField p := by
apply T.isPullback_SpecMap_tensor.hom_ext
· rw [← cancel_mono <| X.fromSpecResidueField T.x]
simp_rw [Category.assoc, ← T.specTensorTo_fst, tensorCongr_SpecTensorTo_assoc]
rw [← Hom.SpecMap_residueFieldMap_fromSpecResidueField_assoc, ofPointTensor_SpecTensorTo_assoc]
· rw [← cancel_mono <| Y.fromSpecResidueField T.y]
simp_rw [Category.assoc, ← T.specTensorTo_snd, tensorCongr_SpecTensorTo_assoc]
rw [← Hom.SpecMap_residueFieldMap_fromSpecResidueField_assoc, ofPointTensor_SpecTensorTo_assoc]
/-- A helper lemma to work with `AlgebraicGeometry.Scheme.Pullback.carrierEquiv`. -/
lemma carrierEquiv_eq_iff {T₁ T₂ : Σ T : Triplet f g, Spec T.tensor} :
T₁ = T₂ ↔ ∃ e : T₁.1 = T₂.1, Spec.map (Triplet.tensorCongr e).inv T₁.2 = T₂.2 := by
constructor
· rintro rfl
simp
· obtain ⟨T, _⟩ := T₁
obtain ⟨T', _⟩ := T₂
rintro ⟨rfl : T = T', e⟩
simpa [e]
/--
The points of the underlying topological space of `X ×[S] Y` bijectively correspond to
pairs of triples `x : X`, `y : Y`, `s : S` with `f x = s = f y` and prime ideals of
`κ(x) ⊗[κ(s)] κ(y)`.
-/
def carrierEquiv : ↑(pullback f g) ≃ Σ T : Triplet f g, Spec T.tensor where
toFun t := ⟨.ofPoint t, SpecOfPoint t⟩
invFun T := T.1.SpecTensorTo T.2
left_inv := SpecTensorTo_SpecOfPoint
right_inv := by
intro ⟨T, p⟩
apply carrierEquiv_eq_iff.mpr
use T.ofPoint_SpecTensorTo p
have : Spec.map (Hom.residueFieldMap T.SpecTensorTo p) (⊥ : PrimeSpectrum _) =
(⊥ : PrimeSpectrum _) :=
(PrimeSpectrum.instUnique).uniq _
simp only [SpecOfPoint, Triplet.tensorCongr_inv, ← this, ← Scheme.Hom.comp_apply,
← Scheme.Hom.comp_apply]
simp [Triplet.Spec_ofPointTensor_SpecTensorTo]
@[simp]
lemma carrierEquiv_symm_fst (T : Triplet f g) (p : Spec T.tensor) :
pullback.fst f g (carrierEquiv.symm ⟨T, p⟩) = T.x := by
simp [carrierEquiv]
@[simp]
lemma carrierEquiv_symm_snd (T : Triplet f g) (p : Spec T.tensor) :
pullback.snd f g (carrierEquiv.symm ⟨T, p⟩) = T.y := by
simp [carrierEquiv]
/-- Given a triple `(x, y, s)` with `f x = s = f y` there exists `t : X ×[S] Y` above
`x` and `ỳ`. For the unpacked version without `Triplet`, see
`AlgebraicGeometry.Scheme.Pullback.exists_preimage`. -/
lemma Triplet.exists_preimage (T : Triplet f g) :
∃ t : ↑(pullback f g), pullback.fst f g t = T.x ∧ pullback.snd f g t = T.y :=
⟨carrierEquiv.symm ⟨T, Nonempty.some inferInstance⟩, by simp⟩
/--
If `f : X ⟶ S` and `g : Y ⟶ S` are morphisms of schemes and `x : X` and `y : Y` are points such
that `f x = g y`, then there exists `z : X ×[S] Y` lying above `x` and `y`.
In other words, the map from the underlying topological space of `X ×[S] Y` to the fiber product
of the underlying topological spaces of `X` and `Y` over `S` is surjective.
-/
lemma exists_preimage_pullback (x : X) (y : Y) (h : f x = g y) :
∃ z : ↑(pullback f g), pullback.fst f g z = x ∧ pullback.snd f g z = y :=
(Pullback.Triplet.mk' x y h).exists_preimage
lemma _root_.AlgebraicGeometry.Scheme.isEmpty_pullback_iff {f : X ⟶ S} {g : Y ⟶ S} :
IsEmpty ↑(Limits.pullback f g) ↔ Disjoint (Set.range f) (Set.range g) := by
refine ⟨?_, Scheme.isEmpty_pullback f g⟩
rw [Set.disjoint_iff_forall_ne]
contrapose!
rintro ⟨_, ⟨x, rfl⟩, _, ⟨y, rfl⟩, e⟩
obtain ⟨z, -⟩ := exists_preimage_pullback x y e
exact ⟨z⟩
variable (f g)
lemma range_fst : Set.range (pullback.fst f g) = f ⁻¹' Set.range g := by
ext x
refine ⟨?_, fun ⟨y, hy⟩ ↦ ?_⟩
· rintro ⟨a, rfl⟩
simp only [Set.mem_preimage, Set.mem_range, ← Scheme.Hom.comp_apply, pullback.condition]
simp
· obtain ⟨a, ha⟩ := Triplet.exists_preimage (Triplet.mk' x y hy.symm)
use a, ha.left
lemma range_snd : Set.range (pullback.snd f g) = g ⁻¹' Set.range f := by
ext x
refine ⟨?_, fun ⟨y, hy⟩ ↦ ?_⟩
· rintro ⟨a, rfl⟩
simp only [Set.mem_preimage, Set.mem_range, ← Scheme.Hom.comp_apply, ← pullback.condition]
simp
· obtain ⟨a, ha⟩ := Triplet.exists_preimage (Triplet.mk' y x hy)
use a, ha.right
lemma range_fst_comp :
Set.range (pullback.fst f g ≫ f) = Set.range f ∩ Set.range g := by
simp [Set.range_comp, range_fst, Set.image_preimage_eq_range_inter]
lemma range_snd_comp :
Set.range (pullback.snd f g ≫ g) = Set.range f ∩ Set.range g := by
rw [← pullback.condition, range_fst_comp]
lemma range_map {X' Y' S' : Scheme.{u}} (f' : X' ⟶ S') (g' : Y' ⟶ S') (i₁ : X ⟶ X')
(i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f')
(e₂ : g ≫ i₃ = i₂ ≫ g') [Mono i₃] :
Set.range (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) =
pullback.fst f' g' ⁻¹' Set.range i₁ ∩ pullback.snd f' g' ⁻¹' Set.range i₂ := by
ext z
constructor
· rintro ⟨t, rfl⟩
constructor
· use pullback.fst f g t
rw [← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply]
simp
· use pullback.snd f g t
rw [← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply]
simp
· intro ⟨⟨x, hx⟩, ⟨y, hy⟩⟩
let T₁ : Triplet (pullback.fst f' g') i₁ := Triplet.mk' z x hx.symm
obtain ⟨w₁, hw₁⟩ := T₁.exists_preimage
let T₂ : Triplet (pullback.snd f' g') i₂ := Triplet.mk' z y hy.symm
obtain ⟨w₂, hw₂⟩ := T₂.exists_preimage
let T : Triplet (pullback.fst (pullback.fst f' g') i₁) (pullback.fst (pullback.snd f' g') i₂) :=
Triplet.mk' w₁ w₂ <| by simp [hw₁.left, hw₂.left, T₁, T₂]
obtain ⟨t, _, ht₂⟩ := T.exists_preimage
use (pullbackFstFstIso f g f' g' i₁ i₂ i₃ e₁ e₂).hom t
rw [pullback_map_eq_pullbackFstFstIso_inv, ← Scheme.Hom.comp_apply, Iso.hom_inv_id_assoc]
simp [ht₂, T, hw₂.left, T₂]
end Pullback
instance isJointlySurjectivePreserving (P : MorphismProperty Scheme.{u}) :
IsJointlySurjectivePreserving P where
exists_preimage_fst_triplet_of_prop {X Y S} f g _ hg x y hxy := by
obtain ⟨a, b, h⟩ := Pullback.exists_preimage_pullback x y hxy
use a
/-- The comparison map for pullbacks under the forgetful functor `Scheme ⥤ Type u` is surjective. -/
lemma pullbackComparison_forget_surjective {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) :
Function.Surjective (pullbackComparison forget f g) := by
refine .of_comp_left (fun x ↦ ?_) <|
injective_of_mono (Types.pullbackIsoPullback (forget.map f) (forget.map g)).hom
obtain ⟨z, h1, h2⟩ := Pullback.exists_preimage_pullback (f := f) (g := g) x.1.1 x.1.2 x.2
use z
ext
· simp only [Function.comp_apply, Types.pullbackIsoPullback_hom_fst]
rwa [← types_comp_apply (g := pullback.fst _ _), pullbackComparison_comp_fst]
· simp only [Function.comp_apply, Types.pullbackIsoPullback_hom_snd]
rwa [← types_comp_apply (g := pullback.snd _ _), pullbackComparison_comp_snd]
@[deprecated (since := "2025-10-06")]
alias Pullback.forget_comparison_surjective := pullbackComparison_forget_surjective
end Scheme
namespace Surjective
instance : MorphismProperty.IsStableUnderBaseChange @Surjective := by
refine .mk' ?_
introv hg
simp only [surjective_iff, ← Set.range_eq_univ, Scheme.Pullback.range_fst] at hg ⊢
rw [hg, Set.preimage_univ]
instance {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) [Surjective g] :
Surjective (pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ inferInstance
instance {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) [Surjective f] :
Surjective (pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ inferInstance
end AlgebraicGeometry.Surjective |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ValuativeCriterion.lean | import Mathlib.AlgebraicGeometry.Morphisms.Immersion
import Mathlib.AlgebraicGeometry.Morphisms.Proper
import Mathlib.RingTheory.RingHom.Injective
import Mathlib.RingTheory.Valuation.LocalSubring
/-!
# Valuative criterion
## Main results
- `AlgebraicGeometry.UniversallyClosed.eq_valuativeCriterion`:
A morphism is universally closed if and only if
it is quasi-compact and satisfies the existence part of the valuative criterion.
- `AlgebraicGeometry.IsSeparated.eq_valuativeCriterion`:
A morphism is separated if and only if
it is quasi-separated and satisfies the uniqueness part of the valuative criterion.
- `AlgebraicGeometry.IsProper.eq_valuativeCriterion`:
A morphism is proper if and only if
it is qcqs and of finite type and satisfies the valuative criterion.
## Future projects
Show that it suffices to check discrete valuation rings when the base is Noetherian.
-/
open CategoryTheory CategoryTheory.Limits
namespace AlgebraicGeometry
universe u
/--
A valuative commutative square over a morphism `f : X ⟶ Y` is a square
```
Spec K ⟶ Y
| |
↓ ↓
Spec R ⟶ X
```
where `R` is a valuation ring, and `K` is its ring of fractions.
We are interested in finding lifts `Spec R ⟶ Y` of this diagram.
-/
structure ValuativeCommSq {X Y : Scheme.{u}} (f : X ⟶ Y) where
/-- The valuation ring of a valuative commutative square. -/
R : Type u
[commRing : CommRing R]
[domain : IsDomain R]
[valuationRing : ValuationRing R]
/-- The field of fractions of a valuative commutative square. -/
K : Type u
[field : Field K]
[algebra : Algebra R K]
[isFractionRing : IsFractionRing R K]
/-- The top map in a valuative commutative map. -/
(i₁ : Spec (.of K) ⟶ X)
/-- The bottom map in a valuative commutative map. -/
(i₂ : Spec (.of R) ⟶ Y)
(commSq : CommSq i₁ (Spec.map (CommRingCat.ofHom (algebraMap R K))) f i₂)
namespace ValuativeCommSq
attribute [instance] commRing domain valuationRing field algebra isFractionRing
end ValuativeCommSq
/-- A morphism `f : X ⟶ Y` satisfies the existence part of the valuative criterion if
every valuative commutative square over `f` has (at least) a lift. -/
def ValuativeCriterion.Existence : MorphismProperty Scheme :=
fun _ _ f ↦ ∀ S : ValuativeCommSq f, S.commSq.HasLift
/-- A morphism `f : X ⟶ Y` satisfies the uniqueness part of the valuative criterion if
every valuative commutative square over `f` has at most one lift. -/
def ValuativeCriterion.Uniqueness : MorphismProperty Scheme :=
fun _ _ f ↦ ∀ S : ValuativeCommSq f, Subsingleton S.commSq.LiftStruct
/-- A morphism `f : X ⟶ Y` satisfies the valuative criterion if
every valuative commutative square over `f` has a unique lift. -/
def ValuativeCriterion : MorphismProperty Scheme :=
fun _ _ f ↦ ∀ S : ValuativeCommSq f, Nonempty (Unique (S.commSq.LiftStruct))
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
lemma ValuativeCriterion.iff {f : X ⟶ Y} :
ValuativeCriterion f ↔ Existence f ∧ Uniqueness f := by
change (∀ _, _) ↔ (∀ _, _) ∧ (∀ _, _)
simp_rw [← forall_and, unique_iff_subsingleton_and_nonempty, and_comm, CommSq.HasLift.iff]
lemma ValuativeCriterion.eq :
ValuativeCriterion = Existence ⊓ Uniqueness := by
ext X Y f
exact iff
lemma ValuativeCriterion.existence {f : X ⟶ Y} (h : ValuativeCriterion f) :
ValuativeCriterion.Existence f := (iff.mp h).1
lemma ValuativeCriterion.uniqueness {f : X ⟶ Y} (h : ValuativeCriterion f) :
ValuativeCriterion.Uniqueness f := (iff.mp h).2
namespace ValuativeCriterion.Existence
open IsLocalRing
@[stacks 01KE]
lemma specializingMap (H : ValuativeCriterion.Existence f) :
SpecializingMap f := by
intro x' y h
let stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
Y.presheaf.stalkSpecializes h ≫ f.stalkMap x' ≫ X.residue x'
obtain ⟨A, hA, hA_local⟩ := exists_factor_valuationRing stalk_y_to_residue_x'.hom
let stalk_y_to_A : Y.presheaf.stalk y ⟶ .of A :=
CommRingCat.ofHom (stalk_y_to_residue_x'.hom.codRestrict _ hA)
have w : X.fromSpecResidueField x' ≫ f =
Spec.map (CommRingCat.ofHom (algebraMap A (X.residueField x'))) ≫
Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y := by
rw [Scheme.fromSpecResidueField, Category.assoc, ← Scheme.SpecMap_stalkMap_fromSpecStalk,
← Scheme.SpecMap_stalkSpecializes_fromSpecStalk h]
simp_rw [← Spec.map_comp_assoc]
rfl
obtain ⟨l, hl₁, hl₂⟩ := (H { R := A, K := X.residueField x', commSq := ⟨w⟩, .. }).exists_lift
dsimp only at hl₁ hl₂
refine ⟨l (closedPoint A), ?_, ?_⟩
· simp_rw [← Scheme.fromSpecResidueField_apply x' (closedPoint (X.residueField x')), ← hl₁]
exact (specializes_closedPoint _).map l.continuous
· rw [← Scheme.Hom.comp_apply, hl₂]
simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Function.comp_apply]
have : Spec.map stalk_y_to_A (closedPoint A) = closedPoint (Y.presheaf.stalk y) :=
comap_closedPoint (S := A) (stalk_y_to_residue_x'.hom.codRestrict A.toSubring hA)
rw [this, Y.fromSpecStalk_closedPoint]
instance {R S : CommRingCat} (e : R ≅ S) : IsLocalHom e.hom.hom :=
isLocalHom_of_isIso _
lemma of_specializingMap (H : (topologically @SpecializingMap).universally f) :
ValuativeCriterion.Existence f := by
rintro ⟨R, K, i₁, i₂, ⟨w⟩⟩
haveI : IsDomain (CommRingCat.of R) := ‹_›
haveI : ValuationRing (CommRingCat.of R) := ‹_›
letI : Field (CommRingCat.of K) := ‹_›
replace H := H (pullback.snd i₂ f) i₂ (pullback.fst i₂ f) (.of_hasPullback i₂ f)
let lft := pullback.lift (Spec.map (CommRingCat.ofHom (algebraMap R K))) i₁ w.symm
obtain ⟨x, h₁, h₂⟩ := @H (lft (closedPoint _)) _ (specializes_closedPoint (R := R) _)
let e : CommRingCat.of R ≅ (Spec <| .of R).presheaf.stalk (pullback.fst i₂ f x) :=
(stalkClosedPointIso (.of R)).symm ≪≫
(Spec <| .of R).presheaf.stalkCongr (.of_eq h₂.symm)
let α := e.hom ≫ (pullback.fst i₂ f).stalkMap x
have : IsLocalHom e.hom.hom := isLocalHom_of_isIso e.hom
have : IsLocalHom α.hom := inferInstanceAs
(IsLocalHom (((pullback.fst i₂ f).stalkMap x).hom.comp e.hom.hom))
let β := (pullback i₂ f).presheaf.stalkSpecializes h₁ ≫ Scheme.stalkClosedPointTo lft
have hαβ : α ≫ β = CommRingCat.ofHom (algebraMap R K) := by
simp only [CommRingCat.coe_of, Iso.trans_hom, Iso.symm_hom, TopCat.Presheaf.stalkCongr_hom,
Category.assoc, α, e, β, stalkClosedPointIso_inv, StructureSheaf.toStalk]
change (Scheme.ΓSpecIso (.of R)).inv ≫ (Spec <| .of R).presheaf.germ _ _ _ ≫ _ = _
simp only [TopCat.Presheaf.germ_stalkSpecializes_assoc, Scheme.Hom.germ_stalkMap_assoc]
-- `map_top` introduces defeq problems, according to `check_compositions`.
-- This is probably the cause of the `erw` needed below.
simp only [TopologicalSpace.Opens.map_top]
rw [Scheme.germ_stalkClosedPointTo lft ⊤ trivial]
erw [← Scheme.Hom.comp_app_assoc lft (pullback.fst i₂ f)]
rw [pullback.lift_fst]
simp
have hbij := (bijective_rangeRestrict_comp_of_valuationRing (R := R) (K := K) α.hom β.hom
(CommRingCat.hom_ext_iff.mp hαβ))
let φ : (pullback i₂ f).presheaf.stalk x ⟶ CommRingCat.of R := CommRingCat.ofHom <|
(RingEquiv.ofBijective _ hbij).symm.toRingHom.comp β.hom.rangeRestrict
have hαφ : α ≫ φ = 𝟙 _ := by ext x; exact (RingEquiv.ofBijective _ hbij).symm_apply_apply x
have hαφ' : (pullback.fst i₂ f).stalkMap x ≫ φ = e.inv := by
rw [← cancel_epi e.hom, ← Category.assoc, hαφ, e.hom_inv_id]
have hφβ : φ ≫ CommRingCat.ofHom (algebraMap R K) = β :=
hαβ ▸ CommRingCat.hom_ext (RingHom.ext fun x ↦ congr_arg Subtype.val
((RingEquiv.ofBijective _ hbij).apply_symm_apply (β.hom.rangeRestrict x)))
refine ⟨⟨⟨Spec.map ((pullback.snd i₂ f).stalkMap x ≫ φ) ≫ X.fromSpecStalk _, ?_, ?_⟩⟩⟩
· simp only [← Spec.map_comp_assoc, Category.assoc, hφβ]
simp only [Spec.map_comp, Category.assoc, Scheme.SpecMap_stalkMap_fromSpecStalk,
Scheme.SpecMap_stalkSpecializes_fromSpecStalk_assoc, β]
-- This next line only fires as `rw`, not `simp`:
rw [Scheme.Spec_stalkClosedPointTo_fromSpecStalk_assoc]
simp [lft]
· simp only [Spec.map_comp, Category.assoc, Scheme.SpecMap_stalkMap_fromSpecStalk,
← pullback.condition]
rw [← Scheme.SpecMap_stalkMap_fromSpecStalk_assoc, ← Spec.map_comp_assoc, hαφ']
simp only [Iso.trans_inv, TopCat.Presheaf.stalkCongr_inv, Iso.symm_inv, Spec.map_comp,
Category.assoc, Scheme.SpecMap_stalkSpecializes_fromSpecStalk_assoc, e]
rw [← Spec_stalkClosedPointIso, ← Spec.map_comp_assoc,
Iso.inv_hom_id, Spec.map_id, Category.id_comp]
instance stableUnderBaseChange : ValuativeCriterion.Existence.IsStableUnderBaseChange := by
constructor
intro Y' X X' Y Y'_to_Y f X'_to_X f' hP hf commSq
let commSq' : ValuativeCommSq f :=
{ R := commSq.R
K := commSq.K
i₁ := commSq.i₁ ≫ X'_to_X
i₂ := commSq.i₂ ≫ Y'_to_Y
commSq := ⟨by simp only [Category.assoc, hP.w, reassoc_of% commSq.commSq.w]⟩ }
obtain ⟨l₀, hl₁, hl₂⟩ := (hf commSq').exists_lift
refine ⟨⟨⟨hP.lift l₀ commSq.i₂ (by simp_all only [commSq']), ?_, hP.lift_snd _ _ _⟩⟩⟩
apply hP.hom_ext
· simpa
· simp only [Category.assoc]
rw [hP.lift_snd]
rw [commSq.commSq.w]
@[stacks 01KE]
protected lemma eq :
ValuativeCriterion.Existence = (topologically @SpecializingMap).universally := by
ext
constructor
· intro _
apply MorphismProperty.universally_mono
· apply specializingMap
· rwa [MorphismProperty.IsStableUnderBaseChange.universally_eq]
· apply of_specializingMap
end ValuativeCriterion.Existence
/-- The **valuative criterion** for universally closed morphisms. -/
@[stacks 01KF]
lemma UniversallyClosed.eq_valuativeCriterion :
@UniversallyClosed = ValuativeCriterion.Existence ⊓ @QuasiCompact := by
rw [universallyClosed_eq_universallySpecializing, ValuativeCriterion.Existence.eq]
/-- The **valuative criterion** for universally closed morphisms. -/
@[stacks 01KF]
lemma UniversallyClosed.of_valuativeCriterion [QuasiCompact f]
(hf : ValuativeCriterion.Existence f) : UniversallyClosed f := by
rw [eq_valuativeCriterion]
exact ⟨hf, ‹_›⟩
section Uniqueness
/-- The **valuative criterion** for separated morphisms. -/
@[stacks 01L0]
lemma IsSeparated.of_valuativeCriterion [QuasiSeparated f]
(hf : ValuativeCriterion.Uniqueness f) : IsSeparated f where
diagonal_isClosedImmersion := by
suffices h : ValuativeCriterion.Existence (pullback.diagonal f) by
have := UniversallyClosed.of_valuativeCriterion (pullback.diagonal f) h
exact .of_isPreimmersion _ (pullback.diagonal f).isClosedMap.isClosed_range
intro S
have hc : CommSq S.i₁ (Spec.map (CommRingCat.ofHom (algebraMap S.R S.K)))
f (S.i₂ ≫ pullback.fst f f ≫ f) := ⟨by simp [← S.commSq.w_assoc]⟩
let S' : ValuativeCommSq f := ⟨S.R, S.K, S.i₁, S.i₂ ≫ pullback.fst f f ≫ f, hc⟩
have : Subsingleton S'.commSq.LiftStruct := hf S'
let S'l₁ : S'.commSq.LiftStruct := ⟨S.i₂ ≫ pullback.fst f f,
by simp [S', ← S.commSq.w_assoc], by simp [S']⟩
let S'l₂ : S'.commSq.LiftStruct := ⟨S.i₂ ≫ pullback.snd f f,
by simp [S', ← S.commSq.w_assoc], by simp [S', pullback.condition]⟩
have h₁₂ : S'l₁ = S'l₂ := Subsingleton.elim _ _
constructor
constructor
refine ⟨S.i₂ ≫ pullback.fst _ _, ?_, ?_⟩
· simp [← S.commSq.w_assoc]
· simp only [Category.assoc]
apply IsPullback.hom_ext (IsPullback.of_hasPullback _ _)
· simp
· simp only [Category.assoc, pullback.diagonal_snd, Category.comp_id]
exact congrArg CommSq.LiftStruct.l h₁₂
@[stacks 01KZ]
lemma IsSeparated.valuativeCriterion [IsSeparated f] : ValuativeCriterion.Uniqueness f := by
intro S
constructor
rintro ⟨l₁, hl₁, hl₁'⟩ ⟨l₂, hl₂, hl₂'⟩
ext : 1
dsimp at *
have h := hl₁'.trans hl₂'.symm
let Z := pullback (pullback.diagonal f) (pullback.lift l₁ l₂ h)
let g : Z ⟶ Spec (.of S.R) := pullback.snd _ _
have : IsClosedImmersion g := MorphismProperty.pullback_snd _ _ inferInstance
have hZ : IsAffine Z := by
rw [@HasAffineProperty.iff_of_isAffine @IsClosedImmersion] at this
exact this.left
suffices IsIso g by
rw [← cancel_epi g]
conv_lhs => rw [← pullback.lift_fst l₁ l₂ h, ← pullback.condition_assoc]
conv_rhs => rw [← pullback.lift_snd l₁ l₂ h, ← pullback.condition_assoc]
simp
suffices h : Function.Bijective (g.appTop) by
refine (HasAffineProperty.iff_of_isAffine (P := MorphismProperty.isomorphisms Scheme)).mpr ?_
exact ⟨hZ, (ConcreteCategory.isIso_iff_bijective _).mpr h⟩
constructor
· let l : Spec (.of S.K) ⟶ Z :=
pullback.lift S.i₁ (Spec.map (CommRingCat.ofHom (algebraMap S.R S.K))) (by
apply IsPullback.hom_ext (IsPullback.of_hasPullback _ _)
· simpa using hl₁.symm
· simpa using hl₂.symm)
have hg : l ≫ g = Spec.map (CommRingCat.ofHom (algebraMap S.R S.K)) :=
pullback.lift_snd _ _ _
have : Function.Injective ((l ≫ g).appTop) := by
rw [hg]
let e := arrowIsoΓSpecOfIsAffine (CommRingCat.ofHom <| algebraMap S.R S.K)
let P : MorphismProperty CommRingCat :=
RingHom.toMorphismProperty <| fun f ↦ Function.Injective f
have : (RingHom.toMorphismProperty <| fun f ↦ Function.Injective f).RespectsIso :=
RingHom.toMorphismProperty_respectsIso_iff.mp RingHom.injective_respectsIso
change P _
rw [← MorphismProperty.arrow_mk_iso_iff (P := P) e]
exact FaithfulSMul.algebraMap_injective S.R S.K
rw [Scheme.Hom.comp_appTop] at this
exact Function.Injective.of_comp this
· rw [@HasAffineProperty.iff_of_isAffine @IsClosedImmersion] at this
exact this.right
/-- The **valuative criterion** for separated morphisms. -/
lemma IsSeparated.eq_valuativeCriterion :
@IsSeparated = ValuativeCriterion.Uniqueness ⊓ @QuasiSeparated := by
ext X Y f
exact ⟨fun _ ↦ ⟨IsSeparated.valuativeCriterion f, inferInstance⟩,
fun ⟨H, _⟩ ↦ .of_valuativeCriterion f H⟩
end Uniqueness
/-- The **valuative criterion** for proper morphisms. -/
@[stacks 0BX5]
lemma IsProper.eq_valuativeCriterion :
@IsProper = ValuativeCriterion ⊓ @QuasiCompact ⊓ @QuasiSeparated ⊓ @LocallyOfFiniteType := by
rw [isProper_eq, IsSeparated.eq_valuativeCriterion, ValuativeCriterion.eq,
UniversallyClosed.eq_valuativeCriterion]
simp_rw [inf_assoc]
ext X Y f
change _ ∧ _ ∧ _ ∧ _ ∧ _ ↔ _ ∧ _ ∧ _ ∧ _ ∧ _
tauto
/-- The **valuative criterion** for proper morphisms. -/
@[stacks 0BX5]
lemma IsProper.of_valuativeCriterion [QuasiCompact f] [QuasiSeparated f] [LocallyOfFiniteType f]
(H : ValuativeCriterion f) : IsProper f := by
rw [eq_valuativeCriterion]
exact ⟨⟨⟨‹_›, ‹_›⟩, ‹_›⟩, ‹_›⟩
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Gluing.lean | import Mathlib.AlgebraicGeometry.Restrict
import Mathlib.CategoryTheory.LocallyDirected
import Mathlib.Geometry.RingedSpace.PresheafedSpace.Gluing
/-!
# Gluing Schemes
Given a family of gluing data of schemes, we may glue them together.
Also see the section about "locally directed" gluing,
which is a special case where the conditions are easier to check.
## Main definitions
* `AlgebraicGeometry.Scheme.GlueData`: A structure containing the family of gluing data.
* `AlgebraicGeometry.Scheme.GlueData.glued`: The glued scheme.
This is defined as the multicoequalizer of `∐ V i j ⇉ ∐ U i`, so that the general colimit API
can be used.
* `AlgebraicGeometry.Scheme.GlueData.ι`: The immersion `ι i : U i ⟶ glued` for each `i : J`.
* `AlgebraicGeometry.Scheme.GlueData.isoCarrier`: The isomorphism between the underlying space
of the glued scheme and the gluing of the underlying topological spaces.
* `AlgebraicGeometry.Scheme.OpenCover.gluedCover`: The glue data associated with an open cover.
* `AlgebraicGeometry.Scheme.OpenCover.fromGlued`: The canonical morphism
`𝒰.gluedCover.glued ⟶ X`. This has an `is_iso` instance.
* `AlgebraicGeometry.Scheme.OpenCover.glueMorphisms`: We may glue a family of compatible
morphisms defined on an open cover of a scheme.
## Main results
* `AlgebraicGeometry.Scheme.GlueData.ι_isOpenImmersion`: The map `ι i : U i ⟶ glued`
is an open immersion for each `i : J`.
* `AlgebraicGeometry.Scheme.GlueData.ι_jointly_surjective` : The underlying maps of
`ι i : U i ⟶ glued` are jointly surjective.
* `AlgebraicGeometry.Scheme.GlueData.vPullbackConeIsLimit` : `V i j` is the pullback
(intersection) of `U i` and `U j` over the glued space.
* `AlgebraicGeometry.Scheme.GlueData.ι_eq_iff` : `ι i x = ι j y` if and only if they coincide
when restricted to `V i i`.
* `AlgebraicGeometry.Scheme.GlueData.isOpen_iff` : A subset of the glued scheme is open iff
all its preimages in `U i` are open.
## Implementation details
All the hard work is done in `AlgebraicGeometry/PresheafedSpace/Gluing.lean` where we glue
presheafed spaces, sheafed spaces, and locally ringed spaces.
-/
noncomputable section
universe v u
open TopologicalSpace CategoryTheory Opposite Topology
open CategoryTheory.Limits AlgebraicGeometry.PresheafedSpace
open CategoryTheory.GlueData
namespace AlgebraicGeometry
namespace Scheme
/-- A family of gluing data consists of
1. An index type `J`
2. A scheme `U i` for each `i : J`.
3. A scheme `V i j` for each `i j : J`.
(Note that this is `J × J → Scheme` rather than `J → J → Scheme` to connect to the
limits library easier.)
4. An open immersion `f i j : V i j ⟶ U i` for each `i j : ι`.
5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`.
such that
6. `f i i` is an isomorphism.
7. `t i i` is the identity.
8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some
`t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.
9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.
We can then glue the schemes `U i` together by identifying `V i j` with `V j i`, such
that the `U i`'s are open subschemes of the glued space.
-/
structure GlueData extends CategoryTheory.GlueData Scheme where
f_open : ∀ i j, IsOpenImmersion (f i j)
attribute [instance] GlueData.f_open
namespace GlueData
variable (D : GlueData.{u})
local notation "𝖣" => D.toGlueData
/-- The glue data of locally ringed spaces associated to a family of glue data of schemes. -/
abbrev toLocallyRingedSpaceGlueData : LocallyRingedSpace.GlueData :=
{ f_open := D.f_open
toGlueData := 𝖣.mapGlueData forgetToLocallyRingedSpace }
instance (i j : 𝖣.J) :
LocallyRingedSpace.IsOpenImmersion ((D.toLocallyRingedSpaceGlueData).toGlueData.f i j) := by
apply GlueData.f_open
instance (i j : 𝖣.J) :
SheafedSpace.IsOpenImmersion
(D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toGlueData.f i j) := by
apply GlueData.f_open
instance (i j : 𝖣.J) :
PresheafedSpace.IsOpenImmersion
(D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toGlueData.f
i j) := by
apply GlueData.f_open
instance (i : 𝖣.J) :
LocallyRingedSpace.IsOpenImmersion ((D.toLocallyRingedSpaceGlueData).toGlueData.ι i) := by
apply LocallyRingedSpace.GlueData.ι_isOpenImmersion
/-- (Implementation). The glued scheme of a glue data.
This should not be used outside this file. Use `AlgebraicGeometry.Scheme.GlueData.glued` instead. -/
def gluedScheme : Scheme := by
apply LocallyRingedSpace.IsOpenImmersion.scheme
D.toLocallyRingedSpaceGlueData.toGlueData.glued
intro x
obtain ⟨i, y, rfl⟩ := D.toLocallyRingedSpaceGlueData.ι_jointly_surjective x
obtain ⟨j, z, hz⟩ := (D.U i).affineCover.exists_eq y
refine ⟨_, ((D.U i).affineCover.f j).toLRSHom ≫
D.toLocallyRingedSpaceGlueData.toGlueData.ι i, ?_⟩
constructor
· simp only [LocallyRingedSpace.comp_toShHom, SheafedSpace.comp_base, TopCat.hom_comp,
ContinuousMap.coe_comp, Set.range_comp]
exact Set.mem_image_of_mem _ ⟨z, hz⟩
· infer_instance
instance : CreatesColimit 𝖣.diagram.multispan forgetToLocallyRingedSpace :=
createsColimitOfFullyFaithfulOfIso D.gluedScheme
(HasColimit.isoOfNatIso (𝖣.diagramIso forgetToLocallyRingedSpace).symm)
instance : PreservesColimit (𝖣.diagram.multispan) forgetToTop :=
inferInstanceAs (PreservesColimit (𝖣.diagram).multispan (forgetToLocallyRingedSpace ⋙
LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat))
instance : PreservesColimit (𝖣.diagram.multispan) forget :=
inferInstanceAs (PreservesColimit (𝖣.diagram).multispan (forgetToTop ⋙ CategoryTheory.forget _))
instance : HasMulticoequalizer 𝖣.diagram :=
hasColimit_of_created _ forgetToLocallyRingedSpace
/-- The glued scheme of a glued space. -/
abbrev glued : Scheme :=
𝖣.glued
/-- The immersion from `D.U i` into the glued space. -/
abbrev ι (i : D.J) : D.U i ⟶ D.glued :=
𝖣.ι i
/-- The gluing as sheafed spaces is isomorphic to the gluing as presheafed spaces. -/
abbrev isoLocallyRingedSpace :
D.glued.toLocallyRingedSpace ≅ D.toLocallyRingedSpaceGlueData.toGlueData.glued :=
𝖣.gluedIso forgetToLocallyRingedSpace
theorem ι_isoLocallyRingedSpace_inv (i : D.J) :
D.toLocallyRingedSpaceGlueData.toGlueData.ι i ≫
D.isoLocallyRingedSpace.inv = (𝖣.ι i).toLRSHom :=
𝖣.ι_gluedIso_inv forgetToLocallyRingedSpace i
instance ι_isOpenImmersion (i : D.J) : IsOpenImmersion (𝖣.ι i) := by
rw [IsOpenImmersion, ← D.ι_isoLocallyRingedSpace_inv]; infer_instance
theorem ι_jointly_surjective (x : 𝖣.glued.carrier) :
∃ (i : D.J) (y : (D.U i).carrier), D.ι i y = x :=
𝖣.ι_jointly_surjective forget x
/-- Promoted to higher priority to short circuit simplifier. -/
@[simp (high), reassoc]
theorem glue_condition (i j : D.J) : D.t i j ≫ D.f j i ≫ D.ι j = D.f i j ≫ D.ι i :=
𝖣.glue_condition i j
/-- The pullback cone spanned by `V i j ⟶ U i` and `V i j ⟶ U j`.
This is a pullback diagram (`vPullbackConeIsLimit`). -/
def vPullbackCone (i j : D.J) : PullbackCone (D.ι i) (D.ι j) :=
PullbackCone.mk (D.f i j) (D.t i j ≫ D.f j i) (by simp)
/-- The following diagram is a pullback, i.e. `Vᵢⱼ` is the intersection of `Uᵢ` and `Uⱼ` in `X`.
```
Vᵢⱼ ⟶ Uᵢ
| |
↓ ↓
Uⱼ ⟶ X
```
-/
def vPullbackConeIsLimit (i j : D.J) : IsLimit (D.vPullbackCone i j) :=
𝖣.vPullbackConeIsLimitOfMap forgetToLocallyRingedSpace i j
(D.toLocallyRingedSpaceGlueData.vPullbackConeIsLimit _ _)
local notation "D_" => TopCat.GlueData.toGlueData <|
D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData
/-- The underlying topological space of the glued scheme is isomorphic to the gluing of the
underlying spaces -/
def isoCarrier :
D.glued.carrier ≅ (D_).glued := by
refine (PresheafedSpace.forget _).mapIso ?_ ≪≫
GlueData.gluedIso _ (PresheafedSpace.forget.{_, _, u} _)
refine SheafedSpace.forgetToPresheafedSpace.mapIso ?_ ≪≫
SheafedSpace.GlueData.isoPresheafedSpace _
refine LocallyRingedSpace.forgetToSheafedSpace.mapIso ?_ ≪≫
LocallyRingedSpace.GlueData.isoSheafedSpace _
exact Scheme.GlueData.isoLocallyRingedSpace _
@[simp]
theorem ι_isoCarrier_inv (i : D.J) :
(D_).ι i ≫ D.isoCarrier.inv = (D.ι i).base := by
delta isoCarrier
rw [Iso.trans_inv, GlueData.ι_gluedIso_inv_assoc, Functor.mapIso_inv, Iso.trans_inv,
Functor.mapIso_inv, Iso.trans_inv, SheafedSpace.forgetToPresheafedSpace_map,
PresheafedSpace.forget_map,
PresheafedSpace.forget_map, ← PresheafedSpace.comp_base, ← Category.assoc,
D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.ι_isoPresheafedSpace_inv i]
erw [← Category.assoc, D.toLocallyRingedSpaceGlueData.ι_isoSheafedSpace_inv i]
change (_ ≫ D.isoLocallyRingedSpace.inv).base = _
rw [D.ι_isoLocallyRingedSpace_inv i]
/-- An equivalence relation on `Σ i, D.U i` that holds iff `𝖣.ι i x = 𝖣.ι j y`.
See `AlgebraicGeometry.Scheme.GlueData.ι_eq_iff`. -/
def Rel (a b : Σ i, ((D.U i).carrier : Type _)) : Prop :=
∃ x : (D.V (a.1, b.1)).carrier, D.f _ _ x = a.2 ∧ (D.t _ _ ≫ D.f _ _) x = b.2
theorem ι_eq_iff (i j : D.J) (x : (D.U i).carrier) (y : (D.U j).carrier) :
𝖣.ι i x = 𝖣.ι j y ↔ D.Rel ⟨i, x⟩ ⟨j, y⟩ := by
refine Iff.trans ?_
(TopCat.GlueData.ι_eq_iff_rel
D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData
i j x y)
rw [← ((TopCat.mono_iff_injective D.isoCarrier.inv).mp _).eq_iff, ← ConcreteCategory.comp_apply]
· simp_rw [← D.ι_isoCarrier_inv]
rfl -- `rfl` was not needed before https://github.com/leanprover-community/mathlib4/pull/13170
· infer_instance
theorem isOpen_iff (U : Set D.glued.carrier) : IsOpen U ↔ ∀ i, IsOpen (D.ι i ⁻¹' U) := by
rw [← (TopCat.homeoOfIso D.isoCarrier.symm).isOpen_preimage, TopCat.GlueData.isOpen_iff]
apply forall_congr'
intro i
rw [← Set.preimage_comp, ← ι_isoCarrier_inv]
rfl
/-- The open cover of the glued space given by the glue data. -/
@[simps -isSimp]
def openCover (D : Scheme.GlueData) : OpenCover D.glued where
I₀ := D.J
X := D.U
f := D.ι
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
exact ⟨D.ι_jointly_surjective, inferInstance⟩
end GlueData
namespace Cover
variable {X : Scheme.{u}} (𝒰 : OpenCover.{u} X)
/-- (Implementation) the transition maps in the glue data associated with an open cover. -/
def gluedCoverT' (x y z : 𝒰.I₀) :
pullback (pullback.fst (𝒰.f x) (𝒰.f y)) (pullback.fst (𝒰.f x) (𝒰.f z)) ⟶
pullback (pullback.fst (𝒰.f y) (𝒰.f z)) (pullback.fst (𝒰.f y) (𝒰.f x)) := by
refine (pullbackRightPullbackFstIso _ _ _).hom ≫ ?_
refine ?_ ≫ (pullbackSymmetry _ _).hom
refine ?_ ≫ (pullbackRightPullbackFstIso _ _ _).inv
refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_
· simp [pullback.condition]
· simp
@[simp, reassoc]
theorem gluedCoverT'_fst_fst (x y z : 𝒰.I₀) :
𝒰.gluedCoverT' x y z ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
delta gluedCoverT'; simp
@[simp, reassoc]
theorem gluedCoverT'_fst_snd (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
delta gluedCoverT'; simp
@[simp, reassoc]
theorem gluedCoverT'_snd_fst (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ pullback.snd _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
delta gluedCoverT'; simp
@[simp, reassoc]
theorem gluedCoverT'_snd_snd (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ := by
delta gluedCoverT'; simp
theorem glued_cover_cocycle_fst (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.fst _ _ =
pullback.fst _ _ := by
apply pullback.hom_ext <;> simp
theorem glued_cover_cocycle_snd (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.snd _ _ =
pullback.snd _ _ := by
apply pullback.hom_ext <;> simp [pullback.condition]
theorem glued_cover_cocycle (x y z : 𝒰.I₀) :
gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y = 𝟙 _ := by
apply pullback.hom_ext <;> simp_rw [Category.id_comp, Category.assoc]
· apply glued_cover_cocycle_fst
· apply glued_cover_cocycle_snd
/-- The glue data associated with an open cover.
The canonical isomorphism `𝒰.gluedCover.glued ⟶ X` is provided by `𝒰.fromGlued`. -/
@[simps]
def gluedCover : Scheme.GlueData.{u} where
J := 𝒰.I₀
U := 𝒰.X
V := fun ⟨x, y⟩ => pullback (𝒰.f x) (𝒰.f y)
f _ _ := pullback.fst _ _
f_id _ := inferInstance
t _ _ := (pullbackSymmetry _ _).hom
t_id x := by simp
t' x y z := gluedCoverT' 𝒰 x y z
t_fac x y z := by apply pullback.hom_ext <;> simp
-- The `cocycle` field could have been `by tidy` but lean timeouts.
cocycle x y z := glued_cover_cocycle 𝒰 x y z
f_open _ := inferInstance
/-- The canonical morphism from the gluing of an open cover of `X` into `X`.
This is an isomorphism, as witnessed by an `IsIso` instance. -/
def fromGlued : 𝒰.gluedCover.glued ⟶ X := by
fapply Multicoequalizer.desc
· exact fun x => 𝒰.f x
rintro ⟨x, y⟩
change pullback.fst _ _ ≫ _ = ((pullbackSymmetry _ _).hom ≫ pullback.fst _ _) ≫ _
simpa using pullback.condition
@[simp, reassoc]
theorem ι_fromGlued (x : 𝒰.I₀) : 𝒰.gluedCover.ι x ≫ 𝒰.fromGlued = 𝒰.f x :=
Multicoequalizer.π_desc _ _ _ _ _
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued := by
intro x y h
obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply] at h
simp_rw [← Scheme.Hom.comp_base] at h
rw [ι_fromGlued, ι_fromGlued] at h
let e :=
(TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
(isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.f i) (𝒰.f j))
rw [𝒰.gluedCover.ι_eq_iff]
use e.hom ⟨⟨x, y⟩, h⟩
constructor
· erw [← ConcreteCategory.comp_apply e.hom,
IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]
rfl
· erw [← ConcreteCategory.comp_apply e.hom, pullbackSymmetry_hom_comp_fst,
IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right]
rfl
instance (x : 𝒰.gluedCover.glued.carrier) :
IsIso (𝒰.fromGlued.stalkMap x) := by
obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
have := Hom.stalkMap_congr_hom _ _ (𝒰.ι_fromGlued i) x
rw [Hom.stalkMap_comp, ← IsIso.eq_comp_inv] at this
rw [this]
infer_instance
theorem isOpenMap_fromGlued : IsOpenMap 𝒰.fromGlued := by
intro U hU
rw [isOpen_iff_forall_mem_open]
intro x hx
rw [𝒰.gluedCover.isOpen_iff] at hU
use 𝒰.fromGlued '' U ∩ Set.range (𝒰.f (𝒰.idx x))
use Set.inter_subset_left
constructor
· rw [← Set.image_preimage_eq_inter_range]
apply (𝒰.f (𝒰.idx x)).isOpenEmbedding.isOpenMap
convert hU (𝒰.idx x) using 1
simp only [← ι_fromGlued, gluedCover_U, Hom.comp_base, TopCat.hom_comp, ContinuousMap.coe_comp,
Set.preimage_comp]
congr! 1
exact Set.preimage_image_eq _ 𝒰.fromGlued_injective
· exact ⟨hx, 𝒰.covers x⟩
@[deprecated (since := "2025-10-07")] alias fromGlued_open_map := isOpenMap_fromGlued
theorem isOpenEmbedding_fromGlued : IsOpenEmbedding 𝒰.fromGlued :=
.of_continuous_injective_isOpenMap (by fun_prop) 𝒰.fromGlued_injective 𝒰.isOpenMap_fromGlued
@[deprecated (since := "2025-10-07")] alias fromGlued_isOpenEmbedding := isOpenEmbedding_fromGlued
instance : Epi 𝒰.fromGlued.base := by
rw [TopCat.epi_iff_surjective]
intro x
obtain ⟨y, h⟩ := 𝒰.covers x
use 𝒰.gluedCover.ι (𝒰.idx x) y
rw [← ConcreteCategory.comp_apply]
rw [← 𝒰.ι_fromGlued (𝒰.idx x)] at h
exact h
instance : IsOpenImmersion 𝒰.fromGlued :=
IsOpenImmersion.of_isIso_stalkMap _ 𝒰.isOpenEmbedding_fromGlued
instance : IsIso 𝒰.fromGlued :=
let F := Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙
SheafedSpace.forgetToPresheafedSpace
have : IsIso (F.map (fromGlued 𝒰)) := by
change IsIso 𝒰.fromGlued.toPshHom
apply PresheafedSpace.IsOpenImmersion.to_iso
isIso_of_reflects_iso _ F
/-- Given an open cover of `X`, and a morphism `𝒰.X x ⟶ Y` for each open subscheme in the cover,
such that these morphisms are compatible in the intersection (pullback), we may glue the morphisms
together into a morphism `X ⟶ Y`.
Note:
If `X` is exactly (defeq to) the gluing of `U i`, then using `Multicoequalizer.desc` suffices.
-/
def glueMorphisms (𝒰 : OpenCover.{v} X) {Y : Scheme.{u}} (f : ∀ x, 𝒰.X x ⟶ Y)
(hf : ∀ x y, pullback.fst (𝒰.f x) (𝒰.f y) ≫ f x = pullback.snd _ _ ≫ f y) :
X ⟶ Y := by
refine inv 𝒰.ulift.fromGlued ≫ ?_
fapply Multicoequalizer.desc
· exact fun i ↦ f _
rintro ⟨i, j⟩
dsimp
change pullback.fst _ _ ≫ f _ = (_ ≫ _) ≫ f _
simpa [pullbackSymmetry_hom_comp_fst] using hf _ _
theorem hom_ext (𝒰 : OpenCover.{v} X) {Y : Scheme} (f₁ f₂ : X ⟶ Y)
(h : ∀ x, 𝒰.f x ≫ f₁ = 𝒰.f x ≫ f₂) : f₁ = f₂ := by
rw [← cancel_epi 𝒰.ulift.fromGlued]
apply Multicoequalizer.hom_ext
intro x
rw [fromGlued, Multicoequalizer.π_desc_assoc, Multicoequalizer.π_desc_assoc]
exact h _
@[simp, reassoc]
theorem ι_glueMorphisms (𝒰 : OpenCover.{v} X) {Y : Scheme} (f : ∀ x, 𝒰.X x ⟶ Y)
(hf : ∀ x y, pullback.fst (𝒰.f x) (𝒰.f y) ≫ f x = pullback.snd _ _ ≫ f y)
(x : 𝒰.I₀) : 𝒰.f x ≫ 𝒰.glueMorphisms f hf = f x := by
refine Cover.hom_ext (𝒰.ulift.pullback₁ (𝒰.f x)) _ _ fun i ↦ ?_
dsimp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_X, ulift_X, ulift_f, PreZeroHypercover.pullback₁_f]
simp_rw [pullback.condition_assoc, ← ulift_f, ← ι_fromGlued, Category.assoc, glueMorphisms,
IsIso.hom_inv_id_assoc, ulift_f, hf]
erw [Multicoequalizer.π_desc]
end Cover
lemma hom_ext_of_forall {X Y : Scheme} (f g : X ⟶ Y)
(H : ∀ x : X, ∃ U : X.Opens, x ∈ U ∧ U.ι ≫ f = U.ι ≫ g) : f = g := by
choose U hxU hU using H
let 𝒰 : X.OpenCover := {
I₀ := X, X i := (U i), f i := (U i).ι,
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ⟨x, by simpa using hxU x⟩, inferInstance⟩ }
exact 𝒰.hom_ext _ _ hU
/-!
## Locally directed gluing
We say that a diagram of open immersions is "locally directed" if for any `V, W ⊆ U` in the diagram,
`V ∩ W` is a union of elements in the diagram. Equivalently, for every `x ∈ U` in the diagram,
the set of elements containing `x` is directed (and hence the name).
For such a diagram, we can glue them directly since the gluing conditions are always satisfied.
The intended usage is to provide the following instances:
- `∀ {i j} (f : i ⟶ j), IsOpenImmersion (F.map f)`
- `(F ⋙ forget).IsLocallyDirected`
and to directly use the `colimit` API.
Also see `AlgebraicGeometry.Scheme.IsLocallyDirected.openCover` for the open cover of the `colimit`.
-/
section IsLocallyDirected
open TopologicalSpace.Opens
universe w
variable {J : Type w} [Category.{v} J] (F : J ⥤ Scheme.{u})
variable [∀ {i j} (f : i ⟶ j), IsOpenImmersion (F.map f)]
namespace IsLocallyDirected
/-- (Implementation detail)
The intersection `V` in the glue data associated to a locally directed diagram. -/
noncomputable
def V (i j : J) : (F.obj i).Opens := ⨆ (k : Σ k, (k ⟶ i) × (k ⟶ j)), (F.map k.2.1).opensRange
lemma V_self (i) : V F i i = ⊤ :=
top_le_iff.mp (le_iSup_of_le ⟨i, 𝟙 _, 𝟙 _⟩ (by simp [Scheme.Hom.opensRange_of_isIso]))
variable [(F ⋙ forget).IsLocallyDirected]
lemma exists_of_pullback_V_V {i j k : J} (x : pullback (C := Scheme) (V F i j).ι (V F i k).ι) :
∃ (l : J) (fi : l ⟶ i) (fj : l ⟶ j) (fk : l ⟶ k)
(α : F.obj l ⟶ pullback (V F i j).ι (V F i k).ι) (z : F.obj l),
IsOpenImmersion α ∧
α ≫ pullback.fst _ _ = (F.map fi).isoOpensRange.hom ≫
(F.obj i).homOfLE (le_iSup_of_le ⟨l, _, fj⟩ le_rfl) ∧
α ≫ pullback.snd _ _ = (F.map fi).isoOpensRange.hom ≫
(F.obj i).homOfLE (le_iSup_of_le ⟨l, _, fk⟩ le_rfl) ∧
α z = x := by
obtain ⟨k₁, y₁, hy₁⟩ := mem_iSup.mp ((pullback.fst (C := Scheme) _ _) x).2
obtain ⟨k₂, y₂, hy₂⟩ := mem_iSup.mp ((pullback.snd (C := Scheme) _ _) x).2
obtain ⟨l, hli, hlk, z, rfl, rfl⟩ :=
(F ⋙ forget).exists_map_eq_of_isLocallyDirected k₁.2.1 k₂.2.1 y₁ y₂
(by simpa [hy₁, hy₂] using congr($(pullback.condition (f := (V F i j).ι)) x))
let α : F.obj l ⟶ pullback (V F i j).ι (V F i k).ι :=
pullback.lift
((F.map (hli ≫ k₁.2.1)).isoOpensRange.hom ≫ Scheme.homOfLE _
(le_iSup_of_le ⟨l, hli ≫ k₁.2.1, hli ≫ k₁.2.2⟩ le_rfl))
((F.map (hli ≫ k₁.2.1)).isoOpensRange.hom ≫ Scheme.homOfLE _
(le_iSup_of_le ⟨l, hli ≫ k₁.2.1, hlk ≫ k₂.2.2⟩ le_rfl))
(by simp)
have : IsOpenImmersion α := by
apply (config := { allowSynthFailures := true }) IsOpenImmersion.of_comp
· exact inferInstanceAs (IsOpenImmersion (pullback.fst _ _))
· simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, α]
infer_instance
have : α z = x := by
apply (pullback.fst (C := Scheme) _ _).isOpenEmbedding.injective
apply (V F i j).ι.isOpenEmbedding.injective
rw [← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply, pullback.lift_fst_assoc]
simpa using hy₁
exact ⟨l, hli ≫ k₁.2.1, hli ≫ k₁.2.2, hlk ≫ k₂.2.2, α, z, ‹_›, by simp [α], by simp [α], ‹_›⟩
variable [Quiver.IsThin J]
lemma fst_inv_eq_snd_inv
{i j : J} (k₁ k₂ : (k : J) × (k ⟶ i) × (k ⟶ j)) {U : (F.obj i).Opens}
(h₁ : (F.map k₁.2.1).opensRange ≤ U) (h₂ : (F.map k₂.2.1).opensRange ≤ U) :
pullback.fst ((F.obj i).homOfLE h₁) ((F.obj i).homOfLE h₂) ≫
(F.map k₁.2.1).isoOpensRange.inv ≫ F.map k₁.2.2 =
pullback.snd ((F.obj i).homOfLE h₁) ((F.obj i).homOfLE h₂) ≫
(F.map k₂.2.1).isoOpensRange.inv ≫ F.map k₂.2.2 := by
apply Scheme.hom_ext_of_forall
intro x
obtain ⟨l, hli, hlj, y, hy₁, hy₂⟩ := (F ⋙ forget).exists_map_eq_of_isLocallyDirected k₁.2.1 k₂.2.1
((pullback.fst _ _ ≫ (F.map k₁.2.1).isoOpensRange.inv) x)
((pullback.snd _ _ ≫ (F.map k₂.2.1).isoOpensRange.inv) x) (by
simp only [Functor.comp_obj, forget_obj, Functor.comp_map, forget_map, ← Hom.comp_apply,
Category.assoc, Hom.isoOpensRange_inv_comp]
congr 5
simpa using congr($(pullback.condition (f := (F.obj i).homOfLE h₁)
(g := (F.obj i).homOfLE h₂)) ≫ Scheme.Opens.ι _))
let α : F.obj l ⟶ pullback ((F.obj i).homOfLE h₁) ((F.obj i).homOfLE h₂) :=
pullback.lift
(F.map hli ≫ (F.map k₁.2.1).isoOpensRange.hom)
(F.map hlj ≫ (F.map k₂.2.1).isoOpensRange.hom)
(by simp [← cancel_mono (Scheme.Opens.ι _), ← Functor.map_comp,
Subsingleton.elim (hli ≫ k₁.2.1) (hlj ≫ k₂.2.1)])
have : IsOpenImmersion α := by
have : IsOpenImmersion (α ≫ pullback.fst _ _) := by
simp only [pullback.lift_fst, α]; infer_instance
exact .of_comp _ (pullback.fst _ _)
have : α y = x := by
simp only [Functor.comp_obj, forget_obj, Functor.comp_map, forget_map, Hom.comp_base,
TopCat.hom_comp, ContinuousMap.comp_apply] at hy₁
apply (pullback.fst ((F.obj i).homOfLE h₁) _).isOpenEmbedding.injective
simp only [← Scheme.Hom.comp_apply, α, pullback.lift_fst]
simp [hy₁]
refine ⟨α.opensRange, ⟨y, this⟩, ?_⟩
rw [← cancel_epi α.isoOpensRange.hom]
simp [α, ← Functor.map_comp, Subsingleton.elim (hli ≫ k₁.2.2) (hlj ≫ k₂.2.2)]
/-- (Implementation detail)
The inclusion map `V i j ⟶ F j` in the glue data associated to a locally directed diagram. -/
def tAux (i j : J) : (V F i j).toScheme ⟶ F.obj j :=
(Scheme.Opens.iSupOpenCover _).glueMorphisms
(fun k ↦ (F.map k.2.1).isoOpensRange.inv ≫ F.map k.2.2) fun k₁ k₂ ↦ by
dsimp [Scheme.Opens.iSupOpenCover]
apply fst_inv_eq_snd_inv F
@[reassoc]
lemma homOfLE_tAux (i j : J) {k : J} (fi : k ⟶ i) (fj : k ⟶ j) :
(F.obj i).homOfLE (le_iSup_of_le ⟨k, fi, fj⟩ le_rfl) ≫
tAux F i j = (F.map fi).isoOpensRange.inv ≫ F.map fj :=
(Scheme.Opens.iSupOpenCover (J := Σ k, (k ⟶ i) × (k ⟶ j)) _).ι_glueMorphisms _ _ ⟨k, fi, fj⟩
/-- (Implementation detail)
The transition map `V i j ⟶ V j i` in the glue data associated to a locally directed diagram. -/
def t (i j : J) : (V F i j).toScheme ⟶ (V F j i).toScheme :=
IsOpenImmersion.lift (V F j i).ι (tAux F i j) (by
rintro _ ⟨x, rfl⟩
obtain ⟨l, x, rfl⟩ := (Scheme.Opens.iSupOpenCover _).exists_eq x
simp only [V, tAux, ← Scheme.Hom.comp_apply, Cover.ι_glueMorphisms]
simp only [Opens.range_ι, iSup_mk, carrier_eq_coe, Hom.coe_opensRange, coe_mk, Hom.comp_base,
TopCat.hom_comp, ContinuousMap.comp_apply]
exact Set.mem_iUnion.mpr ⟨⟨l.1, l.2.2, l.2.1⟩, ⟨_, rfl⟩⟩)
lemma t_id (i : J) : t F i i = 𝟙 _ := by
refine (Scheme.Opens.iSupOpenCover _).hom_ext _ _ fun k ↦ ?_
simp only [Category.comp_id, ← cancel_mono (Scheme.Opens.ι _), Category.assoc,
IsOpenImmersion.lift_fac, Scheme.Cover.ι_glueMorphisms, t, tAux, V]
simp [Scheme.Opens.iSupOpenCover, Iso.inv_comp_eq, Subsingleton.elim k.2.1 k.2.2]
variable [Small.{u} J]
local notation3:max "↓"j:arg => Equiv.symm (equivShrink _) j
/-- (Implementation detail)
The glue data associated to a locally directed diagram.
One usually does not want to use this directly, and instead use the generic `colimit` API.
-/
def glueData : Scheme.GlueData where
J := Shrink.{u} J
U j := F.obj ↓j
V ij := V F ↓ij.1 ↓ij.2
f i j := Scheme.Opens.ι _
f_id i := V_self F ↓i ▸ (Scheme.topIso _).isIso_hom
f_hasPullback := inferInstance
f_open := inferInstance
t i j := t F ↓i ↓j
t_id i := t_id F ↓i
t' i j k := pullback.lift
(IsOpenImmersion.lift (V F ↓j ↓k).ι (pullback.fst _ _ ≫ tAux F ↓i ↓j) (by
rintro _ ⟨x, rfl⟩
obtain ⟨l, fi, fj, fk, α, z, hα, hα₁, hα₂, rfl⟩ := exists_of_pullback_V_V F x
rw [← Scheme.Hom.comp_apply, reassoc_of% hα₁, homOfLE_tAux F ↓i ↓j fi fj,
Iso.hom_inv_id_assoc, Scheme.Opens.range_ι, SetLike.mem_coe]
exact TopologicalSpace.Opens.mem_iSup.mpr ⟨⟨l, fj, fk⟩, ⟨z, rfl⟩⟩))
(pullback.fst _ _ ≫ t F _ _) (by simp [t])
t_fac i j k := pullback.lift_snd _ _ _
cocycle i j k := by
refine Scheme.hom_ext_of_forall _ _ fun x ↦ ?_
have := exists_of_pullback_V_V F x
obtain ⟨l, fi, fj, fk, α, z, hα, hα₁, hα₂, e⟩ := this -- doing them in the same step times out.
refine ⟨α.opensRange, ⟨_, e⟩, ?_⟩
rw [← cancel_mono (pullback.snd _ _), ← cancel_mono (Scheme.Opens.ι _)]
simp only [t, Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
limit.lift_π_assoc, cospan_left, IsOpenImmersion.lift_fac, Category.id_comp]
rw [IsOpenImmersion.comp_lift_assoc]
simp only [limit.lift_π_assoc, PullbackCone.mk_pt, cospan_left, PullbackCone.mk_π_app]
rw [← cancel_epi α.isoOpensRange.hom]
simp_rw [Scheme.Hom.isoOpensRange_hom_ι_assoc, IsOpenImmersion.comp_lift_assoc]
simp only [reassoc_of% hα₁, homOfLE_tAux F _ _ fi fj, Iso.hom_inv_id_assoc, reassoc_of% hα₂]
generalize_proofs _ h₁
have : IsOpenImmersion.lift (V F ↓j ↓k).ι (F.map fj) h₁ = (F.map fj).isoOpensRange.hom ≫
(F.obj ↓j).homOfLE (le_iSup_of_le ⟨l, fj, fk⟩ le_rfl) := by
rw [← cancel_mono (Scheme.Opens.ι _), Category.assoc, IsOpenImmersion.lift_fac,
← Iso.inv_comp_eq, Scheme.Hom.isoOpensRange_inv_comp]
exact (Scheme.homOfLE_ι _ _).symm
simp_rw [this, Category.assoc, homOfLE_tAux F _ _ fj fk, Iso.hom_inv_id_assoc]
generalize_proofs h₂
have : IsOpenImmersion.lift (V F ↓k ↓i).ι (F.map fk) h₂ = (F.map fk).isoOpensRange.hom ≫
(F.obj ↓k).homOfLE (le_iSup_of_le ⟨l, fk, fi⟩ le_rfl) := by
rw [← cancel_mono (Scheme.Opens.ι _), Category.assoc, IsOpenImmersion.lift_fac,
← Iso.inv_comp_eq, Scheme.Hom.isoOpensRange_inv_comp]
exact (Scheme.homOfLE_ι _ _).symm
simp_rw [this, Category.assoc, homOfLE_tAux F _ _ fk fi, Iso.hom_inv_id_assoc,
← Iso.inv_comp_eq, Scheme.Hom.isoOpensRange_inv_comp]
exact (Scheme.homOfLE_ι _ _).symm
lemma glueDataι_naturality {i j : Shrink.{u} J} (f : ↓i ⟶ ↓j) :
F.map f ≫ (glueData F).ι j = (glueData F).ι i := by
have : IsIso (V F ↓i ↓j).ι := by
have : V F ↓i ↓j = ⊤ :=
top_le_iff.mp (le_iSup_of_le ⟨_, 𝟙 i, f⟩ (by simp [Scheme.Hom.opensRange_of_isIso]))
exact this ▸ (topIso _).isIso_hom
have : t F ↓i ↓j ≫ (V F ↓j ↓i).ι ≫ _ = (V F ↓i ↓j).ι ≫ _ :=
(glueData F).glue_condition i j
simp only [t, IsOpenImmersion.lift_fac_assoc] at this
rw [← cancel_epi (V F ↓i ↓j).ι, ← this, ← Category.assoc,
← (Iso.eq_inv_comp _).mp (homOfLE_tAux F ↓i ↓j (𝟙 i) f),
← Category.assoc, ← Category.assoc, Category.assoc]
convert Category.id_comp _
rw [← cancel_mono (Opens.ι _)]
simp [V, InducedCategory.category, Shrink.instCategoryShrink]
/-- (Implementation detail)
The cocone associated to a locally directed diagram.
One usually does not want to use this directly, and instead use the generic `colimit` API.
-/
def cocone : Cocone F where
pt := (glueData F).glued
ι.app j := F.map (eqToHom (by simp)) ≫ (glueData F).ι (equivShrink _ j)
ι.naturality {i j} f := by
simp only [← IsIso.inv_comp_eq, ← Functor.map_inv, ← Functor.map_comp_assoc,
glueDataι_naturality, Functor.const_obj_obj, Functor.const_obj_map, Category.comp_id]
/-- (Implementation detail)
The cocone associated to a locally directed diagram is a colimit.
One usually does not want to use this directly, and instead use the generic `colimit` API.
-/
noncomputable
def isColimit : IsColimit (cocone F) where
desc s := Multicoequalizer.desc _ _ (fun i ↦ s.ι.app ↓i) (by
rintro ⟨i, j⟩
dsimp [glueData, GlueData.diagram]
simp only [t, IsOpenImmersion.lift_fac]
apply (Scheme.Opens.iSupOpenCover _).hom_ext _ _ fun k ↦ ?_
simp only [Opens.iSupOpenCover, V, Scheme.homOfLE_ι_assoc]
rw [homOfLE_tAux_assoc F ↓i ↓j k.2.1 k.2.2, Iso.eq_inv_comp]
simp)
fac s j := by
refine (Category.assoc _ _ _).trans ?_
conv_lhs => enter [2]; tactic => exact Multicoequalizer.π_desc _ _ _ _ _
simp
uniq s m hm := Multicoequalizer.hom_ext _ _ _ fun i ↦ by
simp [← hm ↓i, cocone, reassoc_of% glueDataι_naturality]
rfl
/-- (Implementation detail)
The cocone associated to a locally directed diagram is a colimit as locally ringed spaces.
One usually does not want to use this directly, and instead use the generic `colimit` API.
-/
noncomputable
def isColimitForgetToLocallyRingedSpace :
IsColimit (Scheme.forgetToLocallyRingedSpace.mapCocone (cocone F)) where
desc s := (glueData F).isoLocallyRingedSpace.hom ≫
Multicoequalizer.desc _ _ (fun i ↦ s.ι.app ↓i) (by
rintro ⟨i, j⟩
dsimp [glueData, GlueData.diagram]
simp only [t, IsOpenImmersion.lift_fac, ← Scheme.Hom.comp_toLRSHom]
rw [← cancel_epi (Scheme.Opens.iSupOpenCover _).ulift.fromGlued.toLRSHom,
← cancel_epi (Scheme.Opens.iSupOpenCover _).ulift.gluedCover.isoLocallyRingedSpace.inv]
refine Multicoequalizer.hom_ext _ _ _ fun ⟨k, hk⟩ ↦ ?_
rw [← CategoryTheory.GlueData.ι, reassoc_of% GlueData.ι_isoLocallyRingedSpace_inv,
reassoc_of% GlueData.ι_isoLocallyRingedSpace_inv,
← cancel_epi (Hom.isoOpensRange (F.map _)).hom.toLRSHom]
simp only [Opens.iSupOpenCover, Cover.ulift, V, ← Hom.comp_toLRSHom_assoc,
Cover.ι_fromGlued_assoc, homOfLE_ι, Hom.isoOpensRange_hom_ι, Cover.idx]
generalize_proofs _ _ h
rw [homOfLE_tAux F ↓i ↓j h.choose.2.1 h.choose.2.2, Iso.hom_inv_id_assoc]
exact (s.w h.choose.2.1).trans (s.w h.choose.2.2).symm)
fac s j := by
simp only [cocone, Functor.mapCocone_ι_app, Scheme.Hom.comp_toLRSHom,
forgetToLocallyRingedSpace_map, ← GlueData.ι_isoLocallyRingedSpace_inv]
simpa [CategoryTheory.GlueData.ι] using s.w _
uniq s m hm := by
rw [← Iso.inv_comp_eq]
refine Multicoequalizer.hom_ext _ _ _ fun i ↦ ?_
conv_lhs => rw [← ι.eq_def]
dsimp
simp [cocone, ← hm, glueDataι_naturality,
← GlueData.ι_isoLocallyRingedSpace_inv, -ι_gluedIso_inv_assoc, -ι_gluedIso_inv]
instance : HasColimit F := ⟨_, isColimit F⟩
instance : PreservesColimit F Scheme.forgetToLocallyRingedSpace :=
preservesColimit_of_preserves_colimit_cocone (isColimit F) (isColimitForgetToLocallyRingedSpace F)
instance : CreatesColimit F Scheme.forgetToLocallyRingedSpace :=
CategoryTheory.createsColimitOfReflectsIsomorphismsOfPreserves
/-- The open cover of the colimit of a locally directed diagram by the components. -/
@[simps! I₀ X f]
def openCover : (colimit F).OpenCover :=
Cover.copy ((coverOfIsIso ((isColimit F).coconePointUniqueUpToIso (colimit.isColimit F)).hom).bind
fun i ↦ (glueData F).openCover) J F.obj (colimit.ι F)
((equivShrink J).trans <| (Equiv.uniqueSigma fun (_ : Unit) ↦ Shrink J).symm)
(fun _ ↦ F.mapIso (eqToIso (by simp [GlueData.openCover, glueData]))) fun i ↦ by
change colimit.ι F i = _ ≫ (glueData F).ι (equivShrink J i) ≫ _
simp [← Category.assoc, ← Iso.comp_inv_eq, cocone]
instance (i) : IsOpenImmersion (colimit.ι F i) :=
inferInstanceAs (IsOpenImmersion ((openCover F).f i))
lemma ι_eq_ι_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :
colimit.ι F i xi = colimit.ι F j xj ↔
∃ k fi fj, ∃ (x : F.obj k), F.map fi x = xi ∧ F.map fj x = xj := by
constructor; swap
· rintro ⟨k, fi, fj, x, rfl, rfl⟩; simp only [← Scheme.Hom.comp_apply, colimit.w]
obtain ⟨i, rfl⟩ := (equivShrink J).symm.surjective i
obtain ⟨j, rfl⟩ := (equivShrink J).symm.surjective j
rw [← ((isColimit F).coconePointUniqueUpToIso
(colimit.isColimit F)).inv.isOpenEmbedding.injective.eq_iff]
simp only [Limits.colimit, ← Scheme.Hom.comp_apply,
colimit.comp_coconePointUniqueUpToIso_inv, cocone, glueDataι_naturality]
refine ?_ ∘ ((glueData F).ι_eq_iff _ _ _ _).mp
dsimp only [GlueData.Rel]
rintro ⟨x, rfl, rfl⟩
obtain ⟨⟨k, ki, kj⟩, y, hy : F.map ki y = (glueData F).f i j x⟩ := mem_iSup.mp x.2
refine ⟨k, ki, kj, y, hy, ?_⟩
obtain ⟨k, rfl⟩ := (equivShrink J).symm.surjective k
apply ((glueData F).ι _).isOpenEmbedding.injective
simp only [← Scheme.Hom.comp_apply, Category.assoc, GlueData.glue_condition]
trans (glueData F).ι k y
· simp [← glueDataι_naturality F kj]; rfl
· simp [← glueDataι_naturality F ki, ← hy]; rfl
instance (F : WidePushoutShape J ⥤ Scheme.{u}) [∀ {i j} (f : i ⟶ j), IsOpenImmersion (F.map f)] :
(F ⋙ forget).IsLocallyDirected :=
have (i : _) : Mono ((F ⋙ forget).map (.init i)) :=
(mono_iff_injective _).mpr (F.map _).isOpenEmbedding.injective
inferInstance
end IsLocallyDirected
end IsLocallyDirected
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Spec.lean | import Mathlib.Geometry.RingedSpace.LocallyRingedSpace
import Mathlib.AlgebraicGeometry.StructureSheaf
import Mathlib.RingTheory.Localization.LocalizationLocalization
import Mathlib.Topology.Sheaves.SheafCondition.Sites
import Mathlib.Topology.Sheaves.Functors
import Mathlib.Algebra.Module.LocalizedModule.Basic
/-!
# $Spec$ as a functor to locally ringed spaces.
We define the functor $Spec$ from commutative rings to locally ringed spaces.
## Implementation notes
We define $Spec$ in three consecutive steps, each with more structure than the last:
1. `Spec.toTop`, valued in the category of topological spaces,
2. `Spec.toSheafedSpace`, valued in the category of sheafed spaces and
3. `Spec.toLocallyRingedSpace`, valued in the category of locally ringed spaces.
Additionally, we provide `Spec.toPresheafedSpace` as a composition of `Spec.toSheafedSpace` with
a forgetful functor.
## Related results
The adjunction `Γ ⊣ Spec` is constructed in `Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
noncomputable section
universe u v
namespace AlgebraicGeometry
open Opposite
open CategoryTheory
open StructureSheaf
open Spec (structureSheaf)
/-- The spectrum of a commutative ring, as a topological space.
-/
def Spec.topObj (R : CommRingCat.{u}) : TopCat :=
TopCat.of (PrimeSpectrum R)
@[simp] theorem Spec.topObj_forget {R} : ToType (Spec.topObj R) = PrimeSpectrum R :=
rfl
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of topological spaces.
-/
def Spec.topMap {R S : CommRingCat.{u}} (f : R ⟶ S) : Spec.topObj S ⟶ Spec.topObj R :=
TopCat.ofHom (PrimeSpectrum.comap f.hom)
@[simp]
theorem Spec.topMap_id (R : CommRingCat.{u}) : Spec.topMap (𝟙 R) = 𝟙 (Spec.topObj R) :=
rfl
@[simp]
theorem Spec.topMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.topMap (f ≫ g) = Spec.topMap g ≫ Spec.topMap f :=
rfl
-- Porting note: `simps!` generate some garbage lemmas, so choose manually,
-- if more is needed, add them here
/-- The spectrum, as a contravariant functor from commutative rings to topological spaces.
-/
@[simps!]
def Spec.toTop : CommRingCat.{u}ᵒᵖ ⥤ TopCat where
obj R := Spec.topObj (unop R)
map {_ _} f := Spec.topMap f.unop
/-- The spectrum of a commutative ring, as a `SheafedSpace`.
-/
@[simps]
def Spec.sheafedSpaceObj (R : CommRingCat.{u}) : SheafedSpace CommRingCat where
carrier := Spec.topObj R
presheaf := (structureSheaf R).1
IsSheaf := (structureSheaf R).2
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of sheafed spaces.
-/
@[simps base c_app]
def Spec.sheafedSpaceMap {R S : CommRingCat.{u}} (f : R ⟶ S) :
Spec.sheafedSpaceObj S ⟶ Spec.sheafedSpaceObj R where
base := Spec.topMap f
c :=
{ app := fun U => CommRingCat.ofHom <|
comap f.hom (unop U) ((TopologicalSpace.Opens.map (Spec.topMap f)).obj (unop U)) fun _ => id
naturality := fun {_ _} _ => by ext; rfl }
@[simp]
theorem Spec.sheafedSpaceMap_id {R : CommRingCat.{u}} :
Spec.sheafedSpaceMap (𝟙 R) = 𝟙 (Spec.sheafedSpaceObj R) :=
AlgebraicGeometry.PresheafedSpace.Hom.ext _ _ (Spec.topMap_id R) <| by
ext
dsimp
rw [comap_id (by simp)]
simp
rfl
theorem Spec.sheafedSpaceMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.sheafedSpaceMap (f ≫ g) = Spec.sheafedSpaceMap g ≫ Spec.sheafedSpaceMap f :=
AlgebraicGeometry.PresheafedSpace.Hom.ext _ _ (Spec.topMap_comp f g) <| by
ext
-- Porting note: was one liner
-- `dsimp, rw category_theory.functor.map_id, rw category.comp_id, erw comap_comp f g, refl`
rw [NatTrans.comp_app, sheafedSpaceMap_c_app, Functor.whiskerRight_app, eqToHom_refl]
erw [(sheafedSpaceObj T).presheaf.map_id]
dsimp only [CommRingCat.hom_comp, RingHom.coe_comp, Function.comp_apply]
rw [comap_comp]
rfl
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCat.{u}ᵒᵖ ⥤ SheafedSpace CommRingCat where
obj R := Spec.sheafedSpaceObj (unop R)
map f := Spec.sheafedSpaceMap f.unop
map_comp f g := by simp [Spec.sheafedSpaceMap_comp]
/-- Spec, as a contravariant functor from commutative rings to presheafed spaces.
-/
def Spec.toPresheafedSpace : CommRingCat.{u}ᵒᵖ ⥤ PresheafedSpace CommRingCat :=
Spec.toSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace
@[simp]
theorem Spec.toPresheafedSpace_obj (R : CommRingCat.{u}ᵒᵖ) :
Spec.toPresheafedSpace.obj R = (Spec.sheafedSpaceObj (unop R)).toPresheafedSpace :=
rfl
theorem Spec.toPresheafedSpace_obj_op (R : CommRingCat.{u}) :
Spec.toPresheafedSpace.obj (op R) = (Spec.sheafedSpaceObj R).toPresheafedSpace :=
rfl
@[simp]
theorem Spec.toPresheafedSpace_map (R S : CommRingCat.{u}ᵒᵖ) (f : R ⟶ S) :
Spec.toPresheafedSpace.map f = Spec.sheafedSpaceMap f.unop :=
rfl
theorem Spec.toPresheafedSpace_map_op (R S : CommRingCat.{u}) (f : R ⟶ S) :
Spec.toPresheafedSpace.map f.op = Spec.sheafedSpaceMap f :=
rfl
theorem Spec.basicOpen_hom_ext {X : RingedSpace.{u}} {R : CommRingCat.{u}}
{α β : X ⟶ Spec.sheafedSpaceObj R} (w : α.base = β.base)
(h : ∀ r : R,
let U := PrimeSpectrum.basicOpen r
(toOpen R U ≫ α.c.app (op U)) ≫ X.presheaf.map (eqToHom (by rw [w])) =
toOpen R U ≫ β.c.app (op U)) :
α = β := by
ext : 1
· exact w
· apply
((TopCat.Sheaf.pushforward _ β.base).obj X.sheaf).hom_ext _ PrimeSpectrum.isBasis_basic_opens
intro r
apply (StructureSheaf.to_basicOpen_epi R r).1
simpa using h r
-- `simps!` generates some garbage lemmas, so choose manually,
-- if more is needed, add them here
/-- The spectrum of a commutative ring, as a `LocallyRingedSpace`. -/
@[simps! toSheafedSpace presheaf]
def Spec.locallyRingedSpaceObj (R : CommRingCat.{u}) : LocallyRingedSpace :=
{ Spec.sheafedSpaceObj R with
isLocalRing := fun x =>
RingEquiv.isLocalRing (A := Localization.AtPrime x.asIdeal)
(Iso.commRingCatIsoToRingEquiv <| stalkIso R x).symm }
lemma Spec.locallyRingedSpaceObj_sheaf (R : CommRingCat.{u}) :
(Spec.locallyRingedSpaceObj R).sheaf = structureSheaf R := rfl
lemma Spec.locallyRingedSpaceObj_sheaf' (R : Type u) [CommRing R] :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).sheaf = structureSheaf R := rfl
lemma Spec.locallyRingedSpaceObj_presheaf_map (R : CommRingCat.{u}) {U V} (i : U ⟶ V) :
(Spec.locallyRingedSpaceObj R).presheaf.map i =
(structureSheaf R).1.map i := rfl
lemma Spec.locallyRingedSpaceObj_presheaf' (R : Type u) [CommRing R] :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).presheaf = (structureSheaf R).1 := rfl
lemma Spec.locallyRingedSpaceObj_presheaf_map' (R : Type u) [CommRing R] {U V} (i : U ⟶ V) :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).presheaf.map i =
(structureSheaf R).1.map i := rfl
@[elementwise]
theorem stalkMap_toStalk {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
toStalk R (PrimeSpectrum.comap f.hom p) ≫ (Spec.sheafedSpaceMap f).stalkMap p =
f ≫ toStalk S p := by
rw [← toOpen_germ S ⊤ p trivial, ← toOpen_germ R ⊤ (PrimeSpectrum.comap f.hom p) trivial,
Category.assoc]
erw [PresheafedSpace.stalkMap_germ (Spec.sheafedSpaceMap f) ⊤ p trivial]
rw [Spec.sheafedSpaceMap_c_app]
erw [toOpen_comp_comap_assoc]
rfl
/-- Under the isomorphisms `stalkIso`, the map `stalkMap (Spec.sheafedSpaceMap f) p` corresponds
to the induced local ring homomorphism `Localization.localRingHom`.
-/
@[elementwise]
theorem localRingHom_comp_stalkIso {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
(stalkIso R (PrimeSpectrum.comap f.hom p)).hom ≫
(CommRingCat.ofHom (Localization.localRingHom (PrimeSpectrum.comap f.hom p).asIdeal p.asIdeal
f.hom rfl)) ≫
(stalkIso S p).inv =
(Spec.sheafedSpaceMap f).stalkMap p :=
(stalkIso R (PrimeSpectrum.comap f.hom p)).eq_inv_comp.mp <|
(stalkIso S p).comp_inv_eq.mpr <| CommRingCat.hom_ext <|
Localization.localRingHom_unique _ _ _ (PrimeSpectrum.comap_asIdeal _ _) fun x => by
-- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644 and https://github.com/leanprover-community/mathlib4/pull/8386
rw [stalkIso_hom, stalkIso_inv, CommRingCat.comp_apply, CommRingCat.comp_apply,
localizationToStalk_of, stalkMap_toStalk_apply f p x]
erw [stalkToFiberRingHom_toStalk]
rfl
/-- Version of `localRingHom_comp_stalkIso_apply` using `CommRingCat.Hom.hom` -/
theorem localRingHom_comp_stalkIso_apply' {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S)
(x) :
(stalkIso S p).inv ((Localization.localRingHom (PrimeSpectrum.comap f.hom p).asIdeal p.asIdeal
f.hom rfl) ((stalkIso R (PrimeSpectrum.comap f.hom p)).hom x)) =
(Spec.sheafedSpaceMap f).stalkMap p x :=
localRingHom_comp_stalkIso_apply _ _ _
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps toShHom]
def Spec.locallyRingedSpaceMap {R S : CommRingCat.{u}} (f : R ⟶ S) :
Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
IsLocalHom.mk fun a ha => by
-- Here, we are showing that the map on prime spectra induced by `f` is really a morphism of
-- *locally* ringed spaces, i.e. that the induced map on the stalks is a local ring
-- homomorphism.
erw [← localRingHom_comp_stalkIso_apply' f p a] at ha
have : IsLocalHom (stalkIso (↑S) p).inv.hom := isLocalHom_of_isIso _
replace ha := (isUnit_map_iff (stalkIso S p).inv.hom _).mp ha
replace ha := IsLocalHom.map_nonunit
((stalkIso R ((PrimeSpectrum.comap f.hom) p)).hom a) ha
convert RingHom.isUnit_map (stalkIso R (PrimeSpectrum.comap f.hom p)).inv.hom ha
rw [← CommRingCat.comp_apply, Iso.hom_inv_id, CommRingCat.id_apply]
@[simp]
theorem Spec.locallyRingedSpaceMap_id (R : CommRingCat.{u}) :
Spec.locallyRingedSpaceMap (𝟙 R) = 𝟙 (Spec.locallyRingedSpaceObj R) :=
LocallyRingedSpace.Hom.ext' <| by
rw [Spec.locallyRingedSpaceMap_toShHom, Spec.sheafedSpaceMap_id]; rfl
theorem Spec.locallyRingedSpaceMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.locallyRingedSpaceMap (f ≫ g) =
Spec.locallyRingedSpaceMap g ≫ Spec.locallyRingedSpaceMap f :=
LocallyRingedSpace.Hom.ext' <| by
rw [Spec.locallyRingedSpaceMap_toShHom, Spec.sheafedSpaceMap_comp]; rfl
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCat.{u}ᵒᵖ ⥤ LocallyRingedSpace where
obj R := Spec.locallyRingedSpaceObj (unop R)
map f := Spec.locallyRingedSpaceMap f.unop
map_id R := by dsimp; rw [Spec.locallyRingedSpaceMap_id]
map_comp f g := by dsimp; rw [Spec.locallyRingedSpaceMap_comp]
section SpecΓ
open AlgebraicGeometry.LocallyRingedSpace
/-- The counit morphism `R ⟶ Γ(Spec R)` given by `AlgebraicGeometry.StructureSheaf.toOpen`. -/
def toSpecΓ (R : CommRingCat.{u}) : R ⟶ Γ.obj (op (Spec.toLocallyRingedSpace.obj (op R))) :=
StructureSheaf.toOpen R ⊤
instance isIso_toSpecΓ (R : CommRingCat.{u}) : IsIso (toSpecΓ R) := by
cases R; apply StructureSheaf.isIso_to_global
@[reassoc]
theorem Spec_Γ_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op := by
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): `ext` failed to pick up one of the three lemmas
ext : 2
refine Subtype.ext <| funext fun x' => ?_; symm
apply Localization.localRingHom_to_map
/-- The counit (`SpecΓIdentity.inv.op`) of the adjunction `Γ ⊣ Spec` is an isomorphism. -/
@[simps! hom_app inv_app]
def LocallyRingedSpace.SpecΓIdentity : Spec.toLocallyRingedSpace.rightOp ⋙ Γ ≅ 𝟭 _ :=
Iso.symm <| NatIso.ofComponents.{u,u,u+1,u+1} (fun R =>
letI : IsIso (toSpecΓ R) := StructureSheaf.isIso_to_global _
asIso (toSpecΓ R)) fun {X Y} f => by convert Spec_Γ_naturality (R := X) (S := Y) f
end SpecΓ
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem isIso_SpecMap_stakMap_localization (R : CommRingCat.{u}) (M : Submonoid R)
(x : PrimeSpectrum (Localization M)) :
IsIso
((Spec.toPresheafedSpace.map
(CommRingCat.ofHom (algebraMap R (Localization M))).op).stalkMap x) := by
dsimp only [Spec.toPresheafedSpace_map, Quiver.Hom.unop_op]
rw [← localRingHom_comp_stalkIso]
refine IsIso.comp_isIso' inferInstance (IsIso.comp_isIso' ?_ inferInstance)
/- I do not know why this is defeq to the goal, but I'm happy to accept that it is. -/
change
IsIso (IsLocalization.localizationLocalizationAtPrimeIsoLocalization M
x.asIdeal).toRingEquiv.toCommRingCatIso.hom
infer_instance
@[deprecated (since := "2025-10-11")]
alias Spec_map_localization_isIso := isIso_SpecMap_stakMap_localization
namespace StructureSheaf
variable {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum R)
/-- For an algebra `f : R →+* S`, this is the ring homomorphism `S →+* (f∗ 𝒪ₛ)ₚ` for a `p : Spec R`.
This is shown to be the localization at `p` in `isLocalizedModule_toPushforwardStalkAlgHom`.
-/
def toPushforwardStalk : S ⟶ (Spec.topMap f _* (structureSheaf S).1).stalk p :=
StructureSheaf.toOpen S ⊤ ≫
@TopCat.Presheaf.germ _ _ _ _ (Spec.topMap f _* (structureSheaf S).1) ⊤ p trivial
@[reassoc]
theorem toPushforwardStalk_comp :
f ≫ StructureSheaf.toPushforwardStalk f p =
StructureSheaf.toStalk R p ≫
(TopCat.Presheaf.stalkFunctor _ _).map (Spec.sheafedSpaceMap f).c := by
rw [StructureSheaf.toStalk, Category.assoc, TopCat.Presheaf.stalkFunctor_map_germ]
exact Spec_Γ_naturality_assoc f _
instance : Algebra R ((Spec.topMap f _* (structureSheaf S).1).stalk p) :=
(f ≫ StructureSheaf.toPushforwardStalk f p).hom.toAlgebra
theorem algebraMap_pushforward_stalk :
algebraMap R ((Spec.topMap f _* (structureSheaf S).1).stalk p) =
(f ≫ StructureSheaf.toPushforwardStalk f p).hom :=
rfl
variable (R S)
variable [Algebra R S]
/--
This is the `AlgHom` version of `toPushforwardStalk`, which is the map `S ⟶ (f∗ 𝒪ₛ)ₚ` for some
algebra `R ⟶ S` and some `p : Spec R`.
-/
@[simps!]
def toPushforwardStalkAlgHom :
S →ₐ[R] (Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).1).stalk p :=
{ (StructureSheaf.toPushforwardStalk (CommRingCat.ofHom (algebraMap R S)) p).hom with
commutes' := fun _ => rfl }
theorem isLocalizedModule_toPushforwardStalkAlgHom_aux (y) :
∃ x : S × p.asIdeal.primeCompl, x.2 • y = toPushforwardStalkAlgHom R S p x.1 := by
obtain ⟨U, hp, s, e⟩ := TopCat.Presheaf.germ_exist _ _ y
obtain ⟨_, ⟨r, rfl⟩, hpr : p ∈ PrimeSpectrum.basicOpen r, hrU : PrimeSpectrum.basicOpen r ≤ U⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open (show p ∈ U from hp) U.2
change PrimeSpectrum.basicOpen r ≤ U at hrU
replace e :=
((Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).1).germ_res_apply
(homOfLE hrU) p hpr _).trans e
set s' := (Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).1).map
(homOfLE hrU).op s with h
replace e : ((Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).val).germ _
p hpr) s' = y := by
rw [h]; exact e
clear_value s'; clear! U
obtain ⟨⟨s, ⟨_, n, rfl⟩⟩, hsn⟩ :=
@IsLocalization.surj _ _ _ _ _ _
(StructureSheaf.IsLocalization.to_basicOpen S <| algebraMap R S r) s'
refine ⟨⟨s, ⟨r, hpr⟩ ^ n⟩, ?_⟩
rw [Submonoid.smul_def, Algebra.smul_def, algebraMap_pushforward_stalk, toPushforwardStalk,
CommRingCat.comp_apply, CommRingCat.comp_apply]
iterate 2
erw [← (Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).1).germ_res_apply
(homOfLE le_top) p hpr]
rw [← e]
let f := TopCat.Presheaf.germ (Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _*
(structureSheaf S).val) _ p hpr
rw [← map_mul, mul_comm]
dsimp only [Subtype.coe_mk] at hsn
rw [← map_pow (algebraMap R S)] at hsn
congr 1
instance isLocalizedModule_toPushforwardStalkAlgHom :
IsLocalizedModule p.asIdeal.primeCompl (toPushforwardStalkAlgHom R S p).toLinearMap := by
apply IsLocalizedModule.mkOfAlgebra
· intro x hx; rw [algebraMap_pushforward_stalk, toPushforwardStalk_comp]
change IsUnit ((TopCat.Presheaf.stalkFunctor CommRingCat p).map
(Spec.sheafedSpaceMap (CommRingCat.ofHom (algebraMap ↑R ↑S))).c _)
exact (IsLocalization.map_units ((structureSheaf R).presheaf.stalk p) ⟨x, hx⟩).map _
· apply isLocalizedModule_toPushforwardStalkAlgHom_aux
· intro x hx
rw [toPushforwardStalkAlgHom_apply,
← (toPushforwardStalk (CommRingCat.ofHom (algebraMap ↑R ↑S)) p).hom.map_zero,
toPushforwardStalk] at hx
rw [CommRingCat.comp_apply, map_zero] at hx
obtain ⟨U, hpU, i₁, i₂, e⟩ := TopCat.Presheaf.germ_eq (C := CommRingCat) _ _ _ _ _ _ hx
obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open (show p ∈ U.1 from hpU)
U.2
apply_fun (Spec.topMap (CommRingCat.ofHom (algebraMap R S)) _* (structureSheaf S).1).map
(homOfLE hrU).op at e
simp only [map_zero] at e
have : toOpen S (PrimeSpectrum.basicOpen <| algebraMap R S r) x = 0 := by
refine Eq.trans ?_ e; rfl
have :=
(@IsLocalization.mk'_one _ _ _ _ _ _
(StructureSheaf.IsLocalization.to_basicOpen S <| algebraMap R S r) x).trans
this
obtain ⟨⟨_, n, rfl⟩, e⟩ := (IsLocalization.mk'_eq_zero_iff _ _).mp this
refine ⟨⟨r, hpr⟩ ^ n, ?_⟩
rw [Submonoid.smul_def, Algebra.smul_def, SubmonoidClass.coe_pow, map_pow]
exact e
end StructureSheaf
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Scheme.lean | import Mathlib.AlgebraicGeometry.Spec
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.CategoryTheory.Elementwise
/-!
# The category of schemes
A scheme is a locally ringed space such that every point is contained in some open set
where there is an isomorphism of presheaves between the restriction to that open set,
and the structure sheaf of `Spec R`, for some commutative ring `R`.
A morphism of schemes is just a morphism of the underlying locally ringed spaces.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
universe u
noncomputable section
open TopologicalSpace CategoryTheory TopCat Opposite
namespace AlgebraicGeometry
/-- We define `Scheme` as an `X : LocallyRingedSpace`,
along with a proof that every point has an open neighbourhood `U`
so that the restriction of `X` to `U` is isomorphic,
as a locally ringed space, to `Spec.toLocallyRingedSpace.obj (op R)`
for some `R : CommRingCat`.
-/
structure Scheme extends LocallyRingedSpace where
local_affine :
∀ x : toLocallyRingedSpace,
∃ (U : OpenNhds x) (R : CommRingCat),
Nonempty
(toLocallyRingedSpace.restrict U.isOpenEmbedding ≅ Spec.toLocallyRingedSpace.obj (op R))
namespace Scheme
instance : CoeSort Scheme Type* where
coe X := X.carrier
open Lean PrettyPrinter.Delaborator SubExpr in
/-- Pretty printer for coercing schemes to types. -/
@[app_delab TopCat.carrier]
partial def delabAdjoinNotation : Delab := whenPPOption getPPNotation do
guard <| (← getExpr).isAppOfArity ``TopCat.carrier 1
withNaryArg 0 do
guard <| (← getExpr).isAppOfArity ``PresheafedSpace.carrier 3
withNaryArg 2 do
guard <| (← getExpr).isAppOfArity ``SheafedSpace.toPresheafedSpace 3
withNaryArg 2 do
guard <| (← getExpr).isAppOfArity ``LocallyRingedSpace.toSheafedSpace 1
withNaryArg 0 do
guard <| (← getExpr).isAppOfArity ``Scheme.toLocallyRingedSpace 1
withNaryArg 0 do
`(↥$(← delab))
/-- The type of open sets of a scheme. -/
abbrev Opens (X : Scheme) : Type* := TopologicalSpace.Opens X
/-- A morphism between schemes is a morphism between the underlying locally ringed spaces. -/
structure Hom (X Y : Scheme)
extends toLRSHom' : X.toLocallyRingedSpace.Hom Y.toLocallyRingedSpace where
/-- Cast a morphism of schemes into morphisms of local ringed spaces. -/
abbrev Hom.toLRSHom {X Y : Scheme.{u}} (f : X.Hom Y) :
X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace :=
f.toLRSHom'
/-- See Note [custom simps projection] -/
def Hom.Simps.toLRSHom {X Y : Scheme.{u}} (f : X.Hom Y) :
X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace :=
f.toLRSHom
initialize_simps_projections Hom (toLRSHom' → toLRSHom)
/-- Schemes are a full subcategory of locally ringed spaces.
-/
instance : Category Scheme where
Hom := Hom
id X := Hom.mk (𝟙 X.toLocallyRingedSpace)
comp f g := Hom.mk (f.toLRSHom ≫ g.toLRSHom)
/-- `f ⁻¹ᵁ U` is notation for `(Opens.map f.base).obj U`, the preimage of an open set `U` under `f`.
The preferred name in lemmas is `preimage` and it should be treated as an infix. -/
scoped[AlgebraicGeometry] notation3:90 f:91 " ⁻¹ᵁ " U:90 =>
@Functor.obj (Scheme.Opens _) _ (Scheme.Opens _) _
(Opens.map (f : Scheme.Hom _ _).base) U
/-- `Γ(X, U)` is notation for `X.presheaf.obj (op U)`. -/
scoped[AlgebraicGeometry] notation3 "Γ(" X ", " U ")" =>
(PresheafedSpace.presheaf (SheafedSpace.toPresheafedSpace
(LocallyRingedSpace.toSheafedSpace (Scheme.toLocallyRingedSpace X)))).obj
(op (α := Scheme.Opens _) U)
instance {X Y : Scheme.{u}} : CoeFun (X ⟶ Y) (fun _ ↦ X → Y) where
coe f := f.base
instance {X : Scheme.{u}} : Subsingleton Γ(X, ⊥) :=
CommRingCat.subsingleton_of_isTerminal X.sheaf.isTerminalOfEmpty
@[continuity, fun_prop]
lemma Hom.continuous {X Y : Scheme} (f : X ⟶ Y) : Continuous f := f.base.hom.2
/-- The structure sheaf of a scheme. -/
protected abbrev sheaf (X : Scheme) :=
X.toSheafedSpace.sheaf
/--
We give schemes the specialization preorder by default.
-/
instance {X : Scheme.{u}} : Preorder X := specializationPreorder X
lemma le_iff_specializes {X : Scheme.{u}} {a b : X} : a ≤ b ↔ b ⤳ a := by rfl
open Order in
lemma height_of_isClosed {X : Scheme} {x : X} (hx : IsClosed {x}) : height x = 0 := by
simp only [height_eq_zero]
intro b _
obtain rfl | h := eq_or_ne b x
· assumption
· have := IsClosed.not_specializes hx rfl h
contradiction
namespace Hom
variable {X Y : Scheme.{u}} (f : X ⟶ Y) {U U' : Y.Opens} {V V' : X.Opens}
/-- Given a morphism of schemes `f : X ⟶ Y`, and open `U ⊆ Y`,
this is the induced map `Γ(Y, U) ⟶ Γ(X, f ⁻¹ᵁ U)`.
This is treated as a suffix in lemma names. -/
abbrev app (U : Y.Opens) : Γ(Y, U) ⟶ Γ(X, f ⁻¹ᵁ U) :=
f.c.app (op U)
/-- Given a morphism of schemes `f : X ⟶ Y`, this is the induced map `Γ(Y, ⊤) ⟶ Γ(X, ⊤)`.
This is treated as a suffix in lemma names. -/
abbrev appTop : Γ(Y, ⊤) ⟶ Γ(X, ⊤) :=
f.app ⊤
@[reassoc]
lemma naturality (i : op U' ⟶ op U) :
Y.presheaf.map i ≫ f.app U = f.app U' ≫ X.presheaf.map ((Opens.map f.base).map i.unop).op :=
f.c.naturality i
/-- Given a morphism of schemes `f : X ⟶ Y`, and open sets `U ⊆ Y`, `V ⊆ f ⁻¹' U`,
this is the induced map `Γ(Y, U) ⟶ Γ(X, V)`.
This is treated as a suffix in lemma names. -/
def appLE (U : Y.Opens) (V : X.Opens) (e : V ≤ f ⁻¹ᵁ U) : Γ(Y, U) ⟶ Γ(X, V) :=
f.app U ≫ X.presheaf.map (homOfLE e).op
@[reassoc (attr := simp)]
lemma appLE_map (e : V ≤ f ⁻¹ᵁ U) (i : op V ⟶ op V') :
f.appLE U V e ≫ X.presheaf.map i = f.appLE U V' (i.unop.le.trans e) := by
rw [Hom.appLE, Category.assoc, ← Functor.map_comp]
rfl
@[reassoc]
lemma appLE_map' (e : V ≤ f ⁻¹ᵁ U) (i : V = V') :
f.appLE U V' (i ▸ e) ≫ X.presheaf.map (eqToHom i).op = f.appLE U V e :=
appLE_map _ _ _
@[reassoc (attr := simp)]
lemma map_appLE (e : V ≤ f ⁻¹ᵁ U) (i : op U' ⟶ op U) :
Y.presheaf.map i ≫ f.appLE U V e =
f.appLE U' V (e.trans ((Opens.map f.base).map i.unop).le) := by
rw [Hom.appLE, f.naturality_assoc, ← Functor.map_comp]
rfl
@[reassoc]
lemma map_appLE' (e : V ≤ f ⁻¹ᵁ U) (i : U' = U) :
Y.presheaf.map (eqToHom i).op ≫ f.appLE U' V (i ▸ e) = f.appLE U V e :=
map_appLE _ _ _
lemma app_eq_appLE {U : Y.Opens} :
f.app U = f.appLE U _ le_rfl := by
simp [Hom.appLE]
lemma appLE_eq_app {U : Y.Opens} :
f.appLE U (f ⁻¹ᵁ U) le_rfl = f.app U :=
(app_eq_appLE f).symm
lemma appLE_congr (e : V ≤ f ⁻¹ᵁ U) (e₁ : U = U') (e₂ : V = V')
(P : ∀ {R S : CommRingCat.{u}} (_ : R ⟶ S), Prop) :
P (f.appLE U V e) ↔ P (f.appLE U' V' (e₁ ▸ e₂ ▸ e)) := by
subst e₁; subst e₂; rfl
/-- A morphism of schemes `f : X ⟶ Y` induces a local ring homomorphism from
`Y.presheaf.stalk (f x)` to `X.presheaf.stalk x` for any `x : X`. -/
def stalkMap (x : X) : Y.presheaf.stalk (f x) ⟶ X.presheaf.stalk x :=
f.toLRSHom.stalkMap x
protected lemma ext {f g : X ⟶ Y} (h_base : f.base = g.base)
(h_app : ∀ U, f.app U ≫ X.presheaf.map
(eqToHom congr((Opens.map $h_base.symm).obj U)).op = g.app U) : f = g := by
cases f; cases g; congr 1
exact LocallyRingedSpace.Hom.ext' <| SheafedSpace.ext _ _ h_base
(TopCat.Presheaf.ext fun U ↦ by simpa using h_app U)
/-- An alternative ext lemma for scheme morphisms. -/
protected lemma ext' {f g : X ⟶ Y} (h : f.toLRSHom = g.toLRSHom) : f = g := by
cases f; cases g; congr 1
@[simp]
lemma mem_preimage {x : X} {U : Opens Y} : x ∈ f ⁻¹ᵁ U ↔ f x ∈ U := .rfl
lemma coe_preimage {U : Opens Y} : f ⁻¹ᵁ U = f ⁻¹' U := rfl
lemma preimage_sup {U V : Opens Y} : f ⁻¹ᵁ (U ⊔ V) = f ⁻¹ᵁ U ⊔ f ⁻¹ᵁ V := rfl
lemma preimage_inf {U V : Opens Y} : f ⁻¹ᵁ (U ⊓ V) = f ⁻¹ᵁ U ⊓ f ⁻¹ᵁ V := rfl
@[simp] lemma preimage_top : f ⁻¹ᵁ ⊤ = ⊤ := rfl
@[simp] lemma preimage_bot : f ⁻¹ᵁ ⊥ = ⊥ := rfl
lemma preimage_iSup {ι} (U : ι → Opens Y) : f ⁻¹ᵁ iSup U = ⨆ i, f ⁻¹ᵁ U i :=
Opens.ext (by simp)
lemma iSup_preimage_eq_top {ι} {U : ι → Opens Y} (hU : iSup U = ⊤) :
⨆ i, f ⁻¹ᵁ U i = ⊤ := f.preimage_iSup U ▸ hU ▸ rfl
@[deprecated (since := "2025-10-07")] alias preimage_iSup_eq_top := iSup_preimage_eq_top
lemma preimage_mono {U U' : Y.Opens} (hUU' : U ≤ U') :
f ⁻¹ᵁ U ≤ f ⁻¹ᵁ U' :=
fun _ ha ↦ hUU' ha
@[deprecated (since := "2025-10-07")] alias preimage_le_preimage_of_le := preimage_mono
lemma id_preimage (U : X.Opens) : (𝟙 X) ⁻¹ᵁ U = U := rfl
@[simp]
lemma comp_preimage {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g) ⁻¹ᵁ U = f ⁻¹ᵁ g ⁻¹ᵁ U := rfl
end Hom
@[deprecated (since := "2025-10-07")] alias preimage_comp := Hom.comp_preimage
/-- The forgetful functor from `Scheme` to `LocallyRingedSpace`. -/
@[simps!]
def forgetToLocallyRingedSpace : Scheme ⥤ LocallyRingedSpace where
obj := toLocallyRingedSpace
map := Hom.toLRSHom
/-- The forget functor `Scheme ⥤ LocallyRingedSpace` is fully faithful. -/
@[simps preimage_toLRSHom]
def fullyFaithfulForgetToLocallyRingedSpace :
forgetToLocallyRingedSpace.FullyFaithful where
preimage := Hom.mk
instance : forgetToLocallyRingedSpace.Full :=
fullyFaithfulForgetToLocallyRingedSpace.full
instance : forgetToLocallyRingedSpace.Faithful :=
fullyFaithfulForgetToLocallyRingedSpace.faithful
/-- The forgetful functor from `Scheme` to `TopCat`. -/
@[simps!]
def forgetToTop : Scheme ⥤ TopCat :=
Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToTop
/-- An isomorphism of schemes induces a homeomorphism of the underlying topological spaces. -/
noncomputable def homeoOfIso {X Y : Scheme.{u}} (e : X ≅ Y) : X ≃ₜ Y :=
TopCat.homeoOfIso (forgetToTop.mapIso e)
@[simp]
lemma coe_homeoOfIso {X Y : Scheme.{u}} (e : X ≅ Y) :
⇑(homeoOfIso e) = e.hom := rfl
@[simp]
lemma coe_homeoOfIso_symm {X Y : Scheme.{u}} (e : X ≅ Y) :
⇑(homeoOfIso e.symm) = e.inv := rfl
@[simp]
lemma homeoOfIso_symm {X Y : Scheme} (e : X ≅ Y) :
(homeoOfIso e).symm = homeoOfIso e.symm := rfl
lemma homeoOfIso_apply {X Y : Scheme} (e : X ≅ Y) (x : X) :
homeoOfIso e x = e.hom x := rfl
alias _root_.CategoryTheory.Iso.schemeIsoToHomeo := homeoOfIso
/-- An isomorphism of schemes induces a homeomorphism of the underlying topological spaces. -/
noncomputable def Hom.homeomorph {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso (C := Scheme) f] :
X ≃ₜ Y :=
(asIso f).schemeIsoToHomeo
@[simp]
lemma Hom.homeomorph_apply {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso (C := Scheme) f] (x) :
f.homeomorph x = f x := rfl
instance hasCoeToTopCat : CoeOut Scheme TopCat where
coe X := X.carrier
/-- forgetful functor to `TopCat` is the same as coercion -/
unif_hint forgetToTop_obj_eq_coe (X : Scheme) where ⊢
forgetToTop.obj X ≟ (X : TopCat)
/-- The forgetful functor from `Scheme` to `Type`. -/
nonrec def forget : Scheme.{u} ⥤ Type u := Scheme.forgetToTop ⋙ forget TopCat
/-- forgetful functor to `Scheme` is the same as coercion -/
-- Schemes are often coerced as types, and it would be useful to have definitionally equal types
-- to be reducibly equal. The alternative is to make `forget` reducible but that option has
-- poor performance consequences.
unif_hint forget_obj_eq_coe (X : Scheme) where ⊢
forget.obj X ≟ (X : Type*)
@[simp] lemma forget_obj (X) : Scheme.forget.obj X = X := rfl
@[simp] lemma forget_map {X Y} (f : X ⟶ Y) : forget.map f = f := rfl
namespace Hom
@[simp]
theorem id_base (X : Scheme) : (𝟙 X :).base = 𝟙 _ :=
rfl
@[simp]
theorem id_app {X : Scheme} (U : X.Opens) :
(𝟙 X :).app U = 𝟙 _ := rfl
@[simp]
theorem id_appTop {X : Scheme} :
(𝟙 X :).appTop = 𝟙 _ :=
rfl
@[reassoc]
theorem comp_toLRSHom {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).toLRSHom = f.toLRSHom ≫ g.toLRSHom :=
rfl
@[simp, reassoc]
theorem comp_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).base = f.base ≫ g.base :=
rfl
theorem comp_apply {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(f ≫ g) x = g (f x) := by
simp
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_app {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g).app U = g.app U ≫ f.app _ :=
rfl
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_appTop {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).appTop = g.appTop ≫ f.appTop :=
rfl
@[reassoc]
theorem appLE_comp_appLE {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U V W e₁ e₂) :
g.appLE U V e₁ ≫ f.appLE V W e₂ =
(f ≫ g).appLE U W (e₂.trans ((Opens.map f.base).map (homOfLE e₁)).le) := by
dsimp [Hom.appLE]
rw [Category.assoc, f.naturality_assoc, ← Functor.map_comp]
rfl
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_appLE {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U V e) :
(f ≫ g).appLE U V e = g.app U ≫ f.appLE _ V e := by
rw [g.app_eq_appLE, appLE_comp_appLE]
theorem congr_app {X Y : Scheme} {f g : X ⟶ Y} (e : f = g) (U) :
f.app U = g.app U ≫ X.presheaf.map (eqToHom (by subst e; rfl)).op := by
subst e; simp
theorem app_eq {X Y : Scheme} (f : X ⟶ Y) {U V : Y.Opens} (e : U = V) :
f.app U =
Y.presheaf.map (eqToHom e.symm).op ≫ f.app V ≫ X.presheaf.map (eqToHom (e ▸ rfl)).op := by
aesop
theorem eqToHom_app {X Y : Scheme} (e : X = Y) (U) :
(eqToHom e).app U = eqToHom (by subst e; rfl) := by subst e; rfl
instance isIso_toLRSHom {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : IsIso f.toLRSHom :=
forgetToLocallyRingedSpace.map_isIso f
instance isIso_base {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : IsIso f.base :=
Scheme.forgetToTop.map_isIso f
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U) : IsIso (f.app U) :=
haveI := PresheafedSpace.c_isIso_of_iso f.toPshHom
NatIso.isIso_app_of_isIso f.c _
@[simp]
theorem inv_app {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U : X.Opens) :
(inv f).app U =
X.presheaf.map (eqToHom (show (f ≫ inv f) ⁻¹ᵁ U = U by rw [IsIso.hom_inv_id]; rfl)).op ≫
inv (f.app ((inv f) ⁻¹ᵁ U)) := by
rw [IsIso.eq_comp_inv, ← comp_app, congr_app (IsIso.hom_inv_id f), id_app, Category.id_comp]
theorem inv_appTop {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
(inv f).appTop = inv f.appTop := by simp
/-- Copies a morphism with a different underlying map -/
def copyBase {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) : X ⟶ Y where
base := TopCat.ofHom ⟨g, h ▸ f.base.1.2⟩
c := f.c ≫ (TopCat.Presheaf.pushforwardEq (by subst h; rfl) _).hom
prop x := by
subst h
convert f.prop x using 4
cat_disch
lemma copyBase_eq {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) :
f.copyBase g h = f := by
subst h
obtain ⟨⟨⟨f₁, f₂⟩, f₃⟩, f₄⟩ := f
simp only [Hom.copyBase, LocallyRingedSpace.Hom.toShHom_mk]
congr
cat_disch
end Hom
@[deprecated (since := "2025-10-07")] alias id.base := Hom.id_base
@[deprecated (since := "2025-10-07")] alias id_app := Hom.id_app
@[deprecated (since := "2025-10-07")] alias id_appTop := Hom.id_appTop
@[deprecated (since := "2025-10-07")] alias comp_toLRSHom := Hom.comp_toLRSHom
@[deprecated (since := "2025-10-07")] alias comp_toLRSHom_assoc := Hom.comp_toLRSHom_assoc
@[deprecated (since := "2025-10-07")] alias comp_coeBase := Hom.comp_base
@[deprecated (since := "2025-10-07")] alias comp_coeBase_assoc := Hom.comp_base_assoc
@[deprecated (since := "2025-10-07")] alias comp_base := Hom.comp_base
@[deprecated (since := "2025-10-07")] alias comp_base_assoc := Hom.comp_base_assoc
@[deprecated (since := "2025-10-07")] alias comp_base_apply := Hom.comp_apply
@[deprecated (since := "2025-10-07")] alias comp_app := Hom.comp_app
@[deprecated (since := "2025-10-07")] alias comp_app_assoc := Hom.comp_app_assoc
@[deprecated (since := "2025-10-07")] alias comp_appTop := Hom.comp_appTop
@[deprecated (since := "2025-10-07")] alias comp_appTop_assoc := Hom.comp_appTop_assoc
@[deprecated (since := "2025-10-07")] alias appLE_comp_appLE := Hom.appLE_comp_appLE
@[deprecated (since := "2025-10-07")] alias comp_appLE := Hom.comp_appLE
@[deprecated (since := "2025-10-07")] alias comp_appLE_assoc := Hom.comp_appLE_assoc
@[deprecated (since := "2025-10-07")] alias congr_app := Hom.congr_app
@[deprecated (since := "2025-10-07")] alias app_eq := Hom.app_eq
@[deprecated (since := "2025-10-07")] alias eqToHom_c_app := Hom.eqToHom_app
@[deprecated (since := "2025-10-07")] alias inv_app := Hom.inv_app
@[deprecated (since := "2025-10-07")] alias inv_appTop := Hom.inv_appTop
@[deprecated (since := "2025-10-07")] alias presheaf_map_eqToHom_op := eqToHom_map
end Scheme
/-- The spectrum of a commutative ring, as a scheme.
The notation `Spec(R)` for `(R : Type*) [CommRing R]` to mean `Spec (CommRingCat.of R)` is
enabled in the scope `SpecOfNotation`. Please do not use it within Mathlib, but it can be
used in downstream projects if desired. To use this, do:
```lean
import Mathlib.AlgebraicGeometry.Scheme
variable (R : Type*) [CommRing R]
open scoped SpecOfNotation
#check Spec(R)
```
-/
def Spec (R : CommRingCat) : Scheme where
local_affine _ := ⟨⟨⊤, trivial⟩, R, ⟨(Spec.toLocallyRingedSpace.obj (op R)).restrictTopIso⟩⟩
toLocallyRingedSpace := Spec.locallyRingedSpaceObj R
/-- The spectrum of an unbundled ring as a scheme.
WARNING: This is potentially confusing as `Spec (R)` and `Spec(R)` have different meanings.
Hence we avoid using it in mathlib but leave it as a scoped instance for downstream projects.
WARNING: If `R` is already an element of `CommRingCat`, you should use `Spec R` instead of
`Spec(R)`, which is secretly `Spec(↑R)`. -/
scoped[SpecOfNotation] notation3 "Spec("R")" => AlgebraicGeometry.Spec <| .of R
theorem Spec_toLocallyRingedSpace (R : CommRingCat) :
(Spec R).toLocallyRingedSpace = Spec.locallyRingedSpaceObj R :=
rfl
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of schemes. -/
def Spec.map {R S : CommRingCat} (f : R ⟶ S) : Spec S ⟶ Spec R :=
⟨Spec.locallyRingedSpaceMap f⟩
@[simp]
theorem Spec.map_id (R : CommRingCat) : Spec.map (𝟙 R) = 𝟙 (Spec R) :=
Scheme.Hom.ext' <| Spec.locallyRingedSpaceMap_id R
@[reassoc, simp]
theorem Spec.map_comp {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) :
Spec.map (f ≫ g) = Spec.map g ≫ Spec.map f :=
Scheme.Hom.ext' <| Spec.locallyRingedSpaceMap_comp f g
/-- The spectrum, as a contravariant functor from commutative rings to schemes. -/
@[simps]
protected def Scheme.Spec : CommRingCatᵒᵖ ⥤ Scheme where
obj R := Spec (unop R)
map f := Spec.map f.unop
map_id R := by simp
map_comp f g := by simp
lemma Spec.map_eqToHom {R S : CommRingCat} (e : R = S) :
Spec.map (eqToHom e) = eqToHom (e ▸ rfl) := by
subst e; exact Spec.map_id _
instance {R S : CommRingCat} (f : R ⟶ S) [IsIso f] : IsIso (Spec.map f) :=
inferInstanceAs (IsIso <| Scheme.Spec.map f.op)
@[simp]
lemma Spec.map_inv {R S : CommRingCat} (f : R ⟶ S) [IsIso f] :
Spec.map (inv f) = inv (Spec.map f) := by
change Scheme.Spec.map (inv f).op = inv (Scheme.Spec.map f.op)
rw [op_inv, ← Scheme.Spec.map_inv]
section
variable {R S : CommRingCat.{u}} (f : R ⟶ S)
-- The lemmas below are not tagged simp to respect the abstraction.
lemma Spec_carrier (R : CommRingCat.{u}) : (Spec R).carrier = PrimeSpectrum R := rfl
lemma Spec_sheaf (R : CommRingCat.{u}) : (Spec R).sheaf = Spec.structureSheaf R := rfl
lemma Spec_presheaf (R : CommRingCat.{u}) : (Spec R).presheaf = (Spec.structureSheaf R).1 := rfl
lemma Spec.map_base : (Spec.map f).base = ofHom (PrimeSpectrum.comap f.hom) := rfl
lemma Spec.map_apply (x : Spec S) : Spec.map f x = PrimeSpectrum.comap f.hom x := rfl
@[deprecated (since := "2025-10-07")] alias Spec.map_base_apply := Spec.map_apply
lemma Spec.map_app (U) :
(Spec.map f).app U =
CommRingCat.ofHom (StructureSheaf.comap f.hom U (Spec.map f ⁻¹ᵁ U) le_rfl) := rfl
lemma Spec.map_appLE {U V} (e : U ≤ Spec.map f ⁻¹ᵁ V) :
(Spec.map f).appLE V U e = CommRingCat.ofHom (StructureSheaf.comap f.hom V U e) := rfl
instance {A : CommRingCat} [Nontrivial A] : Nonempty (Spec A) :=
inferInstanceAs <| Nonempty (PrimeSpectrum A)
end
namespace Scheme
theorem isEmpty_of_commSq {W X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S}
{i : W ⟶ X} {j : W ⟶ Y} (h : CommSq i j f g)
(H : Disjoint (Set.range f) (Set.range g)) : IsEmpty W :=
⟨fun x ↦ (Set.disjoint_iff_inter_eq_empty.mp H).le
⟨⟨i x, congr($(h.w) x)⟩, ⟨j x, rfl⟩⟩⟩
/-- The empty scheme. -/
@[simps]
def empty : Scheme where
carrier := TopCat.of PEmpty
presheaf := (CategoryTheory.Functor.const _).obj (CommRingCat.of PUnit)
IsSheaf := Presheaf.isSheaf_of_isTerminal _ CommRingCat.punitIsTerminal
isLocalRing x := PEmpty.elim x
local_affine x := PEmpty.elim x
instance : EmptyCollection Scheme :=
⟨empty⟩
/-- The global sections as a functor. For the global section themselves, use `Γ(X, ⊤)` instead. -/
def Γ : Schemeᵒᵖ ⥤ CommRingCat :=
Scheme.forgetToLocallyRingedSpace.op ⋙ LocallyRingedSpace.Γ
theorem Γ_def : Γ = Scheme.forgetToLocallyRingedSpace.op ⋙ LocallyRingedSpace.Γ :=
rfl
@[simp]
theorem Γ_obj (X : Schemeᵒᵖ) : Γ.obj X = Γ(unop X, ⊤) :=
rfl
theorem Γ_obj_op (X : Scheme) : Γ.obj (op X) = Γ(X, ⊤) :=
rfl
@[simp]
theorem Γ_map {X Y : Schemeᵒᵖ} (f : X ⟶ Y) : Γ.map f = f.unop.appTop :=
rfl
theorem Γ_map_op {X Y : Scheme} (f : X ⟶ Y) : Γ.map f.op = f.appTop :=
rfl
/--
The counit (`SpecΓIdentity.inv.op`) of the adjunction `Γ ⊣ Spec` as a natural isomorphism.
This is almost never needed in practical use cases. Use `ΓSpecIso` instead.
-/
def SpecΓIdentity : Scheme.Spec.rightOp ⋙ Scheme.Γ ≅ 𝟭 _ :=
Iso.symm <| NatIso.ofComponents.{u,u,u+1,u+1}
(fun R => asIso (StructureSheaf.toOpen R ⊤))
(fun {X Y} f => by convert Spec_Γ_naturality (R := X) (S := Y) f)
variable (R : CommRingCat.{u})
/-- The global sections of `Spec R` is isomorphic to `R`. -/
def ΓSpecIso : Γ(Spec R, ⊤) ≅ R := SpecΓIdentity.app R
@[simp] lemma SpecΓIdentity_app : SpecΓIdentity.app R = ΓSpecIso R := rfl
@[simp] lemma SpecΓIdentity_hom_app : SpecΓIdentity.hom.app R = (ΓSpecIso R).hom := rfl
@[simp] lemma SpecΓIdentity_inv_app : SpecΓIdentity.inv.app R = (ΓSpecIso R).inv := rfl
@[reassoc (attr := simp)]
lemma ΓSpecIso_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
(Spec.map f).appTop ≫ (ΓSpecIso S).hom = (ΓSpecIso R).hom ≫ f := SpecΓIdentity.hom.naturality f
-- The RHS is not necessarily simpler than the LHS, but this direction coincides with the simp
-- direction of `NatTrans.naturality`.
@[reassoc (attr := simp)]
lemma ΓSpecIso_inv_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
f ≫ (ΓSpecIso S).inv = (ΓSpecIso R).inv ≫ (Spec.map f).appTop := SpecΓIdentity.inv.naturality f
-- This is not marked simp to respect the abstraction
lemma ΓSpecIso_inv : (ΓSpecIso R).inv = StructureSheaf.toOpen R ⊤ := rfl
lemma toOpen_eq (U) :
StructureSheaf.toOpen R U =
(ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op := rfl
instance {K} [Field K] : Unique <| Spec <| .of K :=
inferInstanceAs <| Unique (PrimeSpectrum K)
@[simp]
lemma default_asIdeal {K} [Field K] : (default : Spec (.of K)).asIdeal = ⊥ := rfl
section BasicOpen
variable (X : Scheme) {V U : X.Opens} (f g : Γ(X, U))
/-- The subset of the underlying space where the given section does not vanish. -/
def basicOpen : X.Opens :=
X.toLocallyRingedSpace.toRingedSpace.basicOpen f
theorem mem_basicOpen (x : X) (hx : x ∈ U) :
x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ U x hx f) :=
RingedSpace.mem_basicOpen _ _ _ _
/-- A variant of `mem_basicOpen` for bundled `x : U`. -/
@[simp]
theorem mem_basicOpen' (x : U) : ↑x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ U x x.2 f) :=
RingedSpace.mem_basicOpen _ _ _ _
/-- A variant of `mem_basicOpen` without the `x ∈ U` assumption. -/
theorem mem_basicOpen'' {U : X.Opens} (f : Γ(X, U)) (x : X) :
x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ U x m f) :=
Iff.rfl
theorem mem_basicOpen_top (f : Γ(X, ⊤)) (x : X) :
x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ ⊤ x trivial f) :=
RingedSpace.mem_top_basicOpen _ f x
@[simp]
theorem basicOpen_res (i : op U ⟶ op V) : X.basicOpen (X.presheaf.map i f) = V ⊓ X.basicOpen f :=
RingedSpace.basicOpen_res _ i f
-- This should fire before `basicOpen_res`.
@[simp 1100]
theorem basicOpen_res_eq (i : op U ⟶ op V) [IsIso i] :
X.basicOpen (X.presheaf.map i f) = X.basicOpen f :=
RingedSpace.basicOpen_res_eq _ i f
@[sheaf_restrict]
theorem basicOpen_le : X.basicOpen f ≤ U :=
RingedSpace.basicOpen_le _ _
@[sheaf_restrict]
lemma basicOpen_restrict (i : V ⟶ U) (f : Γ(X, U)) :
X.basicOpen (TopCat.Presheaf.restrict f i) ≤ X.basicOpen f :=
(Scheme.basicOpen_res _ _ _).trans_le inf_le_right
@[simp]
theorem preimage_basicOpen {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens} (r : Γ(Y, U)) :
f ⁻¹ᵁ Y.basicOpen r = X.basicOpen (f.app U r) :=
LocallyRingedSpace.preimage_basicOpen f.toLRSHom r
alias Hom.preimage_basicOpen := preimage_basicOpen
theorem preimage_basicOpen_top {X Y : Scheme.{u}} (f : X ⟶ Y) (r : Γ(Y, ⊤)) :
f ⁻¹ᵁ Y.basicOpen r = X.basicOpen (f.appTop r) :=
preimage_basicOpen ..
alias Hom.preimage_basicOpen_top := preimage_basicOpen_top
lemma basicOpen_appLE {X Y : Scheme.{u}} (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e : U ≤ f ⁻¹ᵁ V)
(s : Γ(Y, V)) : X.basicOpen (f.appLE V U e s) = U ⊓ f ⁻¹ᵁ (Y.basicOpen s) := by
simp only [preimage_basicOpen, Hom.appLE, CommRingCat.comp_apply]
rw [basicOpen_res]
@[simp]
theorem basicOpen_zero (U : X.Opens) : X.basicOpen (0 : Γ(X, U)) = ⊥ :=
LocallyRingedSpace.basicOpen_zero _ U
@[simp]
theorem basicOpen_mul : X.basicOpen (f * g) = X.basicOpen f ⊓ X.basicOpen g :=
RingedSpace.basicOpen_mul _ _ _
lemma basicOpen_pow {n : ℕ} (h : 0 < n) : X.basicOpen (f ^ n) = X.basicOpen f :=
RingedSpace.basicOpen_pow _ _ _ h
lemma basicOpen_add_le :
X.basicOpen (f + g) ≤ X.basicOpen f ⊔ X.basicOpen g := by
intro x hx
have hxU : x ∈ U := X.basicOpen_le _ hx
simp only [SetLike.mem_coe, Scheme.mem_basicOpen _ _ _ hxU, map_add, Opens.coe_sup,
Set.mem_union] at hx ⊢
exact IsLocalRing.isUnit_or_isUnit_of_isUnit_add hx
theorem basicOpen_of_isUnit {f : Γ(X, U)} (hf : IsUnit f) : X.basicOpen f = U :=
RingedSpace.basicOpen_of_isUnit _ hf
@[simp]
theorem basicOpen_one : X.basicOpen (1 : Γ(X, U)) = U :=
X.basicOpen_of_isUnit isUnit_one
instance algebra_section_section_basicOpen {X : Scheme} {U : X.Opens} (f : Γ(X, U)) :
Algebra Γ(X, U) Γ(X, X.basicOpen f) :=
(X.presheaf.map (homOfLE <| X.basicOpen_le f : _ ⟶ U).op).hom.toAlgebra
@[simp]
lemma _root_.AlgebraicGeometry.SpecMap_preimage_basicOpen {R S : CommRingCat} (f : R ⟶ S) (r : R) :
Spec.map f ⁻¹ᵁ PrimeSpectrum.basicOpen r = PrimeSpectrum.basicOpen (f r) := rfl
end BasicOpen
section ZeroLocus
variable (X : Scheme.{u})
/--
The zero locus of a set of sections `s` over an open set `U` is the closed set consisting of
the complement of `U` and of all points of `U`, where all elements of `f` vanish.
-/
def zeroLocus {U : X.Opens} (s : Set Γ(X, U)) : Set X := X.toRingedSpace.zeroLocus s
lemma zeroLocus_def {U : X.Opens} (s : Set Γ(X, U)) :
X.zeroLocus s = ⋂ f ∈ s, (X.basicOpen f).carrierᶜ :=
rfl
lemma zeroLocus_isClosed {U : X.Opens} (s : Set Γ(X, U)) :
IsClosed (X.zeroLocus s) :=
X.toRingedSpace.zeroLocus_isClosed s
lemma zeroLocus_singleton {U : X.Opens} (f : Γ(X, U)) :
X.zeroLocus {f} = (↑(X.basicOpen f))ᶜ :=
X.toRingedSpace.zeroLocus_singleton f
@[simp]
lemma zeroLocus_empty_eq_univ {U : X.Opens} :
X.zeroLocus (∅ : Set Γ(X, U)) = Set.univ :=
X.toRingedSpace.zeroLocus_empty_eq_univ
@[simp]
lemma mem_zeroLocus_iff {U : X.Opens} (s : Set Γ(X, U)) (x : X) :
x ∈ X.zeroLocus s ↔ ∀ f ∈ s, x ∉ X.basicOpen f :=
X.toRingedSpace.mem_zeroLocus_iff s x
lemma codisjoint_zeroLocus {U : X.Opens}
(s : Set Γ(X, U)) : Codisjoint (X.zeroLocus s) U := by
have (x : X) : ∀ f ∈ s, x ∈ X.basicOpen f → x ∈ U := fun _ _ h ↦ X.basicOpen_le _ h
simpa [codisjoint_iff_le_sup, Set.ext_iff, or_iff_not_imp_left]
lemma zeroLocus_span {U : X.Opens} (s : Set Γ(X, U)) :
X.zeroLocus (U := U) (Ideal.span s) = X.zeroLocus s := by
ext x
simp only [Scheme.mem_zeroLocus_iff, SetLike.mem_coe]
refine ⟨fun H f hfs ↦ H f (Ideal.subset_span hfs), fun H f ↦ Submodule.span_induction H ?_ ?_ ?_⟩
· simp only [Scheme.basicOpen_zero]; exact not_false
· exact fun a b _ _ ha hb H ↦ (X.basicOpen_add_le a b H).elim ha hb
· simp +contextual
lemma zeroLocus_map {U V : X.Opens} (i : U ≤ V) (s : Set Γ(X, V)) :
X.zeroLocus ((X.presheaf.map (homOfLE i).op).hom '' s) = X.zeroLocus s ∪ Uᶜ := by
ext x
suffices (∀ f ∈ s, x ∈ U → x ∉ X.basicOpen f) ↔ x ∈ U → (∀ f ∈ s, x ∉ X.basicOpen f) by
simpa [or_iff_not_imp_right]
grind
lemma zeroLocus_map_of_eq {U V : X.Opens} (i : U = V) (s : Set Γ(X, V)) :
X.zeroLocus ((X.presheaf.map (eqToHom i).op).hom '' s) = X.zeroLocus s := by
ext; simp
lemma zeroLocus_mono {U : X.Opens} {s t : Set Γ(X, U)} (h : s ⊆ t) :
X.zeroLocus t ⊆ X.zeroLocus s := by
simp only [Set.subset_def, Scheme.mem_zeroLocus_iff]
exact fun x H f hf hxf ↦ H f (h hf) hxf
lemma preimage_zeroLocus {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens} (s : Set Γ(Y, U)) :
f ⁻¹' Y.zeroLocus s = X.zeroLocus ((f.app U).hom '' s) := by
ext
simp [← Scheme.preimage_basicOpen]
@[simp]
lemma zeroLocus_univ {U : X.Opens} :
X.zeroLocus (U := U) Set.univ = (↑U)ᶜ := by
ext x
simp only [Scheme.mem_zeroLocus_iff, Set.mem_univ, forall_const, Set.mem_compl_iff,
SetLike.mem_coe, ← not_exists, not_iff_not]
exact ⟨fun ⟨f, hf⟩ ↦ X.basicOpen_le f hf, fun _ ↦ ⟨1, by rwa [X.basicOpen_of_isUnit isUnit_one]⟩⟩
lemma zeroLocus_iUnion {U : X.Opens} {ι : Type*} (f : ι → Set Γ(X, U)) :
X.zeroLocus (⋃ i, f i) = ⋂ i, X.zeroLocus (f i) := by
simpa [zeroLocus, AlgebraicGeometry.RingedSpace.zeroLocus] using Set.iInter_comm _
lemma zeroLocus_radical {U : X.Opens} (I : Ideal Γ(X, U)) :
X.zeroLocus (U := U) I.radical = X.zeroLocus (U := U) I := by
refine (X.zeroLocus_mono I.le_radical).antisymm ?_
simp only [Set.subset_def, mem_zeroLocus_iff, SetLike.mem_coe]
rintro x H f ⟨n, hn⟩ hx
rcases n.eq_zero_or_pos with rfl | hn'
· exact H f (by simpa using I.mul_mem_left f hn) hx
· exact H _ hn (X.basicOpen_pow f hn' ▸ hx)
end ZeroLocus
end Scheme
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
(Spec R).basicOpen ((Scheme.ΓSpecIso R).inv f) = PrimeSpectrum.basicOpen f := by
ext x
simp only [SetLike.mem_coe, Scheme.mem_basicOpen_top]
suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by exact this
rw [← isUnit_map_iff (StructureSheaf.stalkToFiberRingHom R x).hom,
StructureSheaf.stalkToFiberRingHom_toStalk]
exact IsLocalization.AtPrime.isUnit_to_map_iff _ (PrimeSpectrum.asIdeal x) f
@[simp]
theorem basicOpen_eq_of_affine' {R : CommRingCat} (f : Γ(Spec R, ⊤)) :
(Spec R).basicOpen f = PrimeSpectrum.basicOpen ((Scheme.ΓSpecIso R).hom f) := by
convert basicOpen_eq_of_affine ((Scheme.ΓSpecIso R).hom f)
exact (Iso.hom_inv_id_apply (Scheme.ΓSpecIso R) f).symm
theorem Scheme.SpecMap_presheaf_map_eqToHom {X : Scheme} {U V : X.Opens} (h : U = V) (W) :
(Spec.map (X.presheaf.map (eqToHom h).op)).app W = eqToHom (by cases h; simp) := by
have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
cases h
refine (Scheme.Hom.congr_app this _).trans ?_
simp [eqToHom_map]
@[deprecated (since := "2025-10-07")]
alias Scheme.Spec_map_presheaf_map_eqToHom := Scheme.SpecMap_presheaf_map_eqToHom
lemma germ_eq_zero_of_pow_mul_eq_zero {X : Scheme.{u}} {U : Opens X} (x : U) {f s : Γ(X, U)}
(hx : x.val ∈ X.basicOpen s) {n : ℕ} (hf : s ^ n * f = 0) : X.presheaf.germ U x x.2 f = 0 := by
rw [Scheme.mem_basicOpen X s x x.2] at hx
have hu : IsUnit (X.presheaf.germ _ x x.2 (s ^ n)) := by
rw [map_pow]
exact IsUnit.pow n hx
rw [← hu.mul_right_eq_zero, ← map_mul, hf, map_zero]
@[reassoc (attr := simp)]
lemma Scheme.hom_base_inv_base {X Y : Scheme.{u}} (e : X ≅ Y) :
e.hom.base ≫ e.inv.base = 𝟙 _ :=
LocallyRingedSpace.iso_hom_base_inv_base (Scheme.forgetToLocallyRingedSpace.mapIso e)
@[deprecated (since := "2025-10-07")]
alias Scheme.iso_hom_base_inv_base := Scheme.hom_base_inv_base
@[simp]
lemma Scheme.hom_inv_apply {X Y : Scheme.{u}} (e : X ≅ Y) (x : X) :
e.inv (e.hom x) = x := by
change (e.hom ≫ e.inv) x = 𝟙 X.toPresheafedSpace x
simp
@[deprecated (since := "2025-10-07")]
alias Scheme.iso_hom_base_inv_base_apply := Scheme.hom_inv_apply
@[reassoc (attr := simp)]
lemma Scheme.inv_base_hom_base {X Y : Scheme.{u}} (e : X ≅ Y) :
e.inv.base ≫ e.hom.base = 𝟙 _ :=
LocallyRingedSpace.iso_inv_base_hom_base (Scheme.forgetToLocallyRingedSpace.mapIso e)
@[deprecated (since := "2025-10-07")]
alias Scheme.iso_inv_base_hom_base := Scheme.inv_base_hom_base
@[simp]
lemma Scheme.inv_hom_apply {X Y : Scheme.{u}} (e : X ≅ Y) (y : Y) :
e.hom (e.inv y) = y := by
change (e.inv ≫ e.hom) y = 𝟙 Y.toPresheafedSpace y
simp
@[deprecated (since := "2025-10-07")]
alias Scheme.iso_inv_base_hom_base_apply := Scheme.inv_hom_apply
theorem Spec_zeroLocus_eq_zeroLocus {R : CommRingCat} (s : Set R) :
(Spec R).zeroLocus ((Scheme.ΓSpecIso R).inv '' s) = PrimeSpectrum.zeroLocus s := by
ext x
suffices (∀ a ∈ s, x ∉ PrimeSpectrum.basicOpen a) ↔ x ∈ PrimeSpectrum.zeroLocus s by simpa
simp [Spec_carrier, PrimeSpectrum.mem_zeroLocus, Set.subset_def,
PrimeSpectrum.mem_basicOpen _ x]
theorem Spec_zeroLocus {R : CommRingCat} (s : Set Γ(Spec R, ⊤)) :
(Spec R).zeroLocus s = PrimeSpectrum.zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s) := by
convert Spec_zeroLocus_eq_zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s)
rw [Set.image_preimage_eq]
exact (ConcreteCategory.bijective_of_isIso (C := CommRingCat) _).2
section Stalks
namespace Scheme.Hom
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
instance (x) : IsLocalHom (f.stalkMap x).hom :=
f.prop x
@[simp]
lemma stalkMap_id (X : Scheme.{u}) (x : X) :
(𝟙 X : X ⟶ X).stalkMap x = 𝟙 (X.presheaf.stalk x) :=
PresheafedSpace.stalkMap.id _ x
lemma stalkMap_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(f ≫ g : X ⟶ Z).stalkMap x = g.stalkMap (f x) ≫ f.stalkMap x :=
PresheafedSpace.stalkMap.comp f.toPshHom g.toPshHom x
@[reassoc]
lemma stalkSpecializes_stalkMap (x x' : X)
(h : x ⤳ x') : Y.presheaf.stalkSpecializes (f.base.hom.map_specializes h) ≫ f.stalkMap x =
f.stalkMap x' ≫ X.presheaf.stalkSpecializes h :=
PresheafedSpace.stalkMap.stalkSpecializes_stalkMap f.toPshHom h
lemma stalkSpecializes_stalkMap_apply (x x' : X) (h : x ⤳ x') (y) :
f.stalkMap x (Y.presheaf.stalkSpecializes (f.base.hom.map_specializes h) y) =
(X.presheaf.stalkSpecializes h (f.stalkMap x' y)) :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkSpecializes_stalkMap f x x' h)) y
@[reassoc]
lemma stalkMap_congr (f g : X ⟶ Y) (hfg : f = g) (x x' : X)
(hxx' : x = x') : f.stalkMap x ≫ (X.presheaf.stalkCongr (.of_eq hxx')).hom =
(Y.presheaf.stalkCongr (.of_eq <| hfg ▸ hxx' ▸ rfl)).hom ≫ g.stalkMap x' :=
LocallyRingedSpace.stalkMap_congr f.toLRSHom g.toLRSHom congr(($hfg).toLRSHom) x x' hxx'
@[reassoc]
lemma stalkMap_congr_hom (f g : X ⟶ Y) (hfg : f = g) (x : X) :
f.stalkMap x = (Y.presheaf.stalkCongr (.of_eq <| hfg ▸ rfl)).hom ≫ g.stalkMap x :=
LocallyRingedSpace.stalkMap_congr_hom f.toLRSHom g.toLRSHom congr(($hfg).toLRSHom) x
@[reassoc]
lemma stalkMap_congr_point (x x' : X) (hxx' : x = x') :
f.stalkMap x ≫ (X.presheaf.stalkCongr (.of_eq hxx')).hom =
(Y.presheaf.stalkCongr (.of_eq <| hxx' ▸ rfl)).hom ≫ f.stalkMap x' :=
LocallyRingedSpace.stalkMap_congr_point f.toLRSHom x x' hxx'
@[reassoc (attr := simp)]
lemma stalkMap_hom_inv (e : X ≅ Y) (y : Y) :
e.hom.stalkMap (e.inv y) ≫ e.inv.stalkMap y =
(Y.presheaf.stalkCongr (.of_eq (by simp))).hom :=
LocallyRingedSpace.stalkMap_hom_inv (forgetToLocallyRingedSpace.mapIso e) y
@[simp]
lemma stalkMap_hom_inv_apply (e : X ≅ Y) (y : Y) (z) :
e.inv.stalkMap y (e.hom.stalkMap (e.inv y) z) =
(Y.presheaf.stalkCongr (.of_eq (by simp))).hom z :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkMap_hom_inv e y)) z
@[reassoc (attr := simp)]
lemma stalkMap_inv_hom (e : X ≅ Y) (x : X) :
e.inv.stalkMap (e.hom x) ≫ e.hom.stalkMap x =
(X.presheaf.stalkCongr (.of_eq (by simp))).hom :=
LocallyRingedSpace.stalkMap_inv_hom (forgetToLocallyRingedSpace.mapIso e) x
@[simp]
lemma stalkMap_inv_hom_apply (e : X ≅ Y) (x : X) (y) :
e.hom.stalkMap x (e.inv.stalkMap (e.hom x) y) =
(X.presheaf.stalkCongr (.of_eq (by simp))).hom y :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkMap_inv_hom e x)) y
@[reassoc (attr := simp)]
lemma germ_stalkMap (U : Y.Opens) (x : X) (hx : f x ∈ U) :
Y.presheaf.germ U (f x) hx ≫ f.stalkMap x =
f.app U ≫ X.presheaf.germ (f ⁻¹ᵁ U) x hx :=
PresheafedSpace.stalkMap_germ f.toPshHom U x hx
@[simp]
lemma germ_stalkMap_apply (U : Y.Opens) (x : X) (hx : f x ∈ U) (y) :
f.stalkMap x (Y.presheaf.germ _ (f x) hx y) =
X.presheaf.germ (f ⁻¹ᵁ U) x hx (f.app U y) :=
PresheafedSpace.stalkMap_germ_apply f.toPshHom U x hx y
/-- If `x = y`, the stalk maps are isomorphic. -/
noncomputable def arrowStalkMapIsoOfEq {x y : X}
(h : x = y) : Arrow.mk (f.stalkMap x) ≅ Arrow.mk (f.stalkMap y) :=
Arrow.isoMk (Y.presheaf.stalkCongr <| (Inseparable.of_eq h).map f.continuous)
(X.presheaf.stalkCongr <| Inseparable.of_eq h) <| by
simp only [Arrow.mk_left, Arrow.mk_right, Functor.id_obj, TopCat.Presheaf.stalkCongr_hom,
Arrow.mk_hom]
rw [stalkSpecializes_stalkMap]
end Hom
@[deprecated (since := "2025-10-07")] alias stalkMap_id := Hom.stalkMap_id
@[deprecated (since := "2025-10-07")] alias stalkMap_comp := Hom.stalkMap_comp
@[deprecated (since := "2025-10-07")]
alias stalkSpecializes_stalkMap := Hom.stalkSpecializes_stalkMap
@[deprecated (since := "2025-10-07")]
alias stalkSpecializes_stalkMap_assoc := Hom.stalkSpecializes_stalkMap_assoc
@[deprecated (since := "2025-10-07")]
alias stalkSpecializes_stalkMap_apply := Hom.stalkSpecializes_stalkMap_apply
@[deprecated (since := "2025-10-07")] alias stalkMap_congr := Hom.stalkMap_congr
@[deprecated (since := "2025-10-07")] alias stalkMap_congr_assoc := Hom.stalkMap_congr_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_congr_hom := Hom.stalkMap_congr_hom
@[deprecated (since := "2025-10-07")] alias stalkMap_congr_hom_assoc := Hom.stalkMap_congr_hom_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_congr_point := Hom.stalkMap_congr_point
@[deprecated (since := "2025-10-07")]
alias stalkMap_congr_point_assoc := Hom.stalkMap_congr_point_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_hom_inv := Hom.stalkMap_hom_inv
@[deprecated (since := "2025-10-07")] alias stalkMap_hom_inv_assoc := Hom.stalkMap_hom_inv_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_hom_inv_apply := Hom.stalkMap_hom_inv_apply
@[deprecated (since := "2025-10-07")] alias stalkMap_inv_hom := Hom.stalkMap_inv_hom
@[deprecated (since := "2025-10-07")] alias stalkMap_inv_hom_assoc := Hom.stalkMap_inv_hom_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_inv_hom_apply := Hom.stalkMap_inv_hom_apply
@[deprecated (since := "2025-10-07")] alias stalkMap_germ := Hom.germ_stalkMap
@[deprecated (since := "2025-10-07")] alias stalkMap_germ_assoc := Hom.germ_stalkMap_assoc
@[deprecated (since := "2025-10-07")] alias stalkMap_germ_apply := Hom.germ_stalkMap_apply
@[deprecated (since := "2025-10-07")] alias arrowStalkMapIsoOfEq := Hom.arrowStalkMapIsoOfEq
end Scheme
end Stalks
section IsLocalRing
open IsLocalRing
@[simp]
lemma Spec_closedPoint {R S : CommRingCat} [IsLocalRing R] [IsLocalRing S]
{f : R ⟶ S} [IsLocalHom f.hom] : Spec.map f (closedPoint S) = closedPoint R :=
IsLocalRing.comap_closedPoint f.hom
end IsLocalRing
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/AffineTransitionLimit.lean | import Mathlib.Algebra.Category.Ring.FinitePresentation
import Mathlib.AlgebraicGeometry.IdealSheaf.Functorial
import Mathlib.AlgebraicGeometry.Morphisms.Separated
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Connected
import Mathlib.CategoryTheory.Monad.Limits
/-!
# Inverse limits of schemes with affine transition maps
In this file, we develop API for inverse limits of schemes with affine transition maps,
following EGA IV 8 and https://stacks.math.columbia.edu/tag/01YT.
-/
universe uI u
open CategoryTheory Limits
namespace AlgebraicGeometry
-- We refrain from considering diagrams in the over category since inverse limits in the over
-- category is isomorphic to limits in `Scheme`. Instead we use `D ⟶ (Functor.const I).obj S` to
-- say that the diagram is over the base scheme `S`.
variable {I : Type u} [Category.{u} I] {S X : Scheme.{u}} (D : I ⥤ Scheme.{u})
(t : D ⟶ (Functor.const I).obj S) (f : X ⟶ S) (c : Cone D) (hc : IsLimit c)
include hc in
/--
Suppose we have a cofiltered diagram of nonempty quasi-compact schemes,
whose transition maps are affine. Then the limit is also nonempty.
-/
@[stacks 01Z2]
lemma Scheme.nonempty_of_isLimit [IsCofilteredOrEmpty I]
[∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)] [∀ i, Nonempty (D.obj i)]
[∀ i, CompactSpace (D.obj i)] :
Nonempty c.pt := by
classical
cases isEmpty_or_nonempty I
· have e := (isLimitEquivIsTerminalOfIsEmpty _ _ hc).uniqueUpToIso specULiftZIsTerminal
exact Nonempty.map e.inv inferInstance
· have i := Nonempty.some ‹Nonempty I›
have : IsCofiltered I := ⟨⟩
let 𝒰 := (D.obj i).affineCover.finiteSubcover
have (i' : _) : IsAffine (𝒰.X i') := inferInstanceAs (IsAffine (Spec _))
obtain ⟨j, H⟩ :
∃ j : 𝒰.I₀, ∀ {i'} (f : i' ⟶ i), Nonempty ((𝒰.pullback₁ (D.map f)).X j) := by
by_contra! H
choose i' f hf using H
let g (j) := IsCofiltered.infTo (insert i (Finset.univ.image i'))
(Finset.univ.image fun j : 𝒰.I₀ ↦ ⟨_, _, by simp, by simp, f j⟩) (X := j)
have (j : 𝒰.I₀) : IsEmpty ((𝒰.pullback₁ (D.map (g i (by simp)))).X j) := by
let F : (𝒰.pullback₁ (D.map (g i (by simp)))).X j ⟶
(𝒰.pullback₁ (D.map (f j))).X j :=
pullback.map _ _ _ _ (D.map (g _ (by simp))) (𝟙 _) (𝟙 _) (by
rw [← D.map_comp, IsCofiltered.infTo_commutes]
· simp [g]
· simp
· exact Finset.mem_image_of_mem _ (Finset.mem_univ _)) (by simp)
exact Function.isEmpty F
obtain ⟨x, -⟩ :=
Cover.covers (𝒰.pullback₁ (D.map (g i (by simp)))) (Nonempty.some inferInstance)
exact (this _).elim x
let F := Over.post D ⋙ Over.pullback (𝒰.f j) ⋙ Over.forget _
have (i' : _) : IsAffine (F.obj i') :=
have : IsAffineHom (pullback.snd (D.map i'.hom) (𝒰.f j)) :=
MorphismProperty.pullback_snd _ _ inferInstance
isAffine_of_isAffineHom (pullback.snd (D.map i'.hom) (𝒰.f j))
have (i' : _) : Nonempty (F.obj i') := H i'.hom
let e : F ⟶ (F ⋙ Scheme.Γ.rightOp) ⋙ Scheme.Spec := Functor.whiskerLeft F ΓSpec.adjunction.unit
have (i : _) : IsIso (e.app i) := IsAffine.affine
have : IsIso e := NatIso.isIso_of_isIso_app e
let c' : LimitCone F := ⟨_, (IsLimit.postcomposeInvEquiv (asIso e) _).symm
(isLimitOfPreserves Scheme.Spec (limit.isLimit (F ⋙ Scheme.Γ.rightOp)))⟩
have : Nonempty c'.1.pt := by
apply (config := { allowSynthFailures := true }) PrimeSpectrum.instNonemptyOfNontrivial
have (i' : _) : Nontrivial ((F ⋙ Scheme.Γ.rightOp).leftOp.obj i') := by
apply (config := { allowSynthFailures := true }) Scheme.component_nontrivial
simp
exact CommRingCat.FilteredColimits.nontrivial
(isColimitCoconeLeftOpOfCone _ (limit.isLimit (F ⋙ Scheme.Γ.rightOp)))
let α : F ⟶ Over.forget _ ⋙ D := Functor.whiskerRight
(Functor.whiskerLeft (Over.post D) (Over.mapPullbackAdj (𝒰.f j)).counit) (Over.forget _)
exact this.map (((Functor.Initial.isLimitWhiskerEquiv (Over.forget i) c).symm hc).lift
((Cones.postcompose α).obj c'.1))
include hc in
open Scheme.IdealSheafData in
/--
Suppose we have a cofiltered diagram of schemes whose transition maps are affine. The limit of
a family of compatible nonempty quasicompact closed sets in the diagram is also nonempty.
-/
lemma exists_mem_of_isClosed_of_nonempty
[IsCofilteredOrEmpty I]
[∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
(Z : ∀ (i : I), Set (D.obj i))
(hZc : ∀ (i : I), IsClosed (Z i))
(hZne : ∀ i, (Z i).Nonempty)
(hZcpt : ∀ i, IsCompact (Z i))
(hmapsTo : ∀ {i i' : I} (f : i ⟶ i'), Set.MapsTo (D.map f) (Z i) (Z i')) :
∃ (s : c.pt), ∀ i, c.π.app i s ∈ Z i := by
let D' : I ⥤ Scheme :=
{ obj i := (vanishingIdeal ⟨Z i, hZc i⟩).subscheme
map {X Y} f := subschemeMap _ _ (D.map f) (by
rw [map_vanishingIdeal, ← le_support_iff_le_vanishingIdeal]
simpa [(hZc _).closure_subset_iff] using (hmapsTo f).subset_preimage)
map_id _ := by simp [← cancel_mono (subschemeι _)]
map_comp _ _ := by simp [← cancel_mono (subschemeι _)] }
let ι : D' ⟶ D := { app i := subschemeι _, naturality _ _ _ := by simp [D'] }
haveI {i j} (f : i ⟶ j) : IsAffineHom (D'.map f) := by
suffices IsAffineHom (D'.map f ≫ ι.app j) from .of_comp _ (ι.app j)
simp only [subschemeMap_subschemeι, D', ι]
infer_instance
haveI _ (i) : Nonempty (D'.obj i) := Set.nonempty_coe_sort.mpr (hZne i)
haveI _ (i) : CompactSpace (D'.obj i) := isCompact_iff_compactSpace.mp (hZcpt i)
let c' : Cone D' :=
{ pt := (⨆ i, (vanishingIdeal ⟨Z i, hZc i⟩).comap (c.π.app i)).subscheme
π :=
{ app i := subschemeMap _ _ (c.π.app i) (by simp [le_map_iff_comap_le, le_iSup_of_le i])
naturality {i j} f := by simp [D', ← cancel_mono (subschemeι _)] } }
let hc' : IsLimit c' :=
{ lift s := IsClosedImmersion.lift (subschemeι _) (hc.lift ((Cones.postcompose ι).obj s)) (by
suffices ∀ i, vanishingIdeal ⟨Z i, hZc i⟩ ≤ (s.π.app i ≫ ι.app i).ker by
simpa [← le_map_iff_comap_le, ← Scheme.Hom.ker_comp]
refine fun i ↦ .trans ?_ (Scheme.Hom.le_ker_comp _ _)
simp [ι])
fac s i := by simp [← cancel_mono (subschemeι _), c', ι]
uniq s m hm := by
rw [← cancel_mono (subschemeι _)]
refine hc.hom_ext fun i ↦ ?_
simp [ι, c', ← hm] }
have : Nonempty (⨆ i, (vanishingIdeal ⟨Z i, hZc i⟩).comap (c.π.app i)).support :=
Scheme.nonempty_of_isLimit D' c' hc'
simpa using this
include hc in
/--
A variant of `exists_mem_of_isClosed_of_nonempty` where the closed sets are only defined
for the objects over a given `j : I`.
-/
@[stacks 01Z3]
lemma exists_mem_of_isClosed_of_nonempty'
[IsCofilteredOrEmpty I]
[∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
{j : I}
(Z : ∀ (i : I), (i ⟶ j) → Set (D.obj i))
(hZc : ∀ i hij, IsClosed (Z i hij))
(hZne : ∀ i hij, (Z i hij).Nonempty)
(hZcpt : ∀ i hij, IsCompact (Z i hij))
(hstab : ∀ (i i' : I) (hi'i : i' ⟶ i) (hij : i ⟶ j),
Set.MapsTo (D.map hi'i) (Z i' (hi'i ≫ hij)) (Z i hij)) :
∃ (s : c.pt), ∀ i hij, c.π.app i s ∈ Z i hij := by
have {i₁ i₂ : Over j} (f : i₁ ⟶ i₂) : IsAffineHom ((Over.forget j ⋙ D).map f) := by
dsimp; infer_instance
simpa [Over.forall_iff] using exists_mem_of_isClosed_of_nonempty (Over.forget j ⋙ D) _
((Functor.Initial.isLimitWhiskerEquiv (Over.forget j) c).symm hc)
(fun i ↦ Z i.left i.hom) (fun _ ↦ hZc _ _) (fun _ ↦ hZne _ _) (fun _ ↦ hZcpt _ _)
(fun {i₁ i₂} f ↦ by dsimp; rw [← Over.w f]; exact hstab ..)
section Opens
include hc in
/-- Let `{ Dᵢ }` be a cofiltered diagram of compact schemes with affine transition maps.
If `U ⊆ Dⱼ` contains the image of `limᵢ Dᵢ ⟶ Dⱼ`, then it contains the image of some `Dₖ ⟶ Dⱼ`. -/
lemma exists_map_eq_top
[IsCofiltered I]
[∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
[∀ i, CompactSpace (D.obj i)]
{i : I} (U : (D.obj i).Opens) (hU : c.π.app i ⁻¹ᵁ U = ⊤) :
∃ (j : I) (fji : j ⟶ i), D.map fji ⁻¹ᵁ U = ⊤ := by
by_contra! H
obtain ⟨s, hs⟩ := exists_mem_of_isClosed_of_nonempty' D c hc (fun j f ↦ (D.map f ⁻¹ᵁ U)ᶜ)
(fun j f ↦ (D.map f ⁻¹ᵁ U).2.isClosed_compl) (fun j f ↦ by
simp only [TopologicalSpace.Opens.map_coe, Set.nonempty_compl, ne_eq]
exact SetLike.coe_injective.ne (H j f))
(fun j f ↦ (D.map f ⁻¹ᵁ U).2.isClosed_compl.isCompact)
(fun j k fkj fji x (hx : _ ∉ U) ↦ by rwa [Functor.map_comp] at hx)
exact absurd (hU.ge (Set.mem_univ s)) (by simpa using hs i (𝟙 i))
attribute [local simp] Scheme.Hom.resLE_comp_resLE
/-- Given a diagram `{ Dᵢ }` of schemes and an open `U ⊆ Dᵢ`,
this is the diagram of `{ Dⱼᵢ⁻¹ U }_{j ≤ i}`. -/
@[simps] noncomputable
def opensDiagram (i : I) (U : (D.obj i).Opens) : Over i ⥤ Scheme where
obj j := D.map j.hom ⁻¹ᵁ U
map {j k} f := (D.map f.left).resLE _ _
(by rw [← Scheme.Hom.comp_preimage, ← D.map_comp, Over.w f])
/-- The map `Dⱼᵢ⁻¹ U ⟶ Dᵢ` from the restricted diagram to the original diagram. -/
@[simps] noncomputable
def opensDiagramι (i : I) (U : (D.obj i).Opens) : opensDiagram D i U ⟶ Over.forget _ ⋙ D where
app j := Scheme.Opens.ι _
instance (i : I) (U : (D.obj i).Opens) (j : Over i) :
IsOpenImmersion ((opensDiagramι D i U).app j) := by
delta opensDiagramι; infer_instance
/-- Given a diagram `{ Dᵢ }` of schemes and an open `U ⊆ Dᵢ`,
the preimage of `U ⊆ Dᵢ` under the map `lim Dᵢ ⟶ Dᵢ` is the limit of `{ Dⱼᵢ⁻¹ U }_{j ≤ i}`.
This is the underlying cone, and it is limiting as witnessed by `isLimitOpensCone` below. -/
@[simps] noncomputable
def opensCone (i : I) (U : (D.obj i).Opens) : Cone (opensDiagram D i U) where
pt := c.π.app i ⁻¹ᵁ U
π.app j := (c.π.app j.left).resLE _ _ (by rw [← Scheme.Hom.comp_preimage, c.w]; rfl)
attribute [local instance] CategoryTheory.isConnected_of_hasTerminal
/-- Given a diagram `{ Dᵢ }_{i ∈ I}` of schemes and an open `U ⊆ Dᵢ`,
the preimage of `U ⊆ Dᵢ` under the map `lim Dᵢ ⟶ Dᵢ` is the limit of `{ Dⱼᵢ⁻¹ U }_{j ≤ i}`. -/
noncomputable
def isLimitOpensCone [IsCofiltered I] (i : I) (U : (D.obj i).Opens) :
IsLimit (opensCone D c i U) :=
isLimitOfIsPullbackOfIsConnected (opensDiagramι D i U) _ _
(by exact { hom := (c.π.app i ⁻¹ᵁ U).ι })
(fun j ↦ IsOpenImmersion.isPullback _ _ _ _ (by simp) (by simp [← Scheme.Hom.comp_preimage]))
((Functor.Initial.isLimitWhiskerEquiv (Over.forget i) c).symm hc)
instance [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)] {i : I}
(U : (D.obj i).Opens) {j k : Over i} (f : j ⟶ k) :
IsAffineHom ((opensDiagram D i U).map f) := by
refine ⟨fun V hV ↦ ?_⟩
convert ((hV.image_of_isOpenImmersion (D.map k.hom ⁻¹ᵁ U).ι).preimage
(D.map f.left)).preimage_of_isOpenImmersion (D.map j.hom ⁻¹ᵁ U).ι ?_
· ext x
change _ ∈ V ↔ _
refine ⟨fun h ↦ ⟨⟨(D.map f.left).base x.1, ?_⟩, ?_, rfl⟩, ?_⟩
· change (D.map f.left ≫ D.map k.hom).base x.1 ∈ U
rw [← D.map_comp, Over.w f]
exact x.2
· convert h
exact Subtype.ext (by simp)
· rintro ⟨⟨_, hU⟩, hV, rfl⟩
convert hV
exact Subtype.ext (by simp)
· simp only [Functor.id_obj, opensDiagram_obj, Functor.const_obj_obj,
Scheme.Opens.opensRange_ι]
rintro x ⟨⟨y, h₁ : (D.map k.hom).base y ∈ U⟩, h₂, e⟩
obtain rfl : y = (D.map f.left).base x := congr($e)
dsimp at h₁
rw [← Scheme.Hom.comp_apply] at h₁
rwa [← D.map_comp, Over.w f] at h₁
end Opens
include hc in
lemma isAffineHom_π_app [IsCofiltered I] [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)] (i : I) :
IsAffineHom (c.π.app i) where
isAffine_preimage U hU := have (j : _) : IsAffine ((opensDiagram D i U).obj j) := hU.preimage _
Scheme.isAffine_of_isLimit _ (isLimitOpensCone D c hc i U)
include hc in
lemma Scheme.compactSpace_of_isLimit [IsCofiltered I]
[∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)] [∀ i, CompactSpace (D.obj i)] :
CompactSpace c.pt := by
obtain ⟨i⟩ := IsCofiltered.nonempty (C := I)
have := isAffineHom_π_app _ _ hc
exact QuasiCompact.compactSpace_of_compactSpace (c.π.app i)
/-!
## Cofiltered Limits and Schemes of Finite Type
Given a cofiltered diagram `D` of quasi-compact `S`-schemes with affine transition maps,
and another scheme `X` of finite type over `S`.
Then the canonical map `colim Homₛ(Dᵢ, X) ⟶ Homₛ(lim Dᵢ, X)` is injective.
In other words, for each pair of `a : Homₛ(Dᵢ, X)` and `b : Homₛ(Dⱼ, X)` that give rise to the
same map `Homₛ(lim Dᵢ, X)`, there exists a `k` with `fᵢ : k ⟶ i` and `fⱼ : k ⟶ j` such that
`D(fᵢ) ≫ a = D(fⱼ) ≫ b`.
This results is formalized in `Scheme.exists_hom_hom_comp_eq_comp_of_locallyOfFiniteType`.
We first reduce to the case `i = j`, and the goal is to reduce to the case where `X` and `S`
are affine, where the result follows from commutative algebra.
To achieve this, we show that there exists some `i₀ ⟶ i` such that for each `x`, `a x` and `b x`
are contained in the same component (i.e. given an open cover `𝒰ₛ` of `S`,
and `𝒰ₓ` of `X` refining `𝒰ₛ`, the range of `x ↦ (a x, b x)` falls in the diagonal part
`⋃ᵢⱼ 𝒰ₓⱼ ×[𝒰ₛᵢ] 𝒰ₓⱼ`).
Then we may restrict to the sub-diagram over `i₀` (which is cofinal because `D` is cofiltered),
and check locally on `X`, reducing to the affine case.
For the actual implementation, we wrap `i`, `a`, `b`, the limit cone `lim Dᵢ`, and open covers
of `X` and `S` into a structure `ExistsHomHomCompEqCompAux` for convenience.
See the injective part of (1) => (3) of https://stacks.math.columbia.edu/tag/01ZC.
-/
section LocallyOfFiniteType
variable [∀ i, CompactSpace (D.obj i)] [LocallyOfFiniteType f] [IsCofiltered I]
include hc in
/-- Subsumed by `Scheme.exists_hom_hom_comp_eq_comp_of_locallyOfFiniteType`. -/
private nonrec lemma Scheme.exists_hom_hom_comp_eq_comp_of_isAffine_of_locallyOfFiniteType
[IsAffine S] [IsAffine X] [∀ i, IsAffine (D.obj i)] [IsAffine c.pt]
{i : I} (a : D.obj i ⟶ X) (ha : t.app i = a ≫ f)
{j : I} (b : D.obj j ⟶ X) (hb : t.app j = b ≫ f)
(hab : c.π.app i ≫ a = c.π.app j ≫ b) :
∃ (k : I) (hik : k ⟶ i) (hjk : k ⟶ j),
D.map hik ≫ a = D.map hjk ≫ b := by
wlog hS : ∃ R, S = Spec R generalizing S
· exact this (t ≫ ((Functor.const I).mapIso S.isoSpec).hom)
(f ≫ S.isoSpec.hom) (by simp [ha]) (by simp [hb]) ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hS
wlog hX : ∃ S, X = Spec S generalizing X
· simpa using this (a ≫ X.isoSpec.hom) (b ≫ X.isoSpec.hom) (by simp [hab]) (X.isoSpec.inv ≫ f)
(by simp [ha]) (by simp [hb]) ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
wlog hD : ∃ D' : I ⥤ CommRingCatᵒᵖ, D = D' ⋙ Scheme.Spec generalizing D
· let e : D ⟶ D ⋙ Scheme.Γ.rightOp ⋙ Scheme.Spec := D.whiskerLeft ΓSpec.adjunction.unit
have inst (i) : IsIso (e.app i) := by dsimp [e]; infer_instance
have inst : IsIso e := NatIso.isIso_of_isIso_app e
have inst (i) : IsAffine ((D ⋙ Scheme.Γ.rightOp ⋙ Scheme.Spec).obj i) := by
dsimp; infer_instance
have inst : IsAffine ((Cones.postcompose (asIso e).hom).obj c).pt := by
dsimp; infer_instance
have := this (D ⋙ Scheme.Γ.rightOp ⋙ Scheme.Spec) ((Cones.postcompose (asIso e).hom).obj c)
((IsLimit.postcomposeHomEquiv (asIso e) c).symm hc) (inv e ≫ t)
((inv e).app _ ≫ a) ((inv e).app _ ≫ b) (by simp [hab]) (by simp [ha]) (by simp [hb])
⟨D ⋙ Scheme.Γ.rightOp, rfl⟩
simp_rw [(inv e).naturality_assoc] at this
simpa using this
obtain ⟨D, rfl⟩ := hD
obtain ⟨a, rfl⟩ := Spec.map_surjective a
obtain ⟨b, rfl⟩ := Spec.map_surjective b
let e : ((Functor.const Iᵒᵖ).obj R).rightOp ⋙ Scheme.Spec ≅ (Functor.const I).obj (Spec R) :=
NatIso.ofComponents (fun _ ↦ Iso.refl _) (by simp)
obtain ⟨t, rfl⟩ : ∃ t' : (Functor.const Iᵒᵖ).obj R ⟶ D.leftOp,
t = Functor.whiskerRight (NatTrans.rightOp t') Scheme.Spec ≫ e.hom :=
⟨⟨fun i ↦ Spec.preimage (t.app i.unop), fun _ _ f ↦ Spec.map_injective
(by simpa using (t.naturality f.unop).symm)⟩, by ext : 2; simp [e]⟩
have := monadicCreatesLimits Scheme.Spec
obtain ⟨k, hik, hjk, H⟩ := (HasRingHomProperty.Spec_iff.mp ‹LocallyOfFiniteType (Spec.map φ)›)
|>.essFiniteType.exists_comp_map_eq_of_isColimit _ D.leftOp t _
(coconeLeftOpOfCone (liftLimit hc))
(isColimitCoconeLeftOpOfCone _ (liftedLimitIsLimit _))
a (Spec.map_injective (by simpa using ha.symm))
b (Spec.map_injective (by simpa using hb.symm))
(Spec.map_injective (by
simp only [coconeLeftOpOfCone_pt, Functor.const_obj_obj,
Functor.leftOp_obj, coconeLeftOpOfCone_ι_app, Spec.map_comp]
simp only [← Scheme.Spec_map, ← liftedLimitMapsToOriginal_hom_π, Category.assoc, hab]))
exact ⟨k.unop, hik.unop, hjk.unop, by simpa [← Spec.map_comp, Spec.map_inj] using H⟩
/-- (Implementation)
An auxiliary structure used to prove `Scheme.exists_hom_hom_comp_eq_comp_of_locallyOfFiniteType`.
See the section docstring. -/
structure ExistsHomHomCompEqCompAux where
/-- (Implementation) The limit cone. See the section docstring. -/
c : Cone D
/-- (Implementation) The limit cone is a limit. See the section docstring. -/
hc : IsLimit c
/-- (Implementation) The index on which `a` and `b` lives. See the section docstring. -/
i : I
/-- (Implementation) `a`. See the section docstring. -/
a : D.obj i ⟶ X
ha : t.app i = a ≫ f
/-- (Implementation) `b`. See the section docstring. -/
b : D.obj i ⟶ X
hb : t.app i = b ≫ f
hab : c.π.app i ≫ a = c.π.app i ≫ b
/-- (Implementation) An open cover on `S`. See the section docstring. -/
𝒰S : Scheme.OpenCover.{u} S
[h𝒰S : ∀ i, IsAffine (𝒰S.X i)]
/-- (Implementation) A family of open covers refining `𝒰S`. See the section docstring. -/
𝒰X (i : (𝒰S.pullback₁ f).I₀) : Scheme.OpenCover.{u} ((𝒰S.pullback₁ f).X i)
[h𝒰X : ∀ i j, IsAffine ((𝒰X i).X j)]
attribute [instance] ExistsHomHomCompEqCompAux.h𝒰S ExistsHomHomCompEqCompAux.h𝒰X
namespace ExistsHomHomCompEqCompAux
noncomputable section
variable {D t f c} [∀ {i j : I} (f : i ⟶ j), IsAffineHom (D.map f)]
variable (A : ExistsHomHomCompEqCompAux D t f)
omit [LocallyOfFiniteType f] in
lemma exists_index : ∃ (i' : I) (hii' : i' ⟶ A.i),
((D.map hii' ≫ pullback.lift A.a A.b (A.ha.symm.trans A.hb)) ⁻¹'
((Scheme.Pullback.diagonalCoverDiagonalRange f A.𝒰S A.𝒰X : Set <|
↑(pullback f f))ᶜ)) = ∅ := by
let W := Scheme.Pullback.diagonalCoverDiagonalRange f A.𝒰S A.𝒰X
by_contra! h
let Z (i' : I) (hii' : i' ⟶ A.i) :=
(D.map hii' ≫ pullback.lift A.a A.b (A.ha.symm.trans A.hb)) ⁻¹' Wᶜ
have hZ (i') (hii' : i' ⟶ A.i) : IsClosed (Z i' hii') :=
(W.isOpen.isClosed_compl).preimage <| Scheme.Hom.continuous _
obtain ⟨s, hs⟩ := exists_mem_of_isClosed_of_nonempty' D A.c A.hc Z hZ h
(fun _ _ ↦ (hZ _ _).isCompact) (fun i i' hii' hij ↦ by simp [Z, Set.MapsTo])
refine hs A.i (𝟙 A.i) (Scheme.Pullback.range_diagonal_subset_diagonalCoverDiagonalRange _ _ _ ?_)
use (A.c.π.app A.i ≫ A.a) s
have H : A.c.π.app A.i ≫ A.a ≫ pullback.diagonal f =
A.c.π.app A.i ≫ pullback.lift A.a A.b (A.ha.symm.trans A.hb) := by ext <;> simp [hab]
simp [← Scheme.Hom.comp_apply, - Scheme.Hom.comp_base, H]
/-- (Implementation)
The index `i'` such that `a` and `b` restricted onto `i'` maps into the diagonal components.
See the section docstring. -/
def i' : I := A.exists_index.choose
/-- (Implementation) The map from `i'` to `i`. See the section docstring. -/
def hii' : A.i' ⟶ A.i := A.exists_index.choose_spec.choose
/-- (Implementation)
The map sending `x` to `(a x, b x)`, which should fall in the diagonal component.
See the section docstring. -/
def g : D.obj A.i' ⟶ pullback f f :=
(D.map A.hii' ≫ pullback.lift A.a A.b (A.ha.symm.trans A.hb))
omit [LocallyOfFiniteType f] in
lemma range_g_subset :
Set.range A.g ⊆ Scheme.Pullback.diagonalCoverDiagonalRange f A.𝒰S A.𝒰X := by
simpa [ExistsHomHomCompEqCompAux.hii', g] using A.exists_index.choose_spec.choose_spec
/-- (Implementation)
The covering of `D(i')` by the pullback of the diagonal components of `X ×ₛ X`.
See the section docstring. -/
noncomputable def 𝒰D₀ : Scheme.OpenCover.{u} (D.obj A.i') :=
Scheme.Cover.mkOfCovers (Σ i : A.𝒰S.I₀, (A.𝒰X i).I₀) _
(fun i ↦ ((Scheme.Pullback.diagonalCover f A.𝒰S A.𝒰X).pullback₁ A.g).f ⟨i.1, i.2, i.2⟩)
(fun x ↦ by simpa [← Set.mem_range, Scheme.Pullback.range_fst,
Scheme.Pullback.diagonalCoverDiagonalRange] using A.range_g_subset ⟨x, rfl⟩)
/-- (Implementation) An affine open cover refining `𝒰D₀`. See the section docstring. -/
noncomputable def 𝒰D : Scheme.OpenCover.{u} (D.obj A.i') :=
A.𝒰D₀.bind fun _ ↦ Scheme.affineCover _
attribute [-simp] cast_eq eq_mpr_eq_cast
/-- (Implementation) The diagram restricted to `Over i'`. See the section docstring. -/
def D' (j : A.𝒰D.I₀) : Over A.i' ⥤ Scheme :=
Over.post D ⋙ Over.pullback (A.𝒰D.f j) ⋙ Over.forget _
/-- (Implementation) The limit cone restricted to `Over i'`. See the section docstring. -/
def c' (j : A.𝒰D.I₀) : Cone (A.D' j) :=
(Over.pullback (A.𝒰D.f j) ⋙ Over.forget _).mapCone ((Over.conePost _ _).obj A.c)
attribute [local instance] IsCofiltered.isConnected
/-- (Implementation)
The limit cone restricted to `Over i'` is still a limit because the diagram is cofiltered.
See the section docstring. -/
def hc' (j : A.𝒰D.I₀) : IsLimit (A.c' j) :=
isLimitOfPreserves (Over.pullback (A.𝒰D.f j) ⋙ Over.forget _) (Over.isLimitConePost _ A.hc)
variable [∀ i, IsAffineHom (A.c.π.app i)]
lemma exists_eq (j : A.𝒰D.I₀) : ∃ (k : I) (hki' : k ⟶ A.i'),
(A.𝒰D.pullback₁ (D.map hki')).f j ≫ D.map (hki' ≫ A.hii') ≫ A.a =
(A.𝒰D.pullback₁ (D.map hki')).f j ≫ D.map (hki' ≫ A.hii') ≫ A.b := by
have : IsAffine (A.𝒰D.X j) := by dsimp [𝒰D]; infer_instance
have (i : _) : IsAffine ((Over.post D ⋙ Over.pullback (A.𝒰D.f j) ⋙ Over.forget _).obj i) := by
dsimp; infer_instance
have : IsAffine ((Over.pullback (A.𝒰D.f j) ⋙ Over.forget (A.𝒰D.X j)).mapCone
((Over.conePost D A.i').obj A.c)).pt := by
dsimp; infer_instance
have : LocallyOfFiniteType ((A.𝒰X j.fst.fst).f j.fst.snd ≫ A.𝒰S.pullbackHom f j.fst.fst) := by
dsimp [Scheme.Cover.pullbackHom]; infer_instance
have H₁ := congr($(pullback.condition (f := A.g) (g := (Scheme.Pullback.diagonalCover f
A.𝒰S A.𝒰X).f ⟨j.1.1, (j.1.2, j.1.2)⟩)) ≫ pullback.fst _ _)
have H₂ := congr($(pullback.condition (f := A.g) (g := (Scheme.Pullback.diagonalCover f
A.𝒰S A.𝒰X).f ⟨j.1.1, (j.1.2, j.1.2)⟩)) ≫ pullback.snd _ _)
simp only [Scheme.Pullback.openCoverOfBase_I₀, Scheme.Pullback.openCoverOfBase_X,
Scheme.Cover.pullbackHom, Scheme.Pullback.openCoverOfLeftRight_I₀,
g, Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
Scheme.Pullback.diagonalCover_map] at H₁ H₂
obtain ⟨k, hik, hjk, H⟩ := Scheme.exists_hom_hom_comp_eq_comp_of_isAffine_of_locallyOfFiniteType
(Over.post D ⋙ Over.pullback (A.𝒰D.f j) ⋙ Over.forget _)
((Over.post D ⋙ Over.pullback (A.𝒰D.f j)).whiskerLeft (Comma.natTrans _ _) ≫
(Functor.const _).map ((A.𝒰D₀.X j.1).affineCover.f j.2 ≫
(Scheme.Pullback.diagonalCover f A.𝒰S A.𝒰X).pullbackHom _ _ ≫
pullback.fst _ _ ≫
(A.𝒰X j.fst.fst).f j.fst.snd ≫ Scheme.Cover.pullbackHom A.𝒰S f j.fst.fst))
(((A.𝒰X j.1.1).f j.1.2 ≫ A.𝒰S.pullbackHom f j.1.1))
((Over.pullback (A.𝒰D.f j) ⋙ Over.forget _).mapCone ((Over.conePost _ _).obj A.c))
(by
refine isLimitOfPreserves (Over.pullback (A.𝒰D.f j) ⋙ Over.forget _) ?_
apply isLimitOfReflects (Over.forget (D.obj A.i'))
exact (Functor.Initial.isLimitWhiskerEquiv (Over.forget A.i') A.c).symm A.hc)
(i := Over.mk (𝟙 _))
(pullback.snd _ _ ≫ (A.𝒰D₀.X j.1).affineCover.f j.2 ≫
(Scheme.Pullback.diagonalCover f A.𝒰S A.𝒰X).pullbackHom _ _ ≫
pullback.fst _ _)
(by simp)
(j := Over.mk (𝟙 _))
(pullback.snd _ _ ≫ (A.𝒰D₀.X j.1).affineCover.f j.2 ≫
(Scheme.Pullback.diagonalCover f A.𝒰S A.𝒰X).pullbackHom _ _ ≫
pullback.snd _ _)
(by simp [pullback.condition])
(by
rw [← cancel_mono ((A.𝒰X j.1.1).f j.1.2), ← cancel_mono (pullback.fst f (A.𝒰S.f j.1.1))]
have H₃ := congr(pullback.fst (A.c.π.app A.i') (A.𝒰D.f j) ≫ $(A.hab))
simp only [pullback.condition_assoc, 𝒰D, ← A.c.w A.hii', Category.assoc] at H₃
simpa [Scheme.Cover.pullbackHom, g, ← H₁, ← H₂, -Cone.w, -Cone.w_assoc] using H₃)
refine ⟨k.left, k.hom, ?_⟩
simpa [← cancel_mono ((A.𝒰X j.1.1).f j.1.2), ← cancel_mono (pullback.fst f (A.𝒰S.f j.1.1)),
Scheme.Cover.pullbackHom, g, ← H₁, ← H₂, pullback.condition_assoc] using H
end
end ExistsHomHomCompEqCompAux
variable [∀ i, IsAffineHom (c.π.app i)] [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
include hc in
/--
Given a cofiltered diagram `D` of quasi-compact `S`-schemes with affine transition maps,
and another scheme `X` of finite type over `S`.
Then the canonical map `colim Homₛ(Dᵢ, X) ⟶ Homₛ(lim Dᵢ, X)` is injective.
In other words, for each pair of `a : Homₛ(Dᵢ, X)` and `b : Homₛ(Dⱼ, X)` that give rise to the
same map `Homₛ(lim Dᵢ, X)`, there exists a `k` with `fᵢ : k ⟶ i` and `fⱼ : k ⟶ j` such that
`D(fᵢ) ≫ a = D(fⱼ) ≫ b`.
-/
@[stacks 01ZC "Injective part of (1) => (3)"]
lemma Scheme.exists_hom_hom_comp_eq_comp_of_locallyOfFiniteType
{i : I} (a : D.obj i ⟶ X) (ha : t.app i = a ≫ f)
{j : I} (b : D.obj j ⟶ X) (hb : t.app j = b ≫ f)
(hab : c.π.app i ≫ a = c.π.app j ≫ b) :
∃ (k : I) (hik : k ⟶ i) (hjk : k ⟶ j),
D.map hik ≫ a = D.map hjk ≫ b := by
classical
wlog h : i = j
· let o := IsCofiltered.min i j
have := this D t f c hc (D.map (IsCofiltered.minToLeft i j) ≫ a)
(by simp [← ha]) (D.map (IsCofiltered.minToRight i j) ≫ b)
(by simp [← hb]) (by simpa) rfl
obtain ⟨k, hik, hjk, heq⟩ := this
use k, hik ≫ IsCofiltered.minToLeft i j, hjk ≫ IsCofiltered.minToRight i j
simpa using heq
subst h
let A : ExistsHomHomCompEqCompAux D t f :=
{ c := c, hc := hc, i := i, a := a, ha := ha, b := b, hb := hb, hab := hab
𝒰S := S.affineCover, 𝒰X i := Scheme.affineCover _ }
let 𝒰 := Scheme.Pullback.diagonalCover f A.𝒰S A.𝒰X
let W := Scheme.Pullback.diagonalCoverDiagonalRange f A.𝒰S A.𝒰X
choose k hki' heq using A.exists_eq
let 𝒰Df := A.𝒰D.finiteSubcover
rcases isEmpty_or_nonempty (D.obj A.i') with h | h
· exact ⟨A.i', A.hii', A.hii', isInitialOfIsEmpty.hom_ext _ _⟩
let O : Finset I := {A.i'} ∪ Finset.univ.image (fun i : 𝒰Df.I₀ ↦ k <| A.𝒰D.idx i.1)
let o := Nonempty.some (inferInstanceAs <| Nonempty 𝒰Df.I₀)
have ho : k (A.𝒰D.idx o.1) ∈ O := by
simp [O]
obtain ⟨l, hl1, hl2⟩ := IsCofiltered.inf_exists O
(Finset.univ.image (fun i : 𝒰Df.I₀ ↦
⟨k <| A.𝒰D.idx i.1, A.i', by simp [O], by simp [O], hki' <| A.𝒰D.idx i.1⟩))
have (w v : 𝒰Df.I₀) :
hl1 (by simp [O]) ≫ hki' (A.𝒰D.idx w.1) = hl1 (by simp [O]) ≫ hki' (A.𝒰D.idx v.1) := by
trans hl1 (show A.i' ∈ O by simp [O])
· exact hl2 _ _ (Finset.mem_image_of_mem _ (Finset.mem_univ _))
· exact .symm <| hl2 _ _ (Finset.mem_image_of_mem _ (by simp))
refine ⟨l, hl1 ho ≫ hki' _ ≫ A.hii', hl1 ho ≫ hki' _ ≫ A.hii', ?_⟩
apply Cover.hom_ext (𝒰Df.pullback₁ (D.map <| hl1 ho ≫ hki' _))
intro u
let F : pullback (D.map (hl1 ho ≫ hki' (A.𝒰D.idx o.1))) (𝒰Df.f u) ⟶
pullback (D.map (hki' <| A.𝒰D.idx u.1)) (A.𝒰D.f <| A.𝒰D.idx u.1) :=
pullback.map _ _ _ _ (D.map <| hl1 (by simp [O]))
(𝟙 _) (𝟙 _) (by rw [Category.comp_id, ← D.map_comp, this]) rfl
have hF : F ≫ pullback.fst (D.map (hki' _)) (A.𝒰D.f _) =
pullback.fst _ _ ≫ D.map (hl1 (by simp [O])) := by simp [F]
simp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_X, PreZeroHypercover.pullback₁_f, Functor.map_comp, Category.assoc]
at heq ⊢
simp_rw [← D.map_comp_assoc, reassoc_of% this o u, D.map_comp_assoc]
rw [← reassoc_of% hF, ← reassoc_of% hF, heq]
end LocallyOfFiniteType
/-!
### Sections of the limit
Let `D` be a cofiltered diagram of schemes with affine transition maps.
Consider the canonical map `colim Γ(Dᵢ, ⊤) ⟶ Γ(lim Dᵢ, ⊤)`.
If `D` consists of quasicompact schemes, then this map is injective. More generally, we show
that if `s t : Γ(Dᵢ, U)` have equal image in `lim Dᵢ`, then they are equal at some `Γ(Dⱼ, Dⱼᵢ⁻¹ U)`.
See `AlgebraicGeometry.exists_app_map_eq_map_of_isLimit`.
If `D` consists of qcqs schemes, then this map is surjective. Specifically, we show that
any `s : Γ(lim Dᵢ, ⊤)` comes from `Γ(Dᵢ, ⊤)` for some `i`.
See `AlgebraicGeometry.exists_appTop_π_eq_of_isLimit`.
These two results imply that `PreservesLimit D Scheme.Γ.rightOp`, which is available as an instance.
-/
section sections
variable [IsCofiltered I]
include hc in
lemma exists_appTop_map_eq_zero_of_isAffine_of_isLimit
[∀ i, IsAffine (D.obj i)]
(i : I) (s : Γ(D.obj i, ⊤)) (hs : (c.π.app i).appTop s = 0) :
∃ (j : I) (f : j ⟶ i), (D.map f).appTop s = 0 := by
have : ∀ i, IsAffine (D.op.obj i).unop := by dsimp; infer_instance
obtain ⟨j, f, hj⟩ := (Types.FilteredColimit.isColimit_eq_iff'
(isColimitOfPreserves (Scheme.Γ ⋙ forget _) hc.op) s (0 : Γ(D.obj i, ⊤))).mp (by simpa)
exact ⟨j.unop, f.unop, by simpa using hj⟩
include hc in
lemma exists_appTop_map_eq_zero_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
{i : I} [CompactSpace (D.obj i)] (s : Γ(D.obj i, ⊤)) (hs : (c.π.app i).appTop s = 0) :
∃ (j : I) (f : j ⟶ i), (D.map f).appTop s = 0 := by
classical
have (x : D.obj i) : ∃ (U : (D.obj i).Opens) (hU : IsAffineOpen U)
(hU : x ∈ U) (j : I) (f : j ⟶ i), (D.map f).app U (s |_ U) = 0 := by
obtain ⟨_, ⟨U, hU : IsAffineOpen U, rfl⟩, hxU, -⟩ :=
(D.obj i).isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
have (j : Over i) : IsAffine ((opensDiagram D i U).obj j) := hU.preimage (D.map _)
obtain ⟨j, f, hj⟩ := exists_appTop_map_eq_zero_of_isAffine_of_isLimit _ _
(isLimitOpensCone D c hc i U) (.mk (𝟙 i)) (((opensDiagramι D i U).app _).appTop s) (by
convert congr((c.pt.presheaf.map (homOfLE le_top).op).hom $hs) using 1
· simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE, ← ConcreteCategory.comp_apply]; rfl
· simp)
refine ⟨U, hU, hxU, j.left, j.hom, ?_⟩
have hf : f.left = j.hom := by simpa using Over.w f
let t' : Γ(D.map j.hom ⁻¹ᵁ U, ⊤) ⟶ Γ(D.obj j.left, D.map j.hom ⁻¹ᵁ U) :=
(D.obj _).presheaf.map (eqToHom ((D.map j.hom ⁻¹ᵁ U).ι_image_top.symm)).op
convert congr(t' $hj)
· dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
simp only [Scheme.Hom.app_eq_appLE, homOfLE_leOfHom, ← ConcreteCategory.comp_apply, hf,
Scheme.Hom.map_appLE, TopologicalSpace.Opens.map_top, Scheme.Hom.resLE_appLE]
simp [t']
· simp
choose U hU hxU j f H using this
obtain ⟨t, ht⟩ := CompactSpace.elim_nhds_subcover (U ·) (fun x ↦ (U x).2.mem_nhds (hxU x))
obtain ⟨k, fk, hk⟩ := IsCofiltered.inf_exists (insert i <| t.image j) (by
exact t.attach.image fun x ↦ ⟨j x.1, i, Finset.mem_insert_of_mem
(Finset.mem_image_of_mem _ x.2), by simp, f x.1⟩)
refine ⟨k, fk (by simp), ?_⟩
apply (D.obj k).IsSheaf.section_ext
rintro x -
obtain ⟨l, hl, hlU⟩ := Set.mem_iUnion₂.mp (ht.ge (Set.mem_univ ((D.map (fk (by simp))).base x)))
refine ⟨D.map (fk (by simp)) ⁻¹ᵁ U l, le_top, hlU, ?_⟩
dsimp
simp only [homOfLE_leOfHom, map_zero]
have h₁ : fk (by simp) = fk (Finset.mem_insert_of_mem (Finset.mem_image_of_mem _ hl)) ≫ f l :=
(hk _ (by simp) (Finset.mem_image.mpr ⟨⟨l, hl⟩, by simp, by simp⟩)).symm
have h₂ : D.map (fk (Finset.mem_insert_self _ _)) ⁻¹ᵁ U l ≤ D.map (fk (Finset.mem_insert_of_mem
(Finset.mem_image_of_mem _ hl))) ⁻¹ᵁ D.map (f l) ⁻¹ᵁ U l := by
rw [← Scheme.Hom.comp_preimage, ← D.map_comp, h₁]
convert congr((D.map (fk _)).appLE _ _ h₂ $(H l))
· dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
simp [Scheme.Hom.app_eq_appLE, ← ConcreteCategory.comp_apply, - CommRingCat.hom_comp,
Scheme.Hom.appLE_comp_appLE, ← Functor.map_comp, h₁]
· simp
include hc in
lemma exists_app_map_eq_zero_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
{i : I} {U : (D.obj i).Opens} (hU : IsCompact (X := D.obj i) U) (s : Γ(D.obj i, U))
(hs : (c.π.app i).app U s = 0) :
∃ (j : I) (f : j ⟶ i), (D.map f).app U s = 0 := by
have : CompactSpace ↥((opensDiagram D i U).obj (Over.mk (𝟙 i))) :=
isCompact_iff_compactSpace.mp (by simpa)
have H : (D.map (𝟙 _) ⁻¹ᵁ U).ι ''ᵁ ⊤ ≤ U := by simp
obtain ⟨j, f, hf⟩ := exists_appTop_map_eq_zero_of_isLimit _ _
(isLimitOpensCone D c hc i U) (i := .mk (𝟙 i))
((D.obj i).presheaf.map (homOfLE (show (D.map (𝟙 _) ⁻¹ᵁ U).ι ''ᵁ ⊤ ≤ U by simp)).op s) (by
rw [← map_zero (c.pt.presheaf.map (homOfLE
(show (c.π.app i ⁻¹ᵁ U).ι ''ᵁ ⊤ ≤ c.π.app i ⁻¹ᵁ U by simp)).op).hom, ← hs]
dsimp [Scheme.Opens.toScheme_presheaf_obj]
rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply]
congr! 2
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE])
dsimp at hf
refine ⟨j.left, f.left, ?_⟩
have hf' : f.left = j.hom := by simpa using Over.w f
convert congr((D.obj j.left).presheaf.map (homOfLE
(show D.map f.left ⁻¹ᵁ U ≤ (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤ by simp [hf'])).op $hf)
· dsimp [Scheme.Opens.toScheme_presheaf_obj]
rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply]
congr! 2
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE]
· simp
include hc in
lemma exists_app_map_eq_map_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
{i : I} {U : (D.obj i).Opens} (hU : IsCompact (X := D.obj i) U) (s t : Γ(D.obj i, U))
(hs : (c.π.app i).app U s = (c.π.app i).app U t) :
∃ (j : I) (f : j ⟶ i), (D.map f).app U s = (D.map f).app U t := by
simpa [sub_eq_zero] using exists_app_map_eq_zero_of_isLimit _ _ hc hU (s - t)
(by simpa [map_sub, sub_eq_zero])
include hc in
lemma exists_appTop_π_eq_of_isAffine_of_isLimit
[∀ i, IsAffine (D.obj i)] (s : Γ(c.pt, ⊤)) :
∃ (i : I) (t : Γ(D.obj i, ⊤)), (c.π.app i).appTop t = s := by
have : ∀ i, IsAffine (D.op.obj i).unop := by dsimp; infer_instance
exact ⟨_, (Types.jointly_surjective_of_isColimit
(isColimitOfPreserves (Scheme.Γ ⋙ forget _) hc.op) s).choose_spec⟩
include hc in
lemma exists_appTop_π_eq_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
(s : Γ(c.pt, ⊤)) [∀ i, CompactSpace (D.obj i)] [∀ i, QuasiSeparatedSpace (D.obj i)] :
∃ (i : I) (t : Γ(D.obj i, ⊤)), s = (c.π.app i).appTop t := by
classical
have := Scheme.compactSpace_of_isLimit _ _ hc
have (x : c.pt) : ∃ (i : I) (U : (D.obj i).Opens) (hU : IsAffineOpen U)
(hU : (c.π.app i).base x ∈ U) (t : Γ(D.obj i, U)), (c.π.app i).app U t = s |_ _ := by
have i := IsCofiltered.nonempty (C := I).some
obtain ⟨_, ⟨U, hU : IsAffineOpen U, rfl⟩, hxU, -⟩ :=
(D.obj i).isBasis_affineOpens.exists_subset_of_mem_open
(Set.mem_univ ((c.π.app i).base x)) isOpen_univ
have (j : Over i) : IsAffine ((opensDiagram D i U).obj j) := hU.preimage (D.map _)
obtain ⟨j, t, hj⟩ := exists_appTop_π_eq_of_isAffine_of_isLimit _ _
(isLimitOpensCone D c hc i U) (s |_ _)
refine ⟨j.left, (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤, by simpa using hU.preimage (D.map _), ?_, t, ?_⟩
· suffices (c.π.app j.1 ≫ D.map j.hom).base x ∈ U by simpa [-Cone.w] using this
rwa [Cone.w]
· have H : c.π.app j.left ⁻¹ᵁ (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤ ≤ (c.π.app i ⁻¹ᵁ U).ι ''ᵁ ⊤ := by
simp [← Scheme.Hom.comp_preimage]
convert congr(c.pt.presheaf.map (homOfLE H).op $hj)
· convert ConcreteCategory.comp_apply _ _ _
congr
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE]
· dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
change _ = (c.pt.presheaf.map (homOfLE _).op ≫ c.pt.presheaf.map (homOfLE _).op) s
rw [← Functor.map_comp]
rfl
choose i U hU hxU t ht using this
dsimp at ht
have (x y : c.pt) : ∃ (j : I) (fjx : j ⟶ i x) (fjy : j ⟶ i y),
(D.map fjx).app (U x) (t x) |_ (D.map fjx ⁻¹ᵁ U x ⊓ D.map fjy ⁻¹ᵁ U y) =
(D.map fjy).app (U y) (t y) |_ (D.map fjx ⁻¹ᵁ U x ⊓ D.map fjy ⁻¹ᵁ U y) := by
obtain ⟨j, fjx, fjy, -⟩ := IsCofilteredOrEmpty.cone_objs (i x) (i y)
obtain ⟨k, fkj, hk⟩ := exists_app_map_eq_zero_of_isLimit D c hc
(((hU x).preimage (D.map fjx)).isCompact.inter_of_isOpen
((hU y).preimage (D.map fjy)).isCompact ((U x).2.preimage (D.map fjx).continuous)
((U y).2.preimage (D.map fjy).continuous))
((D.map fjx).app (U x) (t x) |_ (D.map fjx ⁻¹ᵁ U x ⊓ D.map fjy ⁻¹ᵁ U y) -
(D.map fjy).app (U y) (t y) |_ (D.map fjx ⁻¹ᵁ U x ⊓ D.map fjy ⁻¹ᵁ U y)) (by
dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
simp only [map_sub, sub_eq_zero, ← ConcreteCategory.comp_apply,
Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_map, Scheme.Hom.appLE_comp_appLE,
Cone.w]
simp_rw [Scheme.Hom.appLE, ConcreteCategory.comp_apply, ht, TopCat.Presheaf.restrictOpen,
TopCat.Presheaf.restrict, ← ConcreteCategory.comp_apply, ← Functor.map_comp]
rfl)
refine ⟨k, fkj ≫ fjx, fkj ≫ fjy, ?_⟩
have H : (D.map (fkj ≫ fjx) ⁻¹ᵁ U x ⊓ D.map (fkj ≫ fjy) ⁻¹ᵁ U y) ≤
D.map fkj ⁻¹ᵁ ((D.map fjx ⁻¹ᵁ U x ⊓ D.map fjy ⁻¹ᵁ U y)) := by simp; rfl
apply_fun (D.obj k).presheaf.map (homOfLE H).op at hk
dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] at hk ⊢
simpa [sub_eq_zero, ← ConcreteCategory.comp_apply, - Scheme.Hom.comp_appLE,
Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE] using hk
choose j fjx fjy hj using this
obtain ⟨σ, hσ⟩ := CompactSpace.elim_nhds_subcover (fun x ↦ ((c.π.app (i x)) ⁻¹ᵁ U x).1)
(fun x ↦ ((c.π.app (i x)) ⁻¹ᵁ U x).2.mem_nhds (by exact hxU x))
choose σi hσiσ hσi using fun x ↦ Set.mem_iUnion₂.mp (hσ.ge (Set.mem_univ x))
let S : Finset _ := σ.image i ∪ Finset.image₂ j σ σ
have hiS {x} (hx : x ∈ σ) : i x ∈ S := Finset.subset_union_left (Finset.mem_image_of_mem i hx)
have hjS {x y} (hx : x ∈ σ) (hy : y ∈ σ) : j x y ∈ S :=
Finset.subset_union_right (Finset.mem_image₂_of_mem hx hy)
obtain ⟨k, fk, hk⟩ := IsCofiltered.inf_exists S
(σ.attach.image₂ (fun (x y : σ) ↦ ⟨j x.1 y.1, i x.1, hjS x.2 y.2, hiS x.2, fjx x y⟩) σ.attach ∪
σ.attach.image₂ (fun (x y : σ) ↦ ⟨j x.1 y.1, i y.1, hjS x.2 y.2, hiS y.2, fjy x y⟩) σ.attach)
have hk₁ {x y} (hx : x ∈ σ) (hy : y ∈ σ) := hk (hjS hx hy) (hiS hx) (f := fjx x y)
(Finset.subset_union_left (Finset.mem_image₂.mpr ⟨⟨x, hx⟩, by simp, ⟨y, hy⟩, by simp, rfl⟩))
have hk₂ {x y} (hx : x ∈ σ) (hy : y ∈ σ) := hk (hjS hx hy) (hiS hy) (f := fjy x y)
(Finset.subset_union_right (Finset.mem_image₂.mpr ⟨⟨x, hx⟩, by simp, ⟨y, hy⟩, by simp, rfl⟩))
obtain ⟨k', fk'k, hk'⟩ := exists_map_eq_top D c hc
(⨆ (x : _) (hx : x ∈ σ), D.map (fk (hiS hx)) ⁻¹ᵁ U x) (by
apply SetLike.coe_injective
simpa [← Set.preimage_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base])
have := ((Presheaf.isSheaf_iff_isSheaf_forget _ _ (forget _)).mp (D.obj k').IsSheaf).isSheafFor
(.ofArrows (fun x : σ ↦ D.map (fk'k ≫ fk (hiS x.2)) ⁻¹ᵁ U x.1) fun x ↦ homOfLE le_top)
(fun x _ ↦ by
obtain ⟨ix, hix, h⟩ : ∃ ix, ∃ (h : ix ∈ σ), (D.map (fk'k ≫ fk (hiS h))).base x ∈ U ix := by
simpa using hk'.ge (Set.mem_univ x)
refine ⟨D.map (fk'k ≫ fk (hiS hix)) ⁻¹ᵁ U ix, homOfLE le_top,
Sieve.ofArrows_mk (I := σ) _ _ ⟨ix, hix⟩, h⟩)
rw [← Presieve.isSheafFor_iff_generate, Presieve.isSheafFor_arrows_iff] at this
obtain ⟨t₀, ht₀, -⟩ := this (fun x ↦ (D.map _).app _ (t x)) fun x y V fVx fVy _ ↦ by
have H : V ≤ D.map (fk'k ≫ fk (hjS x.2 y.2)) ⁻¹ᵁ
(D.map (fjx ↑x ↑y) ⁻¹ᵁ U ↑x ⊓ D.map (fjy ↑x ↑y) ⁻¹ᵁ U ↑y) := by
change V ≤ (D.map (fk'k ≫ fk (hjS x.2 y.2)) ≫ D.map (fjx ↑x ↑y)) ⁻¹ᵁ U x ⊓
(D.map (fk'k ≫ fk (hjS x.2 y.2)) ≫ D.map (fjy x y)) ⁻¹ᵁ U y
rw [← Functor.map_comp, ← Functor.map_comp, Category.assoc, Category.assoc,
hk₁ x.2 y.2, hk₂ x.2 y.2, le_inf_iff]
exact ⟨fVx.le, fVy.le⟩
convert congr(((D.map (fk'k ≫ fk (hjS x.2 y.2))).app _ ≫
(D.obj k').presheaf.map (homOfLE H).op) $(hj x y)) using 1
· dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
simp only [← ConcreteCategory.comp_apply]
congr 2
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE,
- Scheme.Hom.comp_appLE, ← Functor.map_comp, hk₁]
· dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
simp only [← ConcreteCategory.comp_apply]
congr 2
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE,
- Scheme.Hom.comp_appLE, ← Functor.map_comp, hk₂]
refine ⟨k', t₀, TopCat.Presheaf.section_ext c.pt.sheaf _ _ _ fun y hy ↦ c.pt.presheaf.germ_ext
(c.π.app _ ⁻¹ᵁ U (σi y)) (hσi y) (homOfLE le_top) (homOfLE le_top) ?_⟩
have H : c.π.app (i (σi y)) ⁻¹ᵁ U (σi y) ≤
c.π.app k' ⁻¹ᵁ D.map (fk'k ≫ fk (hiS (hσiσ _))) ⁻¹ᵁ U (σi y) := by
rw [← Scheme.Hom.comp_preimage, Cone.w]
convert congr(c.pt.presheaf.map (homOfLE H).op ((c.π.app k').app _ $(ht₀ ⟨_, hσiσ y⟩))).symm
· refine (ht (σi y)).symm.trans ?_
dsimp [Scheme.Opens.toScheme_presheaf_obj]
rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply]
congr 2
simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE, -Scheme.Hom.comp_appLE]
· dsimp [Scheme.Opens.toScheme_presheaf_obj]
rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply,
← ConcreteCategory.comp_apply]
congr 2
simp [Scheme.Hom.app_eq_appLE]
include hc in
lemma nonempty_isColimit_Γ_mapCocone [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
[∀ i, CompactSpace (D.obj i)] [∀ i, QuasiSeparatedSpace (D.obj i)] :
Nonempty (IsColimit (Scheme.Γ.mapCocone c.op)) := by
have : ReflectsFilteredColimits (forget CommRingCat) :=
⟨fun _ ↦ reflectsColimitsOfShape_of_reflectsIsomorphisms⟩
refine ReflectsColimit.reflects (F := forget _) (Types.FilteredColimit.isColimitOf' _ _ ?_ ?_)
· exact fun s ↦ ⟨.op _, (exists_appTop_π_eq_of_isLimit D c hc s).choose_spec⟩
· exact fun i s t e ↦ ⟨_, Quiver.Hom.op _,
(exists_app_map_eq_map_of_isLimit _ _ hc isCompact_univ s t e).choose_spec.choose_spec⟩
instance [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)]
[∀ i, CompactSpace (D.obj i)] [∀ i, QuasiSeparatedSpace (D.obj i)] :
PreservesLimit D Scheme.Γ.rightOp :=
have : PreservesColimit D.op Scheme.Γ := ⟨fun hc ↦ nonempty_isColimit_Γ_mapCocone D _ hc.unop⟩
preservesLimit_rightOp _ _
end sections
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/RationalMap.lean | import Mathlib.AlgebraicGeometry.SpreadingOut
import Mathlib.AlgebraicGeometry.FunctionField
import Mathlib.AlgebraicGeometry.Morphisms.Separated
/-!
# Rational maps between schemes
## Main definitions
* `AlgebraicGeometry.Scheme.PartialMap`: A partial map from `X` to `Y` (`X.PartialMap Y`) is
a morphism into `Y` defined on a dense open subscheme of `X`.
* `AlgebraicGeometry.Scheme.PartialMap.equiv`:
Two partial maps are equivalent if they are equal on a dense open subscheme.
* `AlgebraicGeometry.Scheme.RationalMap`:
A rational map from `X` to `Y` (`X ⤏ Y`) is an equivalence class of partial maps.
* `AlgebraicGeometry.Scheme.RationalMap.equivFunctionFieldOver`:
Given `S`-schemes `X` and `Y` such that `Y` is locally of finite type and `X` is integral,
`S`-morphisms `Spec K(X) ⟶ Y` correspond bijectively to `S`-rational maps from `X` to `Y`.
* `AlgebraicGeometry.Scheme.RationalMap.toPartialMap`:
If `X` is integral and `Y` is separated, then any `f : X ⤏ Y` can be realized as a partial
map on `f.domain`, the domain of definition of `f`.
-/
universe u
open CategoryTheory hiding Quotient
namespace AlgebraicGeometry
variable {X Y Z S : Scheme.{u}} (sX : X ⟶ S) (sY : Y ⟶ S)
namespace Scheme
/--
A partial map from `X` to `Y` (`X.PartialMap Y`) is a morphism into `Y`
defined on a dense open subscheme of `X`.
-/
structure PartialMap (X Y : Scheme.{u}) where
/-- The domain of definition of a partial map. -/
domain : X.Opens
dense_domain : Dense (domain : Set X)
/-- The underlying morphism of a partial map. -/
hom : ↑domain ⟶ Y
variable (S) in
/-- A partial map is a `S`-map if the underlying morphism is. -/
abbrev PartialMap.IsOver [X.Over S] [Y.Over S] (f : X.PartialMap Y) :=
f.hom.IsOver S
namespace PartialMap
lemma ext_iff (f g : X.PartialMap Y) :
f = g ↔ ∃ e : f.domain = g.domain, f.hom = (X.isoOfEq e).hom ≫ g.hom := by
constructor
· rintro rfl
simp only [exists_true_left, Scheme.isoOfEq_rfl, Iso.refl_hom, Category.id_comp]
· obtain ⟨U, hU, f⟩ := f
obtain ⟨V, hV, g⟩ := g
rintro ⟨rfl : U = V, e⟩
congr 1
simpa using e
@[ext]
lemma ext (f g : X.PartialMap Y) (e : f.domain = g.domain)
(H : f.hom = (X.isoOfEq e).hom ≫ g.hom) : f = g := by
rw [ext_iff]
exact ⟨e, H⟩
/-- The restriction of a partial map to a smaller domain. -/
@[simps hom domain]
noncomputable
def restrict (f : X.PartialMap Y) (U : X.Opens)
(hU : Dense (U : Set X)) (hU' : U ≤ f.domain) : X.PartialMap Y where
domain := U
dense_domain := hU
hom := X.homOfLE hU' ≫ f.hom
@[simp]
lemma restrict_id (f : X.PartialMap Y) : f.restrict f.domain f.dense_domain le_rfl = f := by
ext1 <;> simp [restrict_domain]
lemma restrict_id_hom (f : X.PartialMap Y) :
(f.restrict f.domain f.dense_domain le_rfl).hom = f.hom := by
simp
@[simp]
lemma restrict_restrict (f : X.PartialMap Y)
(U : X.Opens) (hU : Dense (U : Set X)) (hU' : U ≤ f.domain)
(V : X.Opens) (hV : Dense (V : Set X)) (hV' : V ≤ U) :
(f.restrict U hU hU').restrict V hV hV' = f.restrict V hV (hV'.trans hU') := by
ext1 <;> simp [restrict_domain]
lemma restrict_restrict_hom (f : X.PartialMap Y)
(U : X.Opens) (hU : Dense (U : Set X)) (hU' : U ≤ f.domain)
(V : X.Opens) (hV : Dense (V : Set X)) (hV' : V ≤ U) :
((f.restrict U hU hU').restrict V hV hV').hom = (f.restrict V hV (hV'.trans hU')).hom := by
simp
instance [X.Over S] [Y.Over S] (f : X.PartialMap Y) [f.IsOver S]
(U : X.Opens) (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) :
(f.restrict U hU hU').IsOver S where
/-- The composition of a partial map and a morphism on the right. -/
@[simps]
def compHom (f : X.PartialMap Y) (g : Y ⟶ Z) : X.PartialMap Z where
domain := f.domain
dense_domain := f.dense_domain
hom := f.hom ≫ g
instance [X.Over S] [Y.Over S] [Z.Over S] (f : X.PartialMap Y) (g : Y ⟶ Z)
[f.IsOver S] [g.IsOver S] : (f.compHom g).IsOver S where
/-- A scheme morphism as a partial map. -/
@[simps]
def _root_.AlgebraicGeometry.Scheme.Hom.toPartialMap (f : X.Hom Y) :
X.PartialMap Y := ⟨⊤, dense_univ, X.topIso.hom ≫ f⟩
instance [X.Over S] [Y.Over S] (f : X ⟶ Y) [f.IsOver S] : f.toPartialMap.IsOver S where
lemma isOver_iff [X.Over S] [Y.Over S] {f : X.PartialMap Y} :
f.IsOver S ↔ (f.compHom (Y ↘ S)).hom = f.domain.ι ≫ X ↘ S := by
simp
lemma isOver_iff_eq_restrict [X.Over S] [Y.Over S] {f : X.PartialMap Y} :
f.IsOver S ↔ f.compHom (Y ↘ S) = (X ↘ S).toPartialMap.restrict _ f.dense_domain (by simp) := by
simp [PartialMap.ext_iff]
/-- If `x` is in the domain of a partial map `f`, then `f` restricts to a map from `Spec 𝒪_x`. -/
noncomputable
def fromSpecStalkOfMem (f : X.PartialMap Y) {x} (hx : x ∈ f.domain) :
Spec (X.presheaf.stalk x) ⟶ Y :=
f.domain.fromSpecStalkOfMem x hx ≫ f.hom
/-- A partial map restricts to a map from `Spec K(X)`. -/
noncomputable
abbrev fromFunctionField [IrreducibleSpace X] (f : X.PartialMap Y) :
Spec X.functionField ⟶ Y :=
f.fromSpecStalkOfMem
((genericPoint_specializes _).mem_open f.domain.2 f.dense_domain.nonempty.choose_spec)
lemma fromSpecStalkOfMem_restrict (f : X.PartialMap Y)
{U : X.Opens} (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) {x} (hx : x ∈ U) :
(f.restrict U hU hU').fromSpecStalkOfMem hx = f.fromSpecStalkOfMem (hU' hx) := by
dsimp only [fromSpecStalkOfMem, restrict, Scheme.Opens.fromSpecStalkOfMem]
have e : ⟨x, hU' hx⟩ = X.homOfLE hU' ⟨x, hx⟩ := by
rw [Scheme.homOfLE_base]
rfl
rw [Category.assoc, ← SpecMap_stalkMap_fromSpecStalk_assoc,
← SpecMap_stalkSpecializes_fromSpecStalk (Inseparable.of_eq e).specializes,
← TopCat.Presheaf.stalkCongr_inv _ (Inseparable.of_eq e)]
simp only [← Category.assoc, ← Spec.map_comp]
congr 3
rw [Iso.eq_inv_comp, ← Category.assoc, IsIso.comp_inv_eq, IsIso.eq_inv_comp,
Hom.stalkMap_congr_hom _ _ (X.homOfLE_ι hU').symm]
simp only [TopCat.Presheaf.stalkCongr_hom]
rw [← Hom.stalkSpecializes_stalkMap_assoc, Hom.stalkMap_comp]
lemma fromFunctionField_restrict (f : X.PartialMap Y) [IrreducibleSpace X]
{U : X.Opens} (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) :
(f.restrict U hU hU').fromFunctionField = f.fromFunctionField :=
fromSpecStalkOfMem_restrict f _ _ _
/--
Given `S`-schemes `X` and `Y` such that `Y` is locally of finite type and
`X` is irreducible germ-injective at `x` (e.g. when `X` is integral),
any `S`-morphism `Spec 𝒪ₓ ⟶ Y` spreads out to a partial map from `X` to `Y`.
-/
noncomputable
def ofFromSpecStalk [IrreducibleSpace X] [LocallyOfFiniteType sY] {x : X} [X.IsGermInjectiveAt x]
(φ : Spec (X.presheaf.stalk x) ⟶ Y) (h : φ ≫ sY = X.fromSpecStalk x ≫ sX) : X.PartialMap Y where
hom := (spread_out_of_isGermInjective' sX sY φ h).choose_spec.choose_spec.choose
domain := (spread_out_of_isGermInjective' sX sY φ h).choose
dense_domain := (spread_out_of_isGermInjective' sX sY φ h).choose.2.dense
⟨_, (spread_out_of_isGermInjective' sX sY φ h).choose_spec.choose⟩
lemma ofFromSpecStalk_comp [IrreducibleSpace X] [LocallyOfFiniteType sY]
{x : X} [X.IsGermInjectiveAt x] (φ : Spec (X.presheaf.stalk x) ⟶ Y)
(h : φ ≫ sY = X.fromSpecStalk x ≫ sX) :
(ofFromSpecStalk sX sY φ h).hom ≫ sY = (ofFromSpecStalk sX sY φ h).domain.ι ≫ sX :=
(spread_out_of_isGermInjective' sX sY φ h).choose_spec.choose_spec.choose_spec.2
lemma mem_domain_ofFromSpecStalk [IrreducibleSpace X] [LocallyOfFiniteType sY]
{x : X} [X.IsGermInjectiveAt x] (φ : Spec (X.presheaf.stalk x) ⟶ Y)
(h : φ ≫ sY = X.fromSpecStalk x ≫ sX) : x ∈ (ofFromSpecStalk sX sY φ h).domain :=
(spread_out_of_isGermInjective' sX sY φ h).choose_spec.choose
lemma fromSpecStalkOfMem_ofFromSpecStalk [IrreducibleSpace X] [LocallyOfFiniteType sY]
{x : X} [X.IsGermInjectiveAt x] (φ : Spec (X.presheaf.stalk x) ⟶ Y)
(h : φ ≫ sY = X.fromSpecStalk x ≫ sX) :
(ofFromSpecStalk sX sY φ h).fromSpecStalkOfMem (mem_domain_ofFromSpecStalk sX sY φ h) = φ :=
(spread_out_of_isGermInjective' sX sY φ h).choose_spec.choose_spec.choose_spec.1.symm
@[simp]
lemma fromSpecStalkOfMem_compHom (f : X.PartialMap Y) (g : Y ⟶ Z) (x) (hx) :
(f.compHom g).fromSpecStalkOfMem (x := x) hx = f.fromSpecStalkOfMem hx ≫ g := by
simp [fromSpecStalkOfMem]
@[simp]
lemma fromSpecStalkOfMem_toPartialMap (f : X ⟶ Y) (x) :
f.toPartialMap.fromSpecStalkOfMem (x := x) trivial = X.fromSpecStalk x ≫ f := by
simp [fromSpecStalkOfMem]
/-- Two partial maps are equivalent if they are equal on a dense open subscheme. -/
protected noncomputable
def equiv (f g : X.PartialMap Y) : Prop :=
∃ (W : X.Opens) (hW : Dense (W : Set X)) (hWl : W ≤ f.domain) (hWr : W ≤ g.domain),
(f.restrict W hW hWl).hom = (g.restrict W hW hWr).hom
lemma equivalence_rel : Equivalence (@Scheme.PartialMap.equiv X Y) where
refl f := ⟨f.domain, f.dense_domain, by simp⟩
symm {f g} := by
intro ⟨W, hW, hWl, hWr, e⟩
exact ⟨W, hW, hWr, hWl, e.symm⟩
trans {f g h} := by
intro ⟨W₁, hW₁, hW₁l, hW₁r, e₁⟩ ⟨W₂, hW₂, hW₂l, hW₂r, e₂⟩
refine ⟨W₁ ⊓ W₂, hW₁.inter_of_isOpen_left hW₂ W₁.2, inf_le_left.trans hW₁l,
inf_le_right.trans hW₂r, ?_⟩
dsimp at e₁ e₂
simp only [restrict_domain, restrict_hom, ← X.homOfLE_homOfLE (U := W₁ ⊓ W₂) inf_le_left hW₁l,
Category.assoc, e₁, ← X.homOfLE_homOfLE (U := W₁ ⊓ W₂) inf_le_right hW₂r, ← e₂]
simp only [homOfLE_homOfLE_assoc]
instance : Setoid (X.PartialMap Y) := ⟨@PartialMap.equiv X Y, equivalence_rel⟩
lemma restrict_equiv (f : X.PartialMap Y) (U : X.Opens)
(hU : Dense (U : Set X)) (hU' : U ≤ f.domain) : (f.restrict U hU hU').equiv f :=
⟨U, hU, le_rfl, hU', by simp⟩
lemma equiv_of_fromSpecStalkOfMem_eq [IrreducibleSpace X]
{x : X} [X.IsGermInjectiveAt x] (f g : X.PartialMap Y)
(hxf : x ∈ f.domain) (hxg : x ∈ g.domain)
(H : f.fromSpecStalkOfMem hxf = g.fromSpecStalkOfMem hxg) : f.equiv g := by
have hdense : Dense ((f.domain ⊓ g.domain) : Set X) :=
f.dense_domain.inter_of_isOpen_left g.dense_domain f.domain.2
have := (isGermInjectiveAt_iff_of_isOpenImmersion (f := (f.domain ⊓ g.domain).ι)
(x := ⟨x, hxf, hxg⟩)).mp ‹_›
have := spread_out_unique_of_isGermInjective' (X := (f.domain ⊓ g.domain).toScheme)
(X.homOfLE inf_le_left ≫ f.hom) (X.homOfLE inf_le_right ≫ g.hom) (x := ⟨x, hxf, hxg⟩) ?_
· obtain ⟨U, hxU, e⟩ := this
refine ⟨(f.domain ⊓ g.domain).ι ''ᵁ U, ((f.domain ⊓ g.domain).ι ''ᵁ U).2.dense
⟨_, ⟨_, hxU, rfl⟩⟩,
((Set.image_subset_range _ _).trans_eq (Subtype.range_val)).trans inf_le_left,
((Set.image_subset_range _ _).trans_eq (Subtype.range_val)).trans inf_le_right, ?_⟩
rw [← cancel_epi (Scheme.Hom.isoImage _ _).hom]
simp only [restrict_hom, ← Category.assoc] at e ⊢
convert e using 2 <;> rw [← cancel_mono (Scheme.Opens.ι _)] <;> simp
· rw [← f.fromSpecStalkOfMem_restrict hdense inf_le_left ⟨hxf, hxg⟩,
← g.fromSpecStalkOfMem_restrict hdense inf_le_right ⟨hxf, hxg⟩] at H
simpa only [fromSpecStalkOfMem, restrict_domain, Opens.fromSpecStalkOfMem, Spec.map_inv,
restrict_hom, Category.assoc, IsIso.eq_inv_comp, IsIso.hom_inv_id_assoc] using H
instance (U : X.Opens) [IsReduced X] : IsReduced U := isReduced_of_isOpenImmersion U.ι
lemma Opens.isDominant_ι {U : X.Opens} (hU : Dense (X := X) U) : IsDominant U.ι :=
⟨by simpa [DenseRange] using hU⟩
lemma Opens.isDominant_homOfLE {U V : X.Opens} (hU : Dense (X := X) U) (hU' : U ≤ V) :
IsDominant (X.homOfLE hU') :=
have : IsDominant (X.homOfLE hU' ≫ Opens.ι _) := by simpa using Opens.isDominant_ι hU
IsDominant.of_comp_of_isOpenImmersion (g := Opens.ι _) _
/-- Two partial maps from reduced schemes to separated schemes are equivalent if and only if
they are equal on **any** open dense subset. -/
lemma equiv_iff_of_isSeparated_of_le [X.Over S] [Y.Over S] [IsReduced X]
[IsSeparated (Y ↘ S)] {f g : X.PartialMap Y} [f.IsOver S] [g.IsOver S]
{W : X.Opens} (hW : Dense (X := X) W) (hWl : W ≤ f.domain) (hWr : W ≤ g.domain) : f.equiv g ↔
(f.restrict W hW hWl).hom = (g.restrict W hW hWr).hom := by
refine ⟨fun ⟨V, hV, hVl, hVr, e⟩ ↦ ?_, fun e ↦ ⟨_, _, _, _, e⟩⟩
have : IsDominant (X.homOfLE (inf_le_left : W ⊓ V ≤ W)) :=
Opens.isDominant_homOfLE (hW.inter_of_isOpen_left hV W.2) _
apply ext_of_isDominant_of_isSeparated' S (X.homOfLE (inf_le_left : W ⊓ V ≤ W))
simpa using congr(X.homOfLE (inf_le_right : W ⊓ V ≤ V) ≫ $e)
/-- Two partial maps from reduced schemes to separated schemes are equivalent if and only if
they are equal on the intersection of the domains. -/
lemma equiv_iff_of_isSeparated [X.Over S] [Y.Over S] [IsReduced X]
[IsSeparated (Y ↘ S)] {f g : X.PartialMap Y}
[f.IsOver S] [g.IsOver S] : f.equiv g ↔
(f.restrict _ (f.2.inter_of_isOpen_left g.2 f.domain.2) inf_le_left).hom =
(g.restrict _ (f.2.inter_of_isOpen_left g.2 f.domain.2) inf_le_right).hom :=
equiv_iff_of_isSeparated_of_le (S := S) _ _ _
/-- Two partial maps from reduced schemes to separated schemes with the same domain are equivalent
if and only if they are equal. -/
lemma equiv_iff_of_domain_eq_of_isSeparated [X.Over S] [Y.Over S] [IsReduced X]
[IsSeparated (Y ↘ S)] {f g : X.PartialMap Y} (hfg : f.domain = g.domain)
[f.IsOver S] [g.IsOver S] : f.equiv g ↔ f = g := by
rw [equiv_iff_of_isSeparated_of_le (S := S) f.dense_domain le_rfl hfg.le]
obtain ⟨Uf, _, f⟩ := f
obtain ⟨Ug, _, g⟩ := g
obtain rfl : Uf = Ug := hfg
simp
/-- A partial map from a reduced scheme to a separated scheme is equivalent to a morphism
if and only if it is equal to the restriction of the morphism. -/
lemma equiv_toPartialMap_iff_of_isSeparated [X.Over S] [Y.Over S] [IsReduced X]
[IsSeparated (Y ↘ S)] {f : X.PartialMap Y} {g : X ⟶ Y}
[f.IsOver S] [g.IsOver S] : f.equiv g.toPartialMap ↔
f.hom = f.domain.ι ≫ g := by
rw [equiv_iff_of_isSeparated (S := S), ← cancel_epi (X.isoOfEq (inf_top_eq f.domain)).hom]
simp
rfl
end PartialMap
/-- A rational map from `X` to `Y` (`X ⤏ Y`) is an equivalence class of partial maps,
where two partial maps are equivalent if they are equal on a dense open subscheme. -/
def RationalMap (X Y : Scheme.{u}) : Type u :=
@Quotient (X.PartialMap Y) inferInstance
/-- The notation for rational maps. -/
scoped[AlgebraicGeometry] infix:10 " ⤏ " => Scheme.RationalMap
/-- A partial map as a rational map. -/
def PartialMap.toRationalMap (f : X.PartialMap Y) : X ⤏ Y := Quotient.mk _ f
/-- A scheme morphism as a rational map. -/
abbrev Hom.toRationalMap (f : X.Hom Y) : X ⤏ Y := f.toPartialMap.toRationalMap
variable (S) in
/-- A rational map is a `S`-map if some partial map in the equivalence class is a `S`-map. -/
class RationalMap.IsOver [X.Over S] [Y.Over S] (f : X ⤏ Y) : Prop where
exists_partialMap_over : ∃ g : X.PartialMap Y, g.IsOver S ∧ g.toRationalMap = f
lemma PartialMap.toRationalMap_surjective : Function.Surjective (@toRationalMap X Y) :=
Quotient.exists_rep
lemma RationalMap.exists_rep (f : X ⤏ Y) : ∃ g : X.PartialMap Y, g.toRationalMap = f :=
Quotient.exists_rep f
lemma PartialMap.toRationalMap_eq_iff {f g : X.PartialMap Y} :
f.toRationalMap = g.toRationalMap ↔ f.equiv g :=
Quotient.eq
@[simp]
lemma PartialMap.restrict_toRationalMap (f : X.PartialMap Y) (U : X.Opens)
(hU : Dense (U : Set X)) (hU' : U ≤ f.domain) :
(f.restrict U hU hU').toRationalMap = f.toRationalMap :=
toRationalMap_eq_iff.mpr (f.restrict_equiv U hU hU')
instance [X.Over S] [Y.Over S] (f : X.PartialMap Y) [f.IsOver S] : f.toRationalMap.IsOver S :=
⟨f, ‹_›, rfl⟩
variable (S) in
lemma RationalMap.exists_partialMap_over [X.Over S] [Y.Over S] (f : X ⤏ Y) [f.IsOver S] :
∃ g : X.PartialMap Y, g.IsOver S ∧ g.toRationalMap = f :=
IsOver.exists_partialMap_over
/-- The composition of a rational map and a morphism on the right. -/
def RationalMap.compHom (f : X ⤏ Y) (g : Y ⟶ Z) : X ⤏ Z := by
refine Quotient.map (PartialMap.compHom · g) ?_ f
intro f₁ f₂ ⟨W, hW, hWl, hWr, e⟩
refine ⟨W, hW, hWl, hWr, ?_⟩
simp only [PartialMap.restrict_domain, PartialMap.restrict_hom, PartialMap.compHom_domain,
PartialMap.compHom_hom] at e ⊢
rw [reassoc_of% e]
@[simp]
lemma RationalMap.compHom_toRationalMap (f : X.PartialMap Y) (g : Y ⟶ Z) :
(f.compHom g).toRationalMap = f.toRationalMap.compHom g := rfl
instance [X.Over S] [Y.Over S] [Z.Over S] (f : X ⤏ Y) (g : Y ⟶ Z)
[f.IsOver S] [g.IsOver S] : (f.compHom g).IsOver S where
exists_partialMap_over := by
obtain ⟨f, hf, rfl⟩ := f.exists_partialMap_over S
exact ⟨f.compHom g, inferInstance, rfl⟩
variable (S) in
lemma PartialMap.exists_restrict_isOver [X.Over S] [Y.Over S] (f : X.PartialMap Y)
[f.toRationalMap.IsOver S] : ∃ U hU hU', (f.restrict U hU hU').IsOver S := by
obtain ⟨f', hf₁, hf₂⟩ := RationalMap.IsOver.exists_partialMap_over (S := S) (f := f.toRationalMap)
obtain ⟨U, hU, hUl, hUr, e⟩ := PartialMap.toRationalMap_eq_iff.mp hf₂
exact ⟨U, hU, hUr, by rw [IsOver, ← e]; infer_instance⟩
lemma RationalMap.isOver_iff [X.Over S] [Y.Over S] {f : X ⤏ Y} :
f.IsOver S ↔ f.compHom (Y ↘ S) = (X ↘ S).toRationalMap := by
constructor
· intro h
obtain ⟨g, hg, e⟩ := f.exists_partialMap_over S
rw [← e, Hom.toRationalMap, ← compHom_toRationalMap, PartialMap.isOver_iff_eq_restrict.mp hg,
PartialMap.restrict_toRationalMap]
· intro e
obtain ⟨f, rfl⟩ := PartialMap.toRationalMap_surjective f
obtain ⟨U, hU, hUl, hUr, e⟩ := PartialMap.toRationalMap_eq_iff.mp e
exact ⟨⟨f.restrict U hU hUl, by simpa using e, by simp⟩⟩
lemma PartialMap.isOver_toRationalMap_iff_of_isSeparated [X.Over S] [Y.Over S] [IsReduced X]
[S.IsSeparated] {f : X.PartialMap Y} :
f.toRationalMap.IsOver S ↔ f.IsOver S := by
refine ⟨fun _ ↦ ?_, fun _ ↦ inferInstance⟩
obtain ⟨U, hU, hU', H⟩ := f.exists_restrict_isOver (S := S)
rw [isOver_iff]
have : IsDominant (X.homOfLE hU') := Opens.isDominant_homOfLE hU _
exact ext_of_isDominant (ι := X.homOfLE hU') (by simpa using H.1)
section functionField
/-- A rational map restricts to a map from `Spec K(X)`. -/
noncomputable
def RationalMap.fromFunctionField [IrreducibleSpace X] (f : X ⤏ Y) :
Spec X.functionField ⟶ Y := by
refine Quotient.lift PartialMap.fromFunctionField ?_ f
intro f g ⟨W, hW, hWl, hWr, e⟩
have : f.restrict W hW hWl = g.restrict W hW hWr := by
ext1
· rfl
rw [e]; simp
rw [← f.fromFunctionField_restrict hW hWl, this, g.fromFunctionField_restrict]
@[simp]
lemma RationalMap.fromFunctionField_toRationalMap [IrreducibleSpace X] (f : X.PartialMap Y) :
f.toRationalMap.fromFunctionField = f.fromFunctionField := rfl
/--
Given `S`-schemes `X` and `Y` such that `Y` is locally of finite type and `X` is integral,
any `S`-morphism `Spec K(X) ⟶ Y` spreads out to a rational map from `X` to `Y`.
-/
noncomputable
def RationalMap.ofFunctionField [IsIntegral X] [LocallyOfFiniteType sY]
(f : Spec X.functionField ⟶ Y) (h : f ≫ sY = X.fromSpecStalk _ ≫ sX) : X ⤏ Y :=
(PartialMap.ofFromSpecStalk sX sY f h).toRationalMap
lemma RationalMap.fromFunctionField_ofFunctionField [IsIntegral X] [LocallyOfFiniteType sY]
(f : Spec X.functionField ⟶ Y) (h : f ≫ sY = X.fromSpecStalk _ ≫ sX) :
(ofFunctionField sX sY f h).fromFunctionField = f :=
PartialMap.fromSpecStalkOfMem_ofFromSpecStalk sX sY _ _
lemma RationalMap.eq_of_fromFunctionField_eq [IsIntegral X] (f g : X.RationalMap Y)
(H : f.fromFunctionField = g.fromFunctionField) : f = g := by
obtain ⟨f, rfl⟩ := f.exists_rep
obtain ⟨g, rfl⟩ := g.exists_rep
refine PartialMap.toRationalMap_eq_iff.mpr ?_
exact PartialMap.equiv_of_fromSpecStalkOfMem_eq _ _ _ _ H
/--
Given `S`-schemes `X` and `Y` such that `Y` is locally of finite type and `X` is integral,
`S`-morphisms `Spec K(X) ⟶ Y` correspond bijectively to `S`-rational maps from `X` to `Y`.
-/
noncomputable
def RationalMap.equivFunctionField [IsIntegral X] [LocallyOfFiniteType sY] :
{ f : Spec X.functionField ⟶ Y // f ≫ sY = X.fromSpecStalk _ ≫ sX } ≃
{ f : X ⤏ Y // f.compHom sY = sX.toRationalMap } where
toFun f := ⟨.ofFunctionField sX sY f f.2, PartialMap.toRationalMap_eq_iff.mpr
⟨_, PartialMap.dense_domain _, le_rfl, le_top, by simp [PartialMap.ofFromSpecStalk_comp]⟩⟩
invFun f := ⟨f.1.fromFunctionField, by
obtain ⟨f, hf⟩ := f
obtain ⟨f, rfl⟩ := f.exists_rep
simpa [fromFunctionField_toRationalMap] using congr(RationalMap.fromFunctionField $hf)⟩
left_inv f := Subtype.ext (RationalMap.fromFunctionField_ofFunctionField _ _ _ _)
right_inv f := Subtype.ext (RationalMap.eq_of_fromFunctionField_eq
(ofFunctionField sX sY f.1.fromFunctionField _) f
(RationalMap.fromFunctionField_ofFunctionField _ _ _ _))
/--
Given `S`-schemes `X` and `Y` such that `Y` is locally of finite type and `X` is integral,
`S`-morphisms `Spec K(X) ⟶ Y` correspond bijectively to `S`-rational maps from `X` to `Y`.
-/
noncomputable
def RationalMap.equivFunctionFieldOver [X.Over S] [Y.Over S] [IsIntegral X]
[LocallyOfFiniteType (Y ↘ S)] :
{ f : Spec X.functionField ⟶ Y // f.IsOver S } ≃ { f : X ⤏ Y // f.IsOver S } :=
((Equiv.subtypeEquivProp (by simp only [Hom.isOver_iff]; rfl)).trans
(RationalMap.equivFunctionField (X ↘ S) (Y ↘ S))).trans
(Equiv.subtypeEquivProp (by ext f; rw [RationalMap.isOver_iff]))
end functionField
section domain
/-- The domain of definition of a rational map. -/
def RationalMap.domain (f : X ⤏ Y) : X.Opens :=
sSup { PartialMap.domain g | (g) (_ : g.toRationalMap = f) }
lemma PartialMap.le_domain_toRationalMap (f : X.PartialMap Y) :
f.domain ≤ f.toRationalMap.domain :=
le_sSup ⟨f, rfl, rfl⟩
lemma RationalMap.mem_domain {f : X ⤏ Y} {x} :
x ∈ f.domain ↔ ∃ g : X.PartialMap Y, x ∈ g.domain ∧ g.toRationalMap = f :=
TopologicalSpace.Opens.mem_sSup.trans (by simp [@and_comm (x ∈ _)])
lemma RationalMap.dense_domain (f : X ⤏ Y) : Dense (X := X) f.domain :=
f.inductionOn (fun g ↦ g.dense_domain.mono g.le_domain_toRationalMap)
/-- The open cover of the domain of `f : X ⤏ Y`,
consisting of all the domains of the partial maps in the equivalence class. -/
noncomputable
def RationalMap.openCoverDomain (f : X ⤏ Y) : f.domain.toScheme.OpenCover where
I₀ := { PartialMap.domain g | (g) (_ : g.toRationalMap = f) }
X U := U.1.toScheme
f U := X.homOfLE (le_sSup U.2)
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ?_, inferInstance⟩
use ⟨_, (TopologicalSpace.Opens.mem_sSup.mp x.2).choose_spec.1⟩
exact ⟨⟨x.1, (TopologicalSpace.Opens.mem_sSup.mp x.2).choose_spec.2⟩, Subtype.ext (by simp)⟩
/-- If `f : X ⤏ Y` is a rational map from a reduced scheme to a separated scheme,
then `f` can be represented as a partial map on its domain of definition. -/
noncomputable
def RationalMap.toPartialMap [IsReduced X] [Y.IsSeparated] (f : X ⤏ Y) : X.PartialMap Y := by
refine ⟨f.domain, f.dense_domain, f.openCoverDomain.glueMorphisms
(fun x ↦ (X.isoOfEq x.2.choose_spec.2).inv ≫ x.2.choose.hom) ?_⟩
intro x y
let g (x : f.openCoverDomain.I₀) := x.2.choose
have hg₁ (x) : (g x).toRationalMap = f := x.2.choose_spec.1
have hg₂ (x) : (g x).domain = x.1 := x.2.choose_spec.2
refine (cancel_epi (isPullback_opens_inf_le (le_sSup x.2) (le_sSup y.2)).isoPullback.hom).mp ?_
simp only [openCoverDomain, IsPullback.isoPullback_hom_fst_assoc,
IsPullback.isoPullback_hom_snd_assoc]
change _ ≫ _ ≫ (g x).hom = _ ≫ _ ≫ (g y).hom
simp_rw [← cancel_epi (X.isoOfEq congr($(hg₂ x) ⊓ $(hg₂ y))).hom, ← Category.assoc]
convert (PartialMap.equiv_iff_of_isSeparated (S := ⊤_ _) (f := g x) (g := g y)).mp ?_ using 1
· dsimp; congr 1; simp [g, ← cancel_mono (Opens.ι _)]
· dsimp; congr 1; simp [g, ← cancel_mono (Opens.ι _)]
· rw [← PartialMap.toRationalMap_eq_iff, hg₁, hg₁]
lemma PartialMap.toPartialMap_toRationalMap_restrict [IsReduced X] [Y.IsSeparated]
(f : X.PartialMap Y) : (f.toRationalMap.toPartialMap.restrict _ f.dense_domain
f.le_domain_toRationalMap).hom = f.hom := by
dsimp [RationalMap.toPartialMap]
refine (f.toRationalMap.openCoverDomain.ι_glueMorphisms _ _ ⟨_, f, rfl, rfl⟩).trans ?_
generalize_proofs _ _ H _
have : H.choose = f := (equiv_iff_of_domain_eq_of_isSeparated (S := ⊤_ _) H.choose_spec.2).mp
(toRationalMap_eq_iff.mp H.choose_spec.1)
exact ((ext_iff _ _).mp this.symm).choose_spec.symm
@[simp]
lemma RationalMap.toRationalMap_toPartialMap [IsReduced X] [Y.IsSeparated]
(f : X ⤏ Y) : f.toPartialMap.toRationalMap = f := by
obtain ⟨f, rfl⟩ := PartialMap.toRationalMap_surjective f
trans (f.toRationalMap.toPartialMap.restrict _
f.dense_domain f.le_domain_toRationalMap).toRationalMap
· simp
· congr 1
exact PartialMap.ext _ f rfl (by simpa using f.toPartialMap_toRationalMap_restrict)
instance [IsReduced X] [Y.IsSeparated] [S.IsSeparated] [X.Over S] [Y.Over S]
(f : X ⤏ Y) [f.IsOver S] : f.toPartialMap.IsOver S := by
rw [← PartialMap.isOver_toRationalMap_iff_of_isSeparated, f.toRationalMap_toPartialMap]
infer_instance
end domain
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/GluingOneHypercover.lean | import Mathlib.AlgebraicGeometry.Gluing
import Mathlib.AlgebraicGeometry.Sites.BigZariski
import Mathlib.CategoryTheory.Limits.Types.Multiequalizer
import Mathlib.CategoryTheory.Sites.Hypercover.One
/-!
# The 1-hypercover of a glue data
In this file, given `D : Scheme.GlueData`, we construct a 1-hypercover
`D.openHypercover` of the scheme `D.glued` in the big Zariski site.
We use this 1-hypercover in order to define a constructor `D.sheafValGluedMk`
for sections over `D.glued` of a sheaf of types over the big Zariski site.
## Notes
This contribution was created as part of the AIM workshop
"Formalizing algebraic geometry" in June 2024.
-/
universe v u
open CategoryTheory Opposite Limits
namespace AlgebraicGeometry.Scheme.GlueData
variable (D : Scheme.GlueData.{u})
/-- The 1-hypercover of `D.glued` in the big Zariski site that is given by the
open cover `D.U` from the glue data `D`.
The "covering of the intersection of two such open subsets" is the trivial
covering given by `D.V`. -/
@[simps]
noncomputable def oneHypercover : Scheme.zariskiTopology.OneHypercover D.glued where
I₀ := D.J
X := D.U
f := D.ι
I₁ _ _ := PUnit
Y i₁ i₂ _ := D.V (i₁, i₂)
p₁ i₁ i₂ _ := D.f i₁ i₂
p₂ i₁ i₂ _ := D.t i₁ i₂ ≫ D.f i₂ i₁
w i₁ i₂ _ := by simp only [Category.assoc, Scheme.GlueData.glue_condition]
mem₀ := by
refine zariskiTopology.superset_covering ?_ D.openCover.mem_grothendieckTopology
rw [Sieve.generate_le_iff]
rintro W _ ⟨i⟩
exact ⟨_, 𝟙 _, _, ⟨i⟩, by simp; rfl⟩
mem₁ i₁ i₂ W p₁ p₂ fac := by
refine zariskiTopology.superset_covering (fun T g _ ↦ ?_) (zariskiTopology.top_mem _)
have ⟨φ, h₁, h₂⟩ := PullbackCone.IsLimit.lift' (D.vPullbackConeIsLimit i₁ i₂)
(g ≫ p₁) (g ≫ p₂) (by simpa using g ≫= fac)
exact ⟨⟨⟩, φ, h₁.symm, h₂.symm⟩
section
variable {F : Sheaf Scheme.zariskiTopology (Type v)}
(s : ∀ (j : D.J), F.val.obj (op (D.U j)))
(h : ∀ (i j : D.J), F.val.map (D.f i j).op (s i) =
F.val.map ((D.f j i).op ≫ (D.t i j).op) (s j))
/-- Constructor for sections over `D.glued` of a sheaf of types on the big Zariski site. -/
noncomputable def sheafValGluedMk : F.val.obj (op D.glued) :=
Multifork.IsLimit.sectionsEquiv (D.oneHypercover.isLimitMultifork F)
{ val := s
property := fun _ ↦ h _ _ }
@[simp]
lemma sheafValGluedMk_val (j : D.J) : F.val.map (D.ι j).op (D.sheafValGluedMk s h) = s j :=
Multifork.IsLimit.sectionsEquiv_apply_val (D.oneHypercover.isLimitMultifork F) _ _
end
end AlgebraicGeometry.Scheme.GlueData |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/FunctionField.lean | import Mathlib.AlgebraicGeometry.Properties
/-!
# Function field of integral schemes
We define the function field of an irreducible scheme as the stalk of the generic point.
This is a field when the scheme is integral.
## Main definition
* `AlgebraicGeometry.Scheme.functionField`: The function field of an integral scheme.
* `AlgebraicGeometry.Scheme.germToFunctionField`: The canonical map from a component into the
function field. This map is injective.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
universe u v
open TopologicalSpace Opposite CategoryTheory CategoryTheory.Limits TopCat
namespace AlgebraicGeometry
variable (X : Scheme)
/-- The function field of an irreducible scheme is the local ring at its generic point.
Despite the name, this is a field only when the scheme is integral. -/
noncomputable abbrev Scheme.functionField [IrreducibleSpace X] : CommRingCat :=
X.presheaf.stalk (genericPoint X)
/-- The restriction map from a component to the function field. -/
noncomputable abbrev Scheme.germToFunctionField [IrreducibleSpace X] (U : X.Opens)
[h : Nonempty U] : Γ(X, U) ⟶ X.functionField :=
X.presheaf.germ U
(genericPoint X)
(((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using h))
noncomputable instance [IrreducibleSpace X] (U : X.Opens) [Nonempty U] :
Algebra Γ(X, U) X.functionField :=
(X.germToFunctionField U).hom.toAlgebra
noncomputable instance [IsIntegral X] : Field X.functionField := by
refine .ofIsUnitOrEqZero fun a ↦ ?_
obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
rw [or_iff_not_imp_right, ← (X.presheaf.germ _ _ m).hom.map_zero]
intro ha
replace ha := ne_of_apply_ne _ ha
have hs : genericPoint X ∈ RingedSpace.basicOpen _ s := by
rw [← SetLike.mem_coe, (genericPoint_spec X).mem_open_set_iff,
Set.univ_inter, Set.nonempty_iff_ne_empty, Ne, ← Opens.coe_bot, ← SetLike.ext'_iff]
· erw [basicOpen_eq_bot_iff]
exact ha
· exact (RingedSpace.basicOpen _ _).isOpen
have := (X.presheaf.germ _ _ hs).hom.isUnit_map (RingedSpace.isUnit_res_basicOpen _ s)
rwa [Presheaf.germ_res_apply] at this
theorem germ_injective_of_isIntegral [IsIntegral X] {U : X.Opens} (x : X) (hx : x ∈ U) :
Function.Injective (X.presheaf.germ U x hx) := by
rw [injective_iff_map_eq_zero]
intro y hy
rw [← (X.presheaf.germ U x hx).hom.map_zero] at hy
obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ hx hx _ _ hy
cases Subsingleton.elim iU iV
haveI : Nonempty W := ⟨⟨_, hW⟩⟩
exact map_injective_of_isIntegral X iU e
theorem Scheme.germToFunctionField_injective [IsIntegral X] (U : X.Opens) [Nonempty U] :
Function.Injective (X.germToFunctionField U) :=
germ_injective_of_isIntegral _ _ _
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f]
[hX : IrreducibleSpace X] [IrreducibleSpace Y] :
f (genericPoint X) = genericPoint Y := by
apply ((genericPoint_spec Y).eq _).symm
convert (genericPoint_spec X).image f.continuous
symm
rw [← Set.univ_subset_iff]
convert subset_closure_inter_of_isPreirreducible_of_isOpen _ f.isOpenEmbedding.isOpen_range _
· rw [Set.univ_inter, Set.image_univ]
· apply PreirreducibleSpace.isPreirreducible_univ (X := Y)
· exact ⟨_, trivial, Set.mem_range_self hX.2.some⟩
noncomputable instance stalkFunctionFieldAlgebra [IrreducibleSpace X] (x : X) :
Algebra (X.presheaf.stalk x) X.functionField := by
-- TODO: can we write this normally after the refactor finishes?
apply RingHom.toAlgebra
exact (X.presheaf.stalkSpecializes ((genericPoint_spec X).specializes trivial)).hom
instance functionField_isScalarTower [IrreducibleSpace X] (U : X.Opens) (x : U)
[Nonempty U] : IsScalarTower Γ(X, U) (X.presheaf.stalk x) X.functionField := by
apply IsScalarTower.of_algebraMap_eq'
simp_rw [RingHom.algebraMap_toAlgebra]
change _ = (X.presheaf.germ U x x.2 ≫ _).hom
rw [X.presheaf.germ_stalkSpecializes]
noncomputable instance (R : CommRingCat.{u}) [IsDomain R] :
Algebra R (Spec R).functionField :=
-- TODO: can we write this normally after the refactor finishes?
RingHom.toAlgebra <| by apply CommRingCat.Hom.hom; apply StructureSheaf.toStalk
@[simp]
theorem genericPoint_eq_bot_of_affine (R : CommRingCat) [IsDomain R] :
genericPoint (Spec R) = (⊥ : PrimeSpectrum R) := by
apply (genericPoint_spec (Spec R)).eq
rw [isGenericPoint_def]
rw [← PrimeSpectrum.zeroLocus_vanishingIdeal_eq_closure, PrimeSpectrum.vanishingIdeal_singleton]
rw [← PrimeSpectrum.zeroLocus_singleton_zero]
rfl
instance functionField_isFractionRing_of_affine (R : CommRingCat.{u}) [IsDomain R] :
IsFractionRing R (Spec R).functionField := by
convert StructureSheaf.IsLocalization.to_stalk R (genericPoint (Spec R))
delta IsFractionRing IsLocalization.AtPrime
-- Porting note: `congr` does not work for `Iff`
apply Eq.to_iff
congr 1
rw [genericPoint_eq_bot_of_affine]
ext
exact mem_nonZeroDivisors_iff_ne_zero
instance {X : Scheme} [IsIntegral X] {U : X.Opens} [Nonempty U] :
IsIntegral U :=
isIntegral_of_isOpenImmersion U.ι
theorem IsAffineOpen.primeIdealOf_genericPoint {X : Scheme} [IsIntegral X] {U : X.Opens}
(hU : IsAffineOpen U) [h : Nonempty U] :
hU.primeIdealOf
⟨genericPoint X,
((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using h)⟩ =
genericPoint (Spec Γ(X, U)) := by
haveI : IsAffine _ := hU
delta IsAffineOpen.primeIdealOf
convert
genericPoint_eq_of_isOpenImmersion
(U.toScheme.isoSpec.hom ≫ Spec.map (X.presheaf.map (eqToHom U.isOpenEmbedding_obj_top).op))
-- Porting note: this was `ext1`
apply Subtype.ext
exact (genericPoint_eq_of_isOpenImmersion U.ι).symm
theorem functionField_isFractionRing_of_isAffineOpen [IsIntegral X] (U : X.Opens)
(hU : IsAffineOpen U) [Nonempty U] :
IsFractionRing Γ(X, U) X.functionField := by
haveI : IsAffine _ := hU
haveI : IsIntegral U :=
@isIntegral_of_isAffine_of_isDomain _ _ _ (by rw [Scheme.Opens.toScheme_presheaf_obj,
U.ι.image_top_eq_opensRange, U.opensRange_ι]; infer_instance)
delta IsFractionRing Scheme.functionField
convert hU.isLocalization_stalk ⟨genericPoint X,
(((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using ‹Nonempty U›))⟩ using 1
rw [hU.primeIdealOf_genericPoint, genericPoint_eq_bot_of_affine]
ext; exact mem_nonZeroDivisors_iff_ne_zero
instance (x : X) : IsAffine (X.affineCover.X x) :=
AlgebraicGeometry.isAffine_Spec _
instance [IsIntegral X] (x : X) :
IsFractionRing (X.presheaf.stalk x) X.functionField :=
let U : X.Opens := (X.affineCover.f ((X.affineCover.idx x))).opensRange
have hU : IsAffineOpen U := isAffineOpen_opensRange (X.affineCover.f _)
let x : U := ⟨x, X.affineCover.covers x⟩
have : Nonempty U := ⟨x⟩
let M := (hU.primeIdealOf x).asIdeal.primeCompl
have := hU.isLocalization_stalk x
have := functionField_isFractionRing_of_isAffineOpen X U hU
-- Porting note: the following two lines were not needed.
let _hA := Presheaf.algebra_section_stalk X.presheaf x
have := functionField_isScalarTower X U x
.isFractionRing_of_isDomain_of_isLocalization M ↑(Presheaf.stalk X.presheaf x)
(Scheme.functionField X)
instance [IsIntegral X] {x : X} : IsDomain (X.presheaf.stalk x) :=
Function.Injective.isDomain _ (IsFractionRing.injective (X.presheaf.stalk x) (X.functionField))
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ResidueField.lean | import Mathlib.AlgebraicGeometry.Stalk
import Mathlib.Geometry.RingedSpace.LocallyRingedSpace.ResidueField
/-!
# Residue fields of points
## Main definitions
The following are in the `AlgebraicGeometry.Scheme` namespace:
- `AlgebraicGeometry.Scheme.residueField`: The residue field of the stalk at `x`.
- `AlgebraicGeometry.Scheme.evaluation`: For open subsets `U` of `X` containing `x`,
the evaluation map from sections over `U` to the residue field at `x`.
- `AlgebraicGeometry.Scheme.Hom.residueFieldMap`: A morphism of schemes induce a homomorphism of
residue fields.
- `AlgebraicGeometry.Scheme.fromSpecResidueField`: The canonical map `Spec κ(x) ⟶ X`.
- `AlgebraicGeometry.Scheme.SpecToEquivOfField`: morphisms `Spec K ⟶ X` for a field `K` correspond
to pairs of `x : X` with embedding `κ(x) ⟶ K`.
-/
universe u
open CategoryTheory TopologicalSpace Opposite IsLocalRing
noncomputable section
namespace AlgebraicGeometry.Scheme
variable (X : Scheme.{u}) {U : X.Opens}
/-- The residue field of `X` at a point `x` is the residue field of the stalk of `X`
at `x`. -/
def residueField (x : X) : CommRingCat :=
CommRingCat.of <| IsLocalRing.ResidueField (X.presheaf.stalk x)
instance (x : X) : Field (X.residueField x) :=
inferInstanceAs <| Field (IsLocalRing.ResidueField (X.presheaf.stalk x))
instance (x : X) : Unique (Spec (X.residueField x)) := inferInstanceAs (Unique (Spec <| .of _))
/-- The residue map from the stalk to the residue field. -/
def residue (X : Scheme.{u}) (x) : X.presheaf.stalk x ⟶ X.residueField x :=
CommRingCat.ofHom (IsLocalRing.residue (X.presheaf.stalk x))
/-- See `AlgebraicGeometry.IsClosedImmersion.SpecMap_residue` for the stronger result that
`Spec.map (X.residue x)` is a closed immersion. -/
instance {X : Scheme.{u}} (x) : IsPreimmersion (Spec.map (X.residue x)) :=
IsPreimmersion.mk_SpecMap
(PrimeSpectrum.isClosedEmbedding_comap_of_surjective _ _
Ideal.Quotient.mk_surjective).isEmbedding
(RingHom.surjectiveOnStalks_of_surjective (Ideal.Quotient.mk_surjective))
@[simp]
lemma SpecMap_residue_apply {X : Scheme.{u}} (x : X) (s : Spec (X.residueField x)) :
Spec.map (X.residue x) s = closedPoint (X.presheaf.stalk x) :=
IsLocalRing.PrimeSpectrum.comap_residue _ s
@[deprecated (since := "2025-10-07")] alias Spec_map_residue_apply := SpecMap_residue_apply
lemma residue_surjective (X : Scheme.{u}) (x) : Function.Surjective (X.residue x) :=
Ideal.Quotient.mk_surjective
instance (X : Scheme.{u}) (x) : Epi (X.residue x) :=
ConcreteCategory.epi_of_surjective _ (X.residue_surjective x)
/-- If `K` is a field and `f : 𝒪_{X, x} ⟶ K` is a ring map, then this is the induced
map `κ(x) ⟶ K`. -/
def descResidueField {K : Type u} [Field K] {X : Scheme.{u}} {x : X}
(f : X.presheaf.stalk x ⟶ .of K) [IsLocalHom f.hom] :
X.residueField x ⟶ .of K :=
CommRingCat.ofHom (IsLocalRing.ResidueField.lift (S := K) f.hom)
@[reassoc (attr := simp)]
lemma residue_descResidueField {K : Type u} [Field K] {X : Scheme.{u}} {x}
(f : X.presheaf.stalk x ⟶ .of K) [IsLocalHom f.hom] :
X.residue x ≫ X.descResidueField f = f :=
CommRingCat.hom_ext <| RingHom.ext fun _ ↦ rfl
/--
If `U` is an open of `X` containing `x`, we have a canonical ring map from the sections
over `U` to the residue field of `x`.
If we interpret sections over `U` as functions of `X` defined on `U`, then this ring map
corresponds to evaluation at `x`.
-/
def evaluation (U : X.Opens) (x : X) (hx : x ∈ U) : Γ(X, U) ⟶ X.residueField x :=
X.presheaf.germ U x hx ≫ X.residue _
@[reassoc]
lemma germ_residue (x hx) : X.presheaf.germ U x hx ≫ X.residue x = X.evaluation U x hx := rfl
/-- The global evaluation map from `Γ(X, ⊤)` to the residue field at `x`. -/
abbrev Γevaluation (x : X) : Γ(X, ⊤) ⟶ X.residueField x :=
X.evaluation ⊤ x trivial
@[simp]
lemma evaluation_eq_zero_iff_notMem_basicOpen (x : X) (hx : x ∈ U) (f : Γ(X, U)) :
X.evaluation U x hx f = 0 ↔ x ∉ X.basicOpen f :=
X.toLocallyRingedSpace.evaluation_eq_zero_iff_notMem_basicOpen ⟨x, hx⟩ f
@[deprecated (since := "2025-05-23")]
alias evaluation_eq_zero_iff_not_mem_basicOpen := evaluation_eq_zero_iff_notMem_basicOpen
lemma evaluation_ne_zero_iff_mem_basicOpen (x : X) (hx : x ∈ U) (f : Γ(X, U)) :
X.evaluation U x hx f ≠ 0 ↔ x ∈ X.basicOpen f := by
simp
lemma basicOpen_eq_bot_iff_forall_evaluation_eq_zero (f : X.presheaf.obj (op U)) :
X.basicOpen f = ⊥ ↔ ∀ (x : U), X.evaluation U x x.property f = 0 :=
X.toLocallyRingedSpace.basicOpen_eq_bot_iff_forall_evaluation_eq_zero f
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- If `X ⟶ Y` is a morphism of locally ringed spaces and `x` a point of `X`, we obtain
a morphism of residue fields in the other direction. -/
def Hom.residueFieldMap (f : X ⟶ Y) (x : X) :
Y.residueField (f x) ⟶ X.residueField x :=
CommRingCat.ofHom <| IsLocalRing.ResidueField.map (f.stalkMap x).hom
@[reassoc]
lemma residue_residueFieldMap (x : X) :
Y.residue (f x) ≫ f.residueFieldMap x = f.stalkMap x ≫ X.residue x := by
simp [Hom.residueFieldMap]
rfl
@[simp]
lemma residueFieldMap_id (x : X) :
Hom.residueFieldMap (𝟙 X) x = 𝟙 (X.residueField x) :=
LocallyRingedSpace.residueFieldMap_id _
@[simp]
lemma residueFieldMap_comp {Z : Scheme.{u}} (g : Y ⟶ Z) (x : X) :
(f ≫ g).residueFieldMap x = g.residueFieldMap (f x) ≫ f.residueFieldMap x :=
LocallyRingedSpace.residueFieldMap_comp _ _ _
@[reassoc]
lemma evaluation_naturality {V : Opens Y} (x : X) (hx : f x ∈ V) :
Y.evaluation V (f x) hx ≫ f.residueFieldMap x =
f.app V ≫ X.evaluation (f ⁻¹ᵁ V) x hx :=
LocallyRingedSpace.evaluation_naturality f.1 ⟨x, hx⟩
lemma evaluation_naturality_apply {V : Opens Y} (x : X) (hx : f x ∈ V) (s) :
f.residueFieldMap x (Y.evaluation V (f x) hx s) =
X.evaluation (f ⁻¹ᵁ V) x hx (f.app V s) :=
LocallyRingedSpace.evaluation_naturality_apply f.1 ⟨x, hx⟩ s
@[reassoc]
lemma Γevaluation_naturality (x : X) :
Y.Γevaluation (f x) ≫ f.residueFieldMap x = f.appTop ≫ X.Γevaluation x :=
LocallyRingedSpace.Γevaluation_naturality f.toLRSHom x
lemma Γevaluation_naturality_apply (x : X) (a : Y.presheaf.obj (op ⊤)) :
f.residueFieldMap x (Y.Γevaluation (f x) a) = X.Γevaluation x (f.appTop a) :=
LocallyRingedSpace.Γevaluation_naturality_apply f.toLRSHom x a
instance [IsOpenImmersion f] (x) : IsIso (f.residueFieldMap x) :=
(IsLocalRing.ResidueField.mapEquiv
(asIso (f.stalkMap x)).commRingCatIsoToRingEquiv).toCommRingCatIso.isIso_hom
section congr
-- replace this def if hard to work with
/-- The isomorphism between residue fields of equal points. -/
def residueFieldCongr {x y : X} (h : x = y) :
X.residueField x ≅ X.residueField y :=
eqToIso (by subst h; rfl)
@[simp]
lemma residueFieldCongr_refl {x : X} :
X.residueFieldCongr (refl x) = Iso.refl _ := rfl
@[simp]
lemma residueFieldCongr_symm {x y : X} (e : x = y) :
(X.residueFieldCongr e).symm = X.residueFieldCongr e.symm := rfl
@[simp]
lemma residueFieldCongr_inv {x y : X} (e : x = y) :
(X.residueFieldCongr e).inv = (X.residueFieldCongr e.symm).hom := rfl
@[simp]
lemma residueFieldCongr_trans {x y z : X} (e : x = y) (e' : y = z) :
X.residueFieldCongr e ≪≫ X.residueFieldCongr e' = X.residueFieldCongr (e.trans e') := by
subst e e'
rfl
@[reassoc (attr := simp)]
lemma residueFieldCongr_trans_hom (X : Scheme) {x y z : X} (e : x = y) (e' : y = z) :
(X.residueFieldCongr e).hom ≫ (X.residueFieldCongr e').hom =
(X.residueFieldCongr (e.trans e')).hom := by
subst e e'
rfl
@[reassoc]
lemma residue_residueFieldCongr (X : Scheme) {x y : X} (h : x = y) :
X.residue x ≫ (X.residueFieldCongr h).hom =
(X.presheaf.stalkCongr (.of_eq h)).hom ≫ X.residue y := by
subst h
simp
lemma Hom.residueFieldMap_congr {f g : X ⟶ Y} (e : f = g) (x : X) :
f.residueFieldMap x = (Y.residueFieldCongr (by subst e; rfl)).hom ≫ g.residueFieldMap x := by
subst e; simp
end congr
section fromResidueField
/-- The canonical map `Spec κ(x) ⟶ X`. -/
def fromSpecResidueField (X : Scheme) (x : X) :
Spec (X.residueField x) ⟶ X :=
Spec.map (X.residue x) ≫ X.fromSpecStalk x
instance {X : Scheme.{u}} (x : X) : IsPreimmersion (X.fromSpecResidueField x) := by
dsimp only [Scheme.fromSpecResidueField]
rw [IsPreimmersion.comp_iff]
infer_instance
@[simps] noncomputable
instance (x : X) : (Spec (X.residueField x)).Over X := ⟨X.fromSpecResidueField x⟩
noncomputable
instance (x : X) : (Spec (X.residueField x)).CanonicallyOver X where
@[reassoc (attr := simp)]
lemma residueFieldCongr_fromSpecResidueField {x y : X} (h : x = y) :
Spec.map (X.residueFieldCongr h).hom ≫ X.fromSpecResidueField _ =
X.fromSpecResidueField _ := by
subst h; simp
instance {x y : X} (h : x = y) : (Spec.map (X.residueFieldCongr h).hom).IsOver X where
@[reassoc (attr := simp)]
lemma Hom.SpecMap_residueFieldMap_fromSpecResidueField (x : X) :
Spec.map (f.residueFieldMap x) ≫ Y.fromSpecResidueField _ =
X.fromSpecResidueField x ≫ f := by
dsimp only [fromSpecResidueField]
rw [Category.assoc, ← SpecMap_stalkMap_fromSpecStalk, ← Spec.map_comp_assoc,
← Spec.map_comp_assoc]
rfl
@[deprecated (since := "2025-10-07")]
alias Hom.Spec_map_residueFieldMap_fromSpecResidueField :=
Hom.SpecMap_residueFieldMap_fromSpecResidueField
@[deprecated (since := "2025-10-07")]
alias Hom.Spec_map_residueFieldMap_fromSpecResidueField_assoc :=
Hom.SpecMap_residueFieldMap_fromSpecResidueField_assoc
instance [X.Over Y] (x : X) : Spec.map ((X ↘ Y).residueFieldMap x) |>.IsOver Y where
@[simp]
lemma fromSpecResidueField_apply (x : X.carrier) (s : Spec (X.residueField x)) :
X.fromSpecResidueField x s = x := by
simp [fromSpecResidueField]
lemma range_fromSpecResidueField (x : X.carrier) :
Set.range (X.fromSpecResidueField x) = {x} := by
simp
lemma descResidueField_fromSpecResidueField {K : Type*} [Field K] (X : Scheme) {x}
(f : X.presheaf.stalk x ⟶ .of K) [IsLocalHom f.hom] :
Spec.map (X.descResidueField f) ≫
X.fromSpecResidueField x = Spec.map f ≫ X.fromSpecStalk x := by
simp [fromSpecResidueField, ← Spec.map_comp_assoc]
lemma descResidueField_stalkClosedPointTo_fromSpecResidueField
(K : Type u) [Field K] (X : Scheme.{u}) (f : Spec (.of K) ⟶ X) :
Spec.map (descResidueField (Scheme.stalkClosedPointTo f)) ≫
X.fromSpecResidueField (f (closedPoint K)) = f := by
rw [X.descResidueField_fromSpecResidueField, Scheme.Spec_stalkClosedPointTo_fromSpecStalk]
end fromResidueField
/-- A helper lemma to work with `AlgebraicGeometry.Scheme.SpecToEquivOfField`. -/
lemma SpecToEquivOfField_eq_iff {K : Type*} [Field K] {X : Scheme}
{f₁ f₂ : Σ x : X.carrier, X.residueField x ⟶ .of K} :
f₁ = f₂ ↔ ∃ e : f₁.1 = f₂.1, f₁.2 = (X.residueFieldCongr e).hom ≫ f₂.2 := by
constructor
· rintro rfl
simp
· obtain ⟨f, _⟩ := f₁
obtain ⟨g, _⟩ := f₂
rintro ⟨(rfl : f = g), h⟩
simpa
/-- For a field `K` and a scheme `X`, the morphisms `Spec K ⟶ X` bijectively correspond
to pairs of points `x` of `X` and embeddings `κ(x) ⟶ K`. -/
def SpecToEquivOfField (K : Type u) [Field K] (X : Scheme.{u}) :
(Spec (.of K) ⟶ X) ≃ Σ x, X.residueField x ⟶ .of K where
toFun f :=
⟨_, X.descResidueField (Scheme.stalkClosedPointTo f)⟩
invFun xf := Spec.map xf.2 ≫ X.fromSpecResidueField xf.1
left_inv := Scheme.descResidueField_stalkClosedPointTo_fromSpecResidueField K X
right_inv f := by
rw [SpecToEquivOfField_eq_iff]
simp only [CommRingCat.coe_of, Scheme.Hom.comp_base, TopCat.coe_comp, Function.comp_apply,
Scheme.fromSpecResidueField_apply, exists_true_left]
rw [← Spec.map_inj, Spec.map_comp, ← cancel_mono (X.fromSpecResidueField _)]
grind [Scheme.descResidueField_stalkClosedPointTo_fromSpecResidueField,
Scheme.fromSpecResidueField_apply,
Scheme.residueFieldCongr_fromSpecResidueField]
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Limits.lean | import Mathlib.CategoryTheory.Limits.Shapes.Opposites.Products
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.AlgebraicGeometry.AffineScheme
/-!
# (Co)Limits of Schemes
We construct various limits and colimits in the category of schemes.
* The existence of fibred products was shown in `Mathlib/AlgebraicGeometry/Pullbacks.lean`.
* `Spec ℤ` is the terminal object.
* The preceding two results imply that `Scheme` has all finite limits.
* The empty scheme is the (strict) initial object.
* The disjoint union is the coproduct of a family of schemes, and the forgetful functor to
`LocallyRingedSpace` and `TopCat` preserves them.
## TODO
* Spec preserves finite coproducts.
-/
suppress_compilation
universe u v
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
attribute [local instance] Opposite.small
namespace AlgebraicGeometry
/-- `Spec ℤ` is the terminal object in the category of schemes. -/
noncomputable def specZIsTerminal : IsTerminal (Spec <| .of ℤ) :=
@IsTerminal.isTerminalObj _ _ _ _ Scheme.Spec _ inferInstance
(terminalOpOfInitial CommRingCat.zIsInitial)
/-- `Spec ℤ` is the terminal object in the category of schemes. -/
noncomputable def specULiftZIsTerminal : IsTerminal (Spec <| .of <| ULift.{u} ℤ) :=
@IsTerminal.isTerminalObj _ _ _ _ Scheme.Spec _ inferInstance
(terminalOpOfInitial CommRingCat.isInitial)
instance : HasTerminal Scheme :=
hasTerminal_of_hasTerminal_of_preservesLimit Scheme.Spec
instance : IsAffine (⊤_ Scheme.{u}) :=
.of_isIso (PreservesTerminal.iso Scheme.Spec).inv
instance : HasFiniteLimits Scheme :=
hasFiniteLimits_of_hasTerminal_and_pullbacks
instance (X : Scheme.{u}) : X.Over (⊤_ _) := ⟨terminal.from _⟩
instance {X Y : Scheme.{u}} [X.Over (⊤_ Scheme)] [Y.Over (⊤_ Scheme)] (f : X ⟶ Y) :
@Scheme.Hom.IsOver _ _ f (⊤_ Scheme) ‹_› ‹_› := ⟨Subsingleton.elim _ _⟩
instance {X : Scheme} : Subsingleton (X.Over (⊤_ Scheme)) :=
⟨fun ⟨a⟩ ⟨b⟩ ↦ by simp [Subsingleton.elim a b]⟩
section Initial
/-- The map from the empty scheme. -/
@[simps]
def Scheme.emptyTo (X : Scheme.{u}) : ∅ ⟶ X :=
⟨{ base := TopCat.ofHom ⟨fun x => PEmpty.elim x, by fun_prop⟩
c := { app := fun _ => CommRingCat.punitIsTerminal.from _ } }, fun x => PEmpty.elim x⟩
@[ext]
theorem Scheme.empty_ext {X : Scheme.{u}} (f g : ∅ ⟶ X) : f = g :=
Scheme.Hom.ext' (Subsingleton.elim (α := ∅ ⟶ _) _ _)
theorem Scheme.eq_emptyTo {X : Scheme.{u}} (f : ∅ ⟶ X) : f = Scheme.emptyTo X :=
Scheme.empty_ext f (Scheme.emptyTo X)
instance Scheme.hom_unique_of_empty_source (X : Scheme.{u}) : Unique (∅ ⟶ X) :=
⟨⟨Scheme.emptyTo _⟩, fun _ => Scheme.empty_ext _ _⟩
/-- The empty scheme is the initial object in the category of schemes. -/
def emptyIsInitial : IsInitial (∅ : Scheme.{u}) :=
IsInitial.ofUnique _
@[simp]
theorem emptyIsInitial_to : emptyIsInitial.to = Scheme.emptyTo :=
rfl
instance : IsEmpty (∅ : Scheme.{u}) :=
show IsEmpty PEmpty by infer_instance
instance spec_punit_isEmpty : IsEmpty (Spec <| .of PUnit.{u+1}) :=
inferInstanceAs <| IsEmpty (PrimeSpectrum PUnit)
instance (priority := 100) isOpenImmersion_of_isEmpty {X Y : Scheme} (f : X ⟶ Y)
[IsEmpty X] : IsOpenImmersion f := by
apply (config := { allowSynthFailures := true }) IsOpenImmersion.of_isIso_stalkMap
· exact .of_isEmpty (X := X) _
· intro (i : X); exact isEmptyElim i
instance (priority := 100) isIso_of_isEmpty {X Y : Scheme} (f : X ⟶ Y) [IsEmpty Y] :
IsIso f := by
haveI : IsEmpty X := f.base.hom.1.isEmpty
have : Epi f.base := by
rw [TopCat.epi_iff_surjective]; rintro (x : Y)
exact isEmptyElim x
apply IsOpenImmersion.isIso
/-- A scheme is initial if its underlying space is empty . -/
noncomputable def isInitialOfIsEmpty {X : Scheme} [IsEmpty X] : IsInitial X :=
emptyIsInitial.ofIso (asIso <| emptyIsInitial.to _)
/-- `Spec 0` is the initial object in the category of schemes. -/
noncomputable def specPunitIsInitial : IsInitial (Spec <| .of PUnit.{u+1}) :=
emptyIsInitial.ofIso (asIso <| emptyIsInitial.to _)
instance (priority := 100) isAffine_of_isEmpty {X : Scheme} [IsEmpty X] : IsAffine X :=
.of_isIso (inv (emptyIsInitial.to X) ≫ emptyIsInitial.to (Spec <| .of PUnit))
instance : HasInitial Scheme.{u} :=
hasInitial_of_unique ∅
instance initial_isEmpty : IsEmpty (⊥_ Scheme) :=
⟨fun x => ((initial.to Scheme.empty :) x).elim⟩
theorem isAffineOpen_bot (X : Scheme) : IsAffineOpen (⊥ : X.Opens) :=
@isAffine_of_isEmpty _ (inferInstanceAs (IsEmpty (∅ : Set X)))
instance : HasStrictInitialObjects Scheme :=
hasStrictInitialObjects_of_initial_is_strict fun A f => by infer_instance
instance {X : Scheme} [IsEmpty X] (U : X.Opens) : Subsingleton Γ(X, U) := by
obtain rfl : U = ⊥ := Subsingleton.elim _ _; infer_instance
-- This is also true for schemes with two points.
-- But there are non-affine schemes with three points.
instance (priority := low) {X : Scheme.{u}} [Subsingleton X] : IsAffine X := by
cases isEmpty_or_nonempty X with
| inl h => infer_instance
| inr h =>
obtain ⟨x⟩ := h
obtain ⟨_, ⟨U, hU : IsAffine _, rfl⟩, hxU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (a := x) (by trivial) isOpen_univ
obtain rfl : U = ⊤ := by ext y; simpa [Subsingleton.elim y x]
exact .of_isIso (Scheme.topIso X).inv
end Initial
section Coproduct
variable {ι : Type u} (f : ι → Scheme.{u})
variable {σ : Type v} (g : σ → Scheme.{u})
noncomputable
instance [Small.{u} σ] :
CreatesColimitsOfShape (Discrete σ) Scheme.forgetToLocallyRingedSpace.{u} where
instance [Small.{u} σ] : PreservesColimitsOfShape (Discrete σ) Scheme.forgetToTop.{u} :=
inferInstanceAs (PreservesColimitsOfShape (Discrete σ) (Scheme.forgetToLocallyRingedSpace ⋙
LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat))
instance [Small.{u} σ] : HasColimitsOfShape (Discrete σ) Scheme.{u} :=
⟨fun _ ↦ hasColimit_of_created _ Scheme.forgetToLocallyRingedSpace⟩
lemma sigmaι_eq_iff (i j : ι) (x y) :
Sigma.ι f i x = Sigma.ι f j y ↔ (Sigma.mk i x : Σ i, f i) = Sigma.mk j y := by
refine (Scheme.IsLocallyDirected.ι_eq_ι_iff _).trans ⟨?_, ?_⟩
· rintro ⟨k, ⟨⟨⟨⟩⟩⟩, ⟨⟨⟨⟩⟩⟩, x, rfl, rfl⟩; simp
· simp only [Discrete.functor_obj_eq_as, Sigma.mk.injEq]
rintro ⟨rfl, e⟩
obtain rfl := (heq_eq_eq x y).mp e
exact ⟨⟨i⟩, 𝟙 _, 𝟙 _, x, by simp⟩
/-- The images of each component in the coproduct is disjoint. -/
lemma disjoint_opensRange_sigmaι (i j : ι) (h : i ≠ j) :
Disjoint (Sigma.ι f i).opensRange (Sigma.ι f j).opensRange := by
intro U hU hU' x hx
obtain ⟨x, rfl⟩ := hU hx
obtain ⟨y, hy⟩ := hU' hx
obtain ⟨rfl⟩ := (sigmaι_eq_iff _ _ _ _ _).mp hy
cases h rfl
/-- The cover of `∐ X` by the `Xᵢ`. -/
@[simps!]
noncomputable def sigmaOpenCover [Small.{u} σ] : (∐ g).OpenCover :=
(Scheme.IsLocallyDirected.openCover (Discrete.functor g)).copy σ g (Sigma.ι _)
(discreteEquiv.symm) (fun _ ↦ Iso.refl _) (fun _ ↦ rfl)
/-- The underlying topological space of the coproduct is homeomorphic to the disjoint union. -/
noncomputable
def sigmaMk : (Σ i, f i) ≃ₜ (∐ f :) :=
TopCat.homeoOfIso ((colimit.isoColimitCocone ⟨_, TopCat.sigmaCofanIsColimit _⟩).symm ≪≫
(PreservesCoproduct.iso Scheme.forgetToTop f).symm)
@[simp]
lemma sigmaMk_mk (i) (x : f i) :
sigmaMk f (.mk i x) = Sigma.ι f i x := by
change ((TopCat.sigmaCofan (fun x ↦ (f x).toTopCat)).inj i ≫
(colimit.isoColimitCocone ⟨_, TopCat.sigmaCofanIsColimit _⟩).inv ≫ _) x =
Scheme.forgetToTop.map (Sigma.ι f i) x
congr 2
refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.sigmaCofanIsColimit _⟩ _ _).trans ?_
exact ι_comp_sigmaComparison Scheme.forgetToTop _ _
open scoped Function in
private lemma isOpenImmersion_sigmaDesc_aux
{X : Scheme.{u}} (α : ∀ i, f i ⟶ X) [∀ i, IsOpenImmersion (α i)]
(hα : Pairwise (Disjoint on (Set.range <| α ·))) :
IsOpenImmersion (Sigma.desc α) := by
rw [IsOpenImmersion.iff_isIso_stalkMap]
constructor
· suffices Topology.IsOpenEmbedding (Sigma.desc α ∘ sigmaMk f) by
convert this.comp (sigmaMk f).symm.isOpenEmbedding; ext; simp
refine .of_continuous_injective_isOpenMap ?_ ?_ ?_
· fun_prop
· rintro ⟨ix, x⟩ ⟨iy, y⟩ e
have : α ix x = α iy y := by
simpa [← Scheme.Hom.comp_apply] using e
obtain rfl : ix = iy := by
by_contra h
exact Set.disjoint_iff_forall_ne.mp (hα h) ⟨x, rfl⟩ ⟨y, this.symm⟩ rfl
rw [(α ix).isOpenEmbedding.injective this]
· rw [isOpenMap_sigma]
intro i
simpa [← Scheme.Hom.comp_apply] using (α i).isOpenEmbedding.isOpenMap
· intro x
have ⟨y, hy⟩ := (Scheme.IsLocallyDirected.openCover (Discrete.functor f)).covers x
rw [← hy]
refine IsIso.of_isIso_fac_right
(g := ((Scheme.IsLocallyDirected.openCover (Discrete.functor f)).f _).stalkMap y)
(h := (X.presheaf.stalkCongr (.of_eq ?_)).hom ≫ (α _).stalkMap _) ?_
· simp [← Scheme.Hom.comp_apply]
· simp [← Scheme.Hom.stalkMap_comp, Scheme.Hom.stalkMap_congr_hom _ _ (colimit.ι_desc _ _)]
open scoped Function in
lemma isOpenImmersion_sigmaDesc [Small.{u} σ]
{X : Scheme.{u}} (α : ∀ i, g i ⟶ X) [∀ i, IsOpenImmersion (α i)]
(hα : Pairwise (Disjoint on (Set.range <| α ·))) :
IsOpenImmersion (Sigma.desc α) := by
obtain ⟨ι, ⟨e⟩⟩ := Small.equiv_small (α := σ)
convert IsOpenImmersion.comp ((Sigma.reindex e.symm g).inv) (Sigma.desc fun i ↦ α _)
· refine Sigma.hom_ext _ _ fun i ↦ ?_
obtain ⟨i, rfl⟩ := e.symm.surjective i
simp
· apply isOpenImmersion_sigmaDesc_aux
intro i j hij
exact hα (fun h ↦ hij (e.symm.injective h))
open scoped Function in
/-- `S` is the disjoint union of `Xᵢ` if the `Xᵢ` are covering, pairwise disjoint open subschemes
of `S`. -/
lemma nonempty_isColimit_cofanMk_of [Small.{u} σ]
{X : σ → Scheme.{u}} {S : Scheme.{u}} (f : ∀ i, X i ⟶ S) [∀ i, IsOpenImmersion (f i)]
(hcov : ⨆ i, (f i).opensRange = ⊤) (hdisj : Pairwise (Disjoint on (f · |>.opensRange))) :
Nonempty (IsColimit <| Cofan.mk S f) := by
have : IsOpenImmersion (Sigma.desc f) := by
refine isOpenImmersion_sigmaDesc _ _ (fun i j hij ↦ ?_)
simpa [Function.onFun_apply, disjoint_iff, Opens.ext_iff] using hdisj hij
simp only [← Cofan.isColimit_iff_isIso_sigmaDesc (Cofan.mk S f), cofan_mk_inj, Cofan.mk_pt]
apply isIso_of_isOpenImmersion_of_opensRange_eq_top
rw [eq_top_iff]
intro x hx
have : x ∈ ⨆ i, (f i).opensRange := by rwa [hcov]
obtain ⟨i, y, rfl⟩ := by simpa only [Opens.iSup_mk, Opens.mem_mk, Set.mem_iUnion] using this
use Sigma.ι X i y
simp [← Scheme.Hom.comp_apply]
variable (X Y : Scheme.{u})
/-- (Implementation Detail)
The coproduct of the two schemes is given by indexed coproducts over `WalkingPair`. -/
noncomputable
def coprodIsoSigma : X ⨿ Y ≅ ∐ fun i : ULift.{u} WalkingPair ↦ i.1.casesOn X Y :=
Sigma.whiskerEquiv Equiv.ulift.symm (fun _ ↦ by exact Iso.refl _)
lemma ι_left_coprodIsoSigma_inv : Sigma.ι _ ⟨.left⟩ ≫ (coprodIsoSigma X Y).inv = coprod.inl :=
Sigma.ι_comp_map' _ _ _
lemma ι_right_coprodIsoSigma_inv : Sigma.ι _ ⟨.right⟩ ≫ (coprodIsoSigma X Y).inv = coprod.inr :=
Sigma.ι_comp_map' _ _ _
instance : IsOpenImmersion (coprod.inl : X ⟶ X ⨿ Y) := by
rw [← ι_left_coprodIsoSigma_inv]; infer_instance
instance : IsOpenImmersion (coprod.inr : Y ⟶ X ⨿ Y) := by
rw [← ι_right_coprodIsoSigma_inv]; infer_instance
lemma isCompl_range_inl_inr :
IsCompl (Set.range (coprod.inl : X ⟶ X ⨿ Y)) (Set.range (coprod.inr : Y ⟶ X ⨿ Y)) :=
((TopCat.binaryCofan_isColimit_iff _).mp
⟨mapIsColimitOfPreservesOfIsColimit Scheme.forgetToTop.{u} _ _ (coprodIsCoprod X Y)⟩).2.2
lemma isCompl_opensRange_inl_inr :
IsCompl (coprod.inl : X ⟶ X ⨿ Y).opensRange (coprod.inr : Y ⟶ X ⨿ Y).opensRange := by
convert isCompl_range_inl_inr X Y
simp only [isCompl_iff, disjoint_iff, codisjoint_iff, ← TopologicalSpace.Opens.coe_inj]
rfl
/-- The underlying topological space of the coproduct is homeomorphic to the disjoint union -/
noncomputable
def coprodMk : X ⊕ Y ≃ₜ (X ⨿ Y : Scheme.{u}) :=
TopCat.homeoOfIso ((colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).symm ≪≫
PreservesColimitPair.iso Scheme.forgetToTop X Y)
@[simp]
lemma coprodMk_inl (x : X) :
coprodMk X Y (.inl x) = (coprod.inl : X ⟶ X ⨿ Y) x := by
change ((TopCat.binaryCofan X Y).inl ≫
(colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).inv ≫ _) x =
Scheme.forgetToTop.map coprod.inl x
congr 2
refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.binaryCofanIsColimit _ _⟩ _ _).trans ?_
exact coprodComparison_inl Scheme.forgetToTop
@[simp]
lemma coprodMk_inr (x : Y) :
coprodMk X Y (.inr x) = (coprod.inr : Y ⟶ X ⨿ Y) x := by
change ((TopCat.binaryCofan X Y).inr ≫
(colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).inv ≫ _) x =
Scheme.forgetToTop.map coprod.inr x
congr 2
refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.binaryCofanIsColimit _ _⟩ _ _).trans ?_
exact coprodComparison_inr Scheme.forgetToTop
/-- The open cover of the coproduct of two schemes. -/
noncomputable
def coprodOpenCover.{w} : (X ⨿ Y).OpenCover where
I₀ := PUnit.{w + 1} ⊕ PUnit.{w + 1}
X x := x.elim (fun _ ↦ X) (fun _ ↦ Y)
f x := x.rec (fun _ ↦ coprod.inl) (fun _ ↦ coprod.inr)
mem₀ := by
rw [Scheme.presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ?_, fun x ↦ x.rec (fun _ ↦ inferInstance) (fun _ ↦ inferInstance)⟩
use ((coprodMk X Y).symm x).elim (fun _ ↦ Sum.inl .unit) (fun _ ↦ Sum.inr .unit)
obtain ⟨x, rfl⟩ := (coprodMk X Y).surjective x
simp only [Sum.elim_inl, Sum.elim_inr, Set.mem_range]
rw [Homeomorph.symm_apply_apply]
obtain (x | x) := x
· simp only [Sum.elim_inl, coprodMk_inl, exists_apply_eq_apply]
· simp only [Sum.elim_inr, coprodMk_inr, exists_apply_eq_apply]
/-- If `X` and `Y` are open disjoint and covering open subschemes of `S`,
`S` is the disjoint union of `X` and `Y`. -/
lemma nonempty_isColimit_binaryCofanMk_of_isCompl {X Y S : Scheme.{u}}
(f : X ⟶ S) (g : Y ⟶ S) [IsOpenImmersion f] [IsOpenImmersion g]
(hf : IsCompl f.opensRange g.opensRange) :
Nonempty (IsColimit <| BinaryCofan.mk f g) := by
let c' : Cofan fun j ↦ (WalkingPair.casesOn j X Y : Scheme.{u}) :=
.mk S fun j ↦ WalkingPair.casesOn j f g
let i : BinaryCofan.mk f g ≅ c' := Cofan.ext (Iso.refl _) (by rintro (b|b) <;> rfl)
refine ⟨IsColimit.ofIsoColimit (Nonempty.some ?_) i.symm⟩
let fi (j : WalkingPair) : WalkingPair.casesOn j X Y ⟶ S := WalkingPair.casesOn j f g
convert nonempty_isColimit_cofanMk_of fi _ _
· intro i
cases i <;> (simp [fi]; infer_instance)
· simpa [← WalkingPair.equivBool.symm.iSup_comp, iSup_bool_eq, ← codisjoint_iff] using hf.2
· intro i j hij
match i, j with
| .left, .right => simpa [fi] using hf.1
| .right, .left => simpa [fi] using hf.1.symm
variable (R S : Type u) [CommRing R] [CommRing S]
/-- The map `Spec R ⨿ Spec S ⟶ Spec (R × S)`.
This is an isomorphism as witnessed by an `IsIso` instance provided below. -/
noncomputable
def coprodSpec : Spec (.of R) ⨿ Spec (.of S) ⟶ Spec (.of <| R × S) :=
coprod.desc (Spec.map (CommRingCat.ofHom <| RingHom.fst _ _))
(Spec.map (CommRingCat.ofHom <| RingHom.snd _ _))
@[simp, reassoc]
lemma coprodSpec_inl : coprod.inl ≫ coprodSpec R S =
Spec.map (CommRingCat.ofHom <| RingHom.fst R S) :=
coprod.inl_desc _ _
@[simp, reassoc]
lemma coprodSpec_inr : coprod.inr ≫ coprodSpec R S =
Spec.map (CommRingCat.ofHom <| RingHom.snd R S) :=
coprod.inr_desc _ _
lemma coprodSpec_coprodMk (x) :
coprodSpec R S (coprodMk _ _ x) = (PrimeSpectrum.primeSpectrumProd R S).symm x := by
apply PrimeSpectrum.ext
obtain (x | x) := x <;>
simp only [coprodMk_inl, coprodMk_inr, ← Scheme.Hom.comp_apply,
coprodSpec, coprod.inl_desc, coprod.inr_desc]
· change Ideal.comap _ _ = x.asIdeal.prod ⊤
ext; simp [Ideal.prod, CommRingCat.ofHom]
· change Ideal.comap _ _ = Ideal.prod ⊤ x.asIdeal
ext; simp [Ideal.prod, CommRingCat.ofHom]
lemma coprodSpec_apply (x) :
coprodSpec R S x = (PrimeSpectrum.primeSpectrumProd R S).symm ((coprodMk _ _).symm x) := by
rw [← coprodSpec_coprodMk, Homeomorph.apply_symm_apply]
lemma isIso_stalkMap_coprodSpec (x) :
IsIso ((coprodSpec R S).stalkMap x) := by
obtain ⟨x | x, rfl⟩ := (coprodMk _ _).surjective x
· have := Scheme.Hom.stalkMap_comp coprod.inl (coprodSpec R S) x
rw [← IsIso.comp_inv_eq,
Scheme.Hom.stalkMap_congr_hom _ (Spec.map _) (coprodSpec_inl R S)] at this
rw [coprodMk_inl, ← this]
letI := (RingHom.fst R S).toAlgebra
have : IsOpenImmersion (Spec.map (CommRingCat.ofHom (RingHom.fst R S))) :=
IsOpenImmersion.of_isLocalization (1, 0)
infer_instance
· have := Scheme.Hom.stalkMap_comp coprod.inr (coprodSpec R S) x
rw [← IsIso.comp_inv_eq,
Scheme.Hom.stalkMap_congr_hom _ (Spec.map _) (coprodSpec_inr R S)] at this
rw [coprodMk_inr, ← this]
letI := (RingHom.snd R S).toAlgebra
have : IsOpenImmersion (Spec.map (CommRingCat.ofHom (RingHom.snd R S))) :=
IsOpenImmersion.of_isLocalization (0, 1)
infer_instance
instance : IsIso (coprodSpec R S) := by
rw [isIso_iff_isIso_stalkMap]
refine ⟨?_, isIso_stalkMap_coprodSpec R S⟩
convert_to IsIso (TopCat.isoOfHomeo (X := Spec (.of <| R × S)) <|
PrimeSpectrum.primeSpectrumProdHomeo.trans (coprodMk (Spec <| .of R) (Spec <| .of S))).inv
· ext x; exact coprodSpec_apply R S x
· infer_instance
instance (R S : CommRingCat.{u}ᵒᵖ) : IsIso (coprodComparison Scheme.Spec R S) := by
obtain ⟨R⟩ := R; obtain ⟨S⟩ := S
have : coprodComparison Scheme.Spec (.op R) (.op S) ≫ (Spec.map
((limit.isoLimitCone ⟨_, CommRingCat.prodFanIsLimit R S⟩).inv ≫
(opProdIsoCoprod R S).unop.inv)) = coprodSpec R S := by
ext1
· rw [coprodComparison_inl_assoc, coprodSpec, coprod.inl_desc, Scheme.Spec_map,
← Spec.map_comp, Category.assoc, Iso.unop_inv, opProdIsoCoprod_inv_inl,
limit.isoLimitCone_inv_π]
rfl
· rw [coprodComparison_inr_assoc, coprodSpec, coprod.inr_desc, Scheme.Spec_map,
← Spec.map_comp, Category.assoc, Iso.unop_inv, opProdIsoCoprod_inv_inr,
limit.isoLimitCone_inv_π]
rfl
rw [(IsIso.eq_comp_inv _).mpr this]
infer_instance
instance : PreservesColimitsOfShape (Discrete WalkingPair) Scheme.Spec.{u} :=
⟨fun {_} ↦
have (X Y : CommRingCat.{u}ᵒᵖ) := PreservesColimitPair.of_iso_coprod_comparison Scheme.Spec X Y
preservesColimit_of_iso_diagram _ (diagramIsoPair _).symm⟩
instance : PreservesColimitsOfShape (Discrete PEmpty.{1}) Scheme.Spec.{u} := by
have : IsEmpty (Scheme.Spec.obj (⊥_ CommRingCatᵒᵖ)) :=
@Function.isEmpty _ _ spec_punit_isEmpty (Scheme.Spec.mapIso
(initialIsoIsInitial (initialOpOfTerminal CommRingCat.punitIsTerminal))).hom
have := preservesInitial_of_iso Scheme.Spec (asIso (initial.to _))
exact preservesColimitsOfShape_pempty_of_preservesInitial _
instance {J : Type*} [Finite J] : PreservesColimitsOfShape (Discrete J) Scheme.Spec.{u} :=
preservesFiniteCoproductsOfPreservesBinaryAndInitial _ _
/-- The canonical map `∐ Spec Rᵢ ⟶ Spec (Π Rᵢ)`.
This is an isomorphism when the product is finite. -/
noncomputable
def sigmaSpec (R : ι → CommRingCat) : (∐ fun i ↦ Spec (R i)) ⟶ Spec (.of <| Π i, R i) :=
Sigma.desc (fun i ↦ Spec.map (CommRingCat.ofHom (Pi.evalRingHom _ i)))
@[reassoc (attr := simp)]
lemma ι_sigmaSpec (R : ι → CommRingCat) (i) :
Sigma.ι _ i ≫ sigmaSpec R = Spec.map (CommRingCat.ofHom (Pi.evalRingHom _ i)) :=
Sigma.ι_desc _ _
instance (i) (R : ι → Type _) [∀ i, CommRing (R i)] :
IsOpenImmersion (Spec.map (CommRingCat.ofHom (Pi.evalRingHom (R ·) i))) := by
classical
letI := (Pi.evalRingHom R i).toAlgebra
have : IsLocalization.Away (Function.update (β := R) 0 i 1) (R i) := by
apply IsLocalization.away_of_isIdempotentElem_of_mul
· ext j; by_cases h : j = i <;> aesop
· intro x y
constructor
· intro e; ext j; by_cases h : j = i <;> aesop
· intro e; simpa using congr_fun e i
· exact Function.surjective_eval _
exact IsOpenImmersion.of_isLocalization (Function.update 0 i 1)
instance (R : ι → CommRingCat.{u}) : IsOpenImmersion (sigmaSpec R) := by
classical
apply isOpenImmersion_sigmaDesc
intro ix iy h
refine Set.disjoint_iff_forall_ne.mpr ?_
rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ e
have : DFinsupp.single (β := (R ·)) iy 1 iy ∈ y.asIdeal :=
(PrimeSpectrum.ext_iff.mp e).le (x := DFinsupp.single iy 1)
(show DFinsupp.single (β := (R ·)) iy 1 ix ∈ x.asIdeal by simp [h.symm])
simp [← Ideal.eq_top_iff_one, y.2.ne_top] at this
instance [Finite ι] (R : ι → CommRingCat.{u}) : IsIso (sigmaSpec R) := by
have : sigmaSpec R =
(colimit.isoColimitCocone ⟨_,
(IsColimit.precomposeHomEquiv Discrete.natIsoFunctor.symm _).symm (isColimitOfPreserves
Scheme.Spec (Fan.IsLimit.op (CommRingCat.piFanIsLimit R)))⟩).hom := by
ext1
simp; rfl
rw [this]
infer_instance
instance [Finite ι] [∀ i, IsAffine (f i)] : IsAffine (∐ f) :=
.of_isIso ((Sigma.mapIso (fun i ↦ (f i).isoSpec)).hom ≫ sigmaSpec _)
instance [IsAffine X] [IsAffine Y] : IsAffine (X ⨿ Y) :=
.of_isIso ((coprod.mapIso X.isoSpec Y.isoSpec).hom ≫ coprodSpec _ _)
end Coproduct
instance : CartesianMonoidalCategory Scheme := .ofHasFiniteProducts
instance : BraidedCategory Scheme := .ofCartesianMonoidalCategory
section IsAffine
lemma Scheme.isAffine_of_isLimit {I : Type*} [Category I] {D : I ⥤ Scheme.{u}}
(c : Cone D) (hc : IsLimit c) [∀ i, IsAffine (D.obj i)] :
IsAffine c.pt := by
let α : D ⟶ (D ⋙ Scheme.Γ.rightOp) ⋙ Scheme.Spec := D.whiskerLeft ΓSpec.adjunction.unit
have (i : _) : IsIso (α.app i) := IsAffine.affine
have : IsIso α := NatIso.isIso_of_isIso_app α
have : c.pt ≅ Spec Γ(c.pt, ⊤) := hc.conePointUniqueUpToIso ((IsLimit.postcomposeHomEquiv
(asIso α).symm _).symm (isLimitOfPreserves (Scheme.Γ.rightOp ⋙ Scheme.Spec) hc))
exact .of_isIso this.hom
end IsAffine
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/AffineSpace.lean | import Mathlib.Algebra.MvPolynomial.Monad
import Mathlib.AlgebraicGeometry.Morphisms.Finite
import Mathlib.AlgebraicGeometry.Morphisms.FinitePresentation
import Mathlib.RingTheory.Spectrum.Prime.Polynomial
import Mathlib.AlgebraicGeometry.PullbackCarrier
/-!
# Affine space
## Main definitions
- `AlgebraicGeometry.AffineSpace`: `𝔸(n; S)` is the affine `n`-space over `S`.
- `AlgebraicGeometry.AffineSpace.coord`: The standard coordinate functions on the affine space.
- `AlgebraicGeometry.AffineSpace.homOfVector`:
The morphism `X ⟶ 𝔸(n; S)` given by a `X ⟶ S` and a choice of `n`-coordinate functions.
- `AlgebraicGeometry.AffineSpace.homOverEquiv`:
`S`-morphisms into `Spec 𝔸(n; S)` are equivalent to the choice of `n` global sections.
- `AlgebraicGeometry.AffineSpace.SpecIso`: `𝔸(n; Spec R) ≅ Spec R[n]`
-/
open CategoryTheory Limits MvPolynomial
noncomputable section
namespace AlgebraicGeometry
universe v u
variable (n : Type v) (S : Scheme.{max u v})
local notation3 "ℤ[" n "]" => CommRingCat.of (MvPolynomial n (ULift ℤ))
local notation3 "ℤ[" n "].{" u "," v "}" => CommRingCat.of (MvPolynomial n (ULift.{max u v} ℤ))
/-- `𝔸(n; S)` is the affine `n`-space over `S`.
Note that `n` is an arbitrary index type (e.g. `Fin m`). -/
def AffineSpace (n : Type v) (S : Scheme.{max u v}) : Scheme.{max u v} :=
pullback (terminal.from S) (terminal.from (Spec ℤ[n].{u, v}))
namespace AffineSpace
/-- `𝔸(n; S)` is the affine `n`-space over `S`. -/
scoped [AlgebraicGeometry] notation "𝔸("n"; "S")" => AffineSpace n S
variable {n} in
lemma of_mvPolynomial_int_ext {R} {f g : ℤ[n] ⟶ R} (h : ∀ i, f (.X i) = g (.X i)) : f = g := by
suffices f.hom.comp (MvPolynomial.mapEquiv _ ULift.ringEquiv.symm).toRingHom =
g.hom.comp (MvPolynomial.mapEquiv _ ULift.ringEquiv.symm).toRingHom by
ext x
· obtain ⟨x⟩ := x
simpa [-map_intCast, -eq_intCast] using DFunLike.congr_fun this (C x)
· simpa [-map_intCast, -eq_intCast] using DFunLike.congr_fun this (X x)
ext1
· exact RingHom.ext_int _ _
· simpa using h _
@[simps -isSimp]
instance over : 𝔸(n; S).CanonicallyOver S where
hom := pullback.fst _ _
/-- The map from the affine `n`-space over `S` to the integral model `Spec ℤ[n]`. -/
def toSpecMvPoly : 𝔸(n; S) ⟶ Spec ℤ[n].{u, v} := pullback.snd _ _
variable {X : Scheme.{max u v}}
/--
Morphisms into `Spec ℤ[n]` are equivalent the choice of `n` global sections.
Use `homOverEquiv` instead.
-/
@[simps]
def toSpecMvPolyIntEquiv : (X ⟶ Spec ℤ[n]) ≃ (n → Γ(X, ⊤)) where
toFun f i := f.appTop ((Scheme.ΓSpecIso ℤ[n]).inv (.X i))
invFun v := X.toSpecΓ ≫ Spec.map
(CommRingCat.ofHom (MvPolynomial.eval₂Hom ((algebraMap ℤ _).comp ULift.ringEquiv.toRingHom) v))
left_inv f := by
apply (ΓSpec.adjunction.homEquiv _ _).symm.injective
apply Quiver.Hom.unop_inj
rw [Adjunction.homEquiv_symm_apply, Adjunction.homEquiv_symm_apply]
dsimp
simp only [Scheme.toSpecΓ_appTop, Scheme.ΓSpecIso_naturality, Iso.inv_hom_id_assoc]
apply of_mvPolynomial_int_ext
intro i
rw [ConcreteCategory.hom_ofHom, coe_eval₂Hom, eval₂_X]
rfl
right_inv v := by ext; simp
lemma toSpecMvPolyIntEquiv_comp {X Y : Scheme} (f : X ⟶ Y) (g : Y ⟶ Spec ℤ[n]) (i) :
toSpecMvPolyIntEquiv n (f ≫ g) i = f.appTop (toSpecMvPolyIntEquiv n g i) := rfl
variable {n} in
/-- The standard coordinates of `𝔸(n; S)`. -/
def coord (i : n) : Γ(𝔸(n; S), ⊤) := toSpecMvPolyIntEquiv _ (toSpecMvPoly n S) i
section homOfVector
variable {n S}
/-- The morphism `X ⟶ 𝔸(n; S)` given by a `X ⟶ S` and a choice of `n`-coordinate functions. -/
def homOfVector (f : X ⟶ S) (v : n → Γ(X, ⊤)) : X ⟶ 𝔸(n; S) :=
pullback.lift f ((toSpecMvPolyIntEquiv n).symm v) (by simp)
variable (f : X ⟶ S) (v : n → Γ(X, ⊤))
@[reassoc (attr := simp)]
lemma homOfVector_over : homOfVector f v ≫ 𝔸(n; S) ↘ S = f :=
pullback.lift_fst _ _ _
@[reassoc]
lemma homOfVector_toSpecMvPoly :
homOfVector f v ≫ toSpecMvPoly n S = (toSpecMvPolyIntEquiv n).symm v :=
pullback.lift_snd _ _ _
@[simp]
lemma homOfVector_appTop_coord (i) :
(homOfVector f v).appTop (coord S i) = v i := by
rw [coord, ← toSpecMvPolyIntEquiv_comp, homOfVector_toSpecMvPoly,
Equiv.apply_symm_apply]
@[ext 1100]
lemma hom_ext {f g : X ⟶ 𝔸(n; S)}
(h₁ : f ≫ 𝔸(n; S) ↘ S = g ≫ 𝔸(n; S) ↘ S)
(h₂ : ∀ i, f.appTop (coord S i) = g.appTop (coord S i)) : f = g := by
apply pullback.hom_ext h₁
change f ≫ toSpecMvPoly _ _ = g ≫ toSpecMvPoly _ _
apply (toSpecMvPolyIntEquiv n).injective
ext i
rw [toSpecMvPolyIntEquiv_comp, toSpecMvPolyIntEquiv_comp]
exact h₂ i
@[reassoc]
lemma comp_homOfVector {X Y : Scheme} (v : n → Γ(Y, ⊤)) (f : X ⟶ Y) (g : Y ⟶ S) :
f ≫ homOfVector g v = homOfVector (f ≫ g) (f.appTop ∘ v) := by
ext1 <;> simp
end homOfVector
variable [X.Over S]
variable {n}
instance (v : n → Γ(X, ⊤)) : (homOfVector (X ↘ S) v).IsOver S where
/-- `S`-morphisms into `Spec 𝔸(n; S)` are equivalent to the choice of `n` global sections. -/
@[simps]
def homOverEquiv : { f : X ⟶ 𝔸(n; S) // f.IsOver S } ≃ (n → Γ(X, ⊤)) where
toFun f i := f.1.appTop (coord S i)
invFun v := ⟨homOfVector (X ↘ S) v, inferInstance⟩
left_inv f := by
ext : 2
· simp [f.2.1]
· rw [homOfVector_appTop_coord]
right_inv v := by ext i; simp [-TopologicalSpace.Opens.map_top, homOfVector_appTop_coord]
variable (n) in
/--
The affine space over an affine base is isomorphic to the spectrum of the polynomial ring.
Also see `AffineSpace.SpecIso`.
-/
@[simps -isSimp hom inv]
def isoOfIsAffine [IsAffine S] :
𝔸(n; S) ≅ Spec <| .of <| MvPolynomial n Γ(S, ⊤) where
hom := 𝔸(n; S).toSpecΓ ≫ Spec.map (CommRingCat.ofHom
(eval₂Hom ((𝔸(n; S) ↘ S).appTop).hom (coord S)))
inv := homOfVector (Spec.map (CommRingCat.ofHom C) ≫ S.isoSpec.inv)
((Scheme.ΓSpecIso (.of (MvPolynomial n Γ(S, ⊤)))).inv ∘ MvPolynomial.X)
hom_inv_id := by
ext1
· simp only [Category.assoc, homOfVector_over, Category.id_comp]
rw [← Spec.map_comp_assoc, ← CommRingCat.ofHom_comp, eval₂Hom_comp_C,
CommRingCat.ofHom_hom, ← Scheme.toSpecΓ_naturality_assoc]
simp [Scheme.isoSpec]
· simp
inv_hom_id := by
apply ext_of_isAffine
simp only [Scheme.Hom.comp_base, TopologicalSpace.Opens.map_comp_obj,
TopologicalSpace.Opens.map_top, Scheme.Hom.comp_app, Scheme.toSpecΓ_appTop,
Scheme.ΓSpecIso_naturality, Category.assoc, Scheme.Hom.id_app, ← Iso.eq_inv_comp,
Category.comp_id]
ext : 1
apply ringHom_ext'
· change _ = (CommRingCat.ofHom C ≫ _).hom
rw [CommRingCat.hom_comp, RingHom.comp_assoc, CommRingCat.hom_ofHom, eval₂Hom_comp_C,
← CommRingCat.hom_comp, ← CommRingCat.hom_ext_iff,
← cancel_mono (Scheme.ΓSpecIso _).hom]
rw [← Scheme.Hom.comp_appTop, homOfVector_over, Scheme.Hom.comp_appTop]
simp only [Category.assoc, Scheme.ΓSpecIso_naturality, CommRingCat.of_carrier,
← Scheme.toSpecΓ_appTop]
rw [← Scheme.Hom.comp_appTop_assoc, Scheme.isoSpec, asIso_inv, IsIso.hom_inv_id]
simp
· intro i
rw [CommRingCat.comp_apply, ConcreteCategory.hom_ofHom, coe_eval₂Hom]
simp only [eval₂_X]
exact homOfVector_appTop_coord _ _ _
@[simp]
lemma isoOfIsAffine_hom_appTop [IsAffine S] :
(isoOfIsAffine n S).hom.appTop =
(Scheme.ΓSpecIso _).hom ≫ CommRingCat.ofHom
(eval₂Hom ((𝔸(n; S) ↘ S).appTop).hom (coord S)) := by
simp [isoOfIsAffine_hom]
@[simp]
lemma isoOfIsAffine_inv_appTop_coord [IsAffine S] (i) :
(isoOfIsAffine n S).inv.appTop (coord _ i) = (Scheme.ΓSpecIso (.of _)).inv (.X i) :=
homOfVector_appTop_coord _ _ _
@[reassoc (attr := simp)]
lemma isoOfIsAffine_inv_over [IsAffine S] :
(isoOfIsAffine n S).inv ≫ 𝔸(n; S) ↘ S = Spec.map (CommRingCat.ofHom C) ≫ S.isoSpec.inv :=
pullback.lift_fst _ _ _
instance [IsAffine S] : IsAffine 𝔸(n; S) := .of_isIso (isoOfIsAffine n S).hom
variable (n) in
/-- The affine space over an affine base is isomorphic to the spectrum of the polynomial ring. -/
def SpecIso (R : CommRingCat.{max u v}) :
𝔸(n; Spec R) ≅ Spec <| .of <| MvPolynomial n R :=
isoOfIsAffine _ _ ≪≫ Scheme.Spec.mapIso (MvPolynomial.mapEquiv _
(Scheme.ΓSpecIso R).symm.commRingCatIsoToRingEquiv).toCommRingCatIso.op
@[simp]
lemma SpecIso_hom_appTop (R : CommRingCat.{max u v}) :
(SpecIso n R).hom.appTop = (Scheme.ΓSpecIso _).hom ≫
CommRingCat.ofHom (eval₂Hom ((Scheme.ΓSpecIso _).inv ≫
(𝔸(n; Spec R) ↘ Spec R).appTop).hom (coord (Spec R))) := by
simp only [SpecIso, Iso.trans_hom, Functor.mapIso_hom, Iso.op_hom,
Scheme.Spec_map, Quiver.Hom.unop_op, TopologicalSpace.Opens.map_top, Scheme.Hom.comp_app,
isoOfIsAffine_hom_appTop, Scheme.ΓSpecIso_naturality_assoc]
congr 1
ext : 1
apply ringHom_ext'
· ext; simp
· simp
@[simp]
lemma SpecIso_inv_appTop_coord (R : CommRingCat.{max u v}) (i) :
(SpecIso n R).inv.appTop (coord _ i) = (Scheme.ΓSpecIso (.of _)).inv (.X i) := by
simp only [SpecIso, Iso.trans_inv, Functor.mapIso_inv, Iso.op_inv, Scheme.Spec_map,
Quiver.Hom.unop_op, TopologicalSpace.Opens.map_top, Scheme.Hom.comp_app, CommRingCat.comp_apply]
rw [isoOfIsAffine_inv_appTop_coord, ← CommRingCat.comp_apply, ← Scheme.ΓSpecIso_inv_naturality,
CommRingCat.comp_apply]
congr 1
exact map_X _ _
@[reassoc (attr := simp)]
lemma SpecIso_inv_over (R : CommRingCat.{max u v}) :
(SpecIso n R).inv ≫ 𝔸(n; Spec R) ↘ Spec R = Spec.map (CommRingCat.ofHom C) := by
simp only [SpecIso, Iso.trans_inv, Functor.mapIso_inv, Iso.op_inv, Scheme.Spec_map,
Quiver.Hom.unop_op, Category.assoc, isoOfIsAffine_inv_over, Scheme.isoSpec_Spec_inv,
← Spec.map_comp]
congr 1
rw [Iso.inv_comp_eq]
ext : 2
exact map_C _ _
section functorial
variable (n) in
/-- `𝔸(n; S)` is functorial w.r.t. `S`. -/
def map {S T : Scheme.{max u v}} (f : S ⟶ T) : 𝔸(n; S) ⟶ 𝔸(n; T) :=
homOfVector (𝔸(n; S) ↘ S ≫ f) (coord S)
@[reassoc (attr := simp)]
lemma map_over {S T : Scheme.{max u v}} (f : S ⟶ T) : map n f ≫ 𝔸(n; T) ↘ T = 𝔸(n; S) ↘ S ≫ f :=
pullback.lift_fst _ _ _
@[simp]
lemma map_appTop_coord {S T : Scheme.{max u v}} (f : S ⟶ T) (i) :
(map n f).appTop (coord T i) = coord S i :=
homOfVector_appTop_coord _ _ _
@[reassoc (attr := simp)]
lemma map_toSpecMvPoly {S T : Scheme.{max u v}} (f : S ⟶ T) :
map n f ≫ toSpecMvPoly n T = toSpecMvPoly n S := by
apply (toSpecMvPolyIntEquiv _).injective
ext i
rw [toSpecMvPolyIntEquiv_comp, ← coord, map_appTop_coord, coord]
@[simp]
lemma map_id : map n (𝟙 S) = 𝟙 𝔸(n; S) := by
ext1 <;> simp
@[reassoc, simp]
lemma map_comp {S S' S'' : Scheme} (f : S ⟶ S') (g : S' ⟶ S'') :
map n (f ≫ g) = map n f ≫ map n g := by
ext1
· simp
· simp
lemma map_SpecMap {R S : CommRingCat.{max u v}} (φ : R ⟶ S) :
map n (Spec.map φ) =
(SpecIso n S).hom ≫ Spec.map (CommRingCat.ofHom (MvPolynomial.map φ.hom)) ≫
(SpecIso n R).inv := by
rw [← Iso.inv_comp_eq]
ext1
· simp only [map_over, Category.assoc, SpecIso_inv_over, SpecIso_inv_over_assoc,
← Spec.map_comp, ← CommRingCat.ofHom_comp]
rw [map_comp_C, CommRingCat.ofHom_comp, CommRingCat.ofHom_hom]
· simp only [TopologicalSpace.Opens.map_top, Scheme.Hom.comp_app, CommRingCat.comp_apply]
conv_lhs => enter[2]; tactic => exact map_appTop_coord _ _
conv_rhs => enter[2]; tactic => exact SpecIso_inv_appTop_coord _ _
rw [SpecIso_inv_appTop_coord, ← CommRingCat.comp_apply, ← Scheme.ΓSpecIso_inv_naturality,
CommRingCat.comp_apply, ConcreteCategory.hom_ofHom, map_X]
@[deprecated (since := "2025-10-07")] alias map_Spec_map := map_SpecMap
/-- The map between affine spaces over affine bases is
isomorphic to the natural map between polynomial rings. -/
def mapSpecMap {R S : CommRingCat.{max u v}} (φ : R ⟶ S) :
Arrow.mk (map n (Spec.map φ)) ≅
Arrow.mk (Spec.map (CommRingCat.ofHom (MvPolynomial.map (σ := n) φ.hom))) :=
Arrow.isoMk (SpecIso n S) (SpecIso n R) (by have := (SpecIso n R).inv_hom_id; simp [map_SpecMap])
lemma isPullback_map {S T : Scheme.{max u v}} (f : S ⟶ T) :
IsPullback (map n f) (𝔸(n; S) ↘ S) (𝔸(n; T) ↘ T) f := by
refine (IsPullback.paste_horiz_iff (.flip <| .of_hasPullback _ _) (map_over f)).mp ?_
simp only [terminal.comp_from, ]
convert (IsPullback.of_hasPullback _ _).flip
rw [← toSpecMvPoly, ← toSpecMvPoly, map_toSpecMvPoly]
/-- `𝔸(n; S)` is functorial w.r.t. `n`. -/
def reindex {n m : Type v} (i : m → n) (S : Scheme.{max u v}) : 𝔸(n; S) ⟶ 𝔸(m; S) :=
homOfVector (𝔸(n; S) ↘ S) (coord S ∘ i)
@[simp, reassoc]
lemma reindex_over {n m : Type v} (i : m → n) (S : Scheme.{max u v}) :
reindex i S ≫ 𝔸(m; S) ↘ S = 𝔸(n; S) ↘ S :=
pullback.lift_fst _ _ _
@[simp]
lemma reindex_appTop_coord {n m : Type v} (i : m → n) (S : Scheme.{max u v}) (j : m) :
(reindex i S).appTop (coord S j) = coord S (i j) :=
homOfVector_appTop_coord _ _ _
@[simp]
lemma reindex_id : reindex id S = 𝟙 𝔸(n; S) := by
ext1 <;> simp
@[simp, reassoc]
lemma reindex_comp {n₁ n₂ n₃ : Type v} (i : n₁ → n₂) (j : n₂ → n₃) (S : Scheme.{max u v}) :
reindex (j ∘ i) S = reindex j S ≫ reindex i S := by
have H₁ : reindex (j ∘ i) S ≫ 𝔸(n₁; S) ↘ S = (reindex j S ≫ reindex i S) ≫ 𝔸(n₁; S) ↘ S := by
simp
have H₂ (k) : (reindex (j ∘ i) S).appTop (coord S k) =
(reindex j S).appTop ((reindex i S).appTop (coord S k)) := by
rw [reindex_appTop_coord, reindex_appTop_coord, reindex_appTop_coord]
rfl
exact hom_ext H₁ H₂
@[reassoc (attr := simp)]
lemma map_reindex {n₁ n₂ : Type v} (i : n₁ → n₂) {S T : Scheme.{max u v}} (f : S ⟶ T) :
map n₂ f ≫ reindex i T = reindex i S ≫ map n₁ f := by
apply hom_ext <;> simp
/-- The affine space as a functor. -/
@[simps]
def functor : (Type v)ᵒᵖ ⥤ Scheme.{max u v} ⥤ Scheme.{max u v} where
obj n := { obj := AffineSpace n.unop, map := map n.unop, map_id := map_id, map_comp := map_comp }
map {n m} i := { app := reindex i.unop, naturality := fun _ _ ↦ map_reindex i.unop }
map_id n := by ext: 2; exact reindex_id _
map_comp f g := by ext: 2; dsimp; exact reindex_comp _ _ _
end functorial
section instances
instance : IsAffineHom (𝔸(n; S) ↘ S) := MorphismProperty.pullback_fst _ _ inferInstance
instance : Surjective (𝔸(n; S) ↘ S) := MorphismProperty.pullback_fst _ _ <| by
have := isIso_of_isTerminal specULiftZIsTerminal terminalIsTerminal (terminal.from _)
rw [← terminal.comp_from (Spec.map (CommRingCat.ofHom C)),
MorphismProperty.cancel_right_of_respectsIso (P := @Surjective)]
exact ⟨MvPolynomial.comap_C_surjective⟩
instance [Finite n] : LocallyOfFinitePresentation (𝔸(n; S) ↘ S) :=
MorphismProperty.pullback_fst _ _ <| by
have := isIso_of_isTerminal specULiftZIsTerminal.{max u v} terminalIsTerminal (terminal.from _)
rw [← terminal.comp_from (Spec.map (CommRingCat.ofHom C)),
MorphismProperty.cancel_right_of_respectsIso (P := @LocallyOfFinitePresentation),
HasRingHomProperty.Spec_iff (P := @LocallyOfFinitePresentation), RingHom.FinitePresentation]
convert (inferInstanceAs (Algebra.FinitePresentation (ULift ℤ) ℤ[n]))
exact Algebra.algebra_ext _ _ fun _ ↦ rfl
lemma isOpenMap_over : IsOpenMap (𝔸(n; S) ↘ S) := by
change topologically @IsOpenMap _
wlog hS : ∃ R, S = Spec R
· refine (IsZariskiLocalAtTarget.iff_of_openCover
(P := topologically @IsOpenMap) S.affineCover).mpr ?_
intro i
have := this (n := n) (S.affineCover.X i) ⟨_, rfl⟩
rwa [← (isPullback_map (n := n) (S.affineCover.f i)).isoPullback_hom_snd,
MorphismProperty.cancel_left_of_respectsIso (P := topologically @IsOpenMap)] at this
obtain ⟨R, rfl⟩ := hS
rw [← MorphismProperty.cancel_left_of_respectsIso (P := topologically @IsOpenMap)
(SpecIso n R).inv, SpecIso_inv_over]
exact MvPolynomial.isOpenMap_comap_C
open MorphismProperty in
instance [IsEmpty n] : IsIso (𝔸(n; S) ↘ S) := pullback_fst
(P := isomorphisms _) _ _ <| by
rw [← terminal.comp_from (Spec.map (CommRingCat.ofHom C))]
apply IsStableUnderComposition.comp_mem
· rw [HasAffineProperty.iff_of_isAffine (P := isomorphisms _), ← isomorphisms,
← arrow_mk_iso_iff (isomorphisms _) (arrowIsoΓSpecOfIsAffine _)]
exact ⟨inferInstance, (ConcreteCategory.isIso_iff_bijective _).mpr
⟨C_injective n _, C_surjective _⟩⟩
· exact isIso_of_isTerminal specULiftZIsTerminal terminalIsTerminal (terminal.from _)
lemma isIntegralHom_over_iff_isEmpty : IsIntegralHom (𝔸(n; S) ↘ S) ↔ IsEmpty S ∨ IsEmpty n := by
constructor
· intro h
cases isEmpty_or_nonempty S
· exact .inl ‹_›
refine .inr ?_
wlog hS : ∃ R, S = Spec R
· obtain ⟨x⟩ := ‹Nonempty S›
obtain ⟨y, hy⟩ := S.affineCover.covers x
exact this (S.affineCover.X _) (MorphismProperty.IsStableUnderBaseChange.of_isPullback
(isPullback_map (S.affineCover.f _)) h) ⟨y⟩ ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hS
have : Nontrivial R := (subsingleton_or_nontrivial R).resolve_left fun H ↦
not_isEmpty_of_nonempty (Spec R) (inferInstanceAs (IsEmpty (PrimeSpectrum R)))
constructor
intro i
have := RingHom.toMorphismProperty_respectsIso_iff.mp RingHom.isIntegral_respectsIso.{max u v}
rw [← MorphismProperty.cancel_left_of_respectsIso @IsIntegralHom (SpecIso n R).inv,
SpecIso_inv_over, HasAffineProperty.iff_of_isAffine (P := @IsIntegralHom)] at h
obtain ⟨p : Polynomial R, hp, hp'⟩ :=
(MorphismProperty.arrow_mk_iso_iff (RingHom.toMorphismProperty RingHom.IsIntegral)
(arrowIsoΓSpecOfIsAffine _)).mpr h.2 (X i)
have : (rename fun _ ↦ i).comp (pUnitAlgEquiv.{_, v} _).symm.toAlgHom p = 0 := by
simp [← hp', ← algebraMap_eq]
rw [AlgHom.comp_apply, map_eq_zero_iff _ (rename_injective _ (fun _ _ _ ↦ rfl))] at this
simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_coe, EmbeddingLike.map_eq_zero_iff] at this
simp [this] at hp
· rintro (_ | _) <;> infer_instance
lemma not_isIntegralHom [Nonempty S] [Nonempty n] : ¬ IsIntegralHom (𝔸(n; S) ↘ S) := by
simp [isIntegralHom_over_iff_isEmpty]
lemma spec_le_iff (R : CommRingCat) (p q : Spec R) : p ≤ q ↔ q.asIdeal ≤ p.asIdeal := by
aesop (add simp PrimeSpectrum.le_iff_specializes)
/--
One should bear this equality in mind when breaking the `Spec R/ PrimeSpectrum R` abstraction
boundary, since these instances are not definitionally equal.
-/
example (R : CommRingCat) :
inferInstance (α := Preorder (Spec R)) = inferInstance (α := Preorder (PrimeSpectrum R)ᵒᵈ) := by
aesop (add simp spec_le_iff)
end instances
end AffineSpace
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/QuasiAffine.lean | import Mathlib.AlgebraicGeometry.Morphisms.Immersion
/-!
# Quasi-affine schemes
## Main results
- `IsQuasiAffine`:
A scheme `X` is quasi-affine if it is quasi-compact and `X ⟶ Spec Γ(X, ⊤)` is an immersion.
This actually implies that `X ⟶ Spec Γ(X, ⊤)` is an open immersion.
- `IsQuasiAffine.of_isImmersion`:
Any quasi-compact locally closed subscheme of a quasi-affine scheme is quasi-affine.
-/
open CategoryTheory Limits TopologicalSpace
universe u
namespace AlgebraicGeometry.Scheme
/-- A scheme `X` is quasi-affine if it is quasi-compact and `X ⟶ Spec Γ(X, ⊤)` is an immersion.
This actually implies that `X ⟶ Spec Γ(X, ⊤)` is an open immersion. -/
@[stacks 01P6]
class IsQuasiAffine (X : Scheme.{u}) : Prop extends
CompactSpace X, IsImmersion X.toSpecΓ
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
instance (priority := low) [IsAffine X] : X.IsQuasiAffine where
instance (priority := low) [X.IsQuasiAffine] : X.IsSeparated where
isSeparated_terminal_from := by
rw [← terminal.comp_from X.toSpecΓ]
infer_instance
instance [X.IsQuasiAffine] : IsOpenImmersion X.toSpecΓ := by
have : IsIso X.toSpecΓ.imageι := by delta Hom.imageι Hom.image; rw [X.ker_toSpecΓ]; infer_instance
rw [← X.toSpecΓ.toImage_imageι]
infer_instance
/-- Any quasicompact locally closed subscheme of a quasi-affine scheme is quasi-affine. -/
@[stacks 0BCK]
lemma IsQuasiAffine.of_isImmersion
[Y.IsQuasiAffine] [IsImmersion f] [CompactSpace X] : X.IsQuasiAffine := by
have : IsImmersion (X.toSpecΓ ≫ Spec.map f.appTop) := by rw [← toSpecΓ_naturality]; infer_instance
have : IsImmersion X.toSpecΓ := .of_comp _ (Spec.map f.appTop)
constructor
lemma IsQuasiAffine.isBasis_basicOpen (X : Scheme.{u}) [IsQuasiAffine X] :
Opens.IsBasis { X.basicOpen r | (r : Γ(X, ⊤)) (_ : IsAffineOpen (X.basicOpen r)) } := by
refine Opens.isBasis_iff_nbhd.mpr fun {U x} hxU ↦ ?_
obtain ⟨_, ⟨_, ⟨r, rfl⟩, rfl⟩, hxr, hrU⟩ := (PrimeSpectrum.isBasis_basic_opens
(R := Γ(X, ⊤))).exists_subset_of_mem_open (Set.mem_image_of_mem _ hxU) (X.toSpecΓ ''ᵁ U).2
simp_rw [← toSpecΓ_preimage_basicOpen]
refine ⟨_, ⟨r, ?_, rfl⟩, hxr, (Set.preimage_mono hrU).trans_eq
(Set.preimage_image_eq _ X.toSpecΓ.isEmbedding.injective)⟩
rw [← Hom.isAffineOpen_iff_of_isOpenImmersion X.toSpecΓ]
convert IsAffineOpen.Spec_basicOpen r
exact SetLike.coe_injective (Set.image_preimage_eq_of_subset
(hrU.trans (Set.image_subset_range _ _)))
/-- A quasi-compact scheme is quasi-affine if
it can be covered by affine basic opens of global sections. -/
lemma IsQuasiAffine.of_forall_exists_mem_basicOpen (X : Scheme.{u}) [CompactSpace X]
(H : ∀ x : X, ∃ r : Γ(X, ⊤), IsAffineOpen (X.basicOpen r) ∧ x ∈ X.basicOpen r) :
IsQuasiAffine X := by
suffices IsOpenImmersion X.toSpecΓ by constructor
have : QuasiSeparatedSpace X := by
choose r hr hxr using H
exact .of_isOpenCover (U := (X.basicOpen <| r ·))
(eq_top_iff.mpr fun _ _ ↦ Opens.mem_iSup.mpr ⟨_, hxr _⟩)
(fun _ ↦ isRetrocompact_basicOpen _) (fun x ↦ (hr _).isQuasiSeparated)
refine IsZariskiLocalAtTarget.of_forall_source_exists_preimage _ fun x ↦ ?_
obtain ⟨r, hr, hxr⟩ := H x
refine ⟨PrimeSpectrum.basicOpen r, (X.toSpecΓ_preimage_basicOpen r).ge hxr, ?_⟩
suffices IsOpenImmersion ((X.basicOpen r).ι ≫ X.toSpecΓ) by
convert this <;> rw [toSpecΓ_preimage_basicOpen]
rw [← Opens.toSpecΓ_SpecMap_presheaf_map_top]
have := isLocalization_basicOpen_of_qcqs isCompact_univ isQuasiSeparated_univ r
exact MorphismProperty.comp_mem _ hr.isoSpec.hom _ inferInstance (.of_isLocalization r)
lemma IsQuasiAffine.of_isAffineHom [IsAffineHom f] [Y.IsQuasiAffine] : X.IsQuasiAffine := by
have := QuasiCompact.compactSpace_of_compactSpace f
refine .of_forall_exists_mem_basicOpen _ fun x ↦ ?_
obtain ⟨_, ⟨_, ⟨r, hr, rfl⟩, rfl⟩, hxr, -⟩ := (IsQuasiAffine.isBasis_basicOpen
Y).exists_subset_of_mem_open (Set.mem_univ (f x)) isOpen_univ
refine ⟨f.appTop r, ?_⟩
rw [← preimage_basicOpen_top]
exact ⟨hr.preimage _, hxr⟩
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean | import Mathlib.AlgebraicGeometry.Restrict
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Adjunction.Reflective
/-!
# Adjunction between `Γ` and `Spec`
We define the adjunction `ΓSpec.adjunction : Γ ⊣ Spec` by defining the unit (`toΓSpec`,
in multiple steps in this file) and counit (done in `Spec.lean`) and checking that they satisfy
the left and right triangle identities. The constructions and proofs make use of
maps and lemmas defined and proved in structure_sheaf.lean extensively.
Notice that since the adjunction is between contravariant functors, you get to choose
one of the two categories to have arrows reversed, and it is equally valid to present
the adjunction as `Spec ⊣ Γ` (`Spec.to_LocallyRingedSpace.right_op ⊣ Γ`), in which
case the unit and the counit would switch to each other.
## Main definition
* `AlgebraicGeometry.identityToΓSpec` : The natural transformation `𝟭 _ ⟶ Γ ⋙ Spec`.
* `AlgebraicGeometry.ΓSpec.locallyRingedSpaceAdjunction` : The adjunction `Γ ⊣ Spec` from
`CommRingᵒᵖ` to `LocallyRingedSpace`.
* `AlgebraicGeometry.ΓSpec.adjunction` : The adjunction `Γ ⊣ Spec` from
`CommRingᵒᵖ` to `Scheme`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
noncomputable section
universe u
open PrimeSpectrum
namespace AlgebraicGeometry
open Opposite
open CategoryTheory
open StructureSheaf
open Spec (structureSheaf)
open TopologicalSpace
open AlgebraicGeometry.LocallyRingedSpace
open TopCat.Presheaf
open TopCat.Presheaf.SheafCondition
namespace LocallyRingedSpace
variable (X : LocallyRingedSpace.{u})
/-- The canonical map from the underlying set to the prime spectrum of `Γ(X)`. -/
def toΓSpecFun : X → PrimeSpectrum (Γ.obj (op X)) := fun x =>
comap (X.presheaf.Γgerm x).hom (IsLocalRing.closedPoint (X.presheaf.stalk x))
theorem notMem_prime_iff_unit_in_stalk (r : Γ.obj (op X)) (x : X) :
r ∉ (X.toΓSpecFun x).asIdeal ↔ IsUnit (X.presheaf.Γgerm x r) := by
simp [toΓSpecFun, IsLocalRing.closedPoint]
@[deprecated (since := "2025-05-23")]
alias not_mem_prime_iff_unit_in_stalk := notMem_prime_iff_unit_in_stalk
/-- The preimage of a basic open in `Spec Γ(X)` under the unit is the basic
open in `X` defined by the same element (they are equal as sets). -/
theorem toΓSpec_preimage_basicOpen_eq (r : Γ.obj (op X)) :
X.toΓSpecFun ⁻¹' basicOpen r = SetLike.coe (X.toRingedSpace.basicOpen r) := by
ext
dsimp
simp only [Set.mem_preimage, SetLike.mem_coe]
rw [X.toRingedSpace.mem_top_basicOpen]
exact notMem_prime_iff_unit_in_stalk ..
/-- `toΓSpecFun` is continuous. -/
theorem toΓSpec_continuous : Continuous X.toΓSpecFun := by
rw [isTopologicalBasis_basic_opens.continuous_iff]
rintro _ ⟨r, rfl⟩
rw [X.toΓSpec_preimage_basicOpen_eq r]
exact (X.toRingedSpace.basicOpen r).2
/-- The canonical (bundled) continuous map from the underlying topological
space of `X` to the prime spectrum of its global sections. -/
def toΓSpecBase : X.toTopCat ⟶ Spec.topObj (Γ.obj (op X)) :=
TopCat.ofHom
{ toFun := X.toΓSpecFun
continuous_toFun := X.toΓSpec_continuous }
variable (r : Γ.obj (op X))
/-- The preimage in `X` of a basic open in `Spec Γ(X)` (as an open set). -/
abbrev toΓSpecMapBasicOpen : Opens X :=
(Opens.map X.toΓSpecBase).obj (basicOpen r)
/-- The preimage is the basic open in `X` defined by the same element `r`. -/
theorem toΓSpecMapBasicOpen_eq : X.toΓSpecMapBasicOpen r = X.toRingedSpace.basicOpen r :=
Opens.ext (X.toΓSpec_preimage_basicOpen_eq r)
/-- The map from the global sections `Γ(X)` to the sections on the (preimage of) a basic open. -/
abbrev toToΓSpecMapBasicOpen :
X.presheaf.obj (op ⊤) ⟶ X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r) :=
X.presheaf.map (X.toΓSpecMapBasicOpen r).leTop.op
/-- `r` is a unit as a section on the basic open defined by `r`. -/
theorem isUnit_res_toΓSpecMapBasicOpen : IsUnit (X.toToΓSpecMapBasicOpen r r) := by
convert
(X.presheaf.map <| (eqToHom <| X.toΓSpecMapBasicOpen_eq r).op).hom.isUnit_map
(X.toRingedSpace.isUnit_res_basicOpen r)
rw [← CommRingCat.comp_apply, ← Functor.map_comp]
congr
/-- Define the sheaf hom on individual basic opens for the unit. -/
def toΓSpecCApp :
(structureSheaf <| Γ.obj <| op X).val.obj (op <| basicOpen r) ⟶
X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r) :=
-- note: the explicit type annotations were not needed before
-- https://github.com/leanprover-community/mathlib4/pull/19757
CommRingCat.ofHom <|
IsLocalization.Away.lift
(R := Γ.obj (op X))
(S := (structureSheaf ↑(Γ.obj (op X))).val.obj (op (basicOpen r)))
r
(isUnit_res_toΓSpecMapBasicOpen _ r)
/-- Characterization of the sheaf hom on basic opens,
direction ← (next lemma) is used at various places, but → is not used in this file. -/
theorem toΓSpecCApp_iff
(f :
(structureSheaf <| Γ.obj <| op X).val.obj (op <| basicOpen r) ⟶
X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r)) :
toOpen _ (basicOpen r) ≫ f = X.toToΓSpecMapBasicOpen r ↔ f = X.toΓSpecCApp r := by
have loc_inst := IsLocalization.to_basicOpen (Γ.obj (op X)) r
refine ConcreteCategory.ext_iff.trans ?_
rw [← @IsLocalization.Away.lift_comp _ _ _ _ _ _ _ r loc_inst _
(X.isUnit_res_toΓSpecMapBasicOpen r)]
constructor
· intro h
ext : 1
exact IsLocalization.ringHom_ext (Submonoid.powers r) h
apply congr_arg
theorem toΓSpecCApp_spec : toOpen _ (basicOpen r) ≫ X.toΓSpecCApp r = X.toToΓSpecMapBasicOpen r :=
(X.toΓSpecCApp_iff r _).2 rfl
/-- The sheaf hom on all basic opens, commuting with restrictions. -/
@[simps app]
def toΓSpecCBasicOpens :
(inducedFunctor basicOpen).op ⋙ (structureSheaf (Γ.obj (op X))).1 ⟶
(inducedFunctor basicOpen).op ⋙ ((TopCat.Sheaf.pushforward _ X.toΓSpecBase).obj X.𝒪).1 where
app r := X.toΓSpecCApp r.unop
naturality r s f := by
apply (StructureSheaf.to_basicOpen_epi (Γ.obj (op X)) r.unop).1
simp only [← Category.assoc]
rw [X.toΓSpecCApp_spec r.unop]
convert X.toΓSpecCApp_spec s.unop
symm
apply X.presheaf.map_comp
/-- The canonical morphism of sheafed spaces from `X` to the spectrum of its global sections. -/
@[simps]
def toΓSpecSheafedSpace : X.toSheafedSpace ⟶ Spec.toSheafedSpace.obj (op (Γ.obj (op X))) where
base := X.toΓSpecBase
c :=
TopCat.Sheaf.restrictHomEquivHom (structureSheaf (Γ.obj (op X))).1 _ isBasis_basic_opens
X.toΓSpecCBasicOpens
theorem toΓSpecSheafedSpace_app_eq :
X.toΓSpecSheafedSpace.c.app (op (basicOpen r)) = X.toΓSpecCApp r := by
apply TopCat.Sheaf.extend_hom_app _ _ _
@[reassoc] theorem toΓSpecSheafedSpace_app_spec (r : Γ.obj (op X)) :
toOpen (Γ.obj (op X)) (basicOpen r) ≫ X.toΓSpecSheafedSpace.c.app (op (basicOpen r)) =
X.toToΓSpecMapBasicOpen r :=
(X.toΓSpecSheafedSpace_app_eq r).symm ▸ X.toΓSpecCApp_spec r
/-- The map on stalks induced by the unit commutes with maps from `Γ(X)` to
stalks (in `Spec Γ(X)` and in `X`). -/
theorem toStalk_stalkMap_toΓSpec (x : X) :
toStalk _ _ ≫ X.toΓSpecSheafedSpace.stalkMap x = X.presheaf.Γgerm x := by
rw [PresheafedSpace.Hom.stalkMap,
← toOpen_germ _ (basicOpen (1 : Γ.obj (op X))) _ (by rw [basicOpen_one]; trivial),
← Category.assoc, Category.assoc (toOpen _ _), stalkFunctor_map_germ, ← Category.assoc,
X.toΓSpecSheafedSpace_app_eq, X.toΓSpecCApp_spec, Γgerm]
erw [← stalkPushforward_germ _ _ X.presheaf ⊤]
congr 1
exact (X.toΓSpecBase _* X.presheaf).germ_res le_top.hom _ _
/-- The canonical morphism from `X` to the spectrum of its global sections. -/
@[simps! base]
def toΓSpec : X ⟶ Spec.locallyRingedSpaceObj (Γ.obj (op X)) where
__ := X.toΓSpecSheafedSpace
prop := by
intro x
let p : PrimeSpectrum (Γ.obj (op X)) := X.toΓSpecFun x
constructor
-- show stalk map is local hom ↓
let S := (structureSheaf _).presheaf.stalk p
rintro (t : S) ht
obtain ⟨⟨r, s⟩, he⟩ := IsLocalization.surj p.asIdeal.primeCompl t
dsimp at he
set t' := _
change t * t' = _ at he
apply isUnit_of_mul_isUnit_left (y := t')
rw [he]
refine IsLocalization.map_units S (⟨r, ?_⟩ : p.asIdeal.primeCompl)
apply (notMem_prime_iff_unit_in_stalk _ _ _).mpr
rw [← toStalk_stalkMap_toΓSpec, CommRingCat.comp_apply]
erw [← he]
rw [RingHom.map_mul]
exact ht.mul <| (IsLocalization.map_units (R := Γ.obj (op X)) S s).map _
/-- On a locally ringed space `X`, the preimage of the zero locus of the prime spectrum
of `Γ(X, ⊤)` under `toΓSpec` agrees with the associated zero locus on `X`. -/
lemma toΓSpec_preimage_zeroLocus_eq {X : LocallyRingedSpace.{u}}
(s : Set (X.presheaf.obj (op ⊤))) :
X.toΓSpec.base ⁻¹' PrimeSpectrum.zeroLocus s = X.toRingedSpace.zeroLocus s := by
simp only [RingedSpace.zeroLocus]
have (i : LocallyRingedSpace.Γ.obj (op X)) (_ : i ∈ s) :
(SetLike.coe (X.toRingedSpace.basicOpen i))ᶜ =
X.toΓSpec.base ⁻¹' ((PrimeSpectrum.basicOpen i).carrier)ᶜ := by
symm
rw [Set.preimage_compl, Opens.carrier_eq_coe]
erw [X.toΓSpec_preimage_basicOpen_eq i]
erw [Set.iInter₂_congr this]
simp_rw [← Set.preimage_iInter₂, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl,
compl_compl]
rw [← PrimeSpectrum.zeroLocus_iUnion₂]
simp
theorem comp_ring_hom_ext {X : LocallyRingedSpace.{u}} {R : CommRingCat.{u}} {f : R ⟶ Γ.obj (op X)}
{β : X ⟶ Spec.locallyRingedSpaceObj R}
(w : X.toΓSpec.base ≫ (Spec.locallyRingedSpaceMap f).base = β.base)
(h :
∀ r : R,
f ≫ X.presheaf.map (homOfLE le_top : (Opens.map β.base).obj (basicOpen r) ⟶ _).op =
toOpen R (basicOpen r) ≫ β.c.app (op (basicOpen r))) :
X.toΓSpec ≫ Spec.locallyRingedSpaceMap f = β := by
ext1
refine Spec.basicOpen_hom_ext w ?_
intro r U
rw [LocallyRingedSpace.comp_c_app]
erw [toOpen_comp_comap_assoc]
rw [Category.assoc]
erw [toΓSpecSheafedSpace_app_spec, ← X.presheaf.map_comp]
exact h r
/-- `toSpecΓ _` is an isomorphism so these are mutually two-sided inverses. -/
theorem Γ_Spec_left_triangle : toSpecΓ (Γ.obj (op X)) ≫ X.toΓSpec.c.app (op ⊤) = 𝟙 _ := by
unfold toSpecΓ
rw [← toOpen_res _ (basicOpen (1 : Γ.obj (op X))) ⊤ (eqToHom basicOpen_one.symm),
Category.assoc, NatTrans.naturality, ← Category.assoc]
erw [X.toΓSpecSheafedSpace_app_spec 1, ← Functor.map_comp]
convert eqToHom_map X.presheaf _; rfl
end LocallyRingedSpace
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
app := LocallyRingedSpace.toΓSpec
naturality X Y f := by
symm
apply LocallyRingedSpace.comp_ring_hom_ext
· ext1 x
dsimp
change PrimeSpectrum.comap (f.c.app (op ⊤)).hom (X.toΓSpecFun x) = Y.toΓSpecFun (f.base x)
dsimp [toΓSpecFun]
rw [← IsLocalRing.comap_closedPoint (f.stalkMap x).hom, ←
PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply,
← CommRingCat.hom_comp, ← CommRingCat.hom_comp]
congr 3
exact (PresheafedSpace.stalkMap_germ f.1 ⊤ x trivial).symm
· intro r
rw [LocallyRingedSpace.comp_c_app, ← Category.assoc]
erw [Y.toΓSpecSheafedSpace_app_spec, f.c.naturality]
rfl
namespace ΓSpec
theorem left_triangle (X : LocallyRingedSpace) :
SpecΓIdentity.inv.app (Γ.obj (op X)) ≫ (identityToΓSpec.app X).c.app (op ⊤) = 𝟙 _ :=
X.Γ_Spec_left_triangle
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
𝟙 _ := by
apply LocallyRingedSpace.comp_ring_hom_ext
· ext (p : PrimeSpectrum R)
dsimp
refine PrimeSpectrum.ext (Ideal.ext fun x => ?_)
rw [← IsLocalization.AtPrime.to_map_mem_maximal_iff ((structureSheaf R).presheaf.stalk p)
p.asIdeal x]
rfl
· intro r; apply toOpen_res
/-- The adjunction `Γ ⊣ Spec` from `CommRingᵒᵖ` to `LocallyRingedSpace`. -/
@[simps]
def locallyRingedSpaceAdjunction : Γ.rightOp ⊣ Spec.toLocallyRingedSpace.{u} where
unit := identityToΓSpec
counit := (NatIso.op SpecΓIdentity).inv
left_triangle_components X := by
simp only [Functor.id_obj, Functor.rightOp_obj, Γ_obj, Functor.comp_obj,
Spec.toLocallyRingedSpace_obj, Spec.locallyRingedSpaceObj_toSheafedSpace,
Spec.sheafedSpaceObj_carrier, Spec.sheafedSpaceObj_presheaf, Functor.rightOp_map, Γ_map,
Quiver.Hom.unop_op, NatIso.op_inv, NatTrans.op_app, SpecΓIdentity_inv_app]
exact congr_arg Quiver.Hom.op (left_triangle X)
right_triangle_components R := by
simp only [Spec.toLocallyRingedSpace_obj, Functor.id_obj, Functor.comp_obj, Functor.rightOp_obj,
Γ_obj, Spec.locallyRingedSpaceObj_toSheafedSpace, Spec.sheafedSpaceObj_carrier,
Spec.sheafedSpaceObj_presheaf, NatIso.op_inv, NatTrans.op_app, op_unop, SpecΓIdentity_inv_app,
Spec.toLocallyRingedSpace_map, Quiver.Hom.unop_op]
exact right_triangle R.unop
/-- `@[simp]`-normal form of `locallyRingedSpaceAdjunction_counit_app`. -/
@[simp]
lemma toSpecΓ_unop (R : CommRingCatᵒᵖ) :
AlgebraicGeometry.toSpecΓ (Opposite.unop R) = toOpen R.unop ⊤ := rfl
/-- `@[simp]`-normal form of `locallyRingedSpaceAdjunction_counit_app'`. -/
@[simp]
lemma toSpecΓ_of (R : Type u) [CommRing R] :
AlgebraicGeometry.toSpecΓ (CommRingCat.of R) = toOpen R ⊤ := rfl
lemma locallyRingedSpaceAdjunction_counit_app (R : CommRingCatᵒᵖ) :
locallyRingedSpaceAdjunction.counit.app R =
(toOpen R.unop ⊤).op := rfl
lemma locallyRingedSpaceAdjunction_counit_app' (R : Type u) [CommRing R] :
locallyRingedSpaceAdjunction.counit.app (op <| CommRingCat.of R) =
(toOpen R ⊤).op := rfl
lemma locallyRingedSpaceAdjunction_homEquiv_apply
{X : LocallyRingedSpace} {R : CommRingCatᵒᵖ}
(f : Γ.rightOp.obj X ⟶ R) :
locallyRingedSpaceAdjunction.homEquiv X R f =
identityToΓSpec.app X ≫ Spec.locallyRingedSpaceMap f.unop := rfl
lemma locallyRingedSpaceAdjunction_homEquiv_apply'
{X : LocallyRingedSpace} {R : Type u} [CommRing R]
(f : CommRingCat.of R ⟶ Γ.obj <| op X) :
locallyRingedSpaceAdjunction.homEquiv X (op <| CommRingCat.of R) (op f) =
identityToΓSpec.app X ≫ Spec.locallyRingedSpaceMap f := rfl
lemma toOpen_comp_locallyRingedSpaceAdjunction_homEquiv_app
{X : LocallyRingedSpace} {R : Type u} [CommRing R]
(f : Γ.rightOp.obj X ⟶ op (CommRingCat.of R)) (U) :
StructureSheaf.toOpen R U.unop ≫
(locallyRingedSpaceAdjunction.homEquiv X (op <| CommRingCat.of R) f).c.app U =
f.unop ≫ X.presheaf.map (homOfLE le_top).op := by
rw [← StructureSheaf.toOpen_res _ _ _ (homOfLE le_top), Category.assoc,
NatTrans.naturality _ (homOfLE (le_top (a := U.unop))).op,
show (toOpen R ⊤) = (toOpen R ⊤).op.unop from rfl,
← locallyRingedSpaceAdjunction_counit_app']
simp_rw [← Γ_map_op]
rw [← Γ.rightOp_map_unop, ← Category.assoc, ← unop_comp, ← Adjunction.homEquiv_counit,
Equiv.symm_apply_apply]
rfl
/-- The adjunction `Γ ⊣ Spec` from `CommRingᵒᵖ` to `Scheme`. -/
def adjunction : Scheme.Γ.rightOp ⊣ Scheme.Spec.{u} where
unit :=
{ app := fun X ↦ ⟨locallyRingedSpaceAdjunction.{u}.unit.app X.toLocallyRingedSpace⟩
naturality := fun _ _ f ↦
Scheme.Hom.ext' (locallyRingedSpaceAdjunction.{u}.unit.naturality f.toLRSHom) }
counit := (NatIso.op Scheme.SpecΓIdentity.{u}).inv
left_triangle_components Y :=
locallyRingedSpaceAdjunction.left_triangle_components Y.toLocallyRingedSpace
right_triangle_components R :=
Scheme.Hom.ext' <| locallyRingedSpaceAdjunction.right_triangle_components R
theorem adjunction_homEquiv_apply {X : Scheme} {R : CommRingCatᵒᵖ}
(f : (op <| Scheme.Γ.obj <| op X) ⟶ R) :
ΓSpec.adjunction.homEquiv X R f = ⟨locallyRingedSpaceAdjunction.homEquiv X.1 R f⟩ := rfl
theorem adjunction_homEquiv_symm_apply {X : Scheme} {R : CommRingCatᵒᵖ}
(f : X ⟶ Scheme.Spec.obj R) :
(ΓSpec.adjunction.homEquiv X R).symm f =
(locallyRingedSpaceAdjunction.homEquiv X.1 R).symm f.toLRSHom := rfl
theorem adjunction_counit_app' {R : CommRingCatᵒᵖ} :
ΓSpec.adjunction.counit.app R = locallyRingedSpaceAdjunction.counit.app R := rfl
@[simp]
theorem adjunction_counit_app {R : CommRingCatᵒᵖ} :
ΓSpec.adjunction.counit.app R = (Scheme.ΓSpecIso (unop R)).inv.op := rfl
/-- The canonical map `X ⟶ Spec Γ(X, ⊤)`. This is the unit of the `Γ-Spec` adjunction. -/
def _root_.AlgebraicGeometry.Scheme.toSpecΓ (X : Scheme.{u}) : X ⟶ Spec Γ(X, ⊤) :=
ΓSpec.adjunction.unit.app X
@[simp]
theorem adjunction_unit_app {X : Scheme} :
ΓSpec.adjunction.unit.app X = X.toSpecΓ := rfl
instance isIso_locallyRingedSpaceAdjunction_counit :
IsIso.{u + 1, u + 1} locallyRingedSpaceAdjunction.counit :=
(NatIso.op SpecΓIdentity).isIso_inv
instance isIso_adjunction_counit : IsIso ΓSpec.adjunction.counit := by
apply (config := { allowSynthFailures := true }) NatIso.isIso_of_isIso_app
intro R
rw [adjunction_counit_app]
infer_instance
end ΓSpec
theorem Scheme.toSpecΓ_apply (X : Scheme.{u}) (x) :
Scheme.toSpecΓ X x = Spec.map (X.presheaf.Γgerm x) (IsLocalRing.closedPoint _) := rfl
@[deprecated (since := "2025-10-17")] alias Scheme.toSpecΓ_base := Scheme.toSpecΓ_apply
@[reassoc]
theorem Scheme.toSpecΓ_naturality {X Y : Scheme.{u}} (f : X ⟶ Y) :
f ≫ Y.toSpecΓ = X.toSpecΓ ≫ Spec.map f.appTop :=
ΓSpec.adjunction.unit.naturality f
@[simp]
theorem Scheme.toSpecΓ_appTop (X : Scheme.{u}) :
X.toSpecΓ.appTop = (Scheme.ΓSpecIso Γ(X, ⊤)).hom := by
have := ΓSpec.adjunction.left_triangle_components X
dsimp at this
rw [← IsIso.eq_comp_inv] at this
simp only [Category.id_comp] at this
rw [← Quiver.Hom.op_inj.eq_iff, this, ← op_inv, IsIso.Iso.inv_inv]
@[simp]
theorem SpecMap_ΓSpecIso_hom (R : CommRingCat.{u}) :
Spec.map ((Scheme.ΓSpecIso R).hom) = (Spec R).toSpecΓ := by
have := ΓSpec.adjunction.right_triangle_components (op R)
dsimp at this
rwa [← IsIso.eq_comp_inv, Category.id_comp, ← Spec.map_inv, IsIso.Iso.inv_inv, eq_comm] at this
@[reassoc (attr := simp)]
theorem SpecMap_ΓSpecIso_inv_toSpecΓ (R : CommRingCat.{u}) :
Spec.map (Scheme.ΓSpecIso R).inv ≫ (Spec R).toSpecΓ = 𝟙 _ := by
rw [← SpecMap_ΓSpecIso_hom, ← Spec.map_comp, Iso.hom_inv_id, Spec.map_id]
@[reassoc (attr := simp)]
theorem toSpecΓ_SpecMap_ΓSpecIso_inv (R : CommRingCat.{u}) :
(Spec R).toSpecΓ ≫ Spec.map (Scheme.ΓSpecIso R).inv = 𝟙 _ := by
rw [← SpecMap_ΓSpecIso_hom, ← Spec.map_comp, Iso.inv_hom_id, Spec.map_id]
lemma Scheme.toSpecΓ_preimage_basicOpen (X : Scheme.{u}) (r : Γ(X, ⊤)) :
X.toSpecΓ ⁻¹ᵁ PrimeSpectrum.basicOpen r = X.basicOpen r := by
rw [← basicOpen_eq_of_affine, Scheme.preimage_basicOpen, ← Scheme.Hom.appTop]
congr
rw [Scheme.toSpecΓ_appTop]
exact Iso.inv_hom_id_apply (C := CommRingCat) _ _
-- Warning: this LHS of this lemma breaks the structure-sheaf abstraction.
@[reassoc (attr := simp)]
theorem toOpen_toSpecΓ_app {X : Scheme.{u}} (U) :
StructureSheaf.toOpen _ _ ≫ X.toSpecΓ.app U =
X.presheaf.map (homOfLE (by exact le_top)).op := by
rw [← StructureSheaf.toOpen_res _ _ _ (homOfLE le_top), Category.assoc,
NatTrans.naturality _ (homOfLE (le_top (a := U))).op]
change (ΓSpec.adjunction.counit.app (Scheme.Γ.rightOp.obj X)).unop ≫
(Scheme.Γ.rightOp.map (ΓSpec.adjunction.unit.app X)).unop ≫ _ = _
rw [← Category.assoc, ← unop_comp, ΓSpec.adjunction.left_triangle_components]
dsimp
exact Category.id_comp _
lemma ΓSpecIso_inv_ΓSpec_adjunction_homEquiv {X : Scheme.{u}} {B : CommRingCat} (φ : B ⟶ Γ(X, ⊤)) :
(Scheme.ΓSpecIso B).inv ≫ ((ΓSpec.adjunction.homEquiv X (op B)) φ.op).appTop = φ := by
simp only [Adjunction.homEquiv_apply, Scheme.Spec_map, Opens.map_top, Scheme.Hom.comp_app]
simp
lemma ΓSpec_adjunction_homEquiv_eq {X : Scheme.{u}} {B : CommRingCat} (φ : B ⟶ Γ(X, ⊤)) :
((ΓSpec.adjunction.homEquiv X (op B)) φ.op).appTop = (Scheme.ΓSpecIso B).hom ≫ φ := by
rw [← Iso.inv_comp_eq, ΓSpecIso_inv_ΓSpec_adjunction_homEquiv]
theorem ΓSpecIso_obj_hom {X : Scheme.{u}} (U : X.Opens) :
(Scheme.ΓSpecIso Γ(X, U)).hom = (Spec.map U.topIso.inv).appTop ≫
U.toScheme.toSpecΓ.appTop ≫ U.topIso.hom := by simp
/-! Immediate consequences of the adjunction. -/
/-- The functor `Spec.toLocallyRingedSpace : CommRingCatᵒᵖ ⥤ LocallyRingedSpace`
is fully faithful. -/
def Spec.fullyFaithfulToLocallyRingedSpace : Spec.toLocallyRingedSpace.FullyFaithful :=
ΓSpec.locallyRingedSpaceAdjunction.fullyFaithfulROfIsIsoCounit
/-- Spec is a full functor. -/
instance : Spec.toLocallyRingedSpace.Full :=
Spec.fullyFaithfulToLocallyRingedSpace.full
/-- Spec is a faithful functor. -/
instance : Spec.toLocallyRingedSpace.Faithful :=
Spec.fullyFaithfulToLocallyRingedSpace.faithful
/-- The functor `Spec : CommRingCatᵒᵖ ⥤ Scheme` is fully faithful. -/
def Spec.fullyFaithful : Scheme.Spec.FullyFaithful :=
ΓSpec.adjunction.fullyFaithfulROfIsIsoCounit
/-- Spec is a full functor. -/
instance Spec.full : Scheme.Spec.Full :=
Spec.fullyFaithful.full
/-- Spec is a faithful functor. -/
instance Spec.faithful : Scheme.Spec.Faithful :=
Spec.fullyFaithful.faithful
section
variable {R S : CommRingCat.{u}} {φ ψ : R ⟶ S} (f : Spec S ⟶ Spec R)
lemma Spec.map_inj : Spec.map φ = Spec.map ψ ↔ φ = ψ := by
rw [iff_comm, ← Quiver.Hom.op_inj.eq_iff, ← Scheme.Spec.map_injective.eq_iff]
rfl
lemma Spec.map_injective {R S : CommRingCat} : Function.Injective (Spec.map : (R ⟶ S) → _) :=
fun _ _ ↦ Spec.map_inj.mp
@[simp]
lemma Spec.map_eq_id {R : CommRingCat} {ϕ : R ⟶ R} : Spec.map ϕ = 𝟙 (Spec R) ↔ ϕ = 𝟙 R := by
simp [← map_inj]
/-- The preimage under Spec. -/
def Spec.preimage : R ⟶ S := (Scheme.Spec.preimage f).unop
@[simp] lemma Spec.map_preimage : Spec.map (Spec.preimage f) = f := Scheme.Spec.map_preimage f
@[simp] lemma Spec.map_preimage_unop (f : Spec R ⟶ Spec S) :
Spec.map (Spec.fullyFaithful.preimage f).unop = f := Spec.fullyFaithful.map_preimage _
variable (φ) in
@[simp] lemma Spec.preimage_map : Spec.preimage (Spec.map φ) = φ :=
Spec.map_injective (Spec.map_preimage (Spec.map φ))
/-- Useful for replacing `f` by `Spec.map φ` everywhere in proofs. -/
lemma Spec.map_surjective {R S : CommRingCat} :
Function.Surjective (Spec.map : (R ⟶ S) → _) := by
intro f
use Spec.preimage f
simp
/-- Spec is fully faithful -/
@[simps]
def Spec.homEquiv {R S : CommRingCat} : (Spec S ⟶ Spec R) ≃ (R ⟶ S) where
toFun := Spec.preimage
invFun := Spec.map
left_inv := Spec.map_preimage
right_inv := Spec.preimage_map
@[simp]
lemma Spec.preimage_id {R : CommRingCat} : Spec.preimage (𝟙 (Spec R)) = 𝟙 R :=
Spec.map_injective (by simp)
@[simp, reassoc]
lemma Spec.preimage_comp {R S T : CommRingCat} (f : Spec R ⟶ Spec S) (g : Spec S ⟶ Spec T) :
Spec.preimage (f ≫ g) = Spec.preimage g ≫ Spec.preimage f :=
Spec.map_injective (by simp)
end
instance : Reflective Spec.toLocallyRingedSpace where
L := Γ.rightOp
adj := ΓSpec.locallyRingedSpaceAdjunction
instance Spec.reflective : Reflective Scheme.Spec where
L := Scheme.Γ.rightOp
adj := ΓSpec.adjunction
instance : LocallyRingedSpace.Γ.IsRightAdjoint :=
ΓSpec.locallyRingedSpaceAdjunction.rightOp.isRightAdjoint
instance : Scheme.Γ.IsRightAdjoint := ΓSpec.adjunction.rightOp.isRightAdjoint
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Properties.lean | import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.RingTheory.LocalProperties.Reduced
/-!
# Basic properties of schemes
We provide some basic properties of schemes
## Main definition
* `AlgebraicGeometry.IsIntegral`: A scheme is integral if it is nontrivial and all nontrivial
components of the structure sheaf are integral domains.
* `AlgebraicGeometry.IsReduced`: A scheme is reduced if all the components of the structure sheaf
are reduced.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
universe u
open TopologicalSpace Opposite CategoryTheory CategoryTheory.Limits TopCat Topology
namespace AlgebraicGeometry
variable (X : Scheme)
instance : T0Space X :=
T0Space.of_open_cover fun x => ⟨_, X.affineCover.covers x,
(X.affineCover.f _).opensRange.2, IsEmbedding.t0Space (Y := PrimeSpectrum _)
(isAffineOpen_opensRange (X.affineCover.f _)).isoSpec.schemeIsoToHomeo.isEmbedding⟩
instance : QuasiSober X := by
apply (config := { allowSynthFailures := true })
quasiSober_of_open_cover (Set.range fun x => Set.range <| (X.affineCover.f x))
· rintro ⟨_, i, rfl⟩; exact (X.affineCover.f i).isOpenEmbedding.isOpen_range
· rintro ⟨_, i, rfl⟩
exact @IsOpenEmbedding.quasiSober _ _ _ _ _
(X.affineCover.f i).isOpenEmbedding.isEmbedding.toHomeomorph.symm.isOpenEmbedding
PrimeSpectrum.quasiSober
· rw [Set.top_eq_univ, Set.sUnion_range, Set.eq_univ_iff_forall]
intro x; exact ⟨_, ⟨_, rfl⟩, X.affineCover.covers x⟩
instance {X : Scheme.{u}} : PrespectralSpace X :=
have (Y : Scheme.{u}) (_ : IsAffine Y) : PrespectralSpace Y :=
.of_isClosedEmbedding (Y := PrimeSpectrum _) _
Y.isoSpec.hom.homeomorph.isClosedEmbedding
have (i : _) : PrespectralSpace (X.affineCover.f i).opensRange.1 :=
this (X.affineCover.f i).opensRange (isAffineOpen_opensRange (X.affineCover.f i))
.of_isOpenCover X.affineCover.isOpenCover_opensRange
/-- A scheme `X` is reduced if all `𝒪ₓ(U)` are reduced. -/
class IsReduced : Prop where
component_reduced : ∀ U, _root_.IsReduced Γ(X, U) := by infer_instance
attribute [instance] IsReduced.component_reduced
theorem isReduced_of_isReduced_stalk [∀ x : X, _root_.IsReduced (X.presheaf.stalk x)] :
IsReduced X := by
refine ⟨fun U => ⟨fun s hs => ?_⟩⟩
apply Presheaf.section_ext X.sheaf U s 0
intro x hx
change (X.sheaf.presheaf.germ U x hx) s = (X.sheaf.presheaf.germ U x hx) 0
rw [RingHom.map_zero]
change X.presheaf.germ U x hx s = 0
exact (hs.map _).eq_zero
instance isReduced_stalk_of_isReduced [IsReduced X] (x : X) :
_root_.IsReduced (X.presheaf.stalk x) := by
constructor
rintro g ⟨n, e⟩
obtain ⟨U, hxU, s, (rfl : (X.presheaf.germ U x hxU) s = g)⟩ := X.presheaf.germ_exist x g
rw [← map_pow, ← map_zero (X.presheaf.germ _ x hxU).hom] at e
obtain ⟨V, hxV, iU, iV, (e' : (X.presheaf.map iU.op) (s ^ n) = (X.presheaf.map iV.op) 0)⟩ :=
X.presheaf.germ_eq x hxU hxU _ 0 e
rw [map_pow, map_zero] at e'
replace e' := (IsNilpotent.mk _ _ e').eq_zero (R := Γ(X, V))
rw [← X.presheaf.germ_res iU x hxV, CommRingCat.comp_apply, e', map_zero]
theorem isReduced_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f]
[IsReduced Y] : IsReduced X := by
constructor
intro U
rw [← f.preimage_image_eq U]
exact isReduced_of_injective (inv <| f.app (f ''ᵁ U)).hom
(asIso <| f.app (f ''ᵁ U) : Γ(Y, f ''ᵁ U) ≅ _).symm.commRingCatIsoToRingEquiv.injective
instance {R : CommRingCat.{u}} [H : _root_.IsReduced R] : IsReduced (Spec R) := by
apply (config := { allowSynthFailures := true }) isReduced_of_isReduced_stalk
intro x; dsimp
have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
dsimp; infer_instance
exact isReduced_of_injective (StructureSheaf.stalkIso R x).hom.hom
(StructureSheaf.stalkIso R x).commRingCatIsoToRingEquiv.injective
theorem affine_isReduced_iff (R : CommRingCat) :
IsReduced (Spec R) ↔ _root_.IsReduced R := by
refine ⟨?_, fun h => inferInstance⟩
intro h
exact isReduced_of_injective (Scheme.ΓSpecIso R).inv.hom
(Scheme.ΓSpecIso R).symm.commRingCatIsoToRingEquiv.injective
theorem isReduced_of_isAffine_isReduced [IsAffine X] [_root_.IsReduced Γ(X, ⊤)] :
IsReduced X :=
isReduced_of_isOpenImmersion X.isoSpec.hom
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immersion `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
@[elab_as_elim]
theorem reduce_to_affine_global (P : ∀ {X : Scheme} (_ : X.Opens), Prop)
{X : Scheme} (U : X.Opens)
(h₁ : ∀ (X : Scheme) (U : X.Opens),
(∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P V) → P U)
(h₂ : ∀ (X Y) (f : X ⟶ Y) [IsOpenImmersion f],
∃ (U : X.Opens) (V : Y.Opens), U = ⊤ ∧ V = f.opensRange ∧ (P U → P V))
(h₃ : ∀ R : CommRingCat, P (X := Spec R) ⊤) : P U := by
apply h₁
intro x
obtain ⟨_, ⟨j, rfl⟩, hx, i⟩ :=
X.affineBasisCover_is_basis.exists_subset_of_mem_open (SetLike.mem_coe.2 x.prop) U.isOpen
let U' : Opens _ := ⟨_, (X.affineBasisCover.f j).isOpenEmbedding.isOpen_range⟩
let i' : U' ⟶ U := homOfLE i
refine ⟨U', hx, i', ?_⟩
obtain ⟨_, _, rfl, rfl, h₂'⟩ := h₂ _ _ (X.affineBasisCover.f j)
apply h₂'
apply h₃
theorem reduce_to_affine_nbhd (P : ∀ (X : Scheme) (_ : X), Prop)
(h₁ : ∀ R x, P (Spec R) x)
(h₂ : ∀ {X Y} (f : X ⟶ Y) [IsOpenImmersion f] (x : X), P X x → P Y (f x)) :
∀ (X : Scheme) (x : X), P X x := by
intro X x
obtain ⟨y, e⟩ := X.affineCover.covers x
convert h₂ (X.affineCover.f (X.affineCover.idx x)) y _
· rw [e]
apply h₁
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : X.Opens}
(s : Γ(X, U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
apply TopCat.Presheaf.section_ext X.sheaf U
intro x hx
change (X.sheaf.presheaf.germ U x hx) s = (X.sheaf.presheaf.germ U x hx) 0
rw [RingHom.map_zero]
induction U using reduce_to_affine_global generalizing hX with
| h₁ X U H =>
obtain ⟨V, hx, i, H⟩ := H ⟨x, hx⟩
specialize H (X.presheaf.map i.op s)
rw [Scheme.basicOpen_res, hs] at H
specialize H (inf_bot_eq _) x hx
rw [← X.sheaf.presheaf.germ_res_apply i x hx s]
exact H
| h₂ X Y f =>
refine ⟨f ⁻¹ᵁ f.opensRange, f.opensRange, by simp, rfl, ?_⟩
rintro H hX s hs _ ⟨x, rfl⟩
haveI := isReduced_of_isOpenImmersion f
specialize H (f.app _ s) _ x ⟨x, rfl⟩
· rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
· have H : (X.presheaf.germ _ x _).hom _ = 0 := H
rw [← Scheme.Hom.germ_stalkMap_apply f ⟨_, _⟩ x] at H
apply_fun inv <| f.stalkMap x at H
rw [← CommRingCat.comp_apply, CategoryTheory.IsIso.hom_inv_id, map_zero] at H
exact H
| h₃ R =>
rw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
replace hs := (hs.map (Scheme.ΓSpecIso R).inv.hom).eq_zero
rw [← CommRingCat.comp_apply, Iso.hom_inv_id, CommRingCat.id_apply] at hs
rw [hs, map_zero]
@[simp]
theorem basicOpen_eq_bot_iff {X : Scheme} [IsReduced X] {U : X.Opens}
(s : Γ(X, U)) : X.basicOpen s = ⊥ ↔ s = 0 := by
refine ⟨eq_zero_of_basicOpen_eq_bot s, ?_⟩
rintro rfl
simp
/-- A scheme `X` is integral if its is nonempty,
and `𝒪ₓ(U)` is an integral domain for each `U ≠ ∅`. -/
class IsIntegral : Prop where
nonempty : Nonempty X := by infer_instance
component_integral : ∀ (U : X.Opens) [Nonempty U], IsDomain Γ(X, U) := by infer_instance
attribute [instance] IsIntegral.component_integral IsIntegral.nonempty
instance [IsIntegral X] : IsDomain Γ(X, ⊤) :=
@IsIntegral.component_integral _ _ _ ⟨Nonempty.some inferInstance, trivial⟩
instance (priority := 900) isReduced_of_isIntegral [IsIntegral X] : IsReduced X := by
constructor
intro U
rcases U.1.eq_empty_or_nonempty with h | h
· have : U = ⊥ := SetLike.ext' h
haveI : Subsingleton Γ(X, U) :=
CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
infer_instance
· haveI : Nonempty U := by simpa
infer_instance
instance Scheme.component_nontrivial (X : Scheme.{u}) (U : X.Opens) [Nonempty U] :
Nontrivial Γ(X, U) :=
LocallyRingedSpace.component_nontrivial (hU := ‹_›)
instance irreducibleSpace_of_isIntegral [IsIntegral X] : IrreducibleSpace X := by
by_contra H
replace H : ¬IsPreirreducible (⊤ : Set X) := fun h =>
H { toPreirreducibleSpace := ⟨h⟩
toNonempty := inferInstance }
simp_rw [isPreirreducible_iff_isClosed_union_isClosed, not_forall, not_or] at H
rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
rw [Set.not_top_subset] at h₂ h₃
haveI : Nonempty (⟨Sᶜ, hS.1⟩ : X.Opens) := ⟨⟨_, h₂.choose_spec⟩⟩
haveI : Nonempty (⟨Tᶜ, hT.1⟩ : X.Opens) := ⟨⟨_, h₃.choose_spec⟩⟩
haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : X.Opens) := ⟨⟨_, Or.inl h₂.choose_spec⟩⟩
let e : Γ(X, _) ≅ CommRingCat.of _ :=
(X.sheaf.isProductOfDisjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ ?_).conePointUniqueUpToIso
(CommRingCat.prodFanIsLimit _ _)
· have : IsDomain (Γ(X, ⟨Sᶜ, hS.1⟩) × Γ(X, ⟨Tᶜ, hT.1⟩)) :=
e.symm.commRingCatIsoToRingEquiv.toMulEquiv.isDomain _
exact false_of_nontrivial_of_product_domain Γ(X, ⟨Sᶜ, hS.1⟩) Γ(X, ⟨Tᶜ, hT.1⟩)
· ext x
constructor
· rintro ⟨hS, hT⟩
rcases h₁ (show x ∈ ⊤ by trivial) with h | h
exacts [hS h, hT h]
· simp
theorem isIntegral_of_irreducibleSpace_of_isReduced [IsReduced X] [H : IrreducibleSpace X] :
IsIntegral X := by
constructor; · infer_instance
intro U hU
haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
have : NoZeroDivisors
(X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
refine ⟨fun {a b} e => ?_⟩
simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
by_contra! h
obtain ⟨x, ⟨hxU, hx₁⟩, _, hx₂⟩ :=
nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
replace e := congr_arg (X.presheaf.germ U x hxU) e
rw [RingHom.map_mul, RingHom.map_zero] at e
refine zero_ne_one' (X.presheaf.stalk x) (isUnit_zero_iff.1 ?_)
convert hx₁.mul hx₂
exact e.symm
exact NoZeroDivisors.to_isDomain _
theorem isIntegral_iff_irreducibleSpace_and_isReduced :
IsIntegral X ↔ IrreducibleSpace X ∧ IsReduced X :=
⟨fun _ => ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ =>
isIntegral_of_irreducibleSpace_of_isReduced X⟩
theorem isIntegral_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f]
[IsIntegral Y] [Nonempty X] : IsIntegral X := by
constructor; · infer_instance
intro U hU
rw [← f.preimage_image_eq U]
have : IsDomain Γ(Y, f ''ᵁ U) := by
apply (config := { allowSynthFailures := true }) IsIntegral.component_integral
exact ⟨⟨_, _, hU.some.prop, rfl⟩⟩
exact (asIso <| f.app (f ''ᵁ U) :
Γ(Y, f ''ᵁ U) ≅ _).symm.commRingCatIsoToRingEquiv.toMulEquiv.isDomain _
instance {R : CommRingCat} [IsDomain R] : IrreducibleSpace (Spec R) := by
convert PrimeSpectrum.irreducibleSpace (R := R)
instance {R : CommRingCat} [IsDomain R] : IsIntegral (Spec R) :=
isIntegral_of_irreducibleSpace_of_isReduced _
theorem affine_isIntegral_iff (R : CommRingCat) :
IsIntegral (Spec R) ↔ IsDomain R :=
⟨fun _ => MulEquiv.isDomain Γ(Spec R, ⊤)
(Scheme.ΓSpecIso R).symm.commRingCatIsoToRingEquiv.toMulEquiv, fun _ => inferInstance⟩
theorem isIntegral_of_isAffine_of_isDomain [IsAffine X] [Nonempty X] [IsDomain Γ(X, ⊤)] :
IsIntegral X :=
isIntegral_of_isOpenImmersion X.isoSpec.hom
theorem map_injective_of_isIntegral [IsIntegral X] {U V : X.Opens} (i : U ⟶ V)
[H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
rw [injective_iff_map_eq_zero]
intro x hx
rw [← basicOpen_eq_bot_iff] at hx ⊢
rw [Scheme.basicOpen_res] at hx
revert hx
contrapose!
simp_rw [Ne, ← Opens.not_nonempty_iff_eq_bot, Classical.not_not]
apply nonempty_preirreducible_inter U.isOpen (RingedSpace.basicOpen _ _).isOpen
simpa using H
noncomputable
instance [IsIntegral X] : OrderTop X where
top := genericPoint X
le_top a := genericPoint_specializes a
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Pullbacks.lean | import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Gluing
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.CategoryTheory.Limits.Shapes.Diagonal
import Mathlib.CategoryTheory.Monoidal.Cartesian.Over
/-!
# Fibred products of schemes
In this file we construct the fibred product of schemes via gluing.
We roughly follow [har77] Theorem 3.3.
In particular, the main construction is to show that for an open cover `{ Uᵢ }` of `X`, if there
exist fibred products `Uᵢ ×[Z] Y` for each `i`, then there exists a fibred product `X ×[Z] Y`.
Then, for constructing the fibred product for arbitrary schemes `X, Y, Z`, we can use the
construction to reduce to the case where `X, Y, Z` are all affine, where fibred products are
constructed via tensor products.
-/
universe u v w
noncomputable section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry
namespace AlgebraicGeometry.Scheme
namespace Pullback
variable {X Y Z : Scheme.{u}} (𝒰 : OpenCover.{u} X) (f : X ⟶ Z) (g : Y ⟶ Z)
variable [∀ i, HasPullback (𝒰.f i ≫ f) g]
/-- The intersection of `Uᵢ ×[Z] Y` and `Uⱼ ×[Z] Y` is given by (Uᵢ ×[Z] Y) ×[X] Uⱼ -/
def v (i j : 𝒰.I₀) : Scheme :=
pullback ((pullback.fst (𝒰.f i ≫ f) g) ≫ 𝒰.f i) (𝒰.f j)
/-- The canonical transition map `(Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ` given by the fact
that pullbacks are associative and symmetric. -/
def t (i j : 𝒰.I₀) : v 𝒰 f g i j ⟶ v 𝒰 f g j i := by
have : HasPullback (pullback.snd _ _ ≫ 𝒰.f i ≫ f) g :=
hasPullback_assoc_symm (𝒰.f j) (𝒰.f i) (𝒰.f i ≫ f) g
have : HasPullback (pullback.snd _ _ ≫ 𝒰.f j ≫ f) g :=
hasPullback_assoc_symm (𝒰.f i) (𝒰.f j) (𝒰.f j ≫ f) g
refine (pullbackSymmetry ..).hom ≫ (pullbackAssoc ..).inv ≫ ?_
refine ?_ ≫ (pullbackAssoc ..).hom ≫ (pullbackSymmetry ..).hom
refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_
· rw [pullbackSymmetry_hom_comp_snd_assoc, pullback.condition_assoc, Category.comp_id]
· rw [Category.comp_id, Category.id_comp]
@[simp, reassoc]
theorem t_fst_fst (i j : 𝒰.I₀) : t 𝒰 f g i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.snd _ _ := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_fst,
pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_inv_fst_fst,
pullbackSymmetry_hom_comp_fst]
@[simp, reassoc]
theorem t_fst_snd (i j : 𝒰.I₀) :
t 𝒰 f g i j ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_snd,
pullback.lift_snd, Category.comp_id, pullbackAssoc_inv_snd, pullbackSymmetry_hom_comp_snd_assoc]
@[simp, reassoc]
theorem t_snd (i j : 𝒰.I₀) : t 𝒰 f g i j ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_hom_fst,
pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_fst, pullbackAssoc_inv_fst_snd,
pullbackSymmetry_hom_comp_snd_assoc]
theorem t_id (i : 𝒰.I₀) : t 𝒰 f g i i = 𝟙 _ := by
apply pullback.hom_ext <;> rw [Category.id_comp]
· apply pullback.hom_ext
· rw [← cancel_mono (𝒰.f i)]; simp only [pullback.condition, Category.assoc, t_fst_fst]
· simp only [Category.assoc, t_fst_snd]
· rw [← cancel_mono (𝒰.f i)]; simp only [pullback.condition, t_snd, Category.assoc]
/-- The inclusion map of `V i j = (Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ Uᵢ ×[Z] Y` -/
abbrev fV (i j : 𝒰.I₀) : v 𝒰 f g i j ⟶ pullback (𝒰.f i ≫ f) g :=
pullback.fst _ _
/-- The map `((Xᵢ ×[Z] Y) ×[X] Xⱼ) ×[Xᵢ ×[Z] Y] ((Xᵢ ×[Z] Y) ×[X] Xₖ)` ⟶
`((Xⱼ ×[Z] Y) ×[X] Xₖ) ×[Xⱼ ×[Z] Y] ((Xⱼ ×[Z] Y) ×[X] Xᵢ)` needed for gluing -/
def t' (i j k : 𝒰.I₀) :
pullback (fV 𝒰 f g i j) (fV 𝒰 f g i k) ⟶ pullback (fV 𝒰 f g j k) (fV 𝒰 f g j i) := by
refine (pullbackRightPullbackFstIso ..).hom ≫ ?_
refine ?_ ≫ (pullbackSymmetry _ _).hom
refine ?_ ≫ (pullbackRightPullbackFstIso ..).inv
refine pullback.map _ _ _ _ (t 𝒰 f g i j) (𝟙 _) (𝟙 _) ?_ ?_
· simp_rw [Category.comp_id, t_fst_fst_assoc, ← pullback.condition]
· rw [Category.comp_id, Category.id_comp]
@[simp, reassoc]
theorem t'_fst_fst_fst (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,
pullbackRightPullbackFstIso_hom_fst_assoc]
@[simp, reassoc]
theorem t'_fst_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
@[simp, reassoc]
theorem t'_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_snd, pullback.lift_snd, Category.comp_id,
pullbackRightPullbackFstIso_hom_snd]
@[simp, reassoc]
theorem t'_snd_fst_fst (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,
pullbackRightPullbackFstIso_hom_fst_assoc]
@[simp, reassoc]
theorem t'_snd_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
@[simp, reassoc]
theorem t'_snd_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
theorem cocycle_fst_fst_fst (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫
pullback.fst _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by
simp only [t'_fst_fst_fst, t'_fst_snd, t'_snd_snd]
theorem cocycle_fst_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫
pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t'_fst_fst_snd]
theorem cocycle_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [t'_fst_snd, t'_snd_snd, t'_fst_fst_fst]
theorem cocycle_snd_fst_fst (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫
pullback.fst _ _ = pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by
simp only [pullback.condition_assoc, t'_snd_fst_fst, t'_fst_snd, t'_snd_snd]
theorem cocycle_snd_fst_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫
pullback.snd _ _ = pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by
simp only [pullback.condition_assoc, t'_snd_fst_snd]
theorem cocycle_snd_snd (i j k : 𝒰.I₀) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
simp only [t'_snd_snd, t'_fst_fst_fst, t'_fst_snd]
-- `by tidy` should solve it, but it times out.
theorem cocycle (i j k : 𝒰.I₀) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j = 𝟙 _ := by
apply pullback.hom_ext <;> rw [Category.id_comp]
· apply pullback.hom_ext
· apply pullback.hom_ext
· simp_rw [Category.assoc, cocycle_fst_fst_fst 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_fst_fst_snd 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_fst_snd 𝒰 f g i j k]
· apply pullback.hom_ext
· apply pullback.hom_ext
· simp_rw [Category.assoc, cocycle_snd_fst_fst 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_snd_fst_snd 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_snd_snd 𝒰 f g i j k]
/-- Given `Uᵢ ×[Z] Y`, this is the glued fibred product `X ×[Z] Y`. -/
@[simps U V f t t', simps -isSimp J]
def gluing : Scheme.GlueData.{u} where
J := 𝒰.I₀
U i := pullback (𝒰.f i ≫ f) g
V := fun ⟨i, j⟩ => v 𝒰 f g i j
-- `p⁻¹(Uᵢ ∩ Uⱼ)` where `p : Uᵢ ×[Z] Y ⟶ Uᵢ ⟶ X`.
f _ _ := pullback.fst _ _
f_id _ := inferInstance
f_open := inferInstance
t i j := t 𝒰 f g i j
t_id i := t_id 𝒰 f g i
t' i j k := t' 𝒰 f g i j k
t_fac i j k := by
apply pullback.hom_ext
on_goal 1 => apply pullback.hom_ext
all_goals
simp only [t'_snd_fst_fst, t'_snd_fst_snd, t'_snd_snd, t_fst_fst, t_fst_snd, t_snd,
Category.assoc]
cocycle i j k := cocycle 𝒰 f g i j k
@[simp]
lemma gluing_ι (j : 𝒰.I₀) :
(gluing 𝒰 f g).ι j = Multicoequalizer.π (gluing 𝒰 f g).diagram j := rfl
/-- The first projection from the glued scheme into `X`. -/
def p1 : (gluing 𝒰 f g).glued ⟶ X := by
apply Multicoequalizer.desc (gluing 𝒰 f g).diagram _ fun i ↦ pullback.fst _ _ ≫ 𝒰.f i
simp [t_fst_fst_assoc, ← pullback.condition]
/-- The second projection from the glued scheme into `Y`. -/
def p2 : (gluing 𝒰 f g).glued ⟶ Y := by
apply Multicoequalizer.desc _ _ fun i ↦ pullback.snd _ _
simp [t_fst_snd]
theorem p_comm : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g := by
apply Multicoequalizer.hom_ext
simp [p1, p2, pullback.condition]
variable (s : PullbackCone f g)
/-- (Implementation)
The canonical map `(s.X ×[X] Uᵢ) ×[s.X] (s.X ×[X] Uⱼ) ⟶ (Uᵢ ×[Z] Y) ×[X] Uⱼ`
This is used in `gluedLift`. -/
def gluedLiftPullbackMap (i j : 𝒰.I₀) :
pullback ((𝒰.pullback₁ s.fst).f i) ((𝒰.pullback₁ s.fst).f j) ⟶
(gluing 𝒰 f g).V ⟨i, j⟩ := by
refine (pullbackRightPullbackFstIso _ _ _).hom ≫ ?_
refine pullback.map _ _ _ _ ?_ (𝟙 _) (𝟙 _) ?_ ?_
· exact (pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition
· simpa using pullback.condition
· simp only [Category.comp_id, Category.id_comp]
@[reassoc]
theorem gluedLiftPullbackMap_fst (i j : 𝒰.I₀) :
gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.fst _ _ =
pullback.fst _ _ ≫
(pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition := by
simp [gluedLiftPullbackMap]
@[reassoc]
theorem gluedLiftPullbackMap_snd (i j : 𝒰.I₀) :
gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.snd _ _ := by
simp [gluedLiftPullbackMap]
/-- The lifted map `s.X ⟶ (gluing 𝒰 f g).glued` in order to show that `(gluing 𝒰 f g).glued` is
indeed the pullback.
Given a pullback cone `s`, we have the maps `s.fst ⁻¹' Uᵢ ⟶ Uᵢ` and
`s.fst ⁻¹' Uᵢ ⟶ s.X ⟶ Y` that we may lift to a map `s.fst ⁻¹' Uᵢ ⟶ Uᵢ ×[Z] Y`.
to glue these into a map `s.X ⟶ Uᵢ ×[Z] Y`, we need to show that the maps agree on
`(s.fst ⁻¹' Uᵢ) ×[s.X] (s.fst ⁻¹' Uⱼ) ⟶ Uᵢ ×[Z] Y`. This is achieved by showing that both of these
maps factors through `gluedLiftPullbackMap`.
-/
def gluedLift : s.pt ⟶ (gluing 𝒰 f g).glued := by
fapply Cover.glueMorphisms (𝒰.pullback₁ s.fst)
· exact fun i ↦ (pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition ≫ (gluing 𝒰 f g).ι i
intro i j
rw [← gluedLiftPullbackMap_fst_assoc, ← gluing_f, ← (gluing 𝒰 f g).glue_condition i j,
gluing_t, gluing_f]
simp_rw [← Category.assoc]
congr 1
apply pullback.hom_ext <;> simp_rw [Category.assoc]
· rw [t_fst_fst, gluedLiftPullbackMap_snd]
congr 1
rw [← Iso.inv_comp_eq, pullbackSymmetry_inv_comp_snd, pullback.lift_fst, Category.comp_id]
· rw [t_fst_snd, gluedLiftPullbackMap_fst_assoc, pullback.lift_snd, pullback.lift_snd]
simp_rw [pullbackSymmetry_hom_comp_snd_assoc]
exact pullback.condition_assoc _
theorem gluedLift_p1 : gluedLift 𝒰 f g s ≫ p1 𝒰 f g = s.fst := by
rw [← cancel_epi (Cover.fromGlued <| 𝒰.pullback₁ s.fst)]
apply Multicoequalizer.hom_ext
intro b
simp_rw [Cover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc]
simp_rw [Cover.ι_glueMorphisms (𝒰.pullback₁ s.fst)]
simp [p1, pullback.condition]
theorem gluedLift_p2 : gluedLift 𝒰 f g s ≫ p2 𝒰 f g = s.snd := by
rw [← cancel_epi (Cover.fromGlued <| 𝒰.pullback₁ s.fst)]
apply Multicoequalizer.hom_ext
intro b
simp_rw [Cover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc]
simp_rw [(Cover.ι_glueMorphisms <| 𝒰.pullback₁ s.fst)]
simp [p2]
/-- (Implementation)
The canonical map `(W ×[X] Uᵢ) ×[W] (Uⱼ ×[Z] Y) ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ = V j i` where `W` is
the glued fibred product.
This is used in `lift_comp_ι`. -/
def pullbackFstιToV (i j : 𝒰.I₀) :
pullback (pullback.fst (p1 𝒰 f g) (𝒰.f i)) ((gluing 𝒰 f g).ι j) ⟶
v 𝒰 f g j i :=
(pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.f i) _).hom ≫
(pullback.congrHom (Multicoequalizer.π_desc ..) rfl).hom
@[simp, reassoc]
theorem pullbackFstιToV_fst (i j : 𝒰.I₀) :
pullbackFstιToV 𝒰 f g i j ≫ pullback.fst _ _ = pullback.snd _ _ := by
simp [pullbackFstιToV, p1]
@[simp, reassoc]
theorem pullbackFstιToV_snd (i j : 𝒰.I₀) :
pullbackFstιToV 𝒰 f g i j ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by
simp [pullbackFstιToV, p1]
/-- We show that the map `W ×[X] Uᵢ ⟶ Uᵢ ×[Z] Y ⟶ W` is the first projection, where the
first map is given by the lift of `W ×[X] Uᵢ ⟶ Uᵢ` and `W ×[X] Uᵢ ⟶ W ⟶ Y`.
It suffices to show that the two map agrees when restricted onto `Uⱼ ×[Z] Y`. In this case,
both maps factor through `V j i` via `pullback_fst_ι_to_V` -/
theorem lift_comp_ι (i : 𝒰.I₀) :
pullback.lift (pullback.snd _ _) (pullback.fst _ _ ≫ p2 𝒰 f g)
(by rw [← pullback.condition_assoc, Category.assoc, p_comm]) ≫
(gluing 𝒰 f g).ι i =
(pullback.fst _ _ : pullback (p1 𝒰 f g) (𝒰.f i) ⟶ _) := by
apply Cover.hom_ext ((gluing 𝒰 f g).openCover.pullback₁ (pullback.fst _ _))
intro j
dsimp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_X, PreZeroHypercover.pullback₁_f]
trans pullbackFstιToV 𝒰 f g i j ≫ fV 𝒰 f g j i ≫ (gluing 𝒰 f g).ι _
· rw [← show _ = fV 𝒰 f g j i ≫ _ from (gluing 𝒰 f g).glue_condition j i]
simp_rw [← Category.assoc]
congr 1
rw [gluing_f, gluing_t]
apply pullback.hom_ext <;> simp_rw [Category.assoc]
· simp_rw [t_fst_fst, pullback.lift_fst, pullbackFstιToV_snd, GlueData.openCover_f]
· simp_rw [t_fst_snd, pullback.lift_snd, pullbackFstιToV_fst_assoc, pullback.condition_assoc,
GlueData.openCover_f, p2]
simp
· rw [pullback.condition, ← Category.assoc]
simp_rw [pullbackFstιToV_fst, GlueData.openCover_f]
/-- The canonical isomorphism between `W ×[X] Uᵢ` and `Uᵢ ×[X] Y`. That is, the preimage of `Uᵢ` in
`W` along `p1` is indeed `Uᵢ ×[X] Y`. -/
def pullbackP1Iso (i : 𝒰.I₀) : pullback (p1 𝒰 f g) (𝒰.f i) ≅ pullback (𝒰.f i ≫ f) g := by
fconstructor
· exact
pullback.lift (pullback.snd _ _) (pullback.fst _ _ ≫ p2 𝒰 f g)
(by rw [← pullback.condition_assoc, Category.assoc, p_comm])
· exact pullback.lift ((gluing 𝒰 f g).ι i) (pullback.fst _ _)
(by rw [gluing_ι, p1, Multicoequalizer.π_desc])
· apply pullback.hom_ext
· simpa using lift_comp_ι 𝒰 f g i
· simp_rw [Category.assoc, pullback.lift_snd, pullback.lift_fst, Category.id_comp]
· apply pullback.hom_ext
· simp_rw [Category.assoc, pullback.lift_fst, pullback.lift_snd, Category.id_comp]
· simp [p2]
@[simp, reassoc]
theorem pullbackP1Iso_hom_fst (i : 𝒰.I₀) :
(pullbackP1Iso 𝒰 f g i).hom ≫ pullback.fst _ _ = pullback.snd _ _ := by
simp_rw [pullbackP1Iso, pullback.lift_fst]
@[simp, reassoc]
theorem pullbackP1Iso_hom_snd (i : 𝒰.I₀) :
(pullbackP1Iso 𝒰 f g i).hom ≫ pullback.snd _ _ = pullback.fst _ _ ≫ p2 𝒰 f g := by
simp_rw [pullbackP1Iso, pullback.lift_snd]
@[simp, reassoc]
theorem pullbackP1Iso_inv_fst (i : 𝒰.I₀) :
(pullbackP1Iso 𝒰 f g i).inv ≫ pullback.fst _ _ = (gluing 𝒰 f g).ι i := by
simp_rw [pullbackP1Iso, pullback.lift_fst]
@[simp, reassoc]
theorem pullbackP1Iso_inv_snd (i : 𝒰.I₀) :
(pullbackP1Iso 𝒰 f g i).inv ≫ pullback.snd _ _ = pullback.fst _ _ := by
simp_rw [pullbackP1Iso, pullback.lift_snd]
@[simp, reassoc]
theorem pullbackP1Iso_hom_ι (i : 𝒰.I₀) :
(pullbackP1Iso 𝒰 f g i).hom ≫ Multicoequalizer.π (gluing 𝒰 f g).diagram i =
pullback.fst _ _ := by
rw [← gluing_ι, ← pullbackP1Iso_inv_fst, Iso.hom_inv_id_assoc]
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
apply PullbackCone.isLimitAux'
intro s
refine ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, ?_⟩
intro m h₁ h₂
simp_rw [PullbackCone.mk_pt, PullbackCone.mk_π_app] at h₁ h₂
apply Cover.hom_ext <| 𝒰.pullback₁ s.fst
intro i
rw [gluedLift, (Cover.ι_glueMorphisms <| 𝒰.pullback₁ s.fst)]
dsimp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_X, PullbackCone.mk_pt, PreZeroHypercover.pullback₁_f, gluing_ι]
rw [← cancel_epi
(pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.f i) m ≪≫ pullback.congrHom h₁ rfl).hom,
Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
conv_lhs => rhs; rw [← pullbackP1Iso_hom_ι]
simp_rw [← Category.assoc]
congr 1
apply pullback.hom_ext
· simp_rw [Category.assoc, pullbackP1Iso_hom_fst, pullback.lift_fst, Category.comp_id,
pullbackSymmetry_hom_comp_fst, pullback.lift_snd, Category.comp_id,
pullbackRightPullbackFstIso_hom_snd]
· simp_rw [Category.assoc, pullbackP1Iso_hom_snd, pullback.lift_snd,
pullbackSymmetry_hom_comp_snd_assoc, pullback.lift_fst_assoc, Category.comp_id,
pullbackRightPullbackFstIso_hom_fst_assoc, ← pullback.condition_assoc, h₂]
include 𝒰 in
theorem hasPullback_of_cover : HasPullback f g :=
⟨⟨⟨_, gluedIsLimit 𝒰 f g⟩⟩⟩
instance affine_hasPullback {A B C : CommRingCat}
(f : Spec A ⟶ Spec C)
(g : Spec B ⟶ Spec C) : HasPullback f g := by
rw [← Scheme.Spec.map_preimage f, ← Scheme.Spec.map_preimage g]
exact ⟨⟨⟨_, isLimitOfHasPullbackOfPreservesLimit
Scheme.Spec (Scheme.Spec.preimage f) (Scheme.Spec.preimage g)⟩⟩⟩
theorem affine_affine_hasPullback {B C : CommRingCat} {X : Scheme}
(f : X ⟶ Spec C) (g : Spec B ⟶ Spec C) :
HasPullback f g :=
hasPullback_of_cover X.affineCover f g
instance base_affine_hasPullback {C : CommRingCat} {X Y : Scheme} (f : X ⟶ Spec C)
(g : Y ⟶ Spec C) : HasPullback f g :=
@hasPullback_symmetry _ _ _ _ _ _ _
(@hasPullback_of_cover _ _ _ Y.affineCover g f fun _ =>
@hasPullback_symmetry _ _ _ _ _ _ _ <| affine_affine_hasPullback _ _)
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
(i : Z.affineCover.I₀) : HasPullback ((Z.affineCover.pullback₁ f).f i ≫ f) g := by
simpa [pullback.condition] using
hasPullback_assoc_symm f (Z.affineCover.f i) (Z.affineCover.f i) g
instance {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) : HasPullback f g :=
hasPullback_of_cover (Z.affineCover.pullback₁ f) f g
instance : HasPullbacks Scheme :=
hasPullbacks_of_hasLimit_cospan _
instance isAffine_of_isAffine_isAffine_isAffine {X Y Z : Scheme}
(f : X ⟶ Z) (g : Y ⟶ Z) [IsAffine X] [IsAffine Y] [IsAffine Z] :
IsAffine (pullback f g) :=
.of_isIso
(pullback.map f g (Spec.map (Γ.map f.op)) (Spec.map (Γ.map g.op))
X.toSpecΓ Y.toSpecΓ Z.toSpecΓ
(Scheme.toSpecΓ_naturality f) (Scheme.toSpecΓ_naturality g) ≫
(PreservesPullback.iso Scheme.Spec _ _).inv)
-- The converse is also true. See `Scheme.isEmpty_pullback_iff`.
theorem _root_.AlgebraicGeometry.Scheme.isEmpty_pullback
{X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S)
(H : Disjoint (Set.range f) (Set.range g)) : IsEmpty ↑(Limits.pullback f g) :=
isEmpty_of_commSq (IsPullback.of_hasPullback f g).toCommSq H
/-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/
@[simps! I₀ X f]
def openCoverOfLeft (𝒰 : OpenCover.{v} X) (f : X ⟶ Z) (g : Y ⟶ Z) :
OpenCover (pullback f g) where
I₀ := 𝒰.I₀
X i := pullback (𝒰.f i ≫ f) g
f i := pullback.map (𝒰.f i ≫ f) g f g (𝒰.f i) (𝟙 Y) (𝟙 Z) (by simp) (by simp)
mem₀ := by
rw [ofArrows_mem_precoverage_iff]
refine ⟨fun x ↦ ?_, fun i ↦ ?_⟩
· letI 𝒱 := ((gluing 𝒰.ulift f g).openCover.pushforwardIso
(limit.isoLimitCone ⟨_, gluedIsLimit 𝒰.ulift f g⟩).inv).copy
𝒰.ulift.I₀ (fun i => pullback (𝒰.ulift.f i ≫ f) g)
(fun i => pullback.map _ _ _ _ (𝒰.ulift.f i) (𝟙 _) (𝟙 _) (Category.comp_id _) (by simp))
(Equiv.refl 𝒰.ulift.I₀) (fun _ => Iso.refl _) fun i ↦ by
simp_rw [Cover.pushforwardIso_I₀, Cover.pushforwardIso_f, GlueData.openCover_f,
GlueData.openCover_I₀, gluing_J]
exact pullback.hom_ext (by simp [p1]) (by simp [p2])
obtain ⟨i, x, rfl⟩ := 𝒱.exists_eq x
exact ⟨_, x, rfl⟩
· dsimp
have : pullback.map (𝒰.f i ≫ f) g f g (𝒰.f i) (𝟙 Y) (𝟙 Z) (by simp) (by simp) =
(pullbackSymmetry _ _).hom ≫ (pullbackLeftPullbackSndIso _ _ _).inv ≫
pullback.fst _ _ ≫ (pullbackSymmetry _ _).hom := by aesop
rw [this]
infer_instance
/-- Given an open cover `{ Yᵢ }` of `Y`, then `X ×[Z] Y` is covered by `X ×[Z] Yᵢ`. -/
@[simps! I₀ X f]
def openCoverOfRight (𝒰 : OpenCover.{v} Y) (f : X ⟶ Z) (g : Y ⟶ Z) :
OpenCover.{v} (pullback f g) := by
fapply
((openCoverOfLeft 𝒰 g f).pushforwardIso (pullbackSymmetry _ _).hom).copy 𝒰.I₀
(fun i => pullback f (𝒰.f i ≫ g))
(fun i => pullback.map _ _ _ _ (𝟙 _) (𝒰.f i) (𝟙 _) (by simp) (Category.comp_id _))
(Equiv.refl _) fun i => pullbackSymmetry _ _
intro i
dsimp
apply pullback.hom_ext <;> simp
/-- Given an open cover `{ Xᵢ }` of `X` and an open cover `{ Yⱼ }` of `Y`, then
`X ×[Z] Y` is covered by `Xᵢ ×[Z] Yⱼ`. -/
@[simps! I₀ X f]
def openCoverOfLeftRight (𝒰X : OpenCover.{v} X) (𝒰Y : OpenCover.{w} Y) (f : X ⟶ Z) (g : Y ⟶ Z) :
OpenCover.{max v w} (pullback f g) := by
fapply
Cover.copy ((openCoverOfLeft 𝒰X f g).bind fun x => openCoverOfRight 𝒰Y (𝒰X.f x ≫ f) g)
(𝒰X.I₀ × 𝒰Y.I₀) (fun ij => pullback (𝒰X.f ij.1 ≫ f) (𝒰Y.f ij.2 ≫ g))
(fun ij =>
pullback.map _ _ _ _ (𝒰X.f ij.1) (𝒰Y.f ij.2) (𝟙 _) (Category.comp_id _)
(Category.comp_id _))
(Equiv.sigmaEquivProd _ _).symm fun _ => Iso.refl _
rintro ⟨i, j⟩
apply pullback.hom_ext <;> simp
/-- (Implementation). Use `openCoverOfBase` instead. -/
@[simps! f]
def openCoverOfBase' (𝒰 : OpenCover.{v} Z) (f : X ⟶ Z) (g : Y ⟶ Z) :
OpenCover.{v} (pullback f g) := by
apply (openCoverOfLeft (𝒰.pullback₁ f) f g).bind
intro i
haveI := ((IsPullback.of_hasPullback (pullback.snd g (𝒰.f i))
(pullback.snd f (𝒰.f i))).paste_horiz (IsPullback.of_hasPullback _ _)).flip
refine
@coverOfIsIso _ _ _ _ _
(f := (pullbackSymmetry (pullback.snd f (𝒰.f i)) (pullback.snd g (𝒰.f i))).hom ≫
(limit.isoLimitCone ⟨_, this.isLimit⟩).inv ≫
pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) ?_ ?_) inferInstance
· simp [← pullback.condition]
· simp only [Category.comp_id, Category.id_comp]
/-- Given an open cover `{ Zᵢ }` of `Z`, then `X ×[Z] Y` is covered by `Xᵢ ×[Zᵢ] Yᵢ`, where
`Xᵢ = X ×[Z] Zᵢ` and `Yᵢ = Y ×[Z] Zᵢ` is the preimage of `Zᵢ` in `X` and `Y`. -/
@[simps! I₀ X f]
def openCoverOfBase (𝒰 : OpenCover.{v} Z) (f : X ⟶ Z) (g : Y ⟶ Z) :
OpenCover.{v} (pullback f g) := by
apply
(openCoverOfBase' 𝒰 f g).copy 𝒰.I₀
(fun i =>
pullback (pullback.snd _ _ : pullback f (𝒰.f i) ⟶ _)
(pullback.snd _ _ : pullback g (𝒰.f i) ⟶ _))
(fun i =>
pullback.map _ _ _ _ (pullback.fst _ _) (pullback.fst _ _) (𝒰.f i)
pullback.condition.symm pullback.condition.symm)
((Equiv.prodPUnit 𝒰.I₀).symm.trans (Equiv.sigmaEquivProd 𝒰.I₀ PUnit).symm) fun _ => Iso.refl _
intro i
rw [Iso.refl_hom, Category.id_comp, openCoverOfBase'_f]
ext : 1 <;>
· simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Equiv.trans_apply,
Equiv.prodPUnit_symm_apply, Category.assoc, limit.lift_π_assoc, cospan_left, Category.comp_id,
limit.isoLimitCone_inv_π_assoc, PullbackCone.π_app_left, IsPullback.cone_fst,
pullbackSymmetry_hom_comp_snd_assoc, limit.isoLimitCone_inv_π,
PullbackCone.π_app_right, IsPullback.cone_snd, pullbackSymmetry_hom_comp_fst_assoc]
rfl
variable (f : X ⟶ Y) (𝒰 : OpenCover.{u} Y) (𝒱 : ∀ i, OpenCover.{w} ((𝒰.pullback₁ f).X i))
/--
Given `𝒰 i` covering `Y` and `𝒱 i j` covering `𝒰 i`, this is the open cover
`𝒱 i j₁ ×[𝒰 i] 𝒱 i j₂` ranging over all `i`, `j₁`, `j₂`.
-/
noncomputable
def diagonalCover : (pullback.diagonalObj f).OpenCover :=
(openCoverOfBase 𝒰 f f).bind
fun i ↦ openCoverOfLeftRight (𝒱 i) (𝒱 i) (𝒰.pullbackHom _ _) (𝒰.pullbackHom _ _)
/-- The image of `𝒱 i j₁ ×[𝒰 i] 𝒱 i j₂` in `diagonalCover` with `j₁ = j₂` -/
noncomputable
def diagonalCoverDiagonalRange : (pullback.diagonalObj f).Opens :=
⨆ i : Σ i, (𝒱 i).I₀, ((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange
lemma diagonalCover_map (I) : (diagonalCover f 𝒰 𝒱).f I =
pullback.map _ _ _ _
((𝒱 I.fst).f _ ≫ pullback.fst _ _) ((𝒱 I.fst).f _ ≫ pullback.fst _ _) (𝒰.f _)
(by simp)
(by simp) := by
cases I
ext1 <;> simp [diagonalCover, Cover.pullbackHom]
/-- The restriction of the diagonal `X ⟶ X ×ₛ X` to `𝒱 i j ×[𝒰 i] 𝒱 i j` is the diagonal
`𝒱 i j ⟶ 𝒱 i j ×[𝒰 i] 𝒱 i j`. -/
noncomputable
def diagonalRestrictIsoDiagonal (i j) :
Arrow.mk (pullback.diagonal f ∣_ ((diagonalCover f 𝒰 𝒱).f ⟨i, j, j⟩).opensRange) ≅
Arrow.mk (pullback.diagonal ((𝒱 i).f j ≫ pullback.snd _ _)) := by
refine (morphismRestrictOpensRange _ _).trans ?_
refine Arrow.isoMk ?_ (Iso.refl _) ?_
· exact pullback.congrHom rfl (diagonalCover_map _ _ _ _) ≪≫
pullbackDiagonalMapIso _ _ _ _ ≪≫ (asIso (pullback.diagonal _)).symm
have H : pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).f ⟨i, (j, j)⟩) ≫
pullback.snd _ _ = pullback.snd _ _ ≫ pullback.fst _ _ := by
rw [← cancel_mono ((𝒱 i).f _)]
apply pullback.hom_ext
· trans pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).f ⟨i, (j, j)⟩) ≫
(diagonalCover f 𝒰 𝒱).f _ ≫ pullback.snd _ _
· simp [diagonalCover_map]
symm
trans pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).f ⟨i, (j, j)⟩) ≫
(diagonalCover f 𝒰 𝒱).f _ ≫ pullback.fst _ _
· simp [diagonalCover_map]
· rw [← pullback.condition_assoc, ← pullback.condition_assoc]
simp
· simp [pullback.condition, Cover.pullbackHom]
dsimp [Cover.pullbackHom] at H ⊢
apply pullback.hom_ext
· simp only [Category.assoc, pullback.diagonal_fst, Category.comp_id]
simp only [← Category.assoc, IsIso.comp_inv_eq]
apply pullback.hom_ext <;> simp [H]
· simp only [Category.assoc, pullback.diagonal_snd, Category.comp_id]
simp only [← Category.assoc, IsIso.comp_inv_eq]
apply pullback.hom_ext <;> simp [H]
end Pullback
end AlgebraicGeometry.Scheme
namespace AlgebraicGeometry
instance Scheme.pullback_map_isOpenImmersion {X Y S X' Y' S' : Scheme}
(f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S') (g' : Y' ⟶ S')
(i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f') (e₂ : g ≫ i₃ = i₂ ≫ g')
[IsOpenImmersion i₁] [IsOpenImmersion i₂] [Mono i₃] :
IsOpenImmersion (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) := by
rw [pullback_map_eq_pullbackFstFstIso_inv]
infer_instance
section Spec
variable (R S T : Type u) [CommRing R] [CommRing S] [CommRing T] [Algebra R S] [Algebra R T]
open TensorProduct Algebra.TensorProduct CommRingCat RingHomClass
/-- The isomorphism between the fibred product of two schemes `Spec S` and `Spec T`
over a scheme `Spec R` and the `Spec` of the tensor product `S ⊗[R] T`. -/
noncomputable
def pullbackSpecIso :
pullback (Spec.map (CommRingCat.ofHom (algebraMap R S)))
(Spec.map (CommRingCat.ofHom (algebraMap R T))) ≅ Spec (.of <| S ⊗[R] T) :=
letI H := IsLimit.equivIsoLimit (PullbackCone.eta _)
(PushoutCocone.isColimitEquivIsLimitOp _ (CommRingCat.pushoutCoconeIsColimit R S T))
limit.isoLimitCone ⟨_, isLimitPullbackConeMapOfIsLimit Scheme.Spec _ H⟩
/--
The composition of the inverse of the isomorphism `pullbackSpecIso R S T` (from the pullback of
`Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the first projection is
the morphism `Spec (S ⊗[R] T) ⟶ Spec S` obtained by applying `Spec.map` to the ring morphism
`s ↦ s ⊗ₜ[R] 1`.
-/
@[reassoc (attr := simp)]
lemma pullbackSpecIso_inv_fst :
(pullbackSpecIso R S T).inv ≫ pullback.fst _ _ = Spec.map (ofHom includeLeftRingHom) :=
limit.isoLimitCone_inv_π _ _
/--
The composition of the inverse of the isomorphism `pullbackSpecIso R S T` (from the pullback of
`Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the second projection is
the morphism `Spec (S ⊗[R] T) ⟶ Spec T` obtained by applying `Spec.map` to the ring morphism
`t ↦ 1 ⊗ₜ[R] t`.
-/
@[reassoc (attr := simp)]
lemma pullbackSpecIso_inv_snd :
(pullbackSpecIso R S T).inv ≫ pullback.snd _ _ =
Spec.map (ofHom (R := T) (S := S ⊗[R] T) (toRingHom includeRight)) :=
limit.isoLimitCone_inv_π _ _
/--
The composition of the isomorphism `pullbackSpecIso R S T` (from the pullback of
`Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the morphism
`Spec (S ⊗[R] T) ⟶ Spec S` obtained by applying `Spec.map` to the ring morphism `s ↦ s ⊗ₜ[R] 1`
is the first projection.
-/
@[reassoc (attr := simp)]
lemma pullbackSpecIso_hom_fst :
(pullbackSpecIso R S T).hom ≫ Spec.map (ofHom includeLeftRingHom) = pullback.fst _ _ := by
rw [← pullbackSpecIso_inv_fst, Iso.hom_inv_id_assoc]
/--
The composition of the isomorphism `pullbackSpecIso R S T` (from the pullback of
`Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the morphism
`Spec (S ⊗[R] T) ⟶ Spec T` obtained by applying `Spec.map` to the ring morphism `t ↦ 1 ⊗ₜ[R] t`
is the second projection.
-/
@[reassoc (attr := simp)]
lemma pullbackSpecIso_hom_snd :
(pullbackSpecIso R S T).hom ≫ Spec.map (ofHom (toRingHom includeRight)) = pullback.snd _ _ := by
rw [← pullbackSpecIso_inv_snd, Iso.hom_inv_id_assoc]
lemma isPullback_SpecMap_of_isPushout {A B C P : CommRingCat} (f : A ⟶ B) (g : A ⟶ C)
(inl : B ⟶ P) (inr : C ⟶ P) (h : IsPushout f g inl inr) :
IsPullback (Spec.map inl) (Spec.map inr) (Spec.map f) (Spec.map g) :=
IsPullback.map Scheme.Spec h.op.flip
@[deprecated (since := "2025-10-07")]
alias isPullback_Spec_map_isPushout := isPullback_SpecMap_of_isPushout
lemma isPullback_SpecMap_pushout {A B C : CommRingCat} (f : A ⟶ B) (g : A ⟶ C) :
IsPullback (Spec.map (pushout.inl f g))
(Spec.map (pushout.inr f g)) (Spec.map f) (Spec.map g) := by
apply isPullback_SpecMap_of_isPushout
exact IsPushout.of_hasPushout f g
@[deprecated (since := "2025-10-07")]
alias isPullback_Spec_map_pushout := isPullback_SpecMap_pushout
lemma diagonal_SpecMap :
pullback.diagonal (Spec.map (CommRingCat.ofHom (algebraMap R S))) =
Spec.map (CommRingCat.ofHom (Algebra.TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).toRingHom) ≫
(pullbackSpecIso R S S).inv := by
ext1 <;> simp only [pullback.diagonal_fst, pullback.diagonal_snd, ← Spec.map_comp, ← Spec.map_id,
AlgHom.toRingHom_eq_coe, Category.assoc, pullbackSpecIso_inv_fst, pullbackSpecIso_inv_snd]
· congr 1; ext x; change x = Algebra.TensorProduct.lmul' R (S := S) (x ⊗ₜ[R] 1); simp
· congr 1; ext x; change x = Algebra.TensorProduct.lmul' R (S := S) (1 ⊗ₜ[R] x); simp
@[deprecated (since := "2025-10-07")] alias diagonal_Spec_map := diagonal_SpecMap
end Spec
section CartesianMonoidalCategory
variable {S : Scheme}
instance : CartesianMonoidalCategory (Over S) := Over.cartesianMonoidalCategory _
instance : BraidedCategory (Over S) := .ofCartesianMonoidalCategory
end CartesianMonoidalCategory
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Noetherian.lean | import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.RingTheory.Localization.Submodule
import Mathlib.RingTheory.Spectrum.Prime.Noetherian
/-!
# Noetherian and Locally Noetherian Schemes
We introduce the concept of (locally) Noetherian schemes,
giving definitions, equivalent conditions, and basic properties.
## Main definitions
* `AlgebraicGeometry.IsLocallyNoetherian`: A scheme is locally Noetherian
if the components of the structure sheaf at each affine open are Noetherian rings.
* `AlgebraicGeometry.IsNoetherian`: A scheme is Noetherian if it is locally Noetherian
and quasi-compact as a topological space.
## Main results
* `AlgebraicGeometry.isLocallyNoetherian_iff_of_affine_openCover`: A scheme is locally Noetherian
if and only if it is covered by affine opens whose sections are Noetherian rings.
* `AlgebraicGeometry.IsLocallyNoetherian.quasiSeparatedSpace`: A locally Noetherian scheme is
quasi-separated.
* `AlgebraicGeometry.isNoetherian_iff_of_finite_affine_openCover`: A scheme is Noetherian
if and only if it is covered by finitely many affine opens whose sections are Noetherian rings.
* `AlgebraicGeometry.IsNoetherian.noetherianSpace`: A Noetherian scheme is
topologically a Noetherian space.
## References
* [Stacks: Noetherian Schemes](https://stacks.math.columbia.edu/tag/01OU)
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
universe u v
open Opposite AlgebraicGeometry Localization IsLocalization TopologicalSpace CategoryTheory
namespace AlgebraicGeometry
/-- A scheme `X` is locally Noetherian if `𝒪ₓ(U)` is Noetherian for all affine `U`. -/
class IsLocallyNoetherian (X : Scheme) : Prop where
component_noetherian : ∀ (U : X.affineOpens),
IsNoetherianRing Γ(X, U) := by infer_instance
section localizationProps
variable {R : Type u} [CommRing R] (S : Finset R) (hS : Ideal.span (α := R) S = ⊤)
(hN : ∀ s : S, IsNoetherianRing (Away (M := R) s))
include hS hN in
/-- Let `R` be a ring, and `f i` a finite collection of elements of `R` generating the unit ideal.
If the localization of `R` at each `f i` is Noetherian, so is `R`.
We follow the proof given in [Har77], Proposition II.3.2 -/
theorem isNoetherianRing_of_away : IsNoetherianRing R := by
apply monotone_stabilizes_iff_noetherian.mp
intro I
let floc s := algebraMap R (Away (M := R) s)
let suitableN s :=
{ n : ℕ | ∀ m : ℕ, n ≤ m → (Ideal.map (floc s) (I n)) = (Ideal.map (floc s) (I m)) }
let minN s := sInf (suitableN s)
have hSuit : ∀ s : S, minN s ∈ suitableN s := by
intro s
apply Nat.sInf_mem
let f : ℕ →o Ideal (Away (M := R) s) :=
⟨fun n ↦ Ideal.map (floc s) (I n), fun _ _ h ↦ Ideal.map_mono (I.monotone h)⟩
exact monotone_stabilizes_iff_noetherian.mpr (hN s) f
let N := Finset.sup S minN
use N
have hN : ∀ s : S, minN s ≤ N := fun s => Finset.le_sup s.prop
intro n hn
rw [IsLocalization.ideal_eq_iInf_comap_map_away hS (I N),
IsLocalization.ideal_eq_iInf_comap_map_away hS (I n),
iInf_subtype', iInf_subtype']
apply iInf_congr
intro s
congr 1
rw [← hSuit s N (hN s)]
exact hSuit s n <| Nat.le_trans (hN s) hn
end localizationProps
variable {X : Scheme}
/-- If a scheme `X` has a cover by affine opens whose sections are Noetherian rings,
then `X` is locally Noetherian. -/
theorem isLocallyNoetherian_of_affine_cover {ι} {S : ι → X.affineOpens}
(hS : (⨆ i, S i : X.Opens) = ⊤)
(hS' : ∀ i, IsNoetherianRing Γ(X, S i)) : IsLocallyNoetherian X := by
refine ⟨fun U => ?_⟩
induction U using of_affine_open_cover S hS with
| basicOpen U f hN =>
have := U.prop.isLocalization_basicOpen f
exact IsLocalization.isNoetherianRing (.powers f) Γ(X, X.basicOpen f) hN
| openCover U s _ hN =>
apply isNoetherianRing_of_away s ‹_›
intro ⟨f, hf⟩
have : IsNoetherianRing Γ(X, X.basicOpen f) := hN ⟨f, hf⟩
have := U.prop.isLocalization_basicOpen f
have hEq := IsLocalization.algEquiv (.powers f) (Localization.Away f) Γ(X, X.basicOpen f)
exact isNoetherianRing_of_ringEquiv Γ(X, X.basicOpen f) hEq.symm.toRingEquiv
| hU => exact hS' _
/-- A scheme is locally Noetherian if and only if it is covered by affine opens whose sections
are Noetherian rings.
See [Har77], Proposition II.3.2. -/
theorem isLocallyNoetherian_iff_of_iSup_eq_top {ι} {S : ι → X.affineOpens}
(hS : (⨆ i, S i : X.Opens) = ⊤) :
IsLocallyNoetherian X ↔ ∀ i, IsNoetherianRing Γ(X, S i) :=
⟨fun _ i => IsLocallyNoetherian.component_noetherian (S i),
isLocallyNoetherian_of_affine_cover hS⟩
/-- A version of `isLocallyNoetherian_iff_of_iSup_eq_top` using `Scheme.OpenCover`. -/
theorem isLocallyNoetherian_iff_of_affine_openCover (𝒰 : Scheme.OpenCover.{v, u} X)
[∀ i, IsAffine (𝒰.X i)] :
IsLocallyNoetherian X ↔ ∀ (i : 𝒰.I₀), IsNoetherianRing Γ(𝒰.X i, ⊤) := by
constructor
· intro h i
let U := Scheme.Hom.opensRange (𝒰.f i)
have := h.component_noetherian ⟨U, isAffineOpen_opensRange _⟩
apply isNoetherianRing_of_ringEquiv (R := Γ(X, U))
apply CategoryTheory.Iso.commRingCatIsoToRingEquiv
exact (IsOpenImmersion.ΓIsoTop (𝒰.f i)).symm
· intro hCNoeth
let fS i : X.affineOpens := ⟨Scheme.Hom.opensRange (𝒰.f i), isAffineOpen_opensRange _⟩
apply isLocallyNoetherian_of_affine_cover (S := fS)
· rw [← Scheme.OpenCover.iSup_opensRange 𝒰]
intro i
apply isNoetherianRing_of_ringEquiv (R := Γ(𝒰.X i, ⊤))
apply CategoryTheory.Iso.commRingCatIsoToRingEquiv
exact IsOpenImmersion.ΓIsoTop (𝒰.f i)
lemma isLocallyNoetherian_of_isOpenImmersion {Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f]
[IsLocallyNoetherian Y] : IsLocallyNoetherian X := by
refine ⟨fun U => ?_⟩
let V : Y.affineOpens := ⟨f ''ᵁ U, IsAffineOpen.image_of_isOpenImmersion U.prop _⟩
suffices Γ(X, U) ≅ Γ(Y, V) by
convert isNoetherianRing_of_ringEquiv (R := Γ(Y, V)) _
· apply CategoryTheory.Iso.commRingCatIsoToRingEquiv
exact this.symm
· exact IsLocallyNoetherian.component_noetherian V
rw [← Scheme.Hom.preimage_image_eq f U]
trans
· apply IsOpenImmersion.ΓIso
· suffices Scheme.Hom.opensRange f ⊓ V = V by
rw [this]
rw [← Opens.coe_inj]
rw [Opens.coe_inf, Scheme.Hom.coe_opensRange, Set.inter_eq_right]
exact Set.image_subset_range _ _
/-- If `𝒰` is an open cover of a scheme `X`, then `X` is locally Noetherian if and only if
`𝒰.X i` are all locally Noetherian. -/
theorem isLocallyNoetherian_iff_openCover (𝒰 : Scheme.OpenCover X) :
IsLocallyNoetherian X ↔ ∀ (i : 𝒰.I₀), IsLocallyNoetherian (𝒰.X i) := by
constructor
· intro h i
exact isLocallyNoetherian_of_isOpenImmersion (𝒰.f i)
· rw [isLocallyNoetherian_iff_of_affine_openCover (𝒰 := 𝒰.affineRefinement.openCover)]
intro h i
exact @isNoetherianRing_of_ringEquiv _ _ _ _
(IsOpenImmersion.ΓIsoTop (PreZeroHypercover.f _ i.2)).symm.commRingCatIsoToRingEquiv
(IsLocallyNoetherian.component_noetherian ⟨_, isAffineOpen_opensRange _⟩)
/-- If `R` is a Noetherian ring, `Spec R` is a Noetherian topological space. -/
instance {R : CommRingCat} [IsNoetherianRing R] :
NoetherianSpace (Spec R) := by
convert PrimeSpectrum.instNoetherianSpace (R := R)
lemma noetherianSpace_of_isAffine [IsAffine X] [IsNoetherianRing Γ(X, ⊤)] :
NoetherianSpace X :=
(noetherianSpace_iff_of_homeomorph X.isoSpec.inv.homeomorph).mp inferInstance
lemma noetherianSpace_of_isAffineOpen (U : X.Opens) (hU : IsAffineOpen U)
[IsNoetherianRing Γ(X, U)] :
NoetherianSpace U := by
have : IsNoetherianRing Γ(U, ⊤) := isNoetherianRing_of_ringEquiv _
(Scheme.restrictFunctorΓ.app (op U)).symm.commRingCatIsoToRingEquiv
exact @noetherianSpace_of_isAffine _ hU _
/-- Any open immersion `Z ⟶ X` with `X` locally Noetherian is quasi-compact. -/
@[stacks 01OX]
instance (priority := 100) {Z : Scheme} [IsLocallyNoetherian X]
{f : Z ⟶ X} [IsOpenImmersion f] : QuasiCompact f := by
apply quasiCompact_iff_forall_isAffineOpen.mpr
intro U hU
rw [Opens.map_coe, ← Set.preimage_inter_range]
apply f.isOpenEmbedding.isInducing.isCompact_preimage'
· apply (noetherianSpace_set_iff _).mp
· convert noetherianSpace_of_isAffineOpen U hU
apply IsLocallyNoetherian.component_noetherian ⟨U, hU⟩
· exact Set.inter_subset_left
· exact Set.inter_subset_right
/-- A locally Noetherian scheme is quasi-separated. -/
@[stacks 01OY]
instance (priority := 100) IsLocallyNoetherian.quasiSeparatedSpace [IsLocallyNoetherian X] :
QuasiSeparatedSpace X := by
apply quasiSeparatedSpace_iff_forall_affineOpens.mpr
intro U V
have hInd := U.2.fromSpec.isOpenEmbedding.isInducing
apply (hInd.isCompact_preimage_iff ?_).mp
· rw [← Set.preimage_inter_range, IsAffineOpen.range_fromSpec, Set.inter_comm]
apply hInd.isCompact_preimage'
· apply (noetherianSpace_set_iff _).mp
· convert noetherianSpace_of_isAffineOpen U.1 U.2
apply IsLocallyNoetherian.component_noetherian
· exact Set.inter_subset_left
· rw [IsAffineOpen.range_fromSpec]
exact Set.inter_subset_left
· rw [IsAffineOpen.range_fromSpec]
exact Set.inter_subset_left
/-- A scheme `X` is Noetherian if it is locally Noetherian and compact. -/
@[mk_iff]
class IsNoetherian (X : Scheme) : Prop extends IsLocallyNoetherian X, CompactSpace X
/-- A scheme is Noetherian if and only if it is covered by finitely many affine opens whose
sections are Noetherian rings. -/
theorem isNoetherian_iff_of_finite_iSup_eq_top {ι} [Finite ι] {S : ι → X.affineOpens}
(hS : (⨆ i, S i : X.Opens) = ⊤) :
IsNoetherian X ↔ ∀ i, IsNoetherianRing Γ(X, S i) := by
constructor
· intro h i
apply (isLocallyNoetherian_iff_of_iSup_eq_top hS).mp
exact h.toIsLocallyNoetherian
· intro h
convert IsNoetherian.mk
· exact isLocallyNoetherian_of_affine_cover hS h
· constructor
rw [← Opens.coe_top, ← hS, Opens.iSup_mk]
apply isCompact_iUnion
intro i
apply isCompact_iff_isCompact_univ.mpr
convert CompactSpace.isCompact_univ
have : NoetherianSpace (S i) := by
apply noetherianSpace_of_isAffineOpen (S i).1 (S i).2
apply NoetherianSpace.compactSpace (S i)
/-- A version of `isNoetherian_iff_of_finite_iSup_eq_top` using `Scheme.OpenCover`. -/
theorem isNoetherian_iff_of_finite_affine_openCover {𝒰 : Scheme.OpenCover.{v, u} X}
[Finite 𝒰.I₀] [∀ i, IsAffine (𝒰.X i)] :
IsNoetherian X ↔ ∀ (i : 𝒰.I₀), IsNoetherianRing Γ(𝒰.X i, ⊤) := by
constructor
· intro h i
apply (isLocallyNoetherian_iff_of_affine_openCover _).mp
exact h.toIsLocallyNoetherian
· intro hNoeth
convert IsNoetherian.mk
· exact (isLocallyNoetherian_iff_of_affine_openCover _).mpr hNoeth
· exact Scheme.OpenCover.compactSpace 𝒰
/-- A Noetherian scheme has a Noetherian underlying topological space. -/
@[stacks 01OZ]
instance (priority := 100) IsNoetherian.noetherianSpace [IsNoetherian X] :
NoetherianSpace X := by
apply TopologicalSpace.noetherian_univ_iff.mp
let 𝒰 := X.affineCover.finiteSubcover
rw [← 𝒰.iUnion_range]
suffices ∀ i : 𝒰.I₀, NoetherianSpace (Set.range <| (𝒰.f i)) by
apply NoetherianSpace.iUnion
intro i
have : IsAffine (𝒰.X i) := by
rw [X.affineCover.finiteSubcover_X]
apply Scheme.isAffine_affineCover
let U : X.affineOpens := ⟨Scheme.Hom.opensRange (𝒰.f i), isAffineOpen_opensRange _⟩
convert noetherianSpace_of_isAffineOpen U.1 U.2
apply IsLocallyNoetherian.component_noetherian
/-- Any morphism of schemes `f : X ⟶ Y` with `X` Noetherian is quasi-compact. -/
@[stacks 01P0]
instance (priority := 100) quasiCompact_of_noetherianSpace_source {X Y : Scheme}
[NoetherianSpace X] (f : X ⟶ Y) : QuasiCompact f :=
⟨fun _ _ _ => NoetherianSpace.isCompact _⟩
/-- If `R` is a Noetherian ring, `Spec R` is a locally Noetherian scheme. -/
instance {R : CommRingCat} [IsNoetherianRing R] :
IsLocallyNoetherian (Spec R) := by
apply isLocallyNoetherian_of_affine_cover
(ι := Fin 1) (S := fun _ => ⟨⊤, isAffineOpen_top (Spec R)⟩)
· exact iSup_const
· intro
apply isNoetherianRing_of_ringEquiv R
apply CategoryTheory.Iso.commRingCatIsoToRingEquiv
exact (Scheme.ΓSpecIso R).symm
instance (priority := 100) {R : CommRingCat}
[IsLocallyNoetherian (Spec R)] : IsNoetherianRing R := by
have := IsLocallyNoetherian.component_noetherian ⟨⊤, AlgebraicGeometry.isAffineOpen_top (Spec R)⟩
apply isNoetherianRing_of_ringEquiv Γ(Spec R, ⊤)
apply CategoryTheory.Iso.commRingCatIsoToRingEquiv
exact Scheme.ΓSpecIso R
/-- If `R` is a Noetherian ring, `Spec R` is a Noetherian scheme. -/
instance {R : CommRingCat} [IsNoetherianRing R] :
IsNoetherian (Spec R) where
instance {R} [CommRing R] [IsNoetherianRing R] :
IsNoetherian <| Spec <| .of R := by
suffices IsNoetherianRing (CommRingCat.of R) by infer_instance
assumption
instance [IsLocallyNoetherian X] {x : X} : IsNoetherianRing (X.presheaf.stalk x) := by
obtain ⟨U, hU, hU2, hU3⟩ := exists_isAffineOpen_mem_and_subset (U := ⊤) (x := x) (by aesop)
have := AlgebraicGeometry.IsAffineOpen.isLocalization_stalk hU ⟨x, hU2⟩
exact @IsLocalization.isNoetherianRing _ _ (hU.primeIdealOf ⟨x, hU2⟩).asIdeal.primeCompl
(X.presheaf.stalk x) _ (X.presheaf.algebra_section_stalk ⟨x, hU2⟩)
this (IsLocallyNoetherian.component_noetherian ⟨U, hU⟩)
/-- `R` is a Noetherian ring if and only if `Spec R` is a Noetherian scheme. -/
theorem isNoetherian_Spec {R : CommRingCat} :
IsNoetherian (Spec R) ↔ IsNoetherianRing R :=
⟨fun _ => inferInstance,
fun _ => inferInstance⟩
/-- A Noetherian scheme has a finite number of irreducible components. -/
@[stacks 0BA8]
theorem finite_irreducibleComponents_of_isNoetherian [IsNoetherian X] :
(irreducibleComponents X).Finite := NoetherianSpace.finite_irreducibleComponents
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Finite.lean | import Mathlib.AlgebraicGeometry.Morphisms.Integral
import Mathlib.Algebra.Category.Ring.Epi
/-!
# Finite morphisms of schemes
A morphism of schemes `f : X ⟶ Y` is finite if the preimage
of an arbitrary affine open subset of `Y` is affine and the induced ring map is finite.
It is equivalent to ask only that `Y` is covered by affine opens whose preimage is affine
and the induced ring map is finite.
Also see `AlgebraicGeometry.IsFinite.finite_preimage_singleton` in
`Mathlib/AlgebraicGeometry/Fiber.lean` for the fact that finite morphisms have finite fibers.
-/
universe v u
open CategoryTheory TopologicalSpace Opposite MorphismProperty
namespace AlgebraicGeometry
/-- A morphism of schemes `X ⟶ Y` is finite if
the preimage of any affine open subset of `Y` is affine and the induced ring
hom is finite. -/
@[mk_iff]
class IsFinite {X Y : Scheme} (f : X ⟶ Y) : Prop extends IsAffineHom f where
finite_app (U : Y.Opens) (hU : IsAffineOpen U) : (f.app U).hom.Finite
namespace IsFinite
instance : HasAffineProperty @IsFinite
(fun X _ f _ ↦ IsAffine X ∧ RingHom.Finite (f.appTop).hom) := by
change HasAffineProperty @IsFinite (affineAnd RingHom.Finite)
rw [HasAffineProperty.affineAnd_iff _ RingHom.finite_respectsIso
RingHom.finite_localizationPreserves.away RingHom.finite_ofLocalizationSpan]
simp [isFinite_iff]
instance : IsStableUnderComposition @IsFinite :=
HasAffineProperty.affineAnd_isStableUnderComposition inferInstance
RingHom.finite_stableUnderComposition
instance : IsStableUnderBaseChange @IsFinite :=
HasAffineProperty.affineAnd_isStableUnderBaseChange inferInstance
RingHom.finite_respectsIso RingHom.finite_isStableUnderBaseChange
instance : ContainsIdentities @IsFinite :=
HasAffineProperty.affineAnd_containsIdentities inferInstance
RingHom.finite_respectsIso RingHom.finite_containsIdentities
instance : IsMultiplicative @IsFinite where
lemma SpecMap_iff {R S : CommRingCat.{u}} (f : R ⟶ S) :
IsFinite (Spec.map f) ↔ f.hom.Finite := by
rw [HasAffineProperty.iff_of_isAffine (P := @IsFinite), and_iff_right (by infer_instance),
RingHom.finite_respectsIso.arrow_mk_iso_iff (arrowIsoΓSpecOfIsAffine f)]
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y)
instance (priority := 900) [IsIso f] : IsFinite f := of_isIso @IsFinite f
instance {Z : Scheme.{u}} (g : Y ⟶ Z) [IsFinite f] [IsFinite g] : IsFinite (f ≫ g) :=
IsStableUnderComposition.comp_mem f g ‹IsFinite f› ‹IsFinite g›
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsFinite g] : IsFinite (Limits.pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ inferInstance
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsFinite f] : IsFinite (Limits.pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [IsFinite f] : IsFinite (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
lemma iff_isIntegralHom_and_locallyOfFiniteType :
IsFinite f ↔ IsIntegralHom f ∧ LocallyOfFiniteType f := by
wlog hY : IsAffine Y
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsFinite) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := @IsIntegralHom) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := @LocallyOfFiniteType) Y.affineCover]
simp_rw [this, forall_and]
rw [HasAffineProperty.iff_of_isAffine (P := @IsFinite),
HasAffineProperty.iff_of_isAffine (P := @IsIntegralHom),
RingHom.finite_iff_isIntegral_and_finiteType, ← and_assoc]
refine and_congr_right fun ⟨_, _⟩ ↦
(HasRingHomProperty.iff_of_isAffine (P := @LocallyOfFiniteType)).symm
lemma eq_inf :
@IsFinite = (@IsIntegralHom ⊓ @LocallyOfFiniteType : MorphismProperty Scheme) := by
ext; exact IsFinite.iff_isIntegralHom_and_locallyOfFiniteType _
instance (priority := 900) [IsFinite f] : IsIntegralHom f :=
((IsFinite.iff_isIntegralHom_and_locallyOfFiniteType f).mp ‹_›).1
instance (priority := 900) [IsFinite f] : LocallyOfFiniteType f :=
((IsFinite.iff_isIntegralHom_and_locallyOfFiniteType f).mp ‹_›).2
lemma _root_.AlgebraicGeometry.IsClosedImmersion.iff_isFinite_and_mono :
IsClosedImmersion f ↔ IsFinite f ∧ Mono f := by
wlog hY : IsAffine Y
· change _ ↔ _ ∧ monomorphisms _ f
rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsFinite) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := @IsClosedImmersion) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := monomorphisms _) Y.affineCover]
simp_rw [this, forall_and, monomorphisms]
rw [HasAffineProperty.iff_of_isAffine (P := @IsClosedImmersion),
HasAffineProperty.iff_of_isAffine (P := @IsFinite),
RingHom.surjective_iff_epi_and_finite, @and_comm (Epi _), ← and_assoc]
refine and_congr_right fun ⟨_, _⟩ ↦
Iff.trans ?_ (arrow_mk_iso_iff (monomorphisms _) (arrowIsoSpecΓOfIsAffine f).symm)
trans Mono (f.app ⊤).op
· exact ⟨fun h ↦ inferInstance, fun h ↦ show Epi (f.app ⊤).op.unop by infer_instance⟩
exact (Functor.mono_map_iff_mono Scheme.Spec _).symm
lemma _root_.AlgebraicGeometry.IsClosedImmersion.eq_isFinite_inf_mono :
@IsClosedImmersion = (@IsFinite ⊓ monomorphisms Scheme : MorphismProperty _) := by
ext; exact IsClosedImmersion.iff_isFinite_and_mono _
instance (priority := 900) (f : X ⟶ Y) [IsClosedImmersion f] : IsFinite f :=
((IsClosedImmersion.iff_isFinite_and_mono f).mp ‹_›).1
instance : MorphismProperty.HasOfPostcompProperty @IsFinite @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsFinite _)
lemma of_comp (f : X ⟶ Y) (g : Y ⟶ Z) [IsFinite (f ≫ g)] [IsSeparated g] :
IsFinite f := MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
lemma comp_iff {f : X ⟶ Y} {g : Y ⟶ Z} [IsFinite g] :
IsFinite (f ≫ g) ↔ IsFinite f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
end IsFinite
/-- If `X` is a Jacobson scheme and `k` is a field,
`Spec(k) ⟶ X` is finite iff it is (locally) of finite type.
(The statement is more general to allow the empty scheme as well) -/
lemma isFinite_iff_locallyOfFiniteType_of_jacobsonSpace
{X Y : Scheme.{u}} {f : X ⟶ Y} [Subsingleton X] [IsReduced X] [JacobsonSpace Y] :
IsFinite f ↔ LocallyOfFiniteType f := by
wlog hY : ∃ S, Y = Spec S generalizing X Y
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsFinite) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := @LocallyOfFiniteType) Y.affineCover]
have inst (i) := ((Y.affineCover.pullback₁ f).f i).isOpenEmbedding.injective.subsingleton
have inst (i) := isReduced_of_isOpenImmersion ((Y.affineCover.pullback₁ f).f i)
have inst (i) := JacobsonSpace.of_isOpenEmbedding (Y.affineCover.f i).isOpenEmbedding
exact forall_congr' fun i ↦ this ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hY
wlog hX : ∃ R, X = Spec R generalizing X
· rw [← MorphismProperty.cancel_left_of_respectsIso (P := @IsFinite) X.isoSpec.inv,
← MorphismProperty.cancel_left_of_respectsIso (P := @LocallyOfFiniteType) X.isoSpec.inv]
have inst := X.isoSpec.inv.isOpenEmbedding.injective.subsingleton
refine this ⟨_, rfl⟩
cases isEmpty_or_nonempty X
· exact ⟨inferInstance, inferInstance⟩
have : IrreducibleSpace X := ⟨‹_›⟩
obtain ⟨R, rfl⟩ := hX
have : IsDomain R := (affine_isIntegral_iff R).mp (isIntegral_of_irreducibleSpace_of_isReduced _)
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [IsFinite.SpecMap_iff, HasRingHomProperty.Spec_iff (P := @LocallyOfFiniteType)]
have := (PrimeSpectrum.t1Space_iff_isField (R := R)).mp (show T1Space (Spec R) by infer_instance)
letI := this.toField
letI := φ.hom.toAlgebra
have := PrimeSpectrum.isJacobsonRing_iff_jacobsonSpace.mpr ‹_›
change Module.Finite _ _ ↔ Algebra.FiniteType _ _
exact ⟨fun _ ↦ inferInstance, fun _ ↦ finite_of_finite_type_of_isJacobsonRing _ _⟩
@[stacks 01TB "(1) => (3)"]
lemma Scheme.Hom.closePoints_subset_preimage_closedPoints
{X Y : Scheme.{u}} (f : X ⟶ Y) [JacobsonSpace Y] [LocallyOfFiniteType f] :
closedPoints X ⊆ f ⁻¹' closedPoints Y := by
intro x hx
have := isClosed_singleton_iff_isClosedImmersion.mp hx
have := (isFinite_iff_locallyOfFiniteType_of_jacobsonSpace
(f := X.fromSpecResidueField x ≫ f)).mpr inferInstance
simpa [Set.range_comp, Scheme.range_fromSpecResidueField] using
(X.fromSpecResidueField x ≫ f).isClosedMap.isClosed_range
@[stacks 01TB "(1) => (2)"]
lemma isClosed_singleton_iff_locallyOfFiniteType {X : Scheme.{u}} [JacobsonSpace X] {x : X} :
IsClosed {x} ↔ LocallyOfFiniteType (X.fromSpecResidueField x) := by
constructor
· exact fun H ↦ have := isClosed_singleton_iff_isClosedImmersion.mp H; inferInstance
· intro H
simpa using (X.fromSpecResidueField x).closePoints_subset_preimage_closedPoints
(IsLocalRing.isClosed_singleton_closedPoint _)
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/SurjectiveOnStalks.lean | import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties
import Mathlib.RingTheory.RingHom.Surjective
import Mathlib.RingTheory.Spectrum.Prime.TensorProduct
import Mathlib.Topology.LocalAtTarget
/-!
# Morphisms surjective on stalks
We define the class of morphisms between schemes that are surjective on stalks.
We show that this class is stable under composition and base change.
We also show that (`AlgebraicGeometry.SurjectiveOnStalks.isEmbedding_pullback`)
if `Y ⟶ S` is surjective on stalks, then for every `X ⟶ S`, `X ×ₛ Y` is a subset of
`X × Y` (Cartesian product as topological spaces) with the induced topology.
-/
open CategoryTheory CategoryTheory.Limits Topology
namespace AlgebraicGeometry
universe u
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- The class of morphisms `f : X ⟶ Y` between schemes such that
`𝒪_{Y, f x} ⟶ 𝒪_{X, x}` is surjective for all `x : X`. -/
@[mk_iff]
class SurjectiveOnStalks : Prop where
surj_on_stalks : ∀ x, Function.Surjective (f.stalkMap x)
theorem Scheme.Hom.stalkMap_surjective (f : X.Hom Y) [SurjectiveOnStalks f] (x) :
Function.Surjective (f.stalkMap x) :=
SurjectiveOnStalks.surj_on_stalks x
namespace SurjectiveOnStalks
instance (priority := 900) [IsOpenImmersion f] : SurjectiveOnStalks f :=
⟨fun _ ↦ (ConcreteCategory.bijective_of_isIso _).2⟩
instance : MorphismProperty.IsMultiplicative @SurjectiveOnStalks where
id_mem _ := inferInstance
comp_mem {X Y Z} f g hf hg := by
refine ⟨fun x ↦ ?_⟩
rw [Scheme.Hom.stalkMap_comp]
exact (hf.surj_on_stalks x).comp (hg.surj_on_stalks (f x))
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [SurjectiveOnStalks f]
[SurjectiveOnStalks g] : SurjectiveOnStalks (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
lemma eq_stalkwise :
@SurjectiveOnStalks = stalkwise (Function.Surjective ·) := by
ext; exact surjectiveOnStalks_iff _
instance : IsZariskiLocalAtTarget @SurjectiveOnStalks :=
eq_stalkwise ▸ stalkwiseIsZariskiLocalAtTarget_of_respectsIso RingHom.surjective_respectsIso
instance : IsZariskiLocalAtSource @SurjectiveOnStalks :=
eq_stalkwise ▸ stalkwise_isZariskiLocalAtSource_of_respectsIso RingHom.surjective_respectsIso
lemma Spec_iff {R S : CommRingCat.{u}} {φ : R ⟶ S} :
SurjectiveOnStalks (Spec.map φ) ↔ RingHom.SurjectiveOnStalks φ.hom := by
rw [eq_stalkwise, stalkwise_SpecMap_iff RingHom.surjective_respectsIso,
RingHom.SurjectiveOnStalks]
instance : HasRingHomProperty @SurjectiveOnStalks RingHom.SurjectiveOnStalks :=
eq_stalkwise ▸ .stalkwise RingHom.surjective_respectsIso
variable {f} in
lemma iff_of_isAffine [IsAffine X] [IsAffine Y] :
SurjectiveOnStalks f ↔ RingHom.SurjectiveOnStalks (f.app ⊤).hom := by
rw [← Spec_iff, MorphismProperty.arrow_mk_iso_iff @SurjectiveOnStalks (arrowIsoSpecΓOfIsAffine f)]
theorem of_comp [SurjectiveOnStalks (f ≫ g)] : SurjectiveOnStalks f := by
refine ⟨fun x ↦ ?_⟩
have := (f ≫ g).stalkMap_surjective x
rw [Scheme.Hom.stalkMap_comp] at this
exact Function.Surjective.of_comp this
instance stableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @SurjectiveOnStalks := by
apply HasRingHomProperty.isStableUnderBaseChange
apply RingHom.IsStableUnderBaseChange.mk
· exact (HasRingHomProperty.isLocal_ringHomProperty @SurjectiveOnStalks).respectsIso
intro R S T _ _ _ _ _ H
exact H.baseChange
variable {f} in
lemma mono_of_injective [SurjectiveOnStalks f] (hf : Function.Injective f) : Mono f := by
refine (Scheme.forgetToLocallyRingedSpace ⋙
LocallyRingedSpace.forgetToSheafedSpace).mono_of_mono_map ?_
apply SheafedSpace.mono_of_base_injective_of_stalk_epi
· exact hf
· exact fun x ↦ ConcreteCategory.epi_of_surjective _ (f.stalkMap_surjective x)
/-- If `Y ⟶ S` is surjective on stalks, then for every `X ⟶ S`, `X ×ₛ Y` is a subset of
`X × Y` (Cartesian product as topological spaces) with the induced topology. -/
lemma isEmbedding_pullback {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) [SurjectiveOnStalks g] :
IsEmbedding (fun x ↦ (pullback.fst f g x, pullback.snd f g x)) := by
let L := (fun x ↦ (pullback.fst f g x, pullback.snd f g x))
have H : ∀ R A B (f' : Spec A ⟶ Spec R) (g' : Spec B ⟶ Spec R) (iX : Spec A ⟶ X)
(iY : Spec B ⟶ Y) (iS : Spec R ⟶ S) (e₁ e₂), IsOpenImmersion iX → IsOpenImmersion iY →
IsOpenImmersion iS → IsEmbedding (L ∘ pullback.map f' g' f g iX iY iS e₁ e₂) := by
intro R A B f' g' iX iY iS e₁ e₂ _ _ _
have H : SurjectiveOnStalks g' :=
have : SurjectiveOnStalks (g' ≫ iS) := e₂ ▸ inferInstance
.of_comp _ iS
obtain ⟨φ, rfl⟩ : ∃ φ, Spec.map φ = f' := ⟨_, Spec.map_preimage _⟩
obtain ⟨ψ, rfl⟩ : ∃ ψ, Spec.map ψ = g' := ⟨_, Spec.map_preimage _⟩
algebraize [φ.hom, ψ.hom]
rw [HasRingHomProperty.Spec_iff (P := @SurjectiveOnStalks)] at H
convert ((iX.isOpenEmbedding.prodMap iY.isOpenEmbedding).isEmbedding.comp
(PrimeSpectrum.isEmbedding_tensorProductTo_of_surjectiveOnStalks R A B H)).comp
(Scheme.homeoOfIso (pullbackSpecIso R A B)).isEmbedding
ext1 x
obtain ⟨x, rfl⟩ := (Scheme.homeoOfIso (pullbackSpecIso R A B).symm).surjective x
simp only [Scheme.homeoOfIso_apply, Function.comp_apply]
ext
· simp only [L, ← Scheme.Hom.comp_apply, pullback.lift_fst, Iso.symm_hom,
Iso.inv_hom_id]
erw [← Scheme.Hom.comp_apply, pullbackSpecIso_inv_fst_assoc]
rfl
· simp only [L, ← Scheme.Hom.comp_apply, pullback.lift_snd, Iso.symm_hom,
Iso.inv_hom_id]
erw [← Scheme.Hom.comp_apply, pullbackSpecIso_inv_snd_assoc]
rfl
let 𝒰 := S.affineOpenCover.openCover
let 𝒱 (i) := ((𝒰.pullback₁ f).X i).affineOpenCover.openCover
let 𝒲 (i) := ((𝒰.pullback₁ g).X i).affineOpenCover.openCover
let U (ijk : Σ i, (𝒱 i).I₀ × (𝒲 i).I₀) : TopologicalSpace.Opens (X.carrier × Y) :=
⟨{ P | P.1 ∈ ((𝒱 ijk.1).f ijk.2.1 ≫ (𝒰.pullback₁ f).f ijk.1).opensRange ∧
P.2 ∈ ((𝒲 ijk.1).f ijk.2.2 ≫ (𝒰.pullback₁ g).f ijk.1).opensRange },
(continuous_fst.1 _ ((𝒱 ijk.1).f ijk.2.1 ≫
(𝒰.pullback₁ f).f ijk.1).opensRange.2).inter (continuous_snd.1 _
((𝒲 ijk.1).f ijk.2.2 ≫ (𝒰.pullback₁ g).f ijk.1).opensRange.2)⟩
have : Set.range L ⊆ (iSup U :) := by
simp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_I₀, PreZeroHypercover.pullback₁_X, Set.range_subset_iff]
intro z
simp only [SetLike.mem_coe, TopologicalSpace.Opens.mem_iSup, Sigma.exists, Prod.exists]
obtain ⟨is, s, hsx⟩ := 𝒰.exists_eq (f (pullback.fst f g z))
have hsy : 𝒰.f is s = g (pullback.snd f g z) := by
rwa [← Scheme.Hom.comp_apply, ← pullback.condition, Scheme.Hom.comp_apply]
obtain ⟨x : (𝒰.pullback₁ f).X is, hx⟩ :=
Scheme.IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop
(P := @IsOpenImmersion) inferInstance _ _ hsx.symm
obtain ⟨y : (𝒰.pullback₁ g).X is, hy⟩ :=
Scheme.IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop
(P := @IsOpenImmersion) inferInstance _ _ hsy.symm
obtain ⟨ix, x, rfl⟩ := (𝒱 is).exists_eq x
obtain ⟨iy, y, rfl⟩ := (𝒲 is).exists_eq y
refine ⟨is, ix, iy, ⟨x, hx⟩, ⟨y, hy⟩⟩
let 𝓤 := (Scheme.Pullback.openCoverOfBase 𝒰 f g).bind
(fun i ↦ Scheme.Pullback.openCoverOfLeftRight (𝒱 i) (𝒲 i) _ _)
refine isEmbedding_of_iSup_eq_top_of_preimage_subset_range _ ?_ U this _ (𝓤.f ·)
(fun i ↦ (𝓤.f i).continuous) ?_ ?_
· fun_prop
· rintro i x ⟨⟨x₁, hx₁⟩, ⟨x₂, hx₂⟩⟩
obtain ⟨x₁', hx₁'⟩ :=
Scheme.IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop
(P := @IsOpenImmersion) inferInstance _ _ hx₁.symm
obtain ⟨x₂', hx₂'⟩ :=
Scheme.IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop
(P := @IsOpenImmersion) inferInstance _ _ hx₂.symm
obtain ⟨z, hz⟩ :=
Scheme.IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop
(P := @IsOpenImmersion) inferInstance _ _ (hx₁'.trans hx₂'.symm)
refine ⟨(pullbackFstFstIso _ _ _ _ _ _ (𝒰.f i.1) ?_ ?_).hom z, ?_⟩
· simp [pullback.condition]
· simp [pullback.condition]
· dsimp only
rw [← hx₁', ← hz, ← Scheme.Hom.comp_apply]
erw [← Scheme.Hom.comp_apply]
congr 5
apply pullback.hom_ext <;> simp [𝓤, ← pullback.condition, ← pullback.condition_assoc]
· intro i
have := H (S.affineOpenCover.X i.1) (((𝒰.pullback₁ f).X i.1).affineOpenCover.X i.2.1)
(((𝒰.pullback₁ g).X i.1).affineOpenCover.X i.2.2)
((𝒱 i.1).f i.2.1 ≫ 𝒰.pullbackHom f i.1)
((𝒲 i.1).f i.2.2 ≫ 𝒰.pullbackHom g i.1)
((𝒱 i.1).f i.2.1 ≫ (𝒰.pullback₁ f).f i.1)
((𝒲 i.1).f i.2.2 ≫ (𝒰.pullback₁ g).f i.1)
(𝒰.f i.1) (by simp [pullback.condition]) (by simp [pullback.condition])
inferInstance inferInstance inferInstance
convert this using 7
apply pullback.hom_ext <;>
simp [𝓤, Scheme.Cover.pullbackHom]
end SurjectiveOnStalks
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Flat.lean | import Mathlib.AlgebraicGeometry.Morphisms.Affine
import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.RingTheory.RingHom.FaithfullyFlat
/-!
# Flat morphisms
A morphism of schemes `f : X ⟶ Y` is flat if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, the induced map `Γ(Y, U) ⟶ Γ(X, V)` is flat. This is equivalent to
asking that all stalk maps are flat (see `AlgebraicGeometry.Flat.iff_flat_stalkMap`).
We show that this property is local, and are stable under compositions and base change.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is flat if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, the induced map `Γ(Y, U) ⟶ Γ(X, V)` is flat. This is equivalent to
asking that all stalk maps are flat (see `AlgebraicGeometry.Flat.iff_flat_stalkMap`).
-/
@[mk_iff]
class Flat (f : X ⟶ Y) : Prop where
flat_of_affine_subset :
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), (f.appLE U V e).hom.Flat
namespace Flat
instance : HasRingHomProperty @Flat RingHom.Flat where
isLocal_ringHomProperty := RingHom.Flat.propertyIsLocal
eq_affineLocally' := by
ext X Y f
rw [flat_iff, affineLocally_iff_affineOpens_le]
instance (priority := 900) [IsOpenImmersion f] : Flat f :=
HasRingHomProperty.of_isOpenImmersion
RingHom.Flat.containsIdentities
instance : MorphismProperty.IsStableUnderComposition @Flat :=
HasRingHomProperty.stableUnderComposition RingHom.Flat.stableUnderComposition
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : Flat f] [hg : Flat g] : Flat (f ≫ g) :=
MorphismProperty.comp_mem _ f g hf hg
instance : MorphismProperty.IsMultiplicative @Flat where
id_mem _ := inferInstance
instance isStableUnderBaseChange : MorphismProperty.IsStableUnderBaseChange @Flat :=
HasRingHomProperty.isStableUnderBaseChange RingHom.Flat.isStableUnderBaseChange
instance (f : X ⟶ Z) (g : Y ⟶ Z) [Flat g] : Flat (pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ inferInstance
instance (f : X ⟶ Z) (g : Y ⟶ Z) [Flat f] : Flat (pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [Flat f] : Flat (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [Flat f] : Flat (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
lemma of_stalkMap (H : ∀ x, (f.stalkMap x).hom.Flat) : Flat f :=
HasRingHomProperty.of_stalkMap RingHom.Flat.ofLocalizationPrime H
lemma stalkMap [Flat f] (x : X) : (f.stalkMap x).hom.Flat :=
HasRingHomProperty.stalkMap (P := @Flat)
(fun f hf J hJ ↦ hf.localRingHom J (J.comap f) rfl) ‹_› x
lemma iff_flat_stalkMap : Flat f ↔ ∀ x, (f.stalkMap x).hom.Flat :=
⟨fun _ ↦ stalkMap f, fun H ↦ of_stalkMap f H⟩
instance {X : Scheme.{u}} {ι : Type v} [Small.{u} ι] {Y : ι → Scheme.{u}} {f : ∀ i, Y i ⟶ X}
[∀ i, Flat (f i)] : Flat (Sigma.desc f) :=
IsZariskiLocalAtSource.sigmaDesc (fun _ ↦ inferInstance)
/-- A surjective, quasi-compact, flat morphism is a quotient map. -/
@[stacks 02JY]
lemma isQuotientMap_of_surjective {X Y : Scheme.{u}} (f : X ⟶ Y) [Flat f] [QuasiCompact f]
[Surjective f] : Topology.IsQuotientMap f := by
rw [Topology.isQuotientMap_iff]
refine ⟨f.surjective, fun s ↦ ⟨fun hs ↦ hs.preimage f.continuous, fun hs ↦ ?_⟩⟩
wlog hY : ∃ R, Y = Spec R
· let 𝒰 := Y.affineCover
rw [𝒰.isOpenCover_opensRange.isOpen_iff_inter]
intro i
rw [Scheme.Hom.coe_opensRange, ← Set.image_preimage_eq_inter_range]
apply (𝒰.f i).isOpenEmbedding.isOpenMap
refine this (f := pullback.fst (𝒰.f i) f) _ ?_ ⟨_, rfl⟩
rw [← Set.preimage_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, pullback.condition,
Scheme.Hom.comp_base, TopCat.coe_comp, Set.preimage_comp]
exact hs.preimage (Scheme.Hom.continuous _)
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S
· have _ : CompactSpace X := QuasiCompact.compactSpace_of_compactSpace f
let 𝒰 := X.affineCover.finiteSubcover
let p : ∐ (fun i : 𝒰.I₀ ↦ 𝒰.X i) ⟶ X := Sigma.desc (fun i ↦ 𝒰.f i)
refine this (f := (∐ (fun i : 𝒰.I₀ ↦ 𝒰.X i)).isoSpec.inv ≫ p ≫ f) _ _ ?_ ⟨_, rfl⟩
rw [← Category.assoc, Scheme.Hom.comp_base, TopCat.coe_comp, Set.preimage_comp]
exact hs.preimage (_ ≫ p).continuous
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
refine ((PrimeSpectrum.isQuotientMap_of_generalizingMap ?_ ?_).isOpen_preimage).mp hs
· exact (surjective_iff (Spec.map φ)).mp inferInstance
· apply RingHom.Flat.generalizingMap_comap
rwa [← HasRingHomProperty.Spec_iff (P := @Flat)]
/-- A flat surjective morphism of schemes is an epimorphism in the category of schemes. -/
@[stacks 02VW]
lemma epi_of_flat_of_surjective (f : X ⟶ Y) [Flat f] [Surjective f] : Epi f := by
apply CategoryTheory.Functor.epi_of_epi_map (Scheme.forgetToLocallyRingedSpace)
apply CategoryTheory.Functor.epi_of_epi_map (LocallyRingedSpace.forgetToSheafedSpace)
apply SheafedSpace.epi_of_base_surjective_of_stalk_mono _ ‹Surjective f›.surj
intro x
apply ConcreteCategory.mono_of_injective
algebraize [(f.stalkMap x).hom]
have : Module.FaithfullyFlat (Y.presheaf.stalk (f x)) (X.presheaf.stalk x) :=
@Module.FaithfullyFlat.of_flat_of_isLocalHom _ _ _ _ _ _ _
(Flat.stalkMap f x) (f.toLRSHom.prop x)
exact ‹RingHom.FaithfullyFlat _›.injective
lemma flat_and_surjective_iff_faithfullyFlat_of_isAffine [IsAffine X] [IsAffine Y] :
Flat f ∧ Surjective f ↔ f.appTop.hom.FaithfullyFlat := by
rw [RingHom.FaithfullyFlat.iff_flat_and_comap_surjective,
MorphismProperty.arrow_mk_iso_iff @Surjective (arrowIsoSpecΓOfIsAffine f),
MorphismProperty.arrow_mk_iso_iff @Flat (arrowIsoSpecΓOfIsAffine f),
← HasRingHomProperty.Spec_iff (P := @Flat), surjective_iff]
rfl
end Flat
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean | import Mathlib.AlgebraicGeometry.Morphisms.FinitePresentation
import Mathlib.AlgebraicGeometry.Morphisms.Flat
import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
import Mathlib.RingTheory.Spectrum.Prime.Chevalley
/-!
# Universally open morphism
A morphism of schemes `f : X ⟶ Y` is universally open if `X ×[Y] Y' ⟶ Y'` is an open map
for all base change `Y' ⟶ Y`.
We show that being universally open is local at the target, and is stable under compositions and
base changes.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
open CategoryTheory.MorphismProperty
/-- A morphism of schemes `f : X ⟶ Y` is universally open if the base change `X ×[Y] Y' ⟶ Y'`
along any morphism `Y' ⟶ Y` is (topologically) an open map.
-/
@[mk_iff]
class UniversallyOpen (f : X ⟶ Y) : Prop where
out : universally (topologically @IsOpenMap) f
lemma Scheme.Hom.isOpenMap {X Y : Scheme} (f : X ⟶ Y) [UniversallyOpen f] :
IsOpenMap f := UniversallyOpen.out _ _ _ IsPullback.of_id_snd
namespace UniversallyOpen
theorem eq : @UniversallyOpen = universally (topologically @IsOpenMap) := by
ext X Y f; rw [universallyOpen_iff]
instance (priority := 900) [IsOpenImmersion f] : UniversallyOpen f := by
rw [eq]
intro X' Y' i₁ i₂ f' hf
have hf' : IsOpenImmersion f' := MorphismProperty.of_isPullback hf.flip inferInstance
exact f'.isOpenEmbedding.isOpenMap
instance : RespectsIso @UniversallyOpen :=
eq.symm ▸ inferInstance
instance : IsStableUnderBaseChange @UniversallyOpen :=
eq.symm ▸ inferInstance
instance : IsStableUnderComposition (topologically @IsOpenMap) where
comp_mem f g hf hg := IsOpenMap.comp (f := f) (g := g) hg hf
instance : IsStableUnderComposition @UniversallyOpen := by
rw [eq]
infer_instance
instance {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : UniversallyOpen f] [hg : UniversallyOpen g] : UniversallyOpen (f ≫ g) :=
comp_mem _ _ _ hf hg
instance : MorphismProperty.IsMultiplicative @UniversallyOpen where
id_mem _ := inferInstance
instance fst {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hg : UniversallyOpen g] :
UniversallyOpen (pullback.fst f g) :=
MorphismProperty.pullback_fst f g hg
instance snd {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hf : UniversallyOpen f] :
UniversallyOpen (pullback.snd f g) :=
MorphismProperty.pullback_snd f g hf
instance : IsZariskiLocalAtTarget @UniversallyOpen := by
rw [eq]
apply universally_isZariskiLocalAtTarget
intro X Y f ι U hU H
simp_rw [topologically, morphismRestrict_base] at H
exact hU.isOpenMap_iff_restrictPreimage.mpr H
instance : IsZariskiLocalAtSource @UniversallyOpen := by
rw [eq]
exact universally_isZariskiLocalAtSource _
end UniversallyOpen
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A generalizing morphism, locally of finite presentation is open. -/
@[stacks 01U1]
lemma isOpenMap_of_generalizingMap [LocallyOfFinitePresentation f]
(hf : GeneralizingMap f) : IsOpenMap f := by
change topologically IsOpenMap f
wlog hY : ∃ R, Y = Spec R
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := topologically IsOpenMap) Y.affineCover]
intro i
dsimp only [Scheme.Cover.pullbackHom]
refine this _ ?_ ⟨_, rfl⟩
exact IsZariskiLocalAtTarget.of_isPullback (P := topologically GeneralizingMap)
(iY := Y.affineCover.f i) (IsPullback.of_hasPullback ..) hf
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := topologically IsOpenMap) X.affineCover]
intro i
refine this f _ _ ?_ ⟨_, rfl⟩
exact IsZariskiLocalAtSource.comp (P := topologically GeneralizingMap) hf _
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
algebraize [φ.hom]
convert PrimeSpectrum.isOpenMap_comap_of_hasGoingDown_of_finitePresentation
· rwa [Algebra.HasGoingDown.iff_generalizingMap_primeSpectrumComap]
· apply (HasRingHomProperty.Spec_iff (P := @LocallyOfFinitePresentation)).mp inferInstance
/-- Any flat morphism is generalizing. -/
lemma Flat.generalizingMap [Flat f] : GeneralizingMap f := by
have := HasRingHomProperty.of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget.{u}
(topologically GeneralizingMap)
change topologically GeneralizingMap f
rw [HasRingHomProperty.iff_appLE (P := topologically GeneralizingMap)]
intro U V e
algebraize [(f.appLE U V e).hom]
apply Algebra.HasGoingDown.iff_generalizingMap_primeSpectrumComap.mp
convert Algebra.HasGoingDown.of_flat
exact HasRingHomProperty.appLE @Flat f ‹_› U V e
/-- A flat morphism, locally of finite presentation is universally open. -/
@[stacks 01UA]
instance (priority := low) UniversallyOpen.of_flat [Flat f] [LocallyOfFinitePresentation f] :
UniversallyOpen f :=
⟨universally_mk' _ _ fun _ _ ↦ isOpenMap_of_generalizingMap _ (Flat.generalizingMap _)⟩
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Integral.lean | import Mathlib.AlgebraicGeometry.Morphisms.Separated
import Mathlib.AlgebraicGeometry.Morphisms.UniversallyClosed
import Mathlib.RingTheory.RingHom.Integral
/-!
# Integral morphisms of schemes
A morphism of schemes `f : X ⟶ Y` is integral if the preimage
of an arbitrary affine open subset of `Y` is affine and the induced ring map is integral.
It is equivalent to ask only that `Y` is covered by affine opens whose preimage is affine
and the induced ring map is integral.
-/
universe v u
open CategoryTheory TopologicalSpace Opposite MorphismProperty
namespace AlgebraicGeometry
/-- A morphism of schemes `X ⟶ Y` is integral if the preimage of any affine open subset of `Y` is
affine and the induced ring hom on sections is integral. -/
@[mk_iff]
class IsIntegralHom {X Y : Scheme} (f : X ⟶ Y) : Prop extends IsAffineHom f where
isIntegral_app (f) (U : Y.Opens) (hU : IsAffineOpen U) : (f.app U).hom.IsIntegral
@[deprecated (since := "2025-10-15")]
alias IsIntegralHom.integral_app := IsIntegralHom.isIntegral_app
alias Scheme.Hom.isIntegral_app := IsIntegralHom.isIntegral_app
namespace IsIntegralHom
variable {X Y Z S : Scheme.{u}}
instance hasAffineProperty : HasAffineProperty @IsIntegralHom
fun X _ f _ ↦ IsAffine X ∧ RingHom.IsIntegral (f.app ⊤).hom := by
change HasAffineProperty @IsIntegralHom (affineAnd RingHom.IsIntegral)
rw [HasAffineProperty.affineAnd_iff _ RingHom.isIntegral_respectsIso
RingHom.isIntegral_isStableUnderBaseChange.localizationPreserves.away
RingHom.isIntegral_ofLocalizationSpan]
simp [isIntegralHom_iff]
instance : IsStableUnderComposition @IsIntegralHom :=
HasAffineProperty.affineAnd_isStableUnderComposition (Q := RingHom.IsIntegral) hasAffineProperty
RingHom.isIntegral_stableUnderComposition
instance : IsStableUnderBaseChange @IsIntegralHom :=
HasAffineProperty.affineAnd_isStableUnderBaseChange (Q := RingHom.IsIntegral) hasAffineProperty
RingHom.isIntegral_respectsIso RingHom.isIntegral_isStableUnderBaseChange
instance (priority := low) (f : X ⟶ Y) [IsClosedImmersion f] : IsIntegralHom f where
isIntegral_app U hU := (RingHom.Finite.of_surjective _ (f.app_surjective U hU)).to_isIntegral
instance : IsMultiplicative @IsIntegralHom where
id_mem _ := inferInstance
instance (f : X ⟶ Y) (g : Y ⟶ Z) [IsIntegralHom f] [IsIntegralHom g] : IsIntegralHom (f ≫ g) :=
MorphismProperty.comp_mem _ _ _ ‹_› ‹_›
instance (f : X ⟶ S) (g : Y ⟶ S) [IsIntegralHom g] : IsIntegralHom (Limits.pullback.fst f g) :=
MorphismProperty.pullback_fst f g inferInstance
instance (f : X ⟶ S) (g : Y ⟶ S) [IsIntegralHom f] : IsIntegralHom (Limits.pullback.snd f g) :=
MorphismProperty.pullback_snd f g inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [IsIntegralHom f] : IsIntegralHom (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance : MorphismProperty.HasOfPostcompProperty @IsIntegralHom @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsIntegralHom _)
lemma of_comp (f : X ⟶ Y) (g : Y ⟶ Z) [IsIntegralHom (f ≫ g)] [IsSeparated g] :
IsIntegralHom f := MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
lemma comp_iff {f : X ⟶ Y} {g : Y ⟶ Z} [IsIntegralHom g] :
IsIntegralHom (f ≫ g) ↔ IsIntegralHom f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
lemma SpecMap_iff {R S : CommRingCat} {φ : R ⟶ S} :
IsIntegralHom (Spec.map φ) ↔ φ.hom.IsIntegral := by
have := RingHom.toMorphismProperty_respectsIso_iff.mp RingHom.isIntegral_respectsIso
rw [HasAffineProperty.iff_of_isAffine (P := @IsIntegralHom), and_iff_right]
exacts [MorphismProperty.arrow_mk_iso_iff (RingHom.toMorphismProperty RingHom.IsIntegral)
(arrowIsoΓSpecOfIsAffine φ).symm, inferInstance]
instance : IsMultiplicative @IsIntegralHom where
instance (priority := 100) (f : X ⟶ Y) [IsIntegralHom f] :
UniversallyClosed f := by
revert X Y f ‹IsIntegralHom f›
rw [universallyClosed_eq, ← IsStableUnderBaseChange.universally_eq (P := @IsIntegralHom)]
apply universally_mono
intro X Y f
wlog hY : ∃ R, Y = Spec R generalizing X Y
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsIntegralHom) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := topologically _) Y.affineCover]
exact fun a i ↦ this _ ⟨_, rfl⟩ (a i)
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S generalizing X
· intro H
have inst : IsAffine X := isAffine_of_isAffineHom f
rw [← cancel_left_of_respectsIso (P := topologically _) X.isoSpec.inv]
rw [← cancel_left_of_respectsIso (P := @IsIntegralHom) X.isoSpec.inv] at H
exact this _ ⟨_, rfl⟩ H
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [SpecMap_iff]
exact PrimeSpectrum.isClosedMap_comap_of_isIntegral _
lemma iff_universallyClosed_and_isAffineHom {X Y : Scheme.{u}} {f : X ⟶ Y} :
IsIntegralHom f ↔ UniversallyClosed f ∧ IsAffineHom f := by
refine ⟨fun _ ↦ ⟨inferInstance, inferInstance⟩, fun ⟨H₁, H₂⟩ ↦ ?_⟩
clear * -
wlog hY : ∃ R, Y = Spec R
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsIntegralHom) Y.affineCover]
rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @UniversallyClosed) Y.affineCover] at H₁
rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsAffineHom) Y.affineCover] at H₂
exact fun _ ↦ this inferInstance inferInstance ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S
· have inst : IsAffine X := isAffine_of_isAffineHom f
rw [← cancel_left_of_respectsIso (P := @IsIntegralHom) X.isoSpec.inv]
exact this _ inferInstance inferInstance ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ : ∃ φ, Spec.map φ = f := ⟨_, Spec.map_preimage _⟩
rw [SpecMap_iff]
apply PrimeSpectrum.isIntegral_of_isClosedMap_comap_mapRingHom
algebraize [φ.1, Polynomial.mapRingHom φ.1]
haveI : IsScalarTower R (Polynomial R) (Polynomial S) :=
.of_algebraMap_eq' (Polynomial.mapRingHom_comp_C _).symm
refine H₁.out (Spec.map (CommRingCat.ofHom Polynomial.C))
(Spec.map (CommRingCat.ofHom Polynomial.C)) (Spec.map _)
(isPullback_SpecMap_of_isPushout _ _ _ _
(CommRingCat.isPushout_of_isPushout R S (Polynomial R) (Polynomial S))).flip
lemma eq_universallyClosed_inf_isAffineHom :
@IsIntegralHom = (@UniversallyClosed ⊓ @IsAffineHom : MorphismProperty Scheme) := by
ext
exact iff_universallyClosed_and_isAffineHom
end IsIntegralHom
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean | import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
/-!
# Open immersions
A morphism is an open immersion if the underlying map of spaces is an open embedding
`f : X ⟶ U ⊆ Y`, and the sheaf map `Y(V) ⟶ f _* X(V)` is an iso for each `V ⊆ U`.
Most of the theories are developed in `AlgebraicGeometry/OpenImmersion`, and we provide the
remaining theorems analogous to other lemmas in `AlgebraicGeometry/Morphisms/*`.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace Topology
universe u
namespace AlgebraicGeometry
/-- `Spec (R ⧸ I) ⟶ Spec R` is an open immersion iff `I` is generated by an idempotent. -/
lemma isOpenImmersion_SpecMap_iff_of_surjective {R S : CommRingCat}
(f : R ⟶ S) (hf : Function.Surjective f.hom) :
IsOpenImmersion (Spec.map f) ↔
∃ e, IsIdempotentElem e ∧ RingHom.ker f.hom = Ideal.span {e} := by
constructor
· intro H
obtain ⟨e, he, he'⟩ := PrimeSpectrum.isClopen_iff_zeroLocus.mp
⟨PrimeSpectrum.isClosed_range_comap_of_surjective _ _ hf,
(Spec.map f).isOpenEmbedding.isOpen_range⟩
refine ⟨e, he, ?_⟩
let φ : R ⟶ _ := (CommRingCat.ofHom (Ideal.Quotient.mk (.span {e})))
have : IsOpenImmersion (Spec.map φ) :=
have : IsLocalization.Away (1 - e) (↑R ⧸ Ideal.span {e}) :=
IsLocalization.away_of_isIdempotentElem he.one_sub (by simp) Ideal.Quotient.mk_surjective
IsOpenImmersion.of_isLocalization (1 - e)
have H : Set.range (Spec.map φ) = Set.range (Spec.map f) :=
((PrimeSpectrum.range_comap_of_surjective _ _
Ideal.Quotient.mk_surjective).trans (by simp)).trans he'.symm
let i : S ≅ .of _ := (Scheme.Spec.preimageIso
(IsOpenImmersion.isoOfRangeEq (Spec.map φ) (Spec.map f) H)).unop
have hi : Function.Injective i.inv.hom := (ConcreteCategory.bijective_of_isIso i.inv).1
have : f = φ ≫ i.inv := by apply Spec.map_injective; simp [i, ← Scheme.Spec_map]
rw [this, CommRingCat.hom_comp, RingHom.ker_eq_comap_bot, ← Ideal.comap_comap,
← RingHom.ker_eq_comap_bot, (RingHom.injective_iff_ker_eq_bot i.inv.hom).mp hi,
← RingHom.ker_eq_comap_bot]
simp [φ]
· rintro ⟨e, he, he'⟩
letI := f.hom.toAlgebra
have : IsLocalization.Away (1 - e) S :=
IsLocalization.away_of_isIdempotentElem he.one_sub (by simpa using he') hf
exact IsOpenImmersion.of_isLocalization (1 - e)
variable {X Y : Scheme.{u}}
theorem isOpenImmersion_iff_stalk {f : X ⟶ Y} : IsOpenImmersion f ↔
IsOpenEmbedding f ∧ ∀ x, IsIso (f.stalkMap x) := IsOpenImmersion.iff_isIso_stalkMap f
theorem IsOpenImmersion.of_openCover_source (f : X ⟶ Y)
(𝒰 : X.OpenCover) (hf : Function.Injective f) (h𝒰 : ∀ i, IsOpenImmersion (𝒰.f i ≫ f)) :
IsOpenImmersion f := by
refine isOpenImmersion_iff_stalk.mpr ⟨.of_continuous_injective_isOpenMap f.continuous hf ?_, ?_⟩
· intro U hU
convert (⨆ i, ((𝒰.f i ≫ f) ''ᵁ (𝒰.f i ⁻¹ᵁ ⟨U, hU⟩))).2
ext x
exact ⟨fun ⟨x, _, _⟩ ↦ by have := 𝒰.exists_eq x; simp; grind, by simp; grind⟩
· intro x
obtain ⟨i, x, rfl⟩ := 𝒰.exists_eq x
rw [← (IsIso.comp_inv_eq _).mpr (Scheme.Hom.stalkMap_comp (𝒰.f i) f x)]
infer_instance
lemma IsOpenImmersion.of_forall_source_exists (f : X ⟶ Y)
(hf : Function.Injective f)
(hX : ∀ x, ∃ (U : Scheme) (i : U ⟶ X) (_ : IsOpenImmersion i),
x ∈ i.opensRange ∧ IsOpenImmersion (i ≫ f)) :
IsOpenImmersion f := by
choose U i _ hxi hi using hX
let 𝒰 : X.OpenCover := ⟨⟨X, U, i⟩,
⟨by simpa using show ∀ x, ∃ j y, i j y = x from (⟨_, hxi ·⟩), by simpa⟩⟩
exact IsOpenImmersion.of_openCover_source f 𝒰 hf hi
theorem isOpenImmersion_eq_inf :
@IsOpenImmersion = (topologically IsOpenEmbedding) ⊓
stalkwise (fun f ↦ Function.Bijective f) := by
ext
exact isOpenImmersion_iff_stalk.trans
(and_congr Iff.rfl (forall_congr' fun x ↦ ConcreteCategory.isIso_iff_bijective _))
instance : IsZariskiLocalAtTarget (stalkwise (fun f ↦ Function.Bijective f)) := by
apply stalkwiseIsZariskiLocalAtTarget_of_respectsIso
rw [RingHom.toMorphismProperty_respectsIso_iff]
convert (inferInstanceAs (MorphismProperty.isomorphisms CommRingCat).RespectsIso)
ext
exact (ConcreteCategory.isIso_iff_bijective _).symm
instance isOpenImmersion_isZariskiLocalAtTarget : IsZariskiLocalAtTarget @IsOpenImmersion :=
isOpenImmersion_eq_inf ▸ inferInstance
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Separated.lean | import Mathlib.AlgebraicGeometry.Morphisms.ClosedImmersion
import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic
import Mathlib.CategoryTheory.Limits.Constructions.Over.Products
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Equalizer
/-!
# Separated morphisms
A morphism of schemes is separated if its diagonal morphism is a closed immersion.
## Main definitions
- `AlgebraicGeometry.IsSeparated`: The class of separated morphisms.
- `AlgebraicGeometry.Scheme.IsSeparated`: The class of separated schemes.
- `AlgebraicGeometry.IsSeparated.hasAffineProperty`:
A morphism is separated iff the preimage of affine opens are separated schemes.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {W X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism is separated if the diagonal map is a closed immersion. -/
@[mk_iff]
class IsSeparated : Prop where
/-- A morphism is separated if the diagonal map is a closed immersion. -/
diagonal_isClosedImmersion : IsClosedImmersion (pullback.diagonal f) := by infer_instance
namespace IsSeparated
attribute [instance] diagonal_isClosedImmersion
theorem isSeparated_eq_diagonal_isClosedImmersion :
@IsSeparated = MorphismProperty.diagonal @IsClosedImmersion := by
ext
exact isSeparated_iff _
/-- Monomorphisms are separated. -/
instance (priority := 900) isSeparated_of_mono [Mono f] : IsSeparated f where
instance : MorphismProperty.RespectsIso @IsSeparated := by
rw [isSeparated_eq_diagonal_isClosedImmersion]
infer_instance
instance (priority := 900) [IsSeparated f] : QuasiSeparated f where
instance stableUnderComposition : MorphismProperty.IsStableUnderComposition @IsSeparated := by
rw [isSeparated_eq_diagonal_isClosedImmersion]
infer_instance
instance [IsSeparated f] [IsSeparated g] : IsSeparated (f ≫ g) :=
stableUnderComposition.comp_mem f g inferInstance inferInstance
instance : MorphismProperty.IsMultiplicative @IsSeparated where
id_mem _ := inferInstance
instance isStableUnderBaseChange : MorphismProperty.IsStableUnderBaseChange @IsSeparated := by
rw [isSeparated_eq_diagonal_isClosedImmersion]
infer_instance
instance : IsZariskiLocalAtTarget @IsSeparated := by
rw [isSeparated_eq_diagonal_isClosedImmersion]
infer_instance
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsSeparated g] :
IsSeparated (pullback.fst f g) :=
MorphismProperty.pullback_fst f g inferInstance
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsSeparated f] :
IsSeparated (pullback.snd f g) :=
MorphismProperty.pullback_snd f g inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [IsSeparated f] : IsSeparated (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [IsSeparated f] :
IsSeparated (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
instance (R S : CommRingCat.{u}) (f : R ⟶ S) : IsSeparated (Spec.map f) := by
constructor
letI := f.hom.toAlgebra
change IsClosedImmersion
(Limits.pullback.diagonal (Spec.map (CommRingCat.ofHom (algebraMap R S))))
rw [diagonal_SpecMap, MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion]
exact .spec_of_surjective _ fun x ↦ ⟨.tmul R 1 x,
(Algebra.TensorProduct.lmul'_apply_tmul (R := R) (S := S) 1 x).trans (one_mul x)⟩
@[instance 100]
lemma of_isAffineHom [h : IsAffineHom f] : IsSeparated f := by
wlog hY : IsAffine Y
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := @IsSeparated) _
(iSup_affineOpens_eq_top Y)]
intro U
have H : IsAffineHom (f ∣_ U) := IsZariskiLocalAtTarget.restrict h U
exact this _ U.2
have : IsAffine X := HasAffineProperty.iff_of_isAffine.mp h
rw [MorphismProperty.arrow_mk_iso_iff @IsSeparated (arrowIsoSpecΓOfIsAffine f)]
infer_instance
instance {S T : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) (i : S ⟶ T) [IsSeparated i] :
IsClosedImmersion (pullback.mapDesc f g i) :=
MorphismProperty.of_isPullback (pullback_map_diagonal_isPullback f g i)
inferInstance
/-- Given `f : X ⟶ Y` and `g : Y ⟶ Z` such that `g` is separated, the induced map
`X ⟶ X ×[Z] Y` is a closed immersion. -/
instance [IsSeparated g] :
IsClosedImmersion (pullback.lift (𝟙 _) f (Category.id_comp (f ≫ g))) := by
rw [← MorphismProperty.cancel_left_of_respectsIso @IsClosedImmersion (pullback.fst f (𝟙 Y))]
rw [← MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion _
(pullback.congrHom rfl (Category.id_comp g)).inv]
convert (inferInstanceAs <| IsClosedImmersion (pullback.mapDesc f (𝟙 _) g)) using 1
ext : 1 <;> simp [pullback.condition]
end IsSeparated
section of_injective
open Scheme Pullback
variable (𝒰 : Y.OpenCover) (𝒱 : ∀ i, (pullback f (𝒰.f i)).OpenCover)
lemma Scheme.Pullback.diagonalCoverDiagonalRange_eq_top_of_injective
(hf : Function.Injective f) :
diagonalCoverDiagonalRange f 𝒰 𝒱 = ⊤ := by
rw [← top_le_iff]
rintro x -
simp only [diagonalCoverDiagonalRange, openCoverOfBase_I₀, openCoverOfBase_X,
openCoverOfLeftRight_I₀, Opens.iSup_mk, Opens.carrier_eq_coe, Hom.coe_opensRange, Opens.coe_mk,
Set.mem_iUnion, Set.mem_range, Sigma.exists]
have H : pullback.fst f f x = pullback.snd f f x :=
hf (by rw [← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply, pullback.condition])
let i := 𝒰.idx (f (pullback.fst f f x))
obtain ⟨y : 𝒰.X i, hy : 𝒰.f i y = f _⟩ :=
𝒰.covers (f (pullback.fst f f x))
obtain ⟨z, hz₁, hz₂⟩ := exists_preimage_pullback _ _ hy.symm
let j := (𝒱 i).idx z
obtain ⟨w : (𝒱 i).X j, hy : (𝒱 i).f j w = z⟩ := (𝒱 i).covers z
refine ⟨i, j, ?_⟩
simp_rw [diagonalCover_map]
change x ∈ Set.range _
simp only [diagonalCover, openCoverOfBase_I₀,
Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover, PreZeroHypercover.pullback₁_X,
Precoverage.ZeroHypercover.bind_toPreZeroHypercover, openCoverOfBase_X,
PreZeroHypercover.bind_X, openCoverOfLeftRight_I₀, openCoverOfLeftRight_X]
rw [range_map]
simp [← H, ← hz₁, ← hy]
lemma Scheme.Pullback.range_diagonal_subset_diagonalCoverDiagonalRange :
Set.range (pullback.diagonal f) ⊆ diagonalCoverDiagonalRange f 𝒰 𝒱 := by
rintro _ ⟨x, rfl⟩
simp only [diagonalCoverDiagonalRange, openCoverOfBase_I₀, openCoverOfBase_X,
openCoverOfLeftRight_I₀, Opens.iSup_mk, Opens.carrier_eq_coe, Hom.coe_opensRange, Opens.coe_mk,
Set.mem_iUnion, Set.mem_range, Sigma.exists]
let i := 𝒰.idx (f x)
obtain ⟨y : 𝒰.X i, hy : 𝒰.f i y = f x⟩ := 𝒰.covers (f x)
obtain ⟨z, hz₁, hz₂⟩ := exists_preimage_pullback _ _ hy.symm
let j := (𝒱 i).idx z
obtain ⟨w : (𝒱 i).X j, hy : (𝒱 i).f j w = z⟩ := (𝒱 i).covers z
refine ⟨i, j, pullback.diagonal ((𝒱 i).f j ≫ pullback.snd f (𝒰.f i)) w, ?_⟩
rw [← hz₁, ← hy, ← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply]
simp only [diagonalCover, openCoverOfBase_I₀,
Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover, PreZeroHypercover.pullback₁_X,
Cover.pullbackHom, Precoverage.ZeroHypercover.bind_toPreZeroHypercover, openCoverOfBase_X,
PreZeroHypercover.bind_X, openCoverOfLeftRight_I₀, openCoverOfLeftRight_X,
PreZeroHypercover.bind_f, openCoverOfLeftRight_f, openCoverOfBase_f, Hom.comp_base,
TopCat.hom_comp, ContinuousMap.comp_apply, ContinuousMap.comp_assoc]
simp_rw [← Scheme.Hom.comp_apply]
congr 5
apply pullback.hom_ext <;> simp
lemma isClosedImmersion_diagonal_restrict_diagonalCoverDiagonalRange
[∀ i, IsAffine (𝒰.X i)] [∀ i j, IsAffine ((𝒱 i).X j)] :
IsClosedImmersion (pullback.diagonal f ∣_ diagonalCoverDiagonalRange f 𝒰 𝒱) := by
let U : (Σ i, (𝒱 i).I₀) → (diagonalCoverDiagonalRange f 𝒰 𝒱).toScheme.Opens := fun i ↦
(diagonalCoverDiagonalRange f 𝒰 𝒱).ι ⁻¹ᵁ ((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange
have hU (i) : (diagonalCoverDiagonalRange f 𝒰 𝒱).ι ''ᵁ U i =
((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange := by
rw [Scheme.Hom.image_preimage_eq_opensRange_inf, inf_eq_right, Opens.opensRange_ι]
exact le_iSup (fun i : Σ i, (𝒱 i).I₀ ↦ ((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange) i
have hf : iSup U = ⊤ := (TopologicalSpace.Opens.map_iSup _ _).symm.trans
(diagonalCoverDiagonalRange f 𝒰 𝒱).ι_preimage_self
rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := @IsClosedImmersion) _ hf]
intro i
rw [MorphismProperty.arrow_mk_iso_iff (P := @IsClosedImmersion) (morphismRestrictRestrict _ _ _),
MorphismProperty.arrow_mk_iso_iff (P := @IsClosedImmersion) (morphismRestrictEq _ (hU i)),
MorphismProperty.arrow_mk_iso_iff (P := @IsClosedImmersion) (diagonalRestrictIsoDiagonal ..)]
infer_instance
@[stacks 0DVA]
lemma isSeparated_of_injective (hf : Function.Injective f) :
IsSeparated f := by
constructor
let 𝒰 := Y.affineCover
let 𝒱 (i) := (pullback f (𝒰.f i)).affineCover
refine IsZariskiLocalAtTarget.of_iSup_eq_top (fun i : PUnit.{0} ↦ ⊤) (by simp) fun _ ↦ ?_
rw [← diagonalCoverDiagonalRange_eq_top_of_injective f 𝒰 𝒱 hf]
exact isClosedImmersion_diagonal_restrict_diagonalCoverDiagonalRange f 𝒰 𝒱
end of_injective
instance : MorphismProperty.HasOfPostcompProperty @IsClosedImmersion @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsClosedImmersion _)
lemma IsClosedImmersion.of_comp [IsClosedImmersion (f ≫ g)] [IsSeparated g] :
IsClosedImmersion f := MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
variable {f g} in
lemma IsClosedImmersion.comp_iff [IsClosedImmersion g] :
IsClosedImmersion (f ≫ g) ↔ IsClosedImmersion f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
instance {I J : X.IdealSheafData} (h : I ≤ J) : IsClosedImmersion (I.inclusion h) := by
have : IsClosedImmersion (I.inclusion h ≫ I.subschemeι) := by
simp only [Scheme.IdealSheafData.inclusion_subschemeι]
infer_instance
exact .of_comp _ I.subschemeι
lemma IsSeparated.of_comp [IsSeparated (f ≫ g)] : IsSeparated f := by
have := IsSeparated.diagonal_isClosedImmersion (f := f ≫ g)
rw [pullback.diagonal_comp] at this
exact ⟨@IsClosedImmersion.of_comp _ _ _ _ _ this inferInstance⟩
variable {f g} in
lemma IsSeparated.comp_iff [IsSeparated g] : IsSeparated (f ≫ g) ↔ IsSeparated f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
instance : MorphismProperty.HasOfPostcompProperty @IsSeparated ⊤ where
of_postcomp f g _ _ := .of_comp f g
instance : MorphismProperty.HasOfPostcompProperty @IsAffineHom @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsAffineHom _)
lemma IsAffineHom.of_comp [IsAffineHom (f ≫ g)] [IsSeparated g] :
IsAffineHom f := MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
variable {f g} in
lemma IsAffineHom.comp_iff [IsAffineHom g] : IsAffineHom (f ≫ g) ↔ IsAffineHom f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
@[stacks 01KM]
instance isClosedImmersion_equalizer_ι_left {S : Scheme} {X Y : Over S} [IsSeparated Y.hom]
(f g : X ⟶ Y) : IsClosedImmersion (equalizer.ι f g).left := by
refine MorphismProperty.of_isPullback
((Limits.isPullback_equalizer_prod f g).map (Over.forget _)).flip ?_
rw [← MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion _
(Over.prodLeftIsoPullback Y Y).hom]
convert (inferInstanceAs (IsClosedImmersion (pullback.diagonal Y.hom)))
ext1 <;> simp [← Over.comp_left]
/--
Suppose `X` is a reduced scheme and that `f g : X ⟶ Y` agree over some separated `Y ⟶ Z`.
Then `f = g` if `ι ≫ f = ι ≫ g` for some dominant `ι`.
-/
lemma ext_of_isDominant_of_isSeparated [IsReduced X] {f g : X ⟶ Y}
(s : Y ⟶ Z) [IsSeparated s] (h : f ≫ s = g ≫ s)
(ι : W ⟶ X) [IsDominant ι] (hU : ι ≫ f = ι ≫ g) : f = g := by
let X' : Over Z := Over.mk (f ≫ s)
let Y' : Over Z := Over.mk s
let U' : Over Z := Over.mk (ι ≫ f ≫ s)
let f' : X' ⟶ Y' := Over.homMk f
let g' : X' ⟶ Y' := Over.homMk g
let ι' : U' ⟶ X' := Over.homMk ι
have : IsSeparated Y'.hom := ‹_›
have : IsDominant (equalizer.ι f' g').left := by
apply (config := { allowSynthFailures := true }) IsDominant.of_comp (equalizer.lift ι' ?_).left
· rwa [← Over.comp_left, equalizer.lift_ι]
· ext1; exact hU
have : Surjective (equalizer.ι f' g').left :=
surjective_of_isDominant_of_isClosed_range _ IsClosedImmersion.base_closed.2
have := isIso_of_isClosedImmersion_of_surjective (Y := X) (equalizer.ι f' g').left
rw [← cancel_epi (equalizer.ι f' g').left]
exact congr($(equalizer.condition f' g').left)
variable (S) in
/--
Suppose `X` is a reduced `S`-scheme and `Y` is a separated `S`-scheme.
For any `S`-morphisms `f g : X ⟶ Y`, `f = g` if `ι ≫ f = ι ≫ g` for some dominant `ι`.
-/
lemma ext_of_isDominant_of_isSeparated' [X.Over S] [Y.Over S] [IsReduced X] [IsSeparated (Y ↘ S)]
{f g : X ⟶ Y} [f.IsOver S] [g.IsOver S] {W} (ι : W ⟶ X) [IsDominant ι]
(hU : ι ≫ f = ι ≫ g) : f = g :=
ext_of_isDominant_of_isSeparated (Y ↘ S) (by simp) ι hU
namespace Scheme
/-- A scheme `X` is separated if it is separated over `⊤_ Scheme`. -/
@[mk_iff]
protected class IsSeparated (X : Scheme.{u}) : Prop where
isSeparated_terminal_from : IsSeparated (terminal.from X)
attribute [instance] IsSeparated.isSeparated_terminal_from
lemma isSeparated_iff_isClosedImmersion_prod_lift {X : Scheme.{u}} :
X.IsSeparated ↔ IsClosedImmersion (prod.lift (𝟙 X) (𝟙 X)) := by
rw [isSeparated_iff, AlgebraicGeometry.isSeparated_iff, iff_iff_eq,
← MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion _ (prodIsoPullback X X).hom]
congr
ext : 1 <;> simp
instance [X.IsSeparated] : IsClosedImmersion (prod.lift (𝟙 X) (𝟙 X)) := by
rwa [← isSeparated_iff_isClosedImmersion_prod_lift]
instance (priority := 900) {X : Scheme.{u}} [IsAffine X] : X.IsSeparated := ⟨inferInstance⟩
instance (priority := low) {X : Scheme.{u}} [X.IsSeparated] : QuasiSeparatedSpace X :=
quasiSeparatedSpace_of_quasiSeparated (terminal.from X)
instance (priority := 900) [X.IsSeparated] : IsSeparated f := by
apply (config := { allowSynthFailures := true }) @IsSeparated.of_comp (g := terminal.from Y)
rw [terminal.comp_from]
infer_instance
instance (f g : X ⟶ Y) [Y.IsSeparated] : IsClosedImmersion (Limits.equalizer.ι f g) :=
MorphismProperty.of_isPullback (isPullback_equalizer_prod f g).flip inferInstance
end Scheme
instance IsSeparated.hasAffineProperty :
HasAffineProperty @IsSeparated fun X _ _ _ ↦ X.IsSeparated := by
convert HasAffineProperty.of_isZariskiLocalAtTarget @IsSeparated with X Y f hY
rw [Scheme.isSeparated_iff, ← terminal.comp_from f, IsSeparated.comp_iff]
rfl
/--
Suppose `f g : X ⟶ Y` where `X` is a reduced scheme and `Y` is a separated scheme.
Then `f = g` if `ι ≫ f = ι ≫ g` for some dominant `ι`.
Also see `ext_of_isDominant_of_isSeparated` for the general version over arbitrary bases.
-/
lemma ext_of_isDominant [IsReduced X] {f g : X ⟶ Y} [Y.IsSeparated]
(ι : W ⟶ X) [IsDominant ι] (hU : ι ≫ f = ι ≫ g) : f = g :=
ext_of_isDominant_of_isSeparated (Limits.terminal.from _) (Limits.terminal.hom_ext _ _) ι hU
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean | import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
import Mathlib.Topology.Spectral.Hom
import Mathlib.AlgebraicGeometry.Limits
/-!
# Quasi-compact morphisms
A morphism of schemes is quasi-compact if the preimages of quasi-compact open sets are
quasi-compact.
It suffices to check that preimages of affine open sets are compact
(`quasiCompact_iff_forall_isAffineOpen`).
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/--
A morphism is "quasi-compact" if the underlying map of topological spaces is, i.e. if the preimages
of quasi-compact open sets are quasi-compact.
-/
@[mk_iff]
class QuasiCompact (f : X ⟶ Y) : Prop where
/-- The preimage of a compact open set under a quasi-compact morphism between schemes is
compact. -/
isCompact_preimage : ∀ U : Set Y, IsOpen U → IsCompact U → IsCompact (f ⁻¹' U)
variable {f} in
theorem quasiCompact_iff_isSpectralMap : QuasiCompact f ↔ IsSpectralMap f :=
⟨fun ⟨h⟩ => ⟨by fun_prop, h⟩, fun h => ⟨h.2⟩⟩
theorem Scheme.Hom.isSpectralMap [QuasiCompact f] : IsSpectralMap f := by
rwa [← quasiCompact_iff_isSpectralMap]
@[deprecated (since := "2025-10-07")]
alias quasiCompact_iff_spectral := quasiCompact_iff_isSpectralMap
instance (priority := 900) quasiCompact_of_isIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
QuasiCompact f := by
constructor
intro U _ hU'
convert hU'.image (inv f.base).hom.continuous_toFun using 1
rw [Set.image_eq_preimage_of_inverse]
· delta Function.LeftInverse
exact IsIso.inv_hom_id_apply f.base
· exact IsIso.hom_inv_id_apply f.base
instance quasiCompact_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
[QuasiCompact g] : QuasiCompact (f ≫ g) := by
constructor
intro U hU hU'
rw [Scheme.Hom.comp_base, TopCat.coe_comp, Set.preimage_comp]
apply QuasiCompact.isCompact_preimage
· exact Continuous.isOpen_preimage (by fun_prop) _ hU
apply QuasiCompact.isCompact_preimage <;> assumption
theorem isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens {U : Set X} :
IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ i ∈ s, i := by
apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
(fun (U : X.affineOpens) => (U : X.Opens))
· rw [Subtype.range_coe]; exact X.isBasis_affineOpens
· exact fun i => i.2.isCompact
@[deprecated (since := "2025-10-14")]
alias isCompactOpen_iff_eq_finset_affine_union :=
isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens
theorem isCompact_iff_finite_and_eq_biUnion_affineOpens {U : X.Opens} :
IsCompact (X := X) U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⨆ i ∈ s, (i : X.Opens) := by
convert isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens (U := U.1) using 4 with s
· simp [U.isOpen]
· convert SetLike.coe_injective.eq_iff.symm; simp
theorem isCompact_and_isOpen_iff_finite_and_eq_biUnion_basicOpen [IsAffine X] {U : Set X} :
IsCompact U ∧ IsOpen U ↔ ∃ s : Set Γ(X, ⊤), s.Finite ∧ U = ⋃ i ∈ s, X.basicOpen i :=
(isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _
(fun _ => ((isAffineOpen_top _).basicOpen _).isCompact) _
@[deprecated (since := "2025-10-14")]
alias isCompactOpen_iff_eq_basicOpen_union :=
isCompact_and_isOpen_iff_finite_and_eq_biUnion_basicOpen
variable {f} in
theorem quasiCompact_iff_forall_isAffineOpen :
QuasiCompact f ↔ ∀ U : Y.Opens, IsAffineOpen U → IsCompact (f ⁻¹ᵁ U : Set X) := by
rw [quasiCompact_iff]
refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩
intro H U hU hU'
obtain ⟨S, hS, rfl⟩ := isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens.mp ⟨hU', hU⟩
simp only [Set.preimage_iUnion]
exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop)
@[deprecated (since := "2025-10-14")]
alias quasiCompact_iff_forall_affine := quasiCompact_iff_forall_isAffineOpen
theorem isCompact_basicOpen (X : Scheme) {U : X.Opens} (hU : IsCompact (U : Set X))
(f : Γ(X, U)) : IsCompact (X.basicOpen f : Set X) := by
classical
refine isCompact_iff_finite_and_eq_biUnion_affineOpens.mpr ?_
obtain ⟨s, hs, e⟩ := isCompact_iff_finite_and_eq_biUnion_affineOpens.mp hU
let g : s → X.affineOpens := fun V ↦ ⟨V.1 ⊓ X.basicOpen f, by
rw [← X.basicOpen_res _ (homOfLE ((le_iSup₂ V.1 V.2).trans_eq e.symm)).op]
exact V.1.2.basicOpen _⟩
haveI : Finite s := hs.to_subtype
refine ⟨Set.range g, Set.finite_range g, ?_⟩
rw [iSup_range, ← iSup_inf_eq, iSup_subtype, ← e, inf_eq_right.mpr (X.basicOpen_le f)]
instance : HasAffineProperty @QuasiCompact (fun X _ _ _ ↦ CompactSpace X) where
eq_targetAffineLocally' := by
ext X Y f
simp only [quasiCompact_iff_forall_isAffineOpen, isCompact_iff_compactSpace,
targetAffineLocally, Subtype.forall]
rfl
isLocal_affineProperty := by
constructor
· apply AffineTargetMorphismProperty.respectsIso_mk <;> rintro X Y Z e _ _ H
exacts [@Homeomorph.compactSpace _ _ _ _ H (TopCat.homeoOfIso (asIso e.inv.base)), H]
· introv _ H
rw [Scheme.preimage_basicOpen f r]
exact (isCompact_iff_compactSpace.mp (isCompact_basicOpen _ isCompact_univ _))
· rintro X Y H f S hS hS'
rw [← (isAffineOpen_top _).iSup_basicOpen_eq_self_iff] at hS
rw [← isCompact_univ_iff, ← Opens.coe_top, ← f.preimage_top, ← hS, Scheme.Hom.preimage_iSup,
Opens.iSup_mk, Opens.coe_mk]
exact isCompact_iUnion fun i => isCompact_iff_compactSpace.mpr (hS' i)
theorem compactSpace_iff_quasiCompact (X : Scheme) :
CompactSpace X ↔ QuasiCompact (terminal.from X) := by
rw [HasAffineProperty.iff_of_isAffine (P := @QuasiCompact)]
instance {X : Scheme} [CompactSpace X] : QuasiCompact X.toSpecΓ :=
HasAffineProperty.iff_of_isAffine.mpr ‹_›
/-
A quasi-compact scheme over quasi-compact base is also quasi-compact as a topological space.
For the coverse, see `quasiCompact_of_compactSpace` for the fact that
a (topologically) quasi-compact scheme is quasi-compact over a base if the base is quasi-separated.
-/
lemma QuasiCompact.compactSpace_of_compactSpace {X Y : Scheme.{u}} (f : X ⟶ Y) [QuasiCompact f]
[CompactSpace Y] : CompactSpace X := by
constructor
rw [← Set.preimage_univ (f := f)]
exact QuasiCompact.isCompact_preimage _ isOpen_univ CompactSpace.isCompact_univ
instance quasiCompact_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @QuasiCompact where
comp_mem _ _ _ _ := inferInstance
instance : MorphismProperty.IsMultiplicative @QuasiCompact where
id_mem _ := inferInstance
instance quasiCompact_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @QuasiCompact := by
letI := HasAffineProperty.isLocal_affineProperty @QuasiCompact
apply HasAffineProperty.isStableUnderBaseChange
apply AffineTargetMorphismProperty.IsStableUnderBaseChange.mk
intro X Y S _ _ f g h
let 𝒰 := Scheme.Pullback.openCoverOfRight Y.affineCover.finiteSubcover f g
have : Finite 𝒰.I₀ := by dsimp [𝒰]; infer_instance
have : ∀ i, CompactSpace (𝒰.X i) := by intro i; dsimp [𝒰]; infer_instance
exact 𝒰.compactSpace
variable {Z : Scheme.{u}}
instance (f : X ⟶ Z) (g : Y ⟶ Z) [QuasiCompact g] : QuasiCompact (pullback.fst f g) :=
MorphismProperty.pullback_fst f g inferInstance
instance (f : X ⟶ Z) (g : Y ⟶ Z) [QuasiCompact f] : QuasiCompact (pullback.snd f g) :=
MorphismProperty.pullback_snd f g inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [QuasiCompact f] : QuasiCompact (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
lemma compactSpace_iff_exists :
CompactSpace X ↔ ∃ R, ∃ f : Spec R ⟶ X, Function.Surjective f := by
refine ⟨fun h ↦ ?_, fun ⟨R, f, hf⟩ ↦ ⟨hf.range_eq ▸ isCompact_range f.continuous⟩⟩
let 𝒰 : X.OpenCover := X.affineCover.finiteSubcover
refine ⟨Γ(∐ 𝒰.X, ⊤), (∐ 𝒰.X).isoSpec.inv ≫ Sigma.desc 𝒰.f, ?_⟩
refine Function.Surjective.comp (g := Sigma.desc 𝒰.f)
(fun x ↦ ?_) (∐ 𝒰.X).isoSpec.inv.surjective
obtain ⟨y, hy⟩ := 𝒰.covers x
exact ⟨Sigma.ι 𝒰.X (𝒰.idx x) y, by rw [← Scheme.Hom.comp_apply, Sigma.ι_desc, hy]⟩
lemma isCompact_iff_exists {U : X.Opens} :
IsCompact (U : Set X) ↔ ∃ R, ∃ f : Spec R ⟶ X, Set.range f = U := by
refine isCompact_iff_compactSpace.trans ((compactSpace_iff_exists (X := U)).trans ?_)
refine ⟨fun ⟨R, f, hf⟩ ↦ ⟨R, f ≫ U.ι, by simp [hf.range_comp]⟩, fun ⟨R, f, hf⟩ ↦ ?_⟩
refine ⟨R, IsOpenImmersion.lift U.ι f (by simp [hf]), ?_⟩
rw [← Set.range_eq_univ]
apply show Function.Injective (U.ι '' ·) from Set.image_val_injective
simp only [Set.image_univ, Scheme.Opens.range_ι]
rwa [← Set.range_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, IsOpenImmersion.lift_fac]
@[stacks 01K9]
lemma isClosedMap_iff_specializingMap (f : X ⟶ Y) [QuasiCompact f] :
IsClosedMap f ↔ SpecializingMap f := by
refine ⟨fun h ↦ h.specializingMap, fun H ↦ ?_⟩
wlog hY : ∃ R, Y = Spec R
· change topologically @IsClosedMap f
rw [IsZariskiLocalAtTarget.iff_of_openCover (P := topologically @IsClosedMap) Y.affineCover]
intro i
have _ : QuasiCompact (Y.affineCover.pullbackHom f i) := MorphismProperty.pullback_snd _ _ ‹_›
refine this (Y.affineCover.pullbackHom f i) ?_ ⟨_, rfl⟩
exact IsZariskiLocalAtTarget.of_isPullback
(P := topologically @SpecializingMap) (.of_hasPullback _ _) H
obtain ⟨S, rfl⟩ := hY
clear * - H
intro Z hZ
replace H := hZ.stableUnderSpecialization.image H
wlog hX : ∃ R, X = Spec R
· obtain ⟨R, g, hg⟩ := compactSpace_iff_exists.mp (QuasiCompact.compactSpace_of_compactSpace f)
have inst : QuasiCompact (g ≫ f) := HasAffineProperty.iff_of_isAffine.mpr (by infer_instance)
have := this _ (g ≫ f) (g ⁻¹' Z) (hZ.preimage g.continuous)
simp_rw [Scheme.Hom.comp_base, TopCat.comp_app, ← Set.image_image,
Set.image_preimage_eq _ hg] at this
exact this H ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.homEquiv.symm.surjective f
exact PrimeSpectrum.isClosed_image_of_stableUnderSpecialization φ.hom Z hZ H
@[elab_as_elim]
theorem compact_open_induction_on {P : X.Opens → Prop} (S : X.Opens)
(hS : IsCompact (S : Set X)) (h₁ : P ⊥)
(h₂ : ∀ (S : X.Opens) (_ : IsCompact S.1) (U : X.affineOpens), P S → P (S ⊔ U)) :
P S := by
obtain ⟨s, hs, rfl⟩ := isCompact_iff_finite_and_eq_biUnion_affineOpens.mp hS
refine hs.induction_on _ (by simpa using h₁) fun {x s} _ hs h₄ ↦ ?_
rw [iSup_insert, sup_comm]
exact h₂ _ (isCompact_iff_finite_and_eq_biUnion_affineOpens.mpr ⟨s, hs, by simp⟩) x h₄
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen (X : Scheme)
{U : X.Opens} (hU : IsAffineOpen U) (x f : Γ(X, U))
(H : x |_ (X.basicOpen f) = 0) :
∃ n : ℕ, f ^ n * x = 0 := by
rw [← map_zero (X.presheaf.map (homOfLE <| X.basicOpen_le f : X.basicOpen f ⟶ U).op).hom] at H
obtain ⟨n, e⟩ := (hU.isLocalization_basicOpen f).exists_of_eq _ H
exact ⟨n, by simpa [mul_comm x] using e⟩
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
{U : X.Opens} (hU : IsCompact U.1) (x f : Γ(X, U))
(H : x |_ (X.basicOpen f) = 0) :
∃ n : ℕ, f ^ n * x = 0 := by
obtain ⟨s, hs, e⟩ := isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens.mp ⟨hU, U.2⟩
replace e : U = iSup fun i : s => (i : X.Opens) := by
ext1; simpa using e
have h₁ (i : s) : i.1.1 ≤ U := by
rw [e]
exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
have H' := fun i : s =>
exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
(X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
swap
· change (X.presheaf.map (homOfLE _).op) ((X.presheaf.map (homOfLE _).op).hom x) = 0
have H : (X.presheaf.map (homOfLE _).op) x = 0 := H
convert congr_arg (X.presheaf.map (homOfLE _).op).hom H
· simp only [← CommRingCat.comp_apply, ← Functor.map_comp]
· rfl
· rw [map_zero]
· simp only [Scheme.basicOpen_res, inf_le_right]
choose n hn using H'
haveI := hs.to_subtype
cases nonempty_fintype s
use Finset.univ.sup n
suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
subst e
apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : X.Opens)
intro i
change _ = (X.sheaf.val.map _) 0
rw [map_zero]
apply this
intro i
replace hn :=
congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
(hn i)
dsimp at hn
simp only [← map_mul, ← map_pow] at hn
rwa [mul_zero, ← mul_assoc, ← pow_add, tsub_add_cancel_of_le] at hn
apply Finset.le_sup (Finset.mem_univ i)
/-- A section over a compact open of a scheme is nilpotent if and only if its associated
basic open is empty. -/
lemma Scheme.isNilpotent_iff_basicOpen_eq_bot_of_isCompact {X : Scheme.{u}}
{U : X.Opens} (hU : IsCompact (U : Set X)) (f : Γ(X, U)) :
IsNilpotent f ↔ X.basicOpen f = ⊥ := by
refine ⟨X.basicOpen_eq_bot_of_isNilpotent U f, fun hf ↦ ?_⟩
have h : (1 : Γ(X, U)) |_ (X.basicOpen f) = 0 := by
have e : X.basicOpen f ≤ ⊥ := by rw [hf]
rw [← TopCat.Presheaf.restrict_restrict e bot_le]
rw [Subsingleton.eq_zero (1 |_ ⊥)]
change X.presheaf.map _ 0 = 0
rw [map_zero]
obtain ⟨n, hn⟩ := exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact X hU 1 f h
rw [mul_one] at hn
use n
/-- A global section of a quasi-compact scheme is nilpotent if and only if its associated
basic open is empty. -/
lemma Scheme.isNilpotent_iff_basicOpen_eq_bot {X : Scheme.{u}}
[CompactSpace X] (f : Γ(X, ⊤)) :
IsNilpotent f ↔ X.basicOpen f = ⊥ :=
isNilpotent_iff_basicOpen_eq_bot_of_isCompact (U := ⊤) (CompactSpace.isCompact_univ) f
/-- The zero locus of a set of sections over a compact open of a scheme is `X` if and only if
`s` is contained in the nilradical of `Γ(X, U)`. -/
lemma Scheme.zeroLocus_eq_univ_iff_subset_nilradical_of_isCompact {X : Scheme.{u}} {U : X.Opens}
(hU : IsCompact (U : Set X)) (s : Set Γ(X, U)) :
X.zeroLocus s = Set.univ ↔ s ⊆ nilradical Γ(X, U) := by
simp [Scheme.zeroLocus_def, ← Scheme.isNilpotent_iff_basicOpen_eq_bot_of_isCompact hU,
← mem_nilradical, Set.subset_def]
/-- The zero locus of a set of sections over a compact open of a scheme is `X` if and only if
`s` is contained in the nilradical of `Γ(X, U)`. -/
lemma Scheme.zeroLocus_eq_univ_iff_subset_nilradical {X : Scheme.{u}}
[CompactSpace X] (s : Set Γ(X, ⊤)) :
X.zeroLocus s = Set.univ ↔ s ⊆ nilradical Γ(X, ⊤) :=
zeroLocus_eq_univ_iff_subset_nilradical_of_isCompact (U := ⊤) (CompactSpace.isCompact_univ) s
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/LocalClosure.lean | import Mathlib.AlgebraicGeometry.Morphisms.Basic
/-!
# Local closure of morphism properties
We define the source local closure of a property `P` w.r.t. a morphism property `W` and show it
inherits stability properties from `P`.
-/
universe u
open CategoryTheory Limits MorphismProperty
namespace AlgebraicGeometry
variable (W : MorphismProperty Scheme.{u})
/-- The source (Zariski-)local closure of `P` is satisfied if there exists
an open cover of the source on which `P` is satisfied. -/
def sourceLocalClosure (P : MorphismProperty Scheme.{u}) : MorphismProperty Scheme.{u} :=
fun X _ f ↦ ∃ (𝒰 : Scheme.Cover.{u} (Scheme.precoverage W) X), ∀ (i : 𝒰.I₀), P (𝒰.f i ≫ f)
namespace sourceLocalClosure
variable {W} {P Q : MorphismProperty Scheme.{u}} {X Y : Scheme.{u}}
/-- A choice of open cover on which `P` is satisfied if `f` satisfies the source local closure
of `P`. -/
noncomputable def cover {f : X ⟶ Y} (hf : sourceLocalClosure W P f) :
Scheme.Cover.{u} (Scheme.precoverage W) X :=
hf.choose
lemma property_coverMap_comp {f : X ⟶ Y} (hf : sourceLocalClosure W P f) (i : hf.cover.I₀) :
P (hf.cover.f i ≫ f) :=
hf.choose_spec i
lemma le [W.ContainsIdentities] [W.RespectsIso] : P ≤ sourceLocalClosure W P :=
fun X Y f hf ↦ ⟨X.coverOfIsIso (𝟙 X), by simpa⟩
lemma iff_forall_exists [P.RespectsIso] {f : X ⟶ Y} :
sourceLocalClosure IsOpenImmersion P f ↔ ∀ (x : X), ∃ (U : X.Opens), x ∈ U ∧ P (U.ι ≫ f) := by
refine ⟨fun ⟨𝒰, hf⟩ x ↦ ?_, fun H ↦ ?_⟩
· refine ⟨(𝒰.f (𝒰.idx x)).opensRange, 𝒰.covers x, ?_⟩
rw [← Scheme.Hom.isoOpensRange_inv_comp, Category.assoc, P.cancel_left_of_respectsIso]
apply hf
· choose U hx hf using H
exact ⟨.mkOfCovers X (fun x ↦ U x) (fun _ ↦ (U _).ι) (fun x ↦ ⟨x, ⟨x, hx x⟩, rfl⟩)
fun _ ↦ inferInstance, hf⟩
variable [W.IsStableUnderBaseChange] [Scheme.IsJointlySurjectivePreserving W]
instance [P.RespectsLeft Q] [Q.IsStableUnderBaseChange] :
(sourceLocalClosure W P).RespectsLeft Q := by
refine ⟨fun {X Y} Z f hf g ⟨𝒰, hg⟩ ↦ ⟨𝒰.pullback₁ f, fun i ↦ ?_⟩⟩
simpa [pullback.condition_assoc] using
RespectsLeft.precomp (Q := Q) _ (Q.pullback_snd _ _ hf) _ (hg i)
instance [P.RespectsRight Q] : (sourceLocalClosure W P).RespectsRight Q := by
refine ⟨fun {X Y} Z f hf g ⟨𝒰, hg⟩ ↦ ⟨𝒰, fun i ↦ ?_⟩⟩
rw [← Category.assoc]
exact RespectsRight.postcomp _ hf _ (hg i)
instance [P.RespectsIso] : (sourceLocalClosure W P).RespectsIso where
instance [P.RespectsIso] [P.RespectsLeft @IsOpenImmersion] :
IsZariskiLocalAtSource (sourceLocalClosure IsOpenImmersion P) := by
refine .mk_of_iff fun f 𝒰 ↦ ?_
refine ⟨fun ⟨𝒱, h⟩ ↦ fun i ↦ ⟨𝒱.pullback₁ (𝒰.f i), fun j ↦ ?_⟩, fun h ↦ ?_⟩
· simpa [pullback.condition_assoc] using
RespectsLeft.precomp (Q := @IsOpenImmersion) _ inferInstance _ (h j)
· choose 𝒱 h𝒱 using h
exact ⟨𝒰.bind 𝒱, fun i ↦ h𝒱 _ _⟩
instance [P.IsStableUnderBaseChange] : (sourceLocalClosure W P).IsStableUnderBaseChange := by
refine .mk' fun X Y S f g _ ⟨𝒰, hg⟩ ↦ ⟨𝒰.pullback₁ (pullback.snd f g), fun i ↦ ?_⟩
simpa [← pullbackLeftPullbackSndIso_hom_fst, P.cancel_left_of_respectsIso] using
P.pullback_fst _ _ (hg i)
instance [W.ContainsIdentities] [P.ContainsIdentities] :
(sourceLocalClosure W P).ContainsIdentities :=
⟨fun X ↦ ⟨X.coverOfIsIso (𝟙 X), fun _ ↦ P.id_mem _⟩⟩
instance [W.IsStableUnderComposition] [P.IsStableUnderBaseChange] [P.IsStableUnderComposition] :
(sourceLocalClosure W P).IsStableUnderComposition := by
refine ⟨fun {X Y Z} f g ⟨𝒰, hf⟩ ⟨𝒱, hg⟩ ↦ ?_⟩
refine ⟨𝒰.bind fun i ↦ (𝒱.pullback₁ (𝒰.f i ≫ f)), fun ⟨l, r⟩ ↦ ?_⟩
simpa [← pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.condition_assoc] using
P.comp_mem _ _ (P.pullback_snd _ _ (hf _)) (hg r)
instance [W.IsMultiplicative] [P.IsStableUnderBaseChange] [P.IsMultiplicative] :
(sourceLocalClosure W P).IsMultiplicative where
end sourceLocalClosure
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/LocalIso.lean | import Mathlib.AlgebraicGeometry.Morphisms.LocalClosure
/-!
# Local isomorphisms
A local isomorphism of schemes is a morphism that is source-locally an open immersion.
-/
universe u
open CategoryTheory MorphismProperty
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}}
/-- A local isomorphism of schemes is a morphism that is (Zariski-)source-locally an
open immersion. -/
@[mk_iff]
class IsLocalIso (f : X ⟶ Y) : Prop where
exists_isOpenImmersion (x : X) : ∃ (U : X.Opens), x ∈ U ∧ IsOpenImmersion (U.ι ≫ f)
namespace IsLocalIso
variable (f : X ⟶ Y)
lemma eq_sourceLocalClosure_isOpenImmersion :
@IsLocalIso = sourceLocalClosure IsOpenImmersion IsOpenImmersion := by
ext
rw [isLocalIso_iff, sourceLocalClosure.iff_forall_exists]
instance : IsZariskiLocalAtSource @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
instance : IsMultiplicative @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
instance : IsStableUnderBaseChange @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
/-- `IsLocalIso` is weaker than every source-Zariski-local property containing identities. -/
lemma le_of_isZariskiLocalAtSource (P : MorphismProperty Scheme.{u}) [P.ContainsIdentities]
[IsZariskiLocalAtSource P] : @IsLocalIso ≤ P := by
intro X Y f hf
obtain ⟨𝒰, h⟩ := eq_sourceLocalClosure_isOpenImmersion ▸ hf
rw [IsZariskiLocalAtSource.iff_of_openCover 𝒰 (P := P)]
exact fun _ ↦ IsZariskiLocalAtSource.of_isOpenImmersion _
@[deprecated (since := "2025-10-07")] alias le_of_isLocalAtSource := le_of_isZariskiLocalAtSource
/-- `IsLocalIso` is the weakest source-Zariski-local property containing identities. -/
lemma eq_iInf :
@IsLocalIso = ⨅ (P : MorphismProperty Scheme.{u}) (_ : P.ContainsIdentities)
(_ : IsZariskiLocalAtSource P), P := by
refine le_antisymm ?_ ?_
· simp only [le_iInf_iff]
apply le_of_isZariskiLocalAtSource
· refine iInf_le_of_le @IsLocalIso (iInf_le_of_le inferInstance (iInf_le _ ?_))
infer_instance
end IsLocalIso
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/UnderlyingMap.lean | import Mathlib.Topology.LocalAtTarget
import Mathlib.AlgebraicGeometry.Morphisms.Constructors
/-!
## Properties on the underlying functions of morphisms of schemes.
This file includes various results on properties of morphisms of schemes that come from properties
of the underlying map of topological spaces, including
- `Injective`
- `Surjective`
- `IsOpenMap`
- `IsClosedMap`
- `GeneralizingMap`
- `IsEmbedding`
- `IsOpenEmbedding`
- `IsClosedEmbedding`
- `DenseRange` (`IsDominant`)
-/
open CategoryTheory Topology TopologicalSpace
namespace AlgebraicGeometry
universe u v
section Injective
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
instance : MorphismProperty.RespectsIso (topologically Function.Injective) :=
topologically_respectsIso _ (fun e ↦ e.injective) (fun _ _ hf hg ↦ hg.comp hf)
instance injective_isZariskiLocalAtTarget :
IsZariskiLocalAtTarget (topologically Function.Injective) := by
refine topologically_isZariskiLocalAtTarget _ (fun _ s _ _ h ↦ h.restrictPreimage s)
fun f ι U H _ hf x₁ x₂ e ↦ ?_
obtain ⟨i, hxi⟩ : ∃ i, f x₁ ∈ U i := by simpa using congr(f x₁ ∈ $H)
exact congr(($(@hf i ⟨x₁, hxi⟩ ⟨x₂, show f x₂ ∈ U i from e ▸ hxi⟩ (Subtype.ext e))).1)
end Injective
section Surjective
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism of schemes is surjective if the underlying map is. -/
@[mk_iff]
class Surjective : Prop where
surj : Function.Surjective f
lemma surjective_eq_topologically :
@Surjective = topologically Function.Surjective := by ext; exact surjective_iff _
lemma Scheme.Hom.surjective (f : X ⟶ Y) [Surjective f] : Function.Surjective f :=
Surjective.surj
instance (priority := 100) [IsIso f] : Surjective f := ⟨f.homeomorph.surjective⟩
instance [Surjective f] [Surjective g] : Surjective (f ≫ g) := ⟨g.surjective.comp f.surjective⟩
lemma Surjective.of_comp [Surjective (f ≫ g)] : Surjective g where
surj := Function.Surjective.of_comp (g := f) (f ≫ g).surjective
lemma Surjective.comp_iff [Surjective f] : Surjective (f ≫ g) ↔ Surjective g :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
instance : MorphismProperty.RespectsIso @Surjective :=
surjective_eq_topologically ▸ topologically_respectsIso _ (fun e ↦ e.surjective)
(fun _ _ hf hg ↦ hg.comp hf)
instance surjective_isZariskiLocalAtTarget : IsZariskiLocalAtTarget @Surjective := by
have : MorphismProperty.RespectsIso @Surjective := inferInstance
rw [surjective_eq_topologically] at this ⊢
refine topologically_isZariskiLocalAtTarget _ (fun _ s _ _ h ↦ h.restrictPreimage s) ?_
intro α β _ _ f ι U H _ hf x
obtain ⟨i, hxi⟩ : ∃ i, x ∈ U i := by simpa using congr(x ∈ $H)
obtain ⟨⟨y, _⟩, hy⟩ := hf i ⟨x, hxi⟩
exact ⟨y, congr(($hy).1)⟩
@[simp]
lemma range_eq_univ [Surjective f] : Set.range f = Set.univ := by
simpa [Set.range_eq_univ] using f.surjective
lemma range_eq_range_of_surjective {S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) (e : X ⟶ Y)
[Surjective e] (hge : e ≫ g = f) : Set.range f = Set.range g := by
rw [← hge]
simp [Set.range_comp]
lemma mem_range_iff_of_surjective {S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) (e : X ⟶ Y)
[Surjective e] (hge : e ≫ g = f) (s : S) : s ∈ Set.range f ↔ s ∈ Set.range g := by
rw [range_eq_range_of_surjective f g e hge]
lemma Surjective.sigmaDesc_of_union_range_eq_univ {X : Scheme.{u}}
{ι : Type v} [Small.{u} ι] {Y : ι → Scheme.{u}} {f : ∀ i, Y i ⟶ X}
(H : ⋃ i, Set.range (f i) = Set.univ) : Surjective (Limits.Sigma.desc f) := by
refine ⟨fun x ↦ ?_⟩
simp_rw [Set.eq_univ_iff_forall, Set.mem_iUnion] at H
obtain ⟨i, x, rfl⟩ := H x
use Limits.Sigma.ι Y i x
rw [← Scheme.Hom.comp_apply, Limits.Sigma.ι_desc]
instance {X : Scheme.{u}} {P : MorphismProperty Scheme.{u}} (𝒰 : X.Cover (Scheme.precoverage P)) :
Surjective (Limits.Sigma.desc fun i ↦ 𝒰.f i) :=
Surjective.sigmaDesc_of_union_range_eq_univ 𝒰.iUnion_range
end Surjective
section Injective
instance injective_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition (topologically (Function.Injective ·)) where
comp_mem _ _ hf hg := hg.comp hf
end Injective
section IsOpenMap
instance : (topologically IsOpenMap).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isOpenMap) (fun _ _ hf hg ↦ hg.comp hf)
instance isOpenMap_isZariskiLocalAtTarget : IsZariskiLocalAtTarget (topologically IsOpenMap) :=
topologically_isZariskiLocalAtTarget' _ fun _ _ _ hU _ ↦ hU.isOpenMap_iff_restrictPreimage
instance : IsZariskiLocalAtSource (topologically IsOpenMap) :=
topologically_isZariskiLocalAtSource' (fun _ ↦ _) fun _ _ _ hU _ ↦ hU.isOpenMap_iff_comp
end IsOpenMap
section IsClosedMap
instance : (topologically IsClosedMap).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isClosedMap) (fun _ _ hf hg ↦ hg.comp hf)
instance isClosedMap_isZariskiLocalAtTarget : IsZariskiLocalAtTarget (topologically IsClosedMap) :=
topologically_isZariskiLocalAtTarget' _ fun _ _ _ hU _ ↦ hU.isClosedMap_iff_restrictPreimage
end IsClosedMap
section IsEmbedding
instance : (topologically IsEmbedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isEmbedding) (fun _ _ hf hg ↦ hg.comp hf)
instance isEmbedding_isZariskiLocalAtTarget : IsZariskiLocalAtTarget (topologically IsEmbedding) :=
topologically_isZariskiLocalAtTarget' _ fun _ _ _ hU ↦ hU.isEmbedding_iff_restrictPreimage
end IsEmbedding
section IsOpenEmbedding
instance : (topologically IsOpenEmbedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isOpenEmbedding) (fun _ _ hf hg ↦ hg.comp hf)
instance isOpenEmbedding_isZariskiLocalAtTarget :
IsZariskiLocalAtTarget (topologically IsOpenEmbedding) :=
topologically_isZariskiLocalAtTarget' _ fun _ _ _ hU ↦ hU.isOpenEmbedding_iff_restrictPreimage
end IsOpenEmbedding
section IsClosedEmbedding
instance : (topologically IsClosedEmbedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isClosedEmbedding) (fun _ _ hf hg ↦ hg.comp hf)
instance isClosedEmbedding_isZariskiLocalAtTarget :
IsZariskiLocalAtTarget (topologically IsClosedEmbedding) :=
topologically_isZariskiLocalAtTarget' _ fun _ _ _ hU ↦ hU.isClosedEmbedding_iff_restrictPreimage
end IsClosedEmbedding
section IsDominant
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism of schemes is dominant if the underlying map has dense range. -/
@[mk_iff]
class IsDominant : Prop where
denseRange : DenseRange f
lemma dominant_eq_topologically :
@IsDominant = topologically DenseRange := by ext; exact isDominant_iff _
lemma Scheme.Hom.denseRange (f : X ⟶ Y) [IsDominant f] : DenseRange f :=
IsDominant.denseRange
instance (priority := 100) [Surjective f] : IsDominant f := ⟨f.surjective.denseRange⟩
instance [IsDominant f] [IsDominant g] : IsDominant (f ≫ g) :=
⟨g.denseRange.comp f.denseRange g.continuous⟩
instance : MorphismProperty.IsMultiplicative @IsDominant where
id_mem := fun _ ↦ inferInstance
comp_mem := fun _ _ _ _ ↦ inferInstance
lemma IsDominant.of_comp [H : IsDominant (f ≫ g)] : IsDominant g := by
rw [isDominant_iff, denseRange_iff_closure_range, ← Set.univ_subset_iff] at H ⊢
exact H.trans (closure_mono (Set.range_comp_subset_range f g))
lemma IsDominant.comp_iff [IsDominant f] : IsDominant (f ≫ g) ↔ IsDominant g :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
instance IsDominant.respectsIso : MorphismProperty.RespectsIso @IsDominant :=
MorphismProperty.respectsIso_of_isStableUnderComposition fun _ _ f (_ : IsIso f) ↦ inferInstance
instance IsDominant.isZariskiLocalAtTarget : IsZariskiLocalAtTarget @IsDominant :=
have : MorphismProperty.RespectsIso (topologically DenseRange) :=
dominant_eq_topologically ▸ IsDominant.respectsIso
dominant_eq_topologically ▸ topologically_isZariskiLocalAtTarget' DenseRange
fun _ _ _ hU _ ↦ hU.denseRange_iff_restrictPreimage
lemma surjective_of_isDominant_of_isClosed_range (f : X ⟶ Y) [IsDominant f]
(hf : IsClosed (Set.range f)) :
Surjective f :=
⟨by rw [← Set.range_eq_univ, ← hf.closure_eq, f.denseRange.closure_range]⟩
lemma IsDominant.of_comp_of_isOpenImmersion
(f : X ⟶ Y) (g : Y ⟶ Z) [H : IsDominant (f ≫ g)] [IsOpenImmersion g] :
IsDominant f := by
rw [isDominant_iff, DenseRange] at H ⊢
simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp] at H
convert H.preimage g.isOpenEmbedding.isOpenMap using 1
rw [Set.preimage_image_eq _ g.isOpenEmbedding.injective]
end IsDominant
section SpecializingMap
open TopologicalSpace
instance specializingMap_respectsIso : (topologically @SpecializingMap).RespectsIso := by
apply topologically_respectsIso
· introv
exact f.isClosedMap.specializingMap
· introv hf hg
exact hf.comp hg
instance specializingMap_isZariskiLocalAtTarget :
IsZariskiLocalAtTarget (topologically @SpecializingMap) := by
apply topologically_isZariskiLocalAtTarget
· introv _ _ hf
rw [specializingMap_iff_closure_singleton_subset] at hf ⊢
intro ⟨x, hx⟩ ⟨y, hy⟩ hcl
simp only [closure_subtype, Set.restrictPreimage_mk, Set.image_singleton] at hcl
obtain ⟨a, ha, hay⟩ := hf x hcl
rw [← specializes_iff_mem_closure] at hcl
exact ⟨⟨a, by simp [hay, hy]⟩, by simpa [closure_subtype], by simpa⟩
· introv hU _ hsp
simp_rw [specializingMap_iff_closure_singleton_subset] at hsp ⊢
intro x y hy
have : ∃ i, y ∈ U i := Opens.mem_iSup.mp (hU ▸ Opens.mem_top _)
obtain ⟨i, hi⟩ := this
rw [← specializes_iff_mem_closure] at hy
have hfx : f x ∈ U i := (U i).2.stableUnderGeneralization hy hi
have hy : (⟨y, hi⟩ : U i) ∈ closure {⟨f x, hfx⟩} := by
simp only [closure_subtype, Set.image_singleton]
rwa [← specializes_iff_mem_closure]
obtain ⟨a, ha, hay⟩ := hsp i ⟨x, hfx⟩ hy
rw [closure_subtype] at ha
simp only [Opens.carrier_eq_coe, Set.image_singleton] at ha
apply_fun Subtype.val at hay
simp only [Opens.carrier_eq_coe, Set.restrictPreimage_coe] at hay
use a.val, ha, hay
end SpecializingMap
section GeneralizingMap
instance : (topologically GeneralizingMap).RespectsIso :=
topologically_respectsIso _ (fun f ↦ f.isOpenEmbedding.generalizingMap
f.isOpenEmbedding.isOpen_range.stableUnderGeneralization) (fun _ _ hf hg ↦ hf.comp hg)
instance : IsZariskiLocalAtSource (topologically GeneralizingMap) :=
topologically_isZariskiLocalAtSource' (fun _ ↦ _) fun _ _ _ hU _ ↦ hU.generalizingMap_iff_comp
instance : IsZariskiLocalAtTarget (topologically GeneralizingMap) :=
topologically_isZariskiLocalAtTarget' (fun _ ↦ _) fun _ _ _ hU _ ↦
hU.generalizingMap_iff_restrictPreimage
end GeneralizingMap
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Descent.lean | import Mathlib.AlgebraicGeometry.Morphisms.AffineAnd
import Mathlib.AlgebraicGeometry.Morphisms.LocalIso
import Mathlib.CategoryTheory.MorphismProperty.Descent
/-!
# Descent of morphism properties
Let `P` and `P'` be morphism properties. In this file we show some results to deduce
that `P` descends along `P'` from a codescent property of ring homomorphisms.
## Main results
- `HasRingHomProperty.descendsAlong`: if `P` is a local property induced by `Q`, `P'` implies
`Q'` on global sections of affines and `Q` codescends along `Q'`, then `P` descends along `P'`.
- `HasAffineProperty.descendsAlong_of_affineAnd`: if `P` is given by `affineAnd Q`, `P'` implies
`Q'` on global sections of affines and `Q` codescends along `Q'`, then `P` descends along `P'`
(see TODOs).
## TODO
- Show that affine morphisms descend along faithfully-flat morphisms. This will make
`HasAffineProperty.descendsAlong_of_affineAnd` useful.
-/
universe u v
open TensorProduct CategoryTheory Limits
namespace AlgebraicGeometry
variable (P P' : MorphismProperty Scheme.{u})
/--
If `P` is local at the source, every quasi-compact scheme is dominated by an
affine scheme via `p : Y ⟶ X` such that `p` satisfies `P`.
-/
lemma Scheme.exists_hom_isAffine_of_isZariskiLocalAtSource (X : Scheme.{u}) [CompactSpace X]
[IsZariskiLocalAtSource P] [P.ContainsIdentities] :
∃ (Y : Scheme.{u}) (p : Y ⟶ X), Surjective p ∧ P p ∧ IsAffine Y := by
let 𝒰 := X.affineCover.finiteSubcover
let p : ∐ (fun i : 𝒰.I₀ ↦ 𝒰.X i) ⟶ X := Sigma.desc (fun i ↦ 𝒰.f i)
refine ⟨_, p, ⟨fun x ↦ ?_⟩, ?_, inferInstance⟩
· obtain ⟨i, x, rfl⟩ := X.affineCover.finiteSubcover.exists_eq x
use Sigma.ι X.affineCover.finiteSubcover.X i x
rw [← Scheme.Hom.comp_apply, Sigma.ι_desc]
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) (sigmaOpenCover _)]
exact fun i ↦ by simpa [p] using IsZariskiLocalAtSource.of_isOpenImmersion _
@[deprecated (since := "2025-10-07")]
alias Scheme.exists_hom_isAffine_of_isLocalAtSource :=
Scheme.exists_hom_isAffine_of_isZariskiLocalAtSource
/-- If `P` is local at the target, to show `P` descends along `P'` we may assume
the base to be affine. -/
lemma IsZariskiLocalAtTarget.descendsAlong [IsZariskiLocalAtTarget P] [P'.IsStableUnderBaseChange]
(H : ∀ {R : CommRingCat.{u}} {X Y : Scheme.{u}} (f : X ⟶ Spec R) (g : Y ⟶ Spec R),
P' f → P (pullback.fst f g) → P g) :
P.DescendsAlong P' := by
apply MorphismProperty.DescendsAlong.mk'
introv h hf
wlog hZ : ∃ R, Z = Spec R generalizing X Y Z
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := P) Z.affineCover]
intro i
let ι := Z.affineCover.f i
let e : pullback (pullback.snd f ι) (pullback.snd g ι) ≅
pullback (pullback.fst f g) (pullback.fst f ι) :=
pullbackLeftPullbackSndIso f ι (pullback.snd g ι) ≪≫
pullback.congrHom rfl pullback.condition.symm ≪≫
(pullbackAssoc f g g ι).symm ≪≫ pullback.congrHom pullback.condition.symm rfl ≪≫
(pullbackRightPullbackFstIso f ι (pullback.fst f g)).symm
have heq : e.hom ≫ pullback.snd (pullback.fst f g) (pullback.fst f ι) =
pullback.fst (pullback.snd f ι) (pullback.snd g ι) := by
apply pullback.hom_ext <;> simp [e, pullback.condition]
refine this (f := pullback.snd f ι) ?_ ?_ ⟨_, rfl⟩
· exact P'.pullback_snd _ _ h
· change P (pullback.fst (pullback.snd f ι) (pullback.snd g ι))
rw [← heq, P.cancel_left_of_respectsIso]
exact AlgebraicGeometry.IsZariskiLocalAtTarget.of_isPullback (iY := pullback.fst f ι)
(CategoryTheory.IsPullback.of_hasPullback _ _) hf
obtain ⟨R, rfl⟩ := hZ
exact H f g h hf
@[deprecated (since := "2025-10-07")]
alias IsLocalAtTarget.descendsAlong := IsZariskiLocalAtTarget.descendsAlong
variable (Q Q' : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
variable {Q Q'} in
lemma of_pullback_fst_Spec_of_codescendsAlong [P.RespectsIso]
(hQQ' : RingHom.CodescendsAlong Q Q')
(H₁ : ∀ {R S : CommRingCat.{u}} {f : R ⟶ S}, P' (Spec.map f) → Q' f.hom)
(H₂ : ∀ {R S : CommRingCat.{u}} {f : R ⟶ S}, P (Spec.map f) ↔ Q f.hom)
{R S T : CommRingCat.{u}}
{f : Spec T ⟶ Spec R} {g : Spec S ⟶ Spec R} (h : P' f) (hf : P (pullback.fst f g)) :
P g := by
obtain ⟨φ, rfl⟩ := Spec.map_surjective g
obtain ⟨ψ, rfl⟩ := Spec.map_surjective f
algebraize [φ.hom, ψ.hom]
replace hf : P (pullback.fst (Spec.map <| CommRingCat.ofHom <| algebraMap R T)
(Spec.map <| CommRingCat.ofHom <| algebraMap R S)) := hf
rw [H₂]
refine hQQ'.algebraMap_tensorProduct (R := R) (S := T) (T := S) _ (H₁ h) ?_
rwa [← pullbackSpecIso_hom_fst R T S, P.cancel_left_of_respectsIso, H₂] at hf
/-- If `X` admits a morphism `p : T ⟶ X` from an affine scheme satisfying `P'`, to
show a property descends along a morphism `f : X ⟶ Z` satisfying `P'`, `X` may assumed to
be affine. -/
lemma IsStableUnderBaseChange.of_pullback_fst_of_isAffine [P'.RespectsIso]
[P'.IsStableUnderComposition] [P.IsStableUnderBaseChange]
(H : ∀ {R : CommRingCat.{u}} {S X : Scheme.{u}} (f : Spec R ⟶ S) (g : X ⟶ S),
P' f → P (pullback.fst f g) → P g) {X Y Z T : Scheme.{u}} [IsAffine T] (p : T ⟶ X)
(hp : P' p) (f : X ⟶ Z) (g : Y ⟶ Z) (h : P' f) (hf : P (pullback.fst f g)) : P g := by
apply H ((T.isoSpec.inv ≫ p) ≫ f)
· rw [Category.assoc, P'.cancel_left_of_respectsIso]
exact P'.comp_mem _ _ hp h
· rw [← pullbackRightPullbackFstIso_inv_fst f g (T.isoSpec.inv ≫ p),
P.cancel_left_of_respectsIso]
exact P.pullback_fst _ _ hf
open Opposite
variable [P'.IsStableUnderBaseChange] [P'.IsStableUnderComposition] [P.IsStableUnderBaseChange]
variable
(H₁ : (@IsLocalIso ⊓ @Surjective : MorphismProperty Scheme) ≤ P')
(H₂ : ∀ {R S : CommRingCat.{u}} {f : R ⟶ S}, P' (Spec.map f) → Q' f.hom)
include H₁ in
lemma IsZariskiLocalAtTarget.descendsAlong_inf_quasiCompact [IsZariskiLocalAtTarget P]
(H : ∀ {R S : CommRingCat.{u}} {Y : Scheme.{u}} (φ : R ⟶ S) (g : Y ⟶ Spec R),
P' (Spec.map φ) → P (pullback.fst (Spec.map φ) g) → P g) :
P.DescendsAlong (P' ⊓ @QuasiCompact) := by
apply IsZariskiLocalAtTarget.descendsAlong
intro R X Y f g hf h
wlog hX : ∃ T, X = Spec T generalizing X
· have _ : CompactSpace X := by simpa [← quasiCompact_iff_compactSpace f] using hf.2
obtain ⟨Y, p, hsurj, hP', hY⟩ := X.exists_hom_isAffine_of_isZariskiLocalAtSource @IsLocalIso
refine this (f := (Y.isoSpec.inv ≫ p) ≫ f) ?_ ?_ ⟨_, rfl⟩
· rw [Category.assoc, (P' ⊓ @QuasiCompact).cancel_left_of_respectsIso]
exact ⟨P'.comp_mem _ _ (H₁ _ ⟨hP', hsurj⟩) hf.1, inferInstance⟩
· rw [← pullbackRightPullbackFstIso_inv_fst f g _, P.cancel_left_of_respectsIso]
exact P.pullback_fst _ _ h
obtain ⟨T, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
exact H φ g hf.1 h
@[deprecated (since := "2025-10-07")]
alias IsLocalAtTarget.descendsAlong_inf_quasiCompact :=
IsZariskiLocalAtTarget.descendsAlong_inf_quasiCompact
include H₁ H₂ in
/--
Let `P` be the morphism property associated to the ring hom property `Q`. Suppose
- `P'` implies `Q'` on global sections for affine schemes,
- `P'` is satisfied for all surjective, local isomorphisms, and
- `Q` codescend along `Q'`.
Then `P` descends along quasi-compact morphisms satisfying `P'`.
Note: The second condition is in particular satisfied for faithfully flat morphisms.
-/
nonrec lemma HasRingHomProperty.descendsAlong [HasRingHomProperty P Q]
(hQQ' : RingHom.CodescendsAlong Q Q') :
P.DescendsAlong (P' ⊓ @QuasiCompact) := by
apply IsZariskiLocalAtTarget.descendsAlong_inf_quasiCompact _ _ H₁
introv h hf
wlog hY : ∃ S, Y = Spec S generalizing Y
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) Y.affineCover]
intro i
have heq : pullback.fst (Spec.map φ) (Y.affineCover.f i ≫ g) =
pullback.map _ _ _ _ (𝟙 _) (Y.affineCover.f i) (𝟙 _) (by simp) (by simp) ≫
pullback.fst (Spec.map φ) g := (pullback.lift_fst _ _ _).symm
exact this _ (heq ▸ AlgebraicGeometry.IsZariskiLocalAtSource.comp hf _) ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hY
apply of_pullback_fst_Spec_of_codescendsAlong _ _ hQQ' H₂ _ h hf
simp [HasRingHomProperty.Spec_iff (P := P)]
include H₁ H₂ in
/--
Let `P` be a morphism property associated with `affineAnd Q`. Suppose
- `P'` implies `Q'` on global sections on affine schemes,
- `P'` is satisfied for surjective, local isomorphisms,
- affine morphisms descend along `P''`, and
- `Q` codescends along `Q'`,
Then `P` descends along quasi-compact morphisms satisfying `P'`.
Note: The second condition is in particular satisfied for faithfully flat morphisms.
-/
nonrec lemma HasAffineProperty.descendsAlong_of_affineAnd
(hP : HasAffineProperty P (affineAnd Q)) [MorphismProperty.DescendsAlong @IsAffineHom P']
(hQ : RingHom.RespectsIso Q) (hQQ' : RingHom.CodescendsAlong Q Q') :
P.DescendsAlong (P' ⊓ @QuasiCompact) := by
apply IsZariskiLocalAtTarget.descendsAlong_inf_quasiCompact _ _ H₁
introv h hf
have : IsAffine Y := by
convert isAffine_of_isAffineHom g
exact MorphismProperty.of_pullback_fst_of_descendsAlong h <|
AlgebraicGeometry.HasAffineProperty.affineAnd_le_isAffineHom P inferInstance _ hf
wlog hY : ∃ S, Y = Spec S generalizing Y
· rw [← P.cancel_left_of_respectsIso Y.isoSpec.inv]
have heq : pullback.fst (Spec.map φ) (Y.isoSpec.inv ≫ g) =
pullback.map _ _ _ _ (𝟙 _) (Y.isoSpec.inv) (𝟙 _) (by simp) (by simp) ≫
pullback.fst (Spec.map φ) g := (pullback.lift_fst _ _ _).symm
refine this _ ?_ inferInstance ⟨_, rfl⟩
rwa [heq, P.cancel_left_of_respectsIso]
obtain ⟨Y, rfl⟩ := hY
apply of_pullback_fst_Spec_of_codescendsAlong _ _ hQQ' H₂ _ h hf
simp [SpecMap_iff_of_affineAnd _ hQ]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean | import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.MorphismProperty.Local
import Mathlib.Data.List.TFAE
/-!
# Properties of morphisms between Schemes
We provide the basic framework for talking about properties of morphisms between Schemes.
A `MorphismProperty Scheme` is a predicate on morphisms between schemes. For properties local at
the target, its behaviour is entirely determined by its definition on morphisms into affine schemes,
which we call an `AffineTargetMorphismProperty`. In this file, we provide API lemmas for properties
local at the target, and special support for those properties whose `AffineTargetMorphismProperty`
takes on a more simple form. We also provide API lemmas for properties local at the target.
The main interfaces of the API are the typeclasses `IsLocalAtTarget`, `IsLocalAtSource` and
`HasAffineProperty`, which we describe in detail below.
## `IsZariskiLocalAtTarget`
- `AlgebraicGeometry.IsZariskiLocalAtTarget`: We say that `IsZariskiLocalAtTarget P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`.
For a morphism property `P` local at the target and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.IsZariskiLocalAtTarget.of_isPullback`:
`P` is preserved under pullback along open immersions.
- `AlgebraicGeometry.IsZariskiLocalAtTarget.restrict`:
`P f → P (f ∣_ U)` for an open `U` of `Y`.
- `AlgebraicGeometry.IsZariskiLocalAtTarget.iff_of_iSup_eq_top`:
`P f ↔ ∀ i, P (f ∣_ U i)` for a family `U i` of open sets covering `Y`.
- `AlgebraicGeometry.IsZariskiLocalAtTarget.iff_of_openCover`:
`P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for `𝒰 : Y.openCover`.
## `IsZariskiLocalAtSource`
- `AlgebraicGeometry.IsZariskiLocalAtSource`: We say that `IsZariskiLocalAtSource P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. `P` holds for `𝒰.map i ≫ f` for an open cover `𝒰` of `X` iff `P` holds for `f : X ⟶ Y`.
For a morphism property `P` local at the source and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.IsZariskiLocalAtSource.comp`:
`P` is preserved under composition with open immersions at the source.
- `AlgebraicGeometry.IsZariskiLocalAtSource.iff_of_iSup_eq_top`:
`P f ↔ ∀ i, P (U.ι ≫ f)` for a family `U i` of open sets covering `X`.
- `AlgebraicGeometry.IsZariskiLocalAtSource.iff_of_openCover`:
`P f ↔ ∀ i, P (𝒰.map i ≫ f)` for `𝒰 : X.openCover`.
- `AlgebraicGeometry.IsZariskiLocalAtSource.of_isOpenImmersion`: If `P` contains identities then `P`
holds for open immersions.
## `AffineTargetMorphismProperty`
- `AlgebraicGeometry.AffineTargetMorphismProperty`:
The type of predicates on `f : X ⟶ Y` with `Y` affine.
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal`: We say that `P.IsLocal` if `P`
satisfies the assumptions of the affine communication lemma
(`AlgebraicGeometry.of_affine_open_cover`). That is,
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basicOpen r` for any
global section `r`.
3. If `P` holds for `f ∣_ Y.basicOpen r` for all `r` in a spanning set of the global sections,
then `P` holds for `f`.
## `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.isStableUnderBaseChange`:
If `Q` is stable under affine base change, then `P` is stable under arbitrary base change.
## Implementation details
The properties `IsZariskiLocalAtTarget` and `IsZariskiLocalAtSource` are defined as abbreviations
for the respective local property of morphism properties defined generally for categories equipped
with a `Precoverage`.
-/
universe u v
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
/-- A property is Zariski-local at target if it is local at target in the Zariski topology. -/
abbrev IsZariskiLocalAtTarget (P : MorphismProperty Scheme.{u}) :=
P.IsLocalAtTarget Scheme.zariskiPrecoverage
namespace IsZariskiLocalAtTarget
/--
`P` is local at the target if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.
-/
protected lemma mk' {P : MorphismProperty Scheme} [P.RespectsIso]
(restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Y.Opens), P f → P (f ∣_ U))
(of_sSup_eq_top :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Y.Opens), iSup U = ⊤ →
(∀ i, P (f ∣_ U i)) → P f) :
IsZariskiLocalAtTarget P where
pullbackSnd 𝒰 i hf := (P.arrow_mk_iso_iff (morphismRestrictOpensRange _ _)).mp (restrict _ _ hf)
of_zeroHypercover {X Y f} 𝒰 h := by
refine of_sSup_eq_top f _ (Scheme.OpenCover.iSup_opensRange 𝒰) ?_
exact fun i ↦ (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (h i)
variable {P : MorphismProperty Scheme.{u}} [IsZariskiLocalAtTarget P]
{X Y : Scheme.{u}} {f : X ⟶ Y} (𝒰 : Y.OpenCover)
lemma of_isPullback {UX UY : Scheme.{u}} {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (H : P f) : P f' :=
MorphismProperty.IsLocalAtTarget.of_isPullback (Y.affineCover.add iY) .none h H
theorem restrict (hf : P f) (U : Y.Opens) : P (f ∣_ U) :=
of_isPullback (isPullback_morphismRestrict f U).flip hf
lemma of_iSup_eq_top {ι} (U : ι → Y.Opens) (hU : iSup U = ⊤)
(H : ∀ i, P (f ∣_ U i)) : P f := by
refine (P.iff_of_zeroHypercover_target
(Y.openCoverOfIsOpenCover (s := Set.range U) Subtype.val (by ext; simp [← hU]))).mpr fun i ↦ ?_
obtain ⟨_, i, rfl⟩ := i
refine (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mp ?_
change P (f ∣_ (U i).ι.opensRange)
rw [Scheme.Opens.opensRange_ι]
exact H i
theorem iff_of_iSup_eq_top {ι} (U : ι → Y.Opens) (hU : iSup U = ⊤) :
P f ↔ ∀ i, P (f ∣_ U i) :=
⟨fun H _ ↦ restrict H _, of_iSup_eq_top U hU⟩
lemma of_openCover (H : ∀ i, P (𝒰.pullbackHom f i)) : P f := by
apply of_iSup_eq_top (fun i ↦ (𝒰.f i).opensRange) 𝒰.iSup_opensRange
exact fun i ↦ (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (H i)
theorem iff_of_openCover (𝒰 : Y.OpenCover) :
P f ↔ ∀ i, P (𝒰.pullbackHom f i) :=
⟨fun H _ ↦ of_isPullback (.of_hasPullback _ _) H, of_openCover _⟩
lemma of_range_subset_iSup [P.RespectsRight @IsOpenImmersion] {ι : Type*} (U : ι → Y.Opens)
(H : Set.range f ⊆ (⨆ i, U i : Y.Opens)) (hf : ∀ i, P (f ∣_ U i)) : P f := by
let g : X ⟶ (⨆ i, U i : Y.Opens) := IsOpenImmersion.lift (Scheme.Opens.ι _) f (by simpa using H)
rw [← IsOpenImmersion.lift_fac (⨆ i, U i).ι f (by simpa using H)]
apply MorphismProperty.RespectsRight.postcomp (Q := @IsOpenImmersion) _ inferInstance
rw [iff_of_iSup_eq_top (P := P) (U := fun i : ι ↦ (⨆ i, U i).ι ⁻¹ᵁ U i)]
· intro i
have heq : g ⁻¹ᵁ (⨆ i, U i).ι ⁻¹ᵁ U i = f ⁻¹ᵁ U i := by
change (g ≫ (⨆ i, U i).ι) ⁻¹ᵁ U i = _
simp [g]
let e : Arrow.mk (g ∣_ (⨆ i, U i).ι ⁻¹ᵁ U i) ≅ Arrow.mk (f ∣_ U i) :=
Arrow.isoMk (X.isoOfEq heq) (Scheme.Opens.isoOfLE (le_iSup U i)) <| by
simp [← CategoryTheory.cancel_mono (U i).ι, g]
rw [P.arrow_mk_iso_iff e]
exact hf i
apply (⨆ i, U i).ι.image_injective
dsimp
rw [Scheme.Hom.image_iSup, Scheme.Hom.image_top_eq_opensRange, Scheme.Opens.opensRange_ι]
simp [Scheme.Hom.image_preimage_eq_opensRange_inf, le_iSup U]
lemma of_forall_source_exists_preimage
[P.RespectsRight IsOpenImmersion] [P.HasOfPostcompProperty IsOpenImmersion]
(f : X ⟶ Y) (hX : ∀ x, ∃ (U : Y.Opens), f x ∈ U ∧ P ((f ⁻¹ᵁ U).ι ≫ f)) :
P f := by
choose U h₁ h₂ using hX
apply IsZariskiLocalAtTarget.of_range_subset_iSup U
· rintro y ⟨x, rfl⟩
simp only [Opens.coe_iSup, Set.mem_iUnion, SetLike.mem_coe]
exact ⟨x, h₁ x⟩
· intro x
exact P.of_postcomp (f ∣_ U x) (U x).ι (inferInstanceAs <| IsOpenImmersion _) (by simp [h₂])
end IsZariskiLocalAtTarget
/-- A property is Zariski-local at source if it is local at source in the Zariski topology. -/
abbrev IsZariskiLocalAtSource (P : MorphismProperty Scheme.{u}) :=
P.IsLocalAtSource Scheme.zariskiPrecoverage
namespace IsZariskiLocalAtSource
/--
`P` is local at the source if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `U.ι ≫ f` for any `U`.
3. If `P` holds for `U.ι ≫ f` for an open cover `U` of `X`, then `P` holds for `f`.
-/
protected lemma mk' {P : MorphismProperty Scheme} [P.RespectsIso]
(restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : X.Opens), P f → P (U.ι ≫ f))
(of_sSup_eq_top :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → X.Opens), iSup U = ⊤ →
(∀ i, P ((U i).ι ≫ f)) → P f) :
IsZariskiLocalAtSource P where
comp 𝒰 i H := by
rw [← IsOpenImmersion.isoOfRangeEq_hom_fac (𝒰.f i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.f i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact restrict _ _ H
of_zeroHypercover {X Y} f 𝒰 h := by
refine of_sSup_eq_top f _ (Scheme.OpenCover.iSup_opensRange 𝒰) fun i ↦ ?_
rw [← IsOpenImmersion.isoOfRangeEq_inv_fac (𝒰.f i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.f i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact h _
variable {P : MorphismProperty Scheme.{u}} [IsZariskiLocalAtSource P]
variable {X Y : Scheme.{u}} {f : X ⟶ Y} (𝒰 : X.OpenCover)
lemma comp {UX : Scheme.{u}} (H : P f) (i : UX ⟶ X) [IsOpenImmersion i] :
P (i ≫ f) :=
(P.iff_of_zeroHypercover_source (X.affineCover.add i)).mp H .none
/-- If `P` is local at the source, then it respects composition on the left with open immersions. -/
instance respectsLeft_isOpenImmersion {P : MorphismProperty Scheme}
[IsZariskiLocalAtSource P] : P.RespectsLeft @IsOpenImmersion where
precomp i _ _ hf := IsZariskiLocalAtSource.comp hf i
lemma of_iSup_eq_top {ι} (U : ι → X.Opens) (hU : iSup U = ⊤)
(H : ∀ i, P ((U i).ι ≫ f)) : P f := by
refine (P.iff_of_zeroHypercover_source
(X.openCoverOfIsOpenCover (s := Set.range U) Subtype.val (by ext; simp [← hU]))).mpr fun i ↦ ?_
obtain ⟨_, i, rfl⟩ := i
exact H i
theorem iff_of_iSup_eq_top {ι} (U : ι → X.Opens) (hU : iSup U = ⊤) :
P f ↔ ∀ i, P ((U i).ι ≫ f) :=
⟨fun H _ ↦ comp H _, of_iSup_eq_top U hU⟩
lemma of_openCover (H : ∀ i, P (𝒰.f i ≫ f)) : P f := by
refine of_iSup_eq_top (fun i ↦ (𝒰.f i).opensRange) 𝒰.iSup_opensRange fun i ↦ ?_
rw [← IsOpenImmersion.isoOfRangeEq_inv_fac (𝒰.f i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.f i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact H i
theorem iff_of_openCover :
P f ↔ ∀ i, P (𝒰.f i ≫ f) :=
⟨fun H _ ↦ comp H _, of_openCover _⟩
variable (f) in
lemma of_isOpenImmersion [P.ContainsIdentities] [IsOpenImmersion f] : P f :=
Category.comp_id f ▸ comp (P.id_mem Y) f
lemma isZariskiLocalAtTarget [P.IsMultiplicative]
(hP : ∀ {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) [IsOpenImmersion g], P (f ≫ g) → P f) :
IsZariskiLocalAtTarget P where
pullbackSnd {X Y} f 𝒰 i hf := by
apply hP _ (𝒰.f i)
rw [← pullback.condition]
exact IsZariskiLocalAtSource.comp hf _
of_zeroHypercover {X Y} f 𝒰 h := by
rw [P.iff_of_zeroHypercover_source (𝒰.pullback₁ f)]
intro i
rw [← Scheme.Cover.pullbackHom_map]
exact P.comp_mem _ _ (h i) (of_isOpenImmersion _)
lemma sigmaDesc {X : Scheme.{u}} {ι : Type v} [Small.{u} ι] {Y : ι → Scheme.{u}}
{f : ∀ i, Y i ⟶ X} (hf : ∀ i, P (f i)) : P (Sigma.desc f) := by
rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) (Scheme.IsLocallyDirected.openCover _)]
exact fun i ↦ by simp [hf]
section IsZariskiLocalAtSourceAndTarget
/-- If `P` is local at the source and the target, then restriction on both source and target
preserves `P`. -/
lemma resLE [IsZariskiLocalAtTarget P] {U : Y.Opens} {V : X.Opens}
(e : V ≤ f ⁻¹ᵁ U)
(hf : P f) : P (f.resLE U V e) :=
IsZariskiLocalAtSource.comp (IsZariskiLocalAtTarget.restrict hf U) _
/-- If `P` is local at the source, local at the target and is stable under post-composition with
open immersions, then `P` can be checked locally around points. -/
lemma iff_exists_resLE [IsZariskiLocalAtTarget P]
[P.RespectsRight @IsOpenImmersion] :
P f ↔ ∀ x : X, ∃ (U : Y.Opens) (V : X.Opens) (_ : x ∈ V.1) (e : V ≤ f ⁻¹ᵁ U),
P (f.resLE U V e) := by
refine ⟨fun hf x ↦ ⟨⊤, ⊤, trivial, by simp, resLE _ hf⟩, fun hf ↦ ?_⟩
choose U V hxU e hf using hf
rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (fun x : X ↦ V x) (P := P)]
· intro x
rw [← Scheme.Hom.resLE_comp_ι _ (e x)]
exact MorphismProperty.RespectsRight.postcomp (Q := @IsOpenImmersion) _ inferInstance _ (hf x)
· rw [eq_top_iff]
rintro x -
simp only [Opens.coe_iSup, Set.mem_iUnion, SetLike.mem_coe]
use x, hxU x
end IsZariskiLocalAtSourceAndTarget
end IsZariskiLocalAtSource
/-- An `AffineTargetMorphismProperty` is a class of morphisms from an arbitrary scheme into an
affine scheme. -/
def AffineTargetMorphismProperty :=
∀ ⦃X Y : Scheme⦄ (_ : X ⟶ Y) [IsAffine Y], Prop
namespace AffineTargetMorphismProperty
@[ext]
lemma ext {P Q : AffineTargetMorphismProperty}
(H : ∀ ⦃X Y : Scheme⦄ (f : X ⟶ Y) [IsAffine Y], P f ↔ Q f) : P = Q := by
delta AffineTargetMorphismProperty; ext; exact H _
/-- The restriction of a `MorphismProperty Scheme` to morphisms with affine target. -/
def of (P : MorphismProperty Scheme) : AffineTargetMorphismProperty :=
fun _ _ f _ ↦ P f
/-- An `AffineTargetMorphismProperty` can be extended to a `MorphismProperty` such that it
*never* holds when the target is not affine -/
def toProperty (P : AffineTargetMorphismProperty) :
MorphismProperty Scheme := fun _ _ f => ∃ h, @P _ _ f h
theorem toProperty_apply (P : AffineTargetMorphismProperty)
{X Y : Scheme} (f : X ⟶ Y) [i : IsAffine Y] : P.toProperty f ↔ P f := by
delta AffineTargetMorphismProperty.toProperty; simp [*]
theorem cancel_left_of_respectsIso
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsAffine Z] : P (f ≫ g) ↔ P g := by
rw [← P.toProperty_apply, ← P.toProperty_apply, P.toProperty.cancel_left_of_respectsIso]
theorem cancel_right_of_respectsIso
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsAffine Z] [IsAffine Y] :
P (f ≫ g) ↔ P f := by rw [← P.toProperty_apply, ← P.toProperty_apply,
P.toProperty.cancel_right_of_respectsIso]
theorem arrow_mk_iso_iff
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y X' Y' : Scheme} {f : X ⟶ Y} {f' : X' ⟶ Y'}
(e : Arrow.mk f ≅ Arrow.mk f') {h : IsAffine Y} :
letI : IsAffine Y' := .of_isIso (Y := Y) e.inv.right
P f ↔ P f' := by
rw [← P.toProperty_apply, ← P.toProperty_apply, P.toProperty.arrow_mk_iso_iff e]
theorem respectsIso_mk {P : AffineTargetMorphismProperty}
(h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
(h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [IsAffine Y],
P f → @P _ _ (f ≫ e.hom) (.of_isIso e.inv)) :
P.toProperty.RespectsIso := by
apply MorphismProperty.RespectsIso.mk
· rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
· rintro X Y Z e f ⟨a, h⟩; exact ⟨.of_isIso e.inv, h₂ e f h⟩
instance respectsIso_of
(P : MorphismProperty Scheme) [P.RespectsIso] :
(of P).toProperty.RespectsIso := by
apply respectsIso_mk
· intro _ _ _ _ _ _; apply MorphismProperty.RespectsIso.precomp
· intro _ _ _ _ _ _; apply MorphismProperty.RespectsIso.postcomp
/-- We say that `P : AffineTargetMorphismProperty` is a local property if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basicOpen r` for any
global section `r`.
3. If `P` holds for `f ∣_ Y.basicOpen r` for all `r` in a spanning set of the global sections,
then `P` holds for `f`.
-/
class IsLocal (P : AffineTargetMorphismProperty) : Prop where
/-- `P` as a morphism property respects isomorphisms -/
respectsIso : P.toProperty.RespectsIso
/-- `P` is stable under restriction to basic open set of global sections. -/
to_basicOpen :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (r : Γ(Y, ⊤)), P f → P (f ∣_ Y.basicOpen r)
/-- `P` for `f` if `P` holds for `f` restricted to basic sets of a spanning set of the global
sections -/
of_basicOpenCover :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (s : Finset Γ(Y, ⊤))
(_ : Ideal.span (s : Set Γ(Y, ⊤)) = ⊤), (∀ r : s, P (f ∣_ Y.basicOpen r.1)) → P f
attribute [instance] AffineTargetMorphismProperty.IsLocal.respectsIso
open AffineTargetMorphismProperty in
instance (P : MorphismProperty Scheme) [IsZariskiLocalAtTarget P] :
(of P).IsLocal where
respectsIso := inferInstance
to_basicOpen _ _ H := IsZariskiLocalAtTarget.restrict H _
of_basicOpenCover {_ Y} _ _ _ hs := IsZariskiLocalAtTarget.of_iSup_eq_top _
((isAffineOpen_top Y).iSup_basicOpen_eq_self_iff.mpr hs)
/-- A `P : AffineTargetMorphismProperty` is stable under base change if `P` holds for `Y ⟶ S`
implies that `P` holds for `X ×ₛ Y ⟶ X` with `X` and `S` affine schemes. -/
def IsStableUnderBaseChange (P : AffineTargetMorphismProperty) : Prop :=
∀ ⦃Z X Y S : Scheme⦄ [IsAffine S] [IsAffine X] {f : X ⟶ S} {g : Y ⟶ S}
{f' : Z ⟶ Y} {g' : Z ⟶ X}, IsPullback g' f' f g → P g → P g'
lemma IsStableUnderBaseChange.mk (P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
(H : ∀ ⦃X Y S : Scheme⦄ [IsAffine S] [IsAffine X] (f : X ⟶ S) (g : Y ⟶ S),
P g → P (pullback.fst f g)) : P.IsStableUnderBaseChange := by
intro Z X Y S _ _ f g f' g' h hg
rw [← P.cancel_left_of_respectsIso h.isoPullback.inv, h.isoPullback_inv_fst]
exact H f g hg
end AffineTargetMorphismProperty
section targetAffineLocally
/-- For a `P : AffineTargetMorphismProperty`, `targetAffineLocally P` holds for
`f : X ⟶ Y` whenever `P` holds for the restriction of `f` on every affine open subset of `Y`. -/
def targetAffineLocally (P : AffineTargetMorphismProperty) : MorphismProperty Scheme :=
fun {X Y : Scheme} (f : X ⟶ Y) => ∀ U : Y.affineOpens, P (f ∣_ U)
theorem of_targetAffineLocally_of_isPullback
{P : AffineTargetMorphismProperty} [P.IsLocal]
{X Y UX UY : Scheme.{u}} [IsAffine UY] {f : X ⟶ Y} {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (hf : targetAffineLocally P f) :
P f' := by
rw [← P.cancel_left_of_respectsIso h.isoPullback.inv, h.isoPullback_inv_snd]
exact (P.arrow_mk_iso_iff
(morphismRestrictOpensRange f _)).mp (hf ⟨_, isAffineOpen_opensRange iY⟩)
instance (P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso] :
(targetAffineLocally P).RespectsIso := by
apply MorphismProperty.RespectsIso.mk
· introv H U
rw [morphismRestrict_comp, P.cancel_left_of_respectsIso]
exact H U
· introv H
rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
haveI : IsAffine _ := hU.preimage_of_isIso e.hom
rw [morphismRestrict_comp, P.cancel_right_of_respectsIso]
exact H ⟨(Opens.map e.hom.base).obj U, hU.preimage_of_isIso e.hom⟩
/--
`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`.
To make the proofs easier, we state it instead as
1. `Q` is local at the target
2. `P f` if and only if `∀ U, Q (f ∣_ U)` ranging over all affine opens of `U`.
See `HasAffineProperty.iff`.
-/
class HasAffineProperty (P : MorphismProperty Scheme)
(Q : outParam AffineTargetMorphismProperty) : Prop where
isLocal_affineProperty : Q.IsLocal
eq_targetAffineLocally' : P = targetAffineLocally Q
namespace HasAffineProperty
variable (P : MorphismProperty Scheme) {Q} [HasAffineProperty P Q]
variable {X Y : Scheme.{u}} {f : X ⟶ Y}
instance (Q : AffineTargetMorphismProperty) [Q.IsLocal] :
HasAffineProperty (targetAffineLocally Q) Q :=
⟨inferInstance, rfl⟩
lemma eq_targetAffineLocally : P = targetAffineLocally Q := eq_targetAffineLocally'
/-- Every property local at the target can be associated with an affine target property.
This is not an instance as the associated property can often take on simpler forms. -/
lemma of_isZariskiLocalAtTarget (P : MorphismProperty Scheme.{u})
[IsZariskiLocalAtTarget P] :
HasAffineProperty P (AffineTargetMorphismProperty.of P) where
isLocal_affineProperty := inferInstance
eq_targetAffineLocally' := by
ext X Y f
constructor
· intro hf ⟨U, hU⟩
exact IsZariskiLocalAtTarget.restrict hf _
· intro hf
exact P.of_zeroHypercover_target Y.affineCover
fun i ↦ of_targetAffineLocally_of_isPullback (.of_hasPullback _ _) hf
@[deprecated (since := "2025-10-07")] alias of_isLocalAtTarget := of_isZariskiLocalAtTarget
lemma copy {P P'} {Q Q'} [HasAffineProperty P Q]
(e : P = P') (e' : Q = Q') : HasAffineProperty P' Q' where
isLocal_affineProperty := e' ▸ isLocal_affineProperty P
eq_targetAffineLocally' := e' ▸ e.symm ▸ eq_targetAffineLocally P
variable {P}
theorem of_isPullback {UX UY : Scheme.{u}} [IsAffine UY] {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (hf : P f) :
Q f' :=
letI := isLocal_affineProperty P
of_targetAffineLocally_of_isPullback h (eq_targetAffineLocally (P := P) ▸ hf)
theorem restrict (hf : P f) (U : Y.affineOpens) :
Q (f ∣_ U) :=
of_isPullback (isPullback_morphismRestrict f U).flip hf
instance (priority := 900) : P.RespectsIso := by
letI := isLocal_affineProperty P
rw [eq_targetAffineLocally P]
infer_instance
theorem of_iSup_eq_top
{ι} (U : ι → Y.affineOpens) (hU : ⨆ i, (U i : Y.Opens) = ⊤)
(hU' : ∀ i, Q (f ∣_ U i)) :
P f := by
letI := isLocal_affineProperty P
rw [eq_targetAffineLocally P]
classical
intro V
induction V using of_affine_open_cover U hU with
| basicOpen U r h =>
haveI : IsAffine _ := U.2
have := AffineTargetMorphismProperty.IsLocal.to_basicOpen (f ∣_ U.1) (U.1.topIso.inv r) h
exact (Q.arrow_mk_iso_iff
(morphismRestrictRestrictBasicOpen f _ r)).mp this
| openCover U s hs H =>
apply AffineTargetMorphismProperty.IsLocal.of_basicOpenCover _
(s.image (Scheme.Opens.topIso _).inv) (by simp [← Ideal.map_span, hs, Ideal.map_top])
intro ⟨r, hr⟩
obtain ⟨r, hr', rfl⟩ := Finset.mem_image.mp hr
exact (Q.arrow_mk_iso_iff
(morphismRestrictRestrictBasicOpen f _ r).symm).mp (H ⟨r, hr'⟩)
| hU i => exact hU' i
theorem iff_of_iSup_eq_top
{ι} (U : ι → Y.affineOpens) (hU : ⨆ i, (U i : Y.Opens) = ⊤) :
P f ↔ ∀ i, Q (f ∣_ U i) :=
⟨fun H _ ↦ restrict H _, fun H ↦ HasAffineProperty.of_iSup_eq_top U hU H⟩
theorem of_openCover
(𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.X i)] (h𝒰 : ∀ i, Q (𝒰.pullbackHom f i)) :
P f :=
letI := isLocal_affineProperty P
of_iSup_eq_top
(fun i ↦ ⟨_, isAffineOpen_opensRange (𝒰.f i)⟩) 𝒰.iSup_opensRange
(fun i ↦ (Q.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (h𝒰 i))
theorem iff_of_openCover (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.X i)] :
P f ↔ ∀ i, Q (𝒰.pullbackHom f i) := by
letI := isLocal_affineProperty P
rw [iff_of_iSup_eq_top (P := P)
(fun i ↦ ⟨_, isAffineOpen_opensRange _⟩) 𝒰.iSup_opensRange]
exact forall_congr' fun i ↦ Q.arrow_mk_iso_iff
(morphismRestrictOpensRange f _)
theorem iff_of_isAffine [IsAffine Y] : P f ↔ Q f := by
letI := isLocal_affineProperty P
haveI : ∀ i, IsAffine ((Scheme.coverOfIsIso (P := @IsOpenImmersion) (𝟙 Y)).X i) := fun i => by
dsimp; infer_instance
rw [iff_of_openCover (P := P) (Scheme.coverOfIsIso.{0} (𝟙 Y))]
trans Q (pullback.snd f (𝟙 _))
· exact ⟨fun H => H PUnit.unit, fun H _ => H⟩
rw [← Category.comp_id (pullback.snd _ _), ← pullback.condition,
Q.cancel_left_of_respectsIso]
instance (priority := 900) : IsZariskiLocalAtTarget P := by
letI := isLocal_affineProperty P
apply IsZariskiLocalAtTarget.mk'
· rw [eq_targetAffineLocally P]
intro X Y f U H V
rw [Q.arrow_mk_iso_iff (morphismRestrictRestrict f _ _)]
exact H ⟨_, V.2.image_of_isOpenImmersion (Y.ofRestrict _)⟩
· rintro X Y f ι U hU H
let 𝒰 := Y.openCoverOfIsOpenCover U hU
apply of_openCover 𝒰.affineRefinement.openCover
rintro ⟨i, j⟩
have : P (𝒰.pullbackHom f i) := by
refine (P.arrow_mk_iso_iff
(morphismRestrictEq _ ?_ ≪≫ morphismRestrictOpensRange f (𝒰.f i))).mp (H i)
exact (Scheme.Opens.opensRange_ι _).symm
rw [← Q.cancel_left_of_respectsIso (𝒰.pullbackCoverAffineRefinementObjIso f _).inv,
𝒰.pullbackCoverAffineRefinementObjIso_inv_pullbackHom]
exact of_isPullback (.of_hasPullback _ _) this
open AffineTargetMorphismProperty in
protected theorem iff {P : MorphismProperty Scheme} {Q : AffineTargetMorphismProperty} :
HasAffineProperty P Q ↔ IsZariskiLocalAtTarget P ∧ Q = of P :=
⟨fun _ ↦ ⟨inferInstance, ext fun _ _ _ ↦ iff_of_isAffine.symm⟩,
fun ⟨_, e⟩ ↦ e ▸ of_isZariskiLocalAtTarget P⟩
private theorem pullback_fst_of_right (hP' : Q.IsStableUnderBaseChange)
{X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : Q g) :
P (pullback.fst f g) := by
letI := isLocal_affineProperty P
rw [iff_of_openCover (P := P) X.affineCover]
intro i
let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.f i)
have : e.hom ≫ pullback.fst _ _ = X.affineCover.pullbackHom (pullback.fst _ _) i := by
simp [e, Scheme.Cover.pullbackHom]
rw [← this, Q.cancel_left_of_respectsIso]
apply hP' (.of_hasPullback _ _)
exact H
theorem isStableUnderBaseChange (hP' : Q.IsStableUnderBaseChange) :
P.IsStableUnderBaseChange :=
MorphismProperty.IsStableUnderBaseChange.mk'
(fun X Y S f g _ H => by
rw [P.iff_of_zeroHypercover_target (S.affineCover.pullback₁ f)]
intro i
let e : pullback (pullback.fst f g) ((S.affineCover.pullback₁ f).f i) ≅
_ := by
refine pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g _ ≪≫ ?_ ≪≫
(pullbackRightPullbackFstIso (S.affineCover.f i) g
(pullback.snd f (S.affineCover.f i))).symm
exact asIso
(pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simpa using pullback.condition) (by simp))
have : e.hom ≫ pullback.fst _ _ =
pullback.snd (pullback.fst f g) ((S.affineCover.pullback₁ f).f i) := by
simp [e]
rw [← this, P.cancel_left_of_respectsIso]
apply HasAffineProperty.pullback_fst_of_right hP'
letI := isLocal_affineProperty P
rw [← pullbackSymmetry_hom_comp_snd, Q.cancel_left_of_respectsIso]
apply of_isPullback (.of_hasPullback _ _) H)
lemma isZariskiLocalAtSource
(H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] (𝒰 : Scheme.OpenCover.{u} X),
Q f ↔ ∀ i, Q (𝒰.f i ≫ f)) : IsZariskiLocalAtSource P := by
refine .mk_of_iff ?_
intro X Y f 𝒰
simp_rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top _ (iSup_affineOpens_eq_top Y)]
rw [forall_comm]
refine forall_congr' fun U ↦ ?_
simp_rw [HasAffineProperty.iff_of_isAffine, morphismRestrict_comp]
exact @H _ _ (f ∣_ U.1) U.2 (Scheme.OpenCover.restrict 𝒰 (f ⁻¹ᵁ U.1))
end HasAffineProperty
end targetAffineLocally
open MorphismProperty
lemma hasOfPostcompProperty_isOpenImmersion_of_morphismRestrict (P : MorphismProperty Scheme)
[P.RespectsIso] (H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens), P f → P (f ∣_ U)) :
P.HasOfPostcompProperty @IsOpenImmersion where
of_postcomp {X Y Z} f g hg hfg := by
have : (f ≫ g) ⁻¹ᵁ g.opensRange = ⊤ := by simp
have : f = X.topIso.inv ≫ (X.isoOfEq this).inv ≫ (f ≫ g) ∣_ g.opensRange ≫
(IsOpenImmersion.isoOfRangeEq g.opensRange.ι g (by simp)).hom := by
simp [← cancel_mono g]
simp_rw [this, cancel_left_of_respectsIso (P := P), cancel_right_of_respectsIso (P := P)]
exact H _ _ hfg
instance (P : MorphismProperty Scheme) [P.IsStableUnderBaseChange] :
P.HasOfPostcompProperty @IsOpenImmersion :=
HasOfPostcompProperty.of_le P (.monomorphisms Scheme) (fun _ _ f _ ↦ inferInstanceAs (Mono f))
section Deprecations
@[deprecated (since := "2025-10-07")] alias IsLocalAtTarget := IsZariskiLocalAtTarget
namespace IsLocalAtTarget
@[deprecated (since := "2025-10-07")]
alias mk' := IsZariskiLocalAtTarget.mk'
@[deprecated (since := "2025-10-07")]
alias of_iSup_eq_top := IsZariskiLocalAtTarget.of_iSup_eq_top
@[deprecated (since := "2025-10-07")]
alias iff_of_iSup_eq_top := IsZariskiLocalAtTarget.iff_of_iSup_eq_top
@[deprecated (since := "2025-10-07")]
alias of_openCover := IsZariskiLocalAtTarget.of_openCover
@[deprecated (since := "2025-10-07")]
alias iff_of_openCover := IsZariskiLocalAtTarget.iff_of_openCover
@[deprecated (since := "2025-10-07")]
alias of_isPullback := IsZariskiLocalAtTarget.of_isPullback
@[deprecated (since := "2025-10-07")]
alias restrict := IsZariskiLocalAtTarget.restrict
@[deprecated (since := "2025-10-07")]
alias of_range_subset_iSup := IsZariskiLocalAtTarget.of_range_subset_iSup
end IsLocalAtTarget
@[deprecated (since := "2025-10-07")] alias IsLocalAtSource := IsZariskiLocalAtSource
namespace IsLocalAtSource
@[deprecated (since := "2025-10-07")]
alias mk' := IsZariskiLocalAtSource.mk'
@[deprecated (since := "2025-10-07")]
alias comp := IsZariskiLocalAtSource.comp
@[deprecated (since := "2025-10-07")]
alias respectsLeft_isOpenImmersion := IsZariskiLocalAtSource.respectsLeft_isOpenImmersion
@[deprecated (since := "2025-10-07")]
alias of_iSup_eq_top := IsZariskiLocalAtSource.of_iSup_eq_top
@[deprecated (since := "2025-10-07")]
alias iff_of_iSup_eq_top := IsZariskiLocalAtSource.iff_of_iSup_eq_top
@[deprecated (since := "2025-10-07")]
alias of_openCover := IsZariskiLocalAtSource.of_openCover
@[deprecated (since := "2025-10-07")]
alias iff_of_openCover := IsZariskiLocalAtSource.iff_of_openCover
@[deprecated (since := "2025-10-07")]
alias of_isOpenImmersion := IsZariskiLocalAtSource.of_isOpenImmersion
@[deprecated (since := "2025-10-07")]
alias isLocalAtTarget := IsZariskiLocalAtSource.isZariskiLocalAtTarget
@[deprecated (since := "2025-10-07")]
alias sigmaDesc := IsZariskiLocalAtSource.sigmaDesc
@[deprecated (since := "2025-10-07")]
alias resLE := IsZariskiLocalAtSource.resLE
@[deprecated (since := "2025-10-07")]
alias iff_exists_resLE := IsZariskiLocalAtSource.iff_exists_resLE
end IsLocalAtSource
end Deprecations
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion.lean | import Mathlib.AlgebraicGeometry.IdealSheaf.Subscheme
import Mathlib.AlgebraicGeometry.Morphisms.AffineAnd
import Mathlib.AlgebraicGeometry.Morphisms.FiniteType
import Mathlib.AlgebraicGeometry.ResidueField
import Mathlib.CategoryTheory.MorphismProperty.Comma
/-!
# Closed immersions of schemes
A morphism of schemes `f : X ⟶ Y` is a closed immersion if the underlying map of topological spaces
is a closed immersion and the induced morphisms of stalks are all surjective.
## Main definitions
* `IsClosedImmersion` : The property of scheme morphisms stating `f : X ⟶ Y` is a closed immersion.
## TODO
* Show closed immersions are precisely the proper monomorphisms
* Define closed immersions of locally ringed spaces, where we also assume that the kernel of `O_X →
f_*O_Y` is locally generated by sections as an `O_X`-module, and relate it to this file. See
https://stacks.math.columbia.edu/tag/01HJ.
-/
universe v u
open CategoryTheory Opposite TopologicalSpace Topology
namespace AlgebraicGeometry
/-- A morphism of schemes `X ⟶ Y` is a closed immersion if the underlying
topological map is a closed embedding and the induced stalk maps are surjective. -/
@[mk_iff]
class IsClosedImmersion {X Y : Scheme} (f : X ⟶ Y) : Prop extends SurjectiveOnStalks f where
base_closed : IsClosedEmbedding f
lemma Scheme.Hom.isClosedEmbedding {X Y : Scheme} (f : X ⟶ Y)
[IsClosedImmersion f] : IsClosedEmbedding f :=
IsClosedImmersion.base_closed
namespace IsClosedImmersion
lemma eq_inf : @IsClosedImmersion = (topologically IsClosedEmbedding) ⊓
@SurjectiveOnStalks := by
ext X Y f
rw [isClosedImmersion_iff, and_comm]
rfl
lemma iff_isPreimmersion {X Y : Scheme} {f : X ⟶ Y} :
IsClosedImmersion f ↔ IsPreimmersion f ∧ IsClosed (Set.range f) := by
rw [isClosedImmersion_iff, isPreimmersion_iff, and_assoc, isClosedEmbedding_iff]
lemma of_isPreimmersion {X Y : Scheme} (f : X ⟶ Y) [IsPreimmersion f]
(hf : IsClosed (Set.range f)) : IsClosedImmersion f :=
iff_isPreimmersion.mpr ⟨‹_›, hf⟩
instance (priority := 900) {X Y : Scheme} (f : X ⟶ Y) [IsClosedImmersion f] : IsPreimmersion f :=
(iff_isPreimmersion.mp ‹_›).1
/-- Isomorphisms are closed immersions. -/
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : IsClosedImmersion f where
base_closed := Homeomorph.isClosedEmbedding <| TopCat.homeoOfIso (asIso f.base)
surj_on_stalks := fun _ ↦ (ConcreteCategory.bijective_of_isIso _).2
instance (priority := low) {X Y : Scheme.{u}} [IsEmpty X] (f : X ⟶ Y) : IsClosedImmersion f :=
.of_isPreimmersion _ (by rw [Set.range_eq_empty]; exact isClosed_empty)
instance : MorphismProperty.IsMultiplicative @IsClosedImmersion where
id_mem _ := inferInstance
comp_mem _ _ hf hg := ⟨hg.base_closed.comp hf.base_closed⟩
/-- Composition of closed immersions is a closed immersion. -/
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsClosedImmersion f]
[IsClosedImmersion g] : IsClosedImmersion (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
/-- Composition with an isomorphism preserves closed immersions. -/
instance respectsIso : MorphismProperty.RespectsIso @IsClosedImmersion := by
apply MorphismProperty.RespectsIso.mk <;> intro X Y Z e f hf <;> infer_instance
instance {X : Scheme} (I : X.IdealSheafData) : IsClosedImmersion I.subschemeι :=
.of_isPreimmersion _ (I.range_subschemeι ▸ I.support.isClosed)
/-- Given two commutative rings `R S : CommRingCat` and a surjective morphism
`f : R ⟶ S`, the induced scheme morphism `specObj S ⟶ specObj R` is a
closed immersion. -/
theorem spec_of_surjective {R S : CommRingCat} (f : R ⟶ S) (h : Function.Surjective f) :
IsClosedImmersion (Spec.map f) where
base_closed := PrimeSpectrum.isClosedEmbedding_comap_of_surjective _ _ h
surj_on_stalks x := by
haveI : (RingHom.toMorphismProperty (fun f ↦ Function.Surjective f)).RespectsIso := by
rw [← RingHom.toMorphismProperty_respectsIso_iff]
exact RingHom.surjective_respectsIso
apply (MorphismProperty.arrow_mk_iso_iff
(RingHom.toMorphismProperty (fun f ↦ Function.Surjective f))
(Scheme.arrowStalkMapSpecIso f x)).mpr
exact RingHom.surjective_localRingHom_of_surjective f.hom h x.asIdeal
/-- For any ideal `I` in a commutative ring `R`, the quotient map `specObj R ⟶ specObj (R ⧸ I)`
is a closed immersion. -/
instance spec_of_quotient_mk {R : CommRingCat.{u}} (I : Ideal R) :
IsClosedImmersion (Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk I))) :=
spec_of_surjective _ Ideal.Quotient.mk_surjective
/-- Any morphism between affine schemes that is surjective on global sections is a
closed immersion. -/
lemma of_surjective_of_isAffine {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y)
(h : Function.Surjective (f.appTop)) : IsClosedImmersion f := by
rw [MorphismProperty.arrow_mk_iso_iff @IsClosedImmersion (arrowIsoSpecΓOfIsAffine f)]
apply spec_of_surjective
exact h
/--
If `f ≫ g` and `g` are closed immersions, then `f` is a closed immersion.
Also see `IsClosedImmersion.of_comp` for the general version
where `g` is only required to be separated.
-/
theorem of_comp_isClosedImmersion {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsClosedImmersion g]
[IsClosedImmersion (f ≫ g)] : IsClosedImmersion f where
base_closed := by
have h := (f ≫ g).isClosedEmbedding
simp only [Scheme.Hom.comp_base, TopCat.coe_comp] at h
refine .of_continuous_injective_isClosedMap (Scheme.Hom.continuous f) h.injective.of_comp ?_
intro Z hZ
rw [IsClosedEmbedding.isClosed_iff_image_isClosed g.isClosedEmbedding,
← Set.image_comp]
exact h.isClosedMap _ hZ
surj_on_stalks x := by
have h := (f ≫ g).stalkMap_surjective x
simp_rw [Scheme.Hom.stalkMap_comp] at h
exact Function.Surjective.of_comp h
instance SpecMap_residue {X : Scheme.{u}} (x) : IsClosedImmersion (Spec.map (X.residue x)) :=
IsClosedImmersion.spec_of_surjective (X.residue x)
Ideal.Quotient.mk_surjective
@[deprecated (since := "2025-10-07")] alias Spec_map_residue := SpecMap_residue
instance (priority := low) {X Y : Scheme} (f : X ⟶ Y) [IsClosedImmersion f] : IsAffineHom f :=
isAffineHom_of_isInducing _ f.isClosedEmbedding.isInducing f.isClosedEmbedding.isClosed_range
instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsClosedImmersion f] :
IsIso f.toImage := by
have := @of_comp_isClosedImmersion _ _ _ f.toImage f.imageι inferInstance
(by rw [Scheme.Hom.toImage_imageι]; infer_instance)
have : IsHomeomorph f.toImage :=
isHomeomorph_iff_isEmbedding_surjective.mpr ⟨f.toImage.isEmbedding, by
rw [← Set.range_eq_univ, ← f.toImage.isClosedEmbedding.isClosed_range.closure_eq]
exact f.toImage.denseRange.closure_eq⟩
refine isomorphisms_eq_stalkwise.ge _ ⟨?_, ?_⟩
· exact inferInstanceAs (IsIso (TopCat.isoOfHomeo this.homeomorph).hom)
· intro x
refine ⟨?_, f.toImage.stalkMap_surjective x⟩
change Function.Injective (CommRingCat.Hom.hom (((TopCat.Presheaf.stalkFunctor CommRingCat
(f.toImage x)).map f.toImage.c) ≫ X.presheaf.stalkPushforward _ _ x))
simp only [TopCat.Presheaf.stalkFunctor_obj, CommRingCat.hom_comp, RingHom.coe_comp]
refine .comp ?_ (f.stalkFunctor_toImage_injective _)
have := TopCat.Presheaf.stalkPushforward.stalkPushforward_iso_of_isInducing CommRingCat
(f := f.toImage.base) f.toImage.isEmbedding.isInducing X.presheaf x
exact ((ConcreteCategory.isIso_iff_bijective _).mp this).1
/-- The category of closed subschemes is contravariantly equivalent
to the lattice of ideal sheaves. -/
noncomputable
def overEquivIdealSheafData (X : Scheme.{u}) :
(MorphismProperty.Over @IsClosedImmersion ⊤ X)ᵒᵖ ≌ X.IdealSheafData where
functor := (MorphismProperty.Over.forget _ _ _).op ⋙ X.kerFunctor
inverse :=
{ obj I := .op <| .mk _ I.subschemeι inferInstance
map {I J} h := (MorphismProperty.Over.homMk (Scheme.IdealSheafData.inclusion h.le)).op
map_comp f g := Quiver.Hom.unop_inj (by ext1; simp) }
unitIso := NatIso.ofComponents (fun Y ↦
letI : IsClosedImmersion Y.unop.hom := Y.unop.prop
((MorphismProperty.Over.isoMk (asIso Y.unop.hom.toImage).symm).op)) fun {X Y} f ↦ by
apply Quiver.Hom.unop_inj
ext1
dsimp
rw [IsIso.eq_comp_inv, Category.assoc, IsIso.inv_comp_eq,
← cancel_mono (Scheme.IdealSheafData.subschemeι _)]
simp
counitIso := NatIso.ofComponents (fun I ↦ eqToIso (by simp))
lemma isIso_iff_ker_eq_bot {X Y : Scheme.{u}} {f : X ⟶ Y} [IsClosedImmersion f] :
IsIso f ↔ f.ker = ⊥ := by
refine ⟨fun _ ↦ f.ker_eq_bot_of_isIso, fun H ↦ ?_⟩
have : IsIso f.imageι := by simpa [Scheme.Hom.imageι, Scheme.Hom.image] using H ▸ inferInstance
exact f.toImage_imageι ▸ inferInstance
/-- The universal property of closed immersions:
For a closed immersion `f : X ⟶ Z`, given any morphism of schemes `g : Y ⟶ Z` whose kernel
contains the kernel of `X` in `Z`, we can lift this morphism to a unique `Y ⟶ X` that
commutes with these maps.
-/
noncomputable
def lift {X Y Z : Scheme.{u}}
(f : X ⟶ Z) (g : Y ⟶ Z) [IsClosedImmersion f] (H : f.ker ≤ g.ker) : Y ⟶ X :=
g.toImage ≫ Scheme.IdealSheafData.inclusion H ≫ inv f.toImage
@[reassoc (attr := simp)]
lemma lift_fac {X Y Z : Scheme.{u}}
(f : X ⟶ Z) (g : Y ⟶ Z) [IsClosedImmersion f] (H : f.ker ≤ g.ker) : lift f g H ≫ f = g := by
nth_rw 2 [← f.toImage_imageι]
simp [lift, - Scheme.Hom.toImage_imageι, g.toImage_imageι]
lemma isIso_of_ker_eq {Z₁ Z₂ X : Scheme.{u}} (i₁ : Z₁ ⟶ X) (i₂ : Z₂ ⟶ X)
[IsClosedImmersion i₁] [IsClosedImmersion i₂] (f : Z₁ ⟶ Z₂)
(h : f ≫ i₂ = i₁) (h' : i₁.ker = i₂.ker) : IsIso f := by
let f' : MorphismProperty.Over.mk ⊤ i₁ ‹_› ⟶ .mk ⊤ i₂ ‹_› := MorphismProperty.Over.homMk f h
suffices h : IsIso f'.op by
rwa [isIso_op_iff, ← isIso_iff_of_reflects_iso _ (MorphismProperty.Over.forget ..),
← isIso_iff_of_reflects_iso _ (Over.forget _)] at h
rw [← isIso_iff_of_reflects_iso _ (IsClosedImmersion.overEquivIdealSheafData X).functor]
simpa [IsClosedImmersion.overEquivIdealSheafData] using ⟨homOfLE h'.le, by simp, by simp⟩
lemma isIso_lift {Z₁ Z₂ X : Scheme.{u}} (i₁ : Z₁ ⟶ X) (i₂ : Z₂ ⟶ X)
[IsClosedImmersion i₁] [IsClosedImmersion i₂] (h : i₁.ker = i₂.ker) :
IsIso (lift i₁ i₂ h.le) :=
isIso_of_ker_eq i₂ i₁ _ (by simp) h.symm
end IsClosedImmersion
section Affine
variable {X Y : Scheme.{u}} [IsAffine Y] {f : X ⟶ Y}
open IsClosedImmersion LocallyRingedSpace
/-- If `f : X ⟶ Y` is a morphism of schemes with quasi-compact source and affine target,
`f` induces an injection on global sections, then `f` is dominant. -/
lemma isDominant_of_of_appTop_injective [CompactSpace X]
(hfinj : Function.Injective (f.appTop)) :
IsDominant f := by
have : QuasiCompact f := HasAffineProperty.iff_of_isAffine.mpr ‹_›
have : f.ker = ⊥ := Scheme.IdealSheafData.ext_of_isAffine
(by simpa [f.ker_apply ⟨⊤, isAffineOpen_top Y⟩, ← RingHom.injective_iff_ker_eq_bot])
exact ⟨by simpa only [Scheme.Hom.support_ker, Scheme.IdealSheafData.support_bot,
Closeds.coe_top, ← dense_iff_closure_eq] using (congr((↑($this).support : Set Y)) :)⟩
@[deprecated (since := "2025-05-10")]
alias surjective_of_isClosed_range_of_injective := isDominant_of_of_appTop_injective
instance [CompactSpace X] : IsDominant X.toSpecΓ :=
isDominant_of_of_appTop_injective (by
simpa only [Scheme.toSpecΓ_appTop] using
(ConcreteCategory.bijective_of_isIso (Scheme.ΓSpecIso Γ(X, ⊤)).hom).1)
/-- If `f : X ⟶ Y` is open, injective, `X` is quasi-compact and `Y` is affine, then `f` is stalkwise
injective if it is injective on global sections. -/
lemma stalkMap_injective_of_isOpenMap_of_injective [CompactSpace X]
(hfopen : IsOpenMap f) (hfinj₁ : Function.Injective f)
(hfinj₂ : Function.Injective f.appTop) (x : X) :
Function.Injective (f.stalkMap x) := by
let φ : Γ(Y, ⊤) ⟶ Γ(X, ⊤) := f.appTop
let 𝒰 : X.OpenCover := X.affineCover.finiteSubcover
let res (i : 𝒰.I₀) : Γ(X, ⊤) ⟶ Γ(𝒰.X i, ⊤) := (𝒰.f i).appTop
refine stalkMap_injective_of_isAffine _ _ (fun (g : Γ(Y, ⊤)) h ↦ ?_)
rw [TopCat.Presheaf.Γgerm, Scheme.Hom.germ_stalkMap_apply] at h
obtain ⟨U, w, (hx : x ∈ U), hg⟩ :=
X.toRingedSpace.exists_res_eq_zero_of_germ_eq_zero ⊤ (φ g) ⟨x, trivial⟩ h
obtain ⟨_, ⟨s, rfl⟩, hyv, bsle⟩ := Opens.isBasis_iff_nbhd.mp (isBasis_basicOpen Y)
(show f x ∈ ⟨f '' U.carrier, hfopen U.carrier U.is_open'⟩ from ⟨x, by simpa⟩)
let W (i : 𝒰.I₀) : TopologicalSpace.Opens (𝒰.X i) := (𝒰.X i).basicOpen ((res i) (φ s))
have hwle (i : 𝒰.I₀) : W i ≤ (𝒰.f i)⁻¹ᵁ U := by
change (𝒰.X i).basicOpen ((𝒰.f i ≫ f).appTop s) ≤ _
rw [← Scheme.preimage_basicOpen_top, Scheme.Hom.comp_base, Opens.map_comp_obj]
refine Scheme.Hom.preimage_mono _
(le_trans (f.preimage_mono bsle) (le_of_eq ?_))
simp [Set.preimage_image_eq _ hfinj₁]
have h0 (i : 𝒰.I₀) : (𝒰.f i).appLE _ (W i) (by simp) (φ g) = 0 := by
rw [← Scheme.Hom.appLE_map _ ((Opens.map _).map w).le (homOfLE <| hwle i).op,
← Scheme.Hom.map_appLE _ le_rfl w.op]
simp only [CommRingCat.comp_apply]
rw [hg]
simp only [map_zero]
have h1 (i : 𝒰.I₀) : ∃ n, (res i) (φ (s ^ n * g)) = 0 := by
obtain ⟨n, hn⟩ := exists_of_res_zero_of_qcqs_of_top (s := ((res i) (φ s))) (h0 i)
exact ⟨n, by rwa [map_mul, map_mul, map_pow, map_pow]⟩
have h2 : ∃ n, ∀ i, (res i) (φ (s ^ n * g)) = 0 := by
choose fn hfn using h1
refine ⟨Finset.sup Finset.univ fn, fun i ↦ ?_⟩
rw [map_mul, map_pow, map_mul, map_pow]
simp only [map_mul, map_pow, map_mul, map_pow] at hfn
apply pow_mul_eq_zero_of_le (Finset.le_sup (Finset.mem_univ i)) (hfn i)
obtain ⟨n, hn⟩ := h2
apply germ_eq_zero_of_pow_mul_eq_zero (U := ⊤) ⟨f x, trivial⟩ hyv
rw [RingHom.injective_iff_ker_eq_bot, RingHom.ker_eq_bot_iff_eq_zero] at hfinj₂
exact hfinj₂ _ (Scheme.zero_of_zero_cover _ _ hn)
namespace IsClosedImmersion
/-- If `f` is a closed immersion with affine target such that the induced map on global
sections is injective, `f` is an isomorphism. -/
theorem isIso_of_injective_of_isAffine [IsClosedImmersion f]
(hf : Function.Injective f.appTop) : IsIso f :=
isIso_iff_ker_eq_bot.mpr (Scheme.IdealSheafData.ext_of_isAffine
(by simpa [f.ker_apply ⟨⊤, isAffineOpen_top Y⟩, ← RingHom.injective_iff_ker_eq_bot]))
variable (f)
/-- If `f` is a closed immersion with affine target, the source is affine and
the induced map on global sections is surjective. -/
theorem isAffine_surjective_of_isAffine [IsClosedImmersion f] :
IsAffine X ∧ Function.Surjective f.appTop := by
refine ⟨isAffine_of_isAffineHom f, ?_⟩
simp only [← f.toImage_imageι, Scheme.Hom.comp_appTop, CommRingCat.hom_comp, RingHom.coe_comp,
Scheme.Hom.image, Scheme.Hom.imageι]
rw [Scheme.Hom.appTop, Scheme.Hom.appTop, f.ker.subschemeι_app ⟨⊤, isAffineOpen_top Y⟩,
CommRingCat.hom_comp, RingHom.coe_comp]
exact (ConcreteCategory.bijective_of_isIso _).2.comp
((ConcreteCategory.bijective_of_isIso _).2.comp Ideal.Quotient.mk_surjective)
lemma Spec_iff {R : CommRingCat} {f : X ⟶ Spec R} :
IsClosedImmersion f ↔ ∃ I : Ideal R, ∃ e : X ≅ Spec (.of <| R ⧸ I),
f = e.hom ≫ Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk I)) := by
constructor
· intro H
obtain ⟨h₁, h₂⟩ := IsClosedImmersion.isAffine_surjective_of_isAffine f
let φ := (Scheme.ΓSpecIso R).inv ≫ f.appTop
refine ⟨RingHom.ker φ.1, Scheme.isoSpec _ ≪≫ Scheme.Spec.mapIso
(.op (RingEquiv.ofBijective φ.1.kerLift ?_).toCommRingCatIso), ?_⟩
· exact ⟨φ.1.kerLift_injective, Ideal.Quotient.lift_surjective_of_surjective _ _
(h₂.comp (Scheme.ΓSpecIso R).commRingCatIsoToRingEquiv.symm.surjective)⟩
· simp only [Iso.trans_hom, Functor.mapIso_hom, Iso.op_hom, Scheme.Spec_map,
Quiver.Hom.unop_op, Category.assoc, ← Spec.map_comp]
change f = X.isoSpec.hom ≫ Spec.map φ
simp only [Scheme.isoSpec, asIso_hom, Spec.map_comp, ← Scheme.toSpecΓ_naturality_assoc,
← SpecMap_ΓSpecIso_hom, φ]
simp only [← Spec.map_comp, Iso.inv_hom_id, Spec.map_id, Category.comp_id]
· rintro ⟨I, e, rfl⟩
infer_instance
end IsClosedImmersion
end Affine
variable {X Y Z : Scheme.{u}}
/-- Being a closed immersion is local at the target. -/
instance IsClosedImmersion.isZariskiLocalAtTarget : IsZariskiLocalAtTarget @IsClosedImmersion :=
eq_inf ▸ inferInstance
/-- On morphisms with affine target, being a closed immersion is precisely having affine source
and being surjective on global sections. -/
instance IsClosedImmersion.hasAffineProperty : HasAffineProperty @IsClosedImmersion
(fun X _ f ↦ IsAffine X ∧ Function.Surjective (f.appTop)) := by
convert HasAffineProperty.of_isZariskiLocalAtTarget @IsClosedImmersion
refine ⟨fun ⟨h₁, h₂⟩ ↦ of_surjective_of_isAffine _ h₂, by apply isAffine_surjective_of_isAffine⟩
lemma isClosedImmersion_iff_isAffineHom {f : X ⟶ Y} :
IsClosedImmersion f ↔
IsAffineHom f ∧ ∀ U : Y.Opens, IsAffineOpen U → Function.Surjective (f.app U) := by
rw [HasAffineProperty.eq_targetAffineLocally @IsClosedImmersion]
exact targetAffineLocally_affineAnd_iff' RingHom.surjective_respectsIso _
lemma Scheme.Hom.app_surjective (f : X ⟶ Y) (U : Y.Opens) (hU : IsAffineOpen U)
[IsClosedImmersion f] : Function.Surjective (f.app U) :=
(isClosedImmersion_iff_isAffineHom.mp ‹_›).2 U hU
/-- Being a closed immersion is stable under base change. -/
instance IsClosedImmersion.isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @IsClosedImmersion := by
apply HasAffineProperty.isStableUnderBaseChange
haveI := HasAffineProperty.isLocal_affineProperty @IsClosedImmersion
apply AffineTargetMorphismProperty.IsStableUnderBaseChange.mk
intro X Y S _ _ f g ⟨ha, hsurj⟩
exact ⟨inferInstance, RingHom.surjective_isStableUnderBaseChange.pullback_fst_appTop _
RingHom.surjective_respectsIso f _ hsurj⟩
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsClosedImmersion g] :
IsClosedImmersion (Limits.pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ ‹_›
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsClosedImmersion f] :
IsClosedImmersion (Limits.pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ ‹_›
instance (f : X ⟶ Y) (V : Y.Opens) [IsClosedImmersion f] :
IsClosedImmersion (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
/-- Closed immersions are locally of finite type. -/
instance (priority := 900) {X Y : Scheme.{u}} (f : X ⟶ Y) [h : IsClosedImmersion f] :
LocallyOfFiniteType f := by
rw [HasRingHomProperty.eq_affineLocally @LocallyOfFiniteType,
← and_iff_right (inferInstanceAs (IsAffineHom f)) (b := affineLocally _ _),
← targetAffineLocally_affineAnd_iff_affineLocally RingHom.finiteType_isLocal]
rw [HasAffineProperty.eq_targetAffineLocally @IsClosedImmersion] at h
exact targetAffineLocally_affineAnd_le (RingHom.FiniteType.of_surjective _) _ h
/-- A surjective closed immersion is an isomorphism when the target is reduced. -/
lemma isIso_of_isClosedImmersion_of_surjective {X Y : Scheme.{u}} (f : X ⟶ Y)
[IsClosedImmersion f] [Surjective f] [IsReduced Y] :
IsIso f := by
rw [IsClosedImmersion.isIso_iff_ker_eq_bot, ← Scheme.IdealSheafData.support_eq_top_iff,
← SetLike.coe_injective.eq_iff, Scheme.Hom.support_ker]
simp
lemma isClosed_singleton_iff_isClosedImmersion {X : Scheme} {x : X} :
IsClosed {x} ↔ IsClosedImmersion (X.fromSpecResidueField x) := by
rw [← Scheme.range_fromSpecResidueField]
exact ⟨fun H ↦ .of_isPreimmersion _ H,
fun _ ↦ (X.fromSpecResidueField x).isClosedEmbedding.isClosed_range⟩
section Section
nonrec theorem isClosedImmersion_of_comp_eq_id {X Y : Scheme.{u}} [Subsingleton Y]
(f : X ⟶ Y) (g : Y ⟶ X) (hg : g ≫ f = 𝟙 Y) :
IsClosedImmersion g := by
wlog hX : ∃ R, X = Spec R
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @IsClosedImmersion) X.affineCover]
intro i
by_cases hxU : Set.range g ⊆ (X.affineCover.f i).opensRange
· rw [Scheme.Cover.pullbackHom,
← (IsOpenImmersion.isPullback_lift_id _ _ hxU).flip.isoPullback_inv_snd,
MorphismProperty.cancel_left_of_respectsIso @IsClosedImmersion]
refine this (X.affineCover.f i ≫ f) _ ?_ ⟨_, rfl⟩
rw [IsOpenImmersion.lift_fac_assoc, hg]
· have : IsEmpty ((X.affineCover.pullback₁ g).X i) := by
apply Scheme.isEmpty_pullback
rw [← Set.subset_compl_iff_disjoint_left]
rintro _ hx ⟨x, rfl⟩
apply hxU
rintro _ ⟨y, rfl⟩
exact Subsingleton.elim x y ▸ hx
infer_instance
obtain ⟨R, rfl⟩ := hX
wlog hY : ∃ S, Y = Spec S
· have inst := (Scheme.isoSpec Y).inv.homeomorph.injective.subsingleton
rw [← MorphismProperty.cancel_left_of_respectsIso @IsClosedImmersion (Scheme.isoSpec Y).inv]
exact this R (f ≫ (Scheme.isoSpec Y).hom) ((Scheme.isoSpec Y).inv ≫ g)
(by simp [reassoc_of% hg]) ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hY
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
obtain ⟨ψ, rfl⟩ := Spec.map_surjective g
rw [← Spec.map_comp, ← Spec.map_id, Spec.map_injective.eq_iff] at hg
apply IsClosedImmersion.spec_of_surjective
apply Function.LeftInverse.surjective (g := φ)
exact fun x ↦ congr($hg.1 x)
instance {X Y : Scheme.{u}} [Subsingleton X] (f : Retract X Y) : IsClosedImmersion f.i :=
isClosedImmersion_of_comp_eq_id _ _ f.retract
instance (priority := low) {X Y : Scheme.{u}} [Subsingleton Y] [X.Over Y] (f : Y ⟶ X) [f.IsOver Y] :
IsClosedImmersion f :=
isClosedImmersion_of_comp_eq_id (X ↘ Y) f (by simp)
end Section
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Etale.lean | import Mathlib.AlgebraicGeometry.Morphisms.Smooth
import Mathlib.AlgebraicGeometry.Morphisms.FormallyUnramified
import Mathlib.CategoryTheory.MorphismProperty.Comma
import Mathlib.RingTheory.Smooth.StandardSmoothCotangent
import Mathlib.CategoryTheory.Limits.MorphismProperty
/-!
# Étale morphisms
A morphism of schemes `f : X ⟶ Y` is étale if it is smooth of relative dimension zero. We
also define the category of schemes étale over `X`.
-/
universe t u
universe u₂ u₁ v₂ v₁
open CategoryTheory MorphismProperty Limits
namespace AlgebraicGeometry
/-- A morphism of schemes is étale if it is smooth of relative dimension zero. -/
abbrev IsEtale {X Y : Scheme.{u}} (f : X ⟶ Y) := IsSmoothOfRelativeDimension 0 f
namespace IsEtale
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
instance [IsEtale f] : IsSmooth f :=
IsSmoothOfRelativeDimension.isSmooth 0 f
instance : IsStableUnderBaseChange @IsEtale :=
isSmoothOfRelativeDimension_isStableUnderBaseChange 0
open RingHom in
instance (priority := 900) [IsEtale f] : FormallyUnramified f where
formallyUnramified_of_affine_subset U V e := by
have : Locally (IsStandardSmoothOfRelativeDimension 0) (f.appLE (↑U) (↑V) e).hom :=
HasRingHomProperty.appLE (P := @IsSmoothOfRelativeDimension 0) _ inferInstance ..
have : Locally RingHom.FormallyUnramified (f.appLE U V e).hom := by
apply locally_of_locally _ this
intro R S _ _ f hf
algebraize [f]
rw [RingHom.FormallyUnramified]
have : Algebra.IsStandardSmoothOfRelativeDimension 0 R S := hf
infer_instance
rwa [← RingHom.locally_iff_of_localizationSpanTarget
FormallyUnramified.respectsIso FormallyUnramified.ofLocalizationSpanTarget]
instance : MorphismProperty.HasOfPostcompProperty
@IsEtale (@LocallyOfFiniteType ⊓ @FormallyUnramified) := by
rw [MorphismProperty.hasOfPostcompProperty_iff_le_diagonal]
intro X Y f ⟨hft, hfu⟩
exact inferInstanceAs <| IsEtale (pullback.diagonal f)
/-- If `f ≫ g` is étale and `g` unramified, then `f` is étale. -/
lemma of_comp {Z : Scheme.{u}} (g : Y ⟶ Z) [IsEtale (f ≫ g)] [LocallyOfFiniteType g]
[FormallyUnramified g] : IsEtale f :=
of_postcomp _ (W' := @LocallyOfFiniteType ⊓ @FormallyUnramified) f g ⟨‹_›, ‹_›⟩ ‹_›
instance : MorphismProperty.HasOfPostcompProperty @IsEtale @IsEtale := by
apply MorphismProperty.HasOfPostcompProperty.of_le (W := @IsEtale)
(Q := (@LocallyOfFiniteType ⊓ @FormallyUnramified))
intro X Y f hf
constructor <;> infer_instance
end IsEtale
namespace Scheme
/-- The category `Etale X` is the category of schemes étale over `X`. -/
def Etale (X : Scheme.{u}) : Type _ := MorphismProperty.Over @IsEtale ⊤ X
variable (X : Scheme.{u})
instance : Category X.Etale :=
inferInstanceAs <| Category (MorphismProperty.Over @IsEtale ⊤ X)
/-- The forgetful functor from schemes étale over `X` to schemes over `X`. -/
def Etale.forget : X.Etale ⥤ Over X :=
MorphismProperty.Over.forget @IsEtale ⊤ X
/-- The forgetful functor from schemes étale over `X` to schemes over `X` is fully faithful. -/
def Etale.forgetFullyFaithful : (Etale.forget X).FullyFaithful :=
MorphismProperty.Comma.forgetFullyFaithful _ _ _
instance : (Etale.forget X).Full :=
inferInstanceAs <| (MorphismProperty.Comma.forget _ _ _ _ _).Full
instance : (Etale.forget X).Faithful :=
inferInstanceAs <| (MorphismProperty.Comma.forget _ _ _ _ _).Faithful
instance : HasPullbacks X.Etale := by
unfold Etale
infer_instance
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/IsIso.lean | import Mathlib.AlgebraicGeometry.Morphisms.OpenImmersion
/-!
# Being an isomorphism is local at the target
-/
open CategoryTheory MorphismProperty
namespace AlgebraicGeometry
lemma isomorphisms_eq_isOpenImmersion_inf_surjective :
isomorphisms Scheme = (@IsOpenImmersion ⊓ @Surjective : MorphismProperty Scheme) := by
ext
exact (isIso_iff_isOpenImmersion_and_epi_base _).trans
(and_congr Iff.rfl ((TopCat.epi_iff_surjective _).trans (surjective_iff _).symm))
lemma isomorphisms_eq_stalkwise :
isomorphisms Scheme = (isomorphisms TopCat).inverseImage Scheme.forgetToTop ⊓
stalkwise (fun f ↦ Function.Bijective f) := by
rw [isomorphisms_eq_isOpenImmersion_inf_surjective, isOpenImmersion_eq_inf,
surjective_eq_topologically, inf_right_comm]
congr 1
ext X Y f
exact ⟨fun H ↦ inferInstanceAs (IsIso (TopCat.isoOfHomeo
(H.1.1.toHomeomorphOfSurjective H.2)).hom), fun (_ : IsIso f.base) ↦
let e := (TopCat.homeoOfIso <| asIso f.base); ⟨e.isOpenEmbedding, e.surjective⟩⟩
instance : IsZariskiLocalAtTarget (isomorphisms Scheme) :=
isomorphisms_eq_isOpenImmersion_inf_surjective ▸ inferInstance
instance : HasAffineProperty (isomorphisms Scheme) fun X _ f _ ↦ IsAffine X ∧ IsIso (f.appTop) := by
convert HasAffineProperty.of_isZariskiLocalAtTarget (isomorphisms Scheme) with X Y f hY
exact ⟨fun ⟨_, _⟩ ↦ (arrow_mk_iso_iff (isomorphisms _) (arrowIsoSpecΓOfIsAffine f)).mpr
(inferInstanceAs (IsIso (Spec.map (f.appTop)))),
fun (_ : IsIso f) ↦ ⟨.of_isIso f, inferInstance⟩⟩
instance : IsZariskiLocalAtTarget (monomorphisms Scheme) :=
diagonal_isomorphisms (C := Scheme).symm ▸ inferInstance
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Proper.lean | import Mathlib.AlgebraicGeometry.Morphisms.Separated
import Mathlib.AlgebraicGeometry.Morphisms.Finite
/-!
# Proper morphisms
A morphism of schemes is proper if it is separated, universally closed and (locally) of finite type.
Note that we don't require quasi-compact, since this is implied by universally closed.
## Main results
- `AlgebraicGeometry.isField_of_universallyClosed`:
If `X` is an integral scheme that is universally closed over `Spec K`, then `Γ(X, ⊤)` is a field.
- `AlgebraicGeometry.finite_appTop_of_universallyClosed`:
If `X` is an integral scheme that is universally closed and of finite type over `Spec K`,
then `Γ(X, ⊤)` is finite dimensional over `K`.
-/
noncomputable section
open CategoryTheory
universe u
namespace AlgebraicGeometry
variable {X Y Z S : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism is proper if it is separated, universally closed and locally of finite type. -/
@[mk_iff]
class IsProper : Prop extends IsSeparated f, UniversallyClosed f, LocallyOfFiniteType f where
lemma isProper_eq : @IsProper =
(@IsSeparated ⊓ @UniversallyClosed : MorphismProperty Scheme) ⊓ @LocallyOfFiniteType := by
ext X Y f
rw [isProper_iff, ← and_assoc]
rfl
namespace IsProper
instance : MorphismProperty.RespectsIso @IsProper := by
rw [isProper_eq]
infer_instance
instance stableUnderComposition : MorphismProperty.IsStableUnderComposition @IsProper := by
rw [isProper_eq]
infer_instance
instance : MorphismProperty.IsMultiplicative @IsProper := by
rw [isProper_eq]
infer_instance
instance [IsProper f] [IsProper g] : IsProper (f ≫ g) where
instance (priority := 900) [IsFinite f] : IsProper f where
instance isStableUnderBaseChange : MorphismProperty.IsStableUnderBaseChange @IsProper := by
rw [isProper_eq]
infer_instance
instance : IsZariskiLocalAtTarget @IsProper := by
rw [isProper_eq]
infer_instance
instance (f : X ⟶ S) (g : Y ⟶ S) [IsProper g] : IsProper (Limits.pullback.fst f g) where
instance (f : X ⟶ S) (g : Y ⟶ S) [IsProper f] : IsProper (Limits.pullback.snd f g) where
instance (f : X ⟶ Y) (V : Y.Opens) [IsProper f] : IsProper (f ∣_ V) where
end IsProper
lemma IsFinite.eq_isProper_inf_isAffineHom :
@IsFinite = (@IsProper ⊓ @IsAffineHom : MorphismProperty _) := by
have : (@IsAffineHom ⊓ @IsSeparated : MorphismProperty _) = @IsAffineHom :=
inf_eq_left.mpr fun _ _ _ _ ↦ inferInstance
rw [inf_comm, isProper_eq, inf_assoc, ← inf_assoc, this, eq_inf,
IsIntegralHom.eq_universallyClosed_inf_isAffineHom, inf_assoc, inf_left_comm]
variable {f} in
lemma IsFinite.iff_isProper_and_isAffineHom :
IsFinite f ↔ IsProper f ∧ IsAffineHom f := by
rw [eq_isProper_inf_isAffineHom]
rfl
instance (priority := 100) [IsFinite f] : IsProper f :=
(IsFinite.iff_isProper_and_isAffineHom.mp ‹_›).1
instance : MorphismProperty.HasOfPostcompProperty @UniversallyClosed @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (UniversallyClosed _)
@[stacks 01W6 "(1)"]
lemma UniversallyClosed.of_comp_of_isSeparated [UniversallyClosed (f ≫ g)] [IsSeparated g] :
UniversallyClosed f :=
MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
instance : MorphismProperty.HasOfPostcompProperty @IsProper @IsSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsProper _)
@[stacks 01W6 "(2)"]
lemma IsProper.of_comp [IsProper (f ≫ g)] [IsSeparated g] : IsProper f :=
MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
@[deprecated (since := "2025-10-15")] alias IsProper.of_comp_of_isSeparated := IsProper.of_comp
lemma IsProper.comp_iff {f : X ⟶ Y} {g : Y ⟶ Z} [IsProper g] :
IsProper (f ≫ g) ↔ IsProper f :=
⟨fun _ ↦ .of_comp f g, fun _ ↦ inferInstance⟩
section GlobalSection
variable (K : Type u) [Field K]
/-- If `f : X ⟶ Y` is universally closed and `Y` is affine,
then the map on global sections is integral. -/
theorem isIntegral_appTop_of_universallyClosed (f : X ⟶ Y) [UniversallyClosed f] [IsAffine Y] :
f.appTop.hom.IsIntegral := by
have : CompactSpace X := (quasiCompact_iff_compactSpace f).mp inferInstance
have : UniversallyClosed (X.toSpecΓ ≫ Spec.map f.appTop) := by
rwa [← Scheme.toSpecΓ_naturality,
MorphismProperty.cancel_right_of_respectsIso (P := @UniversallyClosed)]
have : UniversallyClosed X.toSpecΓ := .of_comp_of_isSeparated _ (Spec.map f.appTop)
rw [← IsIntegralHom.SpecMap_iff, IsIntegralHom.iff_universallyClosed_and_isAffineHom]
exact ⟨.of_comp_surjective X.toSpecΓ _, inferInstance⟩
/-- If `X` is an integral scheme that is universally closed over `Spec K`,
then `Γ(X, ⊤)` is a field. -/
theorem isField_of_universallyClosed (f : X ⟶ (Spec <| .of K))
[IsIntegral X] [UniversallyClosed f] : IsField Γ(X, ⊤) := by
let F := (Scheme.ΓSpecIso _).inv ≫ f.appTop
have : F.hom.IsIntegral := by
apply RingHom.isIntegral_respectsIso.2 (e := (Scheme.ΓSpecIso _).symm.commRingCatIsoToRingEquiv)
exact isIntegral_appTop_of_universallyClosed f
algebraize [F.hom]
exact isField_of_isIntegral_of_isField' (Field.toIsField K)
/-- If `X` is an integral scheme that is universally closed and of finite type over `Spec K`,
then `Γ(X, ⊤)` is a finite field extension over `K`. -/
theorem finite_appTop_of_universallyClosed (f : X ⟶ (Spec <| .of K))
[IsIntegral X] [UniversallyClosed f] [LocallyOfFiniteType f] :
f.appTop.hom.Finite := by
have x : X := Nonempty.some inferInstance
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
letI := ((Scheme.ΓSpecIso (.of K)).commRingCatIsoToRingEquiv.toMulEquiv.isField
(Field.toIsField K)).toField
letI := (isField_of_universallyClosed K f).toField
have : Nonempty U := ⟨⟨x, hxU⟩⟩
apply RingHom.finite_of_algHom_finiteType_of_isJacobsonRing (A := Γ(X, U))
(g := (X.presheaf.map (homOfLE le_top).op).hom)
exact LocallyOfFiniteType.finiteType_of_affine_subset ⟨⊤, isAffineOpen_top _⟩ ⟨U, hU⟩ (by simp)
end GlobalSection
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/FiniteType.lean | import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties
import Mathlib.RingTheory.RingHom.FiniteType
import Mathlib.RingTheory.Spectrum.Prime.Jacobson
/-!
# Morphisms of finite type
A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.
A morphism of schemes is of finite type if it is both locally of finite type and quasi-compact.
We show that these properties are local, and are stable under compositions and base change.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.
-/
@[mk_iff]
class LocallyOfFiniteType (f : X ⟶ Y) : Prop where
finiteType_of_affine_subset :
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), (f.appLE U V e).hom.FiniteType
instance : HasRingHomProperty @LocallyOfFiniteType RingHom.FiniteType where
isLocal_ringHomProperty := RingHom.finiteType_isLocal
eq_affineLocally' := by
ext X Y f
rw [locallyOfFiniteType_iff, affineLocally_iff_affineOpens_le]
instance (priority := 900) locallyOfFiniteType_of_isOpenImmersion [IsOpenImmersion f] :
LocallyOfFiniteType f :=
HasRingHomProperty.of_isOpenImmersion
RingHom.finiteType_holdsForLocalizationAway.containsIdentities
instance : MorphismProperty.IsStableUnderComposition @LocallyOfFiniteType :=
HasRingHomProperty.stableUnderComposition RingHom.finiteType_stableUnderComposition
instance locallyOfFiniteType_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : LocallyOfFiniteType f] [hg : LocallyOfFiniteType g] : LocallyOfFiniteType (f ≫ g) :=
MorphismProperty.comp_mem _ f g hf hg
theorem locallyOfFiniteType_of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[LocallyOfFiniteType (f ≫ g)] : LocallyOfFiniteType f :=
HasRingHomProperty.of_comp (fun _ _ ↦ RingHom.FiniteType.of_comp_finiteType) ‹_›
instance : MorphismProperty.IsMultiplicative @LocallyOfFiniteType where
id_mem _ := inferInstance
open scoped TensorProduct in
instance locallyOfFiniteType_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @LocallyOfFiniteType :=
HasRingHomProperty.isStableUnderBaseChange RingHom.finiteType_isStableUnderBaseChange
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [LocallyOfFiniteType g] :
LocallyOfFiniteType (pullback.fst f g) :=
MorphismProperty.pullback_fst f g inferInstance
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [LocallyOfFiniteType f] :
LocallyOfFiniteType (pullback.snd f g) :=
MorphismProperty.pullback_snd f g inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [LocallyOfFiniteType f] : LocallyOfFiniteType (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [LocallyOfFiniteType f] :
LocallyOfFiniteType (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
instance {R} [CommRing R] [IsJacobsonRing R] : JacobsonSpace <| Spec <| .of R :=
inferInstanceAs (JacobsonSpace (PrimeSpectrum R))
instance {R : CommRingCat} [IsJacobsonRing R] : JacobsonSpace (Spec R) :=
inferInstanceAs (JacobsonSpace (PrimeSpectrum R))
nonrec lemma LocallyOfFiniteType.jacobsonSpace
(f : X ⟶ Y) [LocallyOfFiniteType f] [JacobsonSpace Y] : JacobsonSpace X := by
wlog hY : ∃ S, Y = Spec S
· rw [(Scheme.OpenCover.isOpenCover_opensRange (Y.affineCover.pullback₁ f)).jacobsonSpace_iff]
intro i
have inst : LocallyOfFiniteType (Y.affineCover.pullbackHom f i) :=
MorphismProperty.pullback_snd _ _ inferInstance
have inst : JacobsonSpace Y := ‹_› -- TC gets stuck on the WLOG hypothesis without it.
have inst : JacobsonSpace (Y.affineCover.X i) :=
.of_isOpenEmbedding (Y.affineCover.f i).isOpenEmbedding
let e := ((Y.affineCover.pullback₁ f).f i).isOpenEmbedding.isEmbedding.toHomeomorph
have := this (Y.affineCover.pullbackHom f i) ⟨_, rfl⟩
exact .of_isClosedEmbedding e.symm.isClosedEmbedding
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S
· have inst : JacobsonSpace (Spec R) := ‹_› -- TC gets stuck on the WLOG hypothesis without it.
rw [X.affineCover.isOpenCover_opensRange.jacobsonSpace_iff]
intro i
have := this _ (X.affineCover.f i ≫ f) ⟨_, rfl⟩
let e := (X.affineCover.f i).isOpenEmbedding.isEmbedding.toHomeomorph
exact .of_isClosedEmbedding e.symm.isClosedEmbedding
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl : Spec.map φ = f⟩ := Spec.homEquiv.symm.surjective f
have : RingHom.FiniteType φ.hom := HasRingHomProperty.Spec_iff.mp ‹_›
algebraize [φ.hom]
have := PrimeSpectrum.isJacobsonRing_iff_jacobsonSpace.mpr ‹_›
exact PrimeSpectrum.isJacobsonRing_iff_jacobsonSpace.mp (isJacobsonRing_of_finiteType (A := R))
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/UniversallyInjective.lean | import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.Topology.LocalAtTarget
/-!
# Universally injective morphism
A morphism of schemes `f : X ⟶ Y` is universally injective if `X ×[Y] Y' ⟶ Y'` is injective
for all base changes `Y' ⟶ Y`. This is equivalent to the diagonal morphism being surjective
(`AlgebraicGeometry.UniversallyInjective.iff_diagonal`).
We show that being universally injective is local at the target, and is stable under
compositions and base changes.
## TODO
- https://stacks.math.columbia.edu/tag/01S4
Show that this is equivalent to radicial morphisms
(injective + purely inseparable residue field extensions)
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
open CategoryTheory.MorphismProperty Function
/--
A morphism of schemes `f : X ⟶ Y` is universally injective if the base change `X ×[Y] Y' ⟶ Y'`
along any morphism `Y' ⟶ Y` is injective (on points).
-/
@[mk_iff]
class UniversallyInjective (f : X ⟶ Y) : Prop where
universally_injective : universally (topologically (Injective ·)) f
theorem Scheme.Hom.injective (f : X ⟶ Y) [UniversallyInjective f] :
Function.Injective f :=
UniversallyInjective.universally_injective _ _ _ .of_id_snd
theorem universallyInjective_eq :
@UniversallyInjective = universally (topologically (Injective ·)) := by
ext X Y f; rw [universallyInjective_iff]
theorem universallyInjective_eq_diagonal :
@UniversallyInjective = diagonal @Surjective := by
apply le_antisymm
· intro X Y f hf
refine ⟨fun x ↦ ⟨pullback.fst f f x, hf.1 _ _ _ (IsPullback.of_hasPullback f f) ?_⟩⟩
rw [← Scheme.Hom.comp_apply, pullback.diagonal_fst]
rfl
· rw [← universally_eq_iff.mpr (inferInstanceAs (IsStableUnderBaseChange (diagonal @Surjective))),
universallyInjective_eq]
apply universally_mono
intro X Y f hf x₁ x₂ e
obtain ⟨t, ht₁, ht₂⟩ := Scheme.Pullback.exists_preimage_pullback _ _ e
obtain ⟨t, rfl⟩ := hf.1 t
rw [← ht₁, ← ht₂, ← Scheme.Hom.comp_apply, ← Scheme.Hom.comp_apply, pullback.diagonal_fst,
pullback.diagonal_snd]
theorem UniversallyInjective.iff_diagonal :
UniversallyInjective f ↔ Surjective (pullback.diagonal f) := by
rw [universallyInjective_eq_diagonal]; rfl
instance (priority := 900) [Mono f] : UniversallyInjective f :=
have := (pullback.isIso_diagonal_iff f).mpr inferInstance
(UniversallyInjective.iff_diagonal f).mpr inferInstance
theorem UniversallyInjective.respectsIso : RespectsIso @UniversallyInjective :=
universallyInjective_eq_diagonal.symm ▸ inferInstance
instance UniversallyInjective.isStableUnderBaseChange :
IsStableUnderBaseChange @UniversallyInjective :=
universallyInjective_eq_diagonal.symm ▸ inferInstance
instance universallyInjective_isStableUnderComposition :
IsStableUnderComposition @UniversallyInjective :=
universallyInjective_eq ▸ inferInstance
instance : MorphismProperty.IsMultiplicative @UniversallyInjective where
id_mem _ := inferInstance
instance universallyInjective_isZariskiLocalAtTarget :
IsZariskiLocalAtTarget @UniversallyInjective :=
universallyInjective_eq_diagonal.symm ▸ inferInstance
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/UniversallyClosed.lean | import Mathlib.AlgebraicGeometry.Morphisms.ClosedImmersion
import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.Topology.LocalAtTarget
/-!
# Universally closed morphism
A morphism of schemes `f : X ⟶ Y` is universally closed if `X ×[Y] Y' ⟶ Y'` is a closed map
for all base change `Y' ⟶ Y`.
This implies that `f` is topologically proper (`AlgebraicGeometry.Scheme.Hom.isProperMap`).
We show that being universally closed is local at the target, and is stable under compositions and
base changes.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
open CategoryTheory.MorphismProperty
/-- A morphism of schemes `f : X ⟶ Y` is universally closed if the base change `X ×[Y] Y' ⟶ Y'`
along any morphism `Y' ⟶ Y` is (topologically) a closed map.
-/
@[mk_iff]
class UniversallyClosed (f : X ⟶ Y) : Prop where
out : universally (topologically @IsClosedMap) f
lemma Scheme.Hom.isClosedMap {X Y : Scheme} (f : X ⟶ Y) [UniversallyClosed f] :
IsClosedMap f := UniversallyClosed.out _ _ _ IsPullback.of_id_snd
theorem universallyClosed_eq : @UniversallyClosed = universally (topologically @IsClosedMap) := by
ext X Y f; rw [universallyClosed_iff]
instance (priority := 900) [IsClosedImmersion f] : UniversallyClosed f := by
rw [universallyClosed_eq]
intro X' Y' i₁ i₂ f' hf
have hf' : IsClosedImmersion f' :=
MorphismProperty.of_isPullback hf.flip inferInstance
exact hf'.base_closed.isClosedMap
theorem universallyClosed_respectsIso : RespectsIso @UniversallyClosed :=
universallyClosed_eq.symm ▸ universally_respectsIso (topologically @IsClosedMap)
instance universallyClosed_isStableUnderBaseChange : IsStableUnderBaseChange @UniversallyClosed :=
universallyClosed_eq.symm ▸ universally_isStableUnderBaseChange (topologically @IsClosedMap)
instance isClosedMap_isStableUnderComposition :
IsStableUnderComposition (topologically @IsClosedMap) where
comp_mem f g hf hg := IsClosedMap.comp (f := f) (g := g) hg hf
instance universallyClosed_isStableUnderComposition :
IsStableUnderComposition @UniversallyClosed := by
rw [universallyClosed_eq]
infer_instance
lemma UniversallyClosed.of_comp_surjective {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[UniversallyClosed (f ≫ g)] [Surjective f] : UniversallyClosed g := by
constructor
intro X' Y' i₁ i₂ f' H
have := UniversallyClosed.out _ _ _ ((IsPullback.of_hasPullback i₁ f).paste_horiz H)
exact IsClosedMap.of_comp_surjective (MorphismProperty.pullback_fst (P := @Surjective) _ _ ‹_›).1
(Scheme.Hom.continuous _) this
instance universallyClosedTypeComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : UniversallyClosed f] [hg : UniversallyClosed g] : UniversallyClosed (f ≫ g) :=
comp_mem _ _ _ hf hg
instance : MorphismProperty.IsMultiplicative @UniversallyClosed where
id_mem _ := inferInstance
instance universallyClosed_fst {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hg : UniversallyClosed g] :
UniversallyClosed (pullback.fst f g) :=
MorphismProperty.pullback_fst f g hg
instance universallyClosed_snd {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hf : UniversallyClosed f] :
UniversallyClosed (pullback.snd f g) :=
MorphismProperty.pullback_snd f g hf
instance universallyClosed_isZariskiLocalAtTarget : IsZariskiLocalAtTarget @UniversallyClosed := by
rw [universallyClosed_eq]
apply universally_isZariskiLocalAtTarget
intro X Y f ι U hU H
simp_rw [topologically, morphismRestrict_base] at H
exact hU.isClosedMap_iff_restrictPreimage.mpr H
instance (f : X ⟶ Y) (V : Y.Opens) [UniversallyClosed f] : UniversallyClosed (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
open Scheme.Pullback _root_.PrimeSpectrum MvPolynomial in
/-- If `X` is universally closed over a field, then `X` is quasi-compact. -/
lemma compactSpace_of_universallyClosed
{K} [Field K] (f : X ⟶ Spec (.of K)) [UniversallyClosed f] : CompactSpace X := by
classical
let 𝒰 : X.OpenCover := X.affineCover
let U (i : 𝒰.I₀) : X.Opens := (𝒰.f i).opensRange
let T : Scheme := Spec (.of <| MvPolynomial 𝒰.I₀ K)
let q : T ⟶ Spec (.of K) := Spec.map (CommRingCat.ofHom MvPolynomial.C)
let Ti (i : 𝒰.I₀) : T.Opens := basicOpen (MvPolynomial.X i)
let fT : pullback f q ⟶ T := pullback.snd f q
let p : pullback f q ⟶ X := pullback.fst f q
let Z : Set (pullback f q :) := (⨆ i, fT ⁻¹ᵁ (Ti i) ⊓ p ⁻¹ᵁ (U i) : (pullback f q).Opens)ᶜ
have hZ : IsClosed Z := by
simp only [Z, isClosed_compl_iff, Opens.coe_iSup, Opens.coe_inf, Opens.map_coe]
exact isOpen_iUnion fun i ↦ (fT.continuous.1 _ (Ti i).2).inter (p.continuous.1 _ (U i).2)
let Zc : T.Opens := ⟨(fT '' Z)ᶜ, (fT.isClosedMap _ hZ).isOpen_compl⟩
let ψ : MvPolynomial 𝒰.I₀ K →ₐ[K] K := MvPolynomial.aeval (fun _ ↦ 1)
let t : T := Spec.map (CommRingCat.ofHom ψ.toRingHom) default
have ht (i : 𝒰.I₀) : t ∈ Ti i := show ψ (.X i) ≠ 0 by simp [ψ]
have htZc : t ∈ Zc := by
intro ⟨z, hz, hzt⟩
suffices ∃ i, fT z ∈ Ti i ∧ p z ∈ U i from hz (by simpa)
exact ⟨𝒰.idx (p z), hzt ▸ ht _, by simpa [U] using 𝒰.covers (p z)⟩
obtain ⟨U', ⟨g, rfl⟩, htU', hU'le⟩ := Opens.isBasis_iff_nbhd.mp isBasis_basic_opens htZc
let σ : Finset 𝒰.I₀ := MvPolynomial.vars g
let φ : MvPolynomial 𝒰.I₀ K →+* MvPolynomial 𝒰.I₀ K :=
(MvPolynomial.aeval fun i : 𝒰.I₀ ↦ if i ∈ σ then MvPolynomial.X i else 0).toRingHom
let t' : T := Spec.map (CommRingCat.ofHom φ) t
have ht'g : t' ∈ PrimeSpectrum.basicOpen g :=
show φ g ∉ t.asIdeal from (show φ g = g from aeval_ite_mem_eq_self g subset_rfl).symm ▸ htU'
have h : t' ∉ fT '' Z := hU'le ht'g
suffices ⋃ i ∈ σ, (U i).1 = Set.univ from
⟨this ▸ Finset.isCompact_biUnion _ fun i _ ↦ isCompact_range (𝒰.f i).continuous⟩
rw [Set.iUnion₂_eq_univ_iff]
contrapose! h
obtain ⟨x, hx⟩ := h
obtain ⟨z, rfl, hzr⟩ := exists_preimage_pullback x t' (Subsingleton.elim (f x) (q t'))
suffices ∀ i, t ∈ (Ti i).comap (comap φ) → p z ∉ U i from ⟨z, by simpa [Z, p, fT, hzr], hzr⟩
intro i hi₁ hi₂
rw [comap_basicOpen, show φ (.X i) = 0 by simpa [φ] using (hx i · hi₂), basicOpen_zero] at hi₁
cases hi₁
@[stacks 04XU]
lemma Scheme.Hom.isProperMap (f : X ⟶ Y) [UniversallyClosed f] : IsProperMap f := by
rw [isProperMap_iff_isClosedMap_and_compact_fibers]
refine ⟨Scheme.Hom.continuous f, ?_, ?_⟩
· exact MorphismProperty.universally_le (P := topologically @IsClosedMap) _ UniversallyClosed.out
· intro y
have := compactSpace_of_universallyClosed (pullback.snd f (Y.fromSpecResidueField y))
rw [← Scheme.range_fromSpecResidueField, ← Scheme.Pullback.range_fst]
exact isCompact_range (Scheme.Hom.continuous _)
instance (priority := 900) [UniversallyClosed f] : QuasiCompact f where
isCompact_preimage _ _ := f.isProperMap.isCompact_preimage
lemma universallyClosed_eq_universallySpecializing :
@UniversallyClosed = (topologically @SpecializingMap).universally ⊓ @QuasiCompact := by
rw [← universally_eq_iff (P := @QuasiCompact).mpr inferInstance, ← universally_inf]
apply le_antisymm
· rw [← universally_eq_iff (P := @UniversallyClosed).mpr inferInstance]
exact universally_mono fun X Y f H ↦ ⟨f.isClosedMap.specializingMap, inferInstance⟩
· rw [universallyClosed_eq]
exact universally_mono fun X Y f ⟨h₁, h₂⟩ ↦ (isClosedMap_iff_specializingMap _).mpr h₁
instance (priority := low) Surjective.of_universallyClosed_of_isDominant
[UniversallyClosed f] [IsDominant f] : Surjective f := by
rw [surjective_iff, ← Set.range_eq_univ, ← f.denseRange.closure_range,
f.isClosedMap.isClosed_range.closure_eq]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean | import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties
import Mathlib.AlgebraicGeometry.Morphisms.FinitePresentation
import Mathlib.RingTheory.RingHom.StandardSmooth
/-!
# Smooth morphisms
A morphism of schemes `f : X ⟶ Y` is smooth (of relative dimension `n`) if for each `x : X` there
exists an affine open neighborhood `V` of `x` and an affine open neighborhood `U` of
`f.base x` with `V ≤ f ⁻¹ᵁ U` such that the induced map `Γ(Y, U) ⟶ Γ(X, V)` is
standard smooth (of relative dimension `n`).
In other words, smooth (resp. smooth of relative dimension `n`) for scheme morphisms is associated
to the property of ring homomorphisms `Locally IsStandardSmooth`
(resp. `Locally (IsStandardSmoothOfRelativeDimension n)`).
## Implementation details
- Our definition is equivalent to defining `IsSmooth` as the associated scheme morphism property of
the property of ring maps induced by `Algebra.Smooth`. The equivalence will follow from the
equivalence of `Locally IsStandardSmooth` and `Algebra.IsSmooth`, but the latter is a (hard) TODO.
The reason why we choose the definition via `IsStandardSmooth`, is because verifying that
`Algebra.IsSmooth` is local in the sense of `RingHom.PropertyIsLocal` is a (hard) TODO.
## Notes
This contribution was created as part of the AIM workshop "Formalizing algebraic geometry" in
June 2024.
-/
noncomputable section
open CategoryTheory
universe t w v u
namespace AlgebraicGeometry
open RingHom
variable (n m : ℕ) {X Y : Scheme.{u}} (f : X ⟶ Y)
/--
A morphism of schemes `f : X ⟶ Y` is smooth if for each `x : X` there
exists an affine open neighborhood `V` of `x` and an affine open neighborhood `U` of
`f.base x` with `V ≤ f ⁻¹ᵁ U` such that the induced map `Γ(Y, U) ⟶ Γ(X, V)` is
standard smooth.
-/
@[mk_iff]
class IsSmooth : Prop where
exists_isStandardSmooth : ∀ (x : X), ∃ (U : Y.affineOpens) (V : X.affineOpens) (_ : x ∈ V.1)
(e : V.1 ≤ f ⁻¹ᵁ U.1), IsStandardSmooth (f.appLE U V e).hom
/-- The property of scheme morphisms `IsSmooth` is associated with the ring
homomorphism property `Locally IsStandardSmooth`. -/
instance : HasRingHomProperty @IsSmooth (Locally IsStandardSmooth) := by
apply HasRingHomProperty.locally_of_iff
· exact isStandardSmooth_localizationPreserves.away
· exact isStandardSmooth_stableUnderCompositionWithLocalizationAway
· intro X Y f
rw [isSmooth_iff]
/-- Being smooth is stable under composition. -/
instance : MorphismProperty.IsStableUnderComposition @IsSmooth :=
HasRingHomProperty.stableUnderComposition <| locally_stableUnderComposition
isStandardSmooth_respectsIso isStandardSmooth_localizationPreserves
isStandardSmooth_stableUnderComposition
/-- The composition of smooth morphisms is smooth. -/
instance isSmooth_comp {Z : Scheme.{u}} (g : Y ⟶ Z) [IsSmooth f] [IsSmooth g] :
IsSmooth (f ≫ g) :=
MorphismProperty.comp_mem _ f g ‹IsSmooth f› ‹IsSmooth g›
/-- Smooth of relative dimension `n` is stable under base change. -/
lemma isSmooth_isStableUnderBaseChange : MorphismProperty.IsStableUnderBaseChange @IsSmooth :=
HasRingHomProperty.isStableUnderBaseChange <| locally_isStableUnderBaseChange
isStandardSmooth_respectsIso isStandardSmooth_isStableUnderBaseChange
/--
A morphism of schemes `f : X ⟶ Y` is smooth of relative dimension `n` if for each `x : X` there
exists an affine open neighborhood `V` of `x` and an affine open neighborhood `U` of
`f.base x` with `V ≤ f ⁻¹ᵁ U` such that the induced map `Γ(Y, U) ⟶ Γ(X, V)` is
standard smooth of relative dimension `n`.
-/
@[mk_iff]
class IsSmoothOfRelativeDimension : Prop where
exists_isStandardSmoothOfRelativeDimension : ∀ (x : X), ∃ (U : Y.affineOpens)
(V : X.affineOpens) (_ : x ∈ V.1) (e : V.1 ≤ f ⁻¹ᵁ U.1),
IsStandardSmoothOfRelativeDimension n (f.appLE U V e).hom
/-- If `f` is smooth of any relative dimension, it is smooth. -/
lemma IsSmoothOfRelativeDimension.isSmooth [IsSmoothOfRelativeDimension n f] : IsSmooth f where
exists_isStandardSmooth x := by
obtain ⟨U, V, hx, e, hf⟩ := exists_isStandardSmoothOfRelativeDimension (n := n) (f := f) x
exact ⟨U, V, hx, e, hf.isStandardSmooth⟩
/-- The property of scheme morphisms `IsSmoothOfRelativeDimension n` is associated with the ring
homomorphism property `Locally (IsStandardSmoothOfRelativeDimension n)`. -/
instance : HasRingHomProperty (@IsSmoothOfRelativeDimension n)
(Locally (IsStandardSmoothOfRelativeDimension n)) := by
apply HasRingHomProperty.locally_of_iff
· exact (isStandardSmoothOfRelativeDimension_localizationPreserves n).away
· exact isStandardSmoothOfRelativeDimension_stableUnderCompositionWithLocalizationAway n
· intro X Y f
rw [isSmoothOfRelativeDimension_iff]
/-- Smooth of relative dimension `n` is stable under base change. -/
lemma isSmoothOfRelativeDimension_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange (@IsSmoothOfRelativeDimension n) :=
HasRingHomProperty.isStableUnderBaseChange <| locally_isStableUnderBaseChange
isStandardSmoothOfRelativeDimension_respectsIso
(isStandardSmoothOfRelativeDimension_isStableUnderBaseChange n)
/-- Open immersions are smooth of relative dimension `0`. -/
instance (priority := 900) [IsOpenImmersion f] : IsSmoothOfRelativeDimension 0 f :=
HasRingHomProperty.of_isOpenImmersion
(locally_holdsForLocalizationAway <|
isStandardSmoothOfRelativeDimension_holdsForLocalizationAway).containsIdentities
/-- Open immersions are smooth. -/
instance (priority := 900) [IsOpenImmersion f] : IsSmooth f :=
IsSmoothOfRelativeDimension.isSmooth 0 f
/-- If `f` is smooth of relative dimension `n` and `g` is smooth of relative dimension
`m`, then `f ≫ g` is smooth of relative dimension `n + m`. -/
instance isSmoothOfRelativeDimension_comp {Z : Scheme.{u}} (g : Y ⟶ Z)
[hf : IsSmoothOfRelativeDimension n f] [hg : IsSmoothOfRelativeDimension m g] :
IsSmoothOfRelativeDimension (n + m) (f ≫ g) where
exists_isStandardSmoothOfRelativeDimension x := by
obtain ⟨U₂, V₂, hfx₂, e₂, hf₂⟩ := hg.exists_isStandardSmoothOfRelativeDimension (f x)
obtain ⟨U₁', V₁', hx₁', e₁', hf₁'⟩ := hf.exists_isStandardSmoothOfRelativeDimension x
obtain ⟨r, s, hx₁, e₁, hf₁⟩ := exists_basicOpen_le_appLE_of_appLE_of_isAffine
(isStandardSmoothOfRelativeDimension_stableUnderCompositionWithLocalizationAway n).right
(isStandardSmoothOfRelativeDimension_localizationPreserves n).away
x V₂ U₁' V₁' V₁' hx₁' hx₁' e₁' hf₁' hfx₂
have e : X.basicOpen s ≤ (f ≫ g) ⁻¹ᵁ U₂ :=
le_trans e₁ <| f.preimage_mono <| le_trans (Y.basicOpen_le r) e₂
have heq : (f ≫ g).appLE U₂ (X.basicOpen s) e = g.appLE U₂ V₂ e₂ ≫
CommRingCat.ofHom (algebraMap Γ(Y, V₂) Γ(Y, Y.basicOpen r)) ≫
f.appLE (Y.basicOpen r) (X.basicOpen s) e₁ := by
rw [RingHom.algebraMap_toAlgebra, CommRingCat.ofHom_hom,
g.appLE_map_assoc, Scheme.Hom.appLE_comp_appLE]
refine ⟨U₂, ⟨X.basicOpen s, V₁'.2.basicOpen s⟩, hx₁, e, heq ▸ ?_⟩
apply IsStandardSmoothOfRelativeDimension.comp ?_ hf₂
haveI : IsLocalization.Away r Γ(Y, Y.basicOpen r) := V₂.2.isLocalization_basicOpen r
exact (isStandardSmoothOfRelativeDimension_stableUnderCompositionWithLocalizationAway n).left
_ r _ hf₁
instance {Z : Scheme.{u}} (g : Y ⟶ Z) [IsSmoothOfRelativeDimension 0 f]
[IsSmoothOfRelativeDimension 0 g] :
IsSmoothOfRelativeDimension 0 (f ≫ g) :=
inferInstanceAs <| IsSmoothOfRelativeDimension (0 + 0) (f ≫ g)
/-- Smooth of relative dimension `0` is multiplicative. -/
instance : MorphismProperty.IsMultiplicative (@IsSmoothOfRelativeDimension 0) where
id_mem _ := inferInstance
comp_mem _ _ _ _ := inferInstance
/-- Smooth morphisms are locally of finite presentation. -/
instance (priority := 100) [hf : IsSmooth f] : LocallyOfFinitePresentation f := by
rw [HasRingHomProperty.eq_affineLocally @LocallyOfFinitePresentation]
rw [HasRingHomProperty.eq_affineLocally @IsSmooth] at hf
refine affineLocally_le (fun hf ↦ ?_) f hf
apply RingHom.locally_of_locally (Q := RingHom.FinitePresentation) at hf
· rwa [RingHom.locally_iff_of_localizationSpanTarget finitePresentation_respectsIso
finitePresentation_ofLocalizationSpanTarget] at hf
· introv hf
algebraize [f]
-- TODO: why is `algebraize` not generating the following instance?
haveI : Algebra.IsStandardSmooth R S := hf
exact this.finitePresentation
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Immersion.lean | import Mathlib.AlgebraicGeometry.Morphisms.Preimmersion
import Mathlib.AlgebraicGeometry.Morphisms.Separated
import Mathlib.AlgebraicGeometry.IdealSheaf.Functorial
/-!
# Immersions of schemes
A morphism of schemes `f : X ⟶ Y` is an immersion if the underlying map of topological spaces
is a locally closed embedding, and the induced morphisms of stalks are all surjective. This is true
if and only if it can be factored into a closed immersion followed by an open immersion.
## Main results
- `isImmersion_iff_exists`:
A morphism is a (locally-closed) immersion if and only if it can be factored into
a closed immersion followed by a (dominant) open immersion.
- `isImmersion_iff_exists_of_quasiCompact`:
A quasicompact morphism is a (locally-closed) immersion if and only if it can be factored into
an open immersion followed by a closed immersion.
-/
universe v u
open CategoryTheory Limits
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is an immersion if
1. the underlying map of topological spaces is an embedding
2. the range of the map is locally closed
3. the induced morphisms of stalks are all surjective. -/
@[mk_iff]
class IsImmersion (f : X ⟶ Y) : Prop extends IsPreimmersion f where
isLocallyClosed_range : IsLocallyClosed (Set.range f)
lemma Scheme.Hom.isLocallyClosed_range (f : X ⟶ Y) [IsImmersion f] :
IsLocallyClosed (Set.range f) :=
IsImmersion.isLocallyClosed_range
/--
Given an immersion `f : X ⟶ Y`, this is the biggest open set `U ⊆ Y` containing the image of `X`
such that `X` is closed in `U`.
-/
def Scheme.Hom.coborderRange (f : X ⟶ Y) [IsImmersion f] : Y.Opens :=
⟨coborder (Set.range f), f.isLocallyClosed_range.isOpen_coborder⟩
/--
The first part of the factorization of an immersion `f : X ⟶ Y` to a closed immersion
`f.liftCoborder : X ⟶ f.coborderRange` and a dominant open immersion `f.coborderRange.ι`.
-/
noncomputable
def Scheme.Hom.liftCoborder (f : X ⟶ Y) [IsImmersion f] : X ⟶ f.coborderRange :=
IsOpenImmersion.lift f.coborderRange.ι f (by simpa using subset_coborder)
/--
Any (locally-closed) immersion can be factored into
a closed immersion followed by a (dominant) open immersion.
-/
@[reassoc (attr := simp)]
lemma Scheme.Hom.liftCoborder_ι (f : X ⟶ Y) [IsImmersion f] :
f.liftCoborder ≫ f.coborderRange.ι = f :=
IsOpenImmersion.lift_fac _ _ _
lemma Scheme.Hom.liftCoborder_preimage [IsImmersion f] (U : f.coborderRange.toScheme.Opens) :
f.liftCoborder ⁻¹ᵁ U = f ⁻¹ᵁ f.coborderRange.ι ''ᵁ U := by
conv_rhs => enter [1]; rw [← f.liftCoborder_ι]
rw [Scheme.Hom.comp_preimage, Scheme.Hom.preimage_image_eq]
lemma liftCoborder_app [IsImmersion f] (U : f.coborderRange.toScheme.Opens) :
f.liftCoborder.app U = f.app (f.coborderRange.ι ''ᵁ U) ≫
X.presheaf.map (eqToHom <| f.liftCoborder_preimage U).op := by
rw [Scheme.Hom.congr_app (f.liftCoborder_ι).symm (f.coborderRange.ι ''ᵁ U)]
simp [Scheme.Hom.app_eq f.liftCoborder (f.coborderRange.ι.preimage_image_eq U),
← Functor.map_comp_assoc, - Functor.map_comp, Subsingleton.elim _ (𝟙 _)]
instance [IsImmersion f] : IsClosedImmersion f.liftCoborder := by
have : IsPreimmersion (f.liftCoborder ≫ f.coborderRange.ι) := by
simp only [Scheme.Hom.liftCoborder_ι]; infer_instance
have : IsPreimmersion f.liftCoborder := .of_comp f.liftCoborder f.coborderRange.ι
refine .of_isPreimmersion _ ?_
convert isClosed_preimage_val_coborder
apply Set.image_injective.mpr f.coborderRange.ι.isEmbedding.injective
rw [← Set.range_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, f.liftCoborder_ι]
exact (Set.image_preimage_eq_of_subset (by simpa using subset_coborder)).symm
instance [IsImmersion f] : IsDominant f.coborderRange.ι := by
rw [isDominant_iff, DenseRange, Scheme.Opens.range_ι]
exact dense_coborder
lemma isImmersion_eq_inf : @IsImmersion = (@IsPreimmersion ⊓
topologically fun {_ _} _ _ f ↦ IsLocallyClosed (Set.range f) : MorphismProperty Scheme) := by
ext; exact isImmersion_iff _
namespace IsImmersion
instance : IsZariskiLocalAtTarget @IsImmersion := by
suffices IsZariskiLocalAtTarget
(topologically fun {X Y} _ _ f ↦ IsLocallyClosed (Set.range f)) from
isImmersion_eq_inf ▸ inferInstance
apply (config := { allowSynthFailures := true }) topologically_isZariskiLocalAtTarget'
· refine { precomp := ?_, postcomp := ?_ }
· intro X Y Z i hi f hf
change IsIso i at hi
change IsLocallyClosed _
simpa only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp,
Set.range_eq_univ.mpr i.surjective, Set.image_univ]
· intro X Y Z i hi f hf
change IsIso i at hi
change IsLocallyClosed _
simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp]
refine hf.image i.homeomorph.isInducing ?_
rw [Set.range_eq_univ.mpr i.surjective]
exact isOpen_univ.isLocallyClosed
· simp_rw [Set.range_restrictPreimage]
exact fun _ _ _ hU _ ↦ hU.isLocallyClosed_iff_coe_preimage
instance (priority := 900) (f : X ⟶ Y) [IsOpenImmersion f] : IsImmersion f where
isLocallyClosed_range := f.isOpenEmbedding.2.isLocallyClosed
instance (priority := 900) (f : X ⟶ Y) [IsClosedImmersion f] : IsImmersion f where
isLocallyClosed_range := f.isClosedEmbedding.2.isLocallyClosed
instance : MorphismProperty.IsMultiplicative @IsImmersion where
id_mem _ := inferInstance
comp_mem {X Y Z} f g hf hg := by
refine { __ := inferInstanceAs (IsPreimmersion (f ≫ g)), isLocallyClosed_range := ?_ }
simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp]
exact f.isLocallyClosed_range.image g.isEmbedding.isInducing g.isLocallyClosed_range
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsImmersion f]
[IsImmersion g] : IsImmersion (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
variable {f} in
/--
A morphism is a (locally-closed) immersion if and only if it can be factored into
a closed immersion followed by an open immersion.
-/
lemma isImmersion_iff_exists : IsImmersion f ↔ ∃ (Z : Scheme) (g₁ : X ⟶ Z) (g₂ : Z ⟶ Y),
IsClosedImmersion g₁ ∧ IsOpenImmersion g₂ ∧ g₁ ≫ g₂ = f :=
⟨fun _ ↦ ⟨_, f.liftCoborder, f.coborderRange.ι, inferInstance, inferInstance, f.liftCoborder_ι⟩,
fun ⟨_, _, _, _, _, e⟩ ↦ e ▸ inferInstance⟩
instance isStableUnderBaseChange : MorphismProperty.IsStableUnderBaseChange @IsImmersion where
of_isPullback := by
intro X Y Y' S f g f' g' H hg
let Z := Limits.pullback f g.coborderRange.ι
let e : Y' ⟶ Z := Limits.pullback.lift g' (f' ≫ g.liftCoborder) (by simpa using H.w.symm)
have : IsClosedImmersion e := by
have := (IsPullback.paste_horiz_iff (.of_hasPullback f g.coborderRange.ι)
(show e ≫ Limits.pullback.snd _ _ = _ from Limits.pullback.lift_snd _ _ _)).mp ?_
· exact MorphismProperty.of_isPullback this.flip inferInstance
· simpa [e] using H.flip
rw [← Limits.pullback.lift_fst (f := f) (g := g.coborderRange.ι) g' (f' ≫ g.liftCoborder)
(by simpa using H.w.symm)]
infer_instance
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsImmersion g] : IsImmersion (Limits.pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ ‹_›
instance (f : X ⟶ Z) (g : Y ⟶ Z) [IsImmersion f] : IsImmersion (Limits.pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ ‹_›
instance (f : X ⟶ Y) (V : Y.Opens) [IsImmersion f] : IsImmersion (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [IsImmersion f] :
IsImmersion (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
open Limits Scheme.Pullback in
/-- The diagonal morphism is always an immersion. -/
@[stacks 01KJ]
instance : IsImmersion (pullback.diagonal f) := by
let 𝒰 := Y.affineCover
let 𝒱 (i) := (pullback f (𝒰.f i)).affineCover
have H : pullback.diagonal f ⁻¹ᵁ diagonalCoverDiagonalRange f 𝒰 𝒱 = ⊤ :=
top_le_iff.mp fun _ _ ↦ range_diagonal_subset_diagonalCoverDiagonalRange _ _ _ ⟨_, rfl⟩
have := isClosedImmersion_diagonal_restrict_diagonalCoverDiagonalRange f 𝒰 𝒱
have : IsImmersion ((pullback.diagonal f ∣_
diagonalCoverDiagonalRange f 𝒰 𝒱) ≫ Scheme.Opens.ι _) := inferInstance
rwa [morphismRestrict_ι, H, ← Scheme.topIso_hom,
MorphismProperty.cancel_left_of_respectsIso (P := @IsImmersion)] at this
/-- The map `X ×[S] Y ⟶ X ×[T] Y` induced by any `S ⟶ T` is always an immersion. -/
instance {S T : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) (i : S ⟶ T) :
IsImmersion (pullback.mapDesc f g i) :=
MorphismProperty.of_isPullback (pullback_map_diagonal_isPullback f g i) inferInstance
instance : MorphismProperty.HasOfPostcompProperty @IsImmersion ⊤ :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
fun _ _ _ _ ↦ inferInstanceAs (IsImmersion _)
lemma of_comp (f : X ⟶ Y) (g : Y ⟶ Z) [IsImmersion (f ≫ g)] :
IsImmersion f :=
MorphismProperty.HasOfPostcompProperty.of_postcomp (W' := ⊤) _ g trivial ‹_›
theorem comp_iff {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsImmersion g] :
IsImmersion (f ≫ g) ↔ IsImmersion f :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
instance : IsImmersion (prod.lift (𝟙 X) (𝟙 X)) := by
rw [← MorphismProperty.cancel_right_of_respectsIso @IsImmersion _ (prodIsoPullback X X).hom]
convert inferInstanceAs (IsImmersion (pullback.diagonal (terminal.from X)))
ext : 1 <;> simp
instance (f g : X ⟶ Y) : IsImmersion (equalizer.ι f g) :=
MorphismProperty.of_isPullback (P := @IsImmersion)
(isPullback_equalizer_prod f g).flip inferInstance
instance [IsImmersion f] : IsImmersion f.toImage :=
have : IsImmersion (f.toImage ≫ f.imageι) := by simpa
IsImmersion.of_comp f.toImage f.imageι
open Scheme in
/--
If `f : X ⟶ Y` is a quasi-compact immersion, then `X` is the pullback of the
closed immersion `im f ⟶ Y` and an open immersion `U ⟶ Y`.
-/
lemma isPullback_toImage_liftCoborder [IsImmersion f] [QuasiCompact f] :
IsPullback f.toImage f.liftCoborder f.imageι f.coborderRange.ι := by
refine (isPullback_of_isClosedImmersion _ _ _ _ (by simp) ?_).flip
rw [Hom.imageι, IdealSheafData.ker_subschemeι]
ext U : 2
simp only [IdealSheafData.ideal_comap_of_isOpenImmersion, Opens.ι_appIso, Iso.refl_inv,
Hom.ker_apply, RingHom.comap_ker, ← CommRingCat.hom_comp]
dsimp [Opens.toScheme_presheaf_obj]
rw [RingHomCompTriple.comp_eq, liftCoborder_app,
CommRingCat.hom_comp, RingHom.ker_comp_of_injective]
rw [← ConcreteCategory.mono_iff_injective_of_preservesPullback]
infer_instance
instance [IsImmersion f] [QuasiCompact f] : IsOpenImmersion f.toImage :=
MorphismProperty.of_isPullback (IsImmersion.isPullback_toImage_liftCoborder f).flip inferInstance
variable {f} in
/--
A quasi-compact morphism is a (locally-closed) immersion if and only if it can be factored into
an open immersion followed by a closed immersion.
-/
lemma isImmersion_iff_exists_of_quasiCompact [QuasiCompact f] :
IsImmersion f ↔ ∃ (Z : Scheme) (g₁ : X ⟶ Z) (g₂ : Z ⟶ Y),
IsOpenImmersion g₁ ∧ IsClosedImmersion g₂ ∧ g₁ ≫ g₂ = f :=
⟨fun _ ↦ ⟨_, f.toImage, f.imageι, inferInstance, inferInstance, f.toImage_imageι⟩,
fun ⟨_, _, _, _, _, e⟩ ↦ e ▸ inferInstance⟩
end IsImmersion
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean | import Mathlib.AlgebraicGeometry.Morphisms.Constructors
import Mathlib.RingTheory.LocalProperties.Basic
import Mathlib.RingTheory.RingHom.Locally
/-!
# Properties of morphisms from properties of ring homs.
We provide the basic framework for talking about properties of morphisms that come from properties
of ring homs. For `P` a property of ring homs, we have two ways of defining a property of scheme
morphisms:
Let `f : X ⟶ Y`,
- `targetAffineLocally (affineAnd P)`: the preimage of an affine open `U = Spec A` is affine
(`= Spec B`) and `A ⟶ B` satisfies `P`. (in `Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean`)
- `affineLocally P`: For each pair of affine open `U = Spec A ⊆ X` and `V = Spec B ⊆ f ⁻¹' U`,
the ring hom `A ⟶ B` satisfies `P`.
For these notions to be well defined, we require `P` be a sufficient local property. For the former,
`P` should be local on the source (`RingHom.RespectsIso P`, `RingHom.LocalizationPreserves P`,
`RingHom.OfLocalizationSpan`), and `targetAffineLocally (affine_and P)` will be local on
the target.
For the latter `P` should be local on the target (`RingHom.PropertyIsLocal P`), and
`affineLocally P` will be local on both the source and the target.
We also provide the following interface:
## `HasRingHomProperty`
`HasRingHomProperty P Q` is a type class asserting that `P` is local at the target and the source,
and for `f : Spec B ⟶ Spec A`, it is equivalent to the ring hom property `Q` on `Γ(f)`.
For `HasRingHomProperty P Q` and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.HasRingHomProperty.iff_appLE`:
`P f` if and only if `Q (f.appLE U V _)` for all affine `U : Opens Y` and `V : Opens X`.
- `AlgebraicGeometry.HasRingHomProperty.iff_of_source_openCover`:
If `Y` is affine, `P f ↔ ∀ i, Q ((𝒰.map i ≫ f).appTop)` for an affine open cover `𝒰` of `X`.
- `AlgebraicGeometry.HasRingHomProperty.iff_of_isAffine`:
If `X` and `Y` are affine, then `P f ↔ Q (f.appTop)`.
- `AlgebraicGeometry.HasRingHomProperty.Spec_iff`:
`P (Spec.map φ) ↔ Q φ`
- `AlgebraicGeometry.HasRingHomProperty.iff_of_iSup_eq_top`:
If `Y` is affine, `P f ↔ ∀ i, Q (f.appLE ⊤ (U i) _)` for a family `U` of affine opens of `X`.
- `AlgebraicGeometry.HasRingHomProperty.of_isOpenImmersion`:
If `f` is an open immersion then `P f`.
- `AlgebraicGeometry.HasRingHomProperty.isStableUnderBaseChange`:
If `Q` is stable under base change, then so is `P`.
We also provide the instances `P.IsMultiplicative`, `P.IsStableUnderComposition`,
`IsZariskiLocalAtTarget P`, `IsZariskiLocalAtSource P`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
universe u
open CategoryTheory Opposite TopologicalSpace CategoryTheory.Limits AlgebraicGeometry
namespace RingHom
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
theorem IsStableUnderBaseChange.pullback_fst_appTop
(hP : IsStableUnderBaseChange P) (hP' : RespectsIso P)
{X Y S : Scheme} [IsAffine X] [IsAffine Y] [IsAffine S] (f : X ⟶ S) (g : Y ⟶ S)
(H : P g.appTop.hom) : P (pullback.fst f g).appTop.hom := by
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11224): change `rw` to `erw`
erw [← PreservesPullback.iso_inv_fst AffineScheme.forgetToScheme (AffineScheme.ofHom f)
(AffineScheme.ofHom g)]
rw [Scheme.Hom.comp_appTop, CommRingCat.hom_comp, hP'.cancel_right_isIso,
AffineScheme.forgetToScheme_map]
have := congr_arg Quiver.Hom.unop
(PreservesPullback.iso_hom_fst AffineScheme.Γ.rightOp (AffineScheme.ofHom f)
(AffineScheme.ofHom g))
simp only [AffineScheme.Γ, Functor.rightOp_obj, Functor.comp_obj, Functor.op_obj, unop_comp,
AffineScheme.forgetToScheme_obj, Scheme.Γ_obj, Functor.rightOp_map, Functor.comp_map,
Functor.op_map, Quiver.Hom.unop_op, AffineScheme.forgetToScheme_map, Scheme.Γ_map] at this
rw [← this, CommRingCat.hom_comp, hP'.cancel_right_isIso, ← pushoutIsoUnopPullback_inl_hom,
CommRingCat.hom_comp, hP'.cancel_right_isIso]
exact hP.pushout_inl hP' _ _ H
end RingHom
namespace AlgebraicGeometry
section affineLocally
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
/-- For `P` a property of ring homomorphisms, `sourceAffineLocally P` holds for `f : X ⟶ Y`
whenever `P` holds for the restriction of `f` on every affine open subset of `X`. -/
def sourceAffineLocally : AffineTargetMorphismProperty := fun X _ f _ =>
∀ U : X.affineOpens, P (f.appLE ⊤ U le_top).hom
/-- For `P` a property of ring homomorphisms, `affineLocally P` holds for `f : X ⟶ Y` if for each
affine open `U = Spec A ⊆ Y` and `V = Spec B ⊆ f ⁻¹' U`, the ring hom `A ⟶ B` satisfies `P`.
Also see `affineLocally_iff_affineOpens_le`. -/
abbrev affineLocally : MorphismProperty Scheme.{u} :=
targetAffineLocally (sourceAffineLocally P)
theorem sourceAffineLocally_respectsIso (h₁ : RingHom.RespectsIso P) :
(sourceAffineLocally P).toProperty.RespectsIso := by
apply AffineTargetMorphismProperty.respectsIso_mk
· introv H U
have : IsIso (e.hom.appLE (e.hom ''ᵁ U) U.1 (e.hom.preimage_image_eq _).ge) :=
inferInstanceAs (IsIso (e.hom.app _ ≫
X.presheaf.map (eqToHom (e.hom.preimage_image_eq _).symm).op))
rw [← Scheme.Hom.appLE_comp_appLE _ _ ⊤ (e.hom ''ᵁ U) U.1 le_top (e.hom.preimage_image_eq _).ge,
CommRingCat.hom_comp, h₁.cancel_right_isIso]
exact H ⟨_, U.prop.image_of_isOpenImmersion e.hom⟩
· introv H U
rw [Scheme.Hom.comp_appLE, CommRingCat.hom_comp, h₁.cancel_left_isIso]
exact H U
theorem affineLocally_respectsIso (h : RingHom.RespectsIso P) : (affineLocally P).RespectsIso :=
letI := sourceAffineLocally_respectsIso P h
inferInstance
open Scheme in
theorem sourceAffineLocally_morphismRestrict {X Y : Scheme.{u}} (f : X ⟶ Y)
(U : Y.Opens) (hU : IsAffineOpen U) :
@sourceAffineLocally P _ _ (f ∣_ U) hU ↔
∀ (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U), P (f.appLE U V e).hom := by
dsimp only [sourceAffineLocally]
simp only [morphismRestrict_appLE]
rw [(affineOpensRestrict (f ⁻¹ᵁ U)).forall_congr_left, Subtype.forall]
refine forall₂_congr fun V h ↦ ?_
have := (affineOpensRestrict (f ⁻¹ᵁ U)).apply_symm_apply ⟨V, h⟩
exact f.appLE_congr _ (Opens.ι_image_top _) congr($(this).1.1) (fun f => P f.hom)
theorem affineLocally_iff_affineOpens_le {X Y : Scheme.{u}} (f : X ⟶ Y) :
affineLocally.{u} P f ↔
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), P (f.appLE U V e).hom :=
forall_congr' fun U ↦ sourceAffineLocally_morphismRestrict P f U U.2
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso P)
(h₂ : RingHom.LocalizationAwayPreserves P) (h₃ : RingHom.OfLocalizationSpan P) :
(sourceAffineLocally P).IsLocal := by
constructor
· exact sourceAffineLocally_respectsIso P h₁
· intro X Y _ f r H
rw [sourceAffineLocally_morphismRestrict]
intro U hU
have : X.basicOpen (f.appLE ⊤ U (by simp) r) = U := by
simp only [Scheme.Hom.appLE, Opens.map_top, CommRingCat.comp_apply]
rw [Scheme.basicOpen_res]
simpa using hU
rw [← f.appLE_congr (by simp [Scheme.Hom.appLE]) rfl this (fun f => P f.hom),
IsAffineOpen.appLE_eq_away_map f (isAffineOpen_top Y) U.2 _ r]
simp only [CommRingCat.hom_ofHom]
apply (config := { allowSynthFailures := true }) h₂
exact H U
· introv hs hs' U
apply h₃ _ _ hs
intro r
simp_rw [sourceAffineLocally_morphismRestrict] at hs'
have := hs' r ⟨X.basicOpen (f.appLE ⊤ U le_top r.1), U.2.basicOpen (f.appLE ⊤ U le_top r.1)⟩
(by simp [Scheme.Hom.appLE])
rwa [IsAffineOpen.appLE_eq_away_map f (isAffineOpen_top Y) U.2, CommRingCat.hom_ofHom,
← h₁.isLocalization_away_iff] at this
variable {P}
lemma affineLocally_le {Q : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
(hPQ : ∀ {R S : Type u} [CommRing R] [CommRing S] {f : R →+* S}, P f → Q f) :
affineLocally P ≤ affineLocally Q :=
fun _ _ _ hf U V ↦ hPQ (hf U V)
open RingHom
variable {X Y : Scheme.{u}} {f : X ⟶ Y}
/-- If `P` holds for `f` over affine opens `U₂` of `Y` and `V₂` of `X` and `U₁` (resp. `V₁`) are
open affine neighborhoods of `x` (resp. `f.base x`), then `P` also holds for `f`
over some basic open of `U₁` (resp. `V₁`). -/
lemma exists_basicOpen_le_appLE_of_appLE_of_isAffine
(hPa : StableUnderCompositionWithLocalizationAwayTarget P) (hPl : LocalizationAwayPreserves P)
(x : X) (U₁ : Y.affineOpens) (U₂ : Y.affineOpens) (V₁ : X.affineOpens) (V₂ : X.affineOpens)
(hx₁ : x ∈ V₁.1) (hx₂ : x ∈ V₂.1) (e₂ : V₂.1 ≤ f ⁻¹ᵁ U₂.1) (h₂ : P (f.appLE U₂ V₂ e₂).hom)
(hfx₁ : f x ∈ U₁.1) :
∃ (r : Γ(Y, U₁)) (s : Γ(X, V₁)) (_ : x ∈ X.basicOpen s)
(e : X.basicOpen s ≤ f ⁻¹ᵁ Y.basicOpen r),
P (f.appLE (Y.basicOpen r) (X.basicOpen s) e).hom := by
obtain ⟨r, r', hBrr', hBfx⟩ := exists_basicOpen_le_affine_inter U₁.2 U₂.2 (f x)
⟨hfx₁, e₂ hx₂⟩
have ha : IsAffineOpen (X.basicOpen (f.appLE U₂ V₂ e₂ r')) := V₂.2.basicOpen _
have hxa : x ∈ X.basicOpen (f.appLE U₂ V₂ e₂ r') := by
simpa [Scheme.Hom.appLE, ← Scheme.preimage_basicOpen] using And.intro hx₂ (hBrr' ▸ hBfx)
obtain ⟨s, s', hBss', hBx⟩ := exists_basicOpen_le_affine_inter V₁.2 ha x ⟨hx₁, hxa⟩
haveI := V₂.2.isLocalization_basicOpen (f.appLE U₂ V₂ e₂ r')
haveI := U₂.2.isLocalization_basicOpen r'
haveI := ha.isLocalization_basicOpen s'
have ers : X.basicOpen s ≤ f ⁻¹ᵁ Y.basicOpen r := by
rw [hBss', hBrr']
apply le_trans (X.basicOpen_le _)
simp [Scheme.Hom.appLE]
have heq : f.appLE (Y.basicOpen r') (X.basicOpen s') (hBrr' ▸ hBss' ▸ ers) =
f.appLE (Y.basicOpen r') (X.basicOpen (f.appLE U₂ V₂ e₂ r')) (by simp [Scheme.Hom.appLE]) ≫
CommRingCat.ofHom (algebraMap _ _) := by
simp only [Scheme.Hom.appLE, homOfLE_leOfHom, Category.assoc]
congr
apply X.presheaf.map_comp
refine ⟨r, s, hBx, ers, ?_⟩
· rw [f.appLE_congr _ hBrr' hBss' (fun f => P f.hom), heq]
apply hPa _ s' _
rw [U₂.2.appLE_eq_away_map f V₂.2]
exact hPl _ _ _ _ h₂
/-- If `P` holds for `f` over affine opens `U₂` of `Y` and `V₂` of `X` and `U₁` (resp. `V₁`) are
open neighborhoods of `x` (resp. `f.base x`), then `P` also holds for `f` over some affine open
`U'` of `Y` (resp. `V'` of `X`) that is contained in `U₁` (resp. `V₁`). -/
lemma exists_affineOpens_le_appLE_of_appLE
(hPa : StableUnderCompositionWithLocalizationAwayTarget P) (hPl : LocalizationAwayPreserves P)
(x : X) (U₁ : Y.Opens) (U₂ : Y.affineOpens) (V₁ : X.Opens) (V₂ : X.affineOpens)
(hx₁ : x ∈ V₁) (hx₂ : x ∈ V₂.1) (e₂ : V₂.1 ≤ f ⁻¹ᵁ U₂.1) (h₂ : P (f.appLE U₂ V₂ e₂).hom)
(hfx₁ : f x ∈ U₁.1) :
∃ (U' : Y.affineOpens) (V' : X.affineOpens) (_ : U'.1 ≤ U₁) (_ : V'.1 ≤ V₁) (_ : x ∈ V'.1)
(e : V'.1 ≤ f⁻¹ᵁ U'.1), P (f.appLE U' V' e).hom := by
obtain ⟨r, hBr, hBfx⟩ := U₂.2.exists_basicOpen_le ⟨f x, hfx₁⟩ (e₂ hx₂)
obtain ⟨s, hBs, hBx⟩ := V₂.2.exists_basicOpen_le ⟨x, hx₁⟩ hx₂
obtain ⟨r', s', hBx', e', hf'⟩ := exists_basicOpen_le_appLE_of_appLE_of_isAffine hPa hPl x
⟨Y.basicOpen r, U₂.2.basicOpen _⟩ U₂ ⟨X.basicOpen s, V₂.2.basicOpen _⟩ V₂ hBx hx₂ e₂ h₂ hBfx
exact ⟨⟨Y.basicOpen r', (U₂.2.basicOpen _).basicOpen _⟩,
⟨X.basicOpen s', (V₂.2.basicOpen _).basicOpen _⟩, le_trans (Y.basicOpen_le _) hBr,
le_trans (X.basicOpen_le _) hBs, hBx', e', hf'⟩
end affineLocally
/--
`HasRingHomProperty P Q` is a type class asserting that `P` is local at the target and the source,
and for `f : Spec B ⟶ Spec A`, it is equivalent to the ring hom property `Q`.
To make the proofs easier, we state it instead as
1. `Q` is local (See `RingHom.PropertyIsLocal`)
2. `P f` if and only if `Q` holds for every `Γ(Y, U) ⟶ Γ(X, V)` for all affine `U`, `V`.
See `HasRingHomProperty.iff_appLE`.
-/
class HasRingHomProperty (P : MorphismProperty Scheme.{u})
(Q : outParam (∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)) : Prop where
isLocal_ringHomProperty : RingHom.PropertyIsLocal Q
eq_affineLocally' : P = affineLocally Q
namespace HasRingHomProperty
variable (P : MorphismProperty Scheme.{u}) {Q} [HasRingHomProperty P Q]
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
lemma copy {P' : MorphismProperty Scheme.{u}}
{Q' : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
(e : P = P') (e' : ∀ {R S : Type u} [CommRing R] [CommRing S] (f : R →+* S), Q f ↔ Q' f) :
HasRingHomProperty P' Q' := by
subst e
have heq : @Q = @Q' := by
ext R S _ _ f
exact (e' f)
rw [← heq]
infer_instance
lemma eq_affineLocally : P = affineLocally Q := eq_affineLocally'
@[local instance]
lemma HasAffineProperty : HasAffineProperty P (sourceAffineLocally Q) where
isLocal_affineProperty := sourceAffineLocally_isLocal _
(isLocal_ringHomProperty P).respectsIso
(isLocal_ringHomProperty P).localizationAwayPreserves
(isLocal_ringHomProperty P).ofLocalizationSpan
eq_targetAffineLocally' := eq_affineLocally P
/- This is only `inferInstance` because of the `@[local instance]` on `HasAffineProperty` above. -/
instance (priority := 900) : IsZariskiLocalAtTarget P := inferInstance
theorem appLE (H : P f) (U : Y.affineOpens) (V : X.affineOpens) (e) : Q (f.appLE U V e).hom := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le] at H
exact H _ _ _
theorem appTop (H : P f) [IsAffine X] [IsAffine Y] : Q f.appTop.hom := by
rw [Scheme.Hom.appTop, Scheme.Hom.app_eq_appLE]
exact appLE P f H ⟨_, isAffineOpen_top _⟩ ⟨_, isAffineOpen_top _⟩ _
include Q in
theorem comp_of_isOpenImmersion [IsOpenImmersion f] (H : P g) :
P (f ≫ g) := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le] at H ⊢
intro U V e
have : IsIso (f.appLE (f ''ᵁ V) V.1 (f.preimage_image_eq _).ge) :=
inferInstanceAs (IsIso (f.app _ ≫
X.presheaf.map (eqToHom (f.preimage_image_eq _).symm).op))
rw [← Scheme.Hom.appLE_comp_appLE _ _ _ (f ''ᵁ V) V.1
(Set.image_subset_iff.mpr e) (f.preimage_image_eq _).ge,
CommRingCat.hom_comp,
(isLocal_ringHomProperty P).respectsIso.cancel_right_isIso]
exact H _ ⟨_, V.2.image_of_isOpenImmersion _⟩ _
variable {P f}
lemma iff_appLE : P f ↔ ∀ (U : Y.affineOpens) (V : X.affineOpens) (e), Q (f.appLE U V e).hom := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le]
theorem of_source_openCover [IsAffine Y]
(𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.X i)] (H : ∀ i, Q ((𝒰.f i ≫ f).appTop.hom)) :
P f := by
rw [HasAffineProperty.iff_of_isAffine (P := P)]
intro U
let S i : X.affineOpens := ⟨_, isAffineOpen_opensRange (𝒰.f i)⟩
induction U using of_affine_open_cover S 𝒰.iSup_opensRange with
| basicOpen U r H =>
simp_rw [Scheme.affineBasicOpen_coe,
← f.appLE_map (U := ⊤) le_top (homOfLE (X.basicOpen_le r)).op]
have := U.2.isLocalization_basicOpen r
exact (isLocal_ringHomProperty P).StableUnderCompositionWithLocalizationAwayTarget _ r _ H
| openCover U s hs H =>
apply (isLocal_ringHomProperty P).ofLocalizationSpanTarget.ofIsLocalization
(isLocal_ringHomProperty P).respectsIso _ _ hs
rintro r
refine ⟨_, _, _, IsAffineOpen.isLocalization_basicOpen U.2 r, ?_⟩
rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp, Scheme.Hom.appLE_map]
exact H r
| hU i =>
specialize H i
rw [← (isLocal_ringHomProperty P).respectsIso.cancel_right_isIso _
((IsOpenImmersion.isoOfRangeEq (𝒰.f i) (S i).1.ι
Subtype.range_coe.symm).inv.app _), ← CommRingCat.hom_comp, ← Scheme.Hom.comp_appTop,
IsOpenImmersion.isoOfRangeEq_inv_fac_assoc, Scheme.Hom.comp_appTop,
Scheme.Opens.ι_appTop, Scheme.Hom.appTop, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_map] at H
exact (f.appLE_congr _ rfl (by simp) (fun f => Q f.hom)).mp H
theorem iff_of_source_openCover [IsAffine Y] (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.X i)] :
P f ↔ ∀ i, Q ((𝒰.f i ≫ f).appTop).hom :=
⟨fun H i ↦ appTop P _ (comp_of_isOpenImmersion P (𝒰.f i) f H), of_source_openCover 𝒰⟩
theorem iff_of_isAffine [IsAffine X] [IsAffine Y] :
P f ↔ Q (f.appTop).hom := by
rw [iff_of_source_openCover (P := P) (Scheme.coverOfIsIso.{u} (𝟙 _))]
simp
theorem Spec_iff {R S : CommRingCat.{u}} {φ : R ⟶ S} :
P (Spec.map φ) ↔ Q φ.hom := by
have H := (isLocal_ringHomProperty P).respectsIso
rw [iff_of_isAffine (P := P), ← H.cancel_right_isIso _ (Scheme.ΓSpecIso _).hom,
← CommRingCat.hom_comp, Scheme.ΓSpecIso_naturality, CommRingCat.hom_comp, H.cancel_left_isIso]
theorem of_iSup_eq_top [IsAffine Y] {ι : Type*}
(U : ι → X.affineOpens) (hU : ⨆ i, (U i : Opens X) = ⊤)
(H : ∀ i, Q (f.appLE ⊤ (U i).1 le_top).hom) :
P f := by
have (i : _) : IsAffine ((X.openCoverOfIsOpenCover _ hU).X i) := (U i).2
refine of_source_openCover (X.openCoverOfIsOpenCover _ hU) fun i ↦ ?_
simpa [Scheme.Hom.app_eq_appLE] using (f.appLE_congr _ rfl (by simp) (fun f => Q f.hom)).mp (H i)
theorem iff_of_iSup_eq_top [IsAffine Y] {ι : Type*}
(U : ι → X.affineOpens) (hU : ⨆ i, (U i : Opens X) = ⊤) :
P f ↔ ∀ i, Q (f.appLE ⊤ (U i).1 le_top).hom :=
⟨fun H _ ↦ appLE P f H ⟨_, isAffineOpen_top _⟩ _ le_top, of_iSup_eq_top U hU⟩
instance : IsZariskiLocalAtSource P := by
apply HasAffineProperty.isZariskiLocalAtSource
intro X Y f _ 𝒰
simp_rw [← HasAffineProperty.iff_of_isAffine (P := P),
iff_of_source_openCover 𝒰.affineRefinement.openCover,
fun i ↦ iff_of_source_openCover (P := P) (f := 𝒰.f i ≫ f) (𝒰.X i).affineCover]
simp [Scheme.OpenCover.affineRefinement, Sigma.forall]
lemma containsIdentities (hP : RingHom.ContainsIdentities Q) : P.ContainsIdentities where
id_mem X := by
rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
have : IsAffine (𝟙 X ⁻¹ᵁ U.1) := U.2
rw [morphismRestrict_id, iff_of_isAffine (P := P), Scheme.Hom.id_appTop]
apply hP
variable (P) in
open _root_.PrimeSpectrum in
lemma isLocal_ringHomProperty_of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget
[IsZariskiLocalAtTarget P] [IsZariskiLocalAtSource P] :
RingHom.PropertyIsLocal fun f ↦ P (Spec.map (CommRingCat.ofHom f)) := by
have hP : RingHom.RespectsIso (fun f ↦ P (Spec.map (CommRingCat.ofHom f))) :=
RingHom.toMorphismProperty_respectsIso_iff.mpr
(inferInstanceAs (P.inverseImage Scheme.Spec).unop.RespectsIso)
constructor
· intro R S _ _ f r R' S' _ _ _ _ _ _ H
refine (RingHom.RespectsIso.isLocalization_away_iff hP ..).mp ?_
exact (MorphismProperty.arrow_mk_iso_iff P (SpecMapRestrictBasicOpenIso
(CommRingCat.ofHom f) r)).mp (IsZariskiLocalAtTarget.restrict H (basicOpen r))
· intro R S _ _ f s hs H
apply IsZariskiLocalAtSource.of_openCover (Scheme.affineOpenCoverOfSpanRangeEqTop
(fun i : s ↦ (i : S)) (by simpa)).openCover
intro i
simp only [CommRingCat.coe_of, Scheme.AffineOpenCover.openCover_X, ← Spec.map_comp,
Scheme.AffineOpenCover.openCover_f, Scheme.affineOpenCoverOfSpanRangeEqTop_f]
exact H i
· intro R S _ _ f s hs H
apply IsZariskiLocalAtTarget.of_iSup_eq_top _ (PrimeSpectrum.iSup_basicOpen_eq_top_iff
(f := fun i : s ↦ (i : R)).mpr (by simpa))
intro i
exact (MorphismProperty.arrow_mk_iso_iff P (SpecMapRestrictBasicOpenIso
(CommRingCat.ofHom f) i.1)).mpr (H i)
· intro R S T _ _ _ _ r _ f hf
have := AlgebraicGeometry.IsOpenImmersion.of_isLocalization (S := T) r
change P (Spec.map (CommRingCat.ofHom f ≫ CommRingCat.ofHom (algebraMap _ _)))
rw [Spec.map_comp]
exact IsZariskiLocalAtSource.comp hf ..
open _root_.PrimeSpectrum in
variable (P) in
lemma of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget [IsZariskiLocalAtTarget P]
[IsZariskiLocalAtSource P] :
HasRingHomProperty P (fun f ↦ P (Spec.map (CommRingCat.ofHom f))) where
isLocal_ringHomProperty :=
isLocal_ringHomProperty_of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget P
eq_affineLocally' := by
let Q := affineLocally (fun f ↦ P (Spec.map (CommRingCat.ofHom f)))
have : HasRingHomProperty Q (fun f ↦ P (Spec.map (CommRingCat.ofHom f))) :=
⟨isLocal_ringHomProperty_of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget P, rfl⟩
change P = Q
ext X Y f
wlog hY : ∃ R, Y = Spec R generalizing X Y
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := P) Y.affineCover,
IsZariskiLocalAtTarget.iff_of_openCover (P := Q) Y.affineCover]
refine forall_congr' fun _ ↦ this _ ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hY
wlog hX : ∃ R, X = Spec R generalizing X
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) X.affineCover,
IsZariskiLocalAtSource.iff_of_openCover (P := Q) X.affineCover]
refine forall_congr' fun _ ↦ this _ ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hX
obtain ⟨φ, rfl⟩ : ∃ φ, Spec.map φ = f := ⟨_, Spec.map_preimage _⟩
rw [HasRingHomProperty.Spec_iff (P := Q)]
rfl
@[deprecated (since := "2025-10-07")]
alias of_isLocalAtSource_of_isLocalAtTarget := of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget
lemma stalkwise {P} (hP : RingHom.RespectsIso P) :
HasRingHomProperty (stalkwise P) fun {_ S _ _} φ ↦
∀ (p : Ideal S) (_ : p.IsPrime), P (Localization.localRingHom _ p φ rfl) := by
have := stalkwiseIsZariskiLocalAtTarget_of_respectsIso hP
have := stalkwise_isZariskiLocalAtSource_of_respectsIso hP
convert of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget
(P := AlgebraicGeometry.stalkwise P) with R S _ _ φ
exact (stalkwise_SpecMap_iff hP (CommRingCat.ofHom φ)).symm
lemma stableUnderComposition (hP : RingHom.StableUnderComposition Q) :
P.IsStableUnderComposition where
comp_mem {X Y Z} f g hf hg := by
wlog hZ : IsAffine Z generalizing X Y Z
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
rw [morphismRestrict_comp]
exact this _ _ (IsZariskiLocalAtTarget.restrict hf _)
(IsZariskiLocalAtTarget.restrict hg _) U.2
wlog hY : IsAffine Y generalizing X Y
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) (Y.affineCover.pullback₁ f)]
intro i
rw [← Scheme.Cover.pullbackHom_map_assoc]
exact this _ _ (IsZariskiLocalAtTarget.of_isPullback (.of_hasPullback _ _) hf)
(comp_of_isOpenImmersion _ _ _ hg) inferInstance
wlog hX : IsAffine X generalizing X
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) X.affineCover]
intro i
rw [← Category.assoc]
exact this _ (comp_of_isOpenImmersion _ _ _ hf) inferInstance
rw [iff_of_isAffine (P := P)] at hf hg ⊢
exact hP _ _ hg hf
theorem of_comp
(H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
∀ (f : R →+* S) (g : S →+* T), Q (g.comp f) → Q g)
{X Y Z : Scheme.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (h : P (f ≫ g)) : P f := by
wlog hZ : IsAffine Z generalizing X Y Z
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _
(g.iSup_preimage_eq_top (iSup_affineOpens_eq_top Z))]
intro U
have H := IsZariskiLocalAtTarget.restrict h U.1
rw [morphismRestrict_comp] at H
exact this H inferInstance
wlog hY : IsAffine Y generalizing X Y
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top Y)]
intro U
have H := comp_of_isOpenImmersion P (f ⁻¹ᵁ U.1).ι (f ≫ g) h
rw [← morphismRestrict_ι_assoc] at H
exact this H inferInstance
wlog hY : IsAffine X generalizing X
· rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top X)]
intro U
have H := comp_of_isOpenImmersion P U.1.ι (f ≫ g) h
rw [← Category.assoc] at H
exact this H inferInstance
rw [iff_of_isAffine (P := P)] at h ⊢
exact H _ _ h
lemma isMultiplicative (hPc : RingHom.StableUnderComposition Q)
(hPi : RingHom.ContainsIdentities Q) :
P.IsMultiplicative where
comp_mem := (stableUnderComposition hPc).comp_mem
id_mem := (containsIdentities hPi).id_mem
include Q in
lemma of_isOpenImmersion (hP : RingHom.ContainsIdentities Q) [IsOpenImmersion f] : P f :=
haveI : P.ContainsIdentities := containsIdentities hP
IsZariskiLocalAtSource.of_isOpenImmersion f
lemma isStableUnderBaseChange (hP : RingHom.IsStableUnderBaseChange Q) :
P.IsStableUnderBaseChange := by
apply HasAffineProperty.isStableUnderBaseChange
letI := HasAffineProperty.isLocal_affineProperty P
apply AffineTargetMorphismProperty.IsStableUnderBaseChange.mk
intro X Y S _ _ f g H
rw [← HasAffineProperty.iff_of_isAffine (P := P)] at H ⊢
wlog hX : IsAffine Y generalizing Y
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := P)
(Scheme.Pullback.openCoverOfRight Y.affineCover f g)]
intro i
simp only [Scheme.Pullback.openCoverOfRight_X, Scheme.Pullback.openCoverOfRight_f,
limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Category.comp_id]
apply this _ (comp_of_isOpenImmersion _ _ _ H) inferInstance
rw [iff_of_isAffine (P := P)] at H ⊢
exact hP.pullback_fst_appTop _ (isLocal_ringHomProperty P).respectsIso _ _ H
include Q in
private lemma respects_isOpenImmersion_aux
(hQ : RingHom.StableUnderCompositionWithLocalizationAwaySource Q)
{X Y : Scheme.{u}} [IsAffine Y] {U : Y.Opens}
(f : X ⟶ U.toScheme) (hf : P f) : P (f ≫ U.ι) := by
wlog hYa : ∃ (a : Γ(Y, ⊤)), U = Y.basicOpen a generalizing X Y
· obtain ⟨(Us : Set Y.Opens), hUs, heq⟩ := Opens.isBasis_iff_cover.mp (isBasis_basicOpen Y) U
let V (s : Us) : X.Opens := f ⁻¹ᵁ U.ι ⁻¹ᵁ s
rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (P := P) V]
· intro s
let f' : (V s).toScheme ⟶ U.ι ⁻¹ᵁ s := f ∣_ U.ι ⁻¹ᵁ s
have hf' : P f' := IsZariskiLocalAtTarget.restrict hf _
let e : (U.ι ⁻¹ᵁ s).toScheme ≅ s := IsOpenImmersion.isoOfRangeEq ((U.ι ⁻¹ᵁ s).ι ≫ U.ι) s.1.ι
(by simpa only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp, Scheme.Opens.range_ι,
Opens.map_coe, Set.image_preimage_eq_iff, heq, Opens.coe_sSup] using le_sSup s.2)
have heq : (V s).ι ≫ f ≫ U.ι = f' ≫ e.hom ≫ s.1.ι := by
simp only [V, IsOpenImmersion.isoOfRangeEq_hom_fac, f', e, morphismRestrict_ι_assoc]
rw [heq, ← Category.assoc]
refine this _ ?_ ?_
· rwa [P.cancel_right_of_respectsIso]
· obtain ⟨a, ha⟩ := hUs s.2
use a, ha.symm
· apply f.iSup_preimage_eq_top
apply U.ι.image_injective
simp only [U.ι.image_iSup, U.ι.image_preimage_eq_opensRange_inf, Scheme.Opens.opensRange_ι]
conv_rhs => rw [Scheme.Hom.image_top_eq_opensRange, Scheme.Opens.opensRange_ι, heq]
ext : 1
have (i : Us) : U ⊓ i.1 = i.1 := by simp [heq, le_sSup i.property]
simp [this]
obtain ⟨a, rfl⟩ := hYa
wlog hX : IsAffine X generalizing X Y
· rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro V
rw [← Category.assoc]
exact this _ _ (IsZariskiLocalAtSource.comp hf _) V.2
rw [HasRingHomProperty.iff_of_isAffine (P := P)] at hf ⊢
exact hQ _ a _ hf
/-- Any property of scheme morphisms induced by a property of ring homomorphisms is stable
under composition with open immersions. -/
lemma respects_isOpenImmersion (hQ : RingHom.StableUnderCompositionWithLocalizationAwaySource Q) :
P.Respects @IsOpenImmersion where
postcomp {X Y Z} i hi f hf := by
wlog hZ : IsAffine Z generalizing X Y Z
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
rw [morphismRestrict_comp]
exact this _ inferInstance _ (IsZariskiLocalAtTarget.restrict hf _) U.2
let e : Y ≅ i.opensRange.toScheme := IsOpenImmersion.isoOfRangeEq i i.opensRange.ι (by simp)
rw [show f ≫ i = f ≫ e.hom ≫ i.opensRange.ι by simp [e], ← Category.assoc]
exact respects_isOpenImmersion_aux hQ _ (by rwa [P.cancel_right_of_respectsIso])
open RingHom
omit [HasRingHomProperty P Q] in
/-- If `P` is induced by `Locally Q`, it suffices to check `Q` on affine open sets locally around
points of the source. -/
lemma iff_exists_appLE_locally
(hQ : RingHom.StableUnderCompositionWithLocalizationAwaySource Q)
(hQi : RespectsIso Q) [HasRingHomProperty P (Locally Q)] :
P f ↔ ∀ (x : X), ∃ (U : Y.affineOpens) (V : X.affineOpens) (_ : x ∈ V.1) (e : V.1 ≤ f ⁻¹ᵁ U.1),
Q (f.appLE U V e).hom := by
have := respects_isOpenImmersion (P := P)
(RingHom.locally_StableUnderCompositionWithLocalizationAwaySource hQ)
refine ⟨fun hf x ↦ ?_,
fun hf ↦ (IsZariskiLocalAtSource.iff_exists_resLE (P := P)).mpr <| fun x ↦ ?_⟩
· obtain ⟨U, hU, hfx, _⟩ := Opens.isBasis_iff_nbhd.mp Y.isBasis_affineOpens
(Opens.mem_top <| f x)
obtain ⟨V, hV, hx, e⟩ := Opens.isBasis_iff_nbhd.mp X.isBasis_affineOpens
(show x ∈ f ⁻¹ᵁ U from hfx)
simp_rw [HasRingHomProperty.iff_appLE (P := P), locally_iff_isLocalization hQi] at hf
obtain ⟨s, hs, hfs⟩ := hf ⟨U, hU⟩ ⟨V, hV⟩ e
apply iSup_basicOpen_of_span_eq_top at hs
have : x ∈ (⨆ i ∈ s, X.basicOpen i) := hs.symm ▸ hx
have : ∃ r ∈ s, x ∈ X.basicOpen r := by simpa using this
obtain ⟨r, hr, hrs⟩ := this
refine ⟨⟨U, hU⟩, ⟨X.basicOpen r, hV.basicOpen r⟩, hrs, (X.basicOpen_le r).trans e, ?_⟩
rw [← f.appLE_map e (homOfLE (X.basicOpen_le r)).op]
haveI : IsLocalization.Away r Γ(X, X.basicOpen r) := hV.isLocalization_basicOpen r
exact hfs r hr _
· obtain ⟨U, V, hxV, e, hf⟩ := hf x
use U, V, hxV, e
simp only [iff_of_isAffine (P := P), Scheme.Hom.appLE, homOfLE_leOfHom] at hf ⊢
haveI : (toMorphismProperty (Locally Q)).RespectsIso := toMorphismProperty_respectsIso_iff.mp <|
(isLocal_ringHomProperty P).respectsIso
exact (MorphismProperty.arrow_mk_iso_iff (toMorphismProperty (Locally Q))
(arrowResLEAppIso f U V e)).mpr (locally_of hQi _ hf)
/-- `P` can be checked locally around points of the source. -/
lemma iff_exists_appLE
(hQ : StableUnderCompositionWithLocalizationAwaySource Q) : P f ↔
∀ (x : X), ∃ (U : Y.affineOpens) (V : X.affineOpens) (_ : x ∈ V.1) (e : V.1 ≤ f ⁻¹ᵁ U.1),
Q (f.appLE U V e).hom := by
haveI inst : HasRingHomProperty P Q := inferInstance
haveI : HasRingHomProperty P (Locally Q) := by
apply @copy (P := P) (P' := P) (Q := Q) (Q' := Locally Q)
· infer_instance
· rfl
· intro R S _ _ f
exact (locally_iff_of_localizationSpanTarget (isLocal_ringHomProperty P).respectsIso
(isLocal_ringHomProperty P).ofLocalizationSpanTarget _).symm
rw [iff_exists_appLE_locally (P := P) hQ]
haveI : HasRingHomProperty P Q := inst
apply (isLocal_ringHomProperty P (Q := Q)).respectsIso
omit [HasRingHomProperty P Q] in
lemma locally_of_iff (hQl : LocalizationAwayPreserves Q)
(hQa : StableUnderCompositionWithLocalizationAway Q)
(h : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y), P f ↔
∀ (x : X), ∃ (U : Y.affineOpens) (V : X.affineOpens) (_ : x ∈ V.1) (e : V.1 ≤ f ⁻¹ᵁ U.1),
Q (f.appLE U V e).hom) : HasRingHomProperty P (Locally Q) where
isLocal_ringHomProperty := locally_propertyIsLocal hQl hQa
eq_affineLocally' := by
haveI : HasRingHomProperty (affineLocally (Locally Q)) (Locally Q) :=
⟨locally_propertyIsLocal hQl hQa, rfl⟩
ext X Y f
rw [h, iff_exists_appLE_locally (P := affineLocally (Locally Q)) hQa.left hQa.respectsIso]
/-- If `Q` is a property of ring maps that can be checked on prime ideals, the
associated property of scheme morphisms can be checked on stalks. -/
lemma of_stalkMap (hQ : OfLocalizationPrime Q) (H : ∀ x, Q (f.stalkMap x).hom) : P f := by
have hQi := (HasRingHomProperty.isLocal_ringHomProperty P).respectsIso
wlog hY : IsAffine Y generalizing X Y f
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
refine this (fun x ↦ ?_) U.2
exact (hQi.arrow_mk_iso_iff (AlgebraicGeometry.morphismRestrictStalkMap f U x)).mpr (H x.val)
wlog hX : IsAffine X generalizing X f
· rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
refine this ?_ U.2
intro x
rw [Scheme.Hom.stalkMap_comp, CommRingCat.hom_comp, hQi.cancel_right_isIso]
exact H x.val
wlog hXY : ∃ R S, Y = Spec R ∧ X = Spec S generalizing X Y
· rw [← P.cancel_right_of_respectsIso (g := Y.isoSpec.hom)]
rw [← P.cancel_left_of_respectsIso (f := X.isoSpec.inv)]
refine this inferInstance (fun x ↦ ?_) inferInstance ?_
· rw [Scheme.Hom.stalkMap_comp, Scheme.Hom.stalkMap_comp, CommRingCat.hom_comp,
hQi.cancel_right_isIso, CommRingCat.hom_comp, hQi.cancel_left_isIso]
apply H
· use Γ(Y, ⊤), Γ(X, ⊤)
obtain ⟨R, S, rfl, rfl⟩ := hXY
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [Spec_iff (P := P)]
apply hQ
intro P hP
specialize H ⟨P, hP⟩
rwa [hQi.arrow_mk_iso_iff (Scheme.arrowStalkMapSpecIso φ _)] at H
/-- Let `Q` be a property of ring maps that is stable under localization.
Then if the associated property of scheme morphisms holds for `f`, `Q` holds on all stalks. -/
lemma stalkMap
(hQ : ∀ {R S : Type u} [CommRing R] [CommRing S] (f : R →+* S) (_ : Q f)
(J : Ideal S) (_ : J.IsPrime), Q (Localization.localRingHom _ J f rfl))
(hf : P f) (x : X) : Q (f.stalkMap x).hom := by
have hQi := (HasRingHomProperty.isLocal_ringHomProperty P).respectsIso
wlog h : IsAffine X ∧ IsAffine Y generalizing X Y f
· obtain ⟨U, hU, hfx, _⟩ := Opens.isBasis_iff_nbhd.mp Y.isBasis_affineOpens
(Opens.mem_top <| f x)
obtain ⟨V, hV, hx, e⟩ := Opens.isBasis_iff_nbhd.mp X.isBasis_affineOpens
(show x ∈ f ⁻¹ᵁ U from hfx)
rw [← hQi.arrow_mk_iso_iff (Scheme.Hom.resLEStalkMap f e ⟨x, hx⟩)]
exact this (IsZariskiLocalAtSource.resLE _ hf) _ ⟨hV, hU⟩
obtain ⟨hX, hY⟩ := h
wlog hXY : ∃ R S, Y = Spec R ∧ X = Spec S generalizing X Y
· have : Q ((X.isoSpec.inv ≫ f ≫ Y.isoSpec.hom).stalkMap (X.isoSpec.hom x)).hom := by
refine this ?_ (X.isoSpec.hom x) inferInstance inferInstance ?_
· rwa [P.cancel_left_of_respectsIso, P.cancel_right_of_respectsIso]
· use Γ(Y, ⊤), Γ(X, ⊤)
rw [Scheme.Hom.stalkMap_comp, Scheme.Hom.stalkMap_comp, CommRingCat.hom_comp,
hQi.cancel_right_isIso, CommRingCat.hom_comp, hQi.cancel_left_isIso] at this
have heq : (X.isoSpec.inv (X.isoSpec.hom x)) = x := by simp
rwa [hQi.arrow_mk_iso_iff (f.arrowStalkMapIsoOfEq heq)] at this
obtain ⟨R, S, rfl, rfl⟩ := hXY
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [hQi.arrow_mk_iso_iff (Scheme.arrowStalkMapSpecIso φ _)]
rw [Spec_iff (P := P)] at hf
apply hQ _ hf
end HasRingHomProperty
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean | import Mathlib.AlgebraicGeometry.Morphisms.Basic
import Mathlib.RingTheory.RingHomProperties
/-!
# Constructors for properties of morphisms between schemes
This file provides some constructors to obtain morphism properties of schemes from other morphism
properties:
- `AffineTargetMorphismProperty.diagonal` : Given an affine target morphism property `P`,
`P.diagonal f` holds if `P (pullback.mapDesc f₁ f₂ f)` holds for two affine open
immersions `f₁` and `f₂`.
- `AffineTargetMorphismProperty.of`: Given a morphism property `P` of schemes,
this is the restriction of `P` to morphisms with affine target. If `P` is local at the
target, we have `(toAffineTargetMorphismProperty P).targetAffineLocally = P`, see:
`MorphismProperty.targetAffineLocally_toAffineTargetMorphismProperty_eq_of_isZariskiLocalAtTarget`
- `MorphismProperty.topologically`: Given a property `P` of maps of topological spaces,
`(topologically P) f` holds if `P` holds for the underlying continuous map of `f`.
- `MorphismProperty.stalkwise`: Given a property `P` of ring homomorphisms,
`(stalkwise P) f` holds if `P` holds for all stalk maps.
Also provides API for showing the standard locality and stability properties for these
types of properties.
-/
universe u v w
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
section Diagonal
/-- The `AffineTargetMorphismProperty` associated to `(targetAffineLocally P).diagonal`.
See `diagonal_targetAffineLocally_eq_targetAffineLocally`.
-/
def AffineTargetMorphismProperty.diagonal (P : AffineTargetMorphismProperty) :
AffineTargetMorphismProperty :=
fun {X _} f _ =>
∀ ⦃U₁ U₂ : Scheme⦄ (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [IsAffine U₁] [IsAffine U₂] [IsOpenImmersion f₁]
[IsOpenImmersion f₂], P (pullback.mapDesc f₁ f₂ f)
instance AffineTargetMorphismProperty.diagonal_respectsIso (P : AffineTargetMorphismProperty)
[P.toProperty.RespectsIso] : P.diagonal.toProperty.RespectsIso := by
delta AffineTargetMorphismProperty.diagonal
apply AffineTargetMorphismProperty.respectsIso_mk
· introv H _ _
rw [pullback.mapDesc_comp, P.cancel_left_of_respectsIso, P.cancel_right_of_respectsIso]
apply H
· introv H _ _
rw [pullback.mapDesc_comp, P.cancel_right_of_respectsIso]
apply H
theorem HasAffineProperty.diagonal_of_openCover (P) {Q} [HasAffineProperty P Q]
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{v} Y) [∀ i, IsAffine (𝒰.X i)]
(𝒰' : ∀ i, Scheme.OpenCover.{w} (pullback f (𝒰.f i))) [∀ i j, IsAffine ((𝒰' i).X j)]
(h𝒰' : ∀ i j k,
Q (pullback.mapDesc ((𝒰' i).f j) ((𝒰' i).f k) (𝒰.pullbackHom f i))) :
P.diagonal f := by
letI := isLocal_affineProperty P
let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) (pullback.snd _ _) (pullback.snd _ _)
have i1 : ∀ i, IsAffine (𝒱.X i) := fun i => by dsimp [𝒱]; infer_instance
apply of_openCover 𝒱
rintro ⟨i, j, k⟩
dsimp [𝒱]
convert (Q.cancel_left_of_respectsIso
((pullbackDiagonalMapIso _ _ ((𝒰' i).f j) ((𝒰' i).f k)).inv ≫
pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _) (pullback.snd _ _)).mp _ using 1
· simp
· ext1 <;> simp
· simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
Category.comp_id]
convert h𝒰' i j k
ext1 <;> simp [Scheme.Cover.pullbackHom]
theorem HasAffineProperty.diagonal_of_openCover_diagonal
(P) {Q} [HasAffineProperty P Q]
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover Y) [∀ i, IsAffine (𝒰.X i)]
(h𝒰 : ∀ i, Q.diagonal (𝒰.pullbackHom f i)) :
P.diagonal f :=
diagonal_of_openCover P f 𝒰 (fun _ ↦ Scheme.affineCover _)
(fun _ _ _ ↦ h𝒰 _ _ _)
theorem HasAffineProperty.diagonal_of_diagonal_of_isPullback
(P) {Q} [HasAffineProperty P Q]
{X Y U V : Scheme.{u}} {f : X ⟶ Y} {g : U ⟶ Y}
[IsAffine U] [IsOpenImmersion g]
{iV : V ⟶ X} {f' : V ⟶ U} (h : IsPullback iV f' f g) (H : P.diagonal f) :
Q.diagonal f' := by
letI := isLocal_affineProperty P
rw [← Q.diagonal.cancel_left_of_respectsIso h.isoPullback.inv,
h.isoPullback_inv_snd]
rintro U V f₁ f₂ hU hV hf₁ hf₂
rw [← Q.cancel_left_of_respectsIso (pullbackDiagonalMapIso f _ f₁ f₂).hom]
convert HasAffineProperty.of_isPullback (P := P) (.of_hasPullback _ _) H
· apply pullback.hom_ext <;> simp
· infer_instance
· infer_instance
theorem HasAffineProperty.diagonal_iff
(P) {Q} [HasAffineProperty P Q] {X Y : Scheme.{u}} {f : X ⟶ Y} [IsAffine Y] :
Q.diagonal f ↔ P.diagonal f := by
letI := isLocal_affineProperty P
refine ⟨fun hf ↦ ?_, diagonal_of_diagonal_of_isPullback P .of_id_fst⟩
rw [← Q.diagonal.cancel_left_of_respectsIso
(pullback.fst (f := f) (g := 𝟙 Y)), pullback.condition, Category.comp_id] at hf
let 𝒰 := X.affineCover.pushforwardIso (inv (pullback.fst (f := f) (g := 𝟙 Y)))
have (i : _) : IsAffine (𝒰.X i) := by dsimp [𝒰]; infer_instance
exact HasAffineProperty.diagonal_of_openCover.{u, u, u} P f (Scheme.coverOfIsIso (𝟙 _))
(fun _ ↦ 𝒰) (fun _ _ _ ↦ hf _ _)
theorem AffineTargetMorphismProperty.diagonal_of_openCover_source
{Q : AffineTargetMorphismProperty} [Q.IsLocal]
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{v} X) [∀ i, IsAffine (𝒰.X i)]
[IsAffine Y] (h𝒰 : ∀ i j, Q (pullback.mapDesc (𝒰.f i) (𝒰.f j) f)) :
Q.diagonal f := by
rw [HasAffineProperty.diagonal_iff (targetAffineLocally Q)]
let 𝒱 := Scheme.Pullback.openCoverOfLeftRight.{u} 𝒰 𝒰 f f
have i1 : ∀ i, IsAffine (𝒱.X i) := fun i => by dsimp [𝒱]; infer_instance
refine HasAffineProperty.of_openCover (P := targetAffineLocally Q) 𝒱 fun i ↦ ?_
dsimp [𝒱, Scheme.Cover.pullbackHom]
have : IsPullback (pullback.fst _ _ ≫ 𝒰.f _) (pullback.mapDesc (𝒰.f i.1) (𝒰.f i.2) f)
(pullback.diagonal f) (pullback.map _ _ _ _ (𝒰.f _) (𝒰.f _) (𝟙 Y) (by simp) (by simp)) :=
.of_iso (pullback_fst_map_snd_isPullback f (𝟙 _) (𝒰.f i.1 ≫ pullback.lift (𝟙 _) f)
(𝒰.f i.2 ≫ pullback.lift (𝟙 _) f)) (asIso (pullback.map _ _ _ _ (𝟙 _) (𝟙 _)
(pullback.fst _ _) (by simp) (by simp))) (.refl _) (pullback.congrHom (by simp) (by simp))
(.refl _) (by simp) (by cat_disch) (by simp) (by cat_disch)
rw [← Q.cancel_left_of_respectsIso this.isoPullback.hom, IsPullback.isoPullback_hom_snd]
exact h𝒰 _ _
instance HasAffineProperty.diagonal_affineProperty_isLocal
{Q : AffineTargetMorphismProperty} [Q.IsLocal] :
Q.diagonal.IsLocal where
respectsIso := inferInstance
to_basicOpen {_ Y} _ f r hf :=
diagonal_of_diagonal_of_isPullback (targetAffineLocally Q)
(isPullback_morphismRestrict f (Y.basicOpen r)).flip
((diagonal_iff (targetAffineLocally Q)).mp hf)
of_basicOpenCover {X Y} _ f s hs hs' := by
refine (diagonal_iff (targetAffineLocally Q)).mpr ?_
let 𝒰 := Y.openCoverOfIsOpenCover _
((isAffineOpen_top Y).iSup_basicOpen_eq_self_iff.mpr hs)
have (i : _) : IsAffine (𝒰.X i) := (isAffineOpen_top Y).basicOpen i.1
refine diagonal_of_openCover_diagonal (targetAffineLocally Q) f 𝒰 ?_
intro i
exact (Q.diagonal.arrow_mk_iso_iff
(morphismRestrictEq _ (by simp [𝒰]) ≪≫ morphismRestrictOpensRange _ _)).mp (hs' i)
instance (P) {Q} [HasAffineProperty P Q] : HasAffineProperty P.diagonal Q.diagonal where
isLocal_affineProperty := letI := HasAffineProperty.isLocal_affineProperty P; inferInstance
eq_targetAffineLocally' := by
ext X Y f
letI := HasAffineProperty.isLocal_affineProperty P
constructor
· exact fun H U ↦ HasAffineProperty.diagonal_of_diagonal_of_isPullback P
(isPullback_morphismRestrict f U).flip H
· exact fun H ↦ HasAffineProperty.diagonal_of_openCover_diagonal P f Y.affineCover
(fun i ↦ of_targetAffineLocally_of_isPullback (.of_hasPullback _ _) H)
instance (P) [IsZariskiLocalAtTarget P] : IsZariskiLocalAtTarget P.diagonal :=
letI := HasAffineProperty.of_isZariskiLocalAtTarget P
inferInstance
open MorphismProperty in
instance (P : MorphismProperty Scheme)
[P.HasOfPostcompProperty @IsOpenImmersion] [P.RespectsRight @IsOpenImmersion]
[IsZariskiLocalAtSource P] : IsZariskiLocalAtSource P.diagonal := by
let g {X Y : Scheme} (f : X ⟶ Y) (U : X.Opens) :=
pullback.map (U.ι ≫ f) (U.ι ≫ f) f f U.ι U.ι (𝟙 Y) (by simp) (by simp)
refine IsZariskiLocalAtSource.mk' (fun {X Y} f U hf ↦ ?_) (fun {X Y} f {ι} U hU hf ↦ ?_)
· change P _
apply P.of_postcomp (W' := @IsOpenImmersion) (pullback.diagonal (U.ι ≫ f)) (g f U) inferInstance
rw [← pullback.comp_diagonal]
apply IsZariskiLocalAtSource.comp
exact hf
· change P _
refine IsZariskiLocalAtSource.of_iSup_eq_top U hU fun i ↦ ?_
rw [pullback.comp_diagonal]
exact RespectsRight.postcomp (P := P) (Q := @IsOpenImmersion) (g _ _) inferInstance _ (hf i)
end Diagonal
section Universally
theorem universally_isZariskiLocalAtTarget (P : MorphismProperty Scheme)
(hP₂ : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Y.Opens)
(_ : IsOpenCover U), (∀ i, P (f ∣_ U i)) → P f) : IsZariskiLocalAtTarget P.universally := by
apply IsZariskiLocalAtTarget.mk'
· exact fun {X Y} f U => P.universally.of_isPullback
(isPullback_morphismRestrict f U).flip
· intro X Y f ι U hU H X' Y' i₁ i₂ f' h
apply hP₂ _ (fun i ↦ i₂ ⁻¹ᵁ U i)
· simp only [IsOpenCover, ← top_le_iff] at hU ⊢
rintro x -
simpa using @hU (i₂ x) trivial
· rintro i
refine H _ ((X'.isoOfEq ?_).hom ≫ i₁ ∣_ _) (i₂ ∣_ _) _ ?_
· exact congr($(h.1.1) ⁻¹ᵁ U i)
· rw [← (isPullback_morphismRestrict f _).paste_vert_iff]
· simp only [Category.assoc, morphismRestrict_ι, Scheme.isoOfEq_hom_ι_assoc]
exact (isPullback_morphismRestrict f' (i₂ ⁻¹ᵁ U i)).paste_vert h
· rw [← cancel_mono (Scheme.Opens.ι _)]
simp [morphismRestrict_ι_assoc, h.1.1]
@[deprecated (since := "2025-10-07")]
alias universally_isLocalAtTarget := universally_isZariskiLocalAtTarget
lemma universally_isZariskiLocalAtSource (P : MorphismProperty Scheme)
[IsZariskiLocalAtSource P] : IsZariskiLocalAtSource P.universally := by
refine .mk_of_iff ?_
intro X Y f 𝒰
refine ⟨fun hf i ↦ ?_, fun hf ↦ ?_⟩
· apply MorphismProperty.universally_mk'
intro T g _
rw [← P.cancel_left_of_respectsIso (pullbackLeftPullbackSndIso g f _).hom,
pullbackLeftPullbackSndIso_hom_fst]
exact IsZariskiLocalAtSource.comp (hf _ _ _ (IsPullback.of_hasPullback ..)) _
· apply MorphismProperty.universally_mk'
intro T g _
rw [IsZariskiLocalAtSource.iff_of_openCover (P := P) (𝒰.pullback₁ <| pullback.snd g f)]
intro i
dsimp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover,
PreZeroHypercover.pullback₁_X, PreZeroHypercover.pullback₁_f]
rw [← pullbackLeftPullbackSndIso_hom_fst, P.cancel_left_of_respectsIso]
exact hf i _ _ _ (IsPullback.of_hasPullback ..)
@[deprecated (since := "2025-10-07")]
alias universally_isLocalAtSource := universally_isZariskiLocalAtSource
end Universally
section Topologically
/-- `topologically P` holds for a morphism if the underlying topological map satisfies `P`. -/
def topologically
(P : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (_ : α → β), Prop) :
MorphismProperty Scheme.{u} := fun _ _ f => P f
variable (P : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (_ : α → β), Prop)
/-- If a property of maps of topological spaces is stable under composition, the induced
morphism property of schemes is stable under composition. -/
lemma topologically_isStableUnderComposition
(hP : ∀ {α β γ : Type u} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
(f : α → β) (g : β → γ) (_ : P f) (_ : P g), P (g ∘ f)) :
(topologically P).IsStableUnderComposition where
comp_mem {X Y Z} f g hf hg := by
simp only [topologically, Scheme.Hom.comp_base, TopCat.coe_comp]
exact hP _ _ hf hg
/-- If a property of maps of topological spaces is satisfied by all homeomorphisms,
every isomorphism of schemes satisfies the induced property. -/
lemma topologically_iso_le
(hP : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α ≃ₜ β), P f) :
MorphismProperty.isomorphisms Scheme ≤ (topologically P) := by
intro X Y e (he : IsIso e)
have : IsIso e := he
exact hP (TopCat.homeoOfIso (asIso e.base))
/-- If a property of maps of topological spaces is satisfied by homeomorphisms and is stable
under composition, the induced property on schemes respects isomorphisms. -/
lemma topologically_respectsIso
(hP₁ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α ≃ₜ β), P f)
(hP₂ : ∀ {α β γ : Type u} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
(f : α → β) (g : β → γ) (_ : P f) (_ : P g), P (g ∘ f)) :
(topologically P).RespectsIso :=
have : (topologically P).IsStableUnderComposition :=
topologically_isStableUnderComposition P hP₂
MorphismProperty.respectsIso_of_isStableUnderComposition (topologically_iso_le P hP₁)
/-- To check that a topologically defined morphism property is local at the target,
we may check the corresponding properties on topological spaces. -/
lemma topologically_isZariskiLocalAtTarget [(topologically P).RespectsIso]
(hP₂ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β) (s : Set β)
(_ : Continuous f) (_ : IsOpen s), P f → P (s.restrictPreimage f))
(hP₃ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β) {ι : Type u}
(U : ι → Opens β) (_ : IsOpenCover U) (_ : Continuous f),
(∀ i, P ((U i).carrier.restrictPreimage f)) → P f) :
IsZariskiLocalAtTarget (topologically P) := by
apply IsZariskiLocalAtTarget.mk'
· intro X Y f U hf
simp_rw [topologically, morphismRestrict_base]
exact hP₂ f U.carrier f.continuous U.2 hf
· intro X Y f ι U hU hf
apply hP₃ f U hU f.continuous fun i ↦ ?_
rw [← morphismRestrict_base]
exact hf i
@[deprecated (since := "2025-10-07")]
alias topologically_isLocalAtTarget := topologically_isZariskiLocalAtTarget
/-- A variant of `topologically_isZariskiLocalAtTarget`
that takes one iff statement instead of two implications. -/
lemma topologically_isZariskiLocalAtTarget' [(topologically P).RespectsIso]
(hP : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β) {ι : Type u}
(U : ι → Opens β) (_ : IsOpenCover U) (_ : Continuous f),
P f ↔ (∀ i, P ((U i).carrier.restrictPreimage f))) :
IsZariskiLocalAtTarget (topologically P) := by
refine topologically_isZariskiLocalAtTarget P ?_ (fun f _ U hU hU' ↦ (hP f U hU hU').mpr)
introv hf hs H
refine (hP f (![⊤, Opens.mk s hs] ∘ Equiv.ulift) ?_ hf).mp H ⟨1⟩
rw [IsOpenCover, ← top_le_iff]
exact le_iSup (![⊤, Opens.mk s hs] ∘ Equiv.ulift) ⟨0⟩
@[deprecated (since := "2025-10-07")]
alias topologically_isLocalAtTarget' := topologically_isZariskiLocalAtTarget'
lemma topologically_isZariskiLocalAtSource [(topologically P).RespectsIso]
(hP₁ : ∀ {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] (f : X → Y)
(_ : Continuous f) (U : Opens X), P f → P (f ∘ ((↑) : U → X)))
(hP₂ : ∀ {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] (f : X → Y)
(_ : Continuous f) {ι : Type u} (U : ι → Opens X),
IsOpenCover U → (∀ i, P (f ∘ ((↑) : U i → X))) → P f) :
IsZariskiLocalAtSource (topologically P) := by
apply IsZariskiLocalAtSource.mk'
· introv hf
exact hP₁ f f.continuous _ hf
· introv hU hf
exact hP₂ f f.continuous _ hU hf
@[deprecated (since := "2025-10-07")]
alias topologically_isLocalAtSource := topologically_isZariskiLocalAtSource
/-- A variant of `topologically_isZariskiLocalAtSource`
that takes one iff statement instead of two implications. -/
lemma topologically_isZariskiLocalAtSource' [(topologically P).RespectsIso]
(hP : ∀ {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] (f : X → Y) {ι : Type u}
(U : ι → Opens X) (_ : IsOpenCover U) (_ : Continuous f),
P f ↔ (∀ i, P (f ∘ ((↑) : U i → X)))) :
IsZariskiLocalAtSource (topologically P) := by
refine topologically_isZariskiLocalAtSource P ?_ (fun f hf _ U hU hf' ↦ (hP f U hU hf).mpr hf')
introv hf hs
refine (hP f (![⊤, U] ∘ Equiv.ulift) ?_ hf).mp hs ⟨1⟩
rw [IsOpenCover, ← top_le_iff]
exact le_iSup (![⊤, U] ∘ Equiv.ulift) ⟨0⟩
@[deprecated (since := "2025-10-07")]
alias topologically_isLocalAtSource' := topologically_isZariskiLocalAtSource'
end Topologically
/-- `stalkwise P` holds for a morphism if all stalks satisfy `P`. -/
def stalkwise (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop) :
MorphismProperty Scheme.{u} :=
fun _ _ f => ∀ x, P (f.stalkMap x).hom
section Stalkwise
variable {P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
/-- If `P` respects isos, then `stalkwise P` respects isos. -/
lemma stalkwise_respectsIso (hP : RingHom.RespectsIso P) :
(stalkwise P).RespectsIso where
precomp {X Y Z} e (he : IsIso e) f hf := by
simp only [stalkwise, Scheme.Hom.comp_base, TopCat.coe_comp, Function.comp_apply]
intro x
rw [Scheme.Hom.stalkMap_comp]
exact (RingHom.RespectsIso.cancel_right_isIso hP _ _).mpr <| hf (e x)
postcomp {X Y Z} e (he : IsIso _) f hf := by
simp only [stalkwise, Scheme.Hom.comp_base, TopCat.coe_comp, Function.comp_apply]
intro x
rw [Scheme.Hom.stalkMap_comp]
exact (RingHom.RespectsIso.cancel_left_isIso hP _ _).mpr <| hf x
/-- If `P` respects isos, then `stalkwise P` is local at the target. -/
lemma stalkwiseIsZariskiLocalAtTarget_of_respectsIso (hP : RingHom.RespectsIso P) :
IsZariskiLocalAtTarget (stalkwise P) := by
have hP' : (RingHom.toMorphismProperty P).RespectsIso :=
RingHom.toMorphismProperty_respectsIso_iff.mp hP
letI := stalkwise_respectsIso hP
apply IsZariskiLocalAtTarget.mk'
· intro X Y f U hf x
apply ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
morphismRestrictStalkMap f U x).mpr <| hf _
· intro X Y f ι U hU hf x
have hy : f x ∈ iSup U := by rw [hU]; trivial
obtain ⟨i, hi⟩ := Opens.mem_iSup.mp hy
exact ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
morphismRestrictStalkMap f (U i) ⟨x, hi⟩).mp <| hf i ⟨x, hi⟩
@[deprecated (since := "2025-10-07")]
alias stalkwiseIsLocalAtTarget_of_respectsIso := stalkwiseIsZariskiLocalAtTarget_of_respectsIso
/-- If `P` respects isos, then `stalkwise P` is local at the source. -/
lemma stalkwise_isZariskiLocalAtSource_of_respectsIso (hP : RingHom.RespectsIso P) :
IsZariskiLocalAtSource (stalkwise P) := by
letI := stalkwise_respectsIso hP
apply IsZariskiLocalAtSource.mk'
· intro X Y f U hf x
rw [Scheme.Hom.stalkMap_comp, CommRingCat.hom_comp, hP.cancel_right_isIso]
exact hf _
· intro X Y f ι U hU hf x
have hy : x ∈ iSup U := by rw [hU]; trivial
obtain ⟨i, hi⟩ := Opens.mem_iSup.mp hy
rw [← hP.cancel_right_isIso _ ((U i).ι.stalkMap ⟨x, hi⟩)]
simpa [Scheme.Hom.stalkMap_comp] using hf i ⟨x, hi⟩
@[deprecated (since := "2025-10-07")]
alias stalkwise_isLocalAtSource_of_respectsIso := stalkwise_isZariskiLocalAtSource_of_respectsIso
lemma stalkwise_SpecMap_iff (hP : RingHom.RespectsIso P) {R S : CommRingCat} (φ : R ⟶ S) :
stalkwise P (Spec.map φ) ↔ ∀ (p : Ideal S) (_ : p.IsPrime),
P (Localization.localRingHom _ p φ.hom rfl) := by
have hP' : (RingHom.toMorphismProperty P).RespectsIso :=
RingHom.toMorphismProperty_respectsIso_iff.mp hP
trans ∀ (p : PrimeSpectrum S), P (Localization.localRingHom _ p.asIdeal φ.hom rfl)
· exact forall_congr' fun p ↦
(RingHom.toMorphismProperty P).arrow_mk_iso_iff (Scheme.arrowStalkMapSpecIso _ _)
· exact ⟨fun H p hp ↦ H ⟨p, hp⟩, fun H p ↦ H p.1 p.2⟩
@[deprecated (since := "2025-10-07")] alias stalkwise_Spec_map_iff := stalkwise_SpecMap_iff
end Stalkwise
namespace AffineTargetMorphismProperty
/-- If `P` is local at the target, to show that `P` is stable under base change, it suffices to
check this for base change along a morphism of affine schemes. -/
lemma isStableUnderBaseChange_of_isStableUnderBaseChangeOnAffine_of_isZariskiLocalAtTarget
(P : MorphismProperty Scheme) [IsZariskiLocalAtTarget P]
(hP₂ : (of P).IsStableUnderBaseChange) :
P.IsStableUnderBaseChange :=
letI := HasAffineProperty.of_isZariskiLocalAtTarget P
HasAffineProperty.isStableUnderBaseChange hP₂
end AffineTargetMorphismProperty
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean | import Mathlib.AlgebraicGeometry.Morphisms.FiniteType
import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.AlgebraicGeometry.Properties
import Mathlib.RingTheory.RingHom.FinitePresentation
import Mathlib.RingTheory.Spectrum.Prime.Chevalley
/-!
# Morphisms of finite presentation
A morphism of schemes `f : X ⟶ Y` is locally of finite presentation if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite presentation.
A morphism of schemes is of finite presentation if it is both locally of finite presentation and
quasi-compact. We do not provide a separate declaration for this, instead simply assume both
conditions.
We show that these properties are local, and are stable under compositions.
-/
noncomputable section
open CategoryTheory Topology
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is locally of finite presentation if for each affine `U ⊆ Y`
and `V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite presentation. -/
@[mk_iff]
class LocallyOfFinitePresentation : Prop where
finitePresentation_of_affine_subset :
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1),
(f.appLE U V e).hom.FinitePresentation
instance : HasRingHomProperty @LocallyOfFinitePresentation RingHom.FinitePresentation where
isLocal_ringHomProperty := RingHom.finitePresentation_isLocal
eq_affineLocally' := by
ext X Y f
rw [locallyOfFinitePresentation_iff, affineLocally_iff_affineOpens_le]
instance (priority := 900) locallyOfFinitePresentation_of_isOpenImmersion [IsOpenImmersion f] :
LocallyOfFinitePresentation f :=
HasRingHomProperty.of_isOpenImmersion
RingHom.finitePresentation_holdsForLocalizationAway.containsIdentities
instance : MorphismProperty.IsStableUnderComposition @LocallyOfFinitePresentation :=
HasRingHomProperty.stableUnderComposition RingHom.finitePresentation_stableUnderComposition
instance locallyOfFinitePresentation_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : LocallyOfFinitePresentation f] [hg : LocallyOfFinitePresentation g] :
LocallyOfFinitePresentation (f ≫ g) :=
MorphismProperty.comp_mem _ f g hf hg
instance locallyOfFinitePresentation_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @LocallyOfFinitePresentation :=
HasRingHomProperty.isStableUnderBaseChange RingHom.finitePresentation_isStableUnderBaseChange
instance {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) [LocallyOfFinitePresentation g] :
LocallyOfFinitePresentation (Limits.pullback.fst f g) :=
MorphismProperty.pullback_fst _ _ inferInstance
instance {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) [LocallyOfFinitePresentation f] :
LocallyOfFinitePresentation (Limits.pullback.snd f g) :=
MorphismProperty.pullback_snd _ _ inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [LocallyOfFinitePresentation f] :
LocallyOfFinitePresentation (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [LocallyOfFinitePresentation f] :
LocallyOfFinitePresentation (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
instance {X Y : Scheme.{u}} (f : X ⟶ Y) [hf : LocallyOfFinitePresentation f] :
LocallyOfFiniteType f := by
rw [HasRingHomProperty.eq_affineLocally @LocallyOfFinitePresentation] at hf
rw [HasRingHomProperty.eq_affineLocally @LocallyOfFiniteType]
refine affineLocally_le (fun hf ↦ ?_) f hf
exact RingHom.FiniteType.of_finitePresentation hf
/-- **Chevalley's Theorem**: The image of a locally constructible set under a
morphism of finite presentation is locally constructible. -/
@[stacks 054K]
-- `nonrec` is needed for `wlog`
nonrec lemma Scheme.Hom.isLocallyConstructible_image (f : X ⟶ Y)
[hf : LocallyOfFinitePresentation f] [QuasiCompact f]
{s : Set X} (hs : IsLocallyConstructible s) :
IsLocallyConstructible (f '' s) := by
wlog hY : ∃ R, Y = Spec R
· refine .of_isOpenCover Y.affineCover.isOpenCover_opensRange fun i ↦ ?_
have inst : LocallyOfFinitePresentation (Y.affineCover.pullbackHom f i) :=
MorphismProperty.pullback_snd _ _ inferInstance
have inst : QuasiCompact (Y.affineCover.pullbackHom f i) :=
MorphismProperty.pullback_snd _ _ inferInstance
convert (this (Y.affineCover.pullbackHom f i) (hs.preimage_of_isOpenEmbedding
((Y.affineCover.pullback₁ f).f i).isOpenEmbedding)
⟨_, rfl⟩).preimage_of_isOpenEmbedding (Y.affineCover.f i).isoOpensRange.inv.isOpenEmbedding
refine .trans ?_
((Scheme.homeoOfIso (Y.affineCover.f i).isoOpensRange).image_eq_preimage_symm _)
apply Set.image_injective.mpr Subtype.val_injective
rw [Set.image_preimage_eq_inter_range, ← Set.image_comp, ← Set.image_comp,
Subtype.range_coe_subtype, Set.setOf_mem_eq]
change _ = (Y.affineCover.pullbackHom f i ≫
(Y.affineCover.f i).isoOpensRange.hom ≫ Opens.ι _).base.hom '' _
rw [Scheme.Hom.isoOpensRange_hom_ι, Cover.pullbackHom_map, Scheme.Hom.comp_base,
TopCat.hom_comp, ContinuousMap.coe_comp, Set.image_comp, Set.image_preimage_eq_inter_range]
simp [IsOpenImmersion.range_pullbackFst, Set.image_inter_preimage]
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S
· have inst : CompactSpace X := HasAffineProperty.iff_of_isAffine.mp ‹QuasiCompact f›
let 𝒰 := X.affineCover.finiteSubcover
rw [← 𝒰.isOpenCover_opensRange.iUnion_inter s, Set.image_iUnion]
refine .iUnion fun i ↦ ?_
have inst : QuasiCompact (𝒰.f i ≫ f) :=
HasAffineProperty.iff_of_isAffine.mpr (inferInstanceAs (CompactSpace (Spec _)))
convert this (hs.preimage_of_isOpenEmbedding (𝒰.f i).isOpenEmbedding) _
(𝒰.f i ≫ f) ⟨_, rfl⟩
rw [Scheme.Hom.comp_base, ← TopCat.Hom.hom, ← TopCat.Hom.hom, TopCat.hom_comp,
ContinuousMap.coe_comp, Set.image_comp, Set.image_preimage_eq_inter_range, coe_opensRange]
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [HasRingHomProperty.Spec_iff (P := @LocallyOfFinitePresentation)] at hf
exact (PrimeSpectrum.isConstructible_comap_image hf hs.isConstructible).isLocallyConstructible
/-- **Chevalley's Theorem**: The image of a constructible set under a
morphism of finite presentation into a qcqs scheme is constructible. -/
@[stacks 054J]
lemma Scheme.Hom.isConstructible_image (f : X ⟶ Y)
[LocallyOfFinitePresentation f] [QuasiCompact f] [CompactSpace Y] [QuasiSeparatedSpace Y]
{s : Set X} (hs : IsConstructible s) :
IsConstructible (f '' s) :=
(f.isLocallyConstructible_image hs.isLocallyConstructible).isConstructible
@[stacks 054I]
lemma Scheme.Hom.isConstructible_preimage (f : X ⟶ Y) {s : Set Y} (hs : IsConstructible s) :
IsConstructible (f ⁻¹' s) :=
hs.preimage f.continuous fun t ht ht' ↦ IsRetrocompact_iff_isSpectralMap_subtypeVal.mpr
(quasiCompact_iff_isSpectralMap.mp
(MorphismProperty.of_isPullback (P := @QuasiCompact)
(isPullback_morphismRestrict f ⟨t, ht⟩)
(quasiCompact_iff_isSpectralMap.mpr (IsRetrocompact_iff_isSpectralMap_subtypeVal.mp ht'))))
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Preimmersion.lean | import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
import Mathlib.AlgebraicGeometry.Morphisms.SurjectiveOnStalks
/-!
# Preimmersions of schemes
A morphism of schemes `f : X ⟶ Y` is a preimmersion if the underlying map of topological spaces
is an embedding and the induced morphisms of stalks are all surjective. This is not a concept seen
in the literature but it is useful for generalizing results on immersions to other maps including
`Spec 𝒪_{X, x} ⟶ X` and inclusions of fibers `κ(x) ×ₓ Y ⟶ Y`.
-/
universe v u
open CategoryTheory Topology
namespace AlgebraicGeometry
/-- A morphism of schemes `f : X ⟶ Y` is a preimmersion if the underlying map of
topological spaces is an embedding and the induced morphisms of stalks are all surjective. -/
@[mk_iff]
class IsPreimmersion {X Y : Scheme} (f : X ⟶ Y) : Prop extends SurjectiveOnStalks f where
base_embedding : IsEmbedding f
lemma Scheme.Hom.isEmbedding {X Y : Scheme} (f : X ⟶ Y) [IsPreimmersion f] : IsEmbedding f :=
IsPreimmersion.base_embedding
lemma isPreimmersion_eq_inf :
@IsPreimmersion = (@SurjectiveOnStalks ⊓ topologically IsEmbedding : MorphismProperty _) := by
ext
rw [isPreimmersion_iff]
rfl
namespace IsPreimmersion
instance : IsZariskiLocalAtTarget @IsPreimmersion :=
isPreimmersion_eq_inf ▸ inferInstance
instance (priority := 900) {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f] : IsPreimmersion f where
base_embedding := f.isOpenEmbedding.isEmbedding
surj_on_stalks _ := (ConcreteCategory.bijective_of_isIso _).2
instance : MorphismProperty.IsMultiplicative @IsPreimmersion where
id_mem _ := inferInstance
comp_mem f g _ _ := ⟨g.isEmbedding.comp f.isEmbedding⟩
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion f]
[IsPreimmersion g] : IsPreimmersion (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
instance (priority := 900) {X Y} (f : X ⟶ Y) [IsPreimmersion f] : Mono f :=
SurjectiveOnStalks.mono_of_injective f.isEmbedding.injective
theorem of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion g]
[IsPreimmersion (f ≫ g)] : IsPreimmersion f where
base_embedding := by
have h := (f ≫ g).isEmbedding
rwa [← g.isEmbedding.of_comp_iff]
surj_on_stalks x := by
have h := (f ≫ g).stalkMap_surjective x
rw [Scheme.Hom.stalkMap_comp] at h
exact Function.Surjective.of_comp h
theorem comp_iff {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion g] :
IsPreimmersion (f ≫ g) ↔ IsPreimmersion f :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
lemma SpecMap_iff {R S : CommRingCat.{u}} (f : R ⟶ S) :
IsPreimmersion (Spec.map f) ↔ IsEmbedding (PrimeSpectrum.comap f.hom) ∧
f.hom.SurjectiveOnStalks := by
haveI : (RingHom.toMorphismProperty <| fun f ↦ Function.Surjective f).RespectsIso := by
rw [← RingHom.toMorphismProperty_respectsIso_iff]
exact RingHom.surjective_respectsIso
rw [← HasRingHomProperty.Spec_iff (P := @SurjectiveOnStalks), isPreimmersion_iff, and_comm]
rfl
@[deprecated (since := "2025-10-07")] alias Spec_map_iff := SpecMap_iff
lemma mk_SpecMap {R S : CommRingCat.{u}} {f : R ⟶ S}
(h₁ : IsEmbedding (PrimeSpectrum.comap f.hom)) (h₂ : f.hom.SurjectiveOnStalks) :
IsPreimmersion (Spec.map f) :=
(SpecMap_iff f).mpr ⟨h₁, h₂⟩
@[deprecated (since := "2025-10-07")] alias mk_Spec_map := mk_SpecMap
lemma of_isLocalization {R S : Type u} [CommRing R] (M : Submonoid R) [CommRing S]
[Algebra R S] [IsLocalization M S] :
IsPreimmersion (Spec.map (CommRingCat.ofHom <| algebraMap R S)) :=
IsPreimmersion.mk_SpecMap
(PrimeSpectrum.localization_comap_isEmbedding (R := R) S M)
(RingHom.surjectiveOnStalks_of_isLocalization (M := M) S)
open Limits MorphismProperty in
instance : IsStableUnderBaseChange @IsPreimmersion := by
refine .mk' fun X Y Z f g _ _ ↦ ?_
have := pullback_fst (P := @SurjectiveOnStalks) f g inferInstance
constructor
let L (x : (pullback f g :)) : { x : X × Y | f x.1 = g x.2 } :=
⟨⟨pullback.fst f g x, pullback.snd f g x⟩,
by simp only [Set.mem_setOf, ← Scheme.Hom.comp_apply, pullback.condition]⟩
have : IsEmbedding L := IsEmbedding.of_comp (by fun_prop) continuous_subtype_val
(SurjectiveOnStalks.isEmbedding_pullback f g)
exact IsEmbedding.subtypeVal.comp ((TopCat.pullbackHomeoPreimage _ f.continuous _
g.isEmbedding).isEmbedding.comp this)
end IsPreimmersion
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/FormallyUnramified.lean | import Mathlib.AlgebraicGeometry.Morphisms.Separated
import Mathlib.RingTheory.Ideal.IdempotentFG
import Mathlib.RingTheory.RingHom.Unramified
/-!
# Formally unramified morphisms
A morphism of schemes `f : X ⟶ Y` is formally unramified if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, the induced map `Γ(Y, U) ⟶ Γ(X, V)` is formally unramified.
We show that these properties are local, and are stable under compositions and base change.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
open AlgebraicGeometry
/-- If `S` is a formally unramified `R`-algebra, essentially of finite type, the diagonal is an
open immersion. -/
instance Algebra.FormallyUnramified.isOpenImmersion_SpecMap_lmul {R S : Type u} [CommRing R]
[CommRing S] [Algebra R S] [Algebra.FormallyUnramified R S] [Algebra.EssFiniteType R S] :
IsOpenImmersion (Spec.map (CommRingCat.ofHom (TensorProduct.lmul' R (S := S)).toRingHom)) := by
rw [isOpenImmersion_SpecMap_iff_of_surjective _ (fun x ↦ ⟨1 ⊗ₜ x, by simp⟩)]
apply (Ideal.isIdempotentElem_iff_of_fg _ (KaehlerDifferential.ideal_fg R S)).mp
apply (Ideal.cotangent_subsingleton_iff _).mp
exact inferInstanceAs <| Subsingleton Ω[S⁄R]
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is formally unramified if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is formally unramified. -/
@[mk_iff]
class FormallyUnramified (f : X ⟶ Y) : Prop where
formallyUnramified_of_affine_subset :
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1),
(f.appLE U V e).hom.FormallyUnramified
namespace FormallyUnramified
instance : HasRingHomProperty @FormallyUnramified RingHom.FormallyUnramified where
isLocal_ringHomProperty := RingHom.FormallyUnramified.propertyIsLocal
eq_affineLocally' := by
ext X Y f
rw [formallyUnramified_iff, affineLocally_iff_affineOpens_le]
instance : MorphismProperty.IsStableUnderComposition @FormallyUnramified :=
HasRingHomProperty.stableUnderComposition RingHom.FormallyUnramified.stableUnderComposition
/-- `f : X ⟶ S` is formally unramified if `X ⟶ X ×ₛ X` is an open immersion.
In particular, monomorphisms (e.g. immersions) are formally unramified.
The converse is true if `f` is locally of finite type. -/
instance (priority := 900) [IsOpenImmersion (pullback.diagonal f)] : FormallyUnramified f := by
wlog hY : ∃ R, Y = Spec R
· rw [IsZariskiLocalAtTarget.iff_of_openCover (P := @FormallyUnramified) Y.affineCover]
intro i
have inst : IsOpenImmersion (pullback.diagonal (pullback.snd f (Y.affineCover.f i))) :=
MorphismProperty.pullback_snd (P := .diagonal @IsOpenImmersion) _ _ ‹_›
exact this (pullback.snd _ _) ⟨_, rfl⟩
obtain ⟨R, rfl⟩ := hY
wlog hX : ∃ S, X = Spec S generalizing X
· rw [IsZariskiLocalAtSource.iff_of_openCover (P := @FormallyUnramified) X.affineCover]
intro i
have inst : IsOpenImmersion (pullback.diagonal (X.affineCover.f i ≫ f)) :=
MorphismProperty.comp_mem (.diagonal @IsOpenImmersion) _ _
(inferInstanceAs (IsOpenImmersion _)) ‹_›
exact this (_ ≫ _) ⟨_, rfl⟩
obtain ⟨S, rfl⟩ := hX
obtain ⟨φ, rfl : Spec.map φ = f⟩ := Spec.homEquiv.symm.surjective f
rw [HasRingHomProperty.Spec_iff (P := @FormallyUnramified)]
algebraize [φ.hom]
let F := (Algebra.TensorProduct.lmul' R (S := S)).toRingHom
have hF : Function.Surjective F := fun x ↦ ⟨.mk _ _ _ x 1, by simp [F]⟩
have : IsOpenImmersion (Spec.map (CommRingCat.ofHom F)) := by
rwa [← MorphismProperty.cancel_right_of_respectsIso (P := @IsOpenImmersion) _
(pullbackSpecIso R S S).inv, ← AlgebraicGeometry.diagonal_SpecMap R S]
obtain ⟨e, he, he'⟩ := (isOpenImmersion_SpecMap_iff_of_surjective _ hF).mp this
refine ⟨subsingleton_of_forall_eq 0 fun x ↦ ?_⟩
obtain ⟨⟨x, hx⟩, rfl⟩ := Ideal.toCotangent_surjective _ x
obtain ⟨x, rfl⟩ := Ideal.mem_span_singleton.mp (he'.le hx)
refine (Ideal.toCotangent_eq_zero _ _).mpr ?_
rw [pow_two, Subtype.coe_mk, ← he, mul_assoc]
exact Ideal.mul_mem_mul (he'.ge (Ideal.mem_span_singleton_self e)) hx
theorem of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[FormallyUnramified (f ≫ g)] : FormallyUnramified f :=
HasRingHomProperty.of_comp (fun {R S T _ _ _} f g H ↦ by
algebraize [f, g, g.comp f]
exact Algebra.FormallyUnramified.of_comp R S T) ‹_›
instance : MorphismProperty.IsMultiplicative @FormallyUnramified where
id_mem _ := inferInstance
instance : MorphismProperty.IsStableUnderBaseChange @FormallyUnramified :=
HasRingHomProperty.isStableUnderBaseChange RingHom.FormallyUnramified.isStableUnderBaseChange
open MorphismProperty in
/-- The diagonal of a formally unramified morphism of finite type is an open immersion. -/
instance isOpenImmersion_diagonal [FormallyUnramified f] [LocallyOfFiniteType f] :
IsOpenImmersion (pullback.diagonal f) := by
wlog hX : (∃ S, X = Spec S) ∧ ∃ R, Y = Spec R
· let 𝒰Y := Y.affineCover
let 𝒰X (j : (Y.affineCover.pullback₁ f).I₀) :
((Y.affineCover.pullback₁ f).X j).OpenCover := Scheme.affineCover _
apply IsZariskiLocalAtTarget.of_range_subset_iSup _
(Scheme.Pullback.range_diagonal_subset_diagonalCoverDiagonalRange f 𝒰Y 𝒰X)
intro ⟨i, j⟩
rw [arrow_mk_iso_iff (P := @IsOpenImmersion)
(Scheme.Pullback.diagonalRestrictIsoDiagonal f 𝒰Y 𝒰X i j)]
have hu : FormallyUnramified ((𝒰X i).f j ≫ pullback.snd f (𝒰Y.f i)) :=
comp_mem _ _ _ inferInstance (pullback_snd _ _ inferInstance)
have hfin : LocallyOfFiniteType ((𝒰X i).f j ≫ pullback.snd f (𝒰Y.f i)) :=
comp_mem _ _ _ inferInstance (pullback_snd _ _ inferInstance)
exact this _ ⟨⟨_, rfl⟩, ⟨_, rfl⟩⟩
obtain ⟨⟨S, rfl⟩, R, rfl⟩ := hX
obtain ⟨f, rfl⟩ := Spec.map_surjective f
rw [HasRingHomProperty.Spec_iff (P := @FormallyUnramified),
HasRingHomProperty.Spec_iff (P := @LocallyOfFiniteType)] at *
algebraize [f.hom]
rw [show f = CommRingCat.ofHom (algebraMap R S) from rfl, diagonal_SpecMap R S,
cancel_right_of_respectsIso (P := @IsOpenImmersion)]
infer_instance
@[deprecated (since := "2025-05-03")]
alias AlgebraicGeometry.FormallyUnramified.isOpenImmersion_diagonal := isOpenImmersion_diagonal
end FormallyUnramified
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean | import Mathlib.AlgebraicGeometry.Morphisms.Affine
import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties
/-!
# Affine morphisms with additional ring hom property
In this file we define a constructor `affineAnd Q` for affine target morphism properties of schemes
from a property of ring homomorphisms `Q`: A morphism `f : X ⟶ Y` with affine target satisfies
`affineAnd Q` if it is an affine morphism (i.e. `X` is affine) and the induced ring map on global
sections satisfies `Q`.
`affineAnd Q` inherits most stability properties of `Q` and is local at the target if `Q` is local
at the (algebraic) source.
Typical examples of this are affine morphisms (where `Q` is trivial), finite morphisms
(where `Q` is module finite) or closed immersions (where `Q` is being surjective).
-/
universe v u
open CategoryTheory TopologicalSpace Opposite MorphismProperty
namespace AlgebraicGeometry
section
variable (Q : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
/-- This is the affine target morphism property where the source is affine and
the induced map of rings on global sections satisfies `P`. -/
def affineAnd : AffineTargetMorphismProperty :=
fun X _ f ↦ IsAffine X ∧ Q (f.appTop).hom
@[simp]
lemma affineAnd_apply {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
affineAnd Q f ↔ IsAffine X ∧ Q (f.appTop).hom :=
Iff.rfl
attribute [local simp] AffineTargetMorphismProperty.toProperty_apply
variable {Q}
/-- If `P` respects isos, also `affineAnd P` respects isomorphisms. -/
lemma affineAnd_respectsIso (hP : RingHom.RespectsIso Q) :
(affineAnd Q).toProperty.RespectsIso := by
refine RespectsIso.mk _ ?_ ?_
· intro X Y Z e f ⟨hZ, ⟨hY, hf⟩⟩
simpa [hP.cancel_right_isIso, IsAffine.of_isIso e.hom]
· intro X Y Z e f ⟨hZ, hf⟩
simpa [AffineTargetMorphismProperty.toProperty, IsAffine.of_isIso e.inv, hP.cancel_left_isIso]
/-- `affineAnd P` is local if `P` is local on the (algebraic) source. -/
lemma affineAnd_isLocal (hPi : RingHom.RespectsIso Q) (hQl : RingHom.LocalizationAwayPreserves Q)
(hQs : RingHom.OfLocalizationSpan Q) : (affineAnd Q).IsLocal where
respectsIso := affineAnd_respectsIso hPi
to_basicOpen {X Y _} f r := fun ⟨hX, hf⟩ ↦ by
simp only at hf
constructor
· simp only [Scheme.preimage_basicOpen, Opens.map_top]
exact (isAffineOpen_top X).basicOpen _
· dsimp only
rw [morphismRestrict_appTop, CommRingCat.hom_comp, hPi.cancel_right_isIso]
-- Not sure why the `show` fixes the following `rw` complaining about "motive is incorrect"
change Q (Scheme.Hom.app f ((Y.basicOpen r).ι ''ᵁ ⊤)).hom
rw [Scheme.Opens.ι_image_top]
rw [(isAffineOpen_top Y).app_basicOpen_eq_away_map f (isAffineOpen_top X),
CommRingCat.hom_comp, hPi.cancel_right_isIso, ← Scheme.Hom.appTop]
dsimp only [Opens.map_top]
haveI := (isAffineOpen_top X).isLocalization_basicOpen (f.appTop r)
apply hQl
exact hf
of_basicOpenCover {X Y _} f s hs hf := by
dsimp [affineAnd] at hf
haveI : IsAffine X := by
apply isAffine_of_isAffineOpen_basicOpen (f.appTop '' s)
· apply_fun Ideal.map (f.appTop).hom at hs
rwa [Ideal.map_span, Ideal.map_top] at hs
· rintro - ⟨r, hr, rfl⟩
simp_rw [Scheme.preimage_basicOpen] at hf
exact (hf ⟨r, hr⟩).left
refine ⟨inferInstance, hQs.ofIsLocalization' hPi (f.appTop).hom s hs fun a ↦ ?_⟩
refine ⟨Γ(Y, Y.basicOpen a.val), Γ(X, X.basicOpen (f.appTop a.val)), inferInstance,
inferInstance, inferInstance, inferInstance, inferInstance, ?_, ?_⟩
· exact (isAffineOpen_top X).isLocalization_basicOpen (f.appTop a.val)
· obtain ⟨_, hf⟩ := hf a
rw [morphismRestrict_appTop, CommRingCat.hom_comp, hPi.cancel_right_isIso] at hf
-- Not sure why the `show` fixes the following `rw` complaining about "motive is incorrect"
have hf : Q (Scheme.Hom.app f ((Y.basicOpen a.1).ι ''ᵁ ⊤)).hom := hf
rw [Scheme.Opens.ι_image_top] at hf
rw [(isAffineOpen_top Y).app_basicOpen_eq_away_map _ (isAffineOpen_top X)] at hf
rwa [CommRingCat.hom_comp, hPi.cancel_right_isIso] at hf
lemma affineAnd_isLocal_of_propertyIsLocal
(hPi : RingHom.PropertyIsLocal Q) : (affineAnd Q).IsLocal :=
affineAnd_isLocal hPi.respectsIso hPi.localizationAwayPreserves hPi.ofLocalizationSpan
/-- If `P` is stable under base change, so is `affineAnd P`. -/
lemma affineAnd_isStableUnderBaseChange (hQi : RingHom.RespectsIso Q)
(hQb : RingHom.IsStableUnderBaseChange Q) :
(affineAnd Q).IsStableUnderBaseChange := by
haveI : (affineAnd Q).toProperty.RespectsIso := affineAnd_respectsIso hQi
apply AffineTargetMorphismProperty.IsStableUnderBaseChange.mk
intro X Y S _ _ f g ⟨hY, hg⟩
exact ⟨inferInstance, hQb.pullback_fst_appTop _ hQi f _ hg⟩
lemma targetAffineLocally_affineAnd_iff (hQi : RingHom.RespectsIso Q)
{X Y : Scheme.{u}} (f : X ⟶ Y) :
targetAffineLocally (affineAnd Q) f ↔ ∀ U : Y.Opens, IsAffineOpen U →
IsAffineOpen (f ⁻¹ᵁ U) ∧ Q (f.app U).hom := by
simp only [targetAffineLocally, affineAnd_apply, morphismRestrict_app, CommRingCat.hom_comp,
hQi.cancel_right_isIso]
refine ⟨fun hf U hU ↦ ?_, fun h U ↦ ?_⟩
· obtain ⟨hfU, hf⟩ := hf ⟨U, hU⟩
use hfU
have hf : Q (Scheme.Hom.app f (((⟨U, hU⟩ : Y.affineOpens) : Y.Opens).ι ''ᵁ ⊤)).hom := hf
rwa [Scheme.Opens.ι_image_top] at hf
· refine ⟨(h U U.2).1, ?_⟩
change Q (Scheme.Hom.app f ((U : Y.Opens).ι ''ᵁ ⊤)).hom
rw [Scheme.Opens.ι_image_top]
exact (h U U.2).2
/-- Variant of `targetAffineLocally_affineAnd_iff` where `IsAffineHom` is bundled. -/
lemma targetAffineLocally_affineAnd_iff' (hQi : RingHom.RespectsIso Q)
{X Y : Scheme.{u}} (f : X ⟶ Y) :
targetAffineLocally (affineAnd Q) f ↔
IsAffineHom f ∧ ∀ U : Y.Opens, IsAffineOpen U → Q (f.app U).hom := by
rw [targetAffineLocally_affineAnd_iff hQi, isAffineHom_iff]
aesop
lemma targetAffineLocally_affineAnd_iff_affineLocally (hQ : RingHom.PropertyIsLocal Q)
{X Y : Scheme.{u}} (f : X ⟶ Y) :
targetAffineLocally (affineAnd Q) f ↔ IsAffineHom f ∧ affineLocally Q f := by
haveI : HasRingHomProperty (affineLocally Q) Q := ⟨hQ, rfl⟩
rw [targetAffineLocally_affineAnd_iff' hQ.respectsIso]
simp only [and_congr_right_iff]
intro hf
constructor
· wlog hY : IsAffine Y
· intro h
rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := affineLocally Q)
_ (iSup_affineOpens_eq_top _)]
intro U
have : IsAffine (f ⁻¹ᵁ U) := hf.isAffine_preimage U U.2
rw [HasRingHomProperty.iff_of_isAffine (P := affineLocally Q),
morphismRestrict_appTop, CommRingCat.hom_comp, hQ.respectsIso.cancel_right_isIso]
apply h
rw [Scheme.Opens.ι_image_top]
exact U.2
intro h
have : IsAffine X := isAffine_of_isAffineHom f
rw [HasRingHomProperty.iff_of_isAffine (P := affineLocally Q)]
exact h ⊤ (isAffineOpen_top Y)
· intro h U hU
rw [affineLocally_iff_affineOpens_le] at h
rw [f.app_eq_appLE]
exact h ⟨U, hU⟩ ⟨f ⁻¹ᵁ U, hf.isAffine_preimage U hU⟩ (by simp)
lemma targetAffineLocally_affineAnd_eq_affineLocally (hQ : RingHom.PropertyIsLocal Q) :
targetAffineLocally (affineAnd Q) =
(@IsAffineHom ⊓ @affineLocally Q : MorphismProperty Scheme.{u}) := by
ext X Y f
exact targetAffineLocally_affineAnd_iff_affineLocally hQ f
variable {W : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
lemma targetAffineLocally_affineAnd_le
(hQW : ∀ {R S : Type u} [CommRing R] [CommRing S] {f : R →+* S}, Q f → W f) :
targetAffineLocally (affineAnd Q) ≤ targetAffineLocally (affineAnd W) := by
intro X Y f h U
exact ⟨(h U).1, hQW (h U).2⟩
end
section
variable {Q : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
/-- If `P` is a morphism property affine locally defined by `affineAnd Q`, `P` is stable under
composition if `Q` is. -/
lemma HasAffineProperty.affineAnd_isStableUnderComposition {P : MorphismProperty Scheme.{u}}
(hA : HasAffineProperty P (affineAnd Q)) (hQ : RingHom.StableUnderComposition Q) :
P.IsStableUnderComposition where
comp_mem {X Y Z} f g hf hg := by
wlog hZ : IsAffine Z
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
rw [morphismRestrict_comp]
exact this hA hQ _ _ (IsZariskiLocalAtTarget.restrict hf _)
(IsZariskiLocalAtTarget.restrict hg _) U.2
rw [HasAffineProperty.iff_of_isAffine (P := P) (Q := (affineAnd Q))] at hg
obtain ⟨hY, hg⟩ := hg
rw [HasAffineProperty.iff_of_isAffine (P := P) (Q := (affineAnd Q))] at hf
obtain ⟨hX, hf⟩ := hf
rw [HasAffineProperty.iff_of_isAffine (P := P) (Q := (affineAnd Q))]
exact ⟨hX, hQ _ _ hg hf⟩
/-- If `P` is a morphism property affine locally defined by `affineAnd Q`, `P` is stable under
base change if `Q` is. -/
lemma HasAffineProperty.affineAnd_isStableUnderBaseChange {P : MorphismProperty Scheme.{u}}
(_ : HasAffineProperty P (affineAnd Q)) (hQi : RingHom.RespectsIso Q)
(hQb : RingHom.IsStableUnderBaseChange Q) :
P.IsStableUnderBaseChange :=
HasAffineProperty.isStableUnderBaseChange
(AlgebraicGeometry.affineAnd_isStableUnderBaseChange hQi hQb)
/-- If `Q` contains identities and respects isomorphisms (i.e. is satisfied by isomorphisms),
and `P` is affine locally defined by `affineAnd Q`, then `P` contains identities. -/
lemma HasAffineProperty.affineAnd_containsIdentities {P : MorphismProperty Scheme.{u}}
(hA : HasAffineProperty P (affineAnd Q)) (hQi : RingHom.RespectsIso Q)
(hQ : RingHom.ContainsIdentities Q) :
P.ContainsIdentities where
id_mem X := by
rw [eq_targetAffineLocally P, targetAffineLocally_affineAnd_iff hQi]
intro U hU
exact ⟨hU, hQ _⟩
/-- A convenience constructor for `HasAffineProperty P (affineAnd Q)`. The `IsAffineHom` is bundled,
since this goes well with defining morphism properties via `extends IsAffineHom`. -/
lemma HasAffineProperty.affineAnd_iff (P : MorphismProperty Scheme.{u})
(hQi : RingHom.RespectsIso Q) (hQl : RingHom.LocalizationAwayPreserves Q)
(hQs : RingHom.OfLocalizationSpan Q) :
HasAffineProperty P (affineAnd Q) ↔
∀ {X Y : Scheme.{u}} (f : X ⟶ Y), P f ↔
(IsAffineHom f ∧ ∀ U : Y.Opens, IsAffineOpen U → Q (f.app U).hom) := by
simp_rw [isAffineHom_iff]
refine ⟨fun h X Y f ↦ ?_, fun h ↦ ⟨affineAnd_isLocal hQi hQl hQs, ?_⟩⟩
· rw [eq_targetAffineLocally P, targetAffineLocally_affineAnd_iff hQi]
aesop
· ext X Y f
rw [targetAffineLocally_affineAnd_iff hQi, h f]
aesop
lemma HasAffineProperty.affineAnd_le_isAffineHom (P : MorphismProperty Scheme.{u})
(hA : HasAffineProperty P (affineAnd Q)) : P ≤ @IsAffineHom := by
intro X Y f hf
wlog hY : IsAffine Y
· rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := @IsAffineHom) _ (iSup_affineOpens_eq_top _)]
intro U
exact this P hA _ (IsZariskiLocalAtTarget.restrict hf _) U.2
rw [HasAffineProperty.iff_of_isAffine (P := P) (Q := (affineAnd Q))] at hf
rw [HasAffineProperty.iff_of_isAffine (P := @IsAffineHom)]
exact hf.1
lemma HasAffineProperty.affineAnd_eq_of_propertyIsLocal {P P' : MorphismProperty Scheme.{u}}
(hP : HasAffineProperty P (affineAnd Q)) [HasRingHomProperty P' Q] :
P = (@IsAffineHom ⊓ P' : MorphismProperty Scheme.{u}) := by
rw [HasAffineProperty.eq_targetAffineLocally (P := P),
targetAffineLocally_affineAnd_eq_affineLocally,
HasRingHomProperty.eq_affineLocally (P := P')]
exact HasRingHomProperty.isLocal_ringHomProperty P'
lemma HasAffineProperty.SpecMap_iff_of_affineAnd {P : MorphismProperty Scheme.{u}}
(hP : HasAffineProperty P (affineAnd Q)) (hQi : RingHom.RespectsIso Q)
{R S : CommRingCat.{u}} (f : R ⟶ S) : P (Spec.map f) ↔ Q f.hom := by
have := RingHom.toMorphismProperty_respectsIso_iff.mp hQi
rw [HasAffineProperty.iff_of_isAffine (P := P), affineAnd, and_iff_right]
exacts [MorphismProperty.arrow_mk_iso_iff (RingHom.toMorphismProperty Q)
(arrowIsoΓSpecOfIsAffine f).symm, inferInstance]
variable {Q' : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
lemma HasAffineProperty.affineAnd_le_affineAnd {P P' : MorphismProperty Scheme.{u}}
(hP : HasAffineProperty P (affineAnd Q)) (hP' : HasAffineProperty P' (affineAnd Q'))
(hQQ' : ∀ {R S : Type u} [CommRing R] [CommRing S] {f : R →+* S}, Q f → Q' f) :
P ≤ P' := by
rw [HasAffineProperty.eq_targetAffineLocally (P := P),
HasAffineProperty.eq_targetAffineLocally (P := P')]
exact targetAffineLocally_affineAnd_le hQQ'
end
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/QuasiSeparated.lean | import Mathlib.AlgebraicGeometry.Morphisms.Constructors
import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Equalizer
import Mathlib.Topology.QuasiSeparated
import Mathlib.Topology.Sheaves.CommRingCat
/-!
# Quasi-separated morphisms
A morphism of schemes `f : X ⟶ Y` is quasi-separated if the diagonal morphism `X ⟶ X ×[Y] X` is
quasi-compact.
A scheme is quasi-separated if the intersections of any two affine open sets is quasi-compact.
(`AlgebraicGeometry.quasiSeparatedSpace_iff_affine`)
We show that a morphism is quasi-separated if the preimage of every affine open is quasi-separated.
We also show that this property is local at the target,
and is stable under compositions and base-changes.
## Main result
- `AlgebraicGeometry.isLocalization_basicOpen_of_qcqs` (**Qcqs lemma**):
If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/
@[mk_iff]
class QuasiSeparated (f : X ⟶ Y) : Prop where
/-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/
quasiCompact_diagonal : QuasiCompact (pullback.diagonal f) := by infer_instance
attribute [instance] QuasiSeparated.quasiCompact_diagonal
@[deprecated (since := "2025-10-15")]
alias QuasiSeparated.diagonalQuasiCompact := QuasiSeparated.quasiCompact_diagonal
theorem quasiSeparatedSpace_iff_forall_affineOpens {X : Scheme} :
QuasiSeparatedSpace X ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X) := by
rw [quasiSeparatedSpace_iff]
constructor
· intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
· intro H
suffices
∀ (U : X.Opens) (_ : IsCompact U.1) (V : X.Opens) (_ : IsCompact V.1),
IsCompact (U ⊓ V).1
by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
intro U hU V hV
refine compact_open_induction_on V hV ?_ ?_
· simp
· intro S _ V hV
change IsCompact (U.1 ∩ (S.1 ∪ V.1))
rw [Set.inter_union_distrib_left]
apply hV.union
clear hV
refine compact_open_induction_on U hU ?_ ?_
· simp
· intro S _ W hW
change IsCompact ((S.1 ∪ W.1) ∩ V.1)
rw [Set.union_inter_distrib_right]
apply hW.union
apply H
@[deprecated (since := "2025-10-15")]
alias quasiSeparatedSpace_iff_affine := quasiSeparatedSpace_iff_forall_affineOpens
theorem quasiCompact_affineProperty_iff_quasiSeparatedSpace [IsAffine Y] (f : X ⟶ Y) :
AffineTargetMorphismProperty.diagonal (fun X _ _ _ ↦ CompactSpace X) f ↔
QuasiSeparatedSpace X := by
delta AffineTargetMorphismProperty.diagonal
rw [quasiSeparatedSpace_iff_forall_affineOpens]
constructor
· intro H U V
haveI : IsAffine _ := U.2
haveI : IsAffine _ := V.2
let g : pullback U.1.ι V.1.ι ⟶ X := pullback.fst _ _ ≫ U.1.ι
have e := g.isOpenEmbedding.isEmbedding.toHomeomorph
rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
erw [Subtype.range_coe, Subtype.range_coe] at e
rw [isCompact_iff_compactSpace]
exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
· introv H h₁ h₂
let g : pullback f₁ f₂ ⟶ X := pullback.fst _ _ ≫ f₁
have e := g.isOpenEmbedding.isEmbedding.toHomeomorph
rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
simp_rw [isCompact_iff_compactSpace] at H
exact @Homeomorph.compactSpace _ _ _ _
(H ⟨_, isAffineOpen_opensRange f₁⟩ ⟨_, isAffineOpen_opensRange f₂⟩) e.symm
theorem quasiSeparated_eq_diagonal_is_quasiCompact :
@QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by ext; exact quasiSeparated_iff _
instance : HasAffineProperty @QuasiSeparated (fun X _ _ _ ↦ QuasiSeparatedSpace X) where
__ := HasAffineProperty.copy
quasiSeparated_eq_diagonal_is_quasiCompact.symm
(by ext; exact quasiCompact_affineProperty_iff_quasiSeparatedSpace _)
instance (priority := 900) (f : X ⟶ Y) [Mono f] :
QuasiSeparated f where
instance quasiSeparated_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @QuasiSeparated :=
quasiSeparated_eq_diagonal_is_quasiCompact.symm ▸ inferInstance
instance : MorphismProperty.IsMultiplicative @QuasiSeparated where
id_mem _ := inferInstance
instance quasiSeparated_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @QuasiSeparated :=
quasiSeparated_eq_diagonal_is_quasiCompact.symm ▸ inferInstance
instance quasiSeparated_comp (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiSeparated f]
[QuasiSeparated g] : QuasiSeparated (f ≫ g) :=
MorphismProperty.comp_mem _ f g inferInstance inferInstance
theorem quasiSeparatedSpace_iff_quasiSeparated (X : Scheme) :
QuasiSeparatedSpace X ↔ QuasiSeparated (terminal.from X) :=
(HasAffineProperty.iff_of_isAffine (P := @QuasiSeparated)).symm
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [QuasiSeparated g] :
QuasiSeparated (pullback.fst f g) :=
MorphismProperty.pullback_fst f g inferInstance
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [QuasiSeparated f] :
QuasiSeparated (pullback.snd f g) :=
MorphismProperty.pullback_snd f g inferInstance
instance (f : X ⟶ Y) (V : Y.Opens) [QuasiSeparated f] : QuasiSeparated (f ∣_ V) :=
IsZariskiLocalAtTarget.restrict ‹_› V
instance (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e) [QuasiSeparated f] :
QuasiSeparated (f.resLE V U e) := by
delta Scheme.Hom.resLE; infer_instance
theorem quasiSeparatedSpace_of_quasiSeparated (f : X ⟶ Y)
[hY : QuasiSeparatedSpace Y] [QuasiSeparated f] : QuasiSeparatedSpace X := by
rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
rw [← terminalIsTerminal.hom_ext (f ≫ terminal.from Y) (terminal.from X)]
infer_instance
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] : QuasiSeparatedSpace X :=
(quasiSeparatedSpace_congr X.isoSpec.hom.homeomorph).2 PrimeSpectrum.instQuasiSeparatedSpace
theorem IsAffineOpen.isQuasiSeparated {U : X.Opens} (hU : IsAffineOpen U) :
IsQuasiSeparated (U : Set X) := by
rw [isQuasiSeparated_iff_quasiSeparatedSpace]
exacts [@AlgebraicGeometry.quasiSeparatedSpace_of_isAffine _ hU, U.isOpen]
instance [QuasiSeparatedSpace X] : QuasiSeparated X.toSpecΓ :=
HasAffineProperty.iff_of_isAffine.mpr ‹_›
theorem Scheme.quasiSeparatedSpace_of_isOpenCover
{I : Type*} (U : I → X.Opens) (hU : IsOpenCover U)
(hU₁ : ∀ i, IsAffineOpen (U i)) (hU₂ : ∀ i j, IsCompact (X := X) (U i ∩ U j)) :
QuasiSeparatedSpace X := by
letI := HasAffineProperty.isLocal_affineProperty @QuasiCompact
rw [← quasiCompact_affineProperty_iff_quasiSeparatedSpace X.toSpecΓ]
have : ∀ i, IsAffine ((X.openCoverOfIsOpenCover U hU).X i) := hU₁
refine AffineTargetMorphismProperty.diagonal_of_openCover_source _
(Scheme.openCoverOfIsOpenCover _ _ hU) fun i j ↦ ?_
rw [← isCompact_univ_iff, (pullback.fst ((X.openCoverOfIsOpenCover U hU).f i)
((X.openCoverOfIsOpenCover U hU).f j) ≫
(X.openCoverOfIsOpenCover U hU).f i).isOpenEmbedding.isCompact_iff, Set.image_univ,
IsOpenImmersion.range_pullback_to_base_of_left]
simpa using hU₂ i j
lemma quasiSeparatedSpace_iff_quasiCompact_prod_lift :
QuasiSeparatedSpace X ↔ QuasiCompact (prod.lift (𝟙 X) (𝟙 X)) := by
rw [← MorphismProperty.cancel_right_of_respectsIso @QuasiCompact _ (prodIsoPullback X X).hom,
← HasAffineProperty.iff_of_isAffine (f := terminal.from X) (P := @QuasiSeparated),
quasiSeparated_iff]
congr!
ext : 1 <;> simp
instance [QuasiSeparatedSpace X] : QuasiCompact (prod.lift (𝟙 X) (𝟙 X)) := by
rwa [← quasiSeparatedSpace_iff_quasiCompact_prod_lift]
instance [QuasiSeparatedSpace Y] (f g : X ⟶ Y) : QuasiCompact (equalizer.ι f g) :=
MorphismProperty.of_isPullback (P := @QuasiCompact)
(isPullback_equalizer_prod f g).flip inferInstance
instance [CompactSpace X] [QuasiSeparatedSpace Y] (f g : X ⟶ Y) :
CompactSpace (equalizer f g).carrier := by
constructor
simpa using QuasiCompact.isCompact_preimage (f := equalizer.ι f g) _ isOpen_univ isCompact_univ
theorem QuasiSeparated.of_comp (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiSeparated (f ≫ g)] :
QuasiSeparated f := by
let 𝒰 := (Z.affineCover.pullback₁ g).bind fun x => Scheme.affineCover _
have (i : _) : IsAffine (𝒰.X i) := by dsimp [𝒰]; infer_instance
apply HasAffineProperty.of_openCover
((Z.affineCover.pullback₁ g).bind fun x => Scheme.affineCover _)
rintro ⟨i, j⟩; dsimp at i j
refine @quasiSeparatedSpace_of_quasiSeparated _ _ ?_
(HasAffineProperty.of_isPullback (.of_hasPullback _ (Z.affineCover.f i)) ‹_›) ?_
· exact pullback.map _ _ _ _ (𝟙 _) _ _ (by simp) (Category.comp_id _) ≫
(pullbackRightPullbackFstIso g (Z.affineCover.f i) f).hom
· exact inferInstance
instance (priority := low) QuasiSeparated.of_quasiSeparatedSpace
(f : X ⟶ Y) [QuasiSeparatedSpace X] : QuasiSeparated f :=
have : QuasiSeparated (f ≫ Y.toSpecΓ) :=
(HasAffineProperty.iff_of_isAffine (P := @QuasiSeparated)).mpr ‹_›
.of_comp f Y.toSpecΓ
theorem quasiSeparated_iff_quasiSeparatedSpace (f : X ⟶ Y) [QuasiSeparatedSpace Y] :
QuasiSeparated f ↔ QuasiSeparatedSpace X :=
⟨fun _ ↦ quasiSeparatedSpace_of_quasiSeparated f, fun _ ↦ inferInstance⟩
@[deprecated (since := "2025-10-15")]
alias quasiSeparated_over_affine_iff := quasiSeparated_iff_quasiSeparatedSpace
instance : MorphismProperty.HasOfPostcompProperty @QuasiSeparated ⊤ where
of_postcomp f g _ _ := .of_comp f g
instance : MorphismProperty.HasOfPostcompProperty @QuasiCompact @QuasiSeparated :=
MorphismProperty.hasOfPostcompProperty_iff_le_diagonal.mpr
(by rw [quasiSeparated_eq_diagonal_is_quasiCompact])
lemma QuasiCompact.of_comp (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact (f ≫ g)] [QuasiSeparated g] :
QuasiCompact f :=
MorphismProperty.of_postcomp _ _ g ‹_› ‹_›
instance (priority := low) quasiCompact_of_compactSpace {X Y : Scheme} (f : X ⟶ Y)
[CompactSpace X] [QuasiSeparatedSpace Y] : QuasiCompact f :=
have : QuasiCompact (f ≫ Y.toSpecΓ) := HasAffineProperty.iff_of_isAffine.mpr ‹_›
.of_comp f Y.toSpecΓ
theorem quasiCompact_iff_compactSpace (f : X ⟶ Y) [QuasiSeparatedSpace Y] [CompactSpace Y] :
QuasiCompact f ↔ CompactSpace X :=
⟨fun _ ↦ QuasiCompact.compactSpace_of_compactSpace f, fun _ ↦ inferInstance⟩
@[deprecated (since := "2025-10-15")]
alias quasiCompact_over_affine_iff := quasiCompact_iff_compactSpace
theorem exists_eq_pow_mul_of_isAffineOpen (X : Scheme) (U : X.Opens) (hU : IsAffineOpen U)
(f : Γ(X, U)) (x : Γ(X, X.basicOpen f)) :
∃ (n : ℕ) (y : Γ(X, U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
have := (hU.isLocalization_basicOpen f).2
obtain ⟨⟨y, _, n, rfl⟩, d⟩ := this x
use n, y
simpa [mul_comm x] using d.symm
theorem exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux_aux {X : TopCat}
(F : X.Presheaf CommRingCat) {U₁ U₂ U₃ U₄ U₅ U₆ U₇ : Opens X} {n₁ n₂ : ℕ}
{y₁ : F.obj (op U₁)} {y₂ : F.obj (op U₂)} {f : F.obj (op <| U₁ ⊔ U₂)}
{x : F.obj (op U₃)} (h₄₁ : U₄ ≤ U₁) (h₄₂ : U₄ ≤ U₂) (h₅₁ : U₅ ≤ U₁) (h₅₃ : U₅ ≤ U₃)
(h₆₂ : U₆ ≤ U₂) (h₆₃ : U₆ ≤ U₃) (h₇₄ : U₇ ≤ U₄) (h₇₅ : U₇ ≤ U₅) (h₇₆ : U₇ ≤ U₆)
(e₁ : y₁ |_ U₅ = (f |_ U₁ |_ U₅) ^ n₁ * x |_ U₅)
(e₂ : y₂ |_ U₆ = (f |_ U₂ |_ U₆) ^ n₂ * x |_ U₆) :
(((f |_ U₁) ^ n₂ * y₁) |_ U₄) |_ U₇ = (((f |_ U₂) ^ n₁ * y₂) |_ U₄) |_ U₇ := by
apply_fun (fun x : F.obj (op U₅) ↦ x |_ U₇) at e₁
apply_fun (fun x : F.obj (op U₆) ↦ x |_ U₇) at e₂
dsimp only [TopCat.Presheaf.restrictOpenCommRingCat_apply] at e₁ e₂ ⊢
simp only [map_mul, map_pow, ← op_comp, ← F.map_comp, homOfLE_comp, ← CommRingCat.comp_apply]
at e₁ e₂ ⊢
rw [e₁, e₂, mul_left_comm]
theorem exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux (X : Scheme)
(S : X.affineOpens) (U₁ U₂ : X.Opens) {n₁ n₂ : ℕ} {y₁ : Γ(X, U₁)}
{y₂ : Γ(X, U₂)} {f : Γ(X, U₁ ⊔ U₂)}
{x : Γ(X, X.basicOpen f)} (h₁ : S.1 ≤ U₁) (h₂ : S.1 ≤ U₂)
(e₁ : y₁ |_ X.basicOpen (f |_ U₁) =
((f |_ U₁ |_ X.basicOpen _) ^ n₁) * x |_ X.basicOpen _)
(e₂ : y₂ |_ X.basicOpen (f |_ U₂) =
((f |_ U₂ |_ X.basicOpen _) ^ n₂) * x |_ X.basicOpen _) :
∃ n : ℕ, ∀ m, n ≤ m →
((f |_ U₁) ^ (m + n₂) * y₁) |_ S.1 = ((f |_ U₂) ^ (m + n₁) * y₂) |_ S.1 := by
obtain ⟨⟨_, n, rfl⟩, e⟩ :=
(@IsLocalization.eq_iff_exists _ _ _ _ _ _
(S.2.isLocalization_basicOpen (f |_ S.1))
(((f |_ U₁) ^ n₂ * y₁) |_ S.1)
(((f |_ U₂) ^ n₁ * y₂) |_ S.1)).mp <| by
apply exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux_aux (e₁ := e₁) (e₂ := e₂)
· change X.basicOpen _ ≤ _
simp only [TopCat.Presheaf.restrictOpenCommRingCat_apply, Scheme.basicOpen_res]
exact inf_le_inf h₁ le_rfl
· change X.basicOpen _ ≤ _
simp only [TopCat.Presheaf.restrictOpenCommRingCat_apply, Scheme.basicOpen_res]
exact inf_le_inf h₂ le_rfl
use n
intro m hm
rw [← tsub_add_cancel_of_le hm]
simp only [TopCat.Presheaf.restrictOpenCommRingCat_apply,
pow_add, map_pow, map_mul, mul_assoc, ← Functor.map_comp, ← op_comp, homOfLE_comp,
← CommRingCat.comp_apply] at e ⊢
rw [e]
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : X.Opens)
(hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : Γ(X, U)) (x : Γ(X, X.basicOpen f)) :
∃ (n : ℕ) (y : Γ(X, U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
dsimp only [TopCat.Presheaf.restrictOpenCommRingCat_apply]
revert hU' f x
refine compact_open_induction_on U hU ?_ ?_
· intro _ f x
use 0, f
refine @Subsingleton.elim _
(CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty ?_)) _ _
rw [eq_bot_iff]
exact X.basicOpen_le f
· -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
-- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
intro S hS U hU hSU f x
-- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
obtain ⟨n₁, y₁, hy₁⟩ :=
hU (hSU.of_subset Set.subset_union_left) (X.presheaf.map (homOfLE le_sup_left).op f)
(X.presheaf.map (homOfLE _).op x)
-- · rw [X.basicOpen_res]; exact inf_le_right
-- We know that such `y₂, n₂` exists on `U` since `U` is affine.
obtain ⟨n₂, y₂, hy₂⟩ :=
exists_eq_pow_mul_of_isAffineOpen X _ U.2 (X.presheaf.map (homOfLE le_sup_right).op f)
(X.presheaf.map (homOfLE _).op x)
dsimp only [TopCat.Presheaf.restrictOpenCommRingCat_apply] at hy₂
-- swap; · rw [X.basicOpen_res]; exact inf_le_right
-- Since `S ∪ U` is quasi-separated, `S ∩ U` can be covered by finite affine opens.
obtain ⟨s, hs', hs⟩ :=
isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens.mp
⟨hSU _ _ Set.subset_union_left S.2 hS Set.subset_union_right U.1.2
U.2.isCompact,
(S ⊓ U.1).2⟩
haveI := hs'.to_subtype
cases nonempty_fintype s
replace hs : S ⊓ U.1 = iSup fun i : s => (i : X.Opens) := by ext1; simpa using hs
have hs₁ (i : s) : i.1.1 ≤ S := by
refine le_trans ?_ (inf_le_left (b := U.1))
rw [hs]
exact le_iSup (fun (i : s) => (i : X.Opens)) i
have hs₂ (i : s) : i.1.1 ≤ U.1 := by
refine le_trans ?_ (inf_le_right (a := S))
rw [hs]
exact le_iSup (fun (i : s) => (i : X.Opens)) i
-- On each affine open in the intersection, we have `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
-- for some `n` since `f ^ n₂ * y₁ = f ^ (n₁ + n₂) * x = f ^ n₁ * y₂` on `X_f`.
have := fun i ↦ exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux
X i.1 S U (hs₁ i) (hs₂ i) hy₁ hy₂
choose n hn using this
-- We can thus choose a big enough `n` such that `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
-- on `S ∩ U`.
have :
X.presheaf.map (homOfLE <| inf_le_left).op
(X.presheaf.map (homOfLE le_sup_left).op f ^ (Finset.univ.sup n + n₂) * y₁) =
X.presheaf.map (homOfLE <| inf_le_right).op
(X.presheaf.map (homOfLE le_sup_right).op f ^ (Finset.univ.sup n + n₁) * y₂) := by
fapply X.sheaf.eq_of_locally_eq' fun i : s => i.1.1
· refine fun i => homOfLE ?_; rw [hs]
exact le_iSup (fun (i : s) => (i : X.Opens)) i
· exact le_of_eq hs
· intro i
-- This unfolds `X.sheaf`
change (X.presheaf.map _) _ = (X.presheaf.map _) _
simp only [← CommRingCat.comp_apply, ← Functor.map_comp, ← op_comp]
apply hn
exact Finset.le_sup (Finset.mem_univ _)
use Finset.univ.sup n + n₁ + n₂
-- By the sheaf condition, since `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`, it can be glued into
-- the desired section on `S ∪ U`.
use (X.sheaf.objSupIsoProdEqLocus S U.1).inv ⟨⟨_ * _, _ * _⟩, this⟩
refine (X.sheaf.objSupIsoProdEqLocus_inv_eq_iff _ _ _ (X.basicOpen_res _
(homOfLE le_sup_left).op) (X.basicOpen_res _ (homOfLE le_sup_right).op)).mpr ⟨?_, ?_⟩
· -- This unfolds `X.sheaf`
change (X.presheaf.map _) _ = (X.presheaf.map _) _
rw [add_assoc, add_comm n₁]
simp only [pow_add, map_pow, map_mul, hy₁, ← CommRingCat.comp_apply, ← mul_assoc,
← Functor.map_comp, ← op_comp, homOfLE_comp]
· -- This unfolds `X.sheaf`
change (X.presheaf.map _) _ = (X.presheaf.map _) _
simp only [pow_add, map_pow, map_mul, hy₂, ← CommRingCat.comp_apply, ← mul_assoc,
← Functor.map_comp, ← op_comp, homOfLE_comp]
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem isLocalization_basicOpen_of_qcqs {X : Scheme} {U : X.Opens} (hU : IsCompact U.1)
(hU' : IsQuasiSeparated U.1) (f : Γ(X, U)) :
IsLocalization.Away f (Γ(X, X.basicOpen f)) := by
constructor
· rintro ⟨_, n, rfl⟩
simp only [map_pow, RingHom.algebraMap_toAlgebra]
exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
· intro z
obtain ⟨n, y, e⟩ := exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated X U hU hU' f z
refine ⟨⟨y, _, n, rfl⟩, ?_⟩
simpa only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra, mul_comm z] using e.symm
· intro x y
rw [← sub_eq_zero, ← map_sub, RingHom.algebraMap_toAlgebra]
simp_rw [← @sub_eq_zero _ _ (_ * x) (_ * y), ← mul_sub]
generalize x - y = z
intro H
obtain ⟨n, e⟩ := exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact X hU _ _ H
refine ⟨⟨_, n, rfl⟩, ?_⟩
simpa [mul_comm z] using e
lemma exists_of_res_eq_of_qcqs {X : Scheme.{u}} {U : TopologicalSpace.Opens X}
(hU : IsCompact U.carrier) (hU' : IsQuasiSeparated U.carrier)
{f g s : Γ(X, U)} (hfg : f |_ X.basicOpen s = g |_ X.basicOpen s) :
∃ n, s ^ n * f = s ^ n * g := by
obtain ⟨n, hc⟩ := (isLocalization_basicOpen_of_qcqs hU hU' s).exists_of_eq s hfg
use n
lemma exists_of_res_eq_of_qcqs_of_top {X : Scheme.{u}} [CompactSpace X] [QuasiSeparatedSpace X]
{f g s : Γ(X, ⊤)} (hfg : f |_ X.basicOpen s = g |_ X.basicOpen s) :
∃ n, s ^ n * f = s ^ n * g :=
exists_of_res_eq_of_qcqs (U := ⊤) CompactSpace.isCompact_univ isQuasiSeparated_univ hfg
lemma exists_of_res_zero_of_qcqs {X : Scheme.{u}} {U : TopologicalSpace.Opens X}
(hU : IsCompact U.carrier) (hU' : IsQuasiSeparated U.carrier)
{f s : Γ(X, U)} (hf : f |_ X.basicOpen s = 0) :
∃ n, s ^ n * f = 0 := by
suffices h : ∃ n, s ^ n * f = s ^ n * 0 by
simpa using h
apply exists_of_res_eq_of_qcqs hU hU'
simpa
lemma exists_of_res_zero_of_qcqs_of_top {X : Scheme} [CompactSpace X] [QuasiSeparatedSpace X]
{f s : Γ(X, ⊤)} (hf : f |_ X.basicOpen s = 0) :
∃ n, s ^ n * f = 0 :=
exists_of_res_zero_of_qcqs (U := ⊤) CompactSpace.isCompact_univ isQuasiSeparated_univ hf
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
instance isIso_ΓSpec_adjunction_unit_app_basicOpen
[CompactSpace X] [QuasiSeparatedSpace X] (f : Γ(X, ⊤)) :
IsIso (X.toSpecΓ.app (PrimeSpectrum.basicOpen f)) := by
refine @IsIso.of_isIso_comp_right _ _ _ _ _ _ (X.presheaf.map
(eqToHom (Scheme.toSpecΓ_preimage_basicOpen _ _).symm).op) _ ?_
rw [ConcreteCategory.isIso_iff_bijective]
apply (config := { allowSynthFailures := true }) IsLocalization.bijective
· exact StructureSheaf.IsLocalization.to_basicOpen _ _
· refine isLocalization_basicOpen_of_qcqs ?_ ?_ _
· exact isCompact_univ
· exact isQuasiSeparated_univ
· simp [RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp, RingHom.algebraMap_toAlgebra,
← Functor.map_comp]
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Morphisms/Affine.lean | import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.AlgebraicGeometry.Morphisms.IsIso
/-!
# Affine morphisms of schemes
A morphism of schemes `f : X ⟶ Y` is affine if the preimage
of an arbitrary affine open subset of `Y` is affine.
It is equivalent to ask only that `Y` is covered by affine opens whose preimage is affine.
## Main results
- `AlgebraicGeometry.IsAffineHom`: The class of affine morphisms.
- `AlgebraicGeometry.isAffineOpen_of_isAffineOpen_basicOpen`:
If `s` is a spanning set of `Γ(X, U)`, such that each `X.basicOpen i` is affine,
then `U` is also affine.
- `AlgebraicGeometry.isAffineHom_isStableUnderBaseChange`:
Affine morphisms are stable under base change.
We also provide the instance `HasAffineProperty @IsAffineHom fun X _ _ _ ↦ IsAffine X`.
-/
universe v u
open CategoryTheory Limits TopologicalSpace Opposite
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism of schemes `X ⟶ Y` is affine if
the preimage of any affine open subset of `Y` is affine. -/
@[mk_iff]
class IsAffineHom {X Y : Scheme} (f : X ⟶ Y) : Prop where
isAffine_preimage : ∀ U : Y.Opens, IsAffineOpen U → IsAffineOpen (f ⁻¹ᵁ U)
lemma IsAffineOpen.preimage {X Y : Scheme} {U : Y.Opens} (hU : IsAffineOpen U)
(f : X ⟶ Y) [IsAffineHom f] :
IsAffineOpen (f ⁻¹ᵁ U) :=
IsAffineHom.isAffine_preimage _ hU
@[deprecated (since := "2025-10-07")] alias affinePreimage := IsAffineOpen.preimage
instance (priority := 900) [IsIso f] : IsAffineHom f :=
⟨fun _ hU ↦ hU.preimage_of_isIso f⟩
instance (priority := 900) [IsAffineHom f] : QuasiCompact f :=
quasiCompact_iff_forall_isAffineOpen.mpr fun _ hU ↦ (hU.preimage f).isCompact
instance [IsAffineHom f] [IsAffineHom g] : IsAffineHom (f ≫ g) := by
constructor
intro U hU
rw [Scheme.Hom.comp_base, Opens.map_comp_obj]
apply IsAffineHom.isAffine_preimage
apply IsAffineHom.isAffine_preimage
exact hU
instance : MorphismProperty.IsMultiplicative @IsAffineHom where
id_mem := inferInstance
comp_mem _ _ _ _ := inferInstance
instance {X : Scheme} (r : Γ(X, ⊤)) :
IsAffineHom (X.basicOpen r).ι := by
constructor
intro U hU
fapply (Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion (X.basicOpen r).ι).mp
convert hU.basicOpen (X.presheaf.map (homOfLE le_top).op r)
rw [X.basicOpen_res]
ext1
refine Set.image_preimage_eq_inter_range.trans ?_
simp
lemma isRetrocompact_basicOpen (s : Γ(X, ⊤)) : IsRetrocompact (X := X) (X.basicOpen s) :=
IsRetrocompact_iff_isSpectralMap_subtypeVal.mpr (X.basicOpen s).ι.isSpectralMap
/-- Superseded by `isAffine_of_isAffineOpen_basicOpen`. -/
private lemma isAffine_of_isAffineOpen_basicOpen_aux (s : Set Γ(X, ⊤))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
QuasiSeparatedSpace X := by
rw [quasiSeparatedSpace_iff_forall_affineOpens]
intro U V
obtain ⟨s', hs', e⟩ := (Ideal.span_eq_top_iff_finite _).mp hs
rw [← Set.inter_univ (_ ∩ _), ← Opens.coe_top, ← iSup_basicOpen_of_span_eq_top _ _ e,
← iSup_subtype'', Opens.coe_iSup, Set.inter_iUnion]
apply isCompact_iUnion
intro i
rw [Set.inter_inter_distrib_right]
refine (hs₂ i (hs' i.2)).isQuasiSeparated _ _ Set.inter_subset_right
(U.1.2.inter (X.basicOpen _).2) ?_ Set.inter_subset_right (V.1.2.inter (X.basicOpen _).2) ?_
· rw [← Opens.coe_inf, ← X.basicOpen_res _ (homOfLE le_top).op]
exact (U.2.basicOpen _).isCompact
· rw [← Opens.coe_inf, ← X.basicOpen_res _ (homOfLE le_top).op]
exact (V.2.basicOpen _).isCompact
@[stacks 01QF]
lemma isAffine_of_isAffineOpen_basicOpen (s : Set Γ(X, ⊤))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
IsAffine X := by
have : QuasiSeparatedSpace X := isAffine_of_isAffineOpen_basicOpen_aux s hs hs₂
have : CompactSpace X := by
obtain ⟨s', hs', e⟩ := (Ideal.span_eq_top_iff_finite _).mp hs
rw [← isCompact_univ_iff, ← Opens.coe_top, ← iSup_basicOpen_of_span_eq_top _ _ e]
simp only [Finset.mem_coe, Opens.iSup_mk, Opens.carrier_eq_coe, Opens.coe_mk]
apply s'.isCompact_biUnion
exact fun i hi ↦ (hs₂ _ (hs' hi)).isCompact
constructor
refine HasAffineProperty.of_iSup_eq_top (P := MorphismProperty.isomorphisms Scheme)
(fun i : s ↦ ⟨PrimeSpectrum.basicOpen i.1, ?_⟩) ?_ (fun i ↦ ⟨?_, ?_⟩)
· change IsAffineOpen _
simp only [← basicOpen_eq_of_affine]
exact (isAffineOpen_top (Scheme.Spec.obj (op _))).basicOpen _
· rw [PrimeSpectrum.iSup_basicOpen_eq_top_iff, Subtype.range_coe_subtype, Set.setOf_mem_eq, hs]
· rw [Scheme.toSpecΓ_preimage_basicOpen]
exact hs₂ _ i.2
· simp only [Opens.map_top, morphismRestrict_app]
refine IsIso.comp_isIso' ?_ inferInstance
convert isIso_ΓSpec_adjunction_unit_app_basicOpen i.1 using 0
exact congr(IsIso ((ΓSpec.adjunction.unit.app X).app $(by simp)))
/--
If `s` is a spanning set of `Γ(X, U)`, such that each `X.basicOpen i` is affine, then `U` is also
affine.
-/
lemma isAffineOpen_of_isAffineOpen_basicOpen (U) (s : Set Γ(X, U))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
IsAffineOpen U := by
apply isAffine_of_isAffineOpen_basicOpen (U.topIso.inv '' s)
· rw [← Ideal.map_span U.topIso.inv.hom, hs, Ideal.map_top]
· rintro _ ⟨j, hj, rfl⟩
rw [← (Scheme.Opens.ι _).isAffineOpen_iff_of_isOpenImmersion, Scheme.image_basicOpen]
simpa [Scheme.Opens.toScheme_presheaf_obj] using hs₂ j hj
instance : HasAffineProperty @IsAffineHom fun X _ _ _ ↦ IsAffine X where
isLocal_affineProperty := by
constructor
· apply AffineTargetMorphismProperty.respectsIso_mk
· rintro X Y Z e _ _ H
have : IsAffine _ := H
exact .of_isIso e.hom
· exact fun _ _ _ ↦ id
· intro X Y _ f r H
have : IsAffine X := H
change IsAffineOpen _
rw [Scheme.preimage_basicOpen]
exact (isAffineOpen_top X).basicOpen _
· intro X Y _ f S hS hS'
apply_fun Ideal.map (f.appTop).hom at hS
rw [Ideal.map_span, Ideal.map_top] at hS
apply isAffine_of_isAffineOpen_basicOpen _ hS
have : ∀ i : S, IsAffineOpen (f⁻¹ᵁ Y.basicOpen i.1) := hS'
simpa [Scheme.preimage_basicOpen] using this
eq_targetAffineLocally' := by
ext X Y f
simp only [targetAffineLocally, Scheme.affineOpens, Set.coe_setOf, Set.mem_setOf_eq,
Subtype.forall, isAffineHom_iff]
rfl
instance isAffineHom_isStableUnderBaseChange :
MorphismProperty.IsStableUnderBaseChange @IsAffineHom := by
apply HasAffineProperty.isStableUnderBaseChange
letI := HasAffineProperty.isLocal_affineProperty
apply AffineTargetMorphismProperty.IsStableUnderBaseChange.mk
introv X hX H
infer_instance
instance (priority := 100) isAffineHom_of_isAffine [IsAffine X] [IsAffine Y] : IsAffineHom f :=
(HasAffineProperty.iff_of_isAffine (P := @IsAffineHom)).mpr inferInstance
lemma isAffine_of_isAffineHom [IsAffineHom f] [IsAffine Y] : IsAffine X :=
(HasAffineProperty.iff_of_isAffine (P := @IsAffineHom) (f := f)).mp inferInstance
lemma isAffineHom_of_forall_exists_isAffineOpen
(H : ∀ x : Y, ∃ U : Y.Opens, x ∈ U ∧ IsAffineOpen U ∧ IsAffineOpen (f ⁻¹ᵁ U)) :
IsAffineHom f := by
choose U hxU hU hfU using H
rw [HasAffineProperty.iff_of_iSup_eq_top (P := @IsAffineHom) fun i ↦ ⟨U i, hU i⟩]
· exact hfU
· exact top_le_iff.mp (fun x _ ↦ by simpa using ⟨x, hxU x⟩)
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffineHom f] [IsAffine Y] :
IsAffine (pullback f g) :=
letI : IsAffineHom (pullback.snd f g) := MorphismProperty.pullback_snd _ _ ‹_›
isAffine_of_isAffineHom (pullback.snd f g)
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffineHom g] [IsAffine X] :
IsAffine (pullback f g) :=
letI : IsAffineHom (pullback.fst f g) := MorphismProperty.pullback_fst _ _ ‹_›
isAffine_of_isAffineHom (pullback.fst f g)
/-- If the underlying map of a morphism is inducing and has closed range, then it is affine. -/
@[stacks 04DE]
lemma isAffineHom_of_isInducing
(hf₁ : Topology.IsInducing f)
(hf₂ : IsClosed (Set.range f)) :
IsAffineHom f := by
apply isAffineHom_of_forall_exists_isAffineOpen
intro y
by_cases hy : y ∈ Set.range f
· obtain ⟨x, rfl⟩ := hy
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ (f x)) isOpen_univ
obtain ⟨_, ⟨V, hV, rfl⟩, hxV, hVU⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open hxU (f ⁻¹ᵁ U).isOpen
obtain ⟨U', hU'U, rfl⟩ : ∃ U' : Y.Opens, U' ≤ U ∧ f ⁻¹ᵁ U' = V := by
obtain ⟨U', hU', e⟩ := hf₁.isOpen_iff.mp V.2
exact ⟨⟨U', hU'⟩ ⊓ U, inf_le_right, Opens.ext (by simpa [e] using hVU)⟩
obtain ⟨r, hrU', hxr⟩ := hU.exists_basicOpen_le ⟨f x, hxV⟩ hxU
refine ⟨_, hxr, hU.basicOpen r, ?_⟩
convert hV.basicOpen (f.app _ (Y.presheaf.map (homOfLE hU'U).op r)) using 1
simp only [Scheme.preimage_basicOpen, ← CommRingCat.comp_apply, f.naturality]
simpa using ((Opens.map f.base).map (homOfLE hrU')).le
· obtain ⟨_, ⟨U, hU, rfl⟩, hyU, hU'⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open hy hf₂.isOpen_compl
rw [Set.subset_compl_iff_disjoint_right, ← Set.preimage_eq_empty_iff] at hU'
refine ⟨U, hyU, hU, ?_⟩
convert isAffineOpen_bot _
exact Opens.ext hU'
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/NormalForms.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange
import Mathlib.Algebra.CharP.Defs
/-!
# Some normal forms of elliptic curves
This file defines some normal forms of Weierstrass equations of elliptic curves.
## Main definitions and results
The following normal forms are in [silverman2009], section III.1, page 42.
- `WeierstrassCurve.IsCharNeTwoNF` is a type class which asserts that a `WeierstrassCurve` is
of form `Y² = X³ + a₂X² + a₄X + a₆`. It is the normal form of characteristic ≠ 2.
If 2 is invertible in the ring (for example, if it is a field of characteristic ≠ 2),
then for any `WeierstrassCurve` there exists a change of variables which will change
it into such normal form (`WeierstrassCurve.exists_variableChange_isCharNeTwoNF`).
See also `WeierstrassCurve.toCharNeTwoNF` and `WeierstrassCurve.toCharNeTwoNF_spec`.
The following normal forms are in [silverman2009], Appendix A, Proposition 1.1.
- `WeierstrassCurve.IsShortNF` is a type class which asserts that a `WeierstrassCurve` is
of form `Y² = X³ + a₄X + a₆`. It is the normal form of characteristic ≠ 2 or 3, and
also the normal form of characteristic = 3 and j = 0.
If 2 and 3 are invertible in the ring (for example, if it is a field of characteristic ≠ 2 or 3),
then for any `WeierstrassCurve` there exists a change of variables which will change
it into such normal form (`WeierstrassCurve.exists_variableChange_isShortNF`).
See also `WeierstrassCurve.toShortNF` and `WeierstrassCurve.toShortNF_spec`.
If the ring is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ = 0` (for an
elliptic curve, this is equivalent to j = 0), there exists a change of variables which will
change it into such normal form (see `WeierstrassCurve.toShortNFOfCharThree`
and `WeierstrassCurve.toShortNFOfCharThree_spec`).
- `WeierstrassCurve.IsCharThreeJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is
of form `Y² = X³ + a₂X² + a₆`. It is the normal form of characteristic = 3 and j ≠ 0.
If the field is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ ≠ 0` (for an
elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will
change it into such normal form (see `WeierstrassCurve.toCharThreeNF`
and `WeierstrassCurve.toCharThreeNF_spec_of_b₂_ne_zero`).
- `WeierstrassCurve.IsCharThreeNF` is the combination of the above two, that is, asserts that
a `WeierstrassCurve` is of form `Y² = X³ + a₂X² + a₆` or `Y² = X³ + a₄X + a₆`.
It is the normal form of characteristic = 3.
If the field is of characteristic = 3, then for any `WeierstrassCurve` there exists a change of
variables which will change it into such normal form
(`WeierstrassCurve.exists_variableChange_isCharThreeNF`).
See also `WeierstrassCurve.toCharThreeNF` and `WeierstrassCurve.toCharThreeNF_spec`.
- `WeierstrassCurve.IsCharTwoJEqZeroNF` is a type class which asserts that a `WeierstrassCurve` is
of form `Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2 and j = 0.
If the ring is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ = 0` (for an
elliptic curve, this is equivalent to j = 0), there exists a change of variables which will
change it into such normal form (see `WeierstrassCurve.toCharTwoJEqZeroNF`
and `WeierstrassCurve.toCharTwoJEqZeroNF_spec`).
- `WeierstrassCurve.IsCharTwoJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is
of form `Y² + XY = X³ + a₂X² + a₆`. It is the normal form of characteristic = 2 and j ≠ 0.
If the field is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ ≠ 0` (for an
elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will
change it into such normal form (see `WeierstrassCurve.toCharTwoJNeZeroNF`
and `WeierstrassCurve.toCharTwoJNeZeroNF_spec`).
- `WeierstrassCurve.IsCharTwoNF` is the combination of the above two, that is, asserts that
a `WeierstrassCurve` is of form `Y² + XY = X³ + a₂X² + a₆` or
`Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2.
If the field is of characteristic = 2, then for any `WeierstrassCurve` there exists a change of
variables which will change it into such normal form
(`WeierstrassCurve.exists_variableChange_isCharTwoNF`).
See also `WeierstrassCurve.toCharTwoNF` and `WeierstrassCurve.toCharTwoNF_spec`.
## References
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, normal form
-/
variable {R : Type*} [CommRing R] {F : Type*} [Field F] (W : WeierstrassCurve R)
namespace WeierstrassCurve
/-! ## Normal forms of characteristic ≠ 2 -/
/-- A `WeierstrassCurve` is in normal form of characteristic ≠ 2, if its `a₁, a₃ = 0`.
In other words it is `Y² = X³ + a₂X² + a₄X + a₆`. -/
@[mk_iff]
class IsCharNeTwoNF : Prop where
a₁ : W.a₁ = 0
a₃ : W.a₃ = 0
section Quantity
variable [W.IsCharNeTwoNF]
@[simp]
theorem a₁_of_isCharNeTwoNF : W.a₁ = 0 := IsCharNeTwoNF.a₁
@[simp]
theorem a₃_of_isCharNeTwoNF : W.a₃ = 0 := IsCharNeTwoNF.a₃
@[simp]
theorem b₂_of_isCharNeTwoNF : W.b₂ = 4 * W.a₂ := by
rw [b₂, a₁_of_isCharNeTwoNF]
ring1
@[simp]
theorem b₄_of_isCharNeTwoNF : W.b₄ = 2 * W.a₄ := by
rw [b₄, a₃_of_isCharNeTwoNF]
ring1
@[simp]
theorem b₆_of_isCharNeTwoNF : W.b₆ = 4 * W.a₆ := by
rw [b₆, a₃_of_isCharNeTwoNF]
ring1
@[simp]
theorem b₈_of_isCharNeTwoNF : W.b₈ = 4 * W.a₂ * W.a₆ - W.a₄ ^ 2 := by
rw [b₈, a₁_of_isCharNeTwoNF, a₃_of_isCharNeTwoNF]
ring1
@[simp]
theorem c₄_of_isCharNeTwoNF : W.c₄ = 16 * W.a₂ ^ 2 - 48 * W.a₄ := by
rw [c₄, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF]
ring1
@[simp]
theorem c₆_of_isCharNeTwoNF : W.c₆ = -64 * W.a₂ ^ 3 + 288 * W.a₂ * W.a₄ - 864 * W.a₆ := by
rw [c₆, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF]
ring1
@[simp]
theorem Δ_of_isCharNeTwoNF : W.Δ = -64 * W.a₂ ^ 3 * W.a₆ + 16 * W.a₂ ^ 2 * W.a₄ ^ 2 - 64 * W.a₄ ^ 3
- 432 * W.a₆ ^ 2 + 288 * W.a₂ * W.a₄ * W.a₆ := by
rw [Δ, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF, b₈_of_isCharNeTwoNF]
ring1
end Quantity
section VariableChange
variable [Invertible (2 : R)]
/-- There is an explicit change of variables of a `WeierstrassCurve` to
a normal form of characteristic ≠ 2, provided that 2 is invertible in the ring. -/
@[simps]
def toCharNeTwoNF : VariableChange R := ⟨1, 0, ⅟2 * -W.a₁, ⅟2 * -W.a₃⟩
instance toCharNeTwoNF_spec : (W.toCharNeTwoNF • W).IsCharNeTwoNF := by
constructor <;> simp [variableChange_a₁, variableChange_a₃]
theorem exists_variableChange_isCharNeTwoNF : ∃ C : VariableChange R, (C • W).IsCharNeTwoNF :=
⟨_, W.toCharNeTwoNF_spec⟩
end VariableChange
/-! ## Short normal form -/
/-- A `WeierstrassCurve` is in short normal form, if its `a₁, a₂, a₃ = 0`.
In other words it is `Y² = X³ + a₄X + a₆`.
This is the normal form of characteristic ≠ 2 or 3, and
also the normal form of characteristic = 3 and j = 0. -/
@[mk_iff]
class IsShortNF : Prop where
a₁ : W.a₁ = 0
a₂ : W.a₂ = 0
a₃ : W.a₃ = 0
section Quantity
variable [W.IsShortNF]
instance isCharNeTwoNF_of_isShortNF : W.IsCharNeTwoNF := ⟨IsShortNF.a₁, IsShortNF.a₃⟩
theorem a₁_of_isShortNF : W.a₁ = 0 := IsShortNF.a₁
@[simp]
theorem a₂_of_isShortNF : W.a₂ = 0 := IsShortNF.a₂
theorem a₃_of_isShortNF : W.a₃ = 0 := IsShortNF.a₃
theorem b₂_of_isShortNF : W.b₂ = 0 := by
simp
theorem b₄_of_isShortNF : W.b₄ = 2 * W.a₄ := W.b₄_of_isCharNeTwoNF
theorem b₆_of_isShortNF : W.b₆ = 4 * W.a₆ := W.b₆_of_isCharNeTwoNF
theorem b₈_of_isShortNF : W.b₈ = -W.a₄ ^ 2 := by
simp
theorem c₄_of_isShortNF : W.c₄ = -48 * W.a₄ := by
simp
theorem c₆_of_isShortNF : W.c₆ = -864 * W.a₆ := by
simp
theorem Δ_of_isShortNF : W.Δ = -16 * (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by
rw [Δ_of_isCharNeTwoNF, a₂_of_isShortNF]
ring1
variable [CharP R 3]
theorem b₄_of_isShortNF_of_char_three : W.b₄ = -W.a₄ := by
rw [b₄_of_isShortNF]
linear_combination W.a₄ * CharP.cast_eq_zero R 3
theorem b₆_of_isShortNF_of_char_three : W.b₆ = W.a₆ := by
rw [b₆_of_isShortNF]
linear_combination W.a₆ * CharP.cast_eq_zero R 3
theorem c₄_of_isShortNF_of_char_three : W.c₄ = 0 := by
rw [c₄_of_isShortNF]
linear_combination -16 * W.a₄ * CharP.cast_eq_zero R 3
theorem c₆_of_isShortNF_of_char_three : W.c₆ = 0 := by
rw [c₆_of_isShortNF]
linear_combination -288 * W.a₆ * CharP.cast_eq_zero R 3
theorem Δ_of_isShortNF_of_char_three : W.Δ = -W.a₄ ^ 3 := by
rw [Δ_of_isShortNF]
linear_combination (-21 * W.a₄ ^ 3 - 144 * W.a₆ ^ 2) * CharP.cast_eq_zero R 3
variable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsShortNF]
theorem j_of_isShortNF : W.j = 6912 * W.a₄ ^ 3 / (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by
have h := W.Δ'.ne_zero
rw [coe_Δ', Δ_of_isShortNF] at h
rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',
c₄_of_isShortNF, Δ_of_isShortNF, div_eq_div_iff h (right_ne_zero_of_mul h)]
ring1
@[simp]
theorem j_of_isShortNF_of_char_three [CharP F 3] : W.j = 0 := by
rw [j, c₄_of_isShortNF_of_char_three]; simp
end Quantity
section VariableChange
variable [Invertible (2 : R)] [Invertible (3 : R)]
/-- There is an explicit change of variables of a `WeierstrassCurve` to
a short normal form, provided that 2 and 3 are invertible in the ring.
It is the composition of an explicit change of variables with `WeierstrassCurve.toCharNeTwoNF`. -/
def toShortNF : VariableChange R :=
⟨1, ⅟3 * -(W.toCharNeTwoNF • W).a₂, 0, 0⟩ * W.toCharNeTwoNF
instance toShortNF_spec : (W.toShortNF • W).IsShortNF := by
rw [toShortNF, mul_smul]
constructor <;> simp [variableChange_a₁, variableChange_a₂, variableChange_a₃]
theorem exists_variableChange_isShortNF : ∃ C : VariableChange R, (C • W).IsShortNF :=
⟨_, W.toShortNF_spec⟩
end VariableChange
/-! ## Normal forms of characteristic = 3 and j ≠ 0 -/
/-- A `WeierstrassCurve` is in normal form of characteristic = 3 and j ≠ 0, if its
`a₁, a₃, a₄ = 0`. In other words it is `Y² = X³ + a₂X² + a₆`. -/
@[mk_iff]
class IsCharThreeJNeZeroNF : Prop where
a₁ : W.a₁ = 0
a₃ : W.a₃ = 0
a₄ : W.a₄ = 0
section Quantity
variable [W.IsCharThreeJNeZeroNF]
instance isCharNeTwoNF_of_isCharThreeJNeZeroNF : W.IsCharNeTwoNF :=
⟨IsCharThreeJNeZeroNF.a₁, IsCharThreeJNeZeroNF.a₃⟩
theorem a₁_of_isCharThreeJNeZeroNF : W.a₁ = 0 := IsCharThreeJNeZeroNF.a₁
theorem a₃_of_isCharThreeJNeZeroNF : W.a₃ = 0 := IsCharThreeJNeZeroNF.a₃
@[simp]
theorem a₄_of_isCharThreeJNeZeroNF : W.a₄ = 0 := IsCharThreeJNeZeroNF.a₄
theorem b₂_of_isCharThreeJNeZeroNF : W.b₂ = 4 * W.a₂ := W.b₂_of_isCharNeTwoNF
theorem b₄_of_isCharThreeJNeZeroNF : W.b₄ = 0 := by
simp
theorem b₆_of_isCharThreeJNeZeroNF : W.b₆ = 4 * W.a₆ := W.b₆_of_isCharNeTwoNF
theorem b₈_of_isCharThreeJNeZeroNF : W.b₈ = 4 * W.a₂ * W.a₆ := by
simp
theorem c₄_of_isCharThreeJNeZeroNF : W.c₄ = 16 * W.a₂ ^ 2 := by
simp
theorem c₆_of_isCharThreeJNeZeroNF : W.c₆ = -64 * W.a₂ ^ 3 - 864 * W.a₆ := by
simp
theorem Δ_of_isCharThreeJNeZeroNF : W.Δ = -64 * W.a₂ ^ 3 * W.a₆ - 432 * W.a₆ ^ 2 := by
simp
variable [CharP R 3]
theorem b₂_of_isCharThreeJNeZeroNF_of_char_three : W.b₂ = W.a₂ := by
rw [b₂_of_isCharThreeJNeZeroNF]
linear_combination W.a₂ * CharP.cast_eq_zero R 3
theorem b₆_of_isCharThreeJNeZeroNF_of_char_three : W.b₆ = W.a₆ := by
rw [b₆_of_isCharThreeJNeZeroNF]
linear_combination W.a₆ * CharP.cast_eq_zero R 3
theorem b₈_of_isCharThreeJNeZeroNF_of_char_three : W.b₈ = W.a₂ * W.a₆ := by
rw [b₈_of_isCharThreeJNeZeroNF]
linear_combination W.a₂ * W.a₆ * CharP.cast_eq_zero R 3
theorem c₄_of_isCharThreeJNeZeroNF_of_char_three : W.c₄ = W.a₂ ^ 2 := by
rw [c₄_of_isCharThreeJNeZeroNF]
linear_combination 5 * W.a₂ ^ 2 * CharP.cast_eq_zero R 3
theorem c₆_of_isCharThreeJNeZeroNF_of_char_three : W.c₆ = -W.a₂ ^ 3 := by
rw [c₆_of_isCharThreeJNeZeroNF]
linear_combination (-21 * W.a₂ ^ 3 - 288 * W.a₆) * CharP.cast_eq_zero R 3
theorem Δ_of_isCharThreeJNeZeroNF_of_char_three : W.Δ = -W.a₂ ^ 3 * W.a₆ := by
rw [Δ_of_isCharThreeJNeZeroNF]
linear_combination (-21 * W.a₂ ^ 3 * W.a₆ - 144 * W.a₆ ^ 2) * CharP.cast_eq_zero R 3
variable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsCharThreeJNeZeroNF] [CharP F 3]
@[simp]
theorem j_of_isCharThreeJNeZeroNF_of_char_three : W.j = -W.a₂ ^ 3 / W.a₆ := by
have h := W.Δ'.ne_zero
rw [coe_Δ', Δ_of_isCharThreeJNeZeroNF_of_char_three] at h
rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',
c₄_of_isCharThreeJNeZeroNF_of_char_three, Δ_of_isCharThreeJNeZeroNF_of_char_three,
div_eq_div_iff h (right_ne_zero_of_mul h)]
ring1
theorem j_ne_zero_of_isCharThreeJNeZeroNF_of_char_three : W.j ≠ 0 := by
rw [j_of_isCharThreeJNeZeroNF_of_char_three, div_ne_zero_iff]
have h := W.Δ'.ne_zero
rwa [coe_Δ', Δ_of_isCharThreeJNeZeroNF_of_char_three, mul_ne_zero_iff] at h
end Quantity
/-! ## Normal forms of characteristic = 3 -/
/-- A `WeierstrassCurve` is in normal form of characteristic = 3, if it is
`Y² = X³ + a₂X² + a₆` (`WeierstrassCurve.IsCharThreeJNeZeroNF`) or
`Y² = X³ + a₄X + a₆` (`WeierstrassCurve.IsShortNF`). -/
class inductive IsCharThreeNF : Prop
| of_j_ne_zero [W.IsCharThreeJNeZeroNF] : IsCharThreeNF
| of_j_eq_zero [W.IsShortNF] : IsCharThreeNF
instance isCharThreeNF_of_isCharThreeJNeZeroNF [W.IsCharThreeJNeZeroNF] : W.IsCharThreeNF :=
IsCharThreeNF.of_j_ne_zero
instance isCharThreeNF_of_isShortNF [W.IsShortNF] : W.IsCharThreeNF :=
IsCharThreeNF.of_j_eq_zero
instance isCharNeTwoNF_of_isCharThreeNF [W.IsCharThreeNF] : W.IsCharNeTwoNF := by
cases ‹W.IsCharThreeNF› <;> infer_instance
section VariableChange
variable [CharP R 3] [CharP F 3]
/-- For a `WeierstrassCurve` defined over a ring of characteristic = 3,
there is an explicit change of variables of it to `Y² = X³ + a₄X + a₆`
(`WeierstrassCurve.IsShortNF`) if its j = 0.
This is in fact given by `WeierstrassCurve.toCharNeTwoNF`. -/
def toShortNFOfCharThree : VariableChange R :=
have h : (2 : R) * 2 = 1 := by linear_combination CharP.cast_eq_zero R 3
letI : Invertible (2 : R) := ⟨2, h, h⟩
W.toCharNeTwoNF
lemma toShortNFOfCharThree_a₂ : (W.toShortNFOfCharThree • W).a₂ = W.b₂ := by
simp_rw [toShortNFOfCharThree, toCharNeTwoNF, variableChange_a₂, inv_one, Units.val_one, b₂]
linear_combination (-W.a₂ - W.a₁ ^ 2) * CharP.cast_eq_zero R 3
theorem toShortNFOfCharThree_spec (hb₂ : W.b₂ = 0) : (W.toShortNFOfCharThree • W).IsShortNF := by
have h : (2 : R) * 2 = 1 := by linear_combination CharP.cast_eq_zero R 3
letI : Invertible (2 : R) := ⟨2, h, h⟩
have H := W.toCharNeTwoNF_spec
exact ⟨H.a₁, hb₂ ▸ W.toShortNFOfCharThree_a₂, H.a₃⟩
variable (W : WeierstrassCurve F)
/-- For a `WeierstrassCurve` defined over a field of characteristic = 3,
there is an explicit change of variables of it to `WeierstrassCurve.IsCharThreeNF`, that is,
`Y² = X³ + a₂X² + a₆` (`WeierstrassCurve.IsCharThreeJNeZeroNF`) or
`Y² = X³ + a₄X + a₆` (`WeierstrassCurve.IsShortNF`).
It is the composition of an explicit change of variables with
`WeierstrassCurve.toShortNFOfCharThree`. -/
def toCharThreeNF : VariableChange F :=
⟨1, (W.toShortNFOfCharThree • W).a₄ /
(W.toShortNFOfCharThree • W).a₂, 0, 0⟩ * W.toShortNFOfCharThree
theorem toCharThreeNF_spec_of_b₂_ne_zero (hb₂ : W.b₂ ≠ 0) :
(W.toCharThreeNF • W).IsCharThreeJNeZeroNF := by
have h : (2 : F) * 2 = 1 := by linear_combination CharP.cast_eq_zero F 3
letI : Invertible (2 : F) := ⟨2, h, h⟩
rw [toCharThreeNF, mul_smul]
set W' := W.toShortNFOfCharThree • W
haveI : W'.IsCharNeTwoNF := W.toCharNeTwoNF_spec
constructor
· simp [variableChange_a₁]
· simp [variableChange_a₃]
· have ha₂ : W'.a₂ ≠ 0 := W.toShortNFOfCharThree_a₂ ▸ hb₂
simp [field, variableChange_a₄, -mul_eq_zero]
linear_combination (W'.a₄ * W'.a₂ ^ 2 + W'.a₄ ^ 2) * CharP.cast_eq_zero F 3
theorem toCharThreeNF_spec_of_b₂_eq_zero (hb₂ : W.b₂ = 0) : (W.toCharThreeNF • W).IsShortNF := by
rw [toCharThreeNF, toShortNFOfCharThree_a₂, hb₂, div_zero, ← VariableChange.one_def, one_mul]
exact W.toShortNFOfCharThree_spec hb₂
instance toCharThreeNF_spec : (W.toCharThreeNF • W).IsCharThreeNF := by
by_cases hb₂ : W.b₂ = 0
· haveI := W.toCharThreeNF_spec_of_b₂_eq_zero hb₂
infer_instance
· haveI := W.toCharThreeNF_spec_of_b₂_ne_zero hb₂
infer_instance
theorem exists_variableChange_isCharThreeNF : ∃ C : VariableChange F, (C • W).IsCharThreeNF :=
⟨_, W.toCharThreeNF_spec⟩
end VariableChange
/-! ## Normal forms of characteristic = 2 and j ≠ 0 -/
/-- A `WeierstrassCurve` is in normal form of characteristic = 2 and j ≠ 0, if its `a₁ = 1` and
`a₃, a₄ = 0`. In other words it is `Y² + XY = X³ + a₂X² + a₆`. -/
@[mk_iff]
class IsCharTwoJNeZeroNF : Prop where
a₁ : W.a₁ = 1
a₃ : W.a₃ = 0
a₄ : W.a₄ = 0
section Quantity
variable [W.IsCharTwoJNeZeroNF]
@[simp]
theorem a₁_of_isCharTwoJNeZeroNF : W.a₁ = 1 := IsCharTwoJNeZeroNF.a₁
@[simp]
theorem a₃_of_isCharTwoJNeZeroNF : W.a₃ = 0 := IsCharTwoJNeZeroNF.a₃
@[simp]
theorem a₄_of_isCharTwoJNeZeroNF : W.a₄ = 0 := IsCharTwoJNeZeroNF.a₄
@[simp]
theorem b₂_of_isCharTwoJNeZeroNF : W.b₂ = 1 + 4 * W.a₂ := by
rw [b₂, a₁_of_isCharTwoJNeZeroNF]
ring1
@[simp]
theorem b₄_of_isCharTwoJNeZeroNF : W.b₄ = 0 := by
rw [b₄, a₃_of_isCharTwoJNeZeroNF, a₄_of_isCharTwoJNeZeroNF]
ring1
@[simp]
theorem b₆_of_isCharTwoJNeZeroNF : W.b₆ = 4 * W.a₆ := by
rw [b₆, a₃_of_isCharTwoJNeZeroNF]
ring1
@[simp]
theorem b₈_of_isCharTwoJNeZeroNF : W.b₈ = W.a₆ + 4 * W.a₂ * W.a₆ := by
rw [b₈, a₁_of_isCharTwoJNeZeroNF, a₃_of_isCharTwoJNeZeroNF, a₄_of_isCharTwoJNeZeroNF]
ring1
@[simp]
theorem c₄_of_isCharTwoJNeZeroNF : W.c₄ = W.b₂ ^ 2 := by
rw [c₄, b₄_of_isCharTwoJNeZeroNF]
ring1
@[simp]
theorem c₆_of_isCharTwoJNeZeroNF : W.c₆ = -W.b₂ ^ 3 - 864 * W.a₆ := by
rw [c₆, b₄_of_isCharTwoJNeZeroNF, b₆_of_isCharTwoJNeZeroNF]
ring1
variable [CharP R 2]
theorem b₂_of_isCharTwoJNeZeroNF_of_char_two : W.b₂ = 1 := by
rw [b₂_of_isCharTwoJNeZeroNF]
linear_combination 2 * W.a₂ * CharP.cast_eq_zero R 2
theorem b₆_of_isCharTwoJNeZeroNF_of_char_two : W.b₆ = 0 := by
rw [b₆_of_isCharTwoJNeZeroNF]
linear_combination 2 * W.a₆ * CharP.cast_eq_zero R 2
theorem b₈_of_isCharTwoJNeZeroNF_of_char_two : W.b₈ = W.a₆ := by
rw [b₈_of_isCharTwoJNeZeroNF]
linear_combination 2 * W.a₂ * W.a₆ * CharP.cast_eq_zero R 2
theorem c₄_of_isCharTwoJNeZeroNF_of_char_two : W.c₄ = 1 := by
rw [c₄_of_isCharTwoJNeZeroNF, b₂_of_isCharTwoJNeZeroNF_of_char_two]
ring1
theorem c₆_of_isCharTwoJNeZeroNF_of_char_two : W.c₆ = 1 := by
rw [c₆_of_isCharTwoJNeZeroNF, b₂_of_isCharTwoJNeZeroNF_of_char_two]
linear_combination (-1 - 432 * W.a₆) * CharP.cast_eq_zero R 2
@[simp]
theorem Δ_of_isCharTwoJNeZeroNF_of_char_two : W.Δ = W.a₆ := by
rw [Δ, b₂_of_isCharTwoJNeZeroNF_of_char_two, b₄_of_isCharTwoJNeZeroNF,
b₆_of_isCharTwoJNeZeroNF_of_char_two, b₈_of_isCharTwoJNeZeroNF_of_char_two]
linear_combination -W.a₆ * CharP.cast_eq_zero R 2
variable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsCharTwoJNeZeroNF] [CharP F 2]
@[simp]
theorem j_of_isCharTwoJNeZeroNF_of_char_two : W.j = 1 / W.a₆ := by
rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',
c₄_of_isCharTwoJNeZeroNF_of_char_two, Δ_of_isCharTwoJNeZeroNF_of_char_two, one_pow]
theorem j_ne_zero_of_isCharTwoJNeZeroNF_of_char_two : W.j ≠ 0 := by
rw [j_of_isCharTwoJNeZeroNF_of_char_two, div_ne_zero_iff]
have h := W.Δ'.ne_zero
rw [coe_Δ', Δ_of_isCharTwoJNeZeroNF_of_char_two] at h
exact ⟨one_ne_zero, h⟩
end Quantity
/-! ## Normal forms of characteristic = 2 and j = 0 -/
/-- A `WeierstrassCurve` is in normal form of characteristic = 2 and j = 0, if its `a₁, a₂ = 0`.
In other words it is `Y² + a₃Y = X³ + a₄X + a₆`. -/
@[mk_iff]
class IsCharTwoJEqZeroNF : Prop where
a₁ : W.a₁ = 0
a₂ : W.a₂ = 0
section Quantity
variable [W.IsCharTwoJEqZeroNF]
@[simp]
theorem a₁_of_isCharTwoJEqZeroNF : W.a₁ = 0 := IsCharTwoJEqZeroNF.a₁
@[simp]
theorem a₂_of_isCharTwoJEqZeroNF : W.a₂ = 0 := IsCharTwoJEqZeroNF.a₂
@[simp]
theorem b₂_of_isCharTwoJEqZeroNF : W.b₂ = 0 := by
rw [b₂, a₁_of_isCharTwoJEqZeroNF, a₂_of_isCharTwoJEqZeroNF]
ring1
@[simp]
theorem b₄_of_isCharTwoJEqZeroNF : W.b₄ = 2 * W.a₄ := by
rw [b₄, a₁_of_isCharTwoJEqZeroNF]
ring1
@[simp]
theorem b₈_of_isCharTwoJEqZeroNF : W.b₈ = -W.a₄ ^ 2 := by
rw [b₈, a₁_of_isCharTwoJEqZeroNF, a₂_of_isCharTwoJEqZeroNF]
ring1
@[simp]
theorem c₄_of_isCharTwoJEqZeroNF : W.c₄ = -48 * W.a₄ := by
rw [c₄, b₂_of_isCharTwoJEqZeroNF, b₄_of_isCharTwoJEqZeroNF]
ring1
@[simp]
theorem c₆_of_isCharTwoJEqZeroNF : W.c₆ = -216 * W.b₆ := by
rw [c₆, b₂_of_isCharTwoJEqZeroNF, b₄_of_isCharTwoJEqZeroNF]
ring1
@[simp]
theorem Δ_of_isCharTwoJEqZeroNF : W.Δ = -(64 * W.a₄ ^ 3 + 27 * W.b₆ ^ 2) := by
rw [Δ, b₂_of_isCharTwoJEqZeroNF, b₄_of_isCharTwoJEqZeroNF]
ring1
variable [CharP R 2]
theorem b₄_of_isCharTwoJEqZeroNF_of_char_two : W.b₄ = 0 := by
rw [b₄_of_isCharTwoJEqZeroNF]
linear_combination W.a₄ * CharP.cast_eq_zero R 2
theorem b₈_of_isCharTwoJEqZeroNF_of_char_two : W.b₈ = W.a₄ ^ 2 := by
rw [b₈_of_isCharTwoJEqZeroNF]
linear_combination -W.a₄ ^ 2 * CharP.cast_eq_zero R 2
theorem c₄_of_isCharTwoJEqZeroNF_of_char_two : W.c₄ = 0 := by
rw [c₄_of_isCharTwoJEqZeroNF]
linear_combination -24 * W.a₄ * CharP.cast_eq_zero R 2
theorem c₆_of_isCharTwoJEqZeroNF_of_char_two : W.c₆ = 0 := by
rw [c₆_of_isCharTwoJEqZeroNF]
linear_combination -108 * W.b₆ * CharP.cast_eq_zero R 2
theorem Δ_of_isCharTwoJEqZeroNF_of_char_two : W.Δ = W.a₃ ^ 4 := by
rw [Δ_of_isCharTwoJEqZeroNF, b₆_of_char_two]
linear_combination (-32 * W.a₄ ^ 3 - 14 * W.a₃ ^ 4) * CharP.cast_eq_zero R 2
variable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsCharTwoJEqZeroNF]
theorem j_of_isCharTwoJEqZeroNF : W.j = 110592 * W.a₄ ^ 3 / (64 * W.a₄ ^ 3 + 27 * W.b₆ ^ 2) := by
have h := W.Δ'.ne_zero
rw [coe_Δ', Δ_of_isCharTwoJEqZeroNF] at h
rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',
c₄_of_isCharTwoJEqZeroNF, Δ_of_isCharTwoJEqZeroNF, div_eq_div_iff h (neg_ne_zero.1 h)]
ring1
@[simp]
theorem j_of_isCharTwoJEqZeroNF_of_char_two [CharP F 2] : W.j = 0 := by
rw [j, c₄_of_isCharTwoJEqZeroNF_of_char_two]; simp
end Quantity
/-! ## Normal forms of characteristic = 2 -/
/-- A `WeierstrassCurve` is in normal form of characteristic = 2, if it is
`Y² + XY = X³ + a₂X² + a₆` (`WeierstrassCurve.IsCharTwoJNeZeroNF`) or
`Y² + a₃Y = X³ + a₄X + a₆` (`WeierstrassCurve.IsCharTwoJEqZeroNF`). -/
class inductive IsCharTwoNF : Prop
| of_j_ne_zero [W.IsCharTwoJNeZeroNF] : IsCharTwoNF
| of_j_eq_zero [W.IsCharTwoJEqZeroNF] : IsCharTwoNF
instance isCharTwoNF_of_isCharTwoJNeZeroNF [W.IsCharTwoJNeZeroNF] : W.IsCharTwoNF :=
IsCharTwoNF.of_j_ne_zero
instance isCharTwoNF_of_isCharTwoJEqZeroNF [W.IsCharTwoJEqZeroNF] : W.IsCharTwoNF :=
IsCharTwoNF.of_j_eq_zero
section VariableChange
variable [CharP R 2] [CharP F 2]
/-- For a `WeierstrassCurve` defined over a ring of characteristic = 2,
there is an explicit change of variables of it to `Y² + a₃Y = X³ + a₄X + a₆`
(`WeierstrassCurve.IsCharTwoJEqZeroNF`) if its j = 0. -/
def toCharTwoJEqZeroNF : VariableChange R := ⟨1, W.a₂, 0, 0⟩
theorem toCharTwoJEqZeroNF_spec (ha₁ : W.a₁ = 0) :
(W.toCharTwoJEqZeroNF • W).IsCharTwoJEqZeroNF := by
constructor
· simp [toCharTwoJEqZeroNF, ha₁, variableChange_a₁]
· simp_rw [toCharTwoJEqZeroNF, variableChange_a₂, inv_one, Units.val_one]
linear_combination 2 * W.a₂ * CharP.cast_eq_zero R 2
variable (W : WeierstrassCurve F)
/-- For a `WeierstrassCurve` defined over a field of characteristic = 2,
there is an explicit change of variables of it to `Y² + XY = X³ + a₂X² + a₆`
(`WeierstrassCurve.IsCharTwoJNeZeroNF`) if its j ≠ 0. -/
def toCharTwoJNeZeroNF (W : WeierstrassCurve F) (ha₁ : W.a₁ ≠ 0) : VariableChange F :=
⟨Units.mk0 _ ha₁, W.a₃ / W.a₁, 0, (W.a₁ ^ 2 * W.a₄ + W.a₃ ^ 2) / W.a₁ ^ 3⟩
theorem toCharTwoJNeZeroNF_spec (ha₁ : W.a₁ ≠ 0) :
(W.toCharTwoJNeZeroNF ha₁ • W).IsCharTwoJNeZeroNF := by
constructor
· simp [toCharTwoJNeZeroNF, ha₁, variableChange_a₁]
· simp [field, toCharTwoJNeZeroNF, variableChange_a₃, -mul_eq_zero]
linear_combination (W.a₃ * W.a₁ ^ 3 + W.a₁ ^ 2 * W.a₄ + W.a₃ ^ 2) * CharP.cast_eq_zero F 2
· simp [field, toCharTwoJNeZeroNF, variableChange_a₄, -mul_eq_zero]
linear_combination (W.a₃ ^ 2 + W.a₁ * W.a₃ * W.a₂) * CharP.cast_eq_zero F 2
/-- For a `WeierstrassCurve` defined over a field of characteristic = 2,
there is an explicit change of variables of it to `WeierstrassCurve.IsCharTwoNF`, that is,
`Y² + XY = X³ + a₂X² + a₆` (`WeierstrassCurve.IsCharTwoJNeZeroNF`) or
`Y² + a₃Y = X³ + a₄X + a₆` (`WeierstrassCurve.IsCharTwoJEqZeroNF`). -/
def toCharTwoNF [DecidableEq F] : VariableChange F :=
if ha₁ : W.a₁ = 0 then W.toCharTwoJEqZeroNF else W.toCharTwoJNeZeroNF ha₁
instance toCharTwoNF_spec [DecidableEq F] : (W.toCharTwoNF • W).IsCharTwoNF := by
by_cases ha₁ : W.a₁ = 0
· rw [toCharTwoNF, dif_pos ha₁]
haveI := W.toCharTwoJEqZeroNF_spec ha₁
infer_instance
· rw [toCharTwoNF, dif_neg ha₁]
haveI := W.toCharTwoJNeZeroNF_spec ha₁
infer_instance
theorem exists_variableChange_isCharTwoNF : ∃ C : VariableChange F, (C • W).IsCharTwoNF := by
classical
exact ⟨_, W.toCharTwoNF_spec⟩
end VariableChange
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Weierstrass.lean | import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.CubicDiscriminant
import Mathlib.RingTheory.Nilpotent.Defs
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
/-!
# Weierstrass equations of elliptic curves
This file defines the structure of an elliptic curve as a nonsingular Weierstrass curve given by a
Weierstrass equation, which is mathematically accurate in many cases but also good for computation.
## Mathematical background
Let `S` be a scheme. The actual category of elliptic curves over `S` is a large category, whose
objects are schemes `E` equipped with a map `E → S`, a section `S → E`, and some axioms (the map is
smooth and proper and the fibres are geometrically-connected one-dimensional group varieties). In
the special case where `S` is the spectrum of some commutative ring `R` whose Picard group is zero
(this includes all fields, all PIDs, and many other commutative rings) it can be shown (using a lot
of algebro-geometric machinery) that every elliptic curve `E` is a projective plane cubic isomorphic
to a Weierstrass curve given by the equation `Y² + a₁XY + a₃Y = X³ + a₂X² + a₄X + a₆` for some `aᵢ`
in `R`, and such that a certain quantity called the discriminant of `E` is a unit in `R`. If `R` is
a field, this quantity divides the discriminant of a cubic polynomial whose roots over a splitting
field of `R` are precisely the `X`-coordinates of the non-zero 2-torsion points of `E`.
## Main definitions
* `WeierstrassCurve`: a Weierstrass curve over a commutative ring.
* `WeierstrassCurve.Δ`: the discriminant of a Weierstrass curve.
* `WeierstrassCurve.map`: the Weierstrass curve mapped over a ring homomorphism.
* `WeierstrassCurve.twoTorsionPolynomial`: the 2-torsion polynomial of a Weierstrass curve.
* `WeierstrassCurve.IsElliptic`: typeclass asserting that a Weierstrass curve is an elliptic curve.
* `WeierstrassCurve.j`: the j-invariant of an elliptic curve.
## Main statements
* `WeierstrassCurve.twoTorsionPolynomial_discr`: the discriminant of a Weierstrass curve is a
constant factor of the cubic discriminant of its 2-torsion polynomial.
## Implementation notes
The definition of elliptic curves in this file makes sense for all commutative rings `R`, but it
only gives a type which can be beefed up to a category which is equivalent to the category of
elliptic curves over the spectrum `Spec(R)` of `R` in the case that `R` has trivial Picard group
`Pic(R)` or, slightly more generally, when its 12-torsion is trivial. The issue is that for a
general ring `R`, there might be elliptic curves over `Spec(R)` in the sense of algebraic geometry
which are not globally defined by a cubic equation valid over the entire base.
## References
* [N Katz and B Mazur, *Arithmetic Moduli of Elliptic Curves*][katz_mazur]
* [P Deligne, *Courbes Elliptiques: Formulaire (d'après J. Tate)*][deligne_formulaire]
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, j invariant
-/
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow])
universe s u v w
/-! ## Weierstrass curves -/
/-- A Weierstrass curve `Y² + a₁XY + a₃Y = X³ + a₂X² + a₄X + a₆` with parameters `aᵢ`. -/
@[ext]
structure WeierstrassCurve (R : Type u) where
/-- The `a₁` coefficient of a Weierstrass curve. -/
a₁ : R
/-- The `a₂` coefficient of a Weierstrass curve. -/
a₂ : R
/-- The `a₃` coefficient of a Weierstrass curve. -/
a₃ : R
/-- The `a₄` coefficient of a Weierstrass curve. -/
a₄ : R
/-- The `a₆` coefficient of a Weierstrass curve. -/
a₆ : R
namespace WeierstrassCurve
instance {R : Type u} [Inhabited R] : Inhabited <| WeierstrassCurve R :=
⟨⟨default, default, default, default, default⟩⟩
variable {R : Type u} [CommRing R] (W : WeierstrassCurve R)
section Quantity
/-! ### Standard quantities -/
/-- The `b₂` coefficient of a Weierstrass curve. -/
def b₂ : R :=
W.a₁ ^ 2 + 4 * W.a₂
/-- The `b₄` coefficient of a Weierstrass curve. -/
def b₄ : R :=
2 * W.a₄ + W.a₁ * W.a₃
/-- The `b₆` coefficient of a Weierstrass curve. -/
def b₆ : R :=
W.a₃ ^ 2 + 4 * W.a₆
/-- The `b₈` coefficient of a Weierstrass curve. -/
def b₈ : R :=
W.a₁ ^ 2 * W.a₆ + 4 * W.a₂ * W.a₆ - W.a₁ * W.a₃ * W.a₄ + W.a₂ * W.a₃ ^ 2 - W.a₄ ^ 2
lemma b_relation : 4 * W.b₈ = W.b₂ * W.b₆ - W.b₄ ^ 2 := by
simp only [b₂, b₄, b₆, b₈]
ring1
/-- The `c₄` coefficient of a Weierstrass curve. -/
def c₄ : R :=
W.b₂ ^ 2 - 24 * W.b₄
/-- The `c₆` coefficient of a Weierstrass curve. -/
def c₆ : R :=
-W.b₂ ^ 3 + 36 * W.b₂ * W.b₄ - 216 * W.b₆
/-- The discriminant `Δ` of a Weierstrass curve. If `R` is a field, then this polynomial vanishes
if and only if the cubic curve cut out by this equation is singular. Sometimes only defined up to
sign in the literature; we choose the sign used by the LMFDB. For more discussion, see
[the LMFDB page on discriminants](https://www.lmfdb.org/knowledge/show/ec.discriminant). -/
def Δ : R :=
-W.b₂ ^ 2 * W.b₈ - 8 * W.b₄ ^ 3 - 27 * W.b₆ ^ 2 + 9 * W.b₂ * W.b₄ * W.b₆
lemma c_relation : 1728 * W.Δ = W.c₄ ^ 3 - W.c₆ ^ 2 := by
simp only [b₂, b₄, b₆, b₈, c₄, c₆, Δ]
ring1
section CharTwo
variable [CharP R 2]
lemma b₂_of_char_two : W.b₂ = W.a₁ ^ 2 := by
rw [b₂]
linear_combination 2 * W.a₂ * CharP.cast_eq_zero R 2
lemma b₄_of_char_two : W.b₄ = W.a₁ * W.a₃ := by
rw [b₄]
linear_combination W.a₄ * CharP.cast_eq_zero R 2
lemma b₆_of_char_two : W.b₆ = W.a₃ ^ 2 := by
rw [b₆]
linear_combination 2 * W.a₆ * CharP.cast_eq_zero R 2
lemma b₈_of_char_two :
W.b₈ = W.a₁ ^ 2 * W.a₆ + W.a₁ * W.a₃ * W.a₄ + W.a₂ * W.a₃ ^ 2 + W.a₄ ^ 2 := by
rw [b₈]
linear_combination (2 * W.a₂ * W.a₆ - W.a₁ * W.a₃ * W.a₄ - W.a₄ ^ 2) * CharP.cast_eq_zero R 2
lemma c₄_of_char_two : W.c₄ = W.a₁ ^ 4 := by
rw [c₄, b₂_of_char_two]
linear_combination -12 * W.b₄ * CharP.cast_eq_zero R 2
lemma c₆_of_char_two : W.c₆ = W.a₁ ^ 6 := by
rw [c₆, b₂_of_char_two]
linear_combination (18 * W.a₁ ^ 2 * W.b₄ - 108 * W.b₆ - W.a₁ ^ 6) * CharP.cast_eq_zero R 2
lemma Δ_of_char_two : W.Δ = W.a₁ ^ 4 * W.b₈ + W.a₃ ^ 4 + W.a₁ ^ 3 * W.a₃ ^ 3 := by
rw [Δ, b₂_of_char_two, b₄_of_char_two, b₆_of_char_two]
linear_combination (-W.a₁ ^ 4 * W.b₈ - 14 * W.a₃ ^ 4) * CharP.cast_eq_zero R 2
lemma b_relation_of_char_two : W.b₂ * W.b₆ = W.b₄ ^ 2 := by
linear_combination -W.b_relation + 2 * W.b₈ * CharP.cast_eq_zero R 2
lemma c_relation_of_char_two : W.c₄ ^ 3 = W.c₆ ^ 2 := by
linear_combination -W.c_relation + 864 * W.Δ * CharP.cast_eq_zero R 2
end CharTwo
section CharThree
variable [CharP R 3]
lemma b₂_of_char_three : W.b₂ = W.a₁ ^ 2 + W.a₂ := by
rw [b₂]
linear_combination W.a₂ * CharP.cast_eq_zero R 3
lemma b₄_of_char_three : W.b₄ = -W.a₄ + W.a₁ * W.a₃ := by
rw [b₄]
linear_combination W.a₄ * CharP.cast_eq_zero R 3
lemma b₆_of_char_three : W.b₆ = W.a₃ ^ 2 + W.a₆ := by
rw [b₆]
linear_combination W.a₆ * CharP.cast_eq_zero R 3
lemma b₈_of_char_three :
W.b₈ = W.a₁ ^ 2 * W.a₆ + W.a₂ * W.a₆ - W.a₁ * W.a₃ * W.a₄ + W.a₂ * W.a₃ ^ 2 - W.a₄ ^ 2 := by
rw [b₈]
linear_combination W.a₂ * W.a₆ * CharP.cast_eq_zero R 3
lemma c₄_of_char_three : W.c₄ = W.b₂ ^ 2 := by
rw [c₄]
linear_combination -8 * W.b₄ * CharP.cast_eq_zero R 3
lemma c₆_of_char_three : W.c₆ = -W.b₂ ^ 3 := by
rw [c₆]
linear_combination (12 * W.b₂ * W.b₄ - 72 * W.b₆) * CharP.cast_eq_zero R 3
lemma Δ_of_char_three : W.Δ = -W.b₂ ^ 2 * W.b₈ - 8 * W.b₄ ^ 3 := by
rw [Δ]
linear_combination (-9 * W.b₆ ^ 2 + 3 * W.b₂ * W.b₄ * W.b₆) * CharP.cast_eq_zero R 3
lemma b_relation_of_char_three : W.b₈ = W.b₂ * W.b₆ - W.b₄ ^ 2 := by
linear_combination W.b_relation - W.b₈ * CharP.cast_eq_zero R 3
lemma c_relation_of_char_three : W.c₄ ^ 3 = W.c₆ ^ 2 := by
linear_combination -W.c_relation + 576 * W.Δ * CharP.cast_eq_zero R 3
end CharThree
end Quantity
section BaseChange
/-! ### Maps and base changes -/
variable {A : Type v} [CommRing A] (f : R →+* A)
/-- The Weierstrass curve mapped over a ring homomorphism `f : R →+* A`. -/
@[simps]
def map : WeierstrassCurve A :=
⟨f W.a₁, f W.a₂, f W.a₃, f W.a₄, f W.a₆⟩
variable (A) in
/-- The Weierstrass curve base changed to an algebra `A` over `R`. -/
abbrev baseChange [Algebra R A] : WeierstrassCurve A :=
W.map <| algebraMap R A
@[simp]
lemma map_b₂ : (W.map f).b₂ = f W.b₂ := by
simp only [b₂, map_a₁, map_a₂]
map_simp
@[simp]
lemma map_b₄ : (W.map f).b₄ = f W.b₄ := by
simp only [b₄, map_a₁, map_a₃, map_a₄]
map_simp
@[simp]
lemma map_b₆ : (W.map f).b₆ = f W.b₆ := by
simp only [b₆, map_a₃, map_a₆]
map_simp
@[simp]
lemma map_b₈ : (W.map f).b₈ = f W.b₈ := by
simp only [b₈, map_a₁, map_a₂, map_a₃, map_a₄, map_a₆]
map_simp
@[simp]
lemma map_c₄ : (W.map f).c₄ = f W.c₄ := by
simp only [c₄, map_b₂, map_b₄]
map_simp
@[simp]
lemma map_c₆ : (W.map f).c₆ = f W.c₆ := by
simp only [c₆, map_b₂, map_b₄, map_b₆]
map_simp
@[simp]
lemma map_Δ : (W.map f).Δ = f W.Δ := by
simp only [Δ, map_b₂, map_b₄, map_b₆, map_b₈]
map_simp
@[simp]
lemma map_id : W.map (RingHom.id R) = W :=
rfl
lemma map_map {B : Type w} [CommRing B] (g : A →+* B) : (W.map f).map g = W.map (g.comp f) :=
rfl
@[simp]
lemma map_baseChange {S : Type s} [CommRing S] [Algebra R S] {A : Type v} [CommRing A] [Algebra R A]
[Algebra S A] [IsScalarTower R S A] {B : Type w} [CommRing B] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (g : A →ₐ[S] B) : (W.baseChange A).map g = W.baseChange B :=
congr_arg W.map <| g.comp_algebraMap_of_tower R
lemma map_injective {f : R →+* A} (hf : Function.Injective f) :
Function.Injective <| map (f := f) := fun _ _ h => by
rcases mk.inj h with ⟨_, _, _, _, _⟩
ext <;> apply_fun _ using hf <;> assumption
end BaseChange
section TorsionPolynomial
/-! ### 2-torsion polynomials -/
/-- A cubic polynomial whose discriminant is a multiple of the Weierstrass curve discriminant. If
`W` is an elliptic curve over a field `R` of characteristic different from 2, then its roots over a
splitting field of `R` are precisely the `X`-coordinates of the non-zero 2-torsion points of `W`. -/
def twoTorsionPolynomial : Cubic R :=
⟨4, W.b₂, 2 * W.b₄, W.b₆⟩
lemma twoTorsionPolynomial_discr : W.twoTorsionPolynomial.discr = 16 * W.Δ := by
simp only [b₂, b₄, b₆, b₈, Δ, twoTorsionPolynomial, Cubic.discr]
ring1
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc := twoTorsionPolynomial_discr
section CharTwo
variable [CharP R 2]
lemma twoTorsionPolynomial_of_char_two : W.twoTorsionPolynomial = ⟨0, W.b₂, 0, W.b₆⟩ := by
rw [twoTorsionPolynomial]
ext <;> dsimp
· linear_combination 2 * CharP.cast_eq_zero R 2
· linear_combination W.b₄ * CharP.cast_eq_zero R 2
lemma twoTorsionPolynomial_discr_of_char_two : W.twoTorsionPolynomial.discr = 0 := by
linear_combination W.twoTorsionPolynomial_discr + 8 * W.Δ * CharP.cast_eq_zero R 2
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc_of_char_two :=
twoTorsionPolynomial_discr_of_char_two
end CharTwo
section CharThree
variable [CharP R 3]
lemma twoTorsionPolynomial_of_char_three : W.twoTorsionPolynomial = ⟨1, W.b₂, -W.b₄, W.b₆⟩ := by
rw [twoTorsionPolynomial]
ext <;> dsimp
· linear_combination CharP.cast_eq_zero R 3
· linear_combination W.b₄ * CharP.cast_eq_zero R 3
lemma twoTorsionPolynomial_discr_of_char_three : W.twoTorsionPolynomial.discr = W.Δ := by
linear_combination W.twoTorsionPolynomial_discr + 5 * W.Δ * CharP.cast_eq_zero R 3
end CharThree
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
lemma twoTorsionPolynomial_discr_isUnit (hu : IsUnit (2 : R)) :
IsUnit W.twoTorsionPolynomial.discr ↔ IsUnit W.Δ := by
rw [twoTorsionPolynomial_discr, IsUnit.mul_iff, show (16 : R) = 2 ^ 4 by norm_num1]
exact and_iff_right <| hu.pow 4
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
-- TODO: In this case `IsUnit W.Δ` is just `W.IsElliptic`, consider removing/rephrasing this result
lemma twoTorsionPolynomial_discr_ne_zero [Nontrivial R] (hu : IsUnit (2 : R)) (hΔ : IsUnit W.Δ) :
W.twoTorsionPolynomial.discr ≠ 0 :=
((W.twoTorsionPolynomial_discr_isUnit hu).mpr hΔ).ne_zero
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc_of_char_three :=
twoTorsionPolynomial_discr_of_char_three
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc_isUnit :=
twoTorsionPolynomial_discr_isUnit
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc_ne_zero :=
twoTorsionPolynomial_discr_ne_zero
end TorsionPolynomial
/-! ## Elliptic curves -/
-- TODO: change to `protected abbrev IsElliptic := IsUnit W.Δ` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
/-- `WeierstrassCurve.IsElliptic` is a typeclass which asserts that a Weierstrass curve is an
elliptic curve: that its discriminant is a unit. Note that this definition is only mathematically
accurate for certain rings whose Picard group has trivial 12-torsion, such as a field or a PID. -/
@[mk_iff]
protected class IsElliptic : Prop where
isUnit : IsUnit W.Δ
variable [W.IsElliptic]
lemma isUnit_Δ : IsUnit W.Δ := IsElliptic.isUnit
/-- The discriminant `Δ'` of an elliptic curve over `R`, which is given as a unit in `R`.
Note that to prove two equal elliptic curves have the same `Δ'`, you need to use `simp_rw`,
as `rw` cannot transfer instance `WeierstrassCurve.IsElliptic` automatically. -/
noncomputable def Δ' : Rˣ :=
W.isUnit_Δ.unit
/-- The discriminant `Δ'` of an elliptic curve is equal to the
discriminant `Δ` of it as a Weierstrass curve. -/
@[simp]
lemma coe_Δ' : W.Δ' = W.Δ :=
rfl
/-- The j-invariant `j` of an elliptic curve, which is invariant under isomorphisms over `R`.
Note that to prove two equal elliptic curves have the same `j`, you need to use `simp_rw`,
as `rw` cannot transfer instance `WeierstrassCurve.IsElliptic` automatically. -/
noncomputable def j : R :=
W.Δ'⁻¹ * W.c₄ ^ 3
/-- A variant of `WeierstrassCurve.j_eq_zero_iff` without assuming a reduced ring. -/
lemma j_eq_zero_iff' : W.j = 0 ↔ W.c₄ ^ 3 = 0 := by
rw [j, Units.mul_right_eq_zero]
lemma j_eq_zero (h : W.c₄ = 0) : W.j = 0 := by
rw [j_eq_zero_iff', h, zero_pow three_ne_zero]
lemma j_eq_zero_iff [IsReduced R] : W.j = 0 ↔ W.c₄ = 0 := by
rw [j_eq_zero_iff', IsReduced.pow_eq_zero_iff three_ne_zero]
section CharTwo
variable [CharP R 2]
lemma j_of_char_two : W.j = W.Δ'⁻¹ * W.a₁ ^ 12 := by
rw [j, W.c₄_of_char_two, ← pow_mul]
/-- A variant of `WeierstrassCurve.j_eq_zero_iff_of_char_two` without assuming a reduced ring. -/
lemma j_eq_zero_iff_of_char_two' : W.j = 0 ↔ W.a₁ ^ 12 = 0 := by
rw [j_of_char_two, Units.mul_right_eq_zero]
lemma j_eq_zero_of_char_two (h : W.a₁ = 0) : W.j = 0 := by
rw [j_eq_zero_iff_of_char_two', h, zero_pow (Nat.succ_ne_zero _)]
lemma j_eq_zero_iff_of_char_two [IsReduced R] : W.j = 0 ↔ W.a₁ = 0 := by
rw [j_eq_zero_iff_of_char_two', IsReduced.pow_eq_zero_iff (Nat.succ_ne_zero _)]
end CharTwo
section CharThree
variable [CharP R 3]
lemma j_of_char_three : W.j = W.Δ'⁻¹ * W.b₂ ^ 6 := by
rw [j, W.c₄_of_char_three, ← pow_mul]
/-- A variant of `WeierstrassCurve.j_eq_zero_iff_of_char_three` without assuming a reduced ring. -/
lemma j_eq_zero_iff_of_char_three' : W.j = 0 ↔ W.b₂ ^ 6 = 0 := by
rw [j_of_char_three, Units.mul_right_eq_zero]
lemma j_eq_zero_of_char_three (h : W.b₂ = 0) : W.j = 0 := by
rw [j_eq_zero_iff_of_char_three', h, zero_pow (Nat.succ_ne_zero _)]
lemma j_eq_zero_iff_of_char_three [IsReduced R] : W.j = 0 ↔ W.b₂ = 0 := by
rw [j_eq_zero_iff_of_char_three', IsReduced.pow_eq_zero_iff (Nat.succ_ne_zero _)]
end CharThree
-- TODO: this is defeq to `twoTorsionPolynomial_discr_ne_zero` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged,
-- TODO: consider removing/rephrasing this result
lemma twoTorsionPolynomial_discr_ne_zero_of_isElliptic [Nontrivial R] (hu : IsUnit (2 : R)) :
W.twoTorsionPolynomial.discr ≠ 0 :=
W.twoTorsionPolynomial_discr_ne_zero hu W.isUnit_Δ
@[deprecated (since := "2025-10-20")] alias twoTorsionPolynomial_disc_ne_zero_of_isElliptic :=
twoTorsionPolynomial_discr_ne_zero_of_isElliptic
section BaseChange
/-! ### Maps and base changes -/
variable {A : Type v} [CommRing A] (f : R →+* A)
instance : (W.map f).IsElliptic := by
simp only [isElliptic_iff, map_Δ, W.isUnit_Δ.map]
set_option linter.docPrime false in
lemma coe_map_Δ' : (W.map f).Δ' = f W.Δ' := by
rw [coe_Δ', map_Δ, coe_Δ']
set_option linter.docPrime false in
@[simp]
lemma map_Δ' : (W.map f).Δ' = Units.map f W.Δ' := by
ext
exact W.coe_map_Δ' f
set_option linter.docPrime false in
lemma coe_inv_map_Δ' : (W.map f).Δ'⁻¹ = f ↑W.Δ'⁻¹ := by
simp
set_option linter.docPrime false in
lemma inv_map_Δ' : (W.map f).Δ'⁻¹ = Units.map f W.Δ'⁻¹ := by
simp
@[simp]
lemma map_j : (W.map f).j = f W.j := by
rw [j, coe_inv_map_Δ', map_c₄, j, map_mul, map_pow]
end BaseChange
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Group.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Point
deprecated_module (since := "2025-05-07") |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/ModelsWithJ.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Weierstrass
/-!
# Models of elliptic curves with prescribed j-invariant
This file defines the Weierstrass equation over a field with prescribed j-invariant,
proved that it is an elliptic curve, and that its j-invariant is equal to the given value.
It is a modification of [silverman2009], Chapter III, Proposition 1.4 (c).
## Main definitions
* `WeierstrassCurve.ofJ0`: an elliptic curve whose j-invariant is 0.
* `WeierstrassCurve.ofJ1728`: an elliptic curve whose j-invariant is 1728.
* `WeierstrassCurve.ofJNe0Or1728`: an elliptic curve whose j-invariant is neither 0 nor 1728.
* `WeierstrassCurve.ofJ`: an elliptic curve whose j-invariant equal to j.
## Main statements
* `WeierstrassCurve.ofJ_j`: the j-invariant of `WeierstrassCurve.ofJ` is equal to j.
## References
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, j invariant
-/
namespace WeierstrassCurve
variable (R : Type*) [CommRing R] (W : WeierstrassCurve R)
/-- The Weierstrass curve `Y² + Y = X³`. It is of j-invariant 0 if it is an elliptic curve. -/
def ofJ0 : WeierstrassCurve R :=
⟨0, 0, 1, 0, 0⟩
lemma ofJ0_c₄ : (ofJ0 R).c₄ = 0 := by
rw [ofJ0, c₄, b₂, b₄]
norm_num1
lemma ofJ0_Δ : (ofJ0 R).Δ = -27 := by
rw [ofJ0, Δ, b₂, b₄, b₆, b₈]
norm_num1
/-- The Weierstrass curve `Y² = X³ + X`. It is of j-invariant 1728 if it is an elliptic curve. -/
def ofJ1728 : WeierstrassCurve R :=
⟨0, 0, 0, 1, 0⟩
lemma ofJ1728_c₄ : (ofJ1728 R).c₄ = -48 := by
rw [ofJ1728, c₄, b₂, b₄]
norm_num1
lemma ofJ1728_Δ : (ofJ1728 R).Δ = -64 := by
rw [ofJ1728, Δ, b₂, b₄, b₆, b₈]
norm_num1
variable {R} (j : R)
/-- The Weierstrass curve `Y² + (j - 1728)XY = X³ - 36(j - 1728)³X - (j - 1728)⁵`.
It is a modification of the curve in [silverman2009], Chapter III, Proposition 1.4 (c) to avoid
denominators. It is of j-invariant j if it is an elliptic curve. -/
def ofJNe0Or1728 : WeierstrassCurve R :=
⟨j - 1728, 0, 0, -36 * (j - 1728) ^ 3, -(j - 1728) ^ 5⟩
lemma ofJNe0Or1728_c₄ : (ofJNe0Or1728 j).c₄ = j * (j - 1728) ^ 3 := by
simp only [ofJNe0Or1728, c₄, b₂, b₄]
ring1
lemma ofJNe0Or1728_Δ : (ofJNe0Or1728 j).Δ = j ^ 2 * (j - 1728) ^ 9 := by
simp only [ofJNe0Or1728, Δ, b₂, b₄, b₆, b₈]
ring1
variable (R) [W.IsElliptic]
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
/-- When 3 is a unit, `Y² + Y = X³` is an elliptic curve.
It is of j-invariant 0 (see `WeierstrassCurve.ofJ0_j`). -/
instance [hu : Fact (IsUnit (3 : R))] : (ofJ0 R).IsElliptic := by
rw [isElliptic_iff, ofJ0_Δ]
convert (hu.out.pow 3).neg
norm_num1
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
lemma ofJ0_j [Fact (IsUnit (3 : R))] : (ofJ0 R).j = 0 := by
rw [j, ofJ0_c₄]
ring1
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
/-- When 2 is a unit, `Y² = X³ + X` is an elliptic curve.
It is of j-invariant 1728 (see `WeierstrassCurve.ofJ1728_j`). -/
instance [hu : Fact (IsUnit (2 : R))] : (ofJ1728 R).IsElliptic := by
rw [isElliptic_iff, ofJ1728_Δ]
convert (hu.out.pow 6).neg
norm_num1
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
lemma ofJ1728_j [Fact (IsUnit (2 : R))] : (ofJ1728 R).j = 1728 := by
rw [j, Units.inv_mul_eq_iff_eq_mul, ofJ1728_c₄, coe_Δ', ofJ1728_Δ]
norm_num1
variable {R}
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
/-- When j and j - 1728 are both units,
`Y² + (j - 1728)XY = X³ - 36(j - 1728)³X - (j - 1728)⁵` is an elliptic curve.
It is of j-invariant j (see `WeierstrassCurve.ofJNe0Or1728_j`). -/
instance (j : R) [h1 : Fact (IsUnit j)] [h2 : Fact (IsUnit (j - 1728))] :
(ofJNe0Or1728 j).IsElliptic := by
rw [isElliptic_iff, ofJNe0Or1728_Δ]
exact (h1.out.pow 2).mul (h2.out.pow 9)
-- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged
lemma ofJNe0Or1728_j (j : R) [Fact (IsUnit j)] [Fact (IsUnit (j - 1728))] :
(ofJNe0Or1728 j).j = j := by
rw [WeierstrassCurve.j, Units.inv_mul_eq_iff_eq_mul, ofJNe0Or1728_c₄, coe_Δ', ofJNe0Or1728_Δ]
ring1
variable {F : Type*} [Field F] (j : F) [DecidableEq F]
/-- For any element j of a field `F`, there exists an elliptic curve over `F`
with j-invariant equal to j (see `WeierstrassCurve.ofJ_j`).
Its coefficients are given explicitly (see `WeierstrassCurve.ofJ0`, `WeierstrassCurve.ofJ1728`
and `WeierstrassCurve.ofJNe0Or1728`). -/
def ofJ : WeierstrassCurve F :=
if j = 0 then if (3 : F) = 0 then ofJ1728 F else ofJ0 F
else if j = 1728 then ofJ1728 F else ofJNe0Or1728 j
lemma ofJ_0_of_three_ne_zero (h3 : (3 : F) ≠ 0) : ofJ 0 = ofJ0 F := by
rw [ofJ, if_pos rfl, if_neg h3]
lemma ofJ_0_of_three_eq_zero (h3 : (3 : F) = 0) : ofJ 0 = ofJ1728 F := by
rw [ofJ, if_pos rfl, if_pos h3]
lemma ofJ_0_of_two_eq_zero (h2 : (2 : F) = 0) : ofJ 0 = ofJ0 F := by
rw [ofJ, if_pos rfl, if_neg ((show (3 : F) = 1 by linear_combination h2) ▸ one_ne_zero)]
lemma ofJ_1728_of_three_eq_zero (h3 : (3 : F) = 0) : ofJ 1728 = ofJ1728 F := by
rw [ofJ, if_pos (by linear_combination 576 * h3), if_pos h3]
lemma ofJ_1728_of_two_ne_zero (h2 : (2 : F) ≠ 0) : ofJ 1728 = ofJ1728 F := by
by_cases h3 : (3 : F) = 0
· exact ofJ_1728_of_three_eq_zero h3
· rw [ofJ, show (1728 : F) = 2 ^ 6 * 3 ^ 3 by norm_num1,
if_neg (mul_ne_zero (pow_ne_zero 6 h2) (pow_ne_zero 3 h3)), if_pos rfl]
lemma ofJ_1728_of_two_eq_zero (h2 : (2 : F) = 0) : ofJ 1728 = ofJ0 F := by
rw [ofJ, if_pos (by linear_combination 864 * h2),
if_neg ((show (3 : F) = 1 by linear_combination h2) ▸ one_ne_zero)]
lemma ofJ_ne_0_ne_1728 (h0 : j ≠ 0) (h1728 : j ≠ 1728) : ofJ j = ofJNe0Or1728 j := by
rw [ofJ, if_neg h0, if_neg h1728]
instance : (ofJ j).IsElliptic := by
by_cases h0 : j = 0
· by_cases h3 : (3 : F) = 0
· have : Fact <| IsUnit (2 : F) := ⟨.of_mul_eq_one 2 <| by linear_combination h3⟩
rw [h0, ofJ_0_of_three_eq_zero h3]
infer_instance
· have := Fact.mk (Ne.isUnit h3)
rw [h0, ofJ_0_of_three_ne_zero h3]
infer_instance
· by_cases h1728 : j = 1728
· have h2 : (2 : F) ≠ 0 := fun h ↦ h0 (by linear_combination h1728 + 864 * h)
have := Fact.mk h2.isUnit
rw [h1728, ofJ_1728_of_two_ne_zero h2]
infer_instance
· have := Fact.mk (Ne.isUnit h0)
have := Fact.mk (sub_ne_zero.2 h1728).isUnit
rw [ofJ_ne_0_ne_1728 j h0 h1728]
infer_instance
lemma ofJ_j : (ofJ j).j = j := by
by_cases h0 : j = 0
· by_cases h3 : (3 : F) = 0
· have : Fact <| IsUnit (2 : F) := ⟨.of_mul_eq_one 2 <| by linear_combination h3⟩
simp_rw [h0, ofJ_0_of_three_eq_zero h3, ofJ1728_j]
linear_combination 576 * h3
· have := Fact.mk (Ne.isUnit h3)
simp_rw [h0, ofJ_0_of_three_ne_zero h3, ofJ0_j]
· by_cases h1728 : j = 1728
· have h2 : (2 : F) ≠ 0 := fun h ↦ h0 (by linear_combination h1728 + 864 * h)
have := Fact.mk h2.isUnit
simp_rw [h1728, ofJ_1728_of_two_ne_zero h2, ofJ1728_j]
· have := Fact.mk (Ne.isUnit h0)
have := Fact.mk (sub_ne_zero.2 h1728).isUnit
simp_rw [ofJ_ne_0_ne_1728 j h0 h1728, ofJNe0Or1728_j]
instance : Inhabited { W : WeierstrassCurve F // W.IsElliptic } :=
⟨⟨ofJ 37, inferInstance⟩⟩
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/IsomOfJ.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.NormalForms
import Mathlib.FieldTheory.IsSepClosed
/-!
# Elliptic curves with same j-invariants are isomorphic
## Main results
- `WeierstrassCurve.exists_variableChange_of_j_eq`: if `E` and `E'` are elliptic curves with the
same `j`-invariants defined over a separably closed field, then there exists a change of variables
over that field which change `E` into `E'`.
-/
open Polynomial
variable {F : Type*} [Field F] [IsSepClosed F]
namespace WeierstrassCurve
variable (E E' : WeierstrassCurve F) [E.IsElliptic] [E'.IsElliptic]
section CharTwo
variable [CharP F 2]
omit [E.IsElliptic] [E'.IsElliptic] in
private lemma exists_variableChange_of_char_two_of_j_ne_zero
[E.IsCharTwoJNeZeroNF] [E'.IsCharTwoJNeZeroNF] (heq : E.a₆ = E'.a₆) :
∃ C : VariableChange F, C • E = E' := by
obtain ⟨s, hs⟩ := IsSepClosed.exists_root_C_mul_X_pow_add_C_mul_X_add_C' 2 2
1 1 (E.a₂ + E'.a₂) (by simp) (by simp) one_ne_zero
use ⟨1, 0, s, 0⟩
ext
· simp_rw [variableChange_a₁, inv_one, Units.val_one, a₁_of_isCharTwoJNeZeroNF]
linear_combination s * CharP.cast_eq_zero F 2
· simp_rw [variableChange_a₂, inv_one, Units.val_one, a₁_of_isCharTwoJNeZeroNF]
linear_combination -hs + E.a₂ * CharP.cast_eq_zero F 2
· simp_rw [variableChange_a₃, inv_one, Units.val_one, a₃_of_isCharTwoJNeZeroNF]
ring1
· simp_rw [variableChange_a₄, inv_one, Units.val_one, a₃_of_isCharTwoJNeZeroNF,
a₄_of_isCharTwoJNeZeroNF]
ring1
· simp_rw [variableChange_a₆, inv_one, Units.val_one, heq]
ring1
private lemma exists_variableChange_of_char_two_of_j_eq_zero
[E.IsCharTwoJEqZeroNF] [E'.IsCharTwoJEqZeroNF] : ∃ C : VariableChange F, C • E = E' := by
have ha₃ := E.Δ'.ne_zero
rw [E.coe_Δ', Δ_of_isCharTwoJEqZeroNF_of_char_two, pow_ne_zero_iff (Nat.succ_ne_zero _)] at ha₃
have ha₃' := E'.Δ'.ne_zero
rw [E'.coe_Δ', Δ_of_isCharTwoJEqZeroNF_of_char_two, pow_ne_zero_iff (Nat.succ_ne_zero _)] at ha₃'
haveI : NeZero (3 : F) := NeZero.mk <| by
rw [show (3 : F) = 1 by linear_combination CharP.cast_eq_zero F 2]
exact one_ne_zero
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₃ / E'.a₃) 3
obtain ⟨s, hs⟩ := IsSepClosed.exists_root_C_mul_X_pow_add_C_mul_X_add_C' 2 4
1 _ (E.a₄ - u ^ 4 * E'.a₄) (by simp) (by simp) ha₃
obtain ⟨t, ht⟩ := IsSepClosed.exists_root_C_mul_X_pow_add_C_mul_X_add_C' 2 2
1 _ (s ^ 6 + E.a₄ * s ^ 2 + E.a₆ - u ^ 6 * E'.a₆) (by simp) (by simp) ha₃
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff three_ne_zero, hu, div_ne_zero_iff]
exact ⟨ha₃, ha₃'⟩
use ⟨Units.mk0 u hu0, s ^ 2, s, t⟩
ext
· simp_rw [variableChange_a₁, a₁_of_isCharTwoJEqZeroNF,
show (2 : F) = 0 from CharP.cast_eq_zero F 2]
ring1
· simp_rw [variableChange_a₂, a₁_of_isCharTwoJEqZeroNF, a₂_of_isCharTwoJEqZeroNF,
show (3 : F) = 1 by linear_combination CharP.cast_eq_zero F 2]
ring1
· simp_rw [variableChange_a₃, Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div,
hu, a₁_of_isCharTwoJEqZeroNF, show (2 : F) = 0 from CharP.cast_eq_zero F 2]
simp [field]
· simp [field, variableChange_a₄, a₁_of_isCharTwoJEqZeroNF, a₂_of_isCharTwoJEqZeroNF]
linear_combination hs + (s ^ 4 - s * t - E.a₃ * s) * CharP.cast_eq_zero F 2
· simp [field, variableChange_a₆, a₁_of_isCharTwoJEqZeroNF, a₂_of_isCharTwoJEqZeroNF]
linear_combination ht - (t ^ 2 + E.a₃ * t) * CharP.cast_eq_zero F 2
private lemma exists_variableChange_of_char_two (heq : E.j = E'.j) :
∃ C : VariableChange F, C • E = E' := by
obtain ⟨C, _ | _⟩ := E.exists_variableChange_isCharTwoNF
· obtain ⟨C', _ | _⟩ := E'.exists_variableChange_isCharTwoNF
· simp_rw [← variableChange_j E C, ← variableChange_j E' C',
j_of_isCharTwoJNeZeroNF_of_char_two, one_div, inv_inj] at heq
obtain ⟨C'', hC⟩ := exists_variableChange_of_char_two_of_j_ne_zero _ _ heq
use C'⁻¹ * C'' * C
rw [mul_smul, mul_smul, hC, ← mul_smul, inv_mul_cancel, one_smul]
· have h := (C • E).j_ne_zero_of_isCharTwoJNeZeroNF_of_char_two
rw [variableChange_j, heq, ← variableChange_j E' C',
j_of_isCharTwoJEqZeroNF_of_char_two] at h
exact False.elim (h rfl)
· obtain ⟨C', _ | _⟩ := E'.exists_variableChange_isCharTwoNF
· have h := (C' • E').j_ne_zero_of_isCharTwoJNeZeroNF_of_char_two
rw [variableChange_j, ← heq, ← variableChange_j E C,
j_of_isCharTwoJEqZeroNF_of_char_two] at h
exact False.elim (h rfl)
· obtain ⟨C'', hC⟩ := exists_variableChange_of_char_two_of_j_eq_zero (C • E) (C' • E')
use C'⁻¹ * C'' * C
rw [mul_smul, mul_smul, hC, ← mul_smul, inv_mul_cancel, one_smul]
end CharTwo
section CharThree
variable [CharP F 3]
private lemma exists_variableChange_of_char_three_of_j_ne_zero
[E.IsCharThreeJNeZeroNF] [E'.IsCharThreeJNeZeroNF] (heq : E.j = E'.j) :
∃ C : VariableChange F, C • E = E' := by
have h := E.Δ'.ne_zero
rw [E.coe_Δ', Δ_of_isCharThreeJNeZeroNF_of_char_three, mul_ne_zero_iff, neg_ne_zero,
pow_ne_zero_iff three_ne_zero] at h
obtain ⟨ha₂, ha₆⟩ := h
have h := E'.Δ'.ne_zero
rw [E'.coe_Δ', Δ_of_isCharThreeJNeZeroNF_of_char_three, mul_ne_zero_iff, neg_ne_zero,
pow_ne_zero_iff three_ne_zero] at h
obtain ⟨ha₂', ha₆'⟩ := h
haveI : NeZero (2 : F) := NeZero.mk <| by
rw [show (2 : F) = -1 by linear_combination CharP.cast_eq_zero F 3, neg_ne_zero]
exact one_ne_zero
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₂ / E'.a₂) 2
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff two_ne_zero, hu, div_ne_zero_iff]
exact ⟨ha₂, ha₂'⟩
use ⟨Units.mk0 u hu0, 0, 0, 0⟩
ext
· simp_rw [variableChange_a₁, a₁_of_isCharThreeJNeZeroNF]
ring1
· simp_rw [variableChange_a₂, a₁_of_isCharThreeJNeZeroNF, Units.val_inv_eq_inv_val,
Units.val_mk0, inv_pow, inv_mul_eq_div, hu]
simp [field]
· simp_rw [variableChange_a₃, a₁_of_isCharThreeJNeZeroNF, a₃_of_isCharThreeJNeZeroNF]
ring1
· simp_rw [variableChange_a₄, a₁_of_isCharThreeJNeZeroNF, a₃_of_isCharThreeJNeZeroNF,
a₄_of_isCharThreeJNeZeroNF]
ring1
· simp_rw [j_of_isCharThreeJNeZeroNF_of_char_three, div_eq_div_iff ha₆ ha₆'] at heq
simp_rw [variableChange_a₆, a₁_of_isCharThreeJNeZeroNF, a₃_of_isCharThreeJNeZeroNF,
a₄_of_isCharThreeJNeZeroNF, Units.val_inv_eq_inv_val, Units.val_mk0,
inv_pow, inv_mul_eq_div, pow_mul u 2 3, hu]
simp [field]
linear_combination heq
private lemma exists_variableChange_of_char_three_of_j_eq_zero
[E.IsShortNF] [E'.IsShortNF] : ∃ C : VariableChange F, C • E = E' := by
have ha₄ := E.Δ'.ne_zero
rw [E.coe_Δ', Δ_of_isShortNF_of_char_three, neg_ne_zero, pow_ne_zero_iff three_ne_zero] at ha₄
have ha₄' := E'.Δ'.ne_zero
rw [E'.coe_Δ', Δ_of_isShortNF_of_char_three, neg_ne_zero, pow_ne_zero_iff three_ne_zero] at ha₄'
haveI : NeZero (4 : F) := NeZero.mk <| by
rw [show (4 : F) = 1 by linear_combination CharP.cast_eq_zero F 3]
exact one_ne_zero
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₄ / E'.a₄) 4
obtain ⟨r, hr⟩ := IsSepClosed.exists_root_C_mul_X_pow_add_C_mul_X_add_C' 3 3
1 _ (E.a₆ - u ^ 6 * E'.a₆) (by simp) (by simp) ha₄
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff four_ne_zero, hu, div_ne_zero_iff]
exact ⟨ha₄, ha₄'⟩
use ⟨Units.mk0 u hu0, r, 0, 0⟩
ext
· simp_rw [variableChange_a₁, a₁_of_isShortNF]
ring1
· simp_rw [variableChange_a₂, a₁_of_isShortNF, a₂_of_isShortNF,
show (3 : F) = 0 from CharP.cast_eq_zero F 3]
ring1
· simp_rw [variableChange_a₃, a₁_of_isShortNF, a₃_of_isShortNF]
ring1
· simp_rw [variableChange_a₄, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div, hu,
show (3 : F) = 0 from CharP.cast_eq_zero F 3]
simp [field]
· simp_rw [variableChange_a₆, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div]
simp [field]
linear_combination hr
private lemma exists_variableChange_of_char_three (heq : E.j = E'.j) :
∃ C : VariableChange F, C • E = E' := by
obtain ⟨C, _ | _⟩ := E.exists_variableChange_isCharThreeNF
· obtain ⟨C', _ | _⟩ := E'.exists_variableChange_isCharThreeNF
· rw [← variableChange_j E C, ← variableChange_j E' C'] at heq
obtain ⟨C'', hC⟩ := exists_variableChange_of_char_three_of_j_ne_zero _ _ heq
use C'⁻¹ * C'' * C
rw [mul_smul, mul_smul, hC, ← mul_smul, inv_mul_cancel, one_smul]
· have h := (C • E).j_ne_zero_of_isCharThreeJNeZeroNF_of_char_three
rw [variableChange_j, heq, ← variableChange_j E' C', j_of_isShortNF_of_char_three] at h
exact False.elim (h rfl)
· obtain ⟨C', _ | _⟩ := E'.exists_variableChange_isCharThreeNF
· have h := (C' • E').j_ne_zero_of_isCharThreeJNeZeroNF_of_char_three
rw [variableChange_j, ← heq, ← variableChange_j E C, j_of_isShortNF_of_char_three] at h
exact False.elim (h rfl)
· obtain ⟨C'', hC⟩ := exists_variableChange_of_char_three_of_j_eq_zero (C • E) (C' • E')
use C'⁻¹ * C'' * C
rw [mul_smul, mul_smul, hC, ← mul_smul, inv_mul_cancel, one_smul]
end CharThree
section CharNeTwoOrThree
private lemma exists_variableChange_of_char_ne_two_or_three
{p : ℕ} [CharP F p] (hchar2 : p ≠ 2) (hchar3 : p ≠ 3) (heq : E.j = E'.j) :
∃ C : VariableChange F, C • E = E' := by
replace hchar2 : (2 : F) ≠ 0 := CharP.cast_ne_zero_of_ne_of_prime F Nat.prime_two hchar2
replace hchar3 : (3 : F) ≠ 0 := CharP.cast_ne_zero_of_ne_of_prime F Nat.prime_three hchar3
haveI := NeZero.mk hchar2
haveI : NeZero (4 : F) := NeZero.mk <| by
have := pow_ne_zero 2 hchar2
norm_num1 at this
exact this
haveI : NeZero (6 : F) := NeZero.mk <| by
have := mul_ne_zero hchar2 hchar3
norm_num1 at this
exact this
letI : Invertible (2 : F) := invertibleOfNonzero hchar2
letI : Invertible (3 : F) := invertibleOfNonzero hchar3
wlog _ : E.IsShortNF generalizing E
· obtain ⟨C, hE⟩ := E.exists_variableChange_isShortNF
rw [← variableChange_j E C] at heq
obtain ⟨C', hC⟩ := this _ heq hE
exact ⟨C' * C, by rwa [mul_smul]⟩
wlog _ : E'.IsShortNF generalizing E'
· obtain ⟨C, hE'⟩ := E'.exists_variableChange_isShortNF
rw [← variableChange_j E' C] at heq
obtain ⟨C', hC⟩ := this _ heq hE'
exact ⟨C⁻¹ * C', by rw [mul_smul, hC, ← mul_smul, inv_mul_cancel, one_smul]⟩
simp_rw [j, Units.val_inv_eq_inv_val, inv_mul_eq_div,
div_eq_div_iff E.Δ'.ne_zero E'.Δ'.ne_zero, coe_Δ', Δ_of_isShortNF, c₄_of_isShortNF] at heq
replace heq : E.a₄ ^ 3 * E'.a₆ ^ 2 = E'.a₄ ^ 3 * E.a₆ ^ 2 := by
letI : Invertible (47775744 : F) := invertibleOfNonzero <| by
have := mul_ne_zero (pow_ne_zero 16 hchar2) (pow_ne_zero 6 hchar3)
norm_num1 at this
exact this
rw [← mul_right_inj_of_invertible (47775744 : F)]
linear_combination heq
by_cases ha₄ : E.a₄ = 0
· have ha₆ := E.Δ'.ne_zero
rw [coe_Δ', Δ_of_isShortNF, ha₄, zero_pow three_ne_zero, mul_zero, zero_add, ← mul_assoc,
mul_ne_zero_iff, pow_ne_zero_iff two_ne_zero] at ha₆
replace ha₆ := ha₆.2
have ha₄' : E'.a₄ = 0 := by
rw [ha₄, zero_pow three_ne_zero, zero_mul, zero_eq_mul] at heq
exact (pow_eq_zero_iff three_ne_zero).1 <| heq.resolve_right <| pow_ne_zero 2 ha₆
have ha₆' := E'.Δ'.ne_zero
rw [coe_Δ', Δ_of_isShortNF, ha₄', zero_pow three_ne_zero, mul_zero, zero_add, ← mul_assoc,
mul_ne_zero_iff, pow_ne_zero_iff two_ne_zero] at ha₆'
replace ha₆' := ha₆'.2
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₆ / E'.a₆) 6
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff (Nat.succ_ne_zero 5), hu, div_ne_zero_iff]
exact ⟨ha₆, ha₆'⟩
use ⟨Units.mk0 u hu0, 0, 0, 0⟩
ext
· simp [variableChange_a₁]
· simp [variableChange_a₂]
· simp [variableChange_a₃]
· simp [ha₄, ha₄', variableChange_a₄]
· simp_rw [variableChange_a₆, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
ha₄, Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div, hu]
simp [field]
by_cases ha₆ : E.a₆ = 0
· have ha₄ := E.Δ'.ne_zero
rw [coe_Δ', Δ_of_isShortNF, ha₆, zero_pow two_ne_zero, mul_zero, add_zero, ← mul_assoc,
mul_ne_zero_iff, pow_ne_zero_iff three_ne_zero] at ha₄
replace ha₄ := ha₄.2
have ha₆' : E'.a₆ = 0 := by
rw [ha₆, zero_pow two_ne_zero, mul_zero, mul_eq_zero] at heq
exact (pow_eq_zero_iff two_ne_zero).1 <| heq.resolve_left <| pow_ne_zero 3 ha₄
have ha₄' := E'.Δ'.ne_zero
rw [coe_Δ', Δ_of_isShortNF, ha₆', zero_pow two_ne_zero, mul_zero, add_zero, ← mul_assoc,
mul_ne_zero_iff, pow_ne_zero_iff three_ne_zero] at ha₄'
replace ha₄' := ha₄'.2
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₄ / E'.a₄) 4
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff four_ne_zero, hu, div_ne_zero_iff]
exact ⟨ha₄, ha₄'⟩
use ⟨Units.mk0 u hu0, 0, 0, 0⟩
ext
· simp [variableChange_a₁]
· simp [variableChange_a₂]
· simp [variableChange_a₃]
· simp_rw [variableChange_a₄, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div, hu]
simp [field]
· simp [ha₆, ha₆', variableChange_a₆]
have ha₄' : E'.a₄ ≠ 0 := fun h ↦ by
rw [h, zero_pow three_ne_zero, zero_mul, mul_eq_zero,
pow_eq_zero_iff two_ne_zero, pow_eq_zero_iff three_ne_zero] at heq
simpa [E'.coe_Δ', Δ_of_isShortNF, h, heq.resolve_left ha₄] using E'.Δ'.ne_zero
have ha₆' : E'.a₆ ≠ 0 := fun h ↦ by
rw [h, zero_pow two_ne_zero, mul_zero, zero_eq_mul,
pow_eq_zero_iff two_ne_zero, pow_eq_zero_iff three_ne_zero] at heq
tauto
obtain ⟨u, hu⟩ := IsSepClosed.exists_pow_nat_eq (E.a₆ / E'.a₆ / (E.a₄ / E'.a₄)) 2
have hu4 : u ^ 4 = E.a₄ / E'.a₄ := by
rw [pow_mul u 2 2, hu]
simp [field]
linear_combination -heq
have hu6 : u ^ 6 = E.a₆ / E'.a₆ := by
rw [pow_mul u 2 3, hu]
simp [field]
linear_combination -heq
have hu0 : u ≠ 0 := by
rw [← pow_ne_zero_iff four_ne_zero, hu4, div_ne_zero_iff]
exact ⟨ha₄, ha₄'⟩
use ⟨Units.mk0 u hu0, 0, 0, 0⟩
ext
· simp [variableChange_a₁]
· simp [variableChange_a₂]
· simp [variableChange_a₃]
· simp_rw [variableChange_a₄, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div, hu4]
simp [field]
· simp_rw [variableChange_a₆, a₁_of_isShortNF, a₂_of_isShortNF, a₃_of_isShortNF,
Units.val_inv_eq_inv_val, Units.val_mk0, inv_pow, inv_mul_eq_div, hu6]
simp [field]
end CharNeTwoOrThree
/-- If there are two elliptic curves with the same `j`-invariants defined over a
separably closed field, then there exists a change of variables over that field which change
one curve into another. -/
theorem exists_variableChange_of_j_eq (heq : E.j = E'.j) : ∃ C : VariableChange F, C • E = E' := by
obtain ⟨p, _⟩ := CharP.exists F
by_cases hchar2 : p = 2
· subst hchar2
exact exists_variableChange_of_char_two _ _ heq
by_cases hchar3 : p = 3
· subst hchar3
exact exists_variableChange_of_char_three _ _ heq
exact exists_variableChange_of_char_ne_two_or_three _ _ hchar2 hchar3 heq
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/VariableChange.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Weierstrass
/-!
# Change of variables of Weierstrass curves
This file defines admissible linear change of variables of Weierstrass curves.
## Main definitions
* `WeierstrassCurve.VariableChange`: a change of variables of Weierstrass curves.
* An instance which states that change of variables forms a group.
* An instance which states that change of variables acts on Weierstrass curves.
## Main statements
* An instance which states that change of variables preserves elliptic curves.
* `WeierstrassCurve.variableChange_j`: the j-invariant of an elliptic curve is invariant under an
admissible linear change of variables.
## References
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, change of variables
-/
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow])
universe s u v w
namespace WeierstrassCurve
variable {R : Type u} [CommRing R] (W : WeierstrassCurve R)
section VariableChange
/-! ## Variable changes -/
/-- An admissible linear change of variables of Weierstrass curves defined over a ring `R` given by
a tuple `(u, r, s, t)` for some `u` in `Rˣ` and some `r, s, t` in `R`. As a matrix, it is
$$\begin{pmatrix} u^2 & 0 & r \cr u^2s & u^3 & t \cr 0 & 0 & 1 \end{pmatrix}.$$
In other words, this is the change of variables `(X, Y) ↦ (u²X + r, u³Y + u²sX + t)`.
When `R` is a field, any two isomorphic Weierstrass equations are related by this. -/
@[ext]
structure VariableChange (R : Type u) [CommRing R] where
/-- The `u` coefficient of an admissible linear change of variables, which must be a unit. -/
u : Rˣ
/-- The `r` coefficient of an admissible linear change of variables. -/
r : R
/-- The `s` coefficient of an admissible linear change of variables. -/
s : R
/-- The `t` coefficient of an admissible linear change of variables. -/
t : R
namespace VariableChange
variable (C C' : VariableChange R)
instance : One (VariableChange R) where
one := ⟨1, 0, 0, 0⟩
/-- The identity linear change of variables given by the identity matrix. -/
lemma one_def : (1 : VariableChange R) = ⟨1, 0, 0, 0⟩ := rfl
instance : Mul (VariableChange R) where
mul C C' := {
u := C.u * C'.u
r := C.r * C'.u ^ 2 + C'.r
s := C'.u * C.s + C'.s
t := C.t * C'.u ^ 3 + C.r * C'.s * C'.u ^ 2 + C'.t }
/-- The composition of two linear changes of variables given by matrix multiplication. -/
lemma mul_def : C * C' = {
u := C.u * C'.u
r := C.r * C'.u ^ 2 + C'.r
s := C'.u * C.s + C'.s
t := C.t * C'.u ^ 3 + C.r * C'.s * C'.u ^ 2 + C'.t } := rfl
instance : Inv (VariableChange R) where
inv C := {
u := C.u⁻¹
r := -C.r * C.u⁻¹ ^ 2
s := -C.s * C.u⁻¹
t := (C.r * C.s - C.t) * C.u⁻¹ ^ 3 }
/-- The inverse of a linear change of variables given by matrix inversion. -/
lemma inv_def : C⁻¹ = {
u := C.u⁻¹
r := -C.r * C.u⁻¹ ^ 2
s := -C.s * C.u⁻¹
t := (C.r * C.s - C.t) * C.u⁻¹ ^ 3 } := rfl
instance : Group (VariableChange R) where
one_mul C := by
simp only [mul_def, one_def, zero_add, zero_mul, mul_zero, one_mul]
mul_one C := by
simp only [mul_def, one_def, add_zero, mul_zero, one_mul, mul_one, one_pow, Units.val_one]
inv_mul_cancel C := by
rw [mul_def, one_def, inv_def]
ext <;> dsimp only
· exact C.u.inv_mul
· linear_combination -C.r * pow_mul_pow_eq_one 2 C.u.inv_mul
· linear_combination -C.s * C.u.inv_mul
· linear_combination (C.r * C.s - C.t) * pow_mul_pow_eq_one 3 C.u.inv_mul
+ -C.r * C.s * pow_mul_pow_eq_one 2 C.u.inv_mul
mul_assoc _ _ _ := by
ext <;> simp only [mul_def, Units.val_mul] <;> ring1
end VariableChange
variable (C : VariableChange R)
instance : SMul (VariableChange R) (WeierstrassCurve R) where
smul C W := {
a₁ := C.u⁻¹ * (W.a₁ + 2 * C.s)
a₂ := C.u⁻¹ ^ 2 * (W.a₂ - C.s * W.a₁ + 3 * C.r - C.s ^ 2)
a₃ := C.u⁻¹ ^ 3 * (W.a₃ + C.r * W.a₁ + 2 * C.t)
a₄ := C.u⁻¹ ^ 4 * (W.a₄ - C.s * W.a₃ + 2 * C.r * W.a₂ - (C.t + C.r * C.s) * W.a₁ + 3 * C.r ^ 2
- 2 * C.s * C.t)
a₆ := C.u⁻¹ ^ 6 * (W.a₆ + C.r * W.a₄ + C.r ^ 2 * W.a₂ + C.r ^ 3 - C.t * W.a₃ - C.t ^ 2
- C.r * C.t * W.a₁) }
/-- The Weierstrass curve over `R` induced by an admissible linear change of variables
`(X, Y) ↦ (u²X + r, u³Y + u²sX + t)` for some `u` in `Rˣ` and some `r, s, t` in `R`. -/
lemma variableChange_def : C • W = {
a₁ := C.u⁻¹ * (W.a₁ + 2 * C.s)
a₂ := C.u⁻¹ ^ 2 * (W.a₂ - C.s * W.a₁ + 3 * C.r - C.s ^ 2)
a₃ := C.u⁻¹ ^ 3 * (W.a₃ + C.r * W.a₁ + 2 * C.t)
a₄ := C.u⁻¹ ^ 4 * (W.a₄ - C.s * W.a₃ + 2 * C.r * W.a₂ - (C.t + C.r * C.s) * W.a₁ + 3 * C.r ^ 2
- 2 * C.s * C.t)
a₆ := C.u⁻¹ ^ 6 * (W.a₆ + C.r * W.a₄ + C.r ^ 2 * W.a₂ + C.r ^ 3 - C.t * W.a₃ - C.t ^ 2
- C.r * C.t * W.a₁) } := rfl
instance : MulAction (VariableChange R) (WeierstrassCurve R) where
one_smul W := by
rw [VariableChange.one_def, variableChange_def, inv_one, Units.val_one]
ext <;> dsimp only <;> ring1
mul_smul C C' W := by
simp only [VariableChange.mul_def, variableChange_def]
ext <;> simp only [mul_inv, Units.val_mul]
· linear_combination ↑C.u⁻¹ * C.s * 2 * C'.u.inv_mul
· linear_combination
C.s * (-C'.s * 2 - W.a₁) * C.u⁻¹ ^ 2 * ↑C'.u⁻¹ * C'.u.inv_mul
+ (C.r * 3 - C.s ^ 2) * C.u⁻¹ ^ 2 * pow_mul_pow_eq_one 2 C'.u.inv_mul
· linear_combination
C.r * (C'.s * 2 + W.a₁) * C.u⁻¹ ^ 3 * ↑C'.u⁻¹ * pow_mul_pow_eq_one 2 C'.u.inv_mul
+ C.t * 2 * C.u⁻¹ ^ 3 * pow_mul_pow_eq_one 3 C'.u.inv_mul
· linear_combination
C.s * (-W.a₃ - C'.r * W.a₁ - C'.t * 2) * C.u⁻¹ ^ 4 * C'.u⁻¹ ^ 3 * C'.u.inv_mul
+ C.u⁻¹ ^ 4 * C'.u⁻¹ ^ 2 * (C.r * C'.r * 6 + C.r * W.a₂ * 2 - C'.s * C.r * W.a₁ * 2
- C'.s ^ 2 * C.r * 2) * pow_mul_pow_eq_one 2 C'.u.inv_mul
- C.u⁻¹ ^ 4 * ↑C'.u⁻¹ * (C.s * C'.s * C.r * 2 + C.s * C.r * W.a₁ + C'.s * C.t * 2
+ C.t * W.a₁) * pow_mul_pow_eq_one 3 C'.u.inv_mul
+ C.u⁻¹ ^ 4 * (C.r ^ 2 * 3 - C.s * C.t * 2) * pow_mul_pow_eq_one 4 C'.u.inv_mul
· linear_combination
C.r * C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 4 * (C'.r * W.a₂ * 2 - C'.r * C'.s * W.a₁ + C'.r ^ 2 * 3 + W.a₄
- C'.s * C'.t * 2 - C'.s * W.a₃ - C'.t * W.a₁) * pow_mul_pow_eq_one 2 C'.u.inv_mul
- C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 3 * C.t * (C'.r * W.a₁ + C'.t * 2 + W.a₃)
* pow_mul_pow_eq_one 3 C'.u.inv_mul
+ C.r ^ 2 * C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 2 * (C'.r * 3 + W.a₂ - C'.s * W.a₁ - C'.s ^ 2)
* pow_mul_pow_eq_one 4 C'.u.inv_mul
- C.r * C.t * C.u⁻¹ ^ 6 * ↑C'.u⁻¹ * (C'.s * 2 + W.a₁) * pow_mul_pow_eq_one 5 C'.u.inv_mul
+ C.u⁻¹ ^ 6 * (C.r ^ 3 - C.t ^ 2) * pow_mul_pow_eq_one 6 C'.u.inv_mul
lemma variableChange_a₁ : (C • W).a₁ = C.u⁻¹ * (W.a₁ + 2 * C.s) := rfl
lemma variableChange_a₂ : (C • W).a₂ = C.u⁻¹ ^ 2 * (W.a₂ - C.s * W.a₁ + 3 * C.r - C.s ^ 2) := rfl
lemma variableChange_a₃ : (C • W).a₃ = C.u⁻¹ ^ 3 * (W.a₃ + C.r * W.a₁ + 2 * C.t) := rfl
lemma variableChange_a₄ : (C • W).a₄ =
C.u⁻¹ ^ 4 * (W.a₄ - C.s * W.a₃ + 2 * C.r * W.a₂ - (C.t + C.r * C.s) * W.a₁ + 3 * C.r ^ 2
- 2 * C.s * C.t) := rfl
lemma variableChange_a₆ : (C • W).a₆ =
C.u⁻¹ ^ 6 * (W.a₆ + C.r * W.a₄ + C.r ^ 2 * W.a₂ + C.r ^ 3 - C.t * W.a₃ - C.t ^ 2
- C.r * C.t * W.a₁) := rfl
lemma variableChange_b₂ : (C • W).b₂ = C.u⁻¹ ^ 2 * (W.b₂ + 12 * C.r) := by
simp only [b₂, variableChange_a₁, variableChange_a₂]
ring1
lemma variableChange_b₄ : (C • W).b₄ = C.u⁻¹ ^ 4 * (W.b₄ + C.r * W.b₂ + 6 * C.r ^ 2) := by
simp only [b₂, b₄, variableChange_a₁, variableChange_a₃, variableChange_a₄]
ring1
lemma variableChange_b₆ : (C • W).b₆ =
C.u⁻¹ ^ 6 * (W.b₆ + 2 * C.r * W.b₄ + C.r ^ 2 * W.b₂ + 4 * C.r ^ 3) := by
simp only [b₂, b₄, b₆, variableChange_a₃, variableChange_a₆]
ring1
lemma variableChange_b₈ : (C • W).b₈ = C.u⁻¹ ^ 8 *
(W.b₈ + 3 * C.r * W.b₆ + 3 * C.r ^ 2 * W.b₄ + C.r ^ 3 * W.b₂ + 3 * C.r ^ 4) := by
simp only [b₂, b₄, b₆, b₈, variableChange_a₁, variableChange_a₂, variableChange_a₃,
variableChange_a₄, variableChange_a₆]
ring1
lemma variableChange_c₄ : (C • W).c₄ = C.u⁻¹ ^ 4 * W.c₄ := by
simp only [c₄, variableChange_b₂, variableChange_b₄]
ring1
lemma variableChange_c₆ : (C • W).c₆ = C.u⁻¹ ^ 6 * W.c₆ := by
simp only [c₆, variableChange_b₂, variableChange_b₄, variableChange_b₆]
ring1
lemma variableChange_Δ : (C • W).Δ = C.u⁻¹ ^ 12 * W.Δ := by
simp only [b₂, b₄, b₆, b₈, Δ, variableChange_a₁, variableChange_a₂, variableChange_a₃,
variableChange_a₄, variableChange_a₆]
ring1
variable [W.IsElliptic]
instance : (C • W).IsElliptic := by
rw [isElliptic_iff, variableChange_Δ]
exact (C.u⁻¹.isUnit.pow 12).mul W.isUnit_Δ
set_option linter.docPrime false in
lemma variableChange_Δ' : (C • W).Δ' = C.u⁻¹ ^ 12 * W.Δ' := by
simp_rw [Units.ext_iff, Units.val_mul, coe_Δ', variableChange_Δ, Units.val_pow_eq_pow_val]
set_option linter.docPrime false in
lemma coe_variableChange_Δ' : ((C • W).Δ' : R) = C.u⁻¹ ^ 12 * W.Δ' := by
simp_rw [coe_Δ', variableChange_Δ]
set_option linter.docPrime false in
lemma inv_variableChange_Δ' : (C • W).Δ'⁻¹ = C.u ^ 12 * W.Δ'⁻¹ := by
rw [variableChange_Δ', mul_inv, inv_pow, inv_inv]
set_option linter.docPrime false in
lemma coe_inv_variableChange_Δ' : (↑(C • W).Δ'⁻¹ : R) = C.u ^ 12 * W.Δ'⁻¹ := by
rw [inv_variableChange_Δ', Units.val_mul, Units.val_pow_eq_pow_val]
@[simp]
lemma variableChange_j : (C • W).j = W.j := by
rw [j, coe_inv_variableChange_Δ', variableChange_c₄, j, mul_pow, ← pow_mul, ← mul_assoc,
mul_right_comm (C.u.val ^ 12), ← mul_pow, C.u.mul_inv, one_pow, one_mul]
end VariableChange
section BaseChange
/-! ## Maps and base changes -/
variable {A : Type v} [CommRing A] (φ : R →+* A)
namespace VariableChange
variable (C : VariableChange R)
/-- The change of variables mapped over a ring homomorphism `φ : R →+* A`. -/
@[simps]
def map : VariableChange A :=
⟨Units.map φ C.u, φ C.r, φ C.s, φ C.t⟩
variable (A) in
/-- The change of variables base changed to an algebra `A` over `R`. -/
abbrev baseChange [Algebra R A] : VariableChange A :=
C.map <| algebraMap R A
@[simp]
lemma map_id : C.map (RingHom.id R) = C :=
rfl
lemma map_map {A : Type v} [CommRing A] (φ : R →+* A) {B : Type w} [CommRing B] (ψ : A →+* B) :
(C.map φ).map ψ = C.map (ψ.comp φ) :=
rfl
@[simp]
lemma map_baseChange {S : Type s} [CommRing S] [Algebra R S] {A : Type v} [CommRing A] [Algebra R A]
[Algebra S A] [IsScalarTower R S A] {B : Type w} [CommRing B] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (ψ : A →ₐ[S] B) : (C.baseChange A).map ψ = C.baseChange B :=
congr_arg C.map <| ψ.comp_algebraMap_of_tower R
lemma map_injective {φ : R →+* A} (hφ : Function.Injective φ) :
Function.Injective <| map (φ := φ) := fun _ _ h => by
rcases mk.inj h with ⟨h, _, _, _⟩
replace h := (Units.mk.inj h).left
ext <;> apply_fun _ using hφ <;> assumption
/-- The map over a ring homomorphism of a change of variables is a group homomorphism. -/
def mapHom : VariableChange R →* VariableChange A where
toFun := map φ
map_one' := by
simp only [one_def, map]
ext <;> simp only [map_one, Units.val_one, map_zero]
map_mul' C C' := by
simp only [mul_def, map]
ext <;> map_simp <;> simp only [Units.coe_map, MonoidHom.coe_coe]
end VariableChange
lemma map_variableChange (C : VariableChange R) : (C.map φ) • (W.map φ) = (C • W).map φ := by
simp only [map, variableChange_def, VariableChange.map]
ext <;> map_simp <;> simp only [Units.coe_map_inv, MonoidHom.coe_coe]
end BaseChange
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine.lean | import Mathlib.Algebra.Polynomial.Bivariate
import Mathlib.AlgebraicGeometry.EllipticCurve.Weierstrass
import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange
deprecated_module (since := "2025-05-03") |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Reduction.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange
import Mathlib.RingTheory.DiscreteValuationRing.Basic
import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.Valuation.Discrete.Basic
import Mathlib.GroupTheory.ArchimedeanDensely
/-!
# Reduction of Weierstrass curves over local fields
This file defines reduction of Weierstrass curves over local fields, or more generally,
fraction fields of discrete valuation rings.
## Main definitions
* `IsIntegral`: a predicate expressing that a given Weierstrass equation
has integral coefficients.
* `IsMinimal`: a predicate expressing that a given Weierstrass equation
has minimal valuation of discriminant among all isomorphic integral Weierstrass equations.
* `reduction`: the reduction of a Weierstrass curve given by a minimal Weierstrass equation,
which is a Weierstrass curve over the residue field.
* `IsGoodReduction`: a predicate expressing that a given minimal Weierstrass equation
has valuation of its discriminant equal to zero.
## Main statements
* `exists_isIntegral`: any Weierstrass curve is isomorphic to one given by
an integral Weierstrass equation.
* `exists_isMinimal`: any Weierstrass curve is isomorphic to one given by
a minimal Weierstrass equation.
## References
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, minimal weierstrass equation, reduction
-/
namespace WeierstrassCurve
section Integral
variable (R : Type*) [CommRing R]
variable {K : Type*} [Field K] [Algebra R K]
/-- A Weierstrass equation over the fraction field `K` is integral if
it has coefficients in the ring `R`. -/
@[mk_iff]
class IsIntegral (W : WeierstrassCurve K) : Prop where
integral : ∃ W_int : WeierstrassCurve R, W = W_int.baseChange K
/-- An integral model of an integral Weierstrass curve. -/
noncomputable def integralModel (W : WeierstrassCurve K) [hW : IsIntegral R W] :
WeierstrassCurve R :=
hW.integral.choose
lemma baseChange_integralModel_eq (W : WeierstrassCurve K) [hW : IsIntegral R W] :
(integralModel R W).baseChange K = W :=
hW.integral.choose_spec.symm
lemma isIntegral_of_exists_lift {W : WeierstrassCurve K}
(h₁ : ∃ r₁, (algebraMap R K) r₁ = W.a₁)
(h₂ : ∃ r₂, (algebraMap R K) r₂ = W.a₂)
(h₃ : ∃ r₃, (algebraMap R K) r₃ = W.a₃)
(h₄ : ∃ r₄, (algebraMap R K) r₄ = W.a₄)
(h₆ : ∃ r₆, (algebraMap R K) r₆ = W.a₆) :
IsIntegral R W := by
use ⟨h₁.choose, h₂.choose, h₃.choose, h₄.choose, h₆.choose⟩
ext
all_goals simp only [map_a₁, map_a₂, map_a₃, map_a₄, map_a₆]
· apply h₁.choose_spec.symm
· apply h₂.choose_spec.symm
· apply h₃.choose_spec.symm
· apply h₄.choose_spec.symm
· apply h₆.choose_spec.symm
lemma Δ_integral_of_isIntegral (W : WeierstrassCurve K) [IsIntegral R W] :
∃ r : R, algebraMap R K r = W.Δ := by
obtain ⟨W_int, hW_int⟩ : ∃ W_int : WeierstrassCurve R, W = W_int.baseChange K :=
IsIntegral.integral
use W_int.Δ
rw [hW_int, map_Δ]
lemma integralModel_Δ_eq (W : WeierstrassCurve K) [hW : IsIntegral R W] :
algebraMap R K (integralModel R W).Δ = W.Δ := by
conv_rhs => rw [← baseChange_integralModel_eq R W]
simp [integralModel]
variable [IsDomain R] [ValuationRing R] [IsFractionRing R K]
open ValuationRing
theorem exists_isIntegral (W : WeierstrassCurve K) :
∃ C : VariableChange K, IsIntegral R (C • W) := by
let l₀ := [W.a₁, W.a₂, W.a₃, W.a₄, W.a₆]
let l := l₀.map (fun a ↦ valuation R K a)
let lmax : ValueGroup R K :=
l.maximum_of_length_pos (by simp [l₀, l])
have hlmax_mem : lmax ∈ l :=
List.maximum_of_length_pos_mem (by simp [l₀, l])
have hlmax : ∀ v ∈ l, v ≤ lmax := fun v hv ↦
List.le_maximum_of_length_pos_of_mem hv (by simp [l₀, l])
by_cases hlmax_le_1 : lmax ≤ 1
· use ⟨1, 0, 0, 0⟩
apply isIntegral_of_exists_lift R
all_goals simpa [← mem_integer_iff, variableChange_def, Valuation.mem_integer_iff]
using (hlmax _ (by simp [l₀, l])).trans hlmax_le_1
· have hlmax_ge_1 : lmax ≥ 1 := le_of_not_ge hlmax_le_1
have h : ∃ a : K, valuation R K a = lmax := by
let i : ℕ := l.idxOf lmax
have hi : i < l.length := List.idxOf_lt_length_of_mem hlmax_mem
use l₀[i]
have hi₁ : (valuation R K) l₀[i] = l[i] := by simp [l]
simpa only [hi₁] using (List.getElem_idxOf hi)
choose a ha using h
have ha₀ : a ≠ 0 := by
by_contra ha₀; simp only [ha₀, map_zero] at ha
exact (ha ▸ hlmax_le_1) zero_le_one
use ⟨Units.mk0 a ha₀, 0, 0, 0⟩
apply isIntegral_of_exists_lift R
all_goals
apply (mem_integer_iff _ _ _).mp
simp only [variableChange_def, Units.val_inv_eq_inv_val, Units.val_mk0, mul_zero, add_zero,
inv_pow, zero_mul, sub_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow]
apply (Valuation.mem_integer_iff _ _).mpr
simp only [map_mul, map_inv₀, map_pow, ha]
refine inv_mul_le_one_of_le₀ ?_ zero_le'
refine (hlmax _ (by simp [l₀, l])).trans ?_
any_goals
apply le_self_pow hlmax_ge_1.le
linarith
rfl
end Integral
section Minimal
variable (R : Type*) [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
open WithZero Multiplicative
open IsDiscreteValuationRing IsDedekindDomain.HeightOneSpectrum
open Classical in
/-- The valuation of the discriminant of a Weierstrass curve `W`,
which is at most 1 if `W` is integral. Zero otherwise. -/
noncomputable def valuation_Δ_aux (W : WeierstrassCurve K) :
{ v : ℤᵐ⁰ // v ≤ 1 } :=
if h : IsIntegral R W then
⟨valuation K (maximalIdeal R) W.Δ, by
choose r hr using Δ_integral_of_isIntegral R W
rw [← hr]
exact valuation_le_one (maximalIdeal R) r⟩
else ⟨⊥, bot_le⟩
lemma valuation_Δ_aux_eq_of_isIntegral (W : WeierstrassCurve K) [hW : IsIntegral R W] :
valuation_Δ_aux R W = valuation K (maximalIdeal R) W.Δ := by
simp [valuation_Δ_aux, hW]
/-- A Weierstrass equation over the fraction field `K` is minimal if the (multiplicative) valuation
of its discriminant is maximal among all isomorphic integral Weierstrass equations.
We still use 'minimal' for the naming, so as to standardize the naming with Silverman's book. -/
@[mk_iff]
class IsMinimal (W : WeierstrassCurve K) : Prop where
val_Δ_maximal :
MaximalFor
(fun (C : VariableChange K) ↦ IsIntegral R (C • W))
(fun (C : VariableChange K) ↦ valuation_Δ_aux R (C • W))
(1 : VariableChange K)
omit [IsFractionRing R K] in
instance {W : WeierstrassCurve K} [IsMinimal R W] :
IsIntegral R W := by simpa using IsMinimal.val_Δ_maximal.1
theorem exists_isMinimal (W : WeierstrassCurve K) :
∃ C : VariableChange K, IsMinimal R (C • W) := by
obtain ⟨C, hC⟩ := exists_maximalFor_of_wellFoundedGT
(fun (C : VariableChange K) ↦ IsIntegral R (C • W))
(fun (C : VariableChange K) ↦ valuation_Δ_aux R (C • W))
(exists_isIntegral R W)
refine ⟨C, ⟨⟨by simp only [one_smul, hC.1], ?_⟩⟩⟩
intro j hj; rw [← smul_assoc] at hj
let h := hC.2 hj
simp_all only [one_smul]
rw [← smul_assoc]
exact h
/-- A minimal Weierstrass equation for a given Weierstrass curve over `K`. -/
noncomputable def minimal (W : WeierstrassCurve K) : WeierstrassCurve K :=
(W.exists_isMinimal R).choose • W
instance {W : WeierstrassCurve K} :
IsMinimal R (W.minimal R) := (W.exists_isMinimal R).choose_spec
end Minimal
section Reduction
variable (R : Type*) [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
open IsDiscreteValuationRing IsLocalRing IsDedekindDomain.HeightOneSpectrum
/-- The reduction of a Weierstrass curve over `K` given by a minimal Weierstrass equation,
which is a Weierstrass curve over the residue field of `R`. -/
noncomputable def reduction (W : WeierstrassCurve K) [IsMinimal R W] :
WeierstrassCurve (ResidueField R) :=
(integralModel R W).map (residue R)
/-- A minimal Weierstrass equation has good reduction if and only if
the valuation of its discriminant is 1. -/
@[mk_iff]
class IsGoodReduction (W : WeierstrassCurve K) [IsMinimal R W] : Prop where
goodReduction : valuation K (maximalIdeal R) W.Δ = 1
lemma isGoodReduction_iff_isElliptic_reduction {W : WeierstrassCurve K} [IsMinimal R W] :
IsGoodReduction R W ↔ (W.reduction R).IsElliptic := by
refine Iff.trans ?_ (W.reduction R).isElliptic_iff.symm
simp only [reduction, map_Δ, isUnit_iff_ne_zero, ne_eq, residue_eq_zero_iff]
have h :
¬(valuation K (maximalIdeal R) (algebraMap R K (integralModel R W).Δ) < 1)
↔ (integralModel R W).Δ ∉ IsLocalRing.maximalIdeal R :=
not_iff_not.mpr <| valuation_lt_one_iff_mem _ _
refine ((integralModel_Δ_eq R W ▸ isGoodReduction_iff _ _).trans ?_).trans h
simpa using (valuation_le_one _ _).ge_iff_eq.symm
end Reduction
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Point
import Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian.Formula
/-!
# Nonsingular points and the group law in Jacobian coordinates
Let `W` be a Weierstrass curve over a field `F`. The nonsingular Jacobian points of `W` can be
endowed with a group law, which is uniquely determined by the formulae in
`Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Formula.lean` and follows from an equivalence with
the nonsingular points `W⟮F⟯` in affine coordinates.
This file defines the group law on nonsingular Jacobian points.
## Main definitions
* `WeierstrassCurve.Jacobian.neg`: the negation of a point representative.
* `WeierstrassCurve.Jacobian.negMap`: the negation of a point class.
* `WeierstrassCurve.Jacobian.add`: the addition of two point representatives.
* `WeierstrassCurve.Jacobian.addMap`: the addition of two point classes.
* `WeierstrassCurve.Jacobian.Point`: a nonsingular Jacobian point.
* `WeierstrassCurve.Jacobian.Point.neg`: the negation of a nonsingular Jacobian point.
* `WeierstrassCurve.Jacobian.Point.add`: the addition of two nonsingular Jacobian points.
* `WeierstrassCurve.Jacobian.Point.toAffineAddEquiv`: the equivalence between the type of
nonsingular Jacobian points with the type of nonsingular points `W⟮F⟯` in affine coordinates.
## Main statements
* `WeierstrassCurve.Jacobian.nonsingular_neg`: negation preserves the nonsingular condition.
* `WeierstrassCurve.Jacobian.nonsingular_add`: addition preserves the nonsingular condition.
* `WeierstrassCurve.Jacobian.Point.instAddCommGroup`: the type of nonsingular Jacobian points forms
an abelian group under addition.
## Implementation notes
Note that `W(X, Y, Z)` and its partial derivatives are independent of the point representative, and
the nonsingularity condition already implies `(x, y, z) ≠ (0, 0, 0)`, so a nonsingular Jacobian
point on `W` can be given by `[x : y : z]` and the nonsingular condition on any representative.
A nonsingular Jacobian point representative can be converted to a nonsingular point in affine
coordinates using `WeierstrassCurve.Jacobian.Point.toAffine`, which lifts to a map on nonsingular
Jacobian points using `WeierstrassCurve.Jacobian.Point.toAffineLift`. Conversely, a nonsingular
point in affine coordinates can be converted to a nonsingular Jacobian point using
`WeierstrassCurve.Jacobian.Point.fromAffine` or `WeierstrassCurve.Affine.Point.toJacobian`.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, Jacobian, point, group law
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} [CommRing R] [CommRing S]
[CommRing A] [CommRing B] [Field F] [Field K] {W' : Jacobian R} {W : Jacobian F}
namespace Jacobian
/-! ## Negation on Jacobian point representatives -/
variable (W') in
/-- The negation of a Jacobian point representative on a Weierstrass curve. -/
def neg (P : Fin 3 → R) : Fin 3 → R :=
![P x, W'.negY P, P z]
lemma neg_X (P : Fin 3 → R) : W'.neg P x = P x :=
rfl
lemma neg_Y (P : Fin 3 → R) : W'.neg P y = W'.negY P :=
rfl
lemma neg_Z (P : Fin 3 → R) : W'.neg P z = P z :=
rfl
protected lemma neg_smul (P : Fin 3 → R) (u : R) : W'.neg (u • P) = u • W'.neg P := by
rw [neg, negY_smul]
rfl
lemma neg_smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.neg (u • P) ≈ W'.neg P :=
⟨hu.unit, (W'.neg_smul ..).symm⟩
lemma neg_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.neg P ≈ W'.neg Q := by
rcases h with ⟨u, rfl⟩
exact neg_smul_equiv Q u.isUnit
lemma neg_of_Z_eq_zero' {P : Fin 3 → R} (hPz : P z = 0) : W'.neg P = ![P x, -P y, 0] := by
rw [neg, negY_of_Z_eq_zero hPz, hPz]
lemma neg_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
W.neg P = -(P y / P x) • ![1, 1, 0] := by
have hX {n : ℕ} : IsUnit <| P x ^ n := (isUnit_X_of_Z_eq_zero hP hPz).pow n
erw [neg_of_Z_eq_zero' hPz, smul_fin3, neg_sq, div_pow, (equation_of_Z_eq_zero hPz).mp hP.left,
pow_succ, hX.mul_div_cancel_left, mul_one, Odd.neg_pow <| by decide, div_pow, pow_succ,
(equation_of_Z_eq_zero hPz).mp hP.left, hX.mul_div_cancel_left, mul_one, mul_zero]
lemma neg_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.neg P = P z • ![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1] := by
erw [neg, smul_fin3, mul_div_cancel₀ _ <| pow_ne_zero 2 hPz, ← negY_of_Z_ne_zero hPz,
mul_div_cancel₀ _ <| pow_ne_zero 3 hPz, mul_one]
private lemma nonsingular_neg_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
W.Nonsingular ![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1] :=
(nonsingular_some ..).mpr <| (Affine.nonsingular_neg ..).mpr <|
(nonsingular_of_Z_ne_zero hPz).mp hP
lemma nonsingular_neg {P : Fin 3 → F} (hP : W.Nonsingular P) : W.Nonsingular <| W.neg P := by
by_cases hPz : P z = 0
· simp only [neg_of_Z_eq_zero hP hPz, nonsingular_smul _
((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg, nonsingular_zero]
· simp only [neg_of_Z_ne_zero hPz, nonsingular_smul _ <| Ne.isUnit hPz,
nonsingular_neg_of_Z_ne_zero hP hPz]
lemma addZ_neg (P : Fin 3 → R) : addZ P (W'.neg P) = 0 :=
addZ_of_X_eq rfl
lemma addX_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.addX P (W'.neg P) = W'.dblZ P ^ 2 := by
linear_combination (norm := (rw [addX, neg_X, neg_Y, neg_Z, dblZ, negY]; ring1))
-2 * P z ^ 2 * (equation_iff _).mp hP
lemma negAddY_neg {P : Fin 3 → R} (hP : W'.Equation P) :
W'.negAddY P (W'.neg P) = W'.dblZ P ^ 3 := by
linear_combination (norm := (rw [negAddY, neg_X, neg_Y, neg_Z, dblZ, negY]; ring1))
-2 * P z ^ 3 * (P y - W'.negY P) * (equation_iff _).mp hP
lemma addY_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.addY P (W'.neg P) = -W'.dblZ P ^ 3 := by
rw [addY, addX_neg hP, negAddY_neg hP, addZ_neg, negY_of_Z_eq_zero rfl]
rfl
lemma addXYZ_neg {P : Fin 3 → R} (hP : W'.Equation P) :
W'.addXYZ P (W'.neg P) = -W'.dblZ P • ![1, 1, 0] := by
erw [addXYZ, addX_neg hP, addY_neg hP, addZ_neg, smul_fin3, neg_sq, mul_one,
Odd.neg_pow <| by decide, mul_one, mul_zero]
variable (W') in
/-- The negation of a Jacobian point class on a Weierstrass curve `W`.
If `P` is a Jacobian point representative on `W`, then `W.negMap ⟦P⟧` is definitionally equivalent
to `W.neg P`. -/
def negMap (P : PointClass R) : PointClass R :=
P.map W'.neg fun _ _ => neg_equiv
lemma negMap_eq (P : Fin 3 → R) : W'.negMap ⟦P⟧ = ⟦W'.neg P⟧ :=
rfl
lemma negMap_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
W.negMap ⟦P⟧ = ⟦![1, 1, 0]⟧ := by
rw [negMap_eq, neg_of_Z_eq_zero hP hPz,
smul_eq _ ((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg]
lemma negMap_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negMap ⟦P⟧ = ⟦![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1]⟧ := by
rw [negMap_eq, neg_of_Z_ne_zero hPz, smul_eq _ <| Ne.isUnit hPz]
lemma nonsingularLift_negMap {P : PointClass F} (hP : W.NonsingularLift P) :
W.NonsingularLift <| W.negMap P := by
rcases P with ⟨_⟩
exact nonsingular_neg hP
/-! ## Addition on Jacobian point representatives -/
open scoped Classical in
variable (W') in
/-- The addition of two Jacobian point representatives on a Weierstrass curve. -/
noncomputable def add (P Q : Fin 3 → R) : Fin 3 → R :=
if P ≈ Q then W'.dblXYZ P else W'.addXYZ P Q
lemma add_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.add P Q = W'.dblXYZ P :=
if_pos h
lemma add_smul_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) = u ^ 4 • W'.add P Q := by
rw [add_of_equiv <| (smul_equiv_smul P Q hu hv).mpr h, dblXYZ_smul, add_of_equiv h]
lemma add_self (P : Fin 3 → R) : W'.add P P = W'.dblXYZ P :=
add_of_equiv <| Setoid.refl _
lemma add_of_eq {P Q : Fin 3 → R} (h : P = Q) : W'.add P Q = W'.dblXYZ P :=
h ▸ add_self P
lemma add_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) : W'.add P Q = W'.addXYZ P Q :=
if_neg h
lemma add_smul_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) {u v : R} (hu : IsUnit u)
(hv : IsUnit v) : W'.add (u • P) (v • Q) = (u * v) ^ 2 • W'.add P Q := by
rw [add_of_not_equiv <| h.comp (smul_equiv_smul P Q hu hv).mp, addXYZ_smul, add_of_not_equiv h]
lemma add_smul_equiv (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) ≈ W'.add P Q := by
by_cases h : P ≈ Q
· exact ⟨hu.unit ^ 4, by convert (add_smul_of_equiv h hu hv).symm⟩
· exact ⟨(hu.unit * hv.unit) ^ 2, by convert (add_smul_of_not_equiv h hu hv).symm⟩
lemma add_equiv {P P' Q Q' : Fin 3 → R} (hP : P ≈ P') (hQ : Q ≈ Q') :
W'.add P Q ≈ W'.add P' Q' := by
rcases hP, hQ with ⟨⟨u, rfl⟩, ⟨v, rfl⟩⟩
exact add_smul_equiv P' Q' u.isUnit v.isUnit
lemma add_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : W.add P Q = P x ^ 2 • ![1, 1, 0] := by
rw [add_of_equiv <| equiv_of_Z_eq_zero hP hQ hPz hQz, dblXYZ_of_Z_eq_zero hP.left hPz]
lemma add_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) (hQz : Q z ≠ 0) :
W'.add P Q = (P x * Q z) • Q := by
rw [add_of_not_equiv <| not_equiv_of_Z_eq_zero_left hPz hQz, addXYZ_of_Z_eq_zero_left hP hPz]
lemma add_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z = 0) : W'.add P Q = -(Q x * P z) • P := by
rw [add_of_not_equiv <| not_equiv_of_Z_eq_zero_right hPz hQz, addXYZ_of_Z_eq_zero_right hQ hQz]
lemma add_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.add P Q = W.dblU P • ![1, 1, 0] := by
rw [add_of_equiv <| equiv_of_X_eq_of_Y_eq hPz hQz hx hy, dblXYZ_of_Y_eq hQz hx hy hy']
lemma add_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
W.add P Q = addU P Q • ![1, 1, 0] := by
rw [add_of_not_equiv <| not_equiv_of_Y_ne hy, addXYZ_of_X_eq hP hQ hPz hQz hx]
lemma add_of_Y_ne' [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.add P Q = W.dblZ P •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
rw [add_of_equiv <| equiv_of_X_eq_of_Y_eq hPz hQz hx <| Y_eq_of_Y_ne' hP hQ hx hy,
dblXYZ_of_Z_ne_zero hP hQ hPz hQz hx hy]
lemma add_of_X_ne [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : W.add P Q = addZ P Q •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
rw [add_of_not_equiv <| not_equiv_of_X_ne hx, addXYZ_of_Z_ne_zero hP hQ hPz hQz hx]
private lemma nonsingular_add_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : ¬(P x * Q z ^ 2 = Q x * P z ^ 2 ∧ P y * Q z ^ 3 = W.negY Q * P z ^ 3)) : W.Nonsingular
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)), 1] :=
(nonsingular_some ..).mpr <| Affine.nonsingular_add ((nonsingular_of_Z_ne_zero hPz).mp hP)
((nonsingular_of_Z_ne_zero hQz).mp hQ) <| by rwa [← X_eq_iff hPz hQz, ← Y_eq_iff' hPz hQz]
lemma nonsingular_add {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
W.Nonsingular <| W.add P Q := by
by_cases hPz : P z = 0
· by_cases hQz : Q z = 0
· simp only [add_of_Z_eq_zero hP hQ hPz hQz,
nonsingular_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, nonsingular_zero]
· simpa only [add_of_Z_eq_zero_left hP.left hPz hQz,
nonsingular_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· simpa only [add_of_Z_eq_zero_right hQ.left hPz hQz,
nonsingular_smul _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg]
· by_cases hxy : P x * Q z ^ 2 = Q x * P z ^ 2 ∧ P y * Q z ^ 3 = W.negY Q * P z ^ 3
· by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· simp only [add_of_Y_eq hPz hQz hxy.left hy hxy.right, nonsingular_smul _ <|
isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, nonsingular_zero]
· simp only [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
nonsingular_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, nonsingular_zero]
· classical
have := nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy
by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· simpa only [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| not_and.mp hxy hx,
nonsingular_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hx <| not_and.mp hxy hx]
· simpa only [add_of_X_ne hP.left hQ.left hPz hQz hx,
nonsingular_smul _ <| isUnit_addZ_of_X_ne hx]
variable (W') in
/-- The addition of two Jacobian point classes on a Weierstrass curve `W`.
If `P` and `Q` are two Jacobian point representatives on `W`, then `W.addMap ⟦P⟧ ⟦Q⟧` is
definitionally equivalent to `W.add P Q`. -/
noncomputable def addMap (P Q : PointClass R) : PointClass R :=
Quotient.map₂ W'.add (fun _ _ hP _ _ hQ => add_equiv hP hQ) P Q
lemma addMap_eq (P Q : Fin 3 → R) : W'.addMap ⟦P⟧ ⟦Q⟧ = ⟦W'.add P Q⟧ :=
rfl
lemma addMap_of_Z_eq_zero_left {P : Fin 3 → F} {Q : PointClass F} (hP : W.Nonsingular P)
(hQ : W.NonsingularLift Q) (hPz : P z = 0) : W.addMap ⟦P⟧ Q = Q := by
revert hQ
refine Q.inductionOn (motive := fun Q => _ → W.addMap _ Q = Q) fun Q hQ => ?_
by_cases hQz : Q z = 0
· rw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hQ hQz
· rw [addMap_eq, add_of_Z_eq_zero_left hP.left hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
lemma addMap_of_Z_eq_zero_right {P : PointClass F} {Q : Fin 3 → F} (hP : W.NonsingularLift P)
(hQ : W.Nonsingular Q) (hQz : Q z = 0) : W.addMap P ⟦Q⟧ = P := by
revert hP
refine P.inductionOn (motive := fun P => _ → W.addMap P _ = P) fun P hP => ?_
by_cases hPz : P z = 0
· rw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· rw [addMap_eq, add_of_Z_eq_zero_right hQ.left hPz hQz,
smul_eq _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg]
lemma addMap_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.addMap ⟦P⟧ ⟦Q⟧ = ⟦![1, 1, 0]⟧ := by
by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· rw [addMap_eq, add_of_Y_eq hPz hQz hx hy hy',
smul_eq _ <| isUnit_dblU_of_Y_eq hP hPz hQz hx hy hy']
· rw [addMap_eq, add_of_Y_ne hP.left hQ hPz hQz hx hy,
smul_eq _ <| isUnit_addU_of_Y_ne hPz hQz hy]
lemma addMap_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : ¬(P x * Q z ^ 2 = Q x * P z ^ 2 ∧ P y * Q z ^ 3 = W.negY Q * P z ^ 3)) :
W.addMap ⟦P⟧ ⟦Q⟧ =
⟦![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1]⟧ := by
by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· rw [addMap_eq, add_of_Y_ne' hP hQ hPz hQz hx <| not_and.mp hxy hx,
smul_eq _ <| isUnit_dblZ_of_Y_ne' hP hQ hPz hx <| not_and.mp hxy hx]
· rw [addMap_eq, add_of_X_ne hP hQ hPz hQz hx, smul_eq _ <| isUnit_addZ_of_X_ne hx]
lemma nonsingularLift_addMap {P Q : PointClass F} (hP : W.NonsingularLift P)
(hQ : W.NonsingularLift Q) : W.NonsingularLift <| W.addMap P Q := by
rcases P; rcases Q
exact nonsingular_add hP hQ
/-! ## Nonsingular Jacobian points -/
variable (W') in
/-- A nonsingular Jacobian point on a Weierstrass curve `W`. -/
@[ext]
structure Point where
/-- The Jacobian point class underlying a nonsingular Jacobian point on `W`. -/
{point : PointClass R}
/-- The nonsingular condition underlying a nonsingular Jacobian point on `W`. -/
(nonsingular : W'.NonsingularLift point)
namespace Point
lemma mk_point {P : PointClass R} (h : W'.NonsingularLift P) : (mk h).point = P :=
rfl
instance [Nontrivial R] : Zero W'.Point :=
⟨⟨nonsingularLift_zero⟩⟩
lemma zero_def [Nontrivial R] : (0 : W'.Point) = ⟨nonsingularLift_zero⟩ :=
rfl
lemma zero_point [Nontrivial R] : (0 : W'.Point).point = ⟦![1, 1, 0]⟧ :=
rfl
lemma mk_ne_zero [Nontrivial R] {X Y : R} (h : W'.NonsingularLift ⟦![X, Y, 1]⟧) : mk h ≠ 0 :=
(not_equiv_of_Z_eq_zero_right one_ne_zero rfl).comp <| Quotient.eq.mp.comp Point.ext_iff.mp
/-- The natural map from a nonsingular point on a Weierstrass curve in affine coordinates to its
corresponding nonsingular Jacobian point. -/
def fromAffine [Nontrivial R] : W'.toAffine.Point → W'.Point
| 0 => 0
| .some h => ⟨(nonsingularLift_some ..).mpr h⟩
lemma fromAffine_zero [Nontrivial R] : fromAffine 0 = (0 : W'.Point) :=
rfl
lemma fromAffine_some [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) = ⟨(nonsingularLift_some ..).mpr h⟩ :=
rfl
lemma fromAffine_some_ne_zero [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) ≠ 0 :=
mk_ne_zero <| (nonsingularLift_some ..).mpr h
/-- The negation of a nonsingular Jacobian point on a Weierstrass curve `W`.
Given a nonsingular Jacobian point `P` on `W`, use `-P` instead of `neg P`. -/
def neg (P : W.Point) : W.Point :=
⟨nonsingularLift_negMap P.nonsingular⟩
instance : Neg W.Point :=
⟨neg⟩
lemma neg_def (P : W.Point) : -P = P.neg :=
rfl
lemma neg_point (P : W.Point) : (-P).point = W.negMap P.point :=
rfl
/-- The addition of two nonsingular Jacobian points on a Weierstrass curve `W`.
Given two nonsingular Jacobian points `P` and `Q` on `W`, use `P + Q` instead of `add P Q`. -/
noncomputable def add (P Q : W.Point) : W.Point :=
⟨nonsingularLift_addMap P.nonsingular Q.nonsingular⟩
noncomputable instance : Add W.Point :=
⟨add⟩
lemma add_def (P Q : W.Point) : P + Q = P.add Q :=
rfl
lemma add_point (P Q : W.Point) : (P + Q).point = W.addMap P.point Q.point :=
rfl
/-! ## Equivalence between Jacobian and affine coordinates -/
open scoped Classical in
variable (W) in
/-- The natural map from a nonsingular Jacobian point representative on a Weierstrass curve to its
corresponding nonsingular point in affine coordinates. -/
noncomputable def toAffine (P : Fin 3 → F) : W.toAffine.Point :=
if hP : W.Nonsingular P ∧ P z ≠ 0 then .some <| (nonsingular_of_Z_ne_zero hP.2).mp hP.1 else 0
lemma toAffine_of_singular {P : Fin 3 → F} (hP : ¬W.Nonsingular P) : toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_of_not_left _ hP]
lemma toAffine_of_Z_eq_zero {P : Fin 3 → F} (hPz : P z = 0) : toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_not_right.mpr fun _ => hPz]
lemma toAffine_zero : toAffine W ![1, 1, 0] = 0 :=
toAffine_of_Z_eq_zero rfl
lemma toAffine_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
toAffine W P = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) := by
rw [toAffine, dif_pos ⟨hP, hPz⟩]
lemma toAffine_some {X Y : F} (h : W.Nonsingular ![X, Y, 1]) :
toAffine W ![X, Y, 1] = .some ((nonsingular_some ..).mp h) := by
simp only [toAffine_of_Z_ne_zero h one_ne_zero, fin3_def_ext, one_pow, div_one]
lemma toAffine_smul (P : Fin 3 → F) {u : F} (hu : IsUnit u) :
toAffine W (u • P) = toAffine W P := by
by_cases hP : W.Nonsingular P
· by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero <| mul_eq_zero_of_right u hPz, toAffine_of_Z_eq_zero hPz]
· rw [toAffine_of_Z_ne_zero ((nonsingular_smul P hu).mpr hP) <| mul_ne_zero hu.ne_zero hPz,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.some.injEq]
simp only [smul_fin3_ext, mul_pow, mul_div_mul_left _ _ (hu.pow _).ne_zero, and_self]
· rw [toAffine_of_singular <| hP.comp (nonsingular_smul P hu).mp, toAffine_of_singular hP]
lemma toAffine_of_equiv {P Q : Fin 3 → F} (h : P ≈ Q) : toAffine W P = toAffine W Q := by
rcases h with ⟨u, rfl⟩
exact toAffine_smul Q u.isUnit
lemma toAffine_neg {P : Fin 3 → F} (hP : W.Nonsingular P) :
toAffine W (W.neg P) = -toAffine W P := by
by_cases hPz : P z = 0
· rw [neg_of_Z_eq_zero hP hPz,
toAffine_smul _ ((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg,
toAffine_zero, toAffine_of_Z_eq_zero hPz, Affine.Point.neg_zero]
· rw [neg_of_Z_ne_zero hPz, toAffine_smul _ <| Ne.isUnit hPz, toAffine_some <|
(nonsingular_smul _ <| Ne.isUnit hPz).mp <| neg_of_Z_ne_zero hPz ▸ nonsingular_neg hP,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.neg_some]
private lemma toAffine_add_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Nonsingular P) (hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : ¬(P x * Q z ^ 2 = Q x * P z ^ 2 ∧ P y * Q z ^ 3 = W.negY Q * P z ^ 3)) : toAffine W
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] = toAffine W P + toAffine W Q := by
rw [toAffine_some <| nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy, toAffine_of_Z_ne_zero hP hPz,
toAffine_of_Z_ne_zero hQ hQz,
Affine.Point.add_some <| by rwa [← X_eq_iff hPz hQz, ← Y_eq_iff' hPz hQz]]
lemma toAffine_add [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
toAffine W (W.add P Q) = toAffine W P + toAffine W Q := by
by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero hPz, zero_add]
by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero hP hQ hPz hQz, toAffine_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2,
toAffine_zero, toAffine_of_Z_eq_zero hQz]
· rw [add_of_Z_eq_zero_left hP.left hPz hQz,
toAffine_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero_right hQ.left hPz hQz,
toAffine_smul _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg,
toAffine_of_Z_eq_zero hQz, add_zero]
· by_cases hxy : P x * Q z ^ 2 = Q x * P z ^ 2 ∧ P y * Q z ^ 3 = W.negY Q * P z ^ 3
· rw [toAffine_of_Z_ne_zero hP hPz, toAffine_of_Z_ne_zero hQ hQz, Affine.Point.add_of_Y_eq
((X_eq_iff hPz hQz).mp hxy.left) ((Y_eq_iff' hPz hQz).mp hxy.right)]
by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· rw [add_of_Y_eq hPz hQz hxy.left hy hxy.right,
toAffine_smul _ <| isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, toAffine_zero]
· rw [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
toAffine_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, toAffine_zero]
· have := toAffine_add_of_Z_ne_zero hP hQ hPz hQz hxy
by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· rwa [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| not_and.mp hxy hx,
toAffine_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hx <| not_and.mp hxy hx]
· rwa [add_of_X_ne hP.left hQ.left hPz hQz hx, toAffine_smul _ <| isUnit_addZ_of_X_ne hx]
/-- The natural map from a nonsingular Jacobian point on a Weierstrass curve `W` to its
corresponding nonsingular point in affine coordinates.
If `hP` is the nonsingular condition underlying a nonsingular Jacobian point `P` on `W`, then
`toAffineLift ⟨hP⟩` is definitionally equivalent to `toAffine W P`. -/
noncomputable def toAffineLift (P : W.Point) : W.toAffine.Point :=
P.point.lift _ fun _ _ => toAffine_of_equiv
lemma toAffineLift_eq {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) :
toAffineLift ⟨hP⟩ = toAffine W P :=
rfl
lemma toAffineLift_of_Z_eq_zero {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) (hPz : P z = 0) :
toAffineLift ⟨hP⟩ = 0 :=
toAffine_of_Z_eq_zero hPz
lemma toAffineLift_zero : toAffineLift (0 : W.Point) = 0 :=
toAffine_zero
lemma toAffineLift_of_Z_ne_zero {P : Fin 3 → F} {hP : W.NonsingularLift ⟦P⟧} (hPz : P z ≠ 0) :
toAffineLift ⟨hP⟩ = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) :=
toAffine_of_Z_ne_zero hP hPz
lemma toAffineLift_some {X Y : F} (h : W.NonsingularLift ⟦![X, Y, 1]⟧) :
toAffineLift ⟨h⟩ = .some ((nonsingular_some ..).mp h) :=
toAffine_some h
lemma toAffineLift_neg (P : W.Point) : (-P).toAffineLift = -P.toAffineLift := by
rcases P with @⟨⟨_⟩, hP⟩
exact toAffine_neg hP
lemma toAffineLift_add [DecidableEq F] (P Q : W.Point) :
(P + Q).toAffineLift = P.toAffineLift + Q.toAffineLift := by
rcases P, Q with ⟨@⟨⟨_⟩, hP⟩, @⟨⟨_⟩, hQ⟩⟩
exact toAffine_add hP hQ
variable (W) in
/-- The addition-preserving equivalence between the type of nonsingular Jacobian points on a
Weierstrass curve `W` and the type of nonsingular points `W⟮F⟯` in affine coordinates. -/
@[simps]
noncomputable def toAffineAddEquiv [DecidableEq F] : W.Point ≃+ W.toAffine.Point where
toFun := toAffineLift
invFun := fromAffine
left_inv := by
rintro @⟨⟨P⟩, hP⟩
by_cases hPz : P z = 0
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_eq_zero hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_ne_zero hP hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_some_of_Z_ne_zero hPz
right_inv := by
rintro (_ | _)
· rw [← Affine.Point.zero_def, fromAffine_zero, toAffineLift_zero]
· rw [fromAffine_some, toAffineLift_some]
map_add' := toAffineLift_add
noncomputable instance : AddCommGroup W.Point where
nsmul := nsmulRec
zsmul := zsmulRec
zero_add _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, zero_add]
add_zero _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, add_zero]
neg_add_cancel P := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_neg, neg_add_cancel, toAffineLift_zero]
add_comm _ _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, add_comm]
add_assoc _ _ _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, add_assoc]
end Point
/-! ## Maps and base changes -/
@[simp]
protected lemma map_neg (f : R →+* S) (P : Fin 3 → R) :
(W'.map f).toJacobian.neg (f ∘ P) = f ∘ W'.neg P := by
simp only [neg, map_negY, comp_fin3]
map_simp
@[simp]
protected lemma map_add (f : F →+* K) {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) : (W.map f).toJacobian.add (f ∘ P) (f ∘ Q) = f ∘ W.add P Q := by
by_cases h : P ≈ Q
· rw [add_of_equiv <| (comp_equiv_comp f hP hQ).mpr h, add_of_equiv h, map_dblXYZ]
· rw [add_of_not_equiv <| h.comp (comp_equiv_comp f hP hQ).mp, add_of_not_equiv h, map_addXYZ]
lemma baseChange_neg [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B]
[Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B) (P : Fin 3 → A) :
(W'.baseChange B).toJacobian.neg (f ∘ P) = f ∘ (W'.baseChange A).toJacobian.neg P := by
rw [← RingHom.coe_coe, ← WeierstrassCurve.Jacobian.map_neg, map_baseChange]
lemma baseChange_add [Algebra R S] [Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebra R K]
[Algebra S K] [IsScalarTower R S K] (f : F →ₐ[S] K) {P Q : Fin 3 → F}
(hP : (W'.baseChange F).toJacobian.Nonsingular P)
(hQ : (W'.baseChange F).toJacobian.Nonsingular Q) :
(W'.baseChange K).toJacobian.add (f ∘ P) (f ∘ Q) =
f ∘ (W'.baseChange F).toJacobian.add P Q := by
rw [← RingHom.coe_coe, ← WeierstrassCurve.Jacobian.map_add _ hP hQ, map_baseChange]
end Jacobian
/-- An abbreviation for `WeierstrassCurve.Jacobian.Point.fromAffine` for dot notation. -/
abbrev Affine.Point.toJacobian [Nontrivial R] {W : Affine R} (P : W.Point) : W.toJacobian.Point :=
Jacobian.Point.fromAffine P
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean | import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic
import Mathlib.Data.Fin.Tuple.Reflection
import Mathlib.Tactic.Ring.NamePolyVars
/-!
# Weierstrass equations and the nonsingular condition in Jacobian coordinates
A point on the projective plane over a commutative ring `R` with weights `(2, 3, 1)` is an
equivalence class `[x : y : z]` of triples `(x, y, z) ≠ (0, 0, 0)` of elements in `R` such that
`(x, y, z) ∼ (x', y', z')` if there is some unit `u` in `Rˣ` with `(x, y, z) = (u²x', u³y', uz')`.
Let `W` be a Weierstrass curve over a commutative ring `R` with coefficients `aᵢ`. A
*Jacobian point* is a point on the projective plane over `R` with weights `(2, 3, 1)` satisfying the
*`(2, 3, 1)`-homogeneous Weierstrass equation* `W(X, Y, Z) = 0` in *Jacobian coordinates*, where
`W(X, Y, Z) := Y² + a₁XYZ + a₃YZ³ - (X³ + a₂X²Z² + a₄XZ⁴ + a₆Z⁶)`. It is *nonsingular* if its
partial derivatives `W_X(x, y, z)`, `W_Y(x, y, z)`, and `W_Z(x, y, z)` do not vanish simultaneously.
This file gives an explicit implementation of equivalence classes of triples up to scaling by
weights, and defines polynomials associated to Weierstrass equations and the nonsingular condition
in Jacobian coordinates. The group law on the actual type of nonsingular Jacobian points will be
defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean`, based on the formulae for
group operations in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Formula.lean`.
## Main definitions
* `WeierstrassCurve.Jacobian.PointClass`: the equivalence class of a point representative.
* `WeierstrassCurve.Jacobian.Nonsingular`: the nonsingular condition on a point representative.
* `WeierstrassCurve.Jacobian.NonsingularLift`: the nonsingular condition on a point class.
## Main statements
* `WeierstrassCurve.Jacobian.polynomial_relation`: Euler's homogeneous function theorem.
## Implementation notes
All definitions and lemmas for Weierstrass curves in Jacobian coordinates live in the namespace
`WeierstrassCurve.Jacobian` to distinguish them from those in other coordinates. This is simply an
abbreviation for `WeierstrassCurve` that can be converted using `WeierstrassCurve.toJacobian`. This
can be converted into `WeierstrassCurve.Affine` using `WeierstrassCurve.Jacobian.toAffine`.
A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector
notation `![x, y, z]`. However, `P` is not syntactically equivalent to the expanded vector
`![P x, P y, P z]`, so the lemmas `fin3_def` and `fin3_def_ext` can be used to convert between the
two forms. The equivalence of two point representatives `P` and `Q` is implemented as an equivalence
of orbits of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that
`P = u • Q`. However, `u • Q` is not syntactically equal to `![u² * Q x, u³ * Q y, u * Q z]`, so the
lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms. Files in
`Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian` make extensive use of `erw` to get around this.
While `erw` is often an indication of a problem, in this case it is self-contained and should not
cause any issues. It would alternatively be possible to add some automation to assist here.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, Jacobian, Weierstrass equation, nonsingular
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, eval_pow])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
local macro "matrix_simp" : tactic =>
`(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons,
Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two])
local macro "pderiv_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow,
pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm,
pderiv_X_of_ne (by decide : z ≠ x), pderiv_X_of_ne (by decide : x ≠ z),
pderiv_X_of_ne (by decide : z ≠ y), pderiv_X_of_ne (by decide : y ≠ z)])
universe r s u v
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v}
name_poly_vars X, Y, Z over R
namespace WeierstrassCurve
/-! ## Jacobian coordinates -/
variable (R) in
/-- An abbreviation for a Weierstrass curve in Jacobian coordinates. -/
abbrev Jacobian : Type r :=
WeierstrassCurve R
/-- The conversion from a Weierstrass curve to Jacobian coordinates. -/
abbrev toJacobian (W : WeierstrassCurve R) : Jacobian R :=
W
namespace Jacobian
/-- The conversion from a Weierstrass curve in Jacobian coordinates to affine coordinates. -/
abbrev toAffine (W' : Jacobian R) : Affine R :=
W'
lemma fin3_def (P : Fin 3 → R) : ![P x, P y, P z] = P := by
ext n; fin_cases n <;> rfl
lemma fin3_def_ext (a b c : R) : ![a, b, c] x = a ∧ ![a, b, c] y = b ∧ ![a, b, c] z = c :=
⟨rfl, rfl, rfl⟩
lemma comp_fin3 (f : R → S) (a b c : R) : f ∘ ![a, b, c] = ![f a, f b, f c] :=
(FinVec.map_eq ..).symm
variable [CommRing R] [CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] {W' : Jacobian R}
{W : Jacobian F}
/-- The scalar multiplication for a Jacobian point representative on a Weierstrass curve. -/
scoped instance : SMul R <| Fin 3 → R :=
⟨fun u P => ![u ^ 2 * P x, u ^ 3 * P y, u * P z]⟩
lemma smul_fin3 (P : Fin 3 → R) (u : R) : u • P = ![u ^ 2 * P x, u ^ 3 * P y, u * P z] :=
rfl
lemma smul_fin3_ext (P : Fin 3 → R) (u : R) :
(u • P) x = u ^ 2 * P x ∧ (u • P) y = u ^ 3 * P y ∧ (u • P) z = u * P z :=
⟨rfl, rfl, rfl⟩
lemma comp_smul (f : R →+* S) (P : Fin 3 → R) (u : R) : f ∘ (u • P) = f u • f ∘ P := by
ext n; fin_cases n <;> simp only [smul_fin3, comp_fin3] <;> map_simp
/-- The multiplicative action for a Jacobian point representative on a Weierstrass curve. -/
scoped instance : MulAction R <| Fin 3 → R where
one_smul _ := by simp only [smul_fin3, one_pow, one_mul, fin3_def]
mul_smul _ _ _ := by simp only [smul_fin3, mul_pow, mul_assoc, fin3_def_ext]
/-- The equivalence setoid for a Jacobian point representative on a Weierstrass curve. -/
@[reducible]
scoped instance : Setoid <| Fin 3 → R :=
MulAction.orbitRel Rˣ <| Fin 3 → R
variable (R) in
/-- The equivalence class of a Jacobian point representative on a Weierstrass curve. -/
abbrev PointClass : Type r :=
MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R
lemma smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : u • P ≈ P :=
⟨hu.unit, rfl⟩
@[simp]
lemma smul_eq (P : Fin 3 → R) {u : R} (hu : IsUnit u) : (⟦u • P⟧ : PointClass R) = ⟦P⟧ :=
Quotient.eq.mpr <| smul_equiv P hu
lemma smul_equiv_smul (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
u • P ≈ v • Q ↔ P ≈ Q := by
rw [← Quotient.eq_iff_equiv, ← Quotient.eq_iff_equiv, smul_eq P hu, smul_eq Q hv]
lemma equiv_iff_eq_of_Z_eq' {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ∈ nonZeroDivisors R) :
P ≈ Q ↔ P = Q := by
refine ⟨?_, Quotient.exact.comp <| congrArg _⟩
rintro ⟨u, rfl⟩
simp only [Units.smul_def, (mul_cancel_right_mem_nonZeroDivisors hQz).mp <| one_mul (Q z) ▸ hz]
rw [one_smul]
lemma equiv_iff_eq_of_Z_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ≠ 0) :
P ≈ Q ↔ P = Q :=
equiv_iff_eq_of_Z_eq' hz <| mem_nonZeroDivisors_of_ne_zero hQz
lemma Z_eq_zero_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P z = 0 ↔ Q z = 0 := by
rcases h with ⟨_, rfl⟩
simp only [Units.smul_def, smul_fin3_ext, Units.mul_right_eq_zero]
lemma X_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P x * Q z ^ 2 = Q x * P z ^ 2 := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma Y_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P y * Q z ^ 3 = Q y * P z ^ 3 := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma not_equiv_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) (hQz : Q z ≠ 0) : ¬P ≈ Q :=
fun h => hQz <| (Z_eq_zero_of_equiv h).mp hPz
lemma not_equiv_of_Z_eq_zero_right {P Q : Fin 3 → R} (hPz : P z ≠ 0) (hQz : Q z = 0) : ¬P ≈ Q :=
fun h => hPz <| (Z_eq_zero_of_equiv h).mpr hQz
lemma not_equiv_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : ¬P ≈ Q :=
hx.comp X_eq_of_equiv
lemma not_equiv_of_Y_ne {P Q : Fin 3 → R} (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : ¬P ≈ Q :=
hy.comp Y_eq_of_equiv
lemma equiv_of_X_eq_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3) : P ≈ Q := by
use Units.mk0 _ hPz / Units.mk0 _ hQz
simp only [Units.smul_def, smul_fin3, Units.val_div_eq_div_val, Units.val_mk0, div_pow, mul_comm,
mul_div, ← hx, ← hy, mul_div_cancel_right₀ _ <| pow_ne_zero _ hQz, mul_div_cancel_right₀ _ hQz,
fin3_def]
lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
P ≈ ![P x / P z ^ 2, P y / P z ^ 3, 1] :=
equiv_of_X_eq_of_Y_eq hPz one_ne_zero
(by linear_combination (norm := (matrix_simp; ring1)) -P x * div_self (pow_ne_zero 2 hPz))
(by linear_combination (norm := (matrix_simp; ring1)) -P y * div_self (pow_ne_zero 3 hPz))
lemma X_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P x * Q z ^ 2 = Q x * P z ^ 2 ↔ P x / P z ^ 2 = Q x / Q z ^ 2 :=
(div_eq_div_iff (pow_ne_zero 2 hPz) (pow_ne_zero 2 hQz)).symm
lemma Y_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z ^ 3 = Q y * P z ^ 3 ↔ P y / P z ^ 3 = Q y / Q z ^ 3 :=
(div_eq_div_iff (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)).symm
/-! ## Weierstrass equations in Jacobian coordinates -/
variable (W') in
/-- The polynomial `W(X, Y, Z) := Y² + a₁XYZ + a₃YZ³ - (X³ + a₂X²Z² + a₄XZ⁴ + a₆Z⁶)` associated to a
Weierstrass curve `W` over a ring `R` in Jacobian coordinates.
This is represented as a term of type `MvPolynomial (Fin 3) R`, where `X`, `Y`, and `Z`
represent `X`, `Y`, and `Z` respectively. -/
noncomputable def polynomial : MvPolynomial (Fin 3) R :=
Y ^ 2 + C W'.a₁ * X * Y * Z + C W'.a₃ * Y * Z ^ 3
- (X ^ 3 + C W'.a₂ * X ^ 2 * Z ^ 2 + C W'.a₄ * X * Z ^ 4 + C W'.a₆ * Z ^ 6)
lemma eval_polynomial (P : Fin 3 → R) : eval P W'.polynomial =
P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) := by
rw [polynomial]
simp
lemma eval_polynomial_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomial / P z ^ 6 =
W.toAffine.polynomial.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomial, Affine.evalEval_polynomial]; ring1))
W.a₁ * P x * P y / P z ^ 5 * div_self hPz + W.a₃ * P y / P z ^ 3 * div_self (pow_ne_zero 3 hPz)
- W.a₂ * P x ^ 2 / P z ^ 4 * div_self (pow_ne_zero 2 hPz)
- W.a₄ * P x / P z ^ 2 * div_self (pow_ne_zero 4 hPz) - W.a₆ * div_self (pow_ne_zero 6 hPz)
variable (W') in
/-- The proposition that a Jacobian point representative `(x, y, z)` lies in a Weierstrass curve
`W`.
In other words, it satisfies the `(2, 3, 1)`-homogeneous Weierstrass equation `W(X, Y, Z) = 0`. -/
def Equation (P : Fin 3 → R) : Prop :=
eval P W'.polynomial = 0
lemma equation_iff (P : Fin 3 → R) : W'.Equation P ↔
P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) = 0 := by
rw [Equation, eval_polynomial]
lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u • P) ↔ W'.Equation P :=
have hP (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by
rw [equation_iff] at hP ⊢
linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 6 * hP
⟨fun h => by convert hP ↑hu.unit⁻¹ h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩
lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by
rcases h with ⟨u, rfl⟩
exact equation_smul Q u.isUnit
lemma equation_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) :
W'.Equation P ↔ P y ^ 2 = P x ^ 3 := by
simp only [equation_iff, hPz, add_zero, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _, sub_eq_zero]
lemma equation_zero : W'.Equation ![1, 1, 0] := by
simp only [equation_of_Z_eq_zero, fin3_def_ext, one_pow]
lemma equation_some (a b : R) : W'.Equation ![a, b, 1] ↔ W'.toAffine.Equation a b := by
simp only [equation_iff, Affine.equation_iff', fin3_def_ext, one_pow, mul_one]
lemma equation_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Equation P ↔ W.toAffine.Equation (P x / P z ^ 2) (P y / P z ^ 3) :=
(equation_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| equation_some ..
/-! ## The nonsingular condition in Jacobian coordinates -/
variable (W') in
/-- The partial derivative `W_X(X, Y, Z)` with respect to `X` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in Jacobian coordinates. -/
noncomputable def polynomialX : MvPolynomial (Fin 3) R :=
pderiv x W'.polynomial
lemma polynomialX_eq : W'.polynomialX =
C W'.a₁ * Y * Z - (C 3 * X ^ 2 + C (2 * W'.a₂) * X * Z ^ 2 + C W'.a₄ * Z ^ 4) := by
rw [polynomialX, polynomial]
pderiv_simp
ring1
lemma eval_polynomialX (P : Fin 3 → R) : eval P W'.polynomialX =
W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) := by
rw [polynomialX_eq]
simp
lemma eval_polynomialX_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialX / P z ^ 4 =
W.toAffine.polynomialX.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomialX, Affine.evalEval_polynomialX]; ring1))
W.a₁ * P y / P z ^ 3 * div_self hPz - 2 * W.a₂ * P x / P z ^ 2 * div_self (pow_ne_zero 2 hPz)
- W.a₄ * div_self (pow_ne_zero 4 hPz)
variable (W') in
/-- The partial derivative `W_Y(X, Y, Z)` with respect to `Y` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in Jacobian coordinates. -/
noncomputable def polynomialY : MvPolynomial (Fin 3) R :=
pderiv y W'.polynomial
lemma polynomialY_eq : W'.polynomialY = C 2 * Y + C W'.a₁ * X * Z + C W'.a₃ * Z ^ 3 := by
rw [polynomialY, polynomial]
pderiv_simp
ring1
lemma eval_polynomialY (P : Fin 3 → R) :
eval P W'.polynomialY = 2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 := by
rw [polynomialY_eq]
simp
lemma eval_polynomialY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialY / P z ^ 3 =
W.toAffine.polynomialY.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomialY, Affine.evalEval_polynomialY]; ring1))
W.a₁ * P x / P z ^ 2 * div_self hPz + W.a₃ * div_self (pow_ne_zero 3 hPz)
variable (W') in
/-- The partial derivative `W_Z(X, Y, Z)` with respect to `Z` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in Jacobian coordinates. -/
noncomputable def polynomialZ : MvPolynomial (Fin 3) R :=
pderiv z W'.polynomial
lemma polynomialZ_eq : W'.polynomialZ = C W'.a₁ * X * Y + C (3 * W'.a₃) * Y * Z ^ 2 -
(C (2 * W'.a₂) * X ^ 2 * Z + C (4 * W'.a₄) * X * Z ^ 3 + C (6 * W'.a₆) * Z ^ 5) := by
rw [polynomialZ, polynomial]
pderiv_simp
ring1
lemma eval_polynomialZ (P : Fin 3 → R) : eval P W'.polynomialZ =
W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2 -
(2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) := by
rw [polynomialZ_eq]
simp
/-- Euler's homogeneous function theorem in Jacobian coordinates. -/
theorem polynomial_relation (P : Fin 3 → R) : 6 * eval P W'.polynomial =
2 * P x * eval P W'.polynomialX + 3 * P y * eval P W'.polynomialY +
P z * eval P W'.polynomialZ := by
rw [eval_polynomial, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
ring1
variable (W') in
/-- The proposition that a Jacobian point representative `(x, y, z)` on a Weierstrass curve `W` is
nonsingular.
In other words, either `W_X(x, y, z) ≠ 0`, `W_Y(x, y, z) ≠ 0`, or `W_Z(x, y, z) ≠ 0`.
Note that this definition is only mathematically accurate for fields. -/
-- TODO: generalise this definition to be mathematically accurate for a larger class of rings.
def Nonsingular (P : Fin 3 → R) : Prop :=
W'.Equation P ∧
(eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0)
lemma nonsingular_iff (P : Fin 3 → R) : W'.Nonsingular P ↔ W'.Equation P ∧
(W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) ≠ 0 ∨
2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 ≠ 0 ∨
W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2
- (2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) ≠ 0) := by
rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
lemma nonsingular_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) :
W'.Nonsingular (u • P) ↔ W'.Nonsingular P :=
have hP {u : R} (hu : IsUnit u) {P : Fin 3 → R} (hP : W'.Nonsingular <| u • P) :
W'.Nonsingular P := by
rcases (nonsingular_iff _).mp hP with ⟨hP, hP'⟩
refine (nonsingular_iff P).mpr ⟨(equation_smul P hu).mp hP, ?_⟩
contrapose! hP'
simp only [smul_fin3_ext]
exact ⟨by linear_combination (norm := ring1) u ^ 4 * hP'.left,
by linear_combination (norm := ring1) u ^ 3 * hP'.right.left,
by linear_combination (norm := ring1) u ^ 5 * hP'.right.right⟩
⟨hP hu, fun h => hP hu.unit⁻¹.isUnit <| by rwa [smul_smul, hu.val_inv_mul, one_smul]⟩
lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Nonsingular P ↔ W'.Nonsingular Q := by
rcases h with ⟨u, rfl⟩
exact nonsingular_smul Q u.isUnit
lemma nonsingular_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) :
W'.Nonsingular P ↔ W'.Equation P ∧ (3 * P x ^ 2 ≠ 0 ∨ 2 * P y ≠ 0 ∨ W'.a₁ * P x * P y ≠ 0) := by
simp only [nonsingular_iff, hPz, add_zero, sub_zero, zero_sub, mul_zero,
zero_pow <| OfNat.ofNat_ne_zero _, neg_ne_zero]
lemma nonsingular_zero [Nontrivial R] : W'.Nonsingular ![1, 1, 0] := by
simp only [nonsingular_of_Z_eq_zero, equation_zero, true_and, fin3_def_ext, ← not_and_or]
exact fun h => one_ne_zero <| by linear_combination (norm := ring1) h.1 - h.2.1
lemma nonsingular_some (a b : R) : W'.Nonsingular ![a, b, 1] ↔ W'.toAffine.Nonsingular a b := by
simp_rw [nonsingular_iff, equation_some, fin3_def_ext, Affine.nonsingular_iff',
Affine.equation_iff', and_congr_right_iff, ← not_and_or, not_iff_not, one_pow, mul_one,
and_congr_right_iff, Iff.comm, iff_self_and]
intro h ha hb
linear_combination (norm := ring1) 6 * h - 2 * a * ha - 3 * b * hb
lemma nonsingular_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z ^ 2) (P y / P z ^ 3) :=
(nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| nonsingular_some ..
lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by
rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz,
← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 4 hPz,
← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 3 hPz]
lemma X_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P)
(hPz : P z = 0) : P x ≠ 0 := by
intro hPx
simp only [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPx, mul_zero, zero_mul,
zero_pow <| OfNat.ofNat_ne_zero _, ne_self_iff_false, or_false, false_or] at hP
rwa [pow_eq_zero_iff two_ne_zero, hP.left, eq_self, true_and, mul_zero, ne_self_iff_false] at hP
lemma isUnit_X_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P x) :=
(X_ne_zero_of_Z_eq_zero hP hPz).isUnit
lemma Y_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P)
(hPz : P z = 0) : P y ≠ 0 := by
have hPx : P x ≠ 0 := X_ne_zero_of_Z_eq_zero hP hPz
intro hPy
rw [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPy, zero_pow two_ne_zero] at hP
exact hPx <| eq_zero_of_pow_eq_zero hP.left.symm
lemma isUnit_Y_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P y) :=
(Y_ne_zero_of_Z_eq_zero hP hPz).isUnit
lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by
have hPx : IsUnit <| P x := isUnit_X_of_Z_eq_zero hP hPz
have hPy : IsUnit <| P y := isUnit_Y_of_Z_eq_zero hP hPz
have hQx : IsUnit <| Q x := isUnit_X_of_Z_eq_zero hQ hQz
have hQy : IsUnit <| Q y := isUnit_Y_of_Z_eq_zero hQ hQz
simp only [nonsingular_of_Z_eq_zero, equation_of_Z_eq_zero, hPz, hQz] at hP hQ
use (hPy.unit / hPx.unit) * (hQx.unit / hQy.unit)
simp only [Units.smul_def, smul_fin3, Units.val_mul, Units.val_div_eq_div_val, IsUnit.unit_spec,
mul_pow, div_pow, hQz, mul_zero]
conv_rhs => rw [← fin3_def P, hPz]
congr! 2
· rw [hP.left, pow_succ, (hPx.pow 2).mul_div_cancel_left, hQ.left, pow_succ _ 2,
(hQx.pow 2).div_mul_cancel_left, hQx.inv_mul_cancel_right]
· rw [← hP.left, pow_succ, (hPy.pow 2).mul_div_cancel_left, ← hQ.left, pow_succ _ 2,
(hQy.pow 2).div_mul_cancel_left, hQy.inv_mul_cancel_right]
lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
P ≈ ![1, 1, 0] :=
equiv_of_Z_eq_zero hP nonsingular_zero hPz rfl
lemma comp_equiv_comp (f : F →+* K) {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) : f ∘ P ≈ f ∘ Q ↔ P ≈ Q := by
refine ⟨fun h => ?_, fun h => ?_⟩
· by_cases hz : f (P z) = 0
· exact equiv_of_Z_eq_zero hP hQ ((map_eq_zero_iff f f.injective).mp hz) <|
(map_eq_zero_iff f f.injective).mp <| (Z_eq_zero_of_equiv h).mp hz
· refine equiv_of_X_eq_of_Y_eq ((map_ne_zero_iff f f.injective).mp hz)
((map_ne_zero_iff f f.injective).mp <| hz.comp (Z_eq_zero_of_equiv h).mpr) ?_ ?_
all_goals apply f.injective; map_simp
exacts [X_eq_of_equiv h, Y_eq_of_equiv h]
· rcases h with ⟨u, rfl⟩
exact ⟨Units.map f u, (comp_smul ..).symm⟩
variable (W') in
/-- The proposition that a Jacobian point class on a Weierstrass curve `W` is nonsingular.
If `P` is a Jacobian point representative on `W`, then `W.NonsingularLift ⟦P⟧` is definitionally
equivalent to `W.Nonsingular P`.
Note that this definition is only mathematically accurate for fields. -/
def NonsingularLift (P : PointClass R) : Prop :=
P.lift W'.Nonsingular fun _ _ => propext ∘ nonsingular_of_equiv
lemma nonsingularLift_iff (P : Fin 3 → R) : W'.NonsingularLift ⟦P⟧ ↔ W'.Nonsingular P :=
Iff.rfl
lemma nonsingularLift_zero [Nontrivial R] : W'.NonsingularLift ⟦![1, 1, 0]⟧ :=
nonsingular_zero
lemma nonsingularLift_some (a b : R) :
W'.NonsingularLift ⟦![a, b, 1]⟧ ↔ W'.toAffine.Nonsingular a b :=
nonsingular_some a b
/-! ## Maps and base changes -/
variable (f : R →+* S) (P : Fin 3 → R)
@[simp]
lemma map_polynomial : (W'.map f).toJacobian.polynomial = MvPolynomial.map f W'.polynomial := by
simp only [polynomial]
map_simp
variable {P} in
lemma Equation.map (h : W'.Equation P) : (W'.map f).toJacobian.Equation (f ∘ P) := by
rw [Equation, map_polynomial, eval_map, ← eval₂_comp, h, map_zero]
variable {f} in
@[simp]
lemma map_equation (hf : Function.Injective f) :
(W'.map f).toJacobian.Equation (f ∘ P) ↔ W'.Equation P := by
simp only [Equation, map_polynomial, eval_map, ← eval₂_comp, map_eq_zero_iff f hf]
@[simp]
lemma map_polynomialX : (W'.map f).toJacobian.polynomialX = MvPolynomial.map f W'.polynomialX := by
simp only [polynomialX, map_polynomial, pderiv_map]
@[simp]
lemma map_polynomialY : (W'.map f).toJacobian.polynomialY = MvPolynomial.map f W'.polynomialY := by
simp only [polynomialY, map_polynomial, pderiv_map]
@[simp]
lemma map_polynomialZ : (W'.map f).toJacobian.polynomialZ = MvPolynomial.map f W'.polynomialZ := by
simp only [polynomialZ, map_polynomial, pderiv_map]
variable {f} in
@[simp]
lemma map_nonsingular (hf : Function.Injective f) :
(W'.map f).toJacobian.Nonsingular (f ∘ P) ↔ W'.Nonsingular P := by
simp only [Nonsingular, map_equation P hf, map_polynomialX, map_polynomialY, map_polynomialZ,
eval_map, ← eval₂_comp, map_ne_zero_iff f hf]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (P : Fin 3 → A)
lemma baseChange_polynomial : (W'.baseChange B).toJacobian.polynomial =
MvPolynomial.map f (W'.baseChange A).toJacobian.polynomial := by
rw [← map_polynomial, map_baseChange]
variable {P} in
lemma Equation.baseChange (h : (W'.baseChange A).toJacobian.Equation P) :
(W'.baseChange B).toJacobian.Equation (f ∘ P) := by
convert Equation.map f.toRingHom h using 1
rw [AlgHom.toRingHom_eq_coe, map_baseChange]
variable {f} in
lemma baseChange_equation (hf : Function.Injective f) :
(W'.baseChange B).toJacobian.Equation (f ∘ P) ↔ (W'.baseChange A).toJacobian.Equation P := by
rw [← RingHom.coe_coe, ← map_equation P hf, AlgHom.toRingHom_eq_coe, map_baseChange]
lemma baseChange_polynomialX : (W'.baseChange B).toJacobian.polynomialX =
MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialX := by
rw [← map_polynomialX, map_baseChange]
lemma baseChange_polynomialY : (W'.baseChange B).toJacobian.polynomialY =
MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialY := by
rw [← map_polynomialY, map_baseChange]
lemma baseChange_polynomialZ : (W'.baseChange B).toJacobian.polynomialZ =
MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialZ := by
rw [← map_polynomialZ, map_baseChange]
variable {f} in
lemma baseChange_nonsingular (hf : Function.Injective f) :
(W'.baseChange B).toJacobian.Nonsingular (f ∘ P) ↔
(W'.baseChange A).toJacobian.Nonsingular P := by
rw [← RingHom.coe_coe, ← map_nonsingular P hf, AlgHom.toRingHom_eq_coe, map_baseChange]
end Jacobian
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Formula.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula
import Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian.Basic
/-!
# Negation and addition formulae for nonsingular points in Jacobian coordinates
Let `W` be a Weierstrass curve over a field `F`. The nonsingular Jacobian points on `W` can be given
negation and addition operations defined by an analogue of the secant-and-tangent process in
`Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`, but the polynomials involved are
`(2, 3, 1)`-homogeneous, so any instances of division become multiplication in the `Z`-coordinate.
Most computational proofs are immediate from their analogous proofs for affine coordinates.
This file defines polynomials associated to negation, doubling, and addition of Jacobian point
representatives. The group operations and the group law on actual nonsingular Jacobian points will
be defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean`.
## Main definitions
* `WeierstrassCurve.Jacobian.negY`: the `Y`-coordinate of `-P`.
* `WeierstrassCurve.Jacobian.dblZ`: the `Z`-coordinate of `2 • P`.
* `WeierstrassCurve.Jacobian.dblX`: the `X`-coordinate of `2 • P`.
* `WeierstrassCurve.Jacobian.negDblY`: the `Y`-coordinate of `-(2 • P)`.
* `WeierstrassCurve.Jacobian.dblY`: the `Y`-coordinate of `2 • P`.
* `WeierstrassCurve.Jacobian.addZ`: the `Z`-coordinate of `P + Q`.
* `WeierstrassCurve.Jacobian.addX`: the `X`-coordinate of `P + Q`.
* `WeierstrassCurve.Jacobian.negAddY`: the `Y`-coordinate of `-(P + Q)`.
* `WeierstrassCurve.Jacobian.addY`: the `Y`-coordinate of `P + Q`.
## Implementation notes
The definitions of `WeierstrassCurve.Jacobian.addX` and `WeierstrassCurve.Jacobian.negAddY` are
given explicitly by large polynomials that are homogeneous of degrees `8` and `12` respectively.
Clearing the denominators of their corresponding affine rational functions in
`Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean` would give polynomials that are
homogeneous of degrees `12` and `18` respectively, so their actual definitions are off by powers of
a certain polynomial factor that is homogeneous of degree `2`. This factor divides their
corresponding affine polynomials only modulo the `(2, 3, 1)`-homogeneous Weierstrass equation, so
their large quotient polynomials are calculated explicitly in a computer algebra system. All of this
is done to ensure that the definitions of both `WeierstrassCurve.Jacobian.dblXYZ` and
`WeierstrassCurve.Jacobian.addXYZ` are `(2, 3, 1)`-homogeneous of degree `4`.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Formula.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, Jacobian, negation, doubling, addition, group law
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} [CommRing R] [CommRing S]
[CommRing A] [CommRing B] [Field F] [Field K] {W' : Jacobian R} {W : Jacobian F}
namespace Jacobian
/-! ## Negation formulae in Jacobian coordinates -/
variable (W') in
/-- The `Y`-coordinate of a representative of `-P` for a Jacobian point representative `P` on a
Weierstrass curve. -/
def negY (P : Fin 3 → R) : R :=
-P y - W'.a₁ * P x * P z - W'.a₃ * P z ^ 3
lemma negY_eq (X Y Z : R) : W'.negY ![X, Y, Z] = -Y - W'.a₁ * X * Z - W'.a₃ * Z ^ 3 :=
rfl
lemma negY_smul (P : Fin 3 → R) (u : R) : W'.negY (u • P) = u ^ 3 * W'.negY P := by
simp only [negY, smul_fin3_ext]
ring1
lemma negY_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.negY P = -P y := by
rw [negY, hPz, mul_zero, sub_zero, zero_pow three_ne_zero, mul_zero, sub_zero]
lemma negY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negY P / P z ^ 3 = W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [negY, Affine.negY]; ring1))
-W.a₁ * P x / P z ^ 2 * div_self hPz - W.a₃ * div_self (pow_ne_zero 3 hPz)
lemma Y_sub_Y_mul_Y_sub_negY {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
(P y * Q z ^ 3 - Q y * P z ^ 3) * (P y * Q z ^ 3 - W'.negY Q * P z ^ 3) = 0 := by
linear_combination (norm := (rw [negY]; ring1)) Q z ^ 6 * (equation_iff P).mp hP
- P z ^ 6 * (equation_iff Q).mp hQ + (P x ^ 2 * Q z ^ 4 + P x * Q x * P z ^ 2 * Q z ^ 2
+ Q x ^ 2 * P z ^ 4 - W'.a₁ * P y * P z * Q z ^ 4 + W'.a₂ * P x * P z ^ 2 * Q z ^ 4
+ W'.a₂ * Q x * P z ^ 4 * Q z ^ 2 + W'.a₄ * P z ^ 4 * Q z ^ 4) * hx
lemma Y_eq_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
P y * Q z ^ 3 = W'.negY Q * P z ^ 3 :=
sub_eq_zero.mp <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_left <|
sub_ne_zero.mpr hy
lemma Y_eq_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W'.negY Q * P z ^ 3) :
P y * Q z ^ 3 = Q y * P z ^ 3 :=
sub_eq_zero.mp <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_right <|
sub_ne_zero.mpr hy
lemma Y_eq_iff' {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z ^ 3 = W.negY Q * P z ^ 3 ↔
P y / P z ^ 3 = W.toAffine.negY (Q x / Q z ^ 2) (Q y / Q z ^ 3) :=
negY_of_Z_ne_zero hQz ▸ (div_eq_div_iff (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)).symm
lemma Y_sub_Y_add_Y_sub_negY {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
(P y * Q z ^ 3 - Q y * P z ^ 3) + (P y * Q z ^ 3 - W'.negY Q * P z ^ 3) =
(P y - W'.negY P) * Q z ^ 3 := by
linear_combination (norm := (rw [negY, negY]; ring1)) -W'.a₁ * P z * Q z * hx
lemma Y_ne_negY_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
P y ≠ W'.negY P := by
have hy' : P y * Q z ^ 3 - W'.negY Q * P z ^ 3 = 0 :=
(mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_left <| sub_ne_zero_of_ne hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY hx + Q z ^ 3 * hy - hy'
lemma Y_ne_negY_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W'.negY Q * P z ^ 3) : P y ≠ W'.negY P := by
have hy' : P y * Q z ^ 3 - Q y * P z ^ 3 = 0 :=
(mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_right <| sub_ne_zero_of_ne hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY hx + Q z ^ 3 * hy - hy'
lemma Y_eq_negY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : P y = W'.negY P :=
mul_left_injective₀ (pow_ne_zero 3 hQz) <| by
linear_combination (norm := ring1) -Y_sub_Y_add_Y_sub_negY hx + hy + hy'
lemma nonsingular_iff_of_Y_eq_negY {P : Fin 3 → F} (hPz : P z ≠ 0) (hy : P y = W.negY P) :
W.Nonsingular P ↔ W.Equation P ∧ eval P W.polynomialX ≠ 0 := by
have hy' : eval P W.polynomialY = P y - W.negY P := by rw [negY, eval_polynomialY]; ring1
rw [nonsingular_iff_of_Z_ne_zero hPz, hy', hy, sub_self, ne_self_iff_false, or_false]
/-! ## Doubling formulae in Jacobian coordinates -/
variable (W') in
/-- The unit associated to a representative of `2 • P` for a Jacobian point representative `P` on a
Weierstrass curve `W` that is `2`-torsion.
More specifically, the unit `u` such that `W.add P P = u • ![1, 1, 0]` where `P = W.neg P`. -/
noncomputable def dblU (P : Fin 3 → R) : R :=
eval P W'.polynomialX
lemma dblU_eq (P : Fin 3 → R) : W'.dblU P =
W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) := by
rw [dblU, eval_polynomialX]
lemma dblU_smul (P : Fin 3 → R) (u : R) : W'.dblU (u • P) = u ^ 4 * W'.dblU P := by
simp only [dblU_eq, smul_fin3_ext]
ring1
lemma dblU_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.dblU P = -3 * P x ^ 2 := by
rw [dblU_eq, hPz]
ring1
lemma dblU_ne_zero_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.dblU P ≠ 0 :=
((nonsingular_iff_of_Y_eq_negY hPz <| Y_eq_negY_of_Y_eq hQz hx hy hy').mp hP).right
lemma isUnit_dblU_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : IsUnit (W.dblU P) :=
(dblU_ne_zero_of_Y_eq hP hPz hQz hx hy hy').isUnit
variable (W') in
/-- The `Z`-coordinate of a representative of `2 • P` for a Jacobian point representative `P` on a
Weierstrass curve. -/
def dblZ (P : Fin 3 → R) : R :=
P z * (P y - W'.negY P)
lemma dblZ_smul (P : Fin 3 → R) (u : R) : W'.dblZ (u • P) = u ^ 4 * W'.dblZ P := by
simp only [dblZ, negY_smul, smul_fin3_ext]
ring1
lemma dblZ_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.dblZ P = 0 := by
rw [dblZ, hPz, zero_mul]
lemma dblZ_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblZ P = 0 := by
rw [dblZ, Y_eq_negY_of_Y_eq hQz hx hy hy', sub_self, mul_zero]
lemma dblZ_ne_zero_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne hP hQ hx hy
lemma isUnit_dblZ_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne hP hQ hPz hx hy).isUnit
lemma dblZ_ne_zero_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W'.negY Q * P z ^ 3) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hx hy
lemma isUnit_dblZ_of_Y_ne' {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne' hP hQ hPz hx hy).isUnit
private lemma toAffine_slope_of_eq [DecidableEq F]
{P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3) =
-W.dblU P / W.dblZ P := by
have hPy : P y - W.negY P ≠ 0 := sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hx hy
simp only [X_eq_iff hPz hQz, ne_eq, Y_eq_iff' hPz hQz] at hx hy
rw [Affine.slope_of_Y_ne hx <| negY_of_Z_ne_zero hQz ▸ hy, ← negY_of_Z_ne_zero hPz, dblU_eq, dblZ]
simp [field]
variable (W') in
/-- The `X`-coordinate of a representative of `2 • P` for a Jacobian point representative `P` on a
Weierstrass curve. -/
noncomputable def dblX (P : Fin 3 → R) : R :=
W'.dblU P ^ 2 - W'.a₁ * W'.dblU P * P z * (P y - W'.negY P)
- W'.a₂ * P z ^ 2 * (P y - W'.negY P) ^ 2 - 2 * P x * (P y - W'.negY P) ^ 2
lemma dblX_smul (P : Fin 3 → R) (u : R) : W'.dblX (u • P) = (u ^ 4) ^ 2 * W'.dblX P := by
simp only [dblX, dblU_smul, negY_smul, smul_fin3_ext]
ring1
lemma dblX_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblX P = (P x ^ 2) ^ 2 := by
linear_combination (norm := (rw [dblX, dblU_of_Z_eq_zero hPz, negY_of_Z_eq_zero hPz, hPz]; ring1))
-8 * P x * (equation_of_Z_eq_zero hPz).mp hP
lemma dblX_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblX P = W'.dblU P ^ 2 := by
rw [dblX, Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
private lemma toAffine_addX_of_eq {P : Fin 3 → F} (hPz : P z ≠ 0) {n d : F} (hd : d ≠ 0) :
W.toAffine.addX (P x / P z ^ 2) (P x / P z ^ 2) (-n / (P z * d)) =
(n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * d ^ 2) / (P z * d) ^ 2 := by
simp [field]
ring1
lemma dblX_of_Z_ne_zero [DecidableEq F]
{P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblX P / W.dblZ P ^ 2 = W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [dblX, toAffine_slope_of_eq hP hQ hPz hQz hx hy, dblZ, ← (X_eq_iff hPz hQz).mp hx,
toAffine_addX_of_eq hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hx hy]
variable (W') in
/-- The `Y`-coordinate of a representative of `-(2 • P)` for a Jacobian point representative `P` on
a Weierstrass curve. -/
noncomputable def negDblY (P : Fin 3 → R) : R :=
-W'.dblU P * (W'.dblX P - P x * (P y - W'.negY P) ^ 2) + P y * (P y - W'.negY P) ^ 3
lemma negDblY_smul (P : Fin 3 → R) (u : R) : W'.negDblY (u • P) = (u ^ 4) ^ 3 * W'.negDblY P := by
simp only [negDblY, dblU_smul, dblX_smul, negY_smul, smul_fin3_ext]
ring1
lemma negDblY_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negDblY P = -(P x ^ 2) ^ 3 := by
linear_combination (norm :=
(rw [negDblY, dblU_of_Z_eq_zero hPz, dblX_of_Z_eq_zero hP hPz, negY_of_Z_eq_zero hPz]; ring1))
(8 * P y ^ 2 - 4 * P x ^ 3) * (equation_of_Z_eq_zero hPz).mp hP
lemma negDblY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.negDblY P = (-W'.dblU P) ^ 3 := by
rw [negDblY, dblX_of_Y_eq hQz hx hy hy', Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
private lemma toAffine_negAddY_of_eq {P : Fin 3 → F} (hPz : P z ≠ 0) {n d : F} (hd : d ≠ 0) :
W.toAffine.negAddY (P x / P z ^ 2) (P x / P z ^ 2) (P y / P z ^ 3) (-n / (P z * d)) =
(-n * (n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * d ^ 2 - P x * d ^ 2)
+ P y * d ^ 3) / (P z * d) ^ 3 := by
rw [Affine.negAddY, toAffine_addX_of_eq hPz hd]
simp [field]
lemma negDblY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) : W.negDblY P / W.dblZ P ^ 3 =
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [negDblY, dblX, toAffine_slope_of_eq hP hQ hPz hQz hx hy, dblZ, ← (X_eq_iff hPz hQz).mp hx,
toAffine_negAddY_of_eq hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hx hy]
variable (W') in
/-- The `Y`-coordinate of a representative of `2 • P` for a Jacobian point representative `P` on a
Weierstrass curve. -/
noncomputable def dblY (P : Fin 3 → R) : R :=
W'.negY ![W'.dblX P, W'.negDblY P, W'.dblZ P]
lemma dblY_smul (P : Fin 3 → R) (u : R) : W'.dblY (u • P) = (u ^ 4) ^ 3 * W'.dblY P := by
simp only [dblY, negY_eq, negDblY_smul, dblX_smul, dblZ_smul]
ring1
lemma dblY_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblY P = (P x ^ 2) ^ 3 := by
rw [dblY, negY_eq, negDblY_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz]
ring1
lemma dblY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblY P = W'.dblU P ^ 3 := by
rw [dblY, negY_eq, negDblY_of_Y_eq hQz hx hy hy', dblZ_of_Y_eq hQz hx hy hy']
ring1
lemma dblY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblY P / W.dblZ P ^ 3 = W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
erw [dblY, negY_of_Z_ne_zero <| dblZ_ne_zero_of_Y_ne' hP hQ hPz hx hy,
dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, negDblY_of_Z_ne_zero hP hQ hPz hQz hx hy, Affine.addY]
variable (W') in
/-- The coordinates of a representative of `2 • P` for a Jacobian point representative `P` on a
Weierstrass curve. -/
noncomputable def dblXYZ (P : Fin 3 → R) : Fin 3 → R :=
![W'.dblX P, W'.dblY P, W'.dblZ P]
lemma dblXYZ_X (P : Fin 3 → R) : W'.dblXYZ P x = W'.dblX P :=
rfl
lemma dblXYZ_Y (P : Fin 3 → R) : W'.dblXYZ P y = W'.dblY P :=
rfl
lemma dblXYZ_Z (P : Fin 3 → R) : W'.dblXYZ P z = W'.dblZ P :=
rfl
lemma dblXYZ_smul (P : Fin 3 → R) (u : R) : W'.dblXYZ (u • P) = u ^ 4 • W'.dblXYZ P := by
rw [dblXYZ, dblX_smul, dblY_smul, dblZ_smul, smul_fin3, dblXYZ_X, dblXYZ_Y, dblXYZ_Z]
lemma dblXYZ_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblXYZ P = P x ^ 2 • ![1, 1, 0] := by
simp [dblXYZ, dblX_of_Z_eq_zero hP hPz, dblY_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz,
smul_fin3]
lemma dblXYZ_of_Y_eq' [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) :
W'.dblXYZ P = ![W'.dblU P ^ 2, W'.dblU P ^ 3, 0] := by
rw [dblXYZ, dblX_of_Y_eq hQz hx hy hy', dblY_of_Y_eq hQz hx hy hy', dblZ_of_Y_eq hQz hx hy hy']
lemma dblXYZ_of_Y_eq {P Q : Fin 3 → F} (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 = Q y * P z ^ 3) (hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) :
W.dblXYZ P = W.dblU P • ![1, 1, 0] := by
simp [dblXYZ_of_Y_eq' hQz hx hy hy', smul_fin3]
lemma dblXYZ_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblXYZ P = W.dblZ P •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
have hZ {n : ℕ} : IsUnit <| W.dblZ P ^ n := (isUnit_dblZ_of_Y_ne' hP hQ hPz hx hy).pow n
erw [dblXYZ, smul_fin3, ← dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel,
← dblY_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel, mul_one]
/-! ## Addition formulae in Jacobian coordinates -/
/-- The unit associated to a representative of `P + Q` for two Jacobian point representatives `P`
and `Q` on a Weierstrass curve `W` that are not `2`-torsion.
More specifically, the unit `u` such that `W.add P Q = u • ![1, 1, 0]` where
`P x / P z ^ 2 = Q x / Q z ^ 2` but `P ≠ W.neg P`. -/
def addU (P Q : Fin 3 → F) : F :=
-((P y * Q z ^ 3 - Q y * P z ^ 3) / (P z * Q z))
lemma addU_smul {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {u v : F} (hu : u ≠ 0)
(hv : v ≠ 0) : addU (u • P) (v • Q) = (u * v) ^ 2 * addU P Q := by
simp [field, addU, smul_fin3_ext]
lemma addU_of_Z_eq_zero_left {P Q : Fin 3 → F} (hPz : P z = 0) : addU P Q = 0 := by
rw [addU, hPz, zero_mul, div_zero, neg_zero]
lemma addU_of_Z_eq_zero_right {P Q : Fin 3 → F} (hQz : Q z = 0) : addU P Q = 0 := by
rw [addU, hQz, mul_zero, div_zero, neg_zero]
lemma addU_ne_zero_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : addU P Q ≠ 0 :=
neg_ne_zero.mpr <| div_ne_zero (sub_ne_zero.mpr hy) <| mul_ne_zero hPz hQz
lemma isUnit_addU_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : IsUnit (addU P Q) :=
(addU_ne_zero_of_Y_ne hPz hQz hy).isUnit
/-- The `Z`-coordinate of a representative of `P + Q` for two distinct Jacobian point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addZ (P Q : Fin 3 → R) : R :=
P x * Q z ^ 2 - Q x * P z ^ 2
lemma addZ_smul (P Q : Fin 3 → R) (u v : R) : addZ (u • P) (v • Q) = (u * v) ^ 2 * addZ P Q := by
simp only [addZ, smul_fin3_ext]
ring1
lemma addZ_self (P : Fin 3 → R) : addZ P P = 0 :=
sub_self <| P x * P z ^ 2
lemma addZ_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) : addZ P Q = P x * Q z * Q z := by
rw [addZ, hPz]
ring1
lemma addZ_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQz : Q z = 0) :
addZ P Q = -(Q x * P z) * P z := by
rw [addZ, hQz]
ring1
lemma addZ_of_X_eq {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : addZ P Q = 0 := by
rw [addZ, hx, sub_self]
lemma addZ_ne_zero_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : addZ P Q ≠ 0 :=
sub_ne_zero.mpr hx
lemma isUnit_addZ_of_X_ne {P Q : Fin 3 → F} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
IsUnit <| addZ P Q :=
(addZ_ne_zero_of_X_ne hx).isUnit
private lemma toAffine_slope_of_ne [DecidableEq F] {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3) =
(P y * Q z ^ 3 - Q y * P z ^ 3) / (P z * Q z * addZ P Q) := by
rw [Affine.slope_of_X_ne <| by rwa [ne_eq, ← X_eq_iff hPz hQz],
div_sub_div _ _ (pow_ne_zero 2 hPz) (pow_ne_zero 2 hQz), mul_comm <| _ ^ 2, addZ]
simp [field]
variable (W') in
/-- The `X`-coordinate of a representative of `P + Q` for two distinct Jacobian point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addX (P Q : Fin 3 → R) : R :=
P x * Q x ^ 2 * P z ^ 2 - 2 * P y * Q y * P z * Q z + P x ^ 2 * Q x * Q z ^ 2
- W'.a₁ * P x * Q y * P z ^ 2 * Q z - W'.a₁ * P y * Q x * P z * Q z ^ 2
+ 2 * W'.a₂ * P x * Q x * P z ^ 2 * Q z ^ 2 - W'.a₃ * Q y * P z ^ 4 * Q z
- W'.a₃ * P y * P z * Q z ^ 4 + W'.a₄ * Q x * P z ^ 4 * Q z ^ 2
+ W'.a₄ * P x * P z ^ 2 * Q z ^ 4 + 2 * W'.a₆ * P z ^ 4 * Q z ^ 4
lemma addX_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q) :
W'.addX P Q * (P z * Q z) ^ 2 =
(P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2
+ W'.a₁ * (P y * Q z ^ 3 - Q y * P z ^ 3) * P z * Q z * addZ P Q
- W'.a₂ * P z ^ 2 * Q z ^ 2 * addZ P Q ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2
- Q x * P z ^ 2 * addZ P Q ^ 2 := by
linear_combination (norm := (rw [addX, addZ]; ring1)) -Q z ^ 6 * (equation_iff P).mp hP
- P z ^ 6 * (equation_iff Q).mp hQ
lemma addX_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) : W.addX P Q =
((P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2
+ W.a₁ * (P y * Q z ^ 3 - Q y * P z ^ 3) * P z * Q z * addZ P Q
- W.a₂ * P z ^ 2 * Q z ^ 2 * addZ P Q ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2
- Q x * P z ^ 2 * addZ P Q ^ 2) / (P z * Q z) ^ 2 := by
rw [← addX_eq' hP hQ, mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
lemma addX_smul (P Q : Fin 3 → R) (u v : R) :
W'.addX (u • P) (v • Q) = ((u * v) ^ 2) ^ 2 * W'.addX P Q := by
simp only [addX, smul_fin3_ext]
ring1
lemma addX_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addX P P = 0 := by
linear_combination (norm := (rw [addX]; ring1)) -2 * P z ^ 2 * (equation_iff _).mp hP
lemma addX_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) :
W'.addX P Q = (P x * Q z) ^ 2 * Q x := by
rw [addX, hPz]
ring1
lemma addX_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQz : Q z = 0) :
W'.addX P Q = (-(Q x * P z)) ^ 2 * P x := by
rw [addX, hQz]
ring1
lemma addX_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.addX P Q * (P z * Q z) ^ 2 = (P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2 := by
rw [addX_eq' hP hQ, addZ_of_X_eq hx]
ring1
lemma addX_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.addX P Q = addU P Q ^ 2 := by
rw [addU, neg_sq, div_pow, ← addX_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
private lemma toAffine_addX_of_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {n d : F}
(hd : d ≠ 0) : W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2) (n / (P z * Q z * d)) =
(n ^ 2 + W.a₁ * n * P z * Q z * d - W.a₂ * P z ^ 2 * Q z ^ 2 * d ^ 2 - P x * Q z ^ 2 * d ^ 2
- Q x * P z ^ 2 * d ^ 2) / (P z * Q z) ^ 2 / d ^ 2 := by
simp [field]
lemma addX_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : W.addX P Q / addZ P Q ^ 2 =
W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [addX_eq hP hQ hPz hQz, toAffine_slope_of_ne hPz hQz hx,
toAffine_addX_of_ne hPz hQz <| addZ_ne_zero_of_X_ne hx]
variable (W') in
/-- The `Y`-coordinate of a representative of `-(P + Q)` for two distinct Jacobian point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def negAddY (P Q : Fin 3 → R) : R :=
-P y * Q x ^ 3 * P z ^ 3 + 2 * P y * Q y ^ 2 * P z ^ 3 - 3 * P x ^ 2 * Q x * Q y * P z ^ 2 * Q z
+ 3 * P x * P y * Q x ^ 2 * P z * Q z ^ 2 + P x ^ 3 * Q y * Q z ^ 3
- 2 * P y ^ 2 * Q y * Q z ^ 3 + W'.a₁ * P x * Q y ^ 2 * P z ^ 4
+ W'.a₁ * P y * Q x * Q y * P z ^ 3 * Q z - W'.a₁ * P x * P y * Q y * P z * Q z ^ 3
- W'.a₁ * P y ^ 2 * Q x * Q z ^ 4 - 2 * W'.a₂ * P x * Q x * Q y * P z ^ 4 * Q z
+ 2 * W'.a₂ * P x * P y * Q x * P z * Q z ^ 4 + W'.a₃ * Q y ^ 2 * P z ^ 6
- W'.a₃ * P y ^ 2 * Q z ^ 6 - W'.a₄ * Q x * Q y * P z ^ 6 * Q z
- W'.a₄ * P x * Q y * P z ^ 4 * Q z ^ 3 + W'.a₄ * P y * Q x * P z ^ 3 * Q z ^ 4
+ W'.a₄ * P x * P y * P z * Q z ^ 6 - 2 * W'.a₆ * Q y * P z ^ 6 * Q z ^ 3
+ 2 * W'.a₆ * P y * P z ^ 3 * Q z ^ 6
lemma negAddY_eq' (P Q : Fin 3 → R) : W'.negAddY P Q * (P z * Q z) ^ 3 =
(P y * Q z ^ 3 - Q y * P z ^ 3) * (W'.addX P Q * (P z * Q z) ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2)
+ P y * Q z ^ 3 * addZ P Q ^ 3 := by
rw [negAddY, addX, addZ]
ring1
lemma negAddY_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : W.negAddY P Q =
((P y * Q z ^ 3 - Q y * P z ^ 3) * (W.addX P Q * (P z * Q z) ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2)
+ P y * Q z ^ 3 * addZ P Q ^ 3) / (P z * Q z) ^ 3 := by
rw [← negAddY_eq', mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
lemma negAddY_smul (P Q : Fin 3 → R) (u v : R) :
W'.negAddY (u • P) (v • Q) = ((u * v) ^ 2) ^ 3 * W'.negAddY P Q := by
simp only [negAddY, smul_fin3_ext]
ring1
lemma negAddY_self (P : Fin 3 → R) : W'.negAddY P P = 0 := by
rw [negAddY]
ring1
lemma negAddY_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negAddY P Q = (P x * Q z) ^ 3 * W'.negY Q := by
linear_combination (norm := (rw [negAddY, negY, hPz]; ring1))
(W'.negY Q - Q y) * Q z ^ 3 * (equation_of_Z_eq_zero hPz).mp hP
lemma negAddY_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.negAddY P Q = (-(Q x * P z)) ^ 3 * W'.negY P := by
linear_combination (norm := (rw [negAddY, negY, hQz]; ring1))
(P y - W'.negY P) * P z ^ 3 * (equation_of_Z_eq_zero hQz).mp hQ
lemma negAddY_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.negAddY P Q * (P z * Q z) ^ 3 = (P y * Q z ^ 3 - Q y * P z ^ 3) ^ 3 := by
rw [negAddY_eq', addX_eq' hP hQ, addZ_of_X_eq hx]
ring1
lemma negAddY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.negAddY P Q = (-addU P Q) ^ 3 := by
rw [addU, neg_neg, div_pow, ← negAddY_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
private lemma toAffine_negAddY_of_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {n d : F}
(hd : d ≠ 0) :
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (n / (P z * Q z * d)) =
(n * (n ^ 2 + W.a₁ * n * P z * Q z * d - W.a₂ * P z ^ 2 * Q z ^ 2 * d ^ 2
- P x * Q z ^ 2 * d ^ 2 - Q x * P z ^ 2 * d ^ 2 - P x * Q z ^ 2 * d ^ 2)
+ P y * Q z ^ 3 * d ^ 3) / (P z * Q z) ^ 3 / d ^ 3 := by
rw [Affine.negAddY, toAffine_addX_of_ne hPz hQz hd]
simp [field]
lemma negAddY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.negAddY P Q / addZ P Q ^ 3 =
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [negAddY_eq hPz hQz, addX_eq' hP hQ, toAffine_slope_of_ne hPz hQz hx,
toAffine_negAddY_of_ne hPz hQz <| addZ_ne_zero_of_X_ne hx]
variable (W') in
/-- The `Y`-coordinate of a representative of `P + Q` for two distinct Jacobian point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addY (P Q : Fin 3 → R) : R :=
W'.negY ![W'.addX P Q, W'.negAddY P Q, addZ P Q]
lemma addY_smul (P Q : Fin 3 → R) (u v : R) :
W'.addY (u • P) (v • Q) = ((u * v) ^ 2) ^ 3 * W'.addY P Q := by
simp only [addY, negY_eq, negAddY_smul, addX_smul, addZ_smul]
ring1
lemma addY_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addY P P = 0 := by
rw [addY, negY_eq, addX_self hP, negAddY_self, addZ_self]
ring1
lemma addY_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.addY P Q = (P x * Q z) ^ 3 * Q y := by
rw [addY, negY_eq, negAddY_of_Z_eq_zero_left hP hPz, negY, addX_of_Z_eq_zero_left hPz,
addZ_of_Z_eq_zero_left hPz]
ring1
lemma addY_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.addY P Q = (-(Q x * P z)) ^ 3 * P y := by
rw [addY, negY_eq, negAddY_of_Z_eq_zero_right hQ hQz, negY, addX_of_Z_eq_zero_right hQz,
addZ_of_Z_eq_zero_right hQz]
ring1
lemma addY_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.addY P Q * (P z * Q z) ^ 3 = (-(P y * Q z ^ 3 - Q y * P z ^ 3)) ^ 3 := by
linear_combination (norm := (rw [addY, negY_eq, addZ_of_X_eq hx]; ring1))
-negAddY_of_X_eq' hP hQ hx
lemma addY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.addY P Q = addU P Q ^ 3 := by
rw [addU, ← neg_div, div_pow, ← addY_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
lemma addY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.addY P Q / addZ P Q ^ 3 = W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
erw [addY, negY_of_Z_ne_zero <| addZ_ne_zero_of_X_ne hx, addX_of_Z_ne_zero hP hQ hPz hQz hx,
negAddY_of_Z_ne_zero hP hQ hPz hQz hx, Affine.addY]
variable (W') in
/-- The coordinates of a representative of `P + Q` for two distinct Jacobian point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `![0, 0, 0]`. -/
noncomputable def addXYZ (P Q : Fin 3 → R) : Fin 3 → R :=
![W'.addX P Q, W'.addY P Q, addZ P Q]
lemma addXYZ_X (P Q : Fin 3 → R) : W'.addXYZ P Q x = W'.addX P Q :=
rfl
lemma addXYZ_Y (P Q : Fin 3 → R) : W'.addXYZ P Q y = W'.addY P Q :=
rfl
lemma addXYZ_Z (P Q : Fin 3 → R) : W'.addXYZ P Q z = addZ P Q :=
rfl
lemma addXYZ_smul (P Q : Fin 3 → R) (u v : R) :
W'.addXYZ (u • P) (v • Q) = (u * v) ^ 2 • W'.addXYZ P Q := by
rw [addXYZ, addX_smul, addY_smul, addZ_smul, smul_fin3, addXYZ_X, addXYZ_Y, addXYZ_Z]
lemma addXYZ_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addXYZ P P = ![0, 0, 0] := by
rw [addXYZ, addX_self hP, addY_self hP, addZ_self]
lemma addXYZ_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.addXYZ P Q = (P x * Q z) • Q := by
rw [addXYZ, addX_of_Z_eq_zero_left hPz, addY_of_Z_eq_zero_left hP hPz, addZ_of_Z_eq_zero_left hPz,
smul_fin3]
lemma addXYZ_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.addXYZ P Q = -(Q x * P z) • P := by
rw [addXYZ, addX_of_Z_eq_zero_right hQz, addY_of_Z_eq_zero_right hQ hQz,
addZ_of_Z_eq_zero_right hQz, smul_fin3]
lemma addXYZ_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W.addXYZ P Q = addU P Q • ![1, 1, 0] := by
simp [addXYZ, addX_of_X_eq hP hQ hPz hQz hx, addY_of_X_eq hP hQ hPz hQz hx, addZ_of_X_eq hx,
smul_fin3]
lemma addXYZ_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : W.addXYZ P Q = addZ P Q •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
have hZ {n : ℕ} : IsUnit <| addZ P Q ^ n := (isUnit_addZ_of_X_ne hx).pow n
erw [addXYZ, smul_fin3, ← addX_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel,
← addY_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel, mul_one]
/-! ## Maps and base changes -/
variable (f : R →+* S) (P Q : Fin 3 → R)
@[simp]
lemma map_negY : (W'.map f).toJacobian.negY (f ∘ P) = f (W'.negY P) := by
simp only [negY]
map_simp
@[simp]
lemma map_dblU : (W'.map f).toJacobian.dblU (f ∘ P) = f (W'.dblU P) := by
simp only [dblU_eq]
map_simp
@[simp]
lemma map_dblZ : (W'.map f).toJacobian.dblZ (f ∘ P) = f (W'.dblZ P) := by
simp only [dblZ, negY]
map_simp
@[simp]
lemma map_dblX : (W'.map f).toJacobian.dblX (f ∘ P) = f (W'.dblX P) := by
simp only [dblX, map_dblU, map_negY]
map_simp
@[simp]
lemma map_negDblY : (W'.map f).toJacobian.negDblY (f ∘ P) = f (W'.negDblY P) := by
simp only [negDblY, map_dblU, map_dblX, map_negY]
simp
@[simp]
lemma map_dblY : (W'.map f).toJacobian.dblY (f ∘ P) = f (W'.dblY P) := by
simp only [dblY, negY_eq, map_negDblY, map_dblX, map_dblZ]
map_simp
@[simp]
lemma map_dblXYZ : (W'.map f).toJacobian.dblXYZ (f ∘ P) = f ∘ dblXYZ W' P := by
simp only [dblXYZ, map_dblX, map_dblY, map_dblZ, comp_fin3]
@[simp]
lemma map_addU (f : F →+* K) (P Q : Fin 3 → F) : addU (f ∘ P) (f ∘ Q) = f (addU P Q) := by
simp only [addU]
map_simp
@[simp]
lemma map_addZ : addZ (f ∘ P) (f ∘ Q) = f (addZ P Q) := by
simp only [addZ]
map_simp
@[simp]
lemma map_addX : (W'.map f).toJacobian.addX (f ∘ P) (f ∘ Q) = f (W'.addX P Q) := by
simp only [addX]
map_simp
@[simp]
lemma map_negAddY : (W'.map f).toJacobian.negAddY (f ∘ P) (f ∘ Q) = f (W'.negAddY P Q) := by
simp only [negAddY]
map_simp
@[simp]
lemma map_addY : (W'.map f).toJacobian.addY (f ∘ P) (f ∘ Q) = f (W'.addY P Q) := by
simp only [addY, negY_eq, map_negAddY, map_addX, map_addZ]
map_simp
@[simp]
lemma map_addXYZ : (W'.map f).toJacobian.addXYZ (f ∘ P) (f ∘ Q) = f ∘ addXYZ W' P Q := by
simp only [addXYZ, map_addX, map_addY, map_addZ, comp_fin3]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (P Q : Fin 3 → A)
lemma baseChange_negY :
(W'.baseChange B).toJacobian.negY (f ∘ P) = f ((W'.baseChange A).toJacobian.negY P) := by
rw [← RingHom.coe_coe, ← map_negY, map_baseChange]
lemma baseChange_dblU :
(W'.baseChange B).toJacobian.dblU (f ∘ P) = f ((W'.baseChange A).toJacobian.dblU P) := by
rw [← RingHom.coe_coe, ← map_dblU, map_baseChange]
lemma baseChange_dblZ :
(W'.baseChange B).toJacobian.dblZ (f ∘ P) = f ((W'.baseChange A).toJacobian.dblZ P) := by
rw [← RingHom.coe_coe, ← map_dblZ, map_baseChange]
lemma baseChange_dblX :
(W'.baseChange B).toJacobian.dblX (f ∘ P) = f ((W'.baseChange A).toJacobian.dblX P) := by
rw [← RingHom.coe_coe, ← map_dblX, map_baseChange]
lemma baseChange_negDblY :
(W'.baseChange B).toJacobian.negDblY (f ∘ P) = f ((W'.baseChange A).toJacobian.negDblY P) := by
rw [← RingHom.coe_coe, ← map_negDblY, map_baseChange]
lemma baseChange_dblY :
(W'.baseChange B).toJacobian.dblY (f ∘ P) = f ((W'.baseChange A).toJacobian.dblY P) := by
rw [← RingHom.coe_coe, ← map_dblY, map_baseChange]
lemma baseChange_dblXYZ :
(W'.baseChange B).toJacobian.dblXYZ (f ∘ P) = f ∘ (W'.baseChange A).toJacobian.dblXYZ P := by
rw [← RingHom.coe_coe, ← map_dblXYZ, map_baseChange]
lemma baseChange_addX : (W'.baseChange B).toJacobian.addX (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toJacobian.addX P Q) := by
rw [← RingHom.coe_coe, ← map_addX, map_baseChange]
lemma baseChange_negAddY : (W'.baseChange B).toJacobian.negAddY (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toJacobian.negAddY P Q) := by
rw [← RingHom.coe_coe, ← map_negAddY, map_baseChange]
lemma baseChange_addY : (W'.baseChange B).toJacobian.addY (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toJacobian.addY P Q) := by
rw [← RingHom.coe_coe, ← map_addY, map_baseChange]
lemma baseChange_addXYZ : (W'.baseChange B).toJacobian.addXYZ (f ∘ P) (f ∘ Q) =
f ∘ (W'.baseChange A).toJacobian.addXYZ P Q := by
rw [← RingHom.coe_coe, ← map_addXYZ, map_baseChange]
end Jacobian
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Basic.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Point
import Mathlib.NumberTheory.EllipticDivisibilitySequence
/-!
# Division polynomials of Weierstrass curves
This file defines certain polynomials associated to division polynomials of Weierstrass curves.
These are defined in terms of the auxiliary sequences for normalised elliptic divisibility sequences
(EDS) as defined in `Mathlib/NumberTheory/EllipticDivisibilitySequence.lean`.
## Mathematical background
Let `W` be a Weierstrass curve over a commutative ring `R`. The sequence of `n`-division polynomials
`ψₙ ∈ R[X, Y]` of `W` is the normalised EDS with initial values
* `ψ₀ := 0`,
* `ψ₁ := 1`,
* `ψ₂ := 2Y + a₁X + a₃`,
* `ψ₃ := 3X⁴ + b₂X³ + 3b₄X² + 3b₆X + b₈`, and
* `ψ₄ := ψ₂ ⬝ (2X⁶ + b₂X⁵ + 5b₄X⁴ + 10b₆X³ + 10b₈X² + (b₂b₈ - b₄b₆)X + (b₄b₈ - b₆²))`.
Furthermore, define the associated sequences `φₙ, ωₙ ∈ R[X, Y]` by
* `φₙ := Xψₙ² - ψₙ₊₁ ⬝ ψₙ₋₁`, and
* `ωₙ := (ψ₂ₙ / ψₙ - ψₙ ⬝ (a₁φₙ + a₃ψₙ²)) / 2`.
Note that `ωₙ` is always well-defined as a polynomial in `R[X, Y]`. As a start, it can be shown by
induction that `ψₙ` always divides `ψ₂ₙ` in `R[X, Y]`, so that `ψ₂ₙ / ψₙ` is always well-defined as
a polynomial, while division by `2` is well-defined when `R` has characteristic different from `2`.
In general, it can be shown that `2` always divides the polynomial `ψ₂ₙ / ψₙ - ψₙ ⬝ (a₁φₙ + a₃ψₙ²)`
in the characteristic `0` universal ring `𝓡[X, Y] := ℤ[A₁, A₂, A₃, A₄, A₆][X, Y]` of `W`, where the
`Aᵢ` are indeterminates. Then `ωₙ` can be equivalently defined as the image of this division under
the associated universal morphism `𝓡[X, Y] → R[X, Y]` mapping `Aᵢ` to `aᵢ`.
Now, in the coordinate ring `R[W]`, note that `ψ₂²` is congruent to the polynomial
`Ψ₂Sq := 4X³ + b₂X² + 2b₄X + b₆ ∈ R[X]`. As such, the recurrences of a normalised EDS show that
`ψₙ / ψ₂` are congruent to certain polynomials in `R[W]`. In particular, define `preΨₙ ∈ R[X]` as
the auxiliary sequence for a normalised EDS with extra parameter `Ψ₂Sq²` and initial values
* `preΨ₀ := 0`,
* `preΨ₁ := 1`,
* `preΨ₂ := 1`,
* `preΨ₃ := ψ₃`, and
* `preΨ₄ := ψ₄ / ψ₂`.
The corresponding normalised EDS `Ψₙ ∈ R[X, Y]` is then given by
* `Ψₙ := preΨₙ ⬝ ψ₂` if `n` is even, and
* `Ψₙ := preΨₙ` if `n` is odd.
Furthermore, define the associated sequences `ΨSqₙ, Φₙ ∈ R[X]` by
* `ΨSqₙ := preΨₙ² ⬝ Ψ₂Sq` if `n` is even,
* `ΨSqₙ := preΨₙ²` if `n` is odd,
* `Φₙ := XΨSqₙ - preΨₙ₊₁ ⬝ preΨₙ₋₁` if `n` is even, and
* `Φₙ := XΨSqₙ - preΨₙ₊₁ ⬝ preΨₙ₋₁ ⬝ Ψ₂Sq` if `n` is odd.
With these definitions, `ψₙ ∈ R[X, Y]` and `φₙ ∈ R[X, Y]` are congruent in `R[W]` to `Ψₙ ∈ R[X, Y]`
and `Φₙ ∈ R[X]` respectively, which are defined in terms of `Ψ₂Sq ∈ R[X]` and `preΨₙ ∈ R[X]`.
## Main definitions
* `WeierstrassCurve.preΨ`: the univariate polynomials `preΨₙ`.
* `WeierstrassCurve.ΨSq`: the univariate polynomials `ΨSqₙ`.
* `WeierstrassCurve.Ψ`: the bivariate polynomials `Ψₙ`.
* `WeierstrassCurve.Φ`: the univariate polynomials `Φₙ`.
* `WeierstrassCurve.ψ`: the bivariate `n`-division polynomials `ψₙ`.
* `WeierstrassCurve.φ`: the bivariate polynomials `φₙ`.
* TODO: the bivariate polynomials `ωₙ`.
## Implementation notes
Analogously to `Mathlib/NumberTheory/EllipticDivisibilitySequence.lean`, the bivariate polynomials
`Ψₙ` are defined in terms of the univariate polynomials `preΨₙ`. This is done partially to avoid
ring division, but more crucially to allow the definition of `ΨSqₙ` and `Φₙ` as univariate
polynomials without needing to work under the coordinate ring, and to allow the computation of their
leading terms without ambiguity. Furthermore, evaluating these polynomials at a rational point on
`W` recovers their original definition up to linear combinations of the Weierstrass equation of `W`,
hence also avoiding the need to work in the coordinate ring.
TODO: implementation notes for the definition of `ωₙ`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, division polynomial, torsion point
-/
open Polynomial
open scoped Polynomial.Bivariate
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} [CommRing R] [CommRing S] (W : WeierstrassCurve R)
section Ψ₂Sq
/-! ### The univariate polynomial `Ψ₂Sq` -/
/-- The `2`-division polynomial `ψ₂ = Ψ₂`. -/
noncomputable def ψ₂ : R[X][Y] :=
W.toAffine.polynomialY
/-- The univariate polynomial `Ψ₂Sq` congruent to `ψ₂²`. -/
noncomputable def Ψ₂Sq : R[X] :=
C 4 * X ^ 3 + C W.b₂ * X ^ 2 + C (2 * W.b₄) * X + C W.b₆
lemma C_Ψ₂Sq : C W.Ψ₂Sq = W.ψ₂ ^ 2 - 4 * W.toAffine.polynomial := by
rw [Ψ₂Sq, ψ₂, b₂, b₄, b₆, Affine.polynomialY, Affine.polynomial]
C_simp
ring1
lemma ψ₂_sq : W.ψ₂ ^ 2 = C W.Ψ₂Sq + 4 * W.toAffine.polynomial := by
simp [C_Ψ₂Sq]
lemma Affine.CoordinateRing.mk_ψ₂_sq : mk W W.ψ₂ ^ 2 = mk W (C W.Ψ₂Sq) := by
simp [C_Ψ₂Sq]
-- TODO: remove `twoTorsionPolynomial` in favour of `Ψ₂Sq`
lemma Ψ₂Sq_eq : W.Ψ₂Sq = W.twoTorsionPolynomial.toPoly :=
rfl
end Ψ₂Sq
section preΨ'
/-! ### The univariate polynomials `preΨₙ` for `n ∈ ℕ` -/
/-- The `3`-division polynomial `ψ₃ = Ψ₃`. -/
noncomputable def Ψ₃ : R[X] :=
3 * X ^ 4 + C W.b₂ * X ^ 3 + 3 * C W.b₄ * X ^ 2 + 3 * C W.b₆ * X + C W.b₈
/-- The univariate polynomial `preΨ₄`, which is auxiliary to the 4-division polynomial
`ψ₄ = Ψ₄ = preΨ₄ψ₂`. -/
noncomputable def preΨ₄ : R[X] :=
2 * X ^ 6 + C W.b₂ * X ^ 5 + 5 * C W.b₄ * X ^ 4 + 10 * C W.b₆ * X ^ 3 + 10 * C W.b₈ * X ^ 2 +
C (W.b₂ * W.b₈ - W.b₄ * W.b₆) * X + C (W.b₄ * W.b₈ - W.b₆ ^ 2)
/-- The univariate polynomials `preΨₙ` for `n ∈ ℕ`, which are auxiliary to the bivariate polynomials
`Ψₙ` congruent to the bivariate `n`-division polynomials `ψₙ`. -/
noncomputable def preΨ' (n : ℕ) : R[X] :=
preNormEDS' (W.Ψ₂Sq ^ 2) W.Ψ₃ W.preΨ₄ n
@[simp]
lemma preΨ'_zero : W.preΨ' 0 = 0 :=
preNormEDS'_zero ..
@[simp]
lemma preΨ'_one : W.preΨ' 1 = 1 :=
preNormEDS'_one ..
@[simp]
lemma preΨ'_two : W.preΨ' 2 = 1 :=
preNormEDS'_two ..
@[simp]
lemma preΨ'_three : W.preΨ' 3 = W.Ψ₃ :=
preNormEDS'_three ..
@[simp]
lemma preΨ'_four : W.preΨ' 4 = W.preΨ₄ :=
preNormEDS'_four ..
lemma preΨ'_even (m : ℕ) : W.preΨ' (2 * (m + 3)) =
W.preΨ' (m + 2) ^ 2 * W.preΨ' (m + 3) * W.preΨ' (m + 5) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) * W.preΨ' (m + 4) ^ 2 :=
preNormEDS'_even ..
lemma preΨ'_odd (m : ℕ) : W.preΨ' (2 * (m + 2) + 1) =
W.preΨ' (m + 4) * W.preΨ' (m + 2) ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2) :=
preNormEDS'_odd ..
end preΨ'
section preΨ
/-! ### The univariate polynomials `preΨₙ` for `n ∈ ℤ` -/
/-- The univariate polynomials `preΨₙ` for `n ∈ ℤ`, which are auxiliary to the bivariate polynomials
`Ψₙ` congruent to the bivariate `n`-division polynomials `ψₙ`. -/
noncomputable def preΨ (n : ℤ) : R[X] :=
preNormEDS (W.Ψ₂Sq ^ 2) W.Ψ₃ W.preΨ₄ n
@[simp]
lemma preΨ_ofNat (n : ℕ) : W.preΨ n = W.preΨ' n :=
preNormEDS_ofNat ..
@[simp]
lemma preΨ_zero : W.preΨ 0 = 0 :=
preNormEDS_zero ..
@[simp]
lemma preΨ_one : W.preΨ 1 = 1 :=
preNormEDS_one ..
@[simp]
lemma preΨ_two : W.preΨ 2 = 1 :=
preNormEDS_two ..
@[simp]
lemma preΨ_three : W.preΨ 3 = W.Ψ₃ :=
preNormEDS_three ..
@[simp]
lemma preΨ_four : W.preΨ 4 = W.preΨ₄ :=
preNormEDS_four ..
@[simp]
lemma preΨ_neg (n : ℤ) : W.preΨ (-n) = -W.preΨ n :=
preNormEDS_neg ..
lemma preΨ_even (m : ℤ) : W.preΨ (2 * m) =
W.preΨ (m - 1) ^ 2 * W.preΨ m * W.preΨ (m + 2) -
W.preΨ (m - 2) * W.preΨ m * W.preΨ (m + 1) ^ 2 :=
preNormEDS_even ..
@[deprecated (since := "2025-05-15")] alias preΨ_even_ofNat := preΨ_even
lemma preΨ_odd (m : ℤ) : W.preΨ (2 * m + 1) =
W.preΨ (m + 2) * W.preΨ m ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ (m - 1) * W.preΨ (m + 1) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2) :=
preNormEDS_odd ..
@[deprecated (since := "2025-05-15")] alias preΨ_odd_ofNat := preΨ_odd
end preΨ
section ΨSq
/-! ### The univariate polynomials `ΨSqₙ` -/
/-- The univariate polynomials `ΨSqₙ` congruent to `ψₙ²`. -/
noncomputable def ΨSq (n : ℤ) : R[X] :=
W.preΨ n ^ 2 * if Even n then W.Ψ₂Sq else 1
@[simp]
lemma ΨSq_ofNat (n : ℕ) : W.ΨSq n = W.preΨ' n ^ 2 * if Even n then W.Ψ₂Sq else 1 := by
simp [ΨSq]
@[simp]
lemma ΨSq_zero : W.ΨSq 0 = 0 := by
simp [ΨSq]
@[simp]
lemma ΨSq_one : W.ΨSq 1 = 1 := by
simp [ΨSq]
@[simp]
lemma ΨSq_two : W.ΨSq 2 = W.Ψ₂Sq := by
simp [ΨSq]
@[simp]
lemma ΨSq_three : W.ΨSq 3 = W.Ψ₃ ^ 2 := by
simp [ΨSq, show ¬Even (3 : ℤ) by decide]
@[simp]
lemma ΨSq_four : W.ΨSq 4 = W.preΨ₄ ^ 2 * W.Ψ₂Sq := by
simp [ΨSq, show ¬Odd (4 : ℤ) by decide]
@[simp]
lemma ΨSq_neg (n : ℤ) : W.ΨSq (-n) = W.ΨSq n := by
simp [ΨSq]
lemma ΨSq_even (m : ℤ) : W.ΨSq (2 * m) =
(W.preΨ (m - 1) ^ 2 * W.preΨ m * W.preΨ (m + 2) -
W.preΨ (m - 2) * W.preΨ m * W.preΨ (m + 1) ^ 2) ^ 2 * W.Ψ₂Sq := by
rw [ΨSq, preΨ_even, if_pos <| even_two_mul m]
@[deprecated (since := "2025-05-15")] alias ΨSq_even_ofNat := ΨSq_even
lemma ΨSq_odd (m : ℤ) : W.ΨSq (2 * m + 1) =
(W.preΨ (m + 2) * W.preΨ m ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ (m - 1) * W.preΨ (m + 1) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2)) ^ 2 := by
rw [ΨSq, preΨ_odd, if_neg m.not_even_two_mul_add_one, mul_one]
@[deprecated (since := "2025-05-15")] alias ΨSq_odd_ofNat := ΨSq_odd
end ΨSq
section Ψ
/-! ### The bivariate polynomials `Ψₙ` -/
/-- The bivariate polynomials `Ψₙ` congruent to the `n`-division polynomials `ψₙ`. -/
protected noncomputable def Ψ (n : ℤ) : R[X][Y] :=
C (W.preΨ n) * if Even n then W.ψ₂ else 1
open WeierstrassCurve (Ψ)
@[simp]
lemma Ψ_ofNat (n : ℕ) : W.Ψ n = C (W.preΨ' n) * if Even n then W.ψ₂ else 1 := by
simp [Ψ]
@[simp]
lemma Ψ_zero : W.Ψ 0 = 0 := by
simp [Ψ]
@[simp]
lemma Ψ_one : W.Ψ 1 = 1 := by
simp [Ψ]
@[simp]
lemma Ψ_two : W.Ψ 2 = W.ψ₂ := by
simp [Ψ]
@[simp]
lemma Ψ_three : W.Ψ 3 = C W.Ψ₃ := by
simp [Ψ, show ¬Even (3 : ℤ) by decide]
@[simp]
lemma Ψ_four : W.Ψ 4 = C W.preΨ₄ * W.ψ₂ := by
simp [Ψ, show ¬Odd (4 : ℤ) by decide]
@[simp]
lemma Ψ_neg (n : ℤ) : W.Ψ (-n) = -W.Ψ n := by
simp_rw [Ψ, preΨ_neg, C_neg, neg_mul, even_neg]
lemma Ψ_even (m : ℤ) : W.Ψ (2 * m) * W.ψ₂ =
W.Ψ (m - 1) ^ 2 * W.Ψ m * W.Ψ (m + 2) - W.Ψ (m - 2) * W.Ψ m * W.Ψ (m + 1) ^ 2 := by
simp_rw [Ψ, preΨ_even, if_pos <| even_two_mul m, Int.even_add, Int.even_sub, even_two, iff_true,
Int.not_even_one, iff_false]
split_ifs <;> C_simp <;> ring1
@[deprecated (since := "2025-05-15")] alias Ψ_even_ofNat := Ψ_even
lemma Ψ_odd (m : ℤ) : W.Ψ (2 * m + 1) =
W.Ψ (m + 2) * W.Ψ m ^ 3 - W.Ψ (m - 1) * W.Ψ (m + 1) ^ 3 +
W.toAffine.polynomial * (16 * W.toAffine.polynomial - 8 * W.ψ₂ ^ 2) *
C (if Even m then W.preΨ (m + 2) * W.preΨ m ^ 3
else -W.preΨ (m - 1) * W.preΨ (m + 1) ^ 3) := by
simp_rw [Ψ, preΨ_odd, if_neg m.not_even_two_mul_add_one, Int.even_add, Int.even_sub, even_two,
iff_true, Int.not_even_one, iff_false]
split_ifs <;> C_simp <;> rw [C_Ψ₂Sq] <;> ring1
@[deprecated (since := "2025-05-15")] alias Ψ_odd_ofNat := Ψ_odd
lemma Affine.CoordinateRing.mk_Ψ_sq (n : ℤ) : mk W (W.Ψ n) ^ 2 = mk W (C <| W.ΨSq n) := by
simp_rw [Ψ, ΨSq, map_mul, apply_ite C, apply_ite <| mk W, mul_pow, ite_pow, mk_ψ₂_sq, map_one,
one_pow, map_pow]
end Ψ
section Φ
/-! ### The univariate polynomials `Φₙ` -/
/-- The univariate polynomials `Φₙ` congruent to `φₙ`. -/
protected noncomputable def Φ (n : ℤ) : R[X] :=
X * W.ΨSq n - W.preΨ (n + 1) * W.preΨ (n - 1) * if Even n then 1 else W.Ψ₂Sq
open WeierstrassCurve (Φ)
@[simp]
lemma Φ_ofNat (n : ℕ) : W.Φ (n + 1) =
X * W.preΨ' (n + 1) ^ 2 * (if Even n then 1 else W.Ψ₂Sq) -
W.preΨ' (n + 2) * W.preΨ' n * (if Even n then W.Ψ₂Sq else 1) := by
rw [Φ, add_sub_cancel_right]
norm_cast
simp_rw [ΨSq_ofNat, Nat.even_add_one, ite_not, ← mul_assoc, preΨ_ofNat]
@[simp]
lemma Φ_zero : W.Φ 0 = 1 := by
simp [Φ]
@[simp]
lemma Φ_one : W.Φ 1 = X := by
simp [Φ]
@[simp]
lemma Φ_two : W.Φ 2 = X ^ 4 - C W.b₄ * X ^ 2 - C (2 * W.b₆) * X - C W.b₈ := by
rw [show 2 = ((1 : ℕ) + 1 : ℤ) by rfl, Φ_ofNat, preΨ'_two, if_neg Nat.not_even_one, Ψ₂Sq,
preΨ'_three, preΨ'_one, if_neg Nat.not_even_one, Ψ₃]
C_simp
ring1
@[simp]
lemma Φ_three : W.Φ 3 = X * W.Ψ₃ ^ 2 - W.preΨ₄ * W.Ψ₂Sq := by
rw [show 3 = ((2 : ℕ) + 1 : ℤ) by rfl, Φ_ofNat, preΨ'_three, if_pos <| by decide, mul_one,
preΨ'_four, preΨ'_two, mul_one, if_pos even_two]
@[simp]
lemma Φ_four : W.Φ 4 = X * W.preΨ₄ ^ 2 * W.Ψ₂Sq - W.Ψ₃ * (W.preΨ₄ * W.Ψ₂Sq ^ 2 - W.Ψ₃ ^ 3) := by
rw [show 4 = ((3 : ℕ) + 1 : ℤ) by rfl, Φ_ofNat, preΨ'_four, if_neg <| by decide,
show 3 + 2 = 2 * 2 + 1 by rfl, preΨ'_odd, preΨ'_four, preΨ'_two, if_pos Even.zero, preΨ'_one,
preΨ'_three, if_pos Even.zero, if_neg <| by decide]
ring1
@[simp]
lemma Φ_neg (n : ℤ) : W.Φ (-n) = W.Φ n := by
simp_rw [Φ, ΨSq_neg, ← sub_neg_eq_add, ← neg_sub', sub_neg_eq_add, ← neg_add', preΨ_neg,
neg_mul_neg, mul_comm <| W.preΨ <| n - 1, even_neg]
end Φ
section ψ
/-! ### The bivariate polynomials `ψₙ` -/
/-- The bivariate `n`-division polynomials `ψₙ`. -/
protected noncomputable def ψ (n : ℤ) : R[X][Y] :=
normEDS W.ψ₂ (C W.Ψ₃) (C W.preΨ₄) n
open WeierstrassCurve (Ψ ψ)
@[simp]
lemma ψ_zero : W.ψ 0 = 0 :=
normEDS_zero ..
@[simp]
lemma ψ_one : W.ψ 1 = 1 :=
normEDS_one ..
@[simp]
lemma ψ_two : W.ψ 2 = W.ψ₂ :=
normEDS_two ..
@[simp]
lemma ψ_three : W.ψ 3 = C W.Ψ₃ :=
normEDS_three ..
@[simp]
lemma ψ_four : W.ψ 4 = C W.preΨ₄ * W.ψ₂ :=
normEDS_four ..
@[simp]
lemma ψ_neg (n : ℤ) : W.ψ (-n) = -W.ψ n :=
normEDS_neg ..
lemma ψ_even (m : ℤ) : W.ψ (2 * m) * W.ψ₂ =
W.ψ (m - 1) ^ 2 * W.ψ m * W.ψ (m + 2) - W.ψ (m - 2) * W.ψ m * W.ψ (m + 1) ^ 2 :=
normEDS_even ..
@[deprecated (since := "2025-05-15")] alias ψ_even_ofNat := ψ_even
lemma ψ_odd (m : ℤ) : W.ψ (2 * m + 1) =
W.ψ (m + 2) * W.ψ m ^ 3 - W.ψ (m - 1) * W.ψ (m + 1) ^ 3 :=
normEDS_odd ..
@[deprecated (since := "2025-05-15")] alias ψ_odd_ofNat := ψ_odd
lemma Affine.CoordinateRing.mk_ψ (n : ℤ) : mk W (W.ψ n) = mk W (W.Ψ n) := by
simp_rw [ψ, normEDS, Ψ, preΨ, map_mul, map_preNormEDS, map_pow, ← mk_ψ₂_sq, ← pow_mul]
end ψ
section φ
/-! ### The bivariate polynomials `φₙ` -/
/-- The bivariate polynomials `φₙ`. -/
protected noncomputable def φ (n : ℤ) : R[X][Y] :=
C X * W.ψ n ^ 2 - W.ψ (n + 1) * W.ψ (n - 1)
open WeierstrassCurve (Ψ Φ φ)
@[simp]
lemma φ_zero : W.φ 0 = 1 := by
simp [φ]
@[simp]
lemma φ_one : W.φ 1 = C X := by
simp [φ]
@[simp]
lemma φ_two : W.φ 2 = C X * W.ψ₂ ^ 2 - C W.Ψ₃ := by
simp [φ]
@[simp]
lemma φ_three : W.φ 3 = C X * C W.Ψ₃ ^ 2 - C W.preΨ₄ * W.ψ₂ ^ 2 := by
simp [φ, mul_assoc, sq]
@[simp]
lemma φ_four :
W.φ 4 = C X * C W.preΨ₄ ^ 2 * W.ψ₂ ^ 2 - C W.preΨ₄ * W.ψ₂ ^ 4 * C W.Ψ₃ + C W.Ψ₃ ^ 4 := by
rw [φ, ψ_four, show (4 + 1 : ℤ) = 2 * 2 + 1 by rfl, ψ_odd, two_add_two_eq_four, ψ_four,
show (2 - 1 : ℤ) = 1 by rfl, ψ_two, ψ_one, two_add_one_eq_three, show (4 - 1 : ℤ) = 3 by rfl,
ψ_three]
ring1
@[simp]
lemma φ_neg (n : ℤ) : W.φ (-n) = W.φ n := by
simp_rw [φ, ψ_neg, neg_sq, ← sub_neg_eq_add, ← neg_sub', sub_neg_eq_add, ← neg_add', ψ_neg,
neg_mul_neg, mul_comm <| W.ψ <| n - 1]
lemma Affine.CoordinateRing.mk_φ (n : ℤ) : mk W (W.φ n) = mk W (C <| W.Φ n) := by
simp_rw [φ, Φ, map_sub, map_mul, map_pow, mk_ψ, mk_Ψ_sq, Ψ, map_mul,
mul_mul_mul_comm _ <| mk W <| ite .., Int.even_add_one, Int.even_sub_one, ite_not, ← sq,
apply_ite C, apply_ite <| mk W, ite_pow, map_one, one_pow, mk_ψ₂_sq]
end φ
section Map
/-! ### Maps across ring homomorphisms -/
open WeierstrassCurve (Ψ Φ ψ φ)
variable (f : R →+* S)
@[simp]
lemma map_ψ₂ : (W.map f).ψ₂ = W.ψ₂.map (mapRingHom f) := by
simp_rw [ψ₂, Affine.map_polynomialY]
@[simp]
lemma map_Ψ₂Sq : (W.map f).Ψ₂Sq = W.Ψ₂Sq.map f := by
simp [Ψ₂Sq, map_ofNat]
@[simp]
lemma map_Ψ₃ : (W.map f).Ψ₃ = W.Ψ₃.map f := by
simp [Ψ₃]
@[simp]
lemma map_preΨ₄ : (W.map f).preΨ₄ = W.preΨ₄.map f := by
simp [preΨ₄]
@[simp]
lemma map_preΨ' (n : ℕ) : (W.map f).preΨ' n = (W.preΨ' n).map f := by
simp [preΨ', ← coe_mapRingHom]
@[simp]
lemma map_preΨ (n : ℤ) : (W.map f).preΨ n = (W.preΨ n).map f := by
simp [preΨ, ← coe_mapRingHom]
@[simp]
lemma map_ΨSq (n : ℤ) : (W.map f).ΨSq n = (W.ΨSq n).map f := by
simp [ΨSq, ← coe_mapRingHom, apply_ite <| mapRingHom f]
@[simp]
lemma map_Ψ (n : ℤ) : (W.map f).Ψ n = (W.Ψ n).map (mapRingHom f) := by
rw [← coe_mapRingHom]
simp [Ψ, apply_ite <| mapRingHom _]
@[simp]
lemma map_Φ (n : ℤ) : (W.map f).Φ n = (W.Φ n).map f := by
rw [← coe_mapRingHom]
simp [Φ, map_sub, apply_ite <| mapRingHom f]
@[simp]
lemma map_ψ (n : ℤ) : (W.map f).ψ n = (W.ψ n).map (mapRingHom f) := by
rw [← coe_mapRingHom]
simp [ψ]
@[simp]
lemma map_φ (n : ℤ) : (W.map f).φ n = (W.φ n).map (mapRingHom f) := by
simp [φ]
end Map
section BaseChange
/-! ### Base changes across algebra homomorphisms -/
variable [Algebra R S] {A : Type u} [CommRing A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
{B : Type v} [CommRing B] [Algebra R B] [Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B)
lemma baseChange_ψ₂ : (W.baseChange B).ψ₂ = (W.baseChange A).ψ₂.map (mapRingHom f) := by
rw [← map_ψ₂, map_baseChange]
lemma baseChange_Ψ₂Sq : (W.baseChange B).Ψ₂Sq = (W.baseChange A).Ψ₂Sq.map f := by
rw [← map_Ψ₂Sq, map_baseChange]
lemma baseChange_Ψ₃ : (W.baseChange B).Ψ₃ = (W.baseChange A).Ψ₃.map f := by
rw [← map_Ψ₃, map_baseChange]
lemma baseChange_preΨ₄ : (W.baseChange B).preΨ₄ = (W.baseChange A).preΨ₄.map f := by
rw [← map_preΨ₄, map_baseChange]
lemma baseChange_preΨ' (n : ℕ) : (W.baseChange B).preΨ' n = ((W.baseChange A).preΨ' n).map f := by
rw [← map_preΨ', map_baseChange]
lemma baseChange_preΨ (n : ℤ) : (W.baseChange B).preΨ n = ((W.baseChange A).preΨ n).map f := by
rw [← map_preΨ, map_baseChange]
lemma baseChange_ΨSq (n : ℤ) : (W.baseChange B).ΨSq n = ((W.baseChange A).ΨSq n).map f := by
rw [← map_ΨSq, map_baseChange]
lemma baseChange_Ψ (n : ℤ) : (W.baseChange B).Ψ n = ((W.baseChange A).Ψ n).map (mapRingHom f) := by
rw [← map_Ψ, map_baseChange]
lemma baseChange_Φ (n : ℤ) : (W.baseChange B).Φ n = ((W.baseChange A).Φ n).map f := by
rw [← map_Φ, map_baseChange]
lemma baseChange_ψ (n : ℤ) : (W.baseChange B).ψ n = ((W.baseChange A).ψ n).map (mapRingHom f) := by
rw [← map_ψ, map_baseChange]
lemma baseChange_φ (n : ℤ) : (W.baseChange B).φ n = ((W.baseChange A).φ n).map (mapRingHom f) := by
rw [← map_φ, map_baseChange]
end BaseChange
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Degree.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.DivisionPolynomial.Basic
import Mathlib.Tactic.ComputeDegree
/-!
# Division polynomials of Weierstrass curves
This file computes the leading terms of certain polynomials associated to division polynomials of
Weierstrass curves defined in
`Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Basic.lean`.
## Mathematical background
Let `W` be a Weierstrass curve over a commutative ring `R`. By strong induction,
* `preΨₙ` has leading coefficient `n / 2` and degree `(n² - 4) / 2` if `n` is even,
* `preΨₙ` has leading coefficient `n` and degree `(n² - 1) / 2` if `n` is odd,
* `ΨSqₙ` has leading coefficient `n²` and degree `n² - 1`, and
* `Φₙ` has leading coefficient `1` and degree `n²`.
In particular, when `R` is an integral domain of characteristic different from `n`, the univariate
polynomials `preΨₙ`, `ΨSqₙ`, and `Φₙ` all have their expected leading terms.
## Main statements
* `WeierstrassCurve.natDegree_preΨ_le`: the degree bound `d` of `preΨₙ`.
* `WeierstrassCurve.coeff_preΨ`: the `d`-th coefficient of `preΨₙ`.
* `WeierstrassCurve.natDegree_preΨ`: the degree of `preΨₙ` when `n ≠ 0`.
* `WeierstrassCurve.leadingCoeff_preΨ`: the leading coefficient of `preΨₙ` when `n ≠ 0`.
* `WeierstrassCurve.natDegree_ΨSq_le`: the degree bound `d` of `ΨSqₙ`.
* `WeierstrassCurve.coeff_ΨSq`: the `d`-th coefficient of `ΨSqₙ`.
* `WeierstrassCurve.natDegree_ΨSq`: the degree of `ΨSqₙ` when `n ≠ 0`.
* `WeierstrassCurve.leadingCoeff_ΨSq`: the leading coefficient of `ΨSqₙ` when `n ≠ 0`.
* `WeierstrassCurve.natDegree_Φ_le`: the degree bound `d` of `Φₙ`.
* `WeierstrassCurve.coeff_Φ`: the `d`-th coefficient of `Φₙ`.
* `WeierstrassCurve.natDegree_Φ`: the degree of `Φₙ` when `n ≠ 0`.
* `WeierstrassCurve.leadingCoeff_Φ`: the leading coefficient of `Φₙ` when `n ≠ 0`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, division polynomial, torsion point
-/
open Polynomial
universe u
namespace WeierstrassCurve
variable {R : Type u} [CommRing R] (W : WeierstrassCurve R)
section Ψ₂Sq
lemma natDegree_Ψ₂Sq_le : W.Ψ₂Sq.natDegree ≤ 3 := by
rw [Ψ₂Sq]
compute_degree
@[simp]
lemma coeff_Ψ₂Sq : W.Ψ₂Sq.coeff 3 = 4 := by
rw [Ψ₂Sq]
compute_degree!
lemma coeff_Ψ₂Sq_ne_zero (h : (4 : R) ≠ 0) : W.Ψ₂Sq.coeff 3 ≠ 0 := by
rwa [coeff_Ψ₂Sq]
@[simp]
lemma natDegree_Ψ₂Sq (h : (4 : R) ≠ 0) : W.Ψ₂Sq.natDegree = 3 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_Ψ₂Sq_le <| W.coeff_Ψ₂Sq_ne_zero h
lemma natDegree_Ψ₂Sq_pos (h : (4 : R) ≠ 0) : 0 < W.Ψ₂Sq.natDegree :=
W.natDegree_Ψ₂Sq h ▸ three_pos
@[simp]
lemma leadingCoeff_Ψ₂Sq (h : (4 : R) ≠ 0) : W.Ψ₂Sq.leadingCoeff = 4 := by
rw [leadingCoeff, W.natDegree_Ψ₂Sq h, coeff_Ψ₂Sq]
lemma Ψ₂Sq_ne_zero (h : (4 : R) ≠ 0) : W.Ψ₂Sq ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_Ψ₂Sq_pos h
end Ψ₂Sq
section Ψ₃
lemma natDegree_Ψ₃_le : W.Ψ₃.natDegree ≤ 4 := by
rw [Ψ₃]
compute_degree
@[simp]
lemma coeff_Ψ₃ : W.Ψ₃.coeff 4 = 3 := by
rw [Ψ₃]
compute_degree!
lemma coeff_Ψ₃_ne_zero (h : (3 : R) ≠ 0) : W.Ψ₃.coeff 4 ≠ 0 := by
rwa [coeff_Ψ₃]
@[simp]
lemma natDegree_Ψ₃ (h : (3 : R) ≠ 0) : W.Ψ₃.natDegree = 4 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_Ψ₃_le <| W.coeff_Ψ₃_ne_zero h
lemma natDegree_Ψ₃_pos (h : (3 : R) ≠ 0) : 0 < W.Ψ₃.natDegree :=
W.natDegree_Ψ₃ h ▸ four_pos
@[simp]
lemma leadingCoeff_Ψ₃ (h : (3 : R) ≠ 0) : W.Ψ₃.leadingCoeff = 3 := by
rw [leadingCoeff, W.natDegree_Ψ₃ h, coeff_Ψ₃]
lemma Ψ₃_ne_zero (h : (3 : R) ≠ 0) : W.Ψ₃ ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_Ψ₃_pos h
end Ψ₃
section preΨ₄
lemma natDegree_preΨ₄_le : W.preΨ₄.natDegree ≤ 6 := by
rw [preΨ₄]
compute_degree
@[simp]
lemma coeff_preΨ₄ : W.preΨ₄.coeff 6 = 2 := by
rw [preΨ₄]
compute_degree!
lemma coeff_preΨ₄_ne_zero (h : (2 : R) ≠ 0) : W.preΨ₄.coeff 6 ≠ 0 := by
rwa [coeff_preΨ₄]
@[simp]
lemma natDegree_preΨ₄ (h : (2 : R) ≠ 0) : W.preΨ₄.natDegree = 6 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_preΨ₄_le <| W.coeff_preΨ₄_ne_zero h
lemma natDegree_preΨ₄_pos (h : (2 : R) ≠ 0) : 0 < W.preΨ₄.natDegree := by
linarith only [W.natDegree_preΨ₄ h]
@[simp]
lemma leadingCoeff_preΨ₄ (h : (2 : R) ≠ 0) : W.preΨ₄.leadingCoeff = 2 := by
rw [leadingCoeff, W.natDegree_preΨ₄ h, coeff_preΨ₄]
lemma preΨ₄_ne_zero (h : (2 : R) ≠ 0) : W.preΨ₄ ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_preΨ₄_pos h
end preΨ₄
section preΨ'
private def expDegree (n : ℕ) : ℕ :=
(n ^ 2 - if Even n then 4 else 1) / 2
private lemma expDegree_cast {n : ℕ} (hn : n ≠ 0) :
2 * (expDegree n : ℤ) = n ^ 2 - if Even n then 4 else 1 := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩
· rcases n with _ | n
· contradiction
push_cast [expDegree, show (2 * (n + 1)) ^ 2 = 2 * (2 * n * (n + 2)) + 4 by ring1, even_two_mul,
Nat.add_sub_cancel, Nat.mul_div_cancel_left _ two_pos]
ring1
· push_cast [expDegree, show (2 * n + 1) ^ 2 = 2 * (2 * n * (n + 1)) + 1 by ring1,
n.not_even_two_mul_add_one, Nat.add_sub_cancel, Nat.mul_div_cancel_left _ two_pos]
ring1
private lemma expDegree_rec (m : ℕ) :
(expDegree (2 * (m + 3)) = 2 * expDegree (m + 2) + expDegree (m + 3) + expDegree (m + 5) ∧
expDegree (2 * (m + 3)) = expDegree (m + 1) + expDegree (m + 3) + 2 * expDegree (m + 4)) ∧
(expDegree (2 * (m + 2) + 1) =
expDegree (m + 4) + 3 * expDegree (m + 2) + (if Even m then 2 * 3 else 0) ∧
expDegree (2 * (m + 2) + 1) =
expDegree (m + 1) + 3 * expDegree (m + 3) + (if Even m then 0 else 2 * 3)) := by
push_cast [← @Nat.cast_inj ℤ, ← mul_left_cancel_iff_of_pos (b := (expDegree _ : ℤ)) two_pos,
mul_add, mul_left_comm (2 : ℤ)]
repeat rw [expDegree_cast <| by cutsat]
push_cast [Nat.even_add_one, ite_not, even_two_mul]
constructor <;> constructor <;> split_ifs <;> ring1
private def expCoeff (n : ℕ) : ℤ :=
if Even n then n / 2 else n
private lemma expCoeff_cast (n : ℕ) : (expCoeff n : ℚ) = if Even n then (n / 2 : ℚ) else n := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;> simp [expCoeff, n.not_even_two_mul_add_one]
private lemma expCoeff_rec (m : ℕ) :
(expCoeff (2 * (m + 3)) =
expCoeff (m + 2) ^ 2 * expCoeff (m + 3) * expCoeff (m + 5) -
expCoeff (m + 1) * expCoeff (m + 3) * expCoeff (m + 4) ^ 2) ∧
(expCoeff (2 * (m + 2) + 1) =
expCoeff (m + 4) * expCoeff (m + 2) ^ 3 * (if Even m then 4 ^ 2 else 1) -
expCoeff (m + 1) * expCoeff (m + 3) ^ 3 * (if Even m then 1 else 4 ^ 2)) := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast, even_two_mul, m.not_even_two_mul_add_one,
Nat.even_add_one, ite_not]
constructor <;> split_ifs <;> ring1
private lemma natDegree_coeff_preΨ' (n : ℕ) :
(W.preΨ' n).natDegree ≤ expDegree n ∧ (W.preΨ' n).coeff (expDegree n) = expCoeff n := by
let dm {m n p q} : _ → _ → (p * q : R[X]).natDegree ≤ m + n := natDegree_mul_le_of_le
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let cm {m n p q} : _ → _ → (p * q : R[X]).coeff (m + n) = _ := coeff_mul_add_eq_of_natDegree_le
let cp {m n p} : _ → (p ^ m : R[X]).coeff (m * n) = _ := coeff_pow_of_natDegree_le
induction n using normEDSRec with
| zero => simpa only [preΨ'_zero] using ⟨natDegree_zero.le, Int.cast_zero.symm⟩
| one => simpa only [preΨ'_one] using ⟨natDegree_one.le, coeff_one_zero.trans Int.cast_one.symm⟩
| two => simpa only [preΨ'_two] using ⟨natDegree_one.le, coeff_one_zero.trans Int.cast_one.symm⟩
| three => simpa only [preΨ'_three] using ⟨W.natDegree_Ψ₃_le, W.coeff_Ψ₃ ▸ Int.cast_three.symm⟩
| four => simpa only [preΨ'_four] using ⟨W.natDegree_preΨ₄_le, W.coeff_preΨ₄ ▸ Int.cast_two.symm⟩
| even m h₁ h₂ h₃ h₄ h₅ =>
constructor
· nth_rw 1 [preΨ'_even, ← max_self <| expDegree _, (expDegree_rec m).1.1, (expDegree_rec m).1.2]
exact natDegree_sub_le_of_le (dm (dm (dp h₂.1) h₃.1) h₅.1) (dm (dm h₁.1 h₃.1) (dp h₄.1))
· nth_rw 1 [preΨ'_even, coeff_sub, (expDegree_rec m).1.1, cm (dm (dp h₂.1) h₃.1) h₅.1,
cm (dp h₂.1) h₃.1, cp h₂.1, h₂.2, h₃.2, h₅.2, (expDegree_rec m).1.2,
cm (dm h₁.1 h₃.1) (dp h₄.1), cm h₁.1 h₃.1, h₁.2, cp h₄.1, h₃.2, h₄.2, (expCoeff_rec m).1]
norm_cast
| odd m h₁ h₂ h₃ h₄ =>
rw [preΨ'_odd]
constructor
· nth_rw 1 [← max_self <| expDegree _, (expDegree_rec m).2.1, (expDegree_rec m).2.2]
refine natDegree_sub_le_of_le (dm (dm h₄.1 (dp h₂.1)) ?_) (dm (dm h₁.1 (dp h₃.1)) ?_) <;>
split_ifs <;> simp only [natDegree_one.le, dp W.natDegree_Ψ₂Sq_le]
· nth_rw 1 [coeff_sub, (expDegree_rec m).2.1, cm (dm h₄.1 (dp h₂.1)), cm h₄.1 (dp h₂.1),
h₄.2, cp h₂.1, h₂.2, apply_ite₂ coeff, cp W.natDegree_Ψ₂Sq_le, coeff_Ψ₂Sq, coeff_one_zero,
(expDegree_rec m).2.2, cm (dm h₁.1 (dp h₃.1)), cm h₁.1 (dp h₃.1), h₁.2, cp h₃.1, h₃.2,
apply_ite₂ coeff, cp W.natDegree_Ψ₂Sq_le, coeff_one_zero, coeff_Ψ₂Sq, (expCoeff_rec m).2]
· norm_cast
all_goals split_ifs <;> simp only [natDegree_one.le, dp W.natDegree_Ψ₂Sq_le]
lemma natDegree_preΨ'_le (n : ℕ) : (W.preΨ' n).natDegree ≤ (n ^ 2 - if Even n then 4 else 1) / 2 :=
(W.natDegree_coeff_preΨ' n).left
@[simp]
lemma coeff_preΨ' (n : ℕ) : (W.preΨ' n).coeff ((n ^ 2 - if Even n then 4 else 1) / 2) =
if Even n then n / 2 else n := by
convert (W.natDegree_coeff_preΨ' n).right using 1
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;> simp [expCoeff, n.not_even_two_mul_add_one]
lemma coeff_preΨ'_ne_zero {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).coeff ((n ^ 2 - if Even n then 4 else 1) / 2) ≠ 0 := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩
· rw [coeff_preΨ', if_pos <| even_two_mul n, n.mul_div_cancel_left two_pos]
exact right_ne_zero_of_mul <| by rwa [← Nat.cast_mul]
· rwa [coeff_preΨ', if_neg n.not_even_two_mul_add_one]
@[simp]
lemma natDegree_preΨ' {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).natDegree = (n ^ 2 - if Even n then 4 else 1) / 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_preΨ'_le n) <| W.coeff_preΨ'_ne_zero h
lemma natDegree_preΨ'_pos {n : ℕ} (hn : 2 < n) (h : (n : R) ≠ 0) : 0 < (W.preΨ' n).natDegree := by
simp_rw [W.natDegree_preΨ' h, Nat.div_pos_iff, zero_lt_two, true_and]
split_ifs <;> exact Nat.AtLeastTwo.prop.trans <| Nat.sub_le_sub_right (Nat.pow_le_pow_left hn 2) _
@[simp]
lemma leadingCoeff_preΨ' {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).leadingCoeff = if Even n then n / 2 else n := by
rw [leadingCoeff, W.natDegree_preΨ' h, coeff_preΨ']
lemma preΨ'_ne_zero [Nontrivial R] {n : ℕ} (h : (n : R) ≠ 0) : W.preΨ' n ≠ 0 := by
by_cases hn : 2 < n
· exact ne_zero_of_natDegree_gt <| W.natDegree_preΨ'_pos hn h
· rcases n with _ | _ | _ <;> aesop
end preΨ'
section preΨ
lemma natDegree_preΨ_le (n : ℤ) : (W.preΨ n).natDegree ≤
(n.natAbs ^ 2 - if Even n then 4 else 1) / 2 := by
induction n using Int.negInduction with
| nat n => exact_mod_cast W.preΨ_ofNat n ▸ W.natDegree_preΨ'_le n
| neg ih => simp_rw [preΨ_neg, natDegree_neg, Int.natAbs_neg, even_neg, ih]
@[simp]
lemma coeff_preΨ (n : ℤ) : (W.preΨ n).coeff ((n.natAbs ^ 2 - if Even n then 4 else 1) / 2) =
if Even n then n / 2 else n := by
induction n using Int.negInduction with
| nat n => exact_mod_cast W.preΨ_ofNat n ▸ W.coeff_preΨ' n
| neg ih n =>
simp_rw [preΨ_neg, coeff_neg, Int.natAbs_neg, even_neg]
rcases ih n, n.even_or_odd' with ⟨ih, ⟨n, rfl | rfl⟩⟩ <;>
push_cast [even_two_mul, Int.not_even_two_mul_add_one, Int.neg_ediv_of_dvd ⟨n, rfl⟩] at * <;>
rw [ih]
lemma coeff_preΨ_ne_zero {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).coeff ((n.natAbs ^ 2 - if Even n then 4 else 1) / 2) ≠ 0 := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat, Int.even_coe_nat]
using W.coeff_preΨ'_ne_zero <| by exact_mod_cast h
| neg ih n => simpa only [preΨ_neg, coeff_neg, neg_ne_zero, Int.natAbs_neg, even_neg]
using ih n <| neg_ne_zero.mp <| by exact_mod_cast h
@[simp]
lemma natDegree_preΨ {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).natDegree = (n.natAbs ^ 2 - if Even n then 4 else 1) / 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_preΨ_le n) <| W.coeff_preΨ_ne_zero h
lemma natDegree_preΨ_pos {n : ℤ} (hn : 2 < n.natAbs) (h : (n : R) ≠ 0) :
0 < (W.preΨ n).natDegree := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat] using W.natDegree_preΨ'_pos hn <| by exact_mod_cast h
| neg ih n => simpa only [preΨ_neg, natDegree_neg]
using ih n (by rwa [← Int.natAbs_neg]) <| neg_ne_zero.mp <| by exact_mod_cast h
@[simp]
lemma leadingCoeff_preΨ {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).leadingCoeff = if Even n then n / 2 else n := by
rw [leadingCoeff, W.natDegree_preΨ h, coeff_preΨ]
lemma preΨ_ne_zero [Nontrivial R] {n : ℤ} (h : (n : R) ≠ 0) : W.preΨ n ≠ 0 := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat] using W.preΨ'_ne_zero <| by exact_mod_cast h
| neg ih n => simpa only [preΨ_neg, neg_ne_zero]
using ih n <| neg_ne_zero.mp <| by exact_mod_cast h
end preΨ
section ΨSq
private lemma natDegree_coeff_ΨSq_ofNat (n : ℕ) :
(W.ΨSq n).natDegree ≤ n ^ 2 - 1 ∧ (W.ΨSq n).coeff (n ^ 2 - 1) = (n ^ 2 : ℤ) := by
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let h {n} := W.natDegree_coeff_preΨ' n
rcases n with _ | n
· simp
have hd : (n + 1) ^ 2 - 1 = 2 * expDegree (n + 1) + if Even (n + 1) then 3 else 0 := by
push_cast [← @Nat.cast_inj ℤ, add_sq, expDegree_cast n.succ_ne_zero]
split_ifs <;> ring1
have hc : (n + 1 : ℕ) ^ 2 = expCoeff (n + 1) ^ 2 * if Even (n + 1) then 4 else 1 := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast]
split_ifs <;> ring1
rw [ΨSq_ofNat, hd]
constructor
· refine natDegree_mul_le_of_le (dp h.1) ?_
split_ifs <;> simp only [natDegree_one.le, W.natDegree_Ψ₂Sq_le]
· rw [coeff_mul_add_eq_of_natDegree_le (dp h.1), coeff_pow_of_natDegree_le h.1, h.2,
apply_ite₂ coeff, coeff_Ψ₂Sq, coeff_one_zero, hc]
· norm_cast
split_ifs <;> simp only [natDegree_one.le, W.natDegree_Ψ₂Sq_le]
lemma natDegree_ΨSq_le (n : ℤ) : (W.ΨSq n).natDegree ≤ n.natAbs ^ 2 - 1 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_ΨSq_ofNat n).left
| neg ih => simp_rw [ΨSq_neg, Int.natAbs_neg, ih]
@[simp]
lemma coeff_ΨSq (n : ℤ) : (W.ΨSq n).coeff (n.natAbs ^ 2 - 1) = n ^ 2 := by
induction n using Int.negInduction with
| nat n => exact_mod_cast (W.natDegree_coeff_ΨSq_ofNat n).right
| neg ih => rw [ΨSq_neg, Int.natAbs_neg, ← Int.cast_pow, neg_sq, Int.cast_pow, ih]
lemma coeff_ΨSq_ne_zero [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).coeff (n.natAbs ^ 2 - 1) ≠ 0 := by
simpa
@[simp]
lemma natDegree_ΨSq [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).natDegree = n.natAbs ^ 2 - 1 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_ΨSq_le n) <| W.coeff_ΨSq_ne_zero h
lemma natDegree_ΨSq_pos [NoZeroDivisors R] {n : ℤ} (hn : 1 < n.natAbs) (h : (n : R) ≠ 0) :
0 < (W.ΨSq n).natDegree := by
simpa [W.natDegree_ΨSq h]
@[simp]
lemma leadingCoeff_ΨSq [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).leadingCoeff = n ^ 2 := by
rw [leadingCoeff, W.natDegree_ΨSq h, coeff_ΨSq]
lemma ΨSq_ne_zero [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) : W.ΨSq n ≠ 0 := by
by_cases hn : 1 < n.natAbs
· exact ne_zero_of_natDegree_gt <| W.natDegree_ΨSq_pos hn h
· rcases hm : n.natAbs with _ | m
· push_cast [Int.natAbs_eq_zero.mp hm, ne_self_iff_false] at h
· rcases Int.natAbs_eq_iff.mp hm with rfl | rfl <;>
rw [hm, Nat.lt_add_left_iff_pos, Nat.not_lt_eq, Nat.le_zero] at hn <;>
push_cast [hn, ΨSq_neg, ΨSq_one] <;>
exact fun h' => h <| C_injective <| by push_cast [hn, C_neg, C_1, h', neg_zero, C_0]; rfl
end ΨSq
section Φ
private lemma natDegree_coeff_Φ_ofNat (n : ℕ) :
(W.Φ n).natDegree ≤ n ^ 2 ∧ (W.Φ n).coeff (n ^ 2) = 1 := by
let dm {m n p q} : _ → _ → (p * q : R[X]).natDegree ≤ m + n := natDegree_mul_le_of_le
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let cm {m n p q} : _ → _ → (p * q : R[X]).coeff (m + n) = _ := coeff_mul_add_eq_of_natDegree_le
let h {n} := W.natDegree_coeff_preΨ' n
rcases n with _ | _ | n
iterate 2 simp [natDegree_X_le]
have hd : (n + 1 + 1) ^ 2 = 1 + 2 * expDegree (n + 2) + if Even (n + 1) then 0 else 3 := by
push_cast [← @Nat.cast_inj ℤ, expDegree_cast (n + 1).succ_ne_zero, Nat.even_add_one, ite_not]
split_ifs <;> ring1
have hd' : (n + 1 + 1) ^ 2 =
expDegree (n + 3) + expDegree (n + 1) + if Even (n + 1) then 3 else 0 := by
push_cast [← @Nat.cast_inj ℤ, ← mul_left_cancel_iff_of_pos (b := (_ ^ 2 : ℤ)) two_pos, mul_add,
expDegree_cast (n + 2).succ_ne_zero, expDegree_cast n.succ_ne_zero, Nat.even_add_one, ite_not]
split_ifs <;> ring1
have hc : (1 : ℤ) = 1 * expCoeff (n + 2) ^ 2 * (if Even (n + 1) then 1 else 4) -
expCoeff (n + 3) * expCoeff (n + 1) * (if Even (n + 1) then 4 else 1) := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast, Nat.even_add_one, ite_not]
split_ifs <;> ring1
rw [Nat.cast_add, Nat.cast_one, Φ_ofNat]
constructor
· nth_rw 1 [← max_self <| (_ + _) ^ 2, hd, hd']
refine natDegree_sub_le_of_le (dm (dm natDegree_X_le (dp h.1)) ?_) (dm (dm h.1 h.1) ?_) <;>
split_ifs <;> simp only [natDegree_one.le, W.natDegree_Ψ₂Sq_le]
· nth_rw 1 [coeff_sub, hd, hd', cm (dm natDegree_X_le (dp h.1)), cm natDegree_X_le (dp h.1),
coeff_X_one, coeff_pow_of_natDegree_le h.1, h.2, apply_ite₂ coeff, coeff_one_zero, coeff_Ψ₂Sq,
cm (dm h.1 h.1), cm h.1 h.1, h.2, h.2, apply_ite₂ coeff, coeff_one_zero, coeff_Ψ₂Sq]
conv_rhs => rw [← Int.cast_one, hc]
· norm_cast
all_goals split_ifs <;> simp only [natDegree_one.le, W.natDegree_Ψ₂Sq_le]
lemma natDegree_Φ_le (n : ℤ) : (W.Φ n).natDegree ≤ n.natAbs ^ 2 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_Φ_ofNat n).left
| neg ih => simp_rw [Φ_neg, Int.natAbs_neg, ih]
@[simp]
lemma coeff_Φ (n : ℤ) : (W.Φ n).coeff (n.natAbs ^ 2) = 1 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_Φ_ofNat n).right
| neg ih => rw [Φ_neg, Int.natAbs_neg, ih]
lemma coeff_Φ_ne_zero [Nontrivial R] (n : ℤ) : (W.Φ n).coeff (n.natAbs ^ 2) ≠ 0 :=
W.coeff_Φ n ▸ one_ne_zero
@[simp]
lemma natDegree_Φ [Nontrivial R] (n : ℤ) : (W.Φ n).natDegree = n.natAbs ^ 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_Φ_le n) <| W.coeff_Φ_ne_zero n
lemma natDegree_Φ_pos [Nontrivial R] {n : ℤ} (hn : n ≠ 0) : 0 < (W.Φ n).natDegree := by
simpa [sq_pos_iff]
@[simp]
lemma leadingCoeff_Φ [Nontrivial R] (n : ℤ) : (W.Φ n).leadingCoeff = 1 := by
rw [leadingCoeff, natDegree_Φ, coeff_Φ]
lemma Φ_ne_zero [Nontrivial R] (n : ℤ) : W.Φ n ≠ 0 := by
by_cases hn : n = 0
· simpa only [hn, Φ_zero] using one_ne_zero
· exact ne_zero_of_natDegree_gt <| W.natDegree_Φ_pos hn
end Φ
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula
import Mathlib.LinearAlgebra.FreeModule.Norm
import Mathlib.RingTheory.ClassGroup
import Mathlib.RingTheory.Polynomial.UniqueFactorization
/-!
# Nonsingular points and the group law in affine coordinates
Let `W` be a Weierstrass curve over a field `F` given by a Weierstrass equation `W(X, Y) = 0` in
affine coordinates. The type of nonsingular points `W⟮F⟯` in affine coordinates is an inductive,
consisting of the unique point at infinity `𝓞` and nonsingular affine points `(x, y)`. Then `W⟮F⟯`
can be endowed with a group law, with `𝓞` as the identity nonsingular point, which is uniquely
determined by the formulae in `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`.
With this description, there is an addition-preserving injection between `W⟮F⟯` and the ideal class
group of the *affine coordinate ring* `F[W] := F[X, Y] / ⟨W(X, Y)⟩` of `W`. This is given by mapping
`𝓞` to the trivial ideal class and a nonsingular affine point `(x, y)` to the ideal class of the
invertible ideal `⟨X - x, Y - y⟩`. Proving that this is well-defined and preserves addition reduces
to equalities of integral ideals checked in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_neg_mul`
and in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_mul_XYIdeal` via explicit ideal computations.
Now `F[W]` is a free rank two `F[X]`-algebra with basis `{1, Y}`, so every element of `F[W]` is of
the form `p + qY` for some `p, q` in `F[X]`, and there is an algebra norm `N : F[W] → F[X]`.
Injectivity can then be shown by computing the degree of such a norm `N(p + qY)` in two different
ways, which is done in `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis` and in the
auxiliary lemmas in the proof of `WeierstrassCurve.Affine.Point.instAddCommGroup`.
This file defines the group law on nonsingular points `W⟮F⟯` in affine coordinates.
## Main definitions
* `WeierstrassCurve.Affine.CoordinateRing`: the affine coordinate ring `F[W]`.
* `WeierstrassCurve.Affine.CoordinateRing.basis`: the power basis of `F[W]` over `F[X]`.
* `WeierstrassCurve.Affine.Point`: a nonsingular point in affine coordinates.
* `WeierstrassCurve.Affine.Point.neg`: the negation of a nonsingular point in affine coordinates.
* `WeierstrassCurve.Affine.Point.add`: the addition of a nonsingular point in affine coordinates.
## Main statements
* `WeierstrassCurve.Affine.CoordinateRing.instIsDomainCoordinateRing`: the affine coordinate ring
of a Weierstrass curve is an integral domain.
* `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis`: the degree of the norm of an
element in the affine coordinate ring in terms of its power basis.
* `WeierstrassCurve.Affine.Point.instAddCommGroup`: the type of nonsingular points `W⟮F⟯` in affine
coordinates forms an abelian group under addition.
## Notation
* `W⟮K⟯`: the group of nonsingular points on `W` base changed to `K`.
## References
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
* https://drops.dagstuhl.de/storage/00lipics/lipics-vol268-itp2023/LIPIcs.ITP.2023.6/LIPIcs.ITP.2023.6.pdf
## Tags
elliptic curve, affine, point, group law, class group
-/
open FractionalIdeal (coeIdeal_mul)
open Ideal hiding map_mul
open Module Polynomial
open scoped nonZeroDivisors Polynomial.Bivariate
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
universe r s u v w
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} {L : Type w} [CommRing R]
[CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] [Field L] {W' : Affine R}
{W : Affine F}
namespace Affine
/-! ## The affine coordinate ring -/
variable (W') in
/-- The affine coordinate ring `R[W] := R[X, Y] / ⟨W(X, Y)⟩` of a Weierstrass curve `W`. -/
abbrev CoordinateRing : Type r :=
AdjoinRoot W'.polynomial
variable (W') in
/-- The function field `R(W) := Frac(R[W])` of a Weierstrass curve `W`. -/
abbrev FunctionField : Type r :=
FractionRing W'.CoordinateRing
namespace CoordinateRing
noncomputable instance : Algebra R W'.CoordinateRing :=
Quotient.algebra R
noncomputable instance : Algebra R[X] W'.CoordinateRing :=
Quotient.algebra R[X]
instance : IsScalarTower R R[X] W'.CoordinateRing :=
Quotient.isScalarTower R R[X] _
instance [Subsingleton R] : Subsingleton W'.CoordinateRing :=
Module.subsingleton R[X] _
variable (W') in
/-- The natural ring homomorphism mapping `R[X][Y]` to `R[W]`. -/
noncomputable abbrev mk : R[X][Y] →+* W'.CoordinateRing :=
AdjoinRoot.mk W'.polynomial
open scoped Classical in
variable (W') in
/-- The power basis `{1, Y}` for `R[W]` over `R[X]`. -/
protected noncomputable def basis : Basis (Fin 2) R[X] W'.CoordinateRing :=
(subsingleton_or_nontrivial R).by_cases (fun _ => default) fun _ =>
(AdjoinRoot.powerBasis' monic_polynomial).basis.reindex <| finCongr natDegree_polynomial
lemma basis_apply (n : Fin 2) :
CoordinateRing.basis W' n = (AdjoinRoot.powerBasis' monic_polynomial).gen ^ (n : ℕ) := by
classical
nontriviality R
rw [CoordinateRing.basis, Or.by_cases, dif_neg <| not_subsingleton R, Basis.reindex_apply,
PowerBasis.basis_eq_pow, finCongr_symm_apply, Fin.coe_cast]
@[simp]
lemma basis_zero : CoordinateRing.basis W' 0 = 1 := by
simpa only [basis_apply] using pow_zero _
@[simp]
lemma basis_one : CoordinateRing.basis W' 1 = mk W' Y := by
simpa only [basis_apply] using pow_one _
lemma coe_basis : (CoordinateRing.basis W' : Fin 2 → W'.CoordinateRing) = ![1, mk W' Y] := by
ext n
fin_cases n
exacts [basis_zero, basis_one]
lemma smul (x : R[X]) (y : W'.CoordinateRing) : x • y = mk W' (C x) * y :=
(algebraMap_smul W'.CoordinateRing x y).symm
lemma smul_basis_eq_zero {p q : R[X]} (hpq : p • (1 : W'.CoordinateRing) + q • mk W' Y = 0) :
p = 0 ∧ q = 0 := by
have h := Fintype.linearIndependent_iff.mp (CoordinateRing.basis W').linearIndependent ![p, q]
rw [Fin.sum_univ_succ, basis_zero, Fin.sum_univ_one, Fin.succ_zero_eq_one, basis_one] at h
exact ⟨h hpq 0, h hpq 1⟩
lemma exists_smul_basis_eq (x : W'.CoordinateRing) :
∃ p q : R[X], p • (1 : W'.CoordinateRing) + q • mk W' Y = x := by
have h := (CoordinateRing.basis W').sum_equivFun x
rw [Fin.sum_univ_succ, Fin.sum_univ_one, basis_zero, Fin.succ_zero_eq_one, basis_one] at h
exact ⟨_, _, h⟩
lemma smul_basis_mul_C (y : R[X]) (p q : R[X]) :
(p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' (C y) =
(p * y) • (1 : W'.CoordinateRing) + (q * y) • mk W' Y := by
simp only [smul, map_mul]
ring1
lemma smul_basis_mul_Y (p q : R[X]) : (p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' Y =
(q * (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆)) • (1 : W'.CoordinateRing) +
(p - q * (C W'.a₁ * X + C W'.a₃)) • mk W' Y := by
have Y_sq : mk W' Y ^ 2 = mk W' (C (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆) -
C (C W'.a₁ * X + C W'.a₃) * Y) := AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [polynomial]; ring1⟩
simp only [smul, add_mul, mul_assoc, ← sq, Y_sq, map_sub, map_mul]
ring1
variable (W') in
/-- The ring homomorphism `R[W] →+* S[W.map f]` induced by a ring homomorphism `f : R →+* S`. -/
noncomputable def map (f : R →+* S) : W'.CoordinateRing →+* (W'.map f).toAffine.CoordinateRing :=
AdjoinRoot.lift ((AdjoinRoot.of _).comp <| mapRingHom f)
((AdjoinRoot.root (W'.map f).toAffine.polynomial)) <| by
rw [← eval₂_map, ← map_polynomial, AdjoinRoot.eval₂_root]
lemma map_mk (f : R →+* S) (x : R[X][Y]) :
map W' f (mk W' x) = mk (W'.map f) (x.map <| mapRingHom f) := by
rw [map, AdjoinRoot.lift_mk, ← eval₂_map]
exact AdjoinRoot.aeval_eq <| x.map <| mapRingHom f
protected lemma map_smul (f : R →+* S) (x : R[X]) (y : W'.CoordinateRing) :
map W' f (x • y) = x.map f • map W' f y := by
rw [smul, map_mul, map_mk, map_C, smul]
rfl
lemma map_injective {f : R →+* S} (hf : Function.Injective f) : Function.Injective <| map W' f :=
(injective_iff_map_eq_zero _).mpr fun y hy => by
obtain ⟨p, q, rfl⟩ := exists_smul_basis_eq y
simp_rw [map_add, CoordinateRing.map_smul, map_one, map_mk, map_X] at hy
obtain ⟨hp, hq⟩ := smul_basis_eq_zero hy
rw [Polynomial.map_eq_zero_iff hf] at hp hq
simp_rw [hp, hq, zero_smul, add_zero]
instance [IsDomain R] : IsDomain W'.CoordinateRing :=
have : IsDomain (W'.map <| algebraMap R <| FractionRing R).toAffine.CoordinateRing :=
AdjoinRoot.isDomain_of_prime irreducible_polynomial.prime
(map_injective <| IsFractionRing.injective R <| FractionRing R).isDomain
/-! ## Ideals in the affine coordinate ring -/
variable (W') in
/-- The class of the element `X - x` in `R[W]` for some `x` in `R`. -/
noncomputable def XClass (x : R) : W'.CoordinateRing :=
mk W' <| C <| X - C x
lemma XClass_ne_zero [Nontrivial R] (x : R) : XClass W' x ≠ 0 :=
AdjoinRoot.mk_ne_zero_of_natDegree_lt monic_polynomial (C_ne_zero.mpr <| X_sub_C_ne_zero x) <|
by rw [natDegree_polynomial, natDegree_C]; norm_num1
variable (W') in
/-- The class of the element `Y - y(X)` in `R[W]` for some `y(X)` in `R[X]`. -/
noncomputable def YClass (y : R[X]) : W'.CoordinateRing :=
mk W' <| Y - C y
lemma YClass_ne_zero [Nontrivial R] (y : R[X]) : YClass W' y ≠ 0 :=
AdjoinRoot.mk_ne_zero_of_natDegree_lt monic_polynomial (X_sub_C_ne_zero y) <|
by rw [natDegree_polynomial, natDegree_X_sub_C]; norm_num1
lemma C_addPolynomial (x y ℓ : R) : mk W' (C <| W'.addPolynomial x y ℓ) =
mk W' ((Y - C (linePolynomial x y ℓ)) * (W'.negPolynomial - C (linePolynomial x y ℓ))) :=
AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [W'.C_addPolynomial, add_sub_cancel_left, mul_one]⟩
lemma C_addPolynomial_slope [DecidableEq F] {x₁ x₂ y₁ y₂ : F}
(h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂) (hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
mk W (C <| W.addPolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) =
-(XClass W x₁ * XClass W x₂ * XClass W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)) :=
congr_arg (mk W) <| W.C_addPolynomial_slope h₁ h₂ hxy
variable (W') in
/-- The ideal `⟨X - x⟩` of `R[W]` for some `x` in `R`. -/
noncomputable def XIdeal (x : R) : Ideal W'.CoordinateRing :=
.span {XClass W' x}
variable (W') in
/-- The ideal `⟨Y - y(X)⟩` of `R[W]` for some `y(X)` in `R[X]`. -/
noncomputable def YIdeal (y : R[X]) : Ideal W'.CoordinateRing :=
.span {YClass W' y}
variable (W') in
/-- The ideal `⟨X - x, Y - y(X)⟩` of `R[W]` for some `x` in `R` and `y(X)` in `R[X]`. -/
noncomputable def XYIdeal (x : R) (y : R[X]) : Ideal W'.CoordinateRing :=
.span {XClass W' x, YClass W' y}
/-- The `R`-algebra isomorphism from `R[W] / ⟨X - x, Y - y(X)⟩` to `R` obtained by evaluation at
some `y(X)` in `R[X]` and at some `x` in `R` provided that `W(x, y(x)) = 0`. -/
noncomputable def quotientXYIdealEquiv {x : R} {y : R[X]} (h : (W'.polynomial.eval y).eval x = 0) :
(W'.CoordinateRing ⧸ XYIdeal W' x y) ≃ₐ[R] R :=
((quotientEquivAlgOfEq R <| by
simp only [XYIdeal, XClass, YClass, ← Set.image_pair, ← map_span]; rfl).trans <|
DoubleQuot.quotQuotEquivQuotOfLEₐ R <| (span_singleton_le_iff_mem _).mpr <|
mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero.mpr h).trans
quotientSpanCXSubCXSubCAlgEquiv
lemma XYIdeal_add_eq (x₁ x₂ y₁ ℓ : R) : XYIdeal W' (W'.addX x₁ x₂ ℓ) (C <| W'.addY x₁ x₂ y₁ ℓ) =
.span {mk W' <| W'.negPolynomial - C (linePolynomial x₁ y₁ ℓ)} ⊔
XIdeal W' (W'.addX x₁ x₂ ℓ) := by
simp only [XYIdeal, XIdeal, XClass, YClass, addY, negAddY, negY, negPolynomial, linePolynomial]
rw [sub_sub <| -(Y : R[X][Y]), neg_sub_left (Y : R[X][Y]), map_neg, span_singleton_neg, sup_comm,
← span_insert, ← span_pair_add_mul_right <| mk W' <| C <| C <| W'.a₁ + ℓ, ← map_mul, ← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
C_simp
ring1
lemma XYIdeal_eq₁ (x y ℓ : R) : XYIdeal W' x (C y) = XYIdeal W' x (linePolynomial x y ℓ) := by
simp only [XYIdeal, XClass, YClass, linePolynomial]
rw [← span_pair_add_mul_right <| mk W' <| C <| C <| -ℓ, ← map_mul, ← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
C_simp
ring1
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
lemma XYIdeal_eq₂ [DecidableEq F] {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
by_cases hx : x₁ = x₂
· have hy : y₁ ≠ W.negY x₂ y₂ := fun h => hxy ⟨hx, h⟩
rcases hx, Y_eq_of_Y_ne h₁ h₂ hx hy with ⟨rfl, rfl⟩
simp [linePolynomial]
· simp [field, linePolynomial, slope_of_X_ne hx, sub_ne_zero_of_ne hx]
ring1
nth_rw 1 [hy₂]
simp only [XYIdeal, XClass, YClass, linePolynomial]
rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← map_mul, ← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul]
C_simp
ring1
lemma XYIdeal_neg_mul {x y : F} (h : W.Nonsingular x y) :
XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
have Y_rw : (Y - C (C y)) * (Y - C (C <| W.negY x y)) -
C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
W.polynomial * 1 := by
linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
congr_arg C (congr_arg C ((equation_iff ..).mp h.left).symm)
simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← map_mul,
AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, map_mul, span_insert, ← span_singleton_mul_span_singleton,
← Ideal.mul_sup, ← span_insert]
convert mul_top (_ : Ideal W.CoordinateRing) using 2
on_goal 2 => infer_instance
simp_rw [← Set.image_singleton (f := mk W), ← Set.image_insert_eq, ← map_span]
convert map_top (R := F[X][Y]) (mk W) using 1
apply congr_arg
simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
rcases ((nonsingular_iff' ..).mp h).right with hx | hy
· let W_X := W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄)
refine
⟨C <| C W_X⁻¹ * -(X + C (2 * x + W.a₂)), C <| C <| W_X⁻¹ * W.a₁, 0, C <| C <| W_X⁻¹ * -1, ?_⟩
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
simp only [W_X, mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel₀ hx]
C_simp
ring1
· let W_Y := 2 * y + W.a₁ * x + W.a₃
refine ⟨0, C <| C W_Y⁻¹, C <| C <| W_Y⁻¹ * -1, 0, ?_⟩
rw [negY, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hy]
simp only [W_Y, mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel₀ hy]
C_simp
ring1
lemma XYIdeal_mul_XYIdeal [DecidableEq F] {x₁ x₂ y₁ y₂ : F}
(h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂) (hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
XIdeal W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) * (XYIdeal W x₁ (C y₁) * XYIdeal W x₂ (C y₂)) =
YIdeal W (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) *
XYIdeal W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)
(C <| W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
have sup_rw : ∀ a b c d : Ideal W.CoordinateRing, a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c :=
fun _ _ c _ => by rw [← sup_assoc, sup_comm c, sup_sup_sup_comm, ← sup_assoc]
rw [XYIdeal_add_eq, XIdeal, mul_comm, XYIdeal_eq₁ x₁ y₁ <| W.slope x₁ x₂ y₁ y₂, XYIdeal,
XYIdeal_eq₂ h₁ h₂ hxy, XYIdeal, span_pair_mul_span_pair]
simp_rw [span_insert, sup_rw, Ideal.sup_mul, span_singleton_mul_span_singleton]
rw [← neg_eq_iff_eq_neg.mpr <| C_addPolynomial_slope h₁ h₂ hxy, span_singleton_neg,
C_addPolynomial, map_mul, YClass]
simp_rw [mul_comm <| XClass W x₁, mul_assoc, ← span_singleton_mul_span_singleton, ← Ideal.mul_sup]
rw [span_singleton_mul_span_singleton, ← span_insert,
← span_pair_add_mul_right <| -(XClass W <| W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂), mul_neg,
← sub_eq_add_neg, ← sub_mul, ← map_sub <| mk W, sub_sub_sub_cancel_right, span_insert,
← span_singleton_mul_span_singleton, ← sup_rw, ← Ideal.sup_mul, ← Ideal.sup_mul]
apply congr_arg (_ ∘ _)
convert top_mul (_ : Ideal W.CoordinateRing)
simp_rw [XClass, ← Set.image_singleton (f := mk W), ← map_span, ← Ideal.map_sup, eq_top_iff_one,
mem_map_iff_of_surjective _ AdjoinRoot.mk_surjective, ← span_insert, mem_span_insert',
mem_span_singleton']
by_cases hx : x₁ = x₂
· have hy : y₁ ≠ W.negY x₂ y₂ := fun h => hxy ⟨hx, h⟩
rcases hx, Y_eq_of_Y_ne h₁ h₂ hx hy with ⟨rfl, rfl⟩
let y := (y₁ - W.negY x₁ y₁) ^ 2
replace hxy := pow_ne_zero 2 <| sub_ne_zero_of_ne hy
refine ⟨1 + C (C <| y⁻¹ * 4) * W.polynomial,
⟨C <| C y⁻¹ * (C 4 * X ^ 2 + C (4 * x₁ + W.b₂) * X + C (4 * x₁ ^ 2 + W.b₂ * x₁ + 2 * W.b₄)),
0, C (C y⁻¹) * (Y - W.negPolynomial), ?_⟩, by
rw [map_add, map_one, map_mul <| mk W, AdjoinRoot.mk_self, mul_zero, add_zero]⟩
rw [polynomial, negPolynomial, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hxy]
simp only [y, mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel₀ hxy]
linear_combination (norm := (rw [b₂, b₄, negY]; C_simp; ring1))
-4 * congr_arg C (congr_arg C <| (equation_iff ..).mp h₁)
· replace hx := sub_ne_zero_of_ne hx
refine ⟨_, ⟨⟨C <| C (x₁ - x₂)⁻¹, C <| C <| (x₁ - x₂)⁻¹ * -1, 0, ?_⟩, map_one _⟩⟩
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
simp only [← mul_assoc, mul_add, ← C_mul, mul_inv_cancel₀ hx]
C_simp
ring1
/-- The non-zero fractional ideal `⟨X - x, Y - y⟩` of `F(W)` for some `x` and `y` in `F`. -/
noncomputable def XYIdeal' {x y : F} (h : W.Nonsingular x y) :
(FractionalIdeal W.CoordinateRing⁰ W.FunctionField)ˣ :=
Units.mkOfMulEqOne _ _ <| by
rw [← mul_assoc, ← coeIdeal_mul, mul_comm <| XYIdeal W .., XYIdeal_neg_mul h, XIdeal,
FractionalIdeal.coe_ideal_span_singleton_mul_inv W.FunctionField <| XClass_ne_zero x]
lemma XYIdeal'_eq {x y : F} (h : W.Nonsingular x y) :
(XYIdeal' h : FractionalIdeal W.CoordinateRing⁰ W.FunctionField) = XYIdeal W x (C y) :=
rfl
lemma mk_XYIdeal'_neg_mul {x y : F} (h : W.Nonsingular x y) :
ClassGroup.mk (XYIdeal' <| (nonsingular_neg ..).mpr h) * ClassGroup.mk (XYIdeal' h) = 1 := by
rw [← map_mul]
exact (ClassGroup.mk_eq_one_of_coe_ideal <| (coeIdeal_mul ..).symm.trans <|
FractionalIdeal.coeIdeal_inj.mpr <| XYIdeal_neg_mul h).mpr ⟨_, XClass_ne_zero x, rfl⟩
lemma mk_XYIdeal'_mul_mk_XYIdeal' [DecidableEq F] {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁)
(h₂ : W.Nonsingular x₂ y₂) (hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
ClassGroup.mk (XYIdeal' h₁) * ClassGroup.mk (XYIdeal' h₂) =
ClassGroup.mk (XYIdeal' <| nonsingular_add h₁ h₂ hxy) := by
rw [← map_mul]
exact (ClassGroup.mk_eq_mk_of_coe_ideal (coeIdeal_mul ..).symm <| XYIdeal'_eq _).mpr
⟨_, _, XClass_ne_zero _, YClass_ne_zero _, XYIdeal_mul_XYIdeal h₁.left h₂.left hxy⟩
/-! ## Norms on the affine coordinate ring -/
lemma norm_smul_basis (p q : R[X]) : Algebra.norm R[X] (p • (1 : W'.CoordinateRing) + q • mk W' Y) =
p ^ 2 - p * q * (C W'.a₁ * X + C W'.a₃) -
q ^ 2 * (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆) := by
simp_rw [Algebra.norm_eq_matrix_det <| CoordinateRing.basis W', Matrix.det_fin_two,
Algebra.leftMulMatrix_eq_repr_mul, basis_zero, mul_one, basis_one, smul_basis_mul_Y, map_add,
Finsupp.add_apply, map_smul, Finsupp.smul_apply, ← basis_zero, ← basis_one,
Basis.repr_self_apply, if_pos, one_ne_zero, if_false, smul_eq_mul]
ring1
lemma coe_norm_smul_basis (p q : R[X]) : Algebra.norm R[X] (p • 1 + q • mk W' Y) =
mk W' ((C p + C q * X) * (C p + C q * (-(Y : R[X][Y]) - C (C W'.a₁ * X + C W'.a₃)))) :=
AdjoinRoot.mk_eq_mk.mpr ⟨C q ^ 2, by simp only [norm_smul_basis, polynomial]; C_simp; ring1⟩
lemma degree_norm_smul_basis [IsDomain R] (p q : R[X]) :
(Algebra.norm R[X] <| p • 1 + q • mk W' Y).degree = max (2 • p.degree) (2 • q.degree + 3) := by
have hdp : (p ^ 2).degree = 2 • p.degree := degree_pow p 2
have hdpq : (p * q * (C W'.a₁ * X + C W'.a₃)).degree ≤ p.degree + q.degree + 1 := by
grw [degree_mul, degree_mul, degree_linear_le]
have hdq :
(q ^ 2 * (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆)).degree = 2 • q.degree + 3 := by
rw [degree_mul, degree_pow, ← one_mul <| X ^ 3, ← C_1, degree_cubic <| one_ne_zero' R]
rw [norm_smul_basis]
by_cases hp : p = 0
· simp only [hp, hdq, neg_zero, zero_sub, zero_mul, zero_pow two_ne_zero, degree_neg]
exact (max_bot_left _).symm
· by_cases hq : q = 0
· simp only [hq, hdp, sub_zero, zero_mul, mul_zero, zero_pow two_ne_zero]
exact (max_bot_right _).symm
· rw [← not_congr degree_eq_bot] at hp hq
-- Porting note: BUG `cases` tactic does not modify assumptions in `hp'` and `hq'`
rcases hp' : p.degree with _ | dp -- `hp' : ` should be redundant
· exact (hp hp').elim -- `hp'` should be `rfl`
· rw [hp'] at hdp hdpq -- line should be redundant
rcases hq' : q.degree with _ | dq -- `hq' : ` should be redundant
· exact (hq hq').elim -- `hq'` should be `rfl`
· rw [hq'] at hdpq hdq -- line should be redundant
rcases le_or_gt dp (dq + 1) with hpq | hpq
· convert (degree_sub_eq_right_of_degree_lt <| (degree_sub_le _ _).trans_lt <|
max_lt_iff.mpr ⟨hdp.trans_lt _, hdpq.trans_lt _⟩).trans
(max_eq_right_of_lt _).symm <;> rw [hdq] <;>
exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq]
· rw [sub_sub]
convert (degree_sub_eq_left_of_degree_lt <| (degree_add_le _ _).trans_lt <|
max_lt_iff.mpr ⟨hdpq.trans_lt _, hdq.trans_lt _⟩).trans
(max_eq_left_of_lt _).symm <;> rw [hdp] <;>
exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq]
lemma degree_norm_ne_one [IsDomain R] (x : W'.CoordinateRing) :
(Algebra.norm R[X] x).degree ≠ 1 := by
rcases exists_smul_basis_eq x with ⟨p, q, rfl⟩
rw [degree_norm_smul_basis]
rcases p.degree with (_ | _ | _ | _) <;> cases q.degree
any_goals rintro (_ | _)
exact (lt_max_of_lt_right <| (cmp_eq_lt_iff ..).mp rfl).ne'
lemma natDegree_norm_ne_one [IsDomain R] (x : W'.CoordinateRing) :
(Algebra.norm R[X] x).natDegree ≠ 1 :=
degree_norm_ne_one x ∘ (degree_eq_iff_natDegree_eq_of_pos zero_lt_one).mpr
end CoordinateRing
/-! ## Nonsingular points in affine coordinates -/
variable (W') in
/-- A nonsingular point on a Weierstrass curve `W` in affine coordinates. This is either the unique
point at infinity `WeierstrassCurve.Affine.Point.zero` or a nonsingular affine point
`WeierstrassCurve.Affine.Point.some (x, y)` satisfying the Weierstrass equation of `W`. -/
inductive Point
| zero
| some {x y : R} (h : W'.Nonsingular x y)
/-- For an algebraic extension `S` of a ring `R`, the type of nonsingular `S`-points on a
Weierstrass curve `W` over `R` in affine coordinates. -/
scoped notation3:max W' "⟮" S "⟯" => Affine.Point <| baseChange W' S
namespace Point
instance : Inhabited W'.Point :=
⟨.zero⟩
instance : Zero W'.Point :=
⟨.zero⟩
lemma zero_def : 0 = (.zero : W'.Point) :=
rfl
lemma some_ne_zero {x y : R} (h : W'.Nonsingular x y) : Point.some h ≠ 0 := by
rintro (_ | _)
/-- The negation of a nonsingular point on a Weierstrass curve in affine coordinates.
Given a nonsingular point `P` in affine coordinates, use `-P` instead of `neg P`. -/
def neg : W'.Point → W'.Point
| 0 => 0
| some h => some <| (nonsingular_neg ..).mpr h
instance : Neg W'.Point :=
⟨neg⟩
lemma neg_def (P : W'.Point) : -P = P.neg :=
rfl
@[simp]
lemma neg_zero : (-0 : W'.Point) = 0 :=
rfl
@[simp]
lemma neg_some {x y : R} (h : W'.Nonsingular x y) : -some h = some ((nonsingular_neg ..).mpr h) :=
rfl
instance : InvolutiveNeg W'.Point where
neg_neg := by
rintro (_ | _)
· rfl
· simp only [neg_some, negY_negY]
/-- The addition of two nonsingular points on a Weierstrass curve in affine coordinates.
Given two nonsingular points `P` and `Q` in affine coordinates, use `P + Q` instead of `add P Q`. -/
def add [DecidableEq F] : W.Point → W.Point → W.Point
| 0, P => P
| P, 0 => P
| @some _ _ _ x₁ y₁ h₁, @some _ _ _ x₂ y₂ h₂ =>
if hxy : x₁ = x₂ ∧ y₁ = W.negY x₂ y₂ then 0 else some <| nonsingular_add h₁ h₂ hxy
section add
variable [DecidableEq F]
instance : Add W.Point :=
⟨add⟩
instance : AddZeroClass W.Point where
zero_add := by rintro (_ | _) <;> rfl
add_zero := by rintro (_ | _) <;> rfl
lemma add_def (P Q : W.Point) : P + Q = P.add Q :=
rfl
lemma add_some {x₁ x₂ y₁ y₂ : F} (hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) {h₁ : W.Nonsingular x₁ y₁}
{h₂ : W.Nonsingular x₂ y₂} : some h₁ + some h₂ = some (nonsingular_add h₁ h₂ hxy) := by
simp only [add_def, add, dif_neg hxy]
@[simp]
lemma add_of_Y_eq {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ = x₂) (hy : y₁ = W.negY x₂ y₂) : some h₁ + some h₂ = 0 := by
simpa only [add_def, add] using dif_pos ⟨hx, hy⟩
-- Removing `@[simp]`, because `hy` causes a maximum recursion depth error in the simpNF linter.
lemma add_self_of_Y_eq {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ = W.negY x₁ y₁) :
some h₁ + some h₁ = 0 :=
add_of_Y_eq rfl hy
-- @[simp] -- Not a good simp lemma, since `hy` is not in simp normal form.
lemma add_of_Y_ne {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hy : y₁ ≠ W.negY x₂ y₂) :
some h₁ + some h₂ = some (nonsingular_add h₁ h₂ fun hxy => hy hxy.right) :=
add_some fun hxy => hy hxy.right
lemma add_of_Y_ne' {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hy : y₁ ≠ W.negY x₂ y₂) :
some h₁ + some h₂ = -some (nonsingular_negAdd h₁ h₂ fun hxy => hy hxy.right) :=
add_of_Y_ne hy
-- @[simp] -- Not a good simp lemma, since `hy` is not in simp normal form.
lemma add_self_of_Y_ne {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ ≠ W.negY x₁ y₁) :
some h₁ + some h₁ = some (nonsingular_add h₁ h₁ fun hxy => hy hxy.right) :=
add_of_Y_ne hy
lemma add_self_of_Y_ne' {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ ≠ W.negY x₁ y₁) :
some h₁ + some h₁ = -some (nonsingular_negAdd h₁ h₁ fun hxy => hy hxy.right) :=
add_of_Y_ne hy
@[simp]
lemma add_of_X_ne {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ ≠ x₂) : some h₁ + some h₂ = some (nonsingular_add h₁ h₂ fun hxy => hx hxy.left) :=
add_some fun hxy => hx hxy.left
lemma add_of_X_ne' {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ ≠ x₂) : some h₁ + some h₂ = -some (nonsingular_negAdd h₁ h₂ fun hxy => hx hxy.left) :=
add_of_X_ne hx
variable [DecidableEq K] [DecidableEq L]
/-! ## Group law in affine coordinates -/
/-- The group homomorphism mapping a nonsingular affine point `(x, y)` of a Weierstrass curve `W` to
the class of the non-zero fractional ideal `⟨X - x, Y - y⟩` in the ideal class group of `F[W]`. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
toFun P := match P with
| 0 => 0
| some h => Additive.ofMul <| ClassGroup.mk <| CoordinateRing.XYIdeal' h
map_zero' := rfl
map_add' := by
rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
any_goals simp only [← zero_def, zero_add, add_zero]
by_cases hxy : x₁ = x₂ ∧ y₁ = W.negY x₂ y₂
· simp only [hxy.left, hxy.right, add_of_Y_eq rfl rfl]
exact (CoordinateRing.mk_XYIdeal'_neg_mul h₂).symm
· simp only [add_some hxy]
exact (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ hxy).symm
lemma toClass_zero : toClass (0 : W.Point) = 0 :=
rfl
lemma toClass_some {x y : F} (h : W.Nonsingular x y) :
toClass (some h) = ClassGroup.mk (CoordinateRing.XYIdeal' h) :=
rfl
private lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
any_goals rfl
· rw [← zero_def, zero_add, eq_comm (a := 0), neg_eq_iff_eq_neg, neg_zero]
· rw [neg_some, some.injEq]
constructor
· contrapose
exact fun hxy => by simpa only [add_some hxy] using some_ne_zero _
· exact fun ⟨hx, hy⟩ => add_of_Y_eq hx hy
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
constructor
· intro hP
rcases P with (_ | ⟨h, _⟩)
· rfl
· rcases (ClassGroup.mk_eq_one_of_coe_ideal <| by rfl).mp hP with ⟨p, h0, hp⟩
apply (p.natDegree_norm_ne_one _).elim
rw [← finrank_quotient_span_eq_natDegree_norm (CoordinateRing.basis W) h0,
← (quotientEquivAlgOfEq F hp).toLinearEquiv.finrank_eq,
(CoordinateRing.quotientXYIdealEquiv h).toLinearEquiv.finrank_eq, Module.finrank_self]
· exact congr_arg toClass
lemma toClass_injective : Function.Injective <| toClass (W := W) := by
rintro (_ | h) _ hP
all_goals rw [← neg_inj, ← add_eq_zero, ← toClass_eq_zero, map_add, ← hP]
· exact zero_add 0
· exact CoordinateRing.mk_XYIdeal'_neg_mul h
instance : AddCommGroup W.Point where
nsmul := nsmulRec
zsmul := zsmulRec
zero_add := zero_add
add_zero := add_zero
neg_add_cancel _ := by rw [add_eq_zero]
add_comm _ _ := toClass_injective <| by simp only [map_add, add_comm]
add_assoc _ _ _ := toClass_injective <| by simp only [map_add, add_assoc]
/-! ## Maps and base changes -/
variable [Algebra R S] [Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebra R K] [Algebra S K]
[IsScalarTower R S K] [Algebra R L] [Algebra S L] [IsScalarTower R S L] (f : F →ₐ[S] K)
(g : K →ₐ[S] L)
/-- The group homomorphism from `W⟮F⟯` to `W⟮K⟯` induced by an algebra homomorphism `f : F →ₐ[S] K`,
where `W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/
noncomputable def map : W'⟮F⟯ →+ W'⟮K⟯ where
toFun P := match P with
| 0 => 0
| some h => some <| (baseChange_nonsingular _ _ f.injective).mpr h
map_zero' := rfl
map_add' := by
rintro (_ | @⟨x₁, y₁, _⟩) (_ | @⟨x₂, y₂, _⟩)
any_goals rfl
by_cases hxy : x₁ = x₂ ∧ y₁ = (W'.baseChange F).toAffine.negY x₂ y₂
· rw [add_of_Y_eq hxy.left hxy.right,
add_of_Y_eq (congr_arg _ hxy.left) <| by rw [hxy.right, baseChange_negY]]
· simp only [add_some hxy, ← baseChange_addX, ← baseChange_addY, ← baseChange_slope]
rw [add_some fun h => hxy ⟨f.injective h.1, f.injective (W'.baseChange_negY f .. ▸ h).2⟩]
lemma map_zero : map f (0 : W'⟮F⟯) = 0 :=
rfl
lemma map_some {x y : F} (h : (W'.baseChange F).toAffine.Nonsingular x y) :
map f (some h) = some ((W'.baseChange_nonsingular _ _ f.injective).mpr h) :=
rfl
lemma map_id (P : W'⟮F⟯) : map (Algebra.ofId F F) P = P := by
cases P <;> rfl
lemma map_map (P : W'⟮F⟯) : map g (map f P) = map (g.comp f) P := by
cases P <;> rfl
lemma map_injective : Function.Injective <| map (W' := W') f := by
rintro (_ | _) (_ | _) h
any_goals contradiction
· rfl
· simpa only [some.injEq] using ⟨f.injective (some.inj h).left, f.injective (some.inj h).right⟩
variable (F K) in
/-- The group homomorphism from `W⟮F⟯` to `W⟮K⟯` induced by the base change from `F` to `K`, where
`W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/
noncomputable abbrev baseChange [Algebra F K] [IsScalarTower R F K] : W'⟮F⟯ →+ W'⟮K⟯ :=
map <| Algebra.ofId F K
lemma map_baseChange [Algebra F K] [IsScalarTower R F K] [Algebra F L] [IsScalarTower R F L]
(f : K →ₐ[F] L) (P : W'⟮F⟯) : map f (baseChange F K P) = baseChange F L P := by
have : Subsingleton (F →ₐ[F] L) := inferInstance
convert map_map (Algebra.ofId F K) f P
end add
end Point
end Affine
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Basic.lean | import Mathlib.Algebra.Polynomial.Bivariate
import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange
/-!
# Weierstrass equations and the nonsingular condition in affine coordinates
Let `W` be a Weierstrass curve over a commutative ring `R` with coefficients `aᵢ`. An *affine point*
on `W` is a tuple `(x, y)` of elements in `R` satisfying the *Weierstrass equation* `W(X, Y) = 0` in
*affine coordinates*, where `W(X, Y) := Y² + a₁XY + a₃Y - (X³ + a₂X² + a₄X + a₆)`. It is
*nonsingular* if its partial derivatives `W_X(x, y)` and `W_Y(x, y)` do not vanish simultaneously.
This file defines polynomials associated to Weierstrass equations and the nonsingular condition in
affine coordinates. The group law on the actual type of nonsingular points in affine coordinates
will be defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean`, based on the
formulae for group operations in `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`.
## Main definitions
* `WeierstrassCurve.Affine.Equation`: the Weierstrass equation in affine coordinates.
* `WeierstrassCurve.Affine.Nonsingular`: the nonsingular condition in affine coordinates.
## Main statements
* `WeierstrassCurve.Affine.equation_iff_nonsingular`: an elliptic curve in affine coordinates is
nonsingular at every point.
## Implementation notes
All definitions and lemmas for Weierstrass curves in affine coordinates live in the namespace
`WeierstrassCurve.Affine` to distinguish them from those in other coordinates. This is simply an
abbreviation for `WeierstrassCurve` that can be converted using `WeierstrassCurve.toAffine`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, affine, Weierstrass equation, nonsingular
-/
open Polynomial
open scoped Polynomial.Bivariate
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_neg, eval_add, eval_sub, eval_mul, eval_pow, evalEval])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow, map_div₀,
Polynomial.map_ofNat, map_C, map_X, Polynomial.map_neg, Polynomial.map_add, Polynomial.map_sub,
Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_div, coe_mapRingHom,
WeierstrassCurve.map])
universe r s u v
variable {R : Type r} {S : Type s} {A : Type u} {B : Type v}
namespace WeierstrassCurve
/-! ## Affine coordinates -/
variable (R) in
/-- An abbreviation for a Weierstrass curve in affine coordinates. -/
abbrev Affine : Type r :=
WeierstrassCurve R
/-- The conversion from a Weierstrass curve to affine coordinates. -/
abbrev toAffine (W : WeierstrassCurve R) : Affine R :=
W
variable [CommRing R] [CommRing S] [CommRing A] [CommRing B] {W : Affine R}
namespace Affine
/-! ## Weierstrass equations in affine coordinates -/
variable (W) in
/-- The polynomial `W(X, Y) := Y² + a₁XY + a₃Y - (X³ + a₂X² + a₄X + a₆)` associated to a Weierstrass
curve `W` over a ring `R` in affine coordinates.
For ease of polynomial manipulation, this is represented as a term of type `R[X][X]`, where the
inner variable represents `X` and the outer variable represents `Y`. For clarity, the alternative
notations `Y` and `R[X][Y]` are provided in the `Polynomial.Bivariate` scope to represent the outer
variable and the bivariate polynomial ring `R[X][X]` respectively. -/
noncomputable def polynomial : R[X][Y] :=
Y ^ 2 + C (C W.a₁ * X + C W.a₃) * Y - C (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆)
lemma polynomial_eq : W.polynomial = Cubic.toPoly
⟨0, 1, Cubic.toPoly ⟨0, 0, W.a₁, W.a₃⟩, Cubic.toPoly ⟨-1, -W.a₂, -W.a₄, -W.a₆⟩⟩ := by
simp_rw [polynomial, Cubic.toPoly]
map_simp
simp only [C_0, C_1]
ring1
lemma polynomial_ne_zero [Nontrivial R] : W.polynomial ≠ 0 := by
rw [polynomial_eq]
exact Cubic.ne_zero_of_b_ne_zero one_ne_zero
@[simp]
lemma degree_polynomial [Nontrivial R] : W.polynomial.degree = 2 := by
rw [polynomial_eq]
exact Cubic.degree_of_b_ne_zero' one_ne_zero
@[simp]
lemma natDegree_polynomial [Nontrivial R] : W.polynomial.natDegree = 2 := by
rw [polynomial_eq]
exact Cubic.natDegree_of_b_ne_zero' one_ne_zero
lemma monic_polynomial : W.polynomial.Monic := by
nontriviality R
simpa only [polynomial_eq] using Cubic.monic_of_b_eq_one'
lemma irreducible_polynomial [IsDomain R] : Irreducible W.polynomial := by
by_contra h
rcases (monic_polynomial.not_irreducible_iff_exists_add_mul_eq_coeff natDegree_polynomial).mp h
with ⟨f, g, h0, h1⟩
simp only [polynomial_eq, Cubic.coeff_eq_c, Cubic.coeff_eq_d] at h0 h1
apply_fun degree at h0 h1
rw [Cubic.degree_of_a_ne_zero' <| neg_ne_zero.mpr <| one_ne_zero' R, degree_mul] at h0
apply (h1.symm.le.trans Cubic.degree_of_b_eq_zero').not_gt
rcases Nat.WithBot.add_eq_three_iff.mp h0.symm with h | h | h | h
iterate 2 rw [degree_add_eq_right_of_degree_lt] <;> simp only [h] <;> decide
iterate 2 rw [degree_add_eq_left_of_degree_lt] <;> simp only [h] <;> decide
lemma evalEval_polynomial (x y : R) : W.polynomial.evalEval x y =
y ^ 2 + W.a₁ * x * y + W.a₃ * y - (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) := by
simp only [polynomial]
eval_simp
rw [add_mul, ← add_assoc]
@[simp]
lemma evalEval_polynomial_zero : W.polynomial.evalEval 0 0 = -W.a₆ := by
simp only [evalEval_polynomial, zero_add, zero_sub, mul_zero, zero_pow <| Nat.succ_ne_zero _]
variable (W) in
/-- The proposition that an affine point `(x, y)` lies in a Weierstrass curve `W`.
In other words, it satisfies the Weierstrass equation `W(X, Y) = 0`. -/
def Equation (x y : R) : Prop :=
W.polynomial.evalEval x y = 0
lemma equation_iff' (x y : R) : W.Equation x y ↔
y ^ 2 + W.a₁ * x * y + W.a₃ * y - (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) = 0 := by
rw [Equation, evalEval_polynomial]
lemma equation_iff (x y : R) : W.Equation x y ↔
y ^ 2 + W.a₁ * x * y + W.a₃ * y = x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆ := by
rw [equation_iff', sub_eq_zero]
@[simp]
lemma equation_zero : W.Equation 0 0 ↔ W.a₆ = 0 := by
rw [Equation, evalEval_polynomial_zero, neg_eq_zero]
lemma equation_iff_variableChange (x y : R) :
W.Equation x y ↔ (VariableChange.mk 1 x 0 y • W).toAffine.Equation 0 0 := by
rw [equation_iff', ← neg_eq_zero, equation_zero, variableChange_a₆, inv_one, Units.val_one]
congr! 1
ring1
/-! ## The nonsingular condition in affine coordinates -/
variable (W) in
/-- The partial derivative `W_X(X, Y)` with respect to `X` of the polynomial `W(X, Y)` associated to
a Weierstrass curve `W` in affine coordinates. -/
-- TODO: define this in terms of `Polynomial.derivative`.
noncomputable def polynomialX : R[X][Y] :=
C (C W.a₁) * Y - C (C 3 * X ^ 2 + C (2 * W.a₂) * X + C W.a₄)
lemma evalEval_polynomialX (x y : R) :
W.polynomialX.evalEval x y = W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) := by
simp only [polynomialX]
eval_simp
@[simp]
lemma evalEval_polynomialX_zero : W.polynomialX.evalEval 0 0 = -W.a₄ := by
simp only [evalEval_polynomialX, zero_add, zero_sub, mul_zero, zero_pow <| Nat.succ_ne_zero _]
variable (W) in
/-- The partial derivative `W_Y(X, Y)` with respect to `Y` of the polynomial `W(X, Y)` associated to
a Weierstrass curve `W` in affine coordinates. -/
-- TODO: define this in terms of `Polynomial.derivative`.
noncomputable def polynomialY : R[X][Y] :=
C (C 2) * Y + C (C W.a₁ * X + C W.a₃)
lemma evalEval_polynomialY (x y : R) : W.polynomialY.evalEval x y = 2 * y + W.a₁ * x + W.a₃ := by
simp only [polynomialY]
eval_simp
rw [← add_assoc]
@[simp]
lemma evalEval_polynomialY_zero : W.polynomialY.evalEval 0 0 = W.a₃ := by
simp only [evalEval_polynomialY, zero_add, mul_zero]
variable (W) in
/-- The proposition that an affine point `(x, y)` on a Weierstrass curve `W` is nonsingular.
In other words, either `W_X(x, y) ≠ 0` or `W_Y(x, y) ≠ 0`.
Note that this definition is only mathematically accurate for fields. -/
-- TODO: generalise this definition to be mathematically accurate for a larger class of rings.
def Nonsingular (x y : R) : Prop :=
W.Equation x y ∧ (W.polynomialX.evalEval x y ≠ 0 ∨ W.polynomialY.evalEval x y ≠ 0)
lemma nonsingular_iff' (x y : R) : W.Nonsingular x y ↔ W.Equation x y ∧
(W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) ≠ 0 ∨ 2 * y + W.a₁ * x + W.a₃ ≠ 0) := by
rw [Nonsingular, equation_iff', evalEval_polynomialX, evalEval_polynomialY]
lemma nonsingular_iff (x y : R) : W.Nonsingular x y ↔ W.Equation x y ∧
(W.a₁ * y ≠ 3 * x ^ 2 + 2 * W.a₂ * x + W.a₄ ∨ y ≠ -y - W.a₁ * x - W.a₃) := by
rw [nonsingular_iff', sub_ne_zero, ← sub_ne_zero (a := y)]
congr! 3
ring1
@[simp]
lemma nonsingular_zero : W.Nonsingular 0 0 ↔ W.a₆ = 0 ∧ (W.a₃ ≠ 0 ∨ W.a₄ ≠ 0) := by
rw [Nonsingular, equation_zero, evalEval_polynomialX_zero, neg_ne_zero, evalEval_polynomialY_zero,
or_comm]
lemma nonsingular_iff_variableChange (x y : R) :
W.Nonsingular x y ↔ (VariableChange.mk 1 x 0 y • W).toAffine.Nonsingular 0 0 := by
rw [nonsingular_iff', equation_iff_variableChange, equation_zero, ← neg_ne_zero, or_comm,
nonsingular_zero, variableChange_a₃, variableChange_a₄, inv_one, Units.val_one]
simp only [variableChange_def]
congr! 3 <;> ring1
private lemma equation_zero_iff_nonsingular_zero_of_Δ_ne_zero (hΔ : W.Δ ≠ 0) :
W.Equation 0 0 ↔ W.Nonsingular 0 0 := by
simp only [equation_zero, nonsingular_zero, iff_self_and]
contrapose! hΔ
simp only [b₂, b₄, b₆, b₈, Δ, hΔ]
ring1
lemma equation_iff_nonsingular_of_Δ_ne_zero {x y : R} (hΔ : W.Δ ≠ 0) :
W.Equation x y ↔ W.Nonsingular x y := by
rw [equation_iff_variableChange, nonsingular_iff_variableChange,
equation_zero_iff_nonsingular_zero_of_Δ_ne_zero <| by
rwa [variableChange_Δ, inv_one, Units.val_one, one_pow, one_mul]]
lemma equation_iff_nonsingular [Nontrivial R] [W.IsElliptic] {x y : R} :
W.toAffine.Equation x y ↔ W.toAffine.Nonsingular x y :=
W.toAffine.equation_iff_nonsingular_of_Δ_ne_zero <| W.coe_Δ' ▸ W.Δ'.ne_zero
/-! ## Maps and base changes -/
variable (f : R →+* S) (x y : R)
lemma map_polynomial : (W.map f).toAffine.polynomial = W.polynomial.map (mapRingHom f) := by
simp only [polynomial]
map_simp
variable {x y} in
lemma Equation.map {x y : R} (h : W.Equation x y) : (W.map f).toAffine.Equation (f x) (f y) := by
rw [Equation, map_polynomial, map_mapRingHom_evalEval, h, map_zero]
variable {f} in
lemma map_equation (hf : Function.Injective f) :
(W.map f).toAffine.Equation (f x) (f y) ↔ W.Equation x y := by
simp only [Equation, map_polynomial, map_mapRingHom_evalEval, map_eq_zero_iff f hf]
lemma map_polynomialX : (W.map f).toAffine.polynomialX = W.polynomialX.map (mapRingHom f) := by
simp only [polynomialX]
map_simp
lemma map_polynomialY : (W.map f).toAffine.polynomialY = W.polynomialY.map (mapRingHom f) := by
simp only [polynomialY]
map_simp
variable {f} in
lemma map_nonsingular (hf : Function.Injective f) :
(W.map f).toAffine.Nonsingular (f x) (f y) ↔ W.Nonsingular x y := by
simp only [Nonsingular, evalEval, map_equation _ _ hf, map_polynomialX, map_polynomialY,
map_mapRingHom_evalEval, map_ne_zero_iff f hf]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (x y : A)
lemma baseChange_polynomial : (W.baseChange B).toAffine.polynomial =
(W.baseChange A).toAffine.polynomial.map (mapRingHom f) := by
rw [← map_polynomial, map_baseChange]
variable {x y} in
lemma Equation.baseChange (h : (W.baseChange A).toAffine.Equation x y) :
(W.baseChange B).toAffine.Equation (f x) (f y) := by
convert Equation.map f.toRingHom h using 1
rw [AlgHom.toRingHom_eq_coe, map_baseChange]
variable {f} in
lemma baseChange_equation (hf : Function.Injective f) :
(W.baseChange B).toAffine.Equation (f x) (f y) ↔ (W.baseChange A).toAffine.Equation x y := by
rw [← map_equation _ _ hf, AlgHom.toRingHom_eq_coe, map_baseChange, RingHom.coe_coe]
lemma baseChange_polynomialX : (W.baseChange B).toAffine.polynomialX =
(W.baseChange A).toAffine.polynomialX.map (mapRingHom f) := by
rw [← map_polynomialX, map_baseChange]
lemma baseChange_polynomialY : (W.baseChange B).toAffine.polynomialY =
(W.baseChange A).toAffine.polynomialY.map (mapRingHom f) := by
rw [← map_polynomialY, map_baseChange]
variable {f} in
lemma baseChange_nonsingular (hf : Function.Injective f) :
(W.baseChange B).toAffine.Nonsingular (f x) (f y) ↔
(W.baseChange A).toAffine.Nonsingular x y := by
rw [← map_nonsingular _ _ hf, AlgHom.toRingHom_eq_coe, map_baseChange, RingHom.coe_coe]
end Affine
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic
/-!
# Negation and addition formulae for nonsingular points in affine coordinates
Let `W` be a Weierstrass curve over a field `F` with coefficients `aᵢ`. The nonsingular affine
points on `W` can be given negation and addition operations defined by a secant-and-tangent process.
* Given a nonsingular affine point `P`, its *negation* `-P` is defined to be the unique third
nonsingular point of intersection between `W` and the vertical line through `P`.
Explicitly, if `P` is `(x, y)`, then `-P` is `(x, -y - a₁x - a₃)`.
* Given two nonsingular affine points `P` and `Q`, their *addition* `P + Q` is defined to be the
negation of the unique third nonsingular point of intersection between `W` and the line `L`
through `P` and `Q`. Explicitly, let `P` be `(x₁, y₁)` and let `Q` be `(x₂, y₂)`.
* If `x₁ = x₂` and `y₁ = -y₂ - a₁x₂ - a₃`, then `L` is vertical.
* If `x₁ = x₂` and `y₁ ≠ -y₂ - a₁x₂ - a₃`, then `L` is the tangent of `W` at `P = Q`, and has
slope `ℓ := (3x₁² + 2a₂x₁ + a₄ - a₁y₁) / (2y₁ + a₁x₁ + a₃)`.
* Otherwise `x₁ ≠ x₂`, then `L` is the secant of `W` through `P` and `Q`, and has slope
`ℓ := (y₁ - y₂) / (x₁ - x₂)`.
In the last two cases, the `X`-coordinate of `P + Q` is then the unique third solution of the
equation obtained by substituting the line `Y = ℓ(X - x₁) + y₁` into the Weierstrass equation,
and can be written down explicitly as `x := ℓ² + a₁ℓ - a₂ - x₁ - x₂` by inspecting the
coefficients of `X²`. The `Y`-coordinate of `P + Q`, after applying the final negation that maps
`Y` to `-Y - a₁X - a₃`, is precisely `y := -(ℓ(x - x₁) + y₁) - a₁x - a₃`.
This file defines polynomials associated to negation and addition of nonsingular affine points,
including slopes of non-vertical lines. The actual group law on nonsingular points in affine
coordinates will be defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean`.
## Main definitions
* `WeierstrassCurve.Affine.negY`: the `Y`-coordinate of `-P`.
* `WeierstrassCurve.Affine.addX`: the `X`-coordinate of `P + Q`.
* `WeierstrassCurve.Affine.negAddY`: the `Y`-coordinate of `-(P + Q)`.
* `WeierstrassCurve.Affine.addY`: the `Y`-coordinate of `P + Q`.
## Main statements
* `WeierstrassCurve.Affine.equation_neg`: negation preserves the Weierstrass equation.
* `WeierstrassCurve.Affine.nonsingular_neg`: negation preserves the nonsingular condition.
* `WeierstrassCurve.Affine.equation_add`: addition preserves the Weierstrass equation.
* `WeierstrassCurve.Affine.nonsingular_add`: addition preserves the nonsingular condition.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, affine, negation, doubling, addition, group law
-/
open Polynomial
open scoped Polynomial.Bivariate
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
local macro "derivative_simp" : tactic =>
`(tactic| simp only [derivative_C, derivative_X, derivative_X_pow, derivative_neg, derivative_add,
derivative_sub, derivative_mul, derivative_sq])
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_neg, eval_add, eval_sub, eval_mul, eval_pow, evalEval])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow, map_div₀,
Polynomial.map_ofNat, map_C, map_X, Polynomial.map_neg, Polynomial.map_add, Polynomial.map_sub,
Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_div, coe_mapRingHom,
WeierstrassCurve.map])
universe r s u v w
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} [CommRing R] [CommRing S]
[CommRing A] [CommRing B] [Field F] [Field K] {W' : Affine R} {W : Affine F}
namespace Affine
/-! ## Negation formulae in affine coordinates -/
variable (W') in
/-- The negation polynomial `-Y - a₁X - a₃` associated to the negation of a nonsingular affine point
on a Weierstrass curve. -/
noncomputable def negPolynomial : R[X][Y] :=
-(Y : R[X][Y]) - C (C W'.a₁ * X + C W'.a₃)
lemma Y_sub_polynomialY : Y - W'.polynomialY = W'.negPolynomial := by
rw [polynomialY, negPolynomial]
C_simp
ring1
lemma Y_sub_negPolynomial : Y - W'.negPolynomial = W'.polynomialY := by
rw [← Y_sub_polynomialY, sub_sub_cancel]
variable (W') in
/-- The `Y`-coordinate of `-(x, y)` for a nonsingular affine point `(x, y)` on a Weierstrass curve
`W`.
This depends on `W`, and has argument order: `x`, `y`. -/
@[simp]
def negY (x y : R) : R :=
-y - W'.a₁ * x - W'.a₃
lemma negY_negY (x y : R) : W'.negY x (W'.negY x y) = y := by
simp only [negY]
ring1
lemma evalEval_negPolynomial (x y : R) : W'.negPolynomial.evalEval x y = W'.negY x y := by
rw [negY, sub_sub, negPolynomial]
eval_simp
lemma Y_eq_of_X_eq {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hx : x₁ = x₂) : y₁ = y₂ ∨ y₁ = W.negY x₂ y₂ := by
rw [equation_iff] at h₁ h₂
rw [← sub_eq_zero, ← sub_eq_zero (a := y₁), ← mul_eq_zero, negY]
linear_combination (norm := (rw [hx]; ring1)) h₁ - h₂
lemma Y_eq_of_Y_ne {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂) (hx : x₁ = x₂)
(hy : y₁ ≠ W.negY x₂ y₂) : y₁ = y₂ :=
(Y_eq_of_X_eq h₁ h₂ hx).resolve_right hy
lemma equation_neg (x y : R) : W'.Equation x (W'.negY x y) ↔ W'.Equation x y := by
rw [equation_iff, equation_iff, negY]
congr! 1
ring1
lemma nonsingular_neg (x y : R) : W'.Nonsingular x (W'.negY x y) ↔ W'.Nonsingular x y := by
rw [nonsingular_iff, equation_neg, ← negY, negY_negY, ← @ne_comm _ y, nonsingular_iff]
exact and_congr_right' <| (iff_congr not_and_or.symm not_and_or.symm).mpr <|
not_congr <| and_congr_left fun h => by rw [← h]
/-! ## Slope formulae in affine coordinates -/
variable (W') in
/-- The line polynomial `ℓ(X - x) + y` associated to the line `Y = ℓ(X - x) + y` that passes through
a nonsingular affine point `(x, y)` on a Weierstrass curve `W` with a slope of `ℓ`.
This does not depend on `W`, and has argument order: `x`, `y`, `ℓ`. -/
noncomputable def linePolynomial (x y ℓ : R) : R[X] :=
C ℓ * (X - C x) + C y
section slope
variable [DecidableEq F]
variable (W) in
/-- The slope of the line through two nonsingular affine points `(x₁, y₁)` and `(x₂, y₂)` on a
Weierstrass curve `W`.
If `x₁ ≠ x₂`, then this line is the secant of `W` through `(x₁, y₁)` and `(x₂, y₂)`, and has slope
`(y₁ - y₂) / (x₁ - x₂)`. Otherwise, if `y₁ ≠ -y₁ - a₁x₁ - a₃`, then this line is the tangent of `W`
at `(x₁, y₁) = (x₂, y₂)`, and has slope `(3x₁² + 2a₂x₁ + a₄ - a₁y₁) / (2y₁ + a₁x₁ + a₃)`. Otherwise,
this line is vertical, in which case this returns the value `0`.
This depends on `W`, and has argument order: `x₁`, `x₂`, `y₁`, `y₂`. -/
def slope (x₁ x₂ y₁ y₂ : F) : F :=
if x₁ = x₂ then if y₁ = W.negY x₂ y₂ then 0
else (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - W.negY x₁ y₁)
else (y₁ - y₂) / (x₁ - x₂)
@[simp]
lemma slope_of_Y_eq {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ = W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ = 0 := by
rw [slope, if_pos hx, if_pos hy]
@[simp]
lemma slope_of_Y_ne' {x₂ y₁ y₂ : F} (hy : ¬y₁ = -y₂ - W.a₁ * x₂ - W.a₃) :
W.slope x₂ x₂ y₁ y₂ =
(3 * x₂ ^ 2 + 2 * W.a₂ * x₂ + W.a₄ - W.a₁ * y₁) / (y₁ - (-y₁ - W.a₁ * x₂ - W.a₃)) := by
simp [slope, hy]
lemma slope_of_Y_ne {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ ≠ W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ =
(3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - W.negY x₁ y₁) := by
simp_all
@[simp]
lemma slope_of_X_ne {x₁ x₂ y₁ y₂ : F} (hx : x₁ ≠ x₂) :
W.slope x₁ x₂ y₁ y₂ = (y₁ - y₂) / (x₁ - x₂) := by
rw [slope, if_neg hx]
lemma slope_of_Y_ne_eq_evalEval {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ ≠ W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ = -W.polynomialX.evalEval x₁ y₁ / W.polynomialY.evalEval x₁ y₁ := by
rw [slope_of_Y_ne hx hy, evalEval_polynomialX, neg_sub]
congr 1
rw [negY, evalEval_polynomialY]
ring1
end slope
/-! ## Addition formulae in affine coordinates -/
variable (W') in
/-- The addition polynomial obtained by substituting the line `Y = ℓ(X - x) + y` into the polynomial
`W(X, Y)` associated to a Weierstrass curve `W`. If such a line intersects `W` at another
nonsingular affine point `(x', y')` on `W`, then the roots of this polynomial are precisely `x`,
`x'`, and the `X`-coordinate of the addition of `(x, y)` and `(x', y')`.
This depends on `W`, and has argument order: `x`, `y`, `ℓ`. -/
noncomputable def addPolynomial (x y ℓ : R) : R[X] :=
W'.polynomial.eval <| linePolynomial x y ℓ
lemma C_addPolynomial (x y ℓ : R) : C (W'.addPolynomial x y ℓ) =
(Y - C (linePolynomial x y ℓ)) * (W'.negPolynomial - C (linePolynomial x y ℓ)) +
W'.polynomial := by
rw [addPolynomial, linePolynomial, polynomial, negPolynomial]
eval_simp
C_simp
ring1
lemma addPolynomial_eq (x y ℓ : R) : W'.addPolynomial x y ℓ = -Cubic.toPoly
⟨1, -ℓ ^ 2 - W'.a₁ * ℓ + W'.a₂,
2 * x * ℓ ^ 2 + (W'.a₁ * x - 2 * y - W'.a₃) * ℓ + (-W'.a₁ * y + W'.a₄),
-x ^ 2 * ℓ ^ 2 + (2 * x * y + W'.a₃ * x) * ℓ - (y ^ 2 + W'.a₃ * y - W'.a₆)⟩ := by
rw [addPolynomial, linePolynomial, polynomial, Cubic.toPoly]
eval_simp
C_simp
ring1
variable (W') in
/-- The `X`-coordinate of `(x₁, y₁) + (x₂, y₂)` for two nonsingular affine points `(x₁, y₁)` and
`(x₂, y₂)` on a Weierstrass curve `W`, where the line through them has a slope of `ℓ`.
This depends on `W`, and has argument order: `x₁`, `x₂`, `ℓ`. -/
@[simp]
def addX (x₁ x₂ ℓ : R) : R :=
ℓ ^ 2 + W'.a₁ * ℓ - W'.a₂ - x₁ - x₂
variable (W') in
/-- The `Y`-coordinate of `-((x₁, y₁) + (x₂, y₂))` for two nonsingular affine points `(x₁, y₁)` and
`(x₂, y₂)` on a Weierstrass curve `W`, where the line through them has a slope of `ℓ`.
This depends on `W`, and has argument order: `x₁`, `x₂`, `y₁`, `ℓ`. -/
@[simp]
def negAddY (x₁ x₂ y₁ ℓ : R) : R :=
ℓ * (W'.addX x₁ x₂ ℓ - x₁) + y₁
variable (W') in
/-- The `Y`-coordinate of `(x₁, y₁) + (x₂, y₂)` for two nonsingular affine points `(x₁, y₁)` and
`(x₂, y₂)` on a Weierstrass curve `W`, where the line through them has a slope of `ℓ`.
This depends on `W`, and has argument order: `x₁`, `x₂`, `y₁`, `ℓ`. -/
@[simp]
def addY (x₁ x₂ y₁ ℓ : R) : R :=
W'.negY (W'.addX x₁ x₂ ℓ) (W'.negAddY x₁ x₂ y₁ ℓ)
section slope
variable [DecidableEq F]
lemma addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) : W.addPolynomial x₁ y₁ (W.slope x₁ x₂ y₁ y₂) =
-((X - C x₁) * (X - C x₂) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂))) := by
rw [addPolynomial_eq, neg_inj, Cubic.prod_X_sub_C_eq, Cubic.toPoly_injective]
by_cases hx : x₁ = x₂
· have hy : y₁ ≠ W.negY x₂ y₂ := fun h => hxy ⟨hx, h⟩
rcases hx, Y_eq_of_Y_ne h₁ h₂ hx hy with ⟨rfl, rfl⟩
rw [equation_iff] at h₁ h₂
rw [slope_of_Y_ne rfl hy]
rw [negY, ← sub_ne_zero] at hy
replace hy : y₁ - (-y₁ - x₁ * W.a₁ - W.a₃) ≠ 0 := by convert hy using 1; ring
ext
· rfl
· simp only [addX]
ring1
· simp [field]
ring1
· linear_combination (norm := (simp [field]; ring1)) -h₁
· rw [equation_iff] at h₁ h₂
rw [slope_of_X_ne hx]
rw [← sub_eq_zero] at hx
ext
· rfl
· simp only [addX]
ring1
· apply mul_right_injective₀ hx
linear_combination (norm := (simp [field]; ring1)) h₂ - h₁
· apply mul_right_injective₀ hx
linear_combination (norm := (simp [field]; ring1)) x₂ * h₁ - x₁ * h₂
lemma C_addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) : C (W.addPolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) =
-(C (X - C x₁) * C (X - C x₂) * C (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂))) := by
rw [addPolynomial_slope h₁ h₂ hxy]
simp
lemma derivative_addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁)
(h₂ : W.Equation x₂ y₂) (hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
derivative (W.addPolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) =
-((X - C x₁) * (X - C x₂) + (X - C x₁) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)) +
(X - C x₂) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂))) := by
rw [addPolynomial_slope h₁ h₂ hxy]
derivative_simp
ring1
lemma nonsingular_negAdd_of_eval_derivative_ne_zero {x₁ x₂ y₁ ℓ : R}
(hx' : W'.Equation (W'.addX x₁ x₂ ℓ) (W'.negAddY x₁ x₂ y₁ ℓ))
(hx : (W'.addPolynomial x₁ y₁ ℓ).derivative.eval (W'.addX x₁ x₂ ℓ) ≠ 0) :
W'.Nonsingular (W'.addX x₁ x₂ ℓ) (W'.negAddY x₁ x₂ y₁ ℓ) := by
rw [Nonsingular, and_iff_right hx', negAddY, polynomialX, polynomialY]
eval_simp
contrapose! hx
rw [addPolynomial, linePolynomial, polynomial]
eval_simp
derivative_simp
simp only [zero_add, add_zero, sub_zero, zero_mul, mul_one]
eval_simp
linear_combination (norm := (norm_num1; ring1)) hx.left + ℓ * hx.right
lemma equation_add_iff (x₁ x₂ y₁ ℓ : R) : W'.Equation (W'.addX x₁ x₂ ℓ) (W'.negAddY x₁ x₂ y₁ ℓ) ↔
(W'.addPolynomial x₁ y₁ ℓ).eval (W'.addX x₁ x₂ ℓ) = 0 := by
rw [Equation, negAddY, addPolynomial, linePolynomial, polynomial]
eval_simp
lemma equation_negAdd {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) : W.Equation
(W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.negAddY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
rw [equation_add_iff, addPolynomial_slope h₁ h₂ hxy]
eval_simp
rw [neg_eq_zero, sub_self, mul_zero]
lemma equation_add {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
W.Equation (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) :=
(equation_neg ..).mpr <| equation_negAdd h₁ h₂ hxy
lemma nonsingular_negAdd {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁) (h₂ : W.Nonsingular x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) : W.Nonsingular
(W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.negAddY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
by_cases hx₁ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₁
· rwa [negAddY, hx₁, sub_self, mul_zero, zero_add]
· by_cases hx₂ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₂
· by_cases hx : x₁ = x₂
· subst hx
contradiction
· rwa [negAddY, ← neg_sub, mul_neg, hx₂, slope_of_X_ne hx,
div_mul_cancel₀ _ <| sub_ne_zero_of_ne hx, neg_sub, sub_add_cancel]
· apply nonsingular_negAdd_of_eval_derivative_ne_zero <| equation_negAdd h₁.left h₂.left hxy
rw [derivative_addPolynomial_slope h₁.left h₂.left hxy]
eval_simp
simp only [neg_ne_zero, sub_self, mul_zero, add_zero]
exact mul_ne_zero (sub_ne_zero_of_ne hx₁) (sub_ne_zero_of_ne hx₂)
lemma nonsingular_add {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁) (h₂ : W.Nonsingular x₂ y₂)
(hxy : ¬(x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)) :
W.Nonsingular (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) :=
(nonsingular_neg ..).mpr <| nonsingular_negAdd h₁ h₂ hxy
/-- The formula `x(P₁ + P₂) = x(P₁ - P₂) - ψ(P₁)ψ(P₂) / (x(P₂) - x(P₁))²`,
where `ψ(x,y) = 2y + a₁x + a₃`. -/
lemma addX_eq_addX_negY_sub {x₁ x₂ : F} (y₁ y₂ : F) (hx : x₁ ≠ x₂) :
W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = W.addX x₁ x₂ (W.slope x₁ x₂ y₁ <| W.negY x₂ y₂) -
(y₁ - W.negY x₁ y₁) * (y₂ - W.negY x₂ y₂) / (x₂ - x₁) ^ 2 := by
simp_rw [slope_of_X_ne hx, addX, negY, ← neg_sub x₁, neg_sq]
simp [field]
ring1
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- The formula `y(P₁)(x(P₂) - x(P₃)) + y(P₂)(x(P₃) - x(P₁)) + y(P₃)(x(P₁) - x(P₂)) = 0`,
assuming that `P₁ + P₂ + P₃ = O`. -/
lemma cyclic_sum_Y_mul_X_sub_X {x₁ x₂ : F} (y₁ y₂ : F) (hx : x₁ ≠ x₂) :
let x₃ := W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)
y₁ * (x₂ - x₃) + y₂ * (x₃ - x₁) + W.negAddY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂) * (x₁ - x₂) = 0 := by
simp_rw [slope_of_X_ne hx, negAddY, addX]
simp [field, sub_ne_zero.mpr hx]
ring1
/-- The formula `ψ(P₁ + P₂) = (ψ(P₂)(x(P₁) - x(P₃)) - ψ(P₁)(x(P₂) - x(P₃))) / (x(P₂) - x(P₁))`,
where `ψ(x,y) = 2y + a₁x + a₃`. -/
lemma addY_sub_negY_addY {x₁ x₂ : F} (y₁ y₂ : F) (hx : x₁ ≠ x₂) :
let x₃ := W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)
let y₃ := W.addY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂)
y₃ - W.negY x₃ y₃ =
((y₂ - W.negY x₂ y₂) * (x₁ - x₃) - (y₁ - W.negY x₁ y₁) * (x₂ - x₃)) / (x₂ - x₁) := by
simp_rw [addY, negY, eq_div_iff (sub_ne_zero.mpr hx.symm)]
linear_combination (norm := ring1) 2 * cyclic_sum_Y_mul_X_sub_X y₁ y₂ hx
end slope
/-! ## Maps and base changes -/
variable (f : R →+* S) (x y x₁ y₁ x₂ y₂ ℓ : R)
lemma map_negPolynomial :
(W'.map f).toAffine.negPolynomial = W'.negPolynomial.map (mapRingHom f) := by
simp only [negPolynomial]
map_simp
lemma map_negY : (W'.map f).toAffine.negY (f x) (f y) = f (W'.negY x y) := by
simp only [negY]
map_simp
lemma map_linePolynomial : linePolynomial (f x) (f y) (f ℓ) = (linePolynomial x y ℓ).map f := by
simp only [linePolynomial]
map_simp
lemma map_addPolynomial :
(W'.map f).toAffine.addPolynomial (f x) (f y) (f ℓ) = (W'.addPolynomial x y ℓ).map f := by
rw [addPolynomial, map_polynomial, eval_map, linePolynomial, addPolynomial, ← coe_mapRingHom,
← eval₂_hom, linePolynomial]
simp
lemma map_addX : (W'.map f).toAffine.addX (f x₁) (f x₂) (f ℓ) = f (W'.addX x₁ x₂ ℓ) := by
simp only [addX]
map_simp
lemma map_negAddY :
(W'.map f).toAffine.negAddY (f x₁) (f x₂) (f y₁) (f ℓ) = f (W'.negAddY x₁ x₂ y₁ ℓ) := by
simp only [negAddY, map_addX]
map_simp
lemma map_addY :
(W'.map f).toAffine.addY (f x₁) (f x₂) (f y₁) (f ℓ) = f (W'.toAffine.addY x₁ x₂ y₁ ℓ) := by
simp only [addY, map_negAddY, map_addX, map_negY]
lemma map_slope [DecidableEq F] [DecidableEq K] (f : F →+* K) (x₁ x₂ y₁ y₂ : F) :
(W.map f).toAffine.slope (f x₁) (f x₂) (f y₁) (f y₂) = f (W.slope x₁ x₂ y₁ y₂) := by
by_cases hx : x₁ = x₂
· by_cases hy : y₁ = W.negY x₂ y₂
· rw [slope_of_Y_eq (congr_arg f hx) <| by rw [hy, map_negY], slope_of_Y_eq hx hy, map_zero]
· rw [slope_of_Y_ne (congr_arg f hx) <| map_negY f x₂ y₂ ▸ fun h => hy <| f.injective h,
map_negY, slope_of_Y_ne hx hy]
map_simp
· rw [slope_of_X_ne fun h => hx <| f.injective h, slope_of_X_ne hx]
map_simp
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (x y x₁ y₁ x₂ y₂ ℓ : A)
lemma baseChange_negPolynomial : (W'.baseChange B).toAffine.negPolynomial =
(W'.baseChange A).toAffine.negPolynomial.map (mapRingHom f) := by
rw [← map_negPolynomial, map_baseChange]
lemma baseChange_negY :
(W'.baseChange B).toAffine.negY (f x) (f y) = f ((W'.baseChange A).toAffine.negY x y) := by
rw [← RingHom.coe_coe, ← map_negY, map_baseChange]
lemma baseChange_addPolynomial : (W'.baseChange B).toAffine.addPolynomial (f x) (f y) (f ℓ) =
((W'.baseChange A).toAffine.addPolynomial x y ℓ).map f := by
rw [← RingHom.coe_coe, ← map_addPolynomial, map_baseChange]
lemma baseChange_addX : (W'.baseChange B).toAffine.addX (f x₁) (f x₂) (f ℓ) =
f ((W'.baseChange A).toAffine.addX x₁ x₂ ℓ) := by
rw [← RingHom.coe_coe, ← map_addX, map_baseChange]
lemma baseChange_negAddY : (W'.baseChange B).toAffine.negAddY (f x₁) (f x₂) (f y₁) (f ℓ) =
f ((W'.baseChange A).toAffine.negAddY x₁ x₂ y₁ ℓ) := by
rw [← RingHom.coe_coe, ← map_negAddY, map_baseChange]
lemma baseChange_addY : (W'.baseChange B).toAffine.addY (f x₁) (f x₂) (f y₁) (f ℓ) =
f ((W'.baseChange A).toAffine.addY x₁ x₂ y₁ ℓ) := by
rw [← RingHom.coe_coe, ← map_addY, map_baseChange]
lemma baseChange_slope [DecidableEq F] [DecidableEq K]
[Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebra R K] [Algebra S K]
[IsScalarTower R S K] (f : F →ₐ[S] K) (x₁ x₂ y₁ y₂ : F) :
(W'.baseChange K).toAffine.slope (f x₁) (f x₂) (f y₁) (f y₂) =
f ((W'.baseChange F).toAffine.slope x₁ x₂ y₁ y₂) := by
rw [← RingHom.coe_coe, ← map_slope, map_baseChange]
end Affine
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Point
import Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Formula
/-!
# Nonsingular points and the group law in projective coordinates
Let `W` be a Weierstrass curve over a field `F`. The nonsingular projective points of `W` can be
endowed with a group law, which is uniquely determined by the formulae in
`Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Formula.lean` and follows from an equivalence
with the nonsingular points `W⟮F⟯` in affine coordinates.
This file defines the group law on nonsingular projective points.
## Main definitions
* `WeierstrassCurve.Projective.neg`: the negation of a point representative.
* `WeierstrassCurve.Projective.negMap`: the negation of a point class.
* `WeierstrassCurve.Projective.add`: the addition of two point representatives.
* `WeierstrassCurve.Projective.addMap`: the addition of two point classes.
* `WeierstrassCurve.Projective.Point`: a nonsingular projective point.
* `WeierstrassCurve.Projective.Point.neg`: the negation of a nonsingular projective point.
* `WeierstrassCurve.Projective.Point.add`: the addition of two nonsingular projective points.
* `WeierstrassCurve.Projective.Point.toAffineAddEquiv`: the equivalence between the type of
nonsingular projective points with the type of nonsingular points `W⟮F⟯` in affine coordinates.
## Main statements
* `WeierstrassCurve.Projective.nonsingular_neg`: negation preserves the nonsingular condition.
* `WeierstrassCurve.Projective.nonsingular_add`: addition preserves the nonsingular condition.
* `WeierstrassCurve.Projective.Point.instAddCommGroup`: the type of nonsingular projective points
forms an abelian group under addition.
## Implementation notes
Note that `W(X, Y, Z)` and its partial derivatives are independent of the point representative, and
the nonsingularity condition already implies `(x, y, z) ≠ (0, 0, 0)`, so a nonsingular projective
point on `W` can be given by `[x : y : z]` and the nonsingular condition on any representative.
A nonsingular projective point representative can be converted to a nonsingular point in affine
coordinates using `WeierstrassCurve.Projective.Point.toAffine`, which lifts to a map on nonsingular
projective points using `WeierstrassCurve.Projective.Point.toAffineLift`. Conversely, a nonsingular
point in affine coordinates can be converted to a nonsingular projective point using
`WeierstrassCurve.Projective.Point.fromAffine` or `WeierstrassCurve.Affine.Point.toProjective`.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, projective, point, group law
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} [CommRing R] [CommRing S]
[CommRing A] [CommRing B] [Field F] [Field K] {W' : Projective R} {W : Projective F}
namespace Projective
/-! ## Negation on projective point representatives -/
variable (W') in
/-- The negation of a projective point representative on a Weierstrass curve. -/
def neg (P : Fin 3 → R) : Fin 3 → R :=
![P x, W'.negY P, P z]
lemma neg_X (P : Fin 3 → R) : W'.neg P x = P x :=
rfl
lemma neg_Y (P : Fin 3 → R) : W'.neg P y = W'.negY P :=
rfl
lemma neg_Z (P : Fin 3 → R) : W'.neg P z = P z :=
rfl
protected lemma neg_smul (P : Fin 3 → R) (u : R) : W'.neg (u • P) = u • W'.neg P := by
simpa only [neg, negY_smul] using (smul_fin3 (W'.neg P) u).symm
lemma neg_smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.neg (u • P) ≈ W'.neg P :=
⟨hu.unit, (W'.neg_smul ..).symm⟩
lemma neg_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.neg P ≈ W'.neg Q := by
rcases h with ⟨u, rfl⟩
exact neg_smul_equiv Q u.isUnit
lemma neg_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.neg P = -P y • ![0, 1, 0] := by
erw [neg, X_eq_zero_of_Z_eq_zero hP hPz, negY_of_Z_eq_zero hP hPz, hPz, smul_fin3, mul_zero,
mul_one]
lemma neg_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.neg P = P z • ![P x / P z, W.toAffine.negY (P x / P z) (P y / P z), 1] := by
erw [neg, smul_fin3, mul_div_cancel₀ _ hPz, ← negY_of_Z_ne_zero hPz, mul_div_cancel₀ _ hPz,
mul_one]
private lemma nonsingular_neg_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
W.Nonsingular ![P x / P z, W.toAffine.negY (P x / P z) (P y / P z), 1] :=
(nonsingular_some ..).mpr <| (Affine.nonsingular_neg ..).mpr <|
(nonsingular_of_Z_ne_zero hPz).mp hP
lemma nonsingular_neg {P : Fin 3 → F} (hP : W.Nonsingular P) : W.Nonsingular <| W.neg P := by
by_cases hPz : P z = 0
· simp only [neg_of_Z_eq_zero hP.left hPz, nonsingular_smul _ (isUnit_Y_of_Z_eq_zero hP hPz).neg,
nonsingular_zero]
· simp only [neg_of_Z_ne_zero hPz, nonsingular_smul _ <| Ne.isUnit hPz,
nonsingular_neg_of_Z_ne_zero hP hPz]
lemma addZ_neg (P : Fin 3 → R) : W'.addZ P (W'.neg P) = 0 := by
rw [addZ, neg_X, neg_Y, neg_Z, negY]
ring1
lemma addX_neg (P : Fin 3 → R) : W'.addX P (W'.neg P) = 0 := by
rw [addX, neg_X, neg_Y, neg_Z, negY]
ring1
lemma negAddY_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.negAddY P (W'.neg P) = W'.dblZ P := by
linear_combination (norm := (rw [negAddY, neg_X, neg_Y, neg_Z, dblZ, negY]; ring1))
-3 * (P y - W'.negY P) * (equation_iff _).mp hP
lemma addY_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.addY P (W'.neg P) = -W'.dblZ P := by
simp only [addY, addX_neg, negAddY_neg hP, addZ_neg, negY, fin3_def_ext, mul_zero, sub_zero]
lemma addXYZ_neg {P : Fin 3 → R} (hP : W'.Equation P) :
W'.addXYZ P (W'.neg P) = -W'.dblZ P • ![0, 1, 0] := by
erw [addXYZ, addX_neg, addY_neg hP, addZ_neg, smul_fin3, mul_zero, mul_one]
variable (W') in
/-- The negation of a projective point class on a Weierstrass curve `W`.
If `P` is a projective point representative on `W`, then `W.negMap ⟦P⟧` is definitionally equivalent
to `W.neg P`. -/
def negMap (P : PointClass R) : PointClass R :=
P.map W'.neg fun _ _ => neg_equiv
lemma negMap_eq (P : Fin 3 → R) : W'.negMap ⟦P⟧ = ⟦W'.neg P⟧ :=
rfl
lemma negMap_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
W.negMap ⟦P⟧ = ⟦![0, 1, 0]⟧ := by
rw [negMap_eq, neg_of_Z_eq_zero hP.left hPz, smul_eq _ (isUnit_Y_of_Z_eq_zero hP hPz).neg]
lemma negMap_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negMap ⟦P⟧ = ⟦![P x / P z, W.toAffine.negY (P x / P z) (P y / P z), 1]⟧ := by
rw [negMap_eq, neg_of_Z_ne_zero hPz, smul_eq _ <| Ne.isUnit hPz]
lemma nonsingularLift_negMap {P : PointClass F} (hP : W.NonsingularLift P) :
W.NonsingularLift <| W.negMap P := by
rcases P with ⟨_⟩
exact nonsingular_neg hP
/-! ## Addition on projective point representatives -/
open scoped Classical in
variable (W') in
/-- The addition of two projective point representatives on a Weierstrass curve. -/
noncomputable def add (P Q : Fin 3 → R) : Fin 3 → R :=
if P ≈ Q then W'.dblXYZ P else W'.addXYZ P Q
lemma add_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.add P Q = W'.dblXYZ P :=
if_pos h
lemma add_smul_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) = u ^ 4 • W'.add P Q := by
rw [add_of_equiv <| (smul_equiv_smul P Q hu hv).mpr h, dblXYZ_smul, add_of_equiv h]
lemma add_self (P : Fin 3 → R) : W'.add P P = W'.dblXYZ P :=
add_of_equiv <| Setoid.refl _
lemma add_of_eq {P Q : Fin 3 → R} (h : P = Q) : W'.add P Q = W'.dblXYZ P :=
h ▸ add_self P
lemma add_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) : W'.add P Q = W'.addXYZ P Q :=
if_neg h
lemma add_smul_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) {u v : R} (hu : IsUnit u)
(hv : IsUnit v) : W'.add (u • P) (v • Q) = (u * v) ^ 2 • W'.add P Q := by
rw [add_of_not_equiv <| h.comp (smul_equiv_smul P Q hu hv).mp, addXYZ_smul, add_of_not_equiv h]
lemma add_smul_equiv (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) ≈ W'.add P Q := by
by_cases h : P ≈ Q
· exact ⟨hu.unit ^ 4, by convert (add_smul_of_equiv h hu hv).symm⟩
· exact ⟨(hu.unit * hv.unit) ^ 2, by convert (add_smul_of_not_equiv h hu hv).symm⟩
lemma add_equiv {P P' Q Q' : Fin 3 → R} (hP : P ≈ P') (hQ : Q ≈ Q') :
W'.add P Q ≈ W'.add P' Q' := by
rcases hP, hQ with ⟨⟨u, rfl⟩, ⟨v, rfl⟩⟩
exact add_smul_equiv P' Q' u.isUnit v.isUnit
lemma add_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : W.add P Q = P y ^ 4 • ![0, 1, 0] := by
rw [add_of_equiv <| equiv_of_Z_eq_zero hP hQ hPz hQz, dblXYZ_of_Z_eq_zero hP.left hPz]
lemma add_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) (hQz : Q z ≠ 0) : W'.add P Q = (P y ^ 2 * Q z) • Q := by
rw [add_of_not_equiv <| not_equiv_of_Z_eq_zero_left hPz hQz, addXYZ_of_Z_eq_zero_left hP hPz]
lemma add_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z = 0) : W'.add P Q = -(Q y ^ 2 * P z) • P := by
rw [add_of_not_equiv <| not_equiv_of_Z_eq_zero_right hPz hQz, addXYZ_of_Z_eq_zero_right hQ hQz]
lemma add_of_Y_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.add P Q = W.dblU P • ![0, 1, 0] := by
rw [add_of_equiv <| equiv_of_X_eq_of_Y_eq hPz hQz hx hy, dblXYZ_of_Y_eq hP hPz hQz hx hy hy']
lemma add_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ Q y * P z) :
W.add P Q = addU P Q • ![0, 1, 0] := by
rw [add_of_not_equiv <| not_equiv_of_Y_ne hy, addXYZ_of_X_eq hP hQ hPz hQz hx]
lemma add_of_Y_ne' [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.add P Q = W.dblZ P •
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1] := by
rw [add_of_equiv <| equiv_of_X_eq_of_Y_eq hPz hQz hx <| Y_eq_of_Y_ne' hP hQ hPz hQz hx hy,
dblXYZ_of_Z_ne_zero hP hQ hPz hQz hx hy]
lemma add_of_X_ne [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ≠ Q x * P z) : W.add P Q = W.addZ P Q •
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1] := by
rw [add_of_not_equiv <| not_equiv_of_X_ne hx, addXYZ_of_Z_ne_zero hP hQ hPz hQz hx]
private lemma nonsingular_add_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Nonsingular P) (hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : ¬(P x * Q z = Q x * P z ∧ P y * Q z = W.negY Q * P z)) : W.Nonsingular
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1] :=
(nonsingular_some ..).mpr <| Affine.nonsingular_add ((nonsingular_of_Z_ne_zero hPz).mp hP)
((nonsingular_of_Z_ne_zero hQz).mp hQ) <| by rwa [← X_eq_iff hPz hQz, ← Y_eq_iff' hPz hQz]
lemma nonsingular_add {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
W.Nonsingular <| W.add P Q := by
by_cases hPz : P z = 0
· by_cases hQz : Q z = 0
· simp only [add_of_Z_eq_zero hP hQ hPz hQz,
nonsingular_smul _ <| (isUnit_Y_of_Z_eq_zero hP hPz).pow 4, nonsingular_zero]
· simpa only [add_of_Z_eq_zero_left hP.left hPz hQz,
nonsingular_smul _ <| ((isUnit_Y_of_Z_eq_zero hP hPz).pow 2).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· simpa only [add_of_Z_eq_zero_right hQ.left hPz hQz,
nonsingular_smul _ (((isUnit_Y_of_Z_eq_zero hQ hQz).pow 2).mul <| Ne.isUnit hPz).neg]
· by_cases hxy : P x * Q z = Q x * P z ∧ P y * Q z = W.negY Q * P z
· by_cases hy : P y * Q z = Q y * P z
· simp only [add_of_Y_eq hP.left hPz hQz hxy.left hy hxy.right, nonsingular_smul _ <|
isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, nonsingular_zero]
· simp only [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
nonsingular_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, nonsingular_zero]
· classical
have := nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy
by_cases hx : P x * Q z = Q x * P z
· simpa only [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| not_and.mp hxy hx,
nonsingular_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hQz hx <|
not_and.mp hxy hx]
· simpa only [add_of_X_ne hP.left hQ.left hPz hQz hx,
nonsingular_smul _ <| isUnit_addZ_of_X_ne hP.left hQ.left hx]
variable (W') in
/-- The addition of two projective point classes on a Weierstrass curve `W`.
If `P` and `Q` are two projective point representatives on `W`, then `W.addMap ⟦P⟧ ⟦Q⟧` is
definitionally equivalent to `W.add P Q`. -/
noncomputable def addMap (P Q : PointClass R) : PointClass R :=
Quotient.map₂ W'.add (fun _ _ hP _ _ hQ => add_equiv hP hQ) P Q
lemma addMap_eq (P Q : Fin 3 → R) : W'.addMap ⟦P⟧ ⟦Q⟧ = ⟦W'.add P Q⟧ :=
rfl
lemma addMap_of_Z_eq_zero_left {P : Fin 3 → F} {Q : PointClass F} (hP : W.Nonsingular P)
(hQ : W.NonsingularLift Q) (hPz : P z = 0) : W.addMap ⟦P⟧ Q = Q := by
revert hQ
refine Q.inductionOn (motive := fun Q => _ → W.addMap _ Q = Q) fun Q hQ => ?_
by_cases hQz : Q z = 0
· rw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_Y_of_Z_eq_zero hP hPz).pow 4, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hQ hQz
· rw [addMap_eq, add_of_Z_eq_zero_left hP.left hPz hQz,
smul_eq _ <| ((isUnit_Y_of_Z_eq_zero hP hPz).pow 2).mul <| Ne.isUnit hQz]
lemma addMap_of_Z_eq_zero_right {P : PointClass F} {Q : Fin 3 → F} (hP : W.NonsingularLift P)
(hQ : W.Nonsingular Q) (hQz : Q z = 0) : W.addMap P ⟦Q⟧ = P := by
revert hP
refine P.inductionOn (motive := fun P => _ → W.addMap P _ = P) fun P hP => ?_
by_cases hPz : P z = 0
· rw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_Y_of_Z_eq_zero hP hPz).pow 4, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· rw [addMap_eq, add_of_Z_eq_zero_right hQ.left hPz hQz,
smul_eq _ (((isUnit_Y_of_Z_eq_zero hQ hQz).pow 2).mul <| Ne.isUnit hPz).neg]
lemma addMap_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.addMap ⟦P⟧ ⟦Q⟧ = ⟦![0, 1, 0]⟧ := by
by_cases hy : P y * Q z = Q y * P z
· rw [addMap_eq, add_of_Y_eq hP.left hPz hQz hx hy hy',
smul_eq _ <| isUnit_dblU_of_Y_eq hP hPz hQz hx hy hy']
· rw [addMap_eq, add_of_Y_ne hP.left hQ hPz hQz hx hy,
smul_eq _ <| isUnit_addU_of_Y_ne hPz hQz hy]
lemma addMap_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hxy : ¬(P x * Q z = Q x * P z ∧ P y * Q z = W.negY Q * P z)) :
W.addMap ⟦P⟧ ⟦Q⟧ =
⟦![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1]⟧ := by
by_cases hx : P x * Q z = Q x * P z
· rw [addMap_eq, add_of_Y_ne' hP hQ hPz hQz hx <| not_and.mp hxy hx,
smul_eq _ <| isUnit_dblZ_of_Y_ne' hP hQ hPz hQz hx <| not_and.mp hxy hx]
· rw [addMap_eq, add_of_X_ne hP hQ hPz hQz hx, smul_eq _ <| isUnit_addZ_of_X_ne hP hQ hx]
lemma nonsingularLift_addMap {P Q : PointClass F} (hP : W.NonsingularLift P)
(hQ : W.NonsingularLift Q) : W.NonsingularLift <| W.addMap P Q := by
rcases P; rcases Q
exact nonsingular_add hP hQ
/-! ## Nonsingular projective points -/
variable (W') in
/-- A nonsingular projective point on a Weierstrass curve `W`. -/
@[ext]
structure Point where
/-- The projective point class underlying a nonsingular projective point on `W`. -/
{point : PointClass R}
/-- The nonsingular condition underlying a nonsingular projective point on `W`. -/
(nonsingular : W'.NonsingularLift point)
namespace Point
lemma mk_point {P : PointClass R} (h : W'.NonsingularLift P) : (mk h).point = P :=
rfl
instance [Nontrivial R] : Zero W'.Point :=
⟨⟨nonsingularLift_zero⟩⟩
lemma zero_def [Nontrivial R] : (0 : W'.Point) = ⟨nonsingularLift_zero⟩ :=
rfl
lemma zero_point [Nontrivial R] : (0 : W'.Point).point = ⟦![0, 1, 0]⟧ :=
rfl
lemma mk_ne_zero [Nontrivial R] {X Y : R} (h : W'.NonsingularLift ⟦![X, Y, 1]⟧) : mk h ≠ 0 :=
(not_equiv_of_Z_eq_zero_right one_ne_zero rfl).comp <| Quotient.eq.mp.comp Point.ext_iff.mp
/-- The natural map from a nonsingular point on a Weierstrass curve in affine coordinates to its
corresponding nonsingular projective point. -/
def fromAffine [Nontrivial R] : W'.toAffine.Point → W'.Point
| 0 => 0
| .some h => ⟨(nonsingularLift_some ..).mpr h⟩
lemma fromAffine_zero [Nontrivial R] : fromAffine 0 = (0 : W'.Point) :=
rfl
lemma fromAffine_some [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) = ⟨(nonsingularLift_some ..).mpr h⟩ :=
rfl
lemma fromAffine_some_ne_zero [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) ≠ 0 :=
mk_ne_zero <| (nonsingularLift_some ..).mpr h
/-- The negation of a nonsingular projective point on a Weierstrass curve `W`.
Given a nonsingular projective point `P` on `W`, use `-P` instead of `neg P`. -/
def neg (P : W.Point) : W.Point :=
⟨nonsingularLift_negMap P.nonsingular⟩
instance : Neg W.Point :=
⟨neg⟩
lemma neg_def (P : W.Point) : -P = P.neg :=
rfl
lemma neg_point (P : W.Point) : (-P).point = W.negMap P.point :=
rfl
/-- The addition of two nonsingular projective points on a Weierstrass curve `W`.
Given two nonsingular projective points `P` and `Q` on `W`, use `P + Q` instead of `add P Q`. -/
noncomputable def add (P Q : W.Point) : W.Point :=
⟨nonsingularLift_addMap P.nonsingular Q.nonsingular⟩
noncomputable instance : Add W.Point :=
⟨add⟩
lemma add_def (P Q : W.Point) : P + Q = P.add Q :=
rfl
lemma add_point (P Q : W.Point) : (P + Q).point = W.addMap P.point Q.point :=
rfl
/-! ## Equivalence between projective and affine coordinates -/
open scoped Classical in
variable (W) in
/-- The natural map from a nonsingular projective point representative on a Weierstrass curve to its
corresponding nonsingular point in affine coordinates. -/
noncomputable def toAffine (P : Fin 3 → F) : W.toAffine.Point :=
if hP : W.Nonsingular P ∧ P z ≠ 0 then .some <| (nonsingular_of_Z_ne_zero hP.2).mp hP.1 else 0
lemma toAffine_of_singular {P : Fin 3 → F} (hP : ¬W.Nonsingular P) : toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_of_not_left _ hP]
lemma toAffine_of_Z_eq_zero {P : Fin 3 → F} (hPz : P z = 0) : toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_not_right.mpr fun _ => hPz]
lemma toAffine_zero : toAffine W ![0, 1, 0] = 0 :=
toAffine_of_Z_eq_zero rfl
lemma toAffine_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
toAffine W P = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) := by
rw [toAffine, dif_pos ⟨hP, hPz⟩]
lemma toAffine_some {X Y : F} (h : W.Nonsingular ![X, Y, 1]) :
toAffine W ![X, Y, 1] = .some ((nonsingular_some ..).mp h) := by
simp only [toAffine_of_Z_ne_zero h one_ne_zero, fin3_def_ext, div_one]
lemma toAffine_smul (P : Fin 3 → F) {u : F} (hu : IsUnit u) :
toAffine W (u • P) = toAffine W P := by
by_cases hP : W.Nonsingular P
· by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero <| mul_eq_zero_of_right u hPz, toAffine_of_Z_eq_zero hPz]
· rw [toAffine_of_Z_ne_zero ((nonsingular_smul P hu).mpr hP) <| mul_ne_zero hu.ne_zero hPz,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.some.injEq]
simp only [smul_fin3_ext, mul_div_mul_left _ _ hu.ne_zero, and_self]
· rw [toAffine_of_singular <| hP.comp (nonsingular_smul P hu).mp, toAffine_of_singular hP]
lemma toAffine_of_equiv {P Q : Fin 3 → F} (h : P ≈ Q) : toAffine W P = toAffine W Q := by
rcases h with ⟨u, rfl⟩
exact toAffine_smul Q u.isUnit
lemma toAffine_neg {P : Fin 3 → F} (hP : W.Nonsingular P) :
toAffine W (W.neg P) = -toAffine W P := by
by_cases hPz : P z = 0
· rw [neg_of_Z_eq_zero hP.left hPz, toAffine_smul _ (isUnit_Y_of_Z_eq_zero hP hPz).neg,
toAffine_zero, toAffine_of_Z_eq_zero hPz, Affine.Point.neg_zero]
· rw [neg_of_Z_ne_zero hPz, toAffine_smul _ <| Ne.isUnit hPz, toAffine_some <|
(nonsingular_smul _ <| Ne.isUnit hPz).mp <| neg_of_Z_ne_zero hPz ▸ nonsingular_neg hP,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.neg_some]
private lemma toAffine_add_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F}
(hP : W.Nonsingular P) (hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : ¬(P x * Q z = Q x * P z ∧ P y * Q z = W.negY Q * P z)) : toAffine W
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
1] = toAffine W P + toAffine W Q := by
rw [toAffine_some <| nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy, toAffine_of_Z_ne_zero hP hPz,
toAffine_of_Z_ne_zero hQ hQz,
Affine.Point.add_some <| by rwa [← X_eq_iff hPz hQz, ← Y_eq_iff' hPz hQz]]
lemma toAffine_add [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
toAffine W (W.add P Q) = toAffine W P + toAffine W Q := by
by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero hPz, zero_add]
by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero hP hQ hPz hQz, toAffine_smul _ <| (isUnit_Y_of_Z_eq_zero hP hPz).pow 4,
toAffine_zero, toAffine_of_Z_eq_zero hQz]
· rw [add_of_Z_eq_zero_left hP.left hPz hQz,
toAffine_smul _ <| ((isUnit_Y_of_Z_eq_zero hP hPz).pow 2).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero_right hQ.left hPz hQz,
toAffine_smul _ (((isUnit_Y_of_Z_eq_zero hQ hQz).pow 2).mul <| Ne.isUnit hPz).neg,
toAffine_of_Z_eq_zero hQz, add_zero]
· by_cases hxy : P x * Q z = Q x * P z ∧ P y * Q z = W.negY Q * P z
· rw [toAffine_of_Z_ne_zero hP hPz, toAffine_of_Z_ne_zero hQ hQz, Affine.Point.add_of_Y_eq
((X_eq_iff hPz hQz).mp hxy.left) ((Y_eq_iff' hPz hQz).mp hxy.right)]
by_cases hy : P y * Q z = Q y * P z
· rw [add_of_Y_eq hP.left hPz hQz hxy.left hy hxy.right,
toAffine_smul _ <| isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, toAffine_zero]
· rw [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
toAffine_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, toAffine_zero]
· have := toAffine_add_of_Z_ne_zero hP hQ hPz hQz hxy
by_cases hx : P x * Q z = Q x * P z
· rwa [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| not_and.mp hxy hx,
toAffine_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hQz hx <| not_and.mp hxy hx]
· rwa [add_of_X_ne hP.left hQ.left hPz hQz hx,
toAffine_smul _ <| isUnit_addZ_of_X_ne hP.left hQ.left hx]
/-- The natural map from a nonsingular projective point on a Weierstrass curve `W` to its
corresponding nonsingular point in affine coordinates.
If `hP` is the nonsingular condition underlying a nonsingular projective point `P` on `W`, then
`toAffineLift ⟨hP⟩` is definitionally equivalent to `toAffine W P`. -/
noncomputable def toAffineLift (P : W.Point) : W.toAffine.Point :=
P.point.lift _ fun _ _ => toAffine_of_equiv
lemma toAffineLift_eq {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) :
toAffineLift ⟨hP⟩ = toAffine W P :=
rfl
lemma toAffineLift_of_Z_eq_zero {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) (hPz : P z = 0) :
toAffineLift ⟨hP⟩ = 0 :=
toAffine_of_Z_eq_zero hPz
lemma toAffineLift_zero : toAffineLift (0 : W.Point) = 0 :=
toAffine_zero
lemma toAffineLift_of_Z_ne_zero {P : Fin 3 → F} {hP : W.NonsingularLift ⟦P⟧} (hPz : P z ≠ 0) :
toAffineLift ⟨hP⟩ = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) :=
toAffine_of_Z_ne_zero hP hPz
lemma toAffineLift_some {X Y : F} (h : W.NonsingularLift ⟦![X, Y, 1]⟧) :
toAffineLift ⟨h⟩ = .some ((nonsingular_some ..).mp h) :=
toAffine_some h
lemma toAffineLift_neg (P : W.Point) : (-P).toAffineLift = -P.toAffineLift := by
rcases P with @⟨⟨_⟩, hP⟩
exact toAffine_neg hP
lemma toAffineLift_add [DecidableEq F] (P Q : W.Point) :
(P + Q).toAffineLift = P.toAffineLift + Q.toAffineLift := by
rcases P, Q with ⟨@⟨⟨_⟩, hP⟩, @⟨⟨_⟩, hQ⟩⟩
exact toAffine_add hP hQ
variable (W) in
/-- The addition-preserving equivalence between the type of nonsingular projective points on a
Weierstrass curve `W` and the type of nonsingular points `W⟮F⟯` in affine coordinates. -/
@[simps]
noncomputable def toAffineAddEquiv [DecidableEq F] : W.Point ≃+ W.toAffine.Point where
toFun := toAffineLift
invFun := fromAffine
left_inv := by
rintro @⟨⟨P⟩, hP⟩
by_cases hPz : P z = 0
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_eq_zero hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_ne_zero hP hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_some_of_Z_ne_zero hPz
right_inv := by
rintro (_ | _)
· rw [← Affine.Point.zero_def, fromAffine_zero, toAffineLift_zero]
· rw [fromAffine_some, toAffineLift_some]
map_add' := toAffineLift_add
noncomputable instance : AddCommGroup W.Point where
nsmul := nsmulRec
zsmul := zsmulRec
zero_add _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, zero_add]
add_zero _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, add_zero]
neg_add_cancel P := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_neg, neg_add_cancel, toAffineLift_zero]
add_comm _ _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, add_comm]
add_assoc _ _ _ := by
classical
apply (toAffineAddEquiv W).injective
simp only [map_add, add_assoc]
end Point
/-! ## Maps and base changes -/
@[simp]
protected lemma map_neg (f : R →+* S) (P : Fin 3 → R) :
(W'.map f).toProjective.neg (f ∘ P) = f ∘ W'.neg P := by
simp only [neg, map_negY, comp_fin3]
map_simp
@[simp]
protected lemma map_add (f : F →+* K) {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) : (W.map f).toProjective.add (f ∘ P) (f ∘ Q) = f ∘ W.add P Q := by
by_cases h : P ≈ Q
· rw [add_of_equiv <| (comp_equiv_comp f hP hQ).mpr h, add_of_equiv h, map_dblXYZ]
· rw [add_of_not_equiv <| h.comp (comp_equiv_comp f hP hQ).mp, add_of_not_equiv h, map_addXYZ]
lemma baseChange_neg [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B]
[Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B) (P : Fin 3 → A) :
(W'.baseChange B).toProjective.neg (f ∘ P) = f ∘ (W'.baseChange A).toProjective.neg P := by
rw [← RingHom.coe_coe, ← WeierstrassCurve.Projective.map_neg, map_baseChange]
lemma baseChange_add [Algebra R S] [Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebra R K]
[Algebra S K] [IsScalarTower R S K] (f : F →ₐ[S] K) {P Q : Fin 3 → F}
(hP : (W'.baseChange F).toProjective.Nonsingular P)
(hQ : (W'.baseChange F).toProjective.Nonsingular Q) :
(W'.baseChange K).toProjective.add (f ∘ P) (f ∘ Q) =
f ∘ (W'.baseChange F).toProjective.add P Q := by
rw [← RingHom.coe_coe, ← WeierstrassCurve.Projective.map_add _ hP hQ, map_baseChange]
end Projective
/-- An abbreviation for `WeierstrassCurve.Projective.Point.fromAffine` for dot notation. -/
abbrev Affine.Point.toProjective [Nontrivial R] {W : Affine R} (P : W.Point) :
W.toProjective.Point :=
Projective.Point.fromAffine P
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean | import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic
import Mathlib.Data.Fin.Tuple.Reflection
import Mathlib.Tactic.Ring.NamePolyVars
/-!
# Weierstrass equations and the nonsingular condition in projective coordinates
A point on the unweighted projective plane over a commutative ring `R` is an equivalence class
`[x : y : z]` of triples `(x, y, z) ≠ (0, 0, 0)` of elements in `R` such that
`(x, y, z) ∼ (x', y', z')` if there is some unit `u` in `Rˣ` with `(x, y, z) = (ux', uy', uz')`.
Let `W` be a Weierstrass curve over a commutative ring `R` with coefficients `aᵢ`. A
*projective point* is a point on the unweighted projective plane over `R` satisfying the
*homogeneous Weierstrass equation* `W(X, Y, Z) = 0` in *projective coordinates*, where
`W(X, Y, Z) := Y²Z + a₁XYZ + a₃YZ² - (X³ + a₂X²Z + a₄XZ² + a₆Z³)`. It is *nonsingular* if its
partial derivatives `W_X(x, y, z)`, `W_Y(x, y, z)`, and `W_Z(x, y, z)` do not vanish simultaneously.
This file gives an explicit implementation of equivalence classes of triples up to scaling by units,
and defines polynomials associated to Weierstrass equations and the nonsingular condition in
projective coordinates. The group law on the actual type of nonsingular projective points will be
defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean`, based on the formulae
for group operations in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Formula.lean`.
## Main definitions
* `WeierstrassCurve.Projective.PointClass`: the equivalence class of a point representative.
* `WeierstrassCurve.Projective.Nonsingular`: the nonsingular condition on a point representative.
* `WeierstrassCurve.Projective.NonsingularLift`: the nonsingular condition on a point class.
## Main statements
* `WeierstrassCurve.Projective.polynomial_relation`: Euler's homogeneous function theorem.
## Implementation notes
All definitions and lemmas for Weierstrass curves in projective coordinates live in the namespace
`WeierstrassCurve.Projective` to distinguish them from those in other coordinates. This is simply an
abbreviation for `WeierstrassCurve` that can be converted using `WeierstrassCurve.toProjective`.
This can be converted into `WeierstrassCurve.Affine` using `WeierstrassCurve.Projective.toAffine`.
A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector
notation `![x, y, z]`. However, `P` is not definitionally equivalent to the expanded vector
`![P x, P y, P z]`, so the lemmas `fin3_def` and `fin3_def_ext` can be used to convert between the
two forms. The equivalence of two point representatives `P` and `Q` is implemented as an equivalence
of orbits of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that
`P = u • Q`. However, `u • Q` is not definitionally equal to `![u * Q x, u * Q y, u * Q z]`, so the
lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms. Files in
`Mathlib/AlgebraicGeometry/EllipticCurve/Projective` make extensive use of `erw` to get around this.
While `erw` is often an indication of a problem, in this case it is self-contained and should not
cause any issues. It would alternatively be possible to add some automation to assist here.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, projective, Weierstrass equation, nonsingular
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, eval_pow])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
local macro "matrix_simp" : tactic =>
`(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons,
Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two])
local macro "pderiv_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow,
pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm,
pderiv_X_of_ne (by decide : z ≠ x), pderiv_X_of_ne (by decide : x ≠ z),
pderiv_X_of_ne (by decide : z ≠ y), pderiv_X_of_ne (by decide : y ≠ z)])
universe r s u v
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v}
name_poly_vars X, Y, Z over R
namespace WeierstrassCurve
/-! ## Projective coordinates -/
variable (R) in
/-- An abbreviation for a Weierstrass curve in projective coordinates. -/
abbrev Projective : Type r :=
WeierstrassCurve R
/-- The conversion from a Weierstrass curve to projective coordinates. -/
abbrev toProjective (W : WeierstrassCurve R) : Projective R :=
W
namespace Projective
/-- The conversion from a Weierstrass curve in projective coordinates to affine coordinates. -/
abbrev toAffine (W' : Projective R) : Affine R :=
W'
lemma fin3_def (P : Fin 3 → R) : ![P x, P y, P z] = P := by
ext n; fin_cases n <;> rfl
lemma fin3_def_ext (a b c : R) : ![a, b, c] x = a ∧ ![a, b, c] y = b ∧ ![a, b, c] z = c :=
⟨rfl, rfl, rfl⟩
lemma comp_fin3 (f : R → S) (a b c : R) : f ∘ ![a, b, c] = ![f a, f b, f c] :=
(FinVec.map_eq ..).symm
variable [CommRing R] [CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] {W' : Projective R}
{W : Projective F}
lemma smul_fin3 (P : Fin 3 → R) (u : R) : u • P = ![u * P x, u * P y, u * P z] := by
simp [← List.ofFn_inj, List.ofFn_succ]
lemma smul_fin3_ext (P : Fin 3 → R) (u : R) :
(u • P) x = u * P x ∧ (u • P) y = u * P y ∧ (u • P) z = u * P z :=
⟨rfl, rfl, rfl⟩
lemma comp_smul (f : R →+* S) (P : Fin 3 → R) (u : R) : f ∘ (u • P) = f u • f ∘ P := by
ext
simp
/-- The equivalence setoid for a projective point representative on a Weierstrass curve. -/
@[reducible]
scoped instance : Setoid <| Fin 3 → R :=
MulAction.orbitRel Rˣ <| Fin 3 → R
variable (R) in
/-- The equivalence class of a projective point representative on a Weierstrass curve. -/
abbrev PointClass : Type r :=
MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R
lemma smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : u • P ≈ P :=
⟨hu.unit, rfl⟩
@[simp]
lemma smul_eq (P : Fin 3 → R) {u : R} (hu : IsUnit u) : (⟦u • P⟧ : PointClass R) = ⟦P⟧ :=
Quotient.eq.mpr <| smul_equiv P hu
lemma smul_equiv_smul (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
u • P ≈ v • Q ↔ P ≈ Q := by
rw [← Quotient.eq_iff_equiv, ← Quotient.eq_iff_equiv, smul_eq P hu, smul_eq Q hv]
lemma equiv_iff_eq_of_Z_eq' {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ∈ nonZeroDivisors R) :
P ≈ Q ↔ P = Q := by
refine ⟨?_, Quotient.exact.comp <| congrArg _⟩
rintro ⟨u, rfl⟩
simp only [Units.smul_def, (mul_cancel_right_mem_nonZeroDivisors hQz).mp <| one_mul (Q z) ▸ hz]
rw [one_smul]
lemma equiv_iff_eq_of_Z_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ≠ 0) :
P ≈ Q ↔ P = Q :=
equiv_iff_eq_of_Z_eq' hz <| mem_nonZeroDivisors_of_ne_zero hQz
lemma Z_eq_zero_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P z = 0 ↔ Q z = 0 := by
rcases h with ⟨_, rfl⟩
simp only [Units.smul_def, smul_fin3_ext, Units.mul_right_eq_zero]
lemma X_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P x * Q z = Q x * P z := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma Y_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P y * Q z = Q y * P z := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma not_equiv_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) (hQz : Q z ≠ 0) : ¬P ≈ Q :=
fun h => hQz <| (Z_eq_zero_of_equiv h).mp hPz
lemma not_equiv_of_Z_eq_zero_right {P Q : Fin 3 → R} (hPz : P z ≠ 0) (hQz : Q z = 0) : ¬P ≈ Q :=
fun h => hPz <| (Z_eq_zero_of_equiv h).mpr hQz
lemma not_equiv_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ≠ Q x * P z) : ¬P ≈ Q :=
hx.comp X_eq_of_equiv
lemma not_equiv_of_Y_ne {P Q : Fin 3 → R} (hy : P y * Q z ≠ Q y * P z) : ¬P ≈ Q :=
hy.comp Y_eq_of_equiv
lemma equiv_of_X_eq_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) : P ≈ Q := by
use Units.mk0 _ hPz / Units.mk0 _ hQz
simp only [Units.smul_def, smul_fin3, Units.val_div_eq_div_val, Units.val_mk0, mul_comm, mul_div,
← hx, ← hy, mul_div_cancel_right₀ _ hQz, fin3_def]
lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : P ≈ ![P x / P z, P y / P z, 1] :=
equiv_of_X_eq_of_Y_eq hPz one_ne_zero
(by linear_combination (norm := (matrix_simp; ring1)) -P x * div_self hPz)
(by linear_combination (norm := (matrix_simp; ring1)) -P y * div_self hPz)
lemma X_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P x * Q z = Q x * P z ↔ P x / P z = Q x / Q z :=
(div_eq_div_iff hPz hQz).symm
lemma Y_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z = Q y * P z ↔ P y / P z = Q y / Q z :=
(div_eq_div_iff hPz hQz).symm
/-! ## Weierstrass equations in projective coordinates -/
variable (W') in
/-- The polynomial `W(X, Y, Z) := Y²Z + a₁XYZ + a₃YZ² - (X³ + a₂X²Z + a₄XZ² + a₆Z³)` associated to a
Weierstrass curve `W` over a ring `R` in projective coordinates.
This is represented as a term of type `MvPolynomial (Fin 3) R`, where `X`, `Y`, and `Z`
represent `X`, `Y`, and `Z` respectively. -/
noncomputable def polynomial : MvPolynomial (Fin 3) R :=
Y ^ 2 * Z + C W'.a₁ * X * Y * Z + C W'.a₃ * Y * Z ^ 2
- (X ^ 3 + C W'.a₂ * X ^ 2 * Z + C W'.a₄ * X * Z ^ 2 + C W'.a₆ * Z ^ 3)
lemma eval_polynomial (P : Fin 3 → R) : eval P W'.polynomial =
P y ^ 2 * P z + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 2
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z + W'.a₄ * P x * P z ^ 2 + W'.a₆ * P z ^ 3) := by
rw [polynomial]
simp
lemma eval_polynomial_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomial / P z ^ 3 =
W.toAffine.polynomial.evalEval (P x / P z) (P y / P z) := by
linear_combination (norm := (rw [eval_polynomial, Affine.evalEval_polynomial]; ring1))
P y ^ 2 / P z ^ 2 * div_self hPz + W.a₁ * P x * P y / P z ^ 2 * div_self hPz
+ W.a₃ * P y / P z * div_self (pow_ne_zero 2 hPz) - W.a₂ * P x ^ 2 / P z ^ 2 * div_self hPz
- W.a₄ * P x / P z * div_self (pow_ne_zero 2 hPz) - W.a₆ * div_self (pow_ne_zero 3 hPz)
variable (W') in
/-- The proposition that a projective point representative `(x, y, z)` lies in a Weierstrass curve
`W`.
In other words, it satisfies the homogeneous Weierstrass equation `W(X, Y, Z) = 0`. -/
def Equation (P : Fin 3 → R) : Prop :=
eval P W'.polynomial = 0
lemma equation_iff (P : Fin 3 → R) : W'.Equation P ↔
P y ^ 2 * P z + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 2
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z + W'.a₄ * P x * P z ^ 2 + W'.a₆ * P z ^ 3) = 0 := by
rw [Equation, eval_polynomial, sub_eq_zero]
lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u • P) ↔ W'.Equation P :=
have hP (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by
rw [equation_iff] at hP ⊢
linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 3 * hP
⟨fun h => by convert hP ↑hu.unit⁻¹ h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩
lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by
rcases h with ⟨u, rfl⟩
exact equation_smul Q u.isUnit
lemma equation_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.Equation P ↔ P x ^ 3 = 0 := by
simp only [equation_iff, hPz, add_zero, zero_sub, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _,
neg_eq_zero]
lemma equation_zero : W'.Equation ![0, 1, 0] := by
simp only [equation_of_Z_eq_zero, fin3_def_ext, zero_pow three_ne_zero]
lemma equation_some (a b : R) : W'.Equation ![a, b, 1] ↔ W'.toAffine.Equation a b := by
simp only [equation_iff, Affine.equation_iff', fin3_def_ext, one_pow, mul_one]
lemma equation_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Equation P ↔ W.toAffine.Equation (P x / P z) (P y / P z) :=
(equation_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| equation_some ..
lemma X_eq_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : P x = 0 :=
eq_zero_of_pow_eq_zero <| (equation_of_Z_eq_zero hPz).mp hP
/-! ## The nonsingular condition in projective coordinates -/
variable (W') in
/-- The partial derivative `W_X(X, Y, Z)` with respect to `X` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in projective coordinates. -/
noncomputable def polynomialX : MvPolynomial (Fin 3) R :=
pderiv x W'.polynomial
lemma polynomialX_eq : W'.polynomialX =
C W'.a₁ * Y * Z - (C 3 * X ^ 2 + C (2 * W'.a₂) * X * Z + C W'.a₄ * Z ^ 2) := by
rw [polynomialX, polynomial]
pderiv_simp
ring1
lemma eval_polynomialX (P : Fin 3 → R) : eval P W'.polynomialX =
W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z + W'.a₄ * P z ^ 2) := by
rw [polynomialX_eq]
simp
lemma eval_polynomialX_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialX / P z ^ 2 = W.toAffine.polynomialX.evalEval (P x / P z) (P y / P z) := by
linear_combination (norm := (rw [eval_polynomialX, Affine.evalEval_polynomialX]; ring1))
W.a₁ * P y / P z * div_self hPz - 2 * W.a₂ * P x / P z * div_self hPz
- W.a₄ * div_self (pow_ne_zero 2 hPz)
variable (W') in
/-- The partial derivative `W_Y(X, Y, Z)` with respect to `Y` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in projective coordinates. -/
noncomputable def polynomialY : MvPolynomial (Fin 3) R :=
pderiv y W'.polynomial
lemma polynomialY_eq : W'.polynomialY =
C 2 * Y * Z + C W'.a₁ * X * Z + C W'.a₃ * Z ^ 2 := by
rw [polynomialY, polynomial]
pderiv_simp
ring1
lemma eval_polynomialY (P : Fin 3 → R) :
eval P W'.polynomialY = 2 * P y * P z + W'.a₁ * P x * P z + W'.a₃ * P z ^ 2 := by
rw [polynomialY_eq]
simp
lemma eval_polynomialY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialY / P z ^ 2 = W.toAffine.polynomialY.evalEval (P x / P z) (P y / P z) := by
linear_combination (norm := (rw [eval_polynomialY, Affine.evalEval_polynomialY]; ring1))
2 * P y / P z * div_self hPz + W.a₁ * P x / P z * div_self hPz
+ W.a₃ * div_self (pow_ne_zero 2 hPz)
variable (W') in
/-- The partial derivative `W_Z(X, Y, Z)` with respect to `Z` of the polynomial `W(X, Y, Z)`
associated to a Weierstrass curve `W` in projective coordinates. -/
noncomputable def polynomialZ : MvPolynomial (Fin 3) R :=
pderiv z W'.polynomial
lemma polynomialZ_eq : W'.polynomialZ =
Y ^ 2 + C W'.a₁ * X * Y + C (2 * W'.a₃) * Y * Z
- (C W'.a₂ * X ^ 2 + C (2 * W'.a₄) * X * Z + C (3 * W'.a₆) * Z ^ 2) := by
rw [polynomialZ, polynomial]
pderiv_simp
ring1
lemma eval_polynomialZ (P : Fin 3 → R) : eval P W'.polynomialZ =
P y ^ 2 + W'.a₁ * P x * P y + 2 * W'.a₃ * P y * P z
- (W'.a₂ * P x ^ 2 + 2 * W'.a₄ * P x * P z + 3 * W'.a₆ * P z ^ 2) := by
rw [polynomialZ_eq]
simp
/-- Euler's homogeneous function theorem in projective coordinates. -/
theorem polynomial_relation (P : Fin 3 → R) : 3 * eval P W'.polynomial =
P x * eval P W'.polynomialX + P y * eval P W'.polynomialY + P z * eval P W'.polynomialZ := by
rw [eval_polynomial, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
ring1
variable (W') in
/-- The proposition that a projective point representative `(x, y, z)` on a Weierstrass curve `W` is
nonsingular.
In other words, either `W_X(x, y, z) ≠ 0`, `W_Y(x, y, z) ≠ 0`, or `W_Z(x, y, z) ≠ 0`.
Note that this definition is only mathematically accurate for fields. -/
-- TODO: generalise this definition to be mathematically accurate for a larger class of rings.
def Nonsingular (P : Fin 3 → R) : Prop :=
W'.Equation P ∧
(eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0)
lemma nonsingular_iff (P : Fin 3 → R) : W'.Nonsingular P ↔ W'.Equation P ∧
(W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z + W'.a₄ * P z ^ 2) ≠ 0 ∨
2 * P y * P z + W'.a₁ * P x * P z + W'.a₃ * P z ^ 2 ≠ 0 ∨
P y ^ 2 + W'.a₁ * P x * P y + 2 * W'.a₃ * P y * P z
- (W'.a₂ * P x ^ 2 + 2 * W'.a₄ * P x * P z + 3 * W'.a₆ * P z ^ 2) ≠ 0) := by
rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
lemma nonsingular_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) :
W'.Nonsingular (u • P) ↔ W'.Nonsingular P :=
have hP {u : R} (hu : IsUnit u) {P : Fin 3 → R} (hP : W'.Nonsingular <| u • P) :
W'.Nonsingular P := by
rcases (nonsingular_iff _).mp hP with ⟨hP, hP'⟩
refine (nonsingular_iff P).mpr ⟨(equation_smul P hu).mp hP, ?_⟩
contrapose! hP'
simp only [smul_fin3_ext]
exact ⟨by linear_combination (norm := ring1) u ^ 2 * hP'.left,
by linear_combination (norm := ring1) u ^ 2 * hP'.right.left,
by linear_combination (norm := ring1) u ^ 2 * hP'.right.right⟩
⟨hP hu, fun h => hP hu.unit⁻¹.isUnit <| by rwa [smul_smul, hu.val_inv_mul, one_smul]⟩
lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Nonsingular P ↔ W'.Nonsingular Q := by
rcases h with ⟨u, rfl⟩
exact nonsingular_smul Q u.isUnit
lemma nonsingular_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) :
W'.Nonsingular P ↔
W'.Equation P ∧ (3 * P x ^ 2 ≠ 0 ∨ P y ^ 2 + W'.a₁ * P x * P y - W'.a₂ * P x ^ 2 ≠ 0) := by
simp only [nonsingular_iff, hPz, add_zero, zero_sub, mul_zero,
zero_pow <| OfNat.ofNat_ne_zero _, neg_ne_zero, ne_self_iff_false, false_or]
lemma nonsingular_zero [Nontrivial R] : W'.Nonsingular ![0, 1, 0] := by
simp only [nonsingular_of_Z_eq_zero, equation_zero, true_and, fin3_def_ext, ← not_and_or]
exact fun h => one_ne_zero <| by linear_combination (norm := ring1) h.right
lemma nonsingular_some (a b : R) : W'.Nonsingular ![a, b, 1] ↔ W'.toAffine.Nonsingular a b := by
simp_rw [nonsingular_iff, equation_some, fin3_def_ext, Affine.nonsingular_iff',
Affine.equation_iff', and_congr_right_iff, ← not_and_or, not_iff_not, one_pow, mul_one,
and_congr_right_iff, Iff.comm, iff_self_and]
intro h ha hb
linear_combination (norm := ring1) 3 * h - a * ha - b * hb
lemma nonsingular_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z) (P y / P z) :=
(nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| nonsingular_some ..
lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by
rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz,
← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 2 hPz,
← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 2 hPz]
lemma Y_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P)
(hPz : P z = 0) : P y ≠ 0 := by
intro hPy
simp only [nonsingular_of_Z_eq_zero hPz, X_eq_zero_of_Z_eq_zero hP.left hPz, hPy, add_zero,
sub_zero, mul_zero, zero_pow two_ne_zero, or_self, ne_self_iff_false, and_false] at hP
lemma isUnit_Y_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P y) :=
(Y_ne_zero_of_Z_eq_zero hP hPz).isUnit
lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by
use (isUnit_Y_of_Z_eq_zero hP hPz).unit / (isUnit_Y_of_Z_eq_zero hQ hQz).unit
simp only [Units.smul_def, smul_fin3, X_eq_zero_of_Z_eq_zero hQ.left hQz, hQz, mul_zero,
Units.val_div_eq_div_val, IsUnit.unit_spec, (isUnit_Y_of_Z_eq_zero hQ hQz).div_mul_cancel]
conv_rhs => rw [← fin3_def P, X_eq_zero_of_Z_eq_zero hP.left hPz, hPz]
lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
P ≈ ![0, 1, 0] :=
equiv_of_Z_eq_zero hP nonsingular_zero hPz rfl
lemma comp_equiv_comp (f : F →+* K) {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) : f ∘ P ≈ f ∘ Q ↔ P ≈ Q := by
refine ⟨fun h => ?_, fun h => ?_⟩
· by_cases hz : f (P z) = 0
· exact equiv_of_Z_eq_zero hP hQ ((map_eq_zero_iff f f.injective).mp hz) <|
(map_eq_zero_iff f f.injective).mp <| (Z_eq_zero_of_equiv h).mp hz
· refine equiv_of_X_eq_of_Y_eq ((map_ne_zero_iff f f.injective).mp hz)
((map_ne_zero_iff f f.injective).mp <| hz.comp (Z_eq_zero_of_equiv h).mpr) ?_ ?_
all_goals apply f.injective; map_simp
exacts [X_eq_of_equiv h, Y_eq_of_equiv h]
· rcases h with ⟨u, rfl⟩
exact ⟨Units.map f u, (comp_smul ..).symm⟩
variable (W') in
/-- The proposition that a projective point class on a Weierstrass curve `W` is nonsingular.
If `P` is a projective point representative on `W`, then `W.NonsingularLift ⟦P⟧` is definitionally
equivalent to `W.Nonsingular P`.
Note that this definition is only mathematically accurate for fields. -/
def NonsingularLift (P : PointClass R) : Prop :=
P.lift W'.Nonsingular fun _ _ => propext ∘ nonsingular_of_equiv
lemma nonsingularLift_iff (P : Fin 3 → R) : W'.NonsingularLift ⟦P⟧ ↔ W'.Nonsingular P :=
Iff.rfl
lemma nonsingularLift_zero [Nontrivial R] : W'.NonsingularLift ⟦![0, 1, 0]⟧ :=
nonsingular_zero
lemma nonsingularLift_some (a b : R) :
W'.NonsingularLift ⟦![a, b, 1]⟧ ↔ W'.toAffine.Nonsingular a b :=
nonsingular_some a b
/-! ## Maps and base changes -/
variable (f : R →+* S) (P : Fin 3 → R)
@[simp]
lemma map_polynomial : (W'.map f).toProjective.polynomial = MvPolynomial.map f W'.polynomial := by
simp only [polynomial]
map_simp
variable {P} in
lemma Equation.map (h : W'.Equation P) : (W'.map f).toProjective.Equation (f ∘ P) := by
rw [Equation, map_polynomial, eval_map, ← eval₂_comp, h, map_zero]
variable {f} in
@[simp]
lemma map_equation (hf : Function.Injective f) :
(W'.map f).toProjective.Equation (f ∘ P) ↔ W'.Equation P := by
simp only [Equation, map_polynomial, eval_map, ← eval₂_comp, map_eq_zero_iff f hf]
@[simp]
lemma map_polynomialX :
(W'.map f).toProjective.polynomialX = MvPolynomial.map f W'.polynomialX := by
simp only [polynomialX, map_polynomial, pderiv_map]
@[simp]
lemma map_polynomialY :
(W'.map f).toProjective.polynomialY = MvPolynomial.map f W'.polynomialY := by
simp only [polynomialY, map_polynomial, pderiv_map]
@[simp]
lemma map_polynomialZ :
(W'.map f).toProjective.polynomialZ = MvPolynomial.map f W'.polynomialZ := by
simp only [polynomialZ, map_polynomial, pderiv_map]
variable {f} in
@[simp]
lemma map_nonsingular (hf : Function.Injective f) :
(W'.map f).toProjective.Nonsingular (f ∘ P) ↔ W'.Nonsingular P := by
simp only [Nonsingular, map_equation P hf, map_polynomialX, map_polynomialY, map_polynomialZ,
eval_map, ← eval₂_comp, map_ne_zero_iff f hf]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (P : Fin 3 → A)
lemma baseChange_polynomial : (W'.baseChange B).toProjective.polynomial =
MvPolynomial.map f (W'.baseChange A).toProjective.polynomial := by
rw [← map_polynomial, map_baseChange]
variable {P} in
lemma Equation.baseChange (h : (W'.baseChange A).toProjective.Equation P) :
(W'.baseChange B).toProjective.Equation (f ∘ P) := by
convert Equation.map f.toRingHom h using 1
rw [AlgHom.toRingHom_eq_coe, map_baseChange]
variable {f} in
lemma baseChange_equation (hf : Function.Injective f) :
(W'.baseChange B).toProjective.Equation (f ∘ P) ↔
(W'.baseChange A).toProjective.Equation P := by
rw [← RingHom.coe_coe, ← map_equation P hf, AlgHom.toRingHom_eq_coe, map_baseChange]
lemma baseChange_polynomialX : (W'.baseChange B).toProjective.polynomialX =
MvPolynomial.map f (W'.baseChange A).toProjective.polynomialX := by
rw [← map_polynomialX, map_baseChange]
lemma baseChange_polynomialY : (W'.baseChange B).toProjective.polynomialY =
MvPolynomial.map f (W'.baseChange A).toProjective.polynomialY := by
rw [← map_polynomialY, map_baseChange]
lemma baseChange_polynomialZ : (W'.baseChange B).toProjective.polynomialZ =
MvPolynomial.map f (W'.baseChange A).toProjective.polynomialZ := by
rw [← map_polynomialZ, map_baseChange]
variable {f} in
lemma baseChange_nonsingular (hf : Function.Injective f) :
(W'.baseChange B).toProjective.Nonsingular (f ∘ P) ↔
(W'.baseChange A).toProjective.Nonsingular P := by
rw [← RingHom.coe_coe, ← map_nonsingular P hf, AlgHom.toRingHom_eq_coe, map_baseChange]
end Projective
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Formula.lean | import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula
import Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Basic
/-!
# Negation and addition formulae for nonsingular points in projective coordinates
Let `W` be a Weierstrass curve over a field `F`. The nonsingular projective points on `W` can be
given negation and addition operations defined by an analogue of the secant-and-tangent process in
`Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`, but the polynomials involved are
homogeneous, so any instances of division become multiplication in the `Z`-coordinate. Most
computational proofs are immediate from their analogous proofs for affine coordinates.
This file defines polynomials associated to negation, doubling, and addition of projective point
representatives. The group operations and the group law on actual nonsingular projective points will
be defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean`.
## Main definitions
* `WeierstrassCurve.Projective.negY`: the `Y`-coordinate of `-P`.
* `WeierstrassCurve.Projective.dblZ`: the `Z`-coordinate of `2 • P`.
* `WeierstrassCurve.Projective.dblX`: the `X`-coordinate of `2 • P`.
* `WeierstrassCurve.Projective.negDblY`: the `Y`-coordinate of `-(2 • P)`.
* `WeierstrassCurve.Projective.dblY`: the `Y`-coordinate of `2 • P`.
* `WeierstrassCurve.Projective.addZ`: the `Z`-coordinate of `P + Q`.
* `WeierstrassCurve.Projective.addX`: the `X`-coordinate of `P + Q`.
* `WeierstrassCurve.Projective.negAddY`: the `Y`-coordinate of `-(P + Q)`.
* `WeierstrassCurve.Projective.addY`: the `Y`-coordinate of `P + Q`.
## Implementation notes
The definitions of `WeierstrassCurve.Projective.dblX`, `WeierstrassCurve.Projective.negDblY`,
`WeierstrassCurve.Projective.addZ`, `WeierstrassCurve.Projective.addX`, and
`WeierstrassCurve.Projective.negAddY` are given explicitly by large polynomials that are homogeneous
of degree `4`. Clearing the denominators of their corresponding affine rational functions in
`Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean` would give polynomials that are
homogeneous of degrees `5`, `6`, `6`, `8`, and `8` respectively, so their actual definitions are off
by powers of certain polynomial factors that are homogeneous of degree `1` or `2`. These factors
divide their corresponding affine polynomials only modulo the homogeneous Weierstrass equation, so
their large quotient polynomials are calculated explicitly in a computer algebra system. All of this
is done to ensure that the definitions of both `WeierstrassCurve.Projective.dblXYZ` and
`WeierstrassCurve.Projective.addXYZ` are homogeneous of degree `4`.
Whenever possible, all changes to documentation and naming of definitions and theorems should be
mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Formula.lean`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, projective, negation, doubling, addition, group law
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
open MvPolynomial
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow,
map_div₀, WeierstrassCurve.map, Function.comp_apply])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} [CommRing R] [CommRing S]
[CommRing A] [CommRing B] [Field F] [Field K] {W' : Projective R} {W : Projective F}
namespace Projective
/-! ## Negation formulae in projective coordinates -/
variable (W') in
/-- The `Y`-coordinate of a representative of `-P` for a projective point representative `P` on a
Weierstrass curve. -/
def negY (P : Fin 3 → R) : R :=
-P y - W'.a₁ * P x - W'.a₃ * P z
lemma negY_eq (X Y Z : R) : W'.negY ![X, Y, Z] = -Y - W'.a₁ * X - W'.a₃ * Z :=
rfl
lemma negY_smul (P : Fin 3 → R) (u : R) : W'.negY (u • P) = u * W'.negY P := by
simp only [negY, smul_fin3_ext]
ring1
lemma negY_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negY P = -P y := by
rw [negY, hPz, X_eq_zero_of_Z_eq_zero hP hPz, mul_zero, sub_zero, mul_zero, sub_zero]
lemma negY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negY P / P z = W.toAffine.negY (P x / P z) (P y / P z) := by
linear_combination (norm := (rw [negY, Affine.negY]; ring1)) -W.a₃ * div_self hPz
lemma Y_sub_Y_mul_Y_sub_negY {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z = Q x * P z) :
P z * Q z * (P y * Q z - Q y * P z) * (P y * Q z - W'.negY Q * P z) = 0 := by
linear_combination (norm := (rw [negY]; ring1)) Q z ^ 3 * (equation_iff P).mp hP
- P z ^ 3 * (equation_iff Q).mp hQ + (P x ^ 2 * Q z ^ 2 + P x * Q x * P z * Q z
+ Q x ^ 2 * P z ^ 2 - W'.a₁ * P y * P z * Q z ^ 2 + W'.a₂ * P x * Q z ^ 2 * P z
+ W'.a₂ * Q x * P z ^ 2 * Q z + W'.a₄ * P z ^ 2 * Q z ^ 2) * hx
lemma Y_eq_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ Q y * P z) :
P y * Q z = W'.negY Q * P z :=
sub_eq_zero.mp <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_left <|
mul_ne_zero (mul_ne_zero hPz hQz) <| sub_ne_zero.mpr hy
lemma Y_eq_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z ≠ W'.negY Q * P z) : P y * Q z = Q y * P z :=
sub_eq_zero.mp <| (mul_eq_zero.mp <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx
).resolve_right <| sub_ne_zero.mpr hy).resolve_left <| mul_ne_zero hPz hQz
lemma Y_eq_iff' {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z = W.negY Q * P z ↔ P y / P z = W.toAffine.negY (Q x / Q z) (Q y / Q z) :=
negY_of_Z_ne_zero hQz ▸ (div_eq_div_iff hPz hQz).symm
lemma Y_sub_Y_add_Y_sub_negY {P Q : Fin 3 → R} (hx : P x * Q z = Q x * P z) :
(P y * Q z - Q y * P z) + (P y * Q z - W'.negY Q * P z) = (P y - W'.negY P) * Q z := by
linear_combination (norm := (rw [negY, negY]; ring1)) -W'.a₁ * hx
lemma Y_ne_negY_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z ≠ Q y * P z) : P y ≠ W'.negY P := by
have hy' : P y * Q z - W'.negY Q * P z = 0 := sub_eq_zero.mpr <| Y_eq_of_Y_ne hP hQ hPz hQz hx hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY hx + Q z * hy - hy'
lemma Y_ne_negY_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z ≠ W'.negY Q * P z) : P y ≠ W'.negY P := by
have hy' : P y * Q z - Q y * P z = 0 := sub_eq_zero.mpr <| Y_eq_of_Y_ne' hP hQ hPz hQz hx hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY hx + Q z * hy - hy'
lemma Y_eq_negY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W'.negY Q * P z) :
P y = W'.negY P :=
mul_left_injective₀ hQz <| by
linear_combination (norm := ring1) -Y_sub_Y_add_Y_sub_negY hx + hy + hy'
lemma nonsingular_iff_of_Y_eq_negY {P : Fin 3 → F} (hPz : P z ≠ 0) (hy : P y = W.negY P) :
W.Nonsingular P ↔ W.Equation P ∧ eval P W.polynomialX ≠ 0 := by
have hy' : eval P W.polynomialY = (P y - W.negY P) * P z := by rw [negY, eval_polynomialY]; ring1
rw [nonsingular_iff_of_Z_ne_zero hPz, hy', hy, sub_self, zero_mul, ne_self_iff_false, or_false]
/-! ## Doubling formulae in projective coordinates -/
variable (W) in
/-- The unit associated to a representative of `2 • P` for a projective point representative `P` on
a Weierstrass curve `W` that is `2`-torsion.
More specifically, the unit `u` such that `W.add P P = u • ![0, 1, 0]` where `P = W.neg P`. -/
noncomputable def dblU (P : Fin 3 → F) : F :=
eval P W.polynomialX ^ 3 / P z ^ 2
lemma dblU_eq (P : Fin 3 → F) : W.dblU P =
(W.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W.a₂ * P x * P z + W.a₄ * P z ^ 2)) ^ 3 / P z ^ 2 := by
rw [dblU, eval_polynomialX]
lemma dblU_smul (P : Fin 3 → F) (u : F) :
W.dblU (u • P) = u ^ 4 * W.dblU P := by
simp [field, dblU_eq]
lemma dblU_of_Z_eq_zero {P : Fin 3 → F} (hPz : P z = 0) : W.dblU P = 0 := by
rw [dblU_eq, hPz, zero_pow two_ne_zero, div_zero]
lemma dblU_ne_zero_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.dblU P ≠ 0 :=
div_ne_zero (pow_ne_zero 3
((nonsingular_iff_of_Y_eq_negY hPz <| Y_eq_negY_of_Y_eq hQz hx hy hy').mp hP).right) <|
pow_ne_zero 2 hPz
lemma isUnit_dblU_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
IsUnit (W.dblU P) :=
(dblU_ne_zero_of_Y_eq hP hPz hQz hx hy hy').isUnit
variable (W') in
/-- The `Z`-coordinate of a representative of `2 • P` for a projective point representative `P` on a
Weierstrass curve. -/
def dblZ (P : Fin 3 → R) : R :=
P z * (P y - W'.negY P) ^ 3
lemma dblZ_smul (P : Fin 3 → R) (u : R) : W'.dblZ (u • P) = u ^ 4 * W'.dblZ P := by
simp only [dblZ, negY_smul, smul_fin3_ext]
ring1
lemma dblZ_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.dblZ P = 0 := by
rw [dblZ, hPz, zero_mul]
lemma dblZ_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W'.negY Q * P z) : W'.dblZ P = 0 := by
rw [dblZ, Y_eq_negY_of_Y_eq hQz hx hy hy', sub_self, zero_pow three_ne_zero, mul_zero]
lemma dblZ_ne_zero_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z ≠ Q y * P z) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| pow_ne_zero 3 <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne hP hQ hPz hQz hx hy
lemma isUnit_dblZ_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ Q y * P z) : IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne hP hQ hPz hQz hx hy).isUnit
lemma dblZ_ne_zero_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z)
(hy : P y * Q z ≠ W'.negY Q * P z) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| pow_ne_zero 3 <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hPz hQz hx hy
lemma isUnit_dblZ_of_Y_ne' {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne' hP hQ hPz hQz hx hy).isUnit
private lemma toAffine_slope_of_eq [DecidableEq F]
{P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z) =
-eval P W.polynomialX / P z / (P y - W.negY P) := by
have hPy : P y - W.negY P ≠ 0 := sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hPz hQz hx hy
simp only [X_eq_iff hPz hQz, ne_eq, Y_eq_iff' hPz hQz] at hx hy
rw [Affine.slope_of_Y_ne hx <| negY_of_Z_ne_zero hQz ▸ hy, ← negY_of_Z_ne_zero hPz]
simp [field, eval_polynomialX]
variable (W') in
/-- The `X`-coordinate of a representative of `2 • P` for a projective point representative `P` on a
Weierstrass curve. -/
noncomputable def dblX (P : Fin 3 → R) : R :=
2 * P x * P y ^ 3 + 3 * W'.a₁ * P x ^ 2 * P y ^ 2 + 6 * W'.a₂ * P x ^ 3 * P y
- 8 * W'.a₂ * P y ^ 3 * P z + 9 * W'.a₃ * P x ^ 4 - 6 * W'.a₃ * P x * P y ^ 2 * P z
- 6 * W'.a₄ * P x ^ 2 * P y * P z - 18 * W'.a₆ * P x * P y * P z ^ 2
+ 3 * W'.a₁ ^ 2 * P x ^ 3 * P y - 2 * W'.a₁ ^ 2 * P y ^ 3 * P z + 3 * W'.a₁ * W'.a₂ * P x ^ 4
- 12 * W'.a₁ * W'.a₂ * P x * P y ^ 2 * P z - 9 * W'.a₁ * W'.a₃ * P x ^ 2 * P y * P z
- 3 * W'.a₁ * W'.a₄ * P x ^ 3 * P z - 9 * W'.a₁ * W'.a₆ * P x ^ 2 * P z ^ 2
+ 8 * W'.a₂ ^ 2 * P x ^ 2 * P y * P z + 12 * W'.a₂ * W'.a₃ * P x ^ 3 * P z
- 12 * W'.a₂ * W'.a₃ * P y ^ 2 * P z ^ 2 + 8 * W'.a₂ * W'.a₄ * P x * P y * P z ^ 2
- 12 * W'.a₃ ^ 2 * P x * P y * P z ^ 2 + 6 * W'.a₃ * W'.a₄ * P x ^ 2 * P z ^ 2
+ 2 * W'.a₄ ^ 2 * P y * P z ^ 3 + W'.a₁ ^ 3 * P x ^ 4 - 3 * W'.a₁ ^ 3 * P x * P y ^ 2 * P z
- 2 * W'.a₁ ^ 2 * W'.a₂ * P x ^ 2 * P y * P z - 3 * W'.a₁ ^ 2 * W'.a₃ * P y ^ 2 * P z ^ 2
+ 2 * W'.a₁ ^ 2 * W'.a₄ * P x * P y * P z ^ 2 + 4 * W'.a₁ * W'.a₂ ^ 2 * P x ^ 3 * P z
- 8 * W'.a₁ * W'.a₂ * W'.a₃ * P x * P y * P z ^ 2
+ 4 * W'.a₁ * W'.a₂ * W'.a₄ * P x ^ 2 * P z ^ 2 - 3 * W'.a₁ * W'.a₃ ^ 2 * P x ^ 2 * P z ^ 2
+ 2 * W'.a₁ * W'.a₃ * W'.a₄ * P y * P z ^ 3 + W'.a₁ * W'.a₄ ^ 2 * P x * P z ^ 3
+ 4 * W'.a₂ ^ 2 * W'.a₃ * P x ^ 2 * P z ^ 2 - 6 * W'.a₂ * W'.a₃ ^ 2 * P y * P z ^ 3
+ 4 * W'.a₂ * W'.a₃ * W'.a₄ * P x * P z ^ 3 - 2 * W'.a₃ ^ 3 * P x * P z ^ 3
+ W'.a₃ * W'.a₄ ^ 2 * P z ^ 4 - W'.a₁ ^ 4 * P x ^ 2 * P y * P z
+ W'.a₁ ^ 3 * W'.a₂ * P x ^ 3 * P z - 2 * W'.a₁ ^ 3 * W'.a₃ * P x * P y * P z ^ 2
+ W'.a₁ ^ 3 * W'.a₄ * P x ^ 2 * P z ^ 2 + W'.a₁ ^ 2 * W'.a₂ * W'.a₃ * P x ^ 2 * P z ^ 2
- W'.a₁ ^ 2 * W'.a₃ ^ 2 * P y * P z ^ 3 + 2 * W'.a₁ ^ 2 * W'.a₃ * W'.a₄ * P x * P z ^ 3
- W'.a₁ * W'.a₂ * W'.a₃ ^ 2 * P x * P z ^ 3 - W'.a₂ * W'.a₃ ^ 3 * P z ^ 4
+ W'.a₁ * W'.a₃ ^ 2 * W'.a₄ * P z ^ 4
lemma dblX_eq' {P : Fin 3 → R} (hP : W'.Equation P) : W'.dblX P * P z =
(eval P W'.polynomialX ^ 2 - W'.a₁ * eval P W'.polynomialX * P z * (P y - W'.negY P)
- W'.a₂ * P z ^ 2 * (P y - W'.negY P) ^ 2 - 2 * P x * P z * (P y - W'.negY P) ^ 2)
* (P y - W'.negY P) := by
linear_combination (norm := (rw [dblX, eval_polynomialX, negY]; ring1))
9 * (W'.a₁ * P x ^ 2 + 2 * P x * P y) * (equation_iff _).mp hP
lemma dblX_eq {P : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) : W.dblX P =
((eval P W.polynomialX ^ 2 - W.a₁ * eval P W.polynomialX * P z * (P y - W.negY P)
- W.a₂ * P z ^ 2 * (P y - W.negY P) ^ 2 - 2 * P x * P z * (P y - W.negY P) ^ 2)
* (P y - W.negY P)) / P z := by
rw [← dblX_eq' hP, mul_div_cancel_right₀ _ hPz]
lemma dblX_smul (P : Fin 3 → R) (u : R) : W'.dblX (u • P) = u ^ 4 * W'.dblX P := by
simp only [dblX, smul_fin3_ext]
ring1
lemma dblX_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblX P = 0 := by
rw [dblX, hPz, X_eq_zero_of_Z_eq_zero hP hPz]
ring1
lemma dblX_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z)
(hy' : P y * Q z = W'.negY Q * P z) : W'.dblX P = 0 := by
apply eq_zero_of_ne_zero_of_mul_right_eq_zero hPz
rw [dblX_eq' hP, Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
private lemma toAffine_addX_of_eq {P : Fin 3 → F} (hPz : P z ≠ 0) {n d : F} (hd : d ≠ 0) :
W.toAffine.addX (P x / P z) (P x / P z) (-n / P z / d) =
(n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * P z * d ^ 2) * d / P z
/ (P z * d ^ 3) := by
simp [field]
ring1
lemma dblX_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.dblX P / W.dblZ P = W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
rw [dblX_eq hP hPz, dblZ, toAffine_slope_of_eq hP hQ hPz hQz hx hy, ← (X_eq_iff hPz hQz).mp hx,
toAffine_addX_of_eq hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hPz hQz hx hy]
variable (W') in
/-- The `Y`-coordinate of a representative of `-(2 • P)` for a projective point representative `P`
on a Weierstrass curve. -/
noncomputable def negDblY (P : Fin 3 → R) : R :=
-P y ^ 4 - 3 * W'.a₁ * P x * P y ^ 3 - 9 * W'.a₃ * P x ^ 3 * P y + 3 * W'.a₃ * P y ^ 3 * P z
- 3 * W'.a₄ * P x * P y ^ 2 * P z - 27 * W'.a₆ * P x ^ 3 * P z + 9 * W'.a₆ * P y ^ 2 * P z ^ 2
- 3 * W'.a₁ ^ 2 * P x ^ 2 * P y ^ 2 + 4 * W'.a₁ * W'.a₂ * P y ^ 3 * P z
- 3 * W'.a₁ * W'.a₂ * P x ^ 3 * P y - 9 * W'.a₁ * W'.a₃ * P x ^ 4
+ 6 * W'.a₁ * W'.a₃ * P x * P y ^ 2 * P z + 18 * W'.a₁ * W'.a₆ * P x * P y * P z ^ 2
+ 9 * W'.a₂ ^ 2 * P x ^ 4 - 8 * W'.a₂ ^ 2 * P x * P y ^ 2 * P z
- 9 * W'.a₂ * W'.a₃ * P x ^ 2 * P y * P z + 9 * W'.a₂ * W'.a₄ * P x ^ 3 * P z
- 4 * W'.a₂ * W'.a₄ * P y ^ 2 * P z ^ 2 - 27 * W'.a₂ * W'.a₆ * P x ^ 2 * P z ^ 2
- 9 * W'.a₃ ^ 2 * P x ^ 3 * P z + 6 * W'.a₃ ^ 2 * P y ^ 2 * P z ^ 2
- 12 * W'.a₃ * W'.a₄ * P x * P y * P z ^ 2 + 9 * W'.a₄ ^ 2 * P x ^ 2 * P z ^ 2
- 2 * W'.a₁ ^ 3 * P x ^ 3 * P y + W'.a₁ ^ 3 * P y ^ 3 * P z + 3 * W'.a₁ ^ 2 * W'.a₂ * P x ^ 4
+ 2 * W'.a₁ ^ 2 * W'.a₂ * P x * P y ^ 2 * P z + 3 * W'.a₁ ^ 2 * W'.a₃ * P x ^ 2 * P y * P z
+ 3 * W'.a₁ ^ 2 * W'.a₄ * P x ^ 3 * P z - W'.a₁ ^ 2 * W'.a₄ * P y ^ 2 * P z ^ 2
- 12 * W'.a₁ * W'.a₂ ^ 2 * P x ^ 2 * P y * P z - 6 * W'.a₁ * W'.a₂ * W'.a₃ * P x ^ 3 * P z
+ 4 * W'.a₁ * W'.a₂ * W'.a₃ * P y ^ 2 * P z ^ 2
- 8 * W'.a₁ * W'.a₂ * W'.a₄ * P x * P y * P z ^ 2 + 6 * W'.a₁ * W'.a₃ ^ 2 * P x * P y * P z ^ 2
- W'.a₁ * W'.a₄ ^ 2 * P y * P z ^ 3 + 8 * W'.a₂ ^ 3 * P x ^ 3 * P z
- 8 * W'.a₂ ^ 2 * W'.a₃ * P x * P y * P z ^ 2 + 12 * W'.a₂ ^ 2 * W'.a₄ * P x ^ 2 * P z ^ 2
- 9 * W'.a₂ * W'.a₃ ^ 2 * P x ^ 2 * P z ^ 2 - 4 * W'.a₂ * W'.a₃ * W'.a₄ * P y * P z ^ 3
+ 6 * W'.a₂ * W'.a₄ ^ 2 * P x * P z ^ 3 + W'.a₃ ^ 3 * P y * P z ^ 3
- 3 * W'.a₃ ^ 2 * W'.a₄ * P x * P z ^ 3 + W'.a₄ ^ 3 * P z ^ 4 + W'.a₁ ^ 4 * P x * P y ^ 2 * P z
- 3 * W'.a₁ ^ 3 * W'.a₂ * P x ^ 2 * P y * P z + W'.a₁ ^ 3 * W'.a₃ * P y ^ 2 * P z ^ 2
- 2 * W'.a₁ ^ 3 * W'.a₄ * P x * P y * P z ^ 2 + 2 * W'.a₁ ^ 2 * W'.a₂ ^ 2 * P x ^ 3 * P z
- 2 * W'.a₁ ^ 2 * W'.a₂ * W'.a₃ * P x * P y * P z ^ 2
+ 3 * W'.a₁ ^ 2 * W'.a₂ * W'.a₄ * P x ^ 2 * P z ^ 2
- 2 * W'.a₁ ^ 2 * W'.a₃ * W'.a₄ * P y * P z ^ 3 + W'.a₁ ^ 2 * W'.a₄ ^ 2 * P x * P z ^ 3
+ W'.a₁ * W'.a₂ * W'.a₃ ^ 2 * P y * P z ^ 3 + 2 * W'.a₁ * W'.a₂ * W'.a₃ * W'.a₄ * P x * P z ^ 3
+ W'.a₁ * W'.a₃ * W'.a₄ ^ 2 * P z ^ 4 - 2 * W'.a₂ ^ 2 * W'.a₃ ^ 2 * P x * P z ^ 3
- W'.a₂ * W'.a₃ ^ 2 * W'.a₄ * P z ^ 4
lemma negDblY_eq' {P : Fin 3 → R} (hP : W'.Equation P) : W'.negDblY P * P z ^ 2 =
-eval P W'.polynomialX * (eval P W'.polynomialX ^ 2
- W'.a₁ * eval P W'.polynomialX * P z * (P y - W'.negY P)
- W'.a₂ * P z ^ 2 * (P y - W'.negY P) ^ 2 - 2 * P x * P z * (P y - W'.negY P) ^ 2
- P x * P z * (P y - W'.negY P) ^ 2) + P y * P z ^ 2 * (P y - W'.negY P) ^ 3 := by
linear_combination (norm := (rw [negDblY, eval_polynomialX, negY]; ring1))
-9 * (P y ^ 2 * P z + 2 * W'.a₁ * P x * P y * P z - 3 * P x ^ 3 - 3 * W'.a₂ * P x ^ 2 * P z)
* (equation_iff _).mp hP
lemma negDblY_eq {P : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) : W.negDblY P =
(-eval P W.polynomialX * (eval P W.polynomialX ^ 2
- W.a₁ * eval P W.polynomialX * P z * (P y - W.negY P)
- W.a₂ * P z ^ 2 * (P y - W.negY P) ^ 2 - 2 * P x * P z * (P y - W.negY P) ^ 2
- P x * P z * (P y - W.negY P) ^ 2) + P y * P z ^ 2 * (P y - W.negY P) ^ 3) / P z ^ 2 := by
rw [← negDblY_eq' hP, mul_div_cancel_right₀ _ <| pow_ne_zero 2 hPz]
lemma negDblY_smul (P : Fin 3 → R) (u : R) : W'.negDblY (u • P) = u ^ 4 * W'.negDblY P := by
simp only [negDblY, smul_fin3_ext]
ring1
lemma negDblY_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negDblY P = -P y ^ 4 := by
rw [negDblY, hPz, X_eq_zero_of_Z_eq_zero hP hPz]
ring1
lemma negDblY_of_Y_eq' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W'.negY Q * P z) :
W'.negDblY P * P z ^ 2 = -eval P W'.polynomialX ^ 3 := by
rw [negDblY_eq' hP, Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
lemma negDblY_of_Y_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.negDblY P = -W.dblU P := by
rw [dblU, ← neg_div, ← negDblY_of_Y_eq' hP hQz hx hy hy',
mul_div_cancel_right₀ _ <| pow_ne_zero 2 hPz]
private lemma toAffine_negAddY_of_eq {P : Fin 3 → F} (hPz : P z ≠ 0) {n d : F} (hd : d ≠ 0) :
W.toAffine.negAddY (P x / P z) (P x / P z) (P y / P z) (-n / P z / d) =
(-n * (n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * P z * d ^ 2
- P x * P z * d ^ 2) + P y * P z ^ 2 * d ^ 3) / P z ^ 2 / (P z * d ^ 3) := by
rw [Affine.negAddY, toAffine_addX_of_eq hPz hd]
simp [field]
lemma negDblY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.negDblY P / W.dblZ P = W.toAffine.negAddY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
rw [negDblY_eq hP hPz, dblZ, toAffine_slope_of_eq hP hQ hPz hQz hx hy, ← (X_eq_iff hPz hQz).mp hx,
toAffine_negAddY_of_eq hPz <| sub_ne_zero.mpr <| Y_ne_negY_of_Y_ne' hP hQ hPz hQz hx hy]
variable (W') in
/-- The `Y`-coordinate of a representative of `2 • P` for a projective point representative `P` on a
Weierstrass curve. -/
noncomputable def dblY (P : Fin 3 → R) : R :=
W'.negY ![W'.dblX P, W'.negDblY P, W'.dblZ P]
lemma dblY_smul (P : Fin 3 → R) (u : R) : W'.dblY (u • P) = u ^ 4 * W'.dblY P := by
simp only [dblY, negY_eq, negDblY_smul, dblX_smul, dblZ_smul]
ring1
lemma dblY_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblY P = P y ^ 4 := by
rw [dblY, negY_eq, negDblY_of_Z_eq_zero hP hPz, dblX_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz]
ring1
lemma dblY_of_Y_eq' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z)
(hy' : P y * Q z = W'.negY Q * P z) : W'.dblY P * P z ^ 2 = eval P W'.polynomialX ^ 3 := by
linear_combination (norm := (rw [dblY, negY_eq, dblX_of_Y_eq hP hPz hQz hx hy hy',
dblZ_of_Y_eq hQz hx hy hy']; ring1)) -negDblY_of_Y_eq' hP hQz hx hy hy'
lemma dblY_of_Y_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.dblY P = W.dblU P := by
rw [dblU, ← dblY_of_Y_eq' hP hPz hQz hx hy hy', mul_div_cancel_right₀ _ <| pow_ne_zero 2 hPz]
lemma dblY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.dblY P / W.dblZ P = W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
erw [dblY, negY_of_Z_ne_zero <| dblZ_ne_zero_of_Y_ne' hP hQ hPz hQz hx hy,
dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, negDblY_of_Z_ne_zero hP hQ hPz hQz hx hy, Affine.addY]
variable (W') in
/-- The coordinates of a representative of `2 • P` for a projective point representative `P` on a
Weierstrass curve. -/
noncomputable def dblXYZ (P : Fin 3 → R) : Fin 3 → R :=
![W'.dblX P, W'.dblY P, W'.dblZ P]
lemma dblXYZ_X (P : Fin 3 → R) : W'.dblXYZ P x = W'.dblX P :=
rfl
lemma dblXYZ_Y (P : Fin 3 → R) : W'.dblXYZ P y = W'.dblY P :=
rfl
lemma dblXYZ_Z (P : Fin 3 → R) : W'.dblXYZ P z = W'.dblZ P :=
rfl
lemma dblXYZ_smul (P : Fin 3 → R) (u : R) : W'.dblXYZ (u • P) = u ^ 4 • W'.dblXYZ P := by
rw [dblXYZ, dblX_smul, dblY_smul, dblZ_smul, smul_fin3, dblXYZ_X, dblXYZ_Y, dblXYZ_Z]
lemma dblXYZ_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblXYZ P = P y ^ 4 • ![0, 1, 0] := by
erw [dblXYZ, dblX_of_Z_eq_zero hP hPz, dblY_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz, smul_fin3,
mul_zero, mul_one]
lemma dblXYZ_of_Y_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) (hy' : P y * Q z = W.negY Q * P z) :
W.dblXYZ P = W.dblU P • ![0, 1, 0] := by
erw [dblXYZ, dblX_of_Y_eq hP hPz hQz hx hy hy', dblY_of_Y_eq hP hPz hQz hx hy hy',
dblZ_of_Y_eq hQz hx hy hy', smul_fin3, mul_zero, mul_one]
lemma dblXYZ_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) (hy : P y * Q z ≠ W.negY Q * P z) :
W.dblXYZ P = W.dblZ P •
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1] := by
have hZ : IsUnit <| W.dblZ P := isUnit_dblZ_of_Y_ne' hP hQ hPz hQz hx hy
erw [dblXYZ, smul_fin3, ← dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel,
← dblY_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel, mul_one]
/-! ## Addition formulae in projective coordinates -/
/-- The unit associated to a representative of `P + Q` for two projective point representatives `P`
and `Q` on a Weierstrass curve `W` that are not `2`-torsion.
More specifically, the unit `u` such that `W.add P Q = u • ![0, 1, 0]` where `P x / P z = Q x / Q z`
but `P ≠ W.neg P`. -/
def addU (P Q : Fin 3 → F) : F :=
-(P y * Q z - Q y * P z) ^ 3 / (P z * Q z)
lemma addU_smul (P Q : Fin 3 → F) (u v : F) : addU (u • P) (v • Q) = (u * v) ^ 2 * addU P Q := by
simp [field, addU]
lemma addU_of_Z_eq_zero_left {P Q : Fin 3 → F} (hPz : P z = 0) : addU P Q = 0 := by
rw [addU, hPz, zero_mul, div_zero]
lemma addU_of_Z_eq_zero_right {P Q : Fin 3 → F} (hQz : Q z = 0) : addU P Q = 0 := by
rw [addU, hQz, mul_zero <| P z, div_zero]
lemma addU_ne_zero_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ≠ Q y * P z) : addU P Q ≠ 0 :=
div_ne_zero (neg_ne_zero.mpr <| pow_ne_zero 3 <| sub_ne_zero.mpr hy) <| mul_ne_zero hPz hQz
lemma isUnit_addU_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ≠ Q y * P z) : IsUnit (addU P Q) :=
(addU_ne_zero_of_Y_ne hPz hQz hy).isUnit
variable (W') in
/-- The `Z`-coordinate of a representative of `P + Q` for two distinct projective point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addZ (P Q : Fin 3 → R) : R :=
-3 * P x ^ 2 * Q x * Q z + 3 * P x * Q x ^ 2 * P z + P y ^ 2 * Q z ^ 2 - Q y ^ 2 * P z ^ 2
+ W'.a₁ * P x * P y * Q z ^ 2 - W'.a₁ * Q x * Q y * P z ^ 2 - W'.a₂ * P x ^ 2 * Q z ^ 2
+ W'.a₂ * Q x ^ 2 * P z ^ 2 + W'.a₃ * P y * P z * Q z ^ 2 - W'.a₃ * Q y * P z ^ 2 * Q z
- W'.a₄ * P x * P z * Q z ^ 2 + W'.a₄ * Q x * P z ^ 2 * Q z
lemma addZ_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q) :
W'.addZ P Q * (P z * Q z) = (P x * Q z - Q x * P z) ^ 3 := by
linear_combination (norm := (rw [addZ]; ring1))
Q z ^ 3 * (equation_iff _).mp hP - P z ^ 3 * (equation_iff _).mp hQ
lemma addZ_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) : W.addZ P Q = (P x * Q z - Q x * P z) ^ 3 / (P z * Q z) := by
rw [← addZ_eq' hP hQ, mul_div_cancel_right₀ _ <| mul_ne_zero hPz hQz]
lemma addZ_smul (P Q : Fin 3 → R) (u v : R) :
W'.addZ (u • P) (v • Q) = (u * v) ^ 2 * W'.addZ P Q := by
simp only [addZ, smul_fin3_ext]
ring1
lemma addZ_self (P : Fin 3 → R) : W'.addZ P P = 0 := by
rw [addZ]
ring1
lemma addZ_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : W'.addZ P Q = P y ^ 2 * Q z * Q z := by
rw [addZ, hPz, X_eq_zero_of_Z_eq_zero hP hPz]
ring1
lemma addZ_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hQz : Q z = 0) : W'.addZ P Q = -(Q y ^ 2 * P z) * P z := by
rw [addZ, hQz, X_eq_zero_of_Z_eq_zero hQ hQz]
ring1
lemma addZ_of_X_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) : W'.addZ P Q = 0 := by
apply eq_zero_of_ne_zero_of_mul_right_eq_zero <| mul_ne_zero hPz hQz
rw [addZ_eq' hP hQ, hx, sub_self, zero_pow three_ne_zero]
lemma addZ_ne_zero_of_X_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hx : P x * Q z ≠ Q x * P z) : W'.addZ P Q ≠ 0 :=
addZ_eq' hP hQ ▸ left_ne_zero_of_mul <| pow_ne_zero 3 <| sub_ne_zero.mpr hx
lemma isUnit_addZ_of_X_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hx : P x * Q z ≠ Q x * P z) : IsUnit <| W.addZ P Q :=
(addZ_ne_zero_of_X_ne hP hQ hx).isUnit
private lemma toAffine_slope_of_ne [DecidableEq F] {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ≠ Q x * P z) :
W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z) =
(P y * Q z - Q y * P z) / (P x * Q z - Q x * P z) := by
simp [field, Affine.slope_of_X_ne <| by rwa [ne_eq, ← X_eq_iff hPz hQz]]
variable (W') in
/-- The `X`-coordinate of a representative of `P + Q` for two distinct projective point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addX (P Q : Fin 3 → R) : R :=
-P x * Q y ^ 2 * P z + Q x * P y ^ 2 * Q z - 2 * P x * P y * Q y * Q z + 2 * Q x * P y * Q y * P z
- W'.a₁ * P x ^ 2 * Q y * Q z + W'.a₁ * Q x ^ 2 * P y * P z + W'.a₂ * P x ^ 2 * Q x * Q z
- W'.a₂ * P x * Q x ^ 2 * P z - W'.a₃ * P x * P y * Q z ^ 2 + W'.a₃ * Q x * Q y * P z ^ 2
- 2 * W'.a₃ * P x * Q y * P z * Q z + 2 * W'.a₃ * Q x * P y * P z * Q z
+ W'.a₄ * P x ^ 2 * Q z ^ 2 - W'.a₄ * Q x ^ 2 * P z ^ 2 + 3 * W'.a₆ * P x * P z * Q z ^ 2
- 3 * W'.a₆ * Q x * P z ^ 2 * Q z
lemma addX_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q) :
W'.addX P Q * (P z * Q z) ^ 2 =
((P y * Q z - Q y * P z) ^ 2 * P z * Q z
+ W'.a₁ * (P y * Q z - Q y * P z) * P z * Q z * (P x * Q z - Q x * P z)
- W'.a₂ * P z * Q z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2
- Q x * P z * (P x * Q z - Q x * P z) ^ 2) * (P x * Q z - Q x * P z) := by
linear_combination (norm := (rw [addX]; ring1))
(2 * Q x * P z * Q z ^ 3 - P x * Q z ^ 4) * (equation_iff _).mp hP
+ (Q x * P z ^ 4 - 2 * P x * P z ^ 3 * Q z) * (equation_iff _).mp hQ
lemma addX_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) : W.addX P Q =
((P y * Q z - Q y * P z) ^ 2 * P z * Q z
+ W.a₁ * (P y * Q z - Q y * P z) * P z * Q z * (P x * Q z - Q x * P z)
- W.a₂ * P z * Q z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2
- Q x * P z * (P x * Q z - Q x * P z) ^ 2) * (P x * Q z - Q x * P z) / (P z * Q z) ^ 2 := by
rw [← addX_eq' hP hQ, mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
lemma addX_smul (P Q : Fin 3 → R) (u v : R) :
W'.addX (u • P) (v • Q) = (u * v) ^ 2 * W'.addX P Q := by
simp only [addX, smul_fin3_ext]
ring1
lemma addX_self (P : Fin 3 → R) : W'.addX P P = 0 := by
rw [addX]
ring1
lemma addX_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : W'.addX P Q = P y ^ 2 * Q z * Q x := by
rw [addX, hPz, X_eq_zero_of_Z_eq_zero hP hPz]
ring1
lemma addX_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hQz : Q z = 0) : W'.addX P Q = -(Q y ^ 2 * P z) * P x := by
rw [addX, hQz, X_eq_zero_of_Z_eq_zero hQ hQz]
ring1
lemma addX_of_X_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) : W'.addX P Q = 0 := by
apply eq_zero_of_ne_zero_of_mul_right_eq_zero <| pow_ne_zero 2 <| mul_ne_zero hPz hQz
rw [addX_eq' hP hQ, hx]
ring1
private lemma toAffine_addX_of_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {n d : F}
(hd : d ≠ 0) : W.toAffine.addX (P x / P z) (Q x / Q z) (n / d) =
(n ^ 2 * P z * Q z + W.a₁ * n * P z * Q z * d - W.a₂ * P z * Q z * d ^ 2 - P x * Q z * d ^ 2
- Q x * P z * d ^ 2) * d / (P z * Q z) ^ 2 / (d ^ 3 / (P z * Q z)) := by
simp [field]
lemma addX_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ≠ Q x * P z) : W.addX P Q / W.addZ P Q =
W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
rw [addX_eq hP hQ hPz hQz, addZ_eq hP hQ hPz hQz, toAffine_slope_of_ne hPz hQz hx,
toAffine_addX_of_ne hPz hQz <| sub_ne_zero.mpr hx]
variable (W') in
/-- The `Y`-coordinate of a representative of `-(P + Q)` for two distinct projective point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def negAddY (P Q : Fin 3 → R) : R :=
-3 * P x ^ 2 * Q x * Q y + 3 * P x * Q x ^ 2 * P y - P y ^ 2 * Q y * Q z + P y * Q y ^ 2 * P z
+ W'.a₁ * P x * Q y ^ 2 * P z - W'.a₁ * Q x * P y ^ 2 * Q z - W'.a₂ * P x ^ 2 * Q y * Q z
+ W'.a₂ * Q x ^ 2 * P y * P z + 2 * W'.a₂ * P x * Q x * P y * Q z
- 2 * W'.a₂ * P x * Q x * Q y * P z - W'.a₃ * P y ^ 2 * Q z ^ 2 + W'.a₃ * Q y ^ 2 * P z ^ 2
+ W'.a₄ * P x * P y * Q z ^ 2 - 2 * W'.a₄ * P x * Q y * P z * Q z
+ 2 * W'.a₄ * Q x * P y * P z * Q z - W'.a₄ * Q x * Q y * P z ^ 2
+ 3 * W'.a₆ * P y * P z * Q z ^ 2 - 3 * W'.a₆ * Q y * P z ^ 2 * Q z
lemma negAddY_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q) :
W'.negAddY P Q * (P z * Q z) ^ 2 =
(P y * Q z - Q y * P z) * ((P y * Q z - Q y * P z) ^ 2 * P z * Q z
+ W'.a₁ * (P y * Q z - Q y * P z) * P z * Q z * (P x * Q z - Q x * P z)
- W'.a₂ * P z * Q z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2
- Q x * P z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2)
+ P y * Q z * (P x * Q z - Q x * P z) ^ 3 := by
linear_combination (norm := (rw [negAddY]; ring1))
(2 * Q y * P z * Q z ^ 3 - P y * Q z ^ 4) * (equation_iff _).mp hP
+ (Q y * P z ^ 4 - 2 * P y * P z ^ 3 * Q z) * (equation_iff _).mp hQ
lemma negAddY_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) : W.negAddY P Q =
((P y * Q z - Q y * P z) * ((P y * Q z - Q y * P z) ^ 2 * P z * Q z
+ W.a₁ * (P y * Q z - Q y * P z) * P z * Q z * (P x * Q z - Q x * P z)
- W.a₂ * P z * Q z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2
- Q x * P z * (P x * Q z - Q x * P z) ^ 2 - P x * Q z * (P x * Q z - Q x * P z) ^ 2)
+ P y * Q z * (P x * Q z - Q x * P z) ^ 3) / (P z * Q z) ^ 2 := by
rw [← negAddY_eq' hP hQ, mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
lemma negAddY_smul (P Q : Fin 3 → R) (u v : R) :
W'.negAddY (u • P) (v • Q) = (u * v) ^ 2 * W'.negAddY P Q := by
simp only [negAddY, smul_fin3_ext]
ring1
lemma negAddY_self (P : Fin 3 → R) : W'.negAddY P P = 0 := by
rw [negAddY]
ring1
lemma negAddY_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : W'.negAddY P Q = P y ^ 2 * Q z * W'.negY Q := by
rw [negAddY, hPz, X_eq_zero_of_Z_eq_zero hP hPz, negY]
ring1
lemma negAddY_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hQz : Q z = 0) : W'.negAddY P Q = -(Q y ^ 2 * P z) * W'.negY P := by
rw [negAddY, hQz, X_eq_zero_of_Z_eq_zero hQ hQz, negY]
ring1
lemma negAddY_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z = Q x * P z) :
W'.negAddY P Q * (P z * Q z) ^ 2 = (P y * Q z - Q y * P z) ^ 3 * (P z * Q z) := by
rw [negAddY_eq' hP hQ, hx]
ring1
lemma negAddY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) : W.negAddY P Q = -addU P Q := by
rw [addU, neg_div, neg_neg, ← mul_div_mul_right _ _ <| mul_ne_zero hPz hQz,
← negAddY_of_X_eq' hP hQ hx, ← sq,
mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
private lemma toAffine_negAddY_of_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {n d : F}
(hd : d ≠ 0) : W.toAffine.negAddY (P x / P z) (Q x / Q z) (P y / P z) (n / d) =
(n * (n ^ 2 * P z * Q z + W.a₁ * n * P z * Q z * d - W.a₂ * P z * Q z * d ^ 2
- P x * Q z * d ^ 2 - Q x * P z * d ^ 2 - P x * Q z * d ^ 2) + P y * Q z * d ^ 3)
/ (P z * Q z) ^ 2 / (d ^ 3 / (P z * Q z)) := by
rw [Affine.negAddY, toAffine_addX_of_ne hPz hQz hd]
simp [field]
lemma negAddY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ≠ Q x * P z) : W.negAddY P Q / W.addZ P Q =
W.toAffine.negAddY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
rw [negAddY_eq hP hQ hPz hQz, addZ_eq hP hQ hPz hQz, toAffine_slope_of_ne hPz hQz hx,
toAffine_negAddY_of_ne hPz hQz <| sub_ne_zero.mpr hx]
variable (W') in
/-- The `Y`-coordinate of a representative of `P + Q` for two distinct projective point
representatives `P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `0`. -/
def addY (P Q : Fin 3 → R) : R :=
W'.negY ![W'.addX P Q, W'.negAddY P Q, W'.addZ P Q]
lemma addY_smul (P Q : Fin 3 → R) (u v : R) :
W'.addY (u • P) (v • Q) = (u * v) ^ 2 * W'.addY P Q := by
simp only [addY, negY_eq, negAddY_smul, addX_smul, addZ_smul]
ring1
lemma addY_self (P : Fin 3 → R) : W'.addY P P = 0 := by
simp only [addY, negY_eq, negAddY_self, addX_self, addZ_self, neg_zero, mul_zero, sub_zero]
lemma addY_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : W'.addY P Q = P y ^ 2 * Q z * Q y := by
rw [addY, negY_eq, negAddY_of_Z_eq_zero_left hP hPz, negY, addX_of_Z_eq_zero_left hP hPz,
addZ_of_Z_eq_zero_left hP hPz]
ring1
lemma addY_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hQz : Q z = 0) : W'.addY P Q = -(Q y ^ 2 * P z) * P y := by
rw [addY, negY_eq, negAddY_of_Z_eq_zero_right hQ hQz, negY, addX_of_Z_eq_zero_right hQ hQz,
addZ_of_Z_eq_zero_right hQ hQz]
ring1
lemma addY_of_X_eq' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) :
W'.addY P Q * (P z * Q z) ^ 3 = -(P y * Q z - Q y * P z) ^ 3 * (P z * Q z) ^ 2 := by
linear_combination (norm := (rw [addY, negY_eq, addX_of_X_eq hP hQ hPz hQz hx,
addZ_of_X_eq hP hQ hPz hQz hx]; ring1)) -(P z * Q z) * negAddY_of_X_eq' hP hQ hx
lemma addY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) : W.addY P Q = addU P Q := by
rw [addU, ← mul_div_mul_right _ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz,
← addY_of_X_eq' hP hQ hPz hQz hx, ← pow_succ',
mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
lemma addY_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ≠ Q x * P z) : W.addY P Q / W.addZ P Q =
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)) := by
erw [addY, negY_of_Z_ne_zero <| addZ_ne_zero_of_X_ne hP hQ hx, addX_of_Z_ne_zero hP hQ hPz hQz hx,
negAddY_of_Z_ne_zero hP hQ hPz hQz hx, Affine.addY]
variable (W') in
/-- The coordinates of a representative of `P + Q` for two distinct projective point representatives
`P` and `Q` on a Weierstrass curve.
If the representatives of `P` and `Q` are equal, then this returns the value `![0, 0, 0]`. -/
noncomputable def addXYZ (P Q : Fin 3 → R) : Fin 3 → R :=
![W'.addX P Q, W'.addY P Q, W'.addZ P Q]
lemma addXYZ_X (P Q : Fin 3 → R) : W'.addXYZ P Q x = W'.addX P Q :=
rfl
lemma addXYZ_Y (P Q : Fin 3 → R) : W'.addXYZ P Q y = W'.addY P Q :=
rfl
lemma addXYZ_Z (P Q : Fin 3 → R) : W'.addXYZ P Q z = W'.addZ P Q :=
rfl
lemma addXYZ_smul (P Q : Fin 3 → R) (u v : R) :
W'.addXYZ (u • P) (v • Q) = (u * v) ^ 2 • W'.addXYZ P Q := by
rw [addXYZ, addX_smul, addY_smul, addZ_smul, smul_fin3, addXYZ_X, addXYZ_Y, addXYZ_Z]
lemma addXYZ_self (P : Fin 3 → R) : W'.addXYZ P P = ![0, 0, 0] := by
rw [addXYZ, addX_self, addY_self, addZ_self]
lemma addXYZ_of_Z_eq_zero_left [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hPz : P z = 0) : W'.addXYZ P Q = (P y ^ 2 * Q z) • Q := by
rw [addXYZ, addX_of_Z_eq_zero_left hP hPz, addY_of_Z_eq_zero_left hP hPz,
addZ_of_Z_eq_zero_left hP hPz, smul_fin3]
lemma addXYZ_of_Z_eq_zero_right [NoZeroDivisors R] {P Q : Fin 3 → R} (hQ : W'.Equation Q)
(hQz : Q z = 0) : W'.addXYZ P Q = -(Q y ^ 2 * P z) • P := by
rw [addXYZ, addX_of_Z_eq_zero_right hQ hQz, addY_of_Z_eq_zero_right hQ hQz,
addZ_of_Z_eq_zero_right hQ hQz, smul_fin3]
lemma addXYZ_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z = Q x * P z) : W.addXYZ P Q = addU P Q • ![0, 1, 0] := by
erw [addXYZ, addX_of_X_eq hP hQ hPz hQz hx, addY_of_X_eq hP hQ hPz hQz hx,
addZ_of_X_eq hP hQ hPz hQz hx, smul_fin3, mul_zero, mul_one]
lemma addXYZ_of_Z_ne_zero [DecidableEq F] {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ≠ Q x * P z) : W.addXYZ P Q = W.addZ P Q •
![W.toAffine.addX (P x / P z) (Q x / Q z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)),
W.toAffine.addY (P x / P z) (Q x / Q z) (P y / P z)
(W.toAffine.slope (P x / P z) (Q x / Q z) (P y / P z) (Q y / Q z)), 1] := by
have hZ : IsUnit <| W.addZ P Q := isUnit_addZ_of_X_ne hP hQ hx
erw [addXYZ, smul_fin3, ← addX_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel,
← addY_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel, mul_one]
/-! ## Maps and base changes -/
variable (f : R →+* S) (P Q : Fin 3 → R)
@[simp]
lemma map_negY : (W'.map f).toProjective.negY (f ∘ P) = f (W'.negY P) := by
simp only [negY]
map_simp
@[simp]
lemma map_dblU (f : F →+* K) (P : Fin 3 → F) :
(W.map f).toProjective.dblU (f ∘ P) = f (W.dblU P) := by
simp only [dblU_eq]
map_simp
@[simp]
lemma map_dblZ : (W'.map f).toProjective.dblZ (f ∘ P) = f (W'.dblZ P) := by
simp only [dblZ, negY]
map_simp
@[simp]
lemma map_dblX : (W'.map f).toProjective.dblX (f ∘ P) = f (W'.dblX P) := by
simp only [dblX]
map_simp
@[simp]
lemma map_negDblY : (W'.map f).toProjective.negDblY (f ∘ P) = f (W'.negDblY P) := by
simp only [negDblY]
map_simp
@[simp]
lemma map_dblY : (W'.map f).toProjective.dblY (f ∘ P) = f (W'.dblY P) := by
simp only [dblY, negY_eq, map_negDblY, map_dblX, map_dblZ]
map_simp
@[simp]
lemma map_dblXYZ : (W'.map f).toProjective.dblXYZ (f ∘ P) = f ∘ dblXYZ W' P := by
simp only [dblXYZ, map_dblX, map_dblY, map_dblZ, comp_fin3]
@[simp]
lemma map_addU (f : F →+* K) (P Q : Fin 3 → F) : addU (f ∘ P) (f ∘ Q) = f (addU P Q) := by
simp only [addU]
map_simp
@[simp]
lemma map_addZ : (W'.map f).toProjective.addZ (f ∘ P) (f ∘ Q) = f (W'.addZ P Q) := by
simp only [addZ]
map_simp
@[simp]
lemma map_addX : (W'.map f).toProjective.addX (f ∘ P) (f ∘ Q) = f (W'.addX P Q) := by
simp only [addX]
map_simp
@[simp]
lemma map_negAddY : (W'.map f).toProjective.negAddY (f ∘ P) (f ∘ Q) = f (W'.negAddY P Q) := by
simp only [negAddY]
map_simp
@[simp]
lemma map_addY : (W'.map f).toProjective.addY (f ∘ P) (f ∘ Q) = f (W'.addY P Q) := by
simp only [addY, negY_eq, map_negAddY, map_addX, map_addZ]
map_simp
@[simp]
lemma map_addXYZ : (W'.map f).toProjective.addXYZ (f ∘ P) (f ∘ Q) = f ∘ addXYZ W' P Q := by
simp only [addXYZ, map_addX, map_addY, map_addZ, comp_fin3]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (f : A →ₐ[S] B) (P Q : Fin 3 → A)
lemma baseChange_negY :
(W'.baseChange B).toProjective.negY (f ∘ P) = f ((W'.baseChange A).toProjective.negY P) := by
rw [← RingHom.coe_coe, ← map_negY, map_baseChange]
lemma baseChange_dblU [Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebra R K] [Algebra S K]
[IsScalarTower R S K] (f : F →ₐ[S] K) (P : Fin 3 → F) :
(W'.baseChange K).toProjective.dblU (f ∘ P) = f ((W'.baseChange F).toProjective.dblU P) := by
rw [← RingHom.coe_coe, ← map_dblU, map_baseChange]
lemma baseChange_dblZ :
(W'.baseChange B).toProjective.dblZ (f ∘ P) = f ((W'.baseChange A).toProjective.dblZ P) := by
rw [← RingHom.coe_coe, ← map_dblZ, map_baseChange]
lemma baseChange_dblX :
(W'.baseChange B).toProjective.dblX (f ∘ P) = f ((W'.baseChange A).toProjective.dblX P) := by
rw [← RingHom.coe_coe, ← map_dblX, map_baseChange]
lemma baseChange_negDblY : (W'.baseChange B).toProjective.negDblY (f ∘ P) =
f ((W'.baseChange A).toProjective.negDblY P) := by
rw [← RingHom.coe_coe, ← map_negDblY, map_baseChange]
lemma baseChange_dblY :
(W'.baseChange B).toProjective.dblY (f ∘ P) = f ((W'.baseChange A).toProjective.dblY P) := by
rw [← RingHom.coe_coe, ← map_dblY, map_baseChange]
lemma baseChange_dblXYZ : (W'.baseChange B).toProjective.dblXYZ (f ∘ P) =
f ∘ (W'.baseChange A).toProjective.dblXYZ P := by
rw [← RingHom.coe_coe, ← map_dblXYZ, map_baseChange]
lemma baseChange_addX : (W'.baseChange B).toProjective.addX (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toProjective.addX P Q) := by
rw [← RingHom.coe_coe, ← map_addX, map_baseChange]
lemma baseChange_negAddY : (W'.baseChange B).toProjective.negAddY (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toProjective.negAddY P Q) := by
rw [← RingHom.coe_coe, ← map_negAddY, map_baseChange]
lemma baseChange_addY : (W'.baseChange B).toProjective.addY (f ∘ P) (f ∘ Q) =
f ((W'.baseChange A).toProjective.addY P Q) := by
rw [← RingHom.coe_coe, ← map_addY, map_baseChange]
lemma baseChange_addXYZ : (W'.baseChange B).toProjective.addXYZ (f ∘ P) (f ∘ Q) =
f ∘ (W'.baseChange A).toProjective.addXYZ P Q := by
rw [← RingHom.coe_coe, ← map_addXYZ, map_baseChange]
end Projective
end WeierstrassCurve |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/IdealSheaf/Subscheme.lean | import Mathlib.AlgebraicGeometry.Morphisms.Preimmersion
import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.AlgebraicGeometry.IdealSheaf.Basic
import Mathlib.CategoryTheory.Adjunction.Opposites
/-!
# Subscheme associated to an ideal sheaf
We construct the subscheme associated to an ideal sheaf.
## Main definition
* `AlgebraicGeometry.Scheme.IdealSheafData.subscheme`: The subscheme associated to an ideal sheaf.
* `AlgebraicGeometry.Scheme.IdealSheafData.subschemeι`: The inclusion from the subscheme.
* `AlgebraicGeometry.Scheme.Hom.image`: The scheme-theoretic image of a morphism.
* `AlgebraicGeometry.Scheme.kerAdjunction`:
The adjunction between taking kernels and taking the associated subscheme.
## Note
Some instances are in `Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion` and
`Mathlib/AlgebraicGeometry/Morphisms/Separated` because they need more API to prove.
-/
open CategoryTheory TopologicalSpace PrimeSpectrum Limits
universe u
namespace AlgebraicGeometry.Scheme.IdealSheafData
variable {X : Scheme.{u}}
variable (I : IdealSheafData X)
/-- `Spec (𝒪ₓ(U)/I(U))`, the object to be glued into the closed subscheme. -/
def glueDataObj (U : X.affineOpens) : Scheme :=
Spec <| .of <| Γ(X, U) ⧸ I.ideal U
/-- `Spec (𝒪ₓ(U)/I(U)) ⟶ Spec (𝒪ₓ(U)) = U`, the closed immersion into `U`. -/
noncomputable
def glueDataObjι (U : X.affineOpens) : I.glueDataObj U ⟶ U.1 :=
Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk _)) ≫ U.2.isoSpec.inv
instance (U : X.affineOpens) : IsPreimmersion (I.glueDataObjι U) :=
have : IsPreimmersion (Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk (I.ideal U)))) :=
.mk_SpecMap
(isClosedEmbedding_comap_of_surjective _ _ Ideal.Quotient.mk_surjective).isEmbedding
(RingHom.surjectiveOnStalks_of_surjective Ideal.Quotient.mk_surjective)
.comp _ _
lemma glueDataObjι_ι (U : X.affineOpens) : I.glueDataObjι U ≫ U.1.ι =
Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk _)) ≫ U.2.fromSpec := by
rw [glueDataObjι, Category.assoc]; rfl
lemma ker_glueDataObjι_appTop (U : X.affineOpens) :
RingHom.ker (I.glueDataObjι U).appTop.hom = (I.ideal U).comap U.1.topIso.hom.hom := by
let φ := CommRingCat.ofHom (Ideal.Quotient.mk (I.ideal U))
rw [← Ideal.mk_ker (I := I.ideal _)]
change RingHom.ker (Spec.map φ ≫ _).appTop.hom = (RingHom.ker φ.hom).comap _
rw [← RingHom.ker_equiv_comp _ (Scheme.ΓSpecIso _).commRingCatIsoToRingEquiv, RingHom.comap_ker,
RingEquiv.toRingHom_eq_coe, Iso.commRingCatIsoToRingEquiv_toRingHom, ← CommRingCat.hom_comp,
← CommRingCat.hom_comp]
congr 2
simp only [Scheme.Hom.comp_app, TopologicalSpace.Opens.map_top, Category.assoc,
Scheme.ΓSpecIso_naturality, Scheme.Opens.topIso_hom]
rw [← Scheme.Hom.appTop, U.2.isoSpec_inv_appTop, Category.assoc, Iso.inv_hom_id_assoc]
simp only [Scheme.Opens.topIso_hom]
open scoped Set.Notation in
lemma range_glueDataObjι (U : X.affineOpens) :
Set.range (I.glueDataObjι U) =
U.2.isoSpec.inv '' PrimeSpectrum.zeroLocus (I.ideal U) := by
simp only [glueDataObjι, Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp]
erw [range_comap_of_surjective]
swap; · exact Ideal.Quotient.mk_surjective
simp only [Ideal.mk_ker, CommRingCat.hom_ofHom]
lemma range_glueDataObjι_ι (U : X.affineOpens) :
Set.range (I.glueDataObjι U ≫ U.1.ι) = X.zeroLocus (U := U) (I.ideal U) ∩ U := by
simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp, range_glueDataObjι]
rw [← Set.image_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, IsAffineOpen.isoSpec_inv_ι,
IsAffineOpen.fromSpec_image_zeroLocus]
/-- The underlying space of `Spec (𝒪ₓ(U)/I(U))` is homeomorphic to its image in `X`. -/
noncomputable
def glueDataObjCarrierIso (U : X.affineOpens) :
(I.glueDataObj U).carrier ≅ TopCat.of ↑(X.zeroLocus (U := U) (I.ideal U) ∩ U) :=
TopCat.isoOfHomeo ((I.glueDataObjι U ≫ U.1.ι).isEmbedding.toHomeomorph.trans
(.setCongr (I.range_glueDataObjι_ι U)))
/-- The open immersion `Spec Γ(𝒪ₓ/I, U) ⟶ Spec Γ(𝒪ₓ/I, V)` if `U ≤ V`. -/
noncomputable
def glueDataObjMap {U V : X.affineOpens} (h : U ≤ V) : I.glueDataObj U ⟶ I.glueDataObj V :=
Spec.map (CommRingCat.ofHom (Ideal.quotientMap _ _ (I.ideal_le_comap_ideal h)))
lemma isLocalization_away {U V : X.affineOpens}
(h : U ≤ V) (f : Γ(X, V.1)) (hU : U = X.affineBasicOpen f) :
letI := (Ideal.quotientMap _ _ (I.ideal_le_comap_ideal h)).toAlgebra
IsLocalization.Away (Ideal.Quotient.mk (I.ideal V) f) (Γ(X, U) ⧸ (I.ideal U)) := by
letI := (Ideal.quotientMap _ _ (I.ideal_le_comap_ideal h)).toAlgebra
let f' : Γ(X, V) ⧸ I.ideal V := Ideal.Quotient.mk _ f
letI := (X.presheaf.map (homOfLE (X := X.Opens) h).op).hom.toAlgebra
have : IsLocalization.Away f Γ(X, U) := by
subst hU; exact V.2.isLocalization_of_eq_basicOpen _ _ rfl
simp only [IsLocalization.Away, ← Submonoid.map_powers]
refine IsLocalization.of_surjective _ _ _ Ideal.Quotient.mk_surjective _
Ideal.Quotient.mk_surjective ?_ ?_
· simp [RingHom.algebraMap_toAlgebra, Ideal.quotientMap_comp_mk]; rfl
· simp only [Ideal.mk_ker, RingHom.algebraMap_toAlgebra, I.map_ideal', le_refl]
instance isOpenImmersion_glueDataObjMap {V : X.affineOpens} (f : Γ(X, V.1)) :
IsOpenImmersion (I.glueDataObjMap (X.affineBasicOpen_le f)) := by
letI := (Ideal.quotientMap _ _ (I.ideal_le_comap_ideal (X.affineBasicOpen_le f))).toAlgebra
have := I.isLocalization_away (X.affineBasicOpen_le f) f rfl
exact IsOpenImmersion.of_isLocalization (Ideal.Quotient.mk _ f)
lemma opensRange_glueDataObjMap {V : X.affineOpens} (f : Γ(X, V.1)) :
(I.glueDataObjMap (X.affineBasicOpen_le f)).opensRange =
(I.glueDataObjι V) ⁻¹ᵁ (V.1.ι ⁻¹ᵁ X.basicOpen f) := by
letI := (Ideal.quotientMap _ _ (I.ideal_le_comap_ideal (X.affineBasicOpen_le f))).toAlgebra
let f' : Γ(X, V) ⧸ I.ideal V := Ideal.Quotient.mk _ f
have := I.isLocalization_away (X.affineBasicOpen_le f) f rfl
ext1
refine (localization_away_comap_range _ f').trans ?_
rw [← comap_basicOpen, ← V.2.fromSpec_preimage_basicOpen,
← Scheme.Hom.comp_preimage, glueDataObjι_ι]
rfl
@[reassoc (attr := simp)]
lemma glueDataObjMap_glueDataObjι {U V : X.affineOpens} (h : U ≤ V) :
I.glueDataObjMap h ≫ I.glueDataObjι V = I.glueDataObjι U ≫ X.homOfLE h := by
rw [glueDataObjMap, glueDataObjι, ← Spec.map_comp_assoc, ← CommRingCat.ofHom_comp,
Ideal.quotientMap_comp_mk, CommRingCat.ofHom_comp, Spec.map_comp_assoc, glueDataObjι,
Category.assoc]
congr 1
rw [Iso.eq_inv_comp, IsAffineOpen.isoSpec_hom, CommRingCat.ofHom_hom]
erw [Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_assoc U.1 V.1 h]
rw [← IsAffineOpen.isoSpec_hom V.2, Iso.hom_inv_id, Category.comp_id]
lemma ideal_le_ker_glueDataObjι (U V : X.affineOpens) :
I.ideal V ≤ RingHom.ker (U.1.ι.app V.1 ≫ (I.glueDataObjι U).app _).hom := by
intro x hx
apply (I.glueDataObj U).IsSheaf.section_ext
intro p hp
obtain ⟨f, g, hfg, hf⟩ := exists_basicOpen_le_affine_inter U.2 V.2 (I.glueDataObjι U p).1
⟨(I.glueDataObjι U p).2, hp⟩
refine ⟨(I.glueDataObjι U ⁻¹ᵁ U.1.ι ⁻¹ᵁ X.basicOpen f),
fun x hx ↦ X.basicOpen_le g (hfg ▸ hx), hf, ?_⟩
have := Hom.isIso_app (I.glueDataObjMap (X.affineBasicOpen_le f))
(I.glueDataObjι U ⁻¹ᵁ U.1.ι ⁻¹ᵁ X.basicOpen f) (by rw [opensRange_glueDataObjMap])
apply ((ConcreteCategory.isIso_iff_bijective _).mp this).1
simp only [map_zero, ← RingHom.comp_apply,
← CommRingCat.hom_comp, Category.assoc]
simp only [Scheme.Hom.app_eq_appLE, homOfLE_leOfHom, Scheme.Hom.map_appLE,
Scheme.Hom.appLE_comp_appLE, Category.assoc, glueDataObjMap_glueDataObjι_assoc]
rw [Scheme.Hom.appLE]
have H : (X.homOfLE (X.basicOpen_le f) ≫ U.1.ι) ⁻¹ᵁ V.1 = ⊤ := by
simp only [Scheme.homOfLE_ι, ← top_le_iff]
exact fun x _ ↦ (hfg.trans_le (X.basicOpen_le g)) x.2
simp only [Scheme.Hom.comp_app, Scheme.Opens.ι_app, Scheme.homOfLE_app, ← Functor.map_comp_assoc,
Scheme.Hom.app_eq _ H, Scheme.Opens.toScheme_presheaf_map, ← Functor.map_comp, Category.assoc]
simp only [CommRingCat.hom_comp, RingHom.comp_apply]
convert RingHom.map_zero _ using 2
rw [← RingHom.mem_ker, ker_glueDataObjι_appTop, ← Ideal.mem_comap, Ideal.comap_comap,
← CommRingCat.hom_comp]
simp only [Scheme.affineBasicOpen_coe, homOfLE_leOfHom, Scheme.Hom.comp_base,
TopologicalSpace.Opens.map_comp_obj, eqToHom_op, eqToHom_unop, ← Functor.map_comp,
Scheme.Opens.topIso_hom, Category.assoc]
exact I.ideal_le_comap_ideal (U := X.affineBasicOpen f) (V := V)
(hfg.trans_le (X.basicOpen_le g)) hx
/-- (Implementation) The intersections `Spec Γ(𝒪ₓ/I, U) ∩ V` useful for gluing. -/
private noncomputable
abbrev glueDataObjPullback (U V : X.affineOpens) : Scheme :=
pullback (I.glueDataObjι U) (X.homOfLE (U := U.1 ⊓ V.1) inf_le_left)
/-- (Implementation) Transition maps in the glue data for `𝒪ₓ/I`. -/
private noncomputable
def glueDataT (U V : X.affineOpens) :
I.glueDataObjPullback U V ⟶ I.glueDataObjPullback V U := by
letI F := pullback.snd (I.glueDataObjι U) (X.homOfLE (inf_le_left (b := V.1)))
refine pullback.lift ((F ≫ X.homOfLE inf_le_right ≫
V.2.isoSpec.hom).liftQuotient _ ?_) (F ≫ X.homOfLE (by simp)) ?_
· intro x hx
simp only [Hom.comp_app, Hom.comp_base, TopologicalSpace.Opens.map_comp_obj,
TopologicalSpace.Opens.map_top, homOfLE_app, homOfLE_leOfHom, Category.assoc, RingHom.mem_ker]
convert_to (U.1.ι.app V.1 ≫ (F ≫ X.homOfLE inf_le_left).appLE (U.1.ι ⁻¹ᵁ V.1) ⊤
(by rw [← Scheme.Hom.comp_preimage, Category.assoc, X.homOfLE_ι]
exact fun x _ ↦ by simpa using (F x).2.2)).hom x = 0 using 3
· simp only [homOfLE_leOfHom, Opens.ι_app, Hom.comp_appLE, homOfLE_app]
have H : ⊤ ≤ X.homOfLE (inf_le_left (b := V.1)) ⁻¹ᵁ U.1.ι ⁻¹ᵁ V.1 := by
rw [← Scheme.Hom.comp_preimage, X.homOfLE_ι]; exact fun x _ ↦ by simpa using x.2.2
rw [← F.map_appLE (show ⊤ ≤ F ⁻¹ᵁ ⊤ from le_rfl) (homOfLE H).op]
simp only [homOfLE_leOfHom, Opens.toScheme_presheaf_map, Quiver.Hom.unop_op,
Hom.opensFunctor_map_homOfLE, ← Functor.map_comp_assoc, IsAffineOpen.isoSpec_hom_appTop,
Opens.topIso_inv, eqToHom_op, homOfLE_leOfHom, Category.assoc,
Iso.inv_hom_id_assoc, F.app_eq_appLE]
rfl
· have : (U.1.ι.app V.1 ≫ (I.glueDataObjι U).app (U.1.ι ⁻¹ᵁ V.1)).hom x = 0 :=
I.ideal_le_ker_glueDataObjι U V hx
simp_rw [F, ← pullback.condition]
simp only [Scheme.Opens.ι_app, CommRingCat.hom_comp, RingHom.coe_comp,
Function.comp_apply, Scheme.Hom.appLE, Scheme.Hom.comp_app, Category.assoc] at this ⊢
simp only [this, map_zero]
· conv_lhs => enter [2]; rw [glueDataObjι]
rw [Scheme.Hom.liftQuotient_comp_assoc, Category.assoc, Category.assoc, Iso.hom_inv_id,
Category.comp_id, Category.assoc, X.homOfLE_homOfLE]
@[reassoc (attr := simp)]
private lemma glueDataT_snd (U V : X.affineOpens) :
I.glueDataT U V ≫ pullback.snd _ _ = pullback.snd _ _ ≫ X.homOfLE (by simp) :=
pullback.lift_snd _ _ _
@[reassoc (attr := simp)]
private lemma glueDataT_fst (U V : X.affineOpens) :
I.glueDataT U V ≫ pullback.fst _ _ ≫ glueDataObjι _ _ =
pullback.snd _ _ ≫ X.homOfLE inf_le_right := by
refine (pullback.lift_fst_assoc _ _ _ _).trans ?_
conv_lhs => enter [2]; rw [glueDataObjι]
rw [Scheme.Hom.liftQuotient_comp_assoc, Category.assoc, Category.assoc, Iso.hom_inv_id,
Category.comp_id]
/-- (Implementation) `t'` in the glue data for `𝒪ₓ/I`. -/
private noncomputable
def glueDataT'Aux (U V W U₀ : X.affineOpens) (hU₀ : U.1 ⊓ W ≤ U₀) :
pullback
(pullback.fst _ _ : I.glueDataObjPullback U V ⟶ _)
(pullback.fst _ _ : I.glueDataObjPullback U W ⟶ _) ⟶ I.glueDataObjPullback V U₀ :=
pullback.lift
(pullback.fst _ _ ≫ I.glueDataT U V ≫ pullback.fst _ _)
(IsOpenImmersion.lift (V.1 ⊓ U₀.1).ι
(pullback.fst _ _ ≫ pullback.fst _ _ ≫ I.glueDataObjι U ≫ U.1.ι) (by
simp only [Scheme.Opens.range_ι, TopologicalSpace.Opens.coe_inf, Set.subset_inter_iff]
constructor
· rw [pullback.condition_assoc (f := I.glueDataObjι U), X.homOfLE_ι,
← Category.assoc, Scheme.Hom.comp_base, TopCat.coe_comp]
exact (Set.range_comp_subset_range _ _).trans (by simp)
· rw [pullback.condition_assoc, pullback.condition_assoc, X.homOfLE_ι,
← Category.assoc, Scheme.Hom.comp_base, TopCat.coe_comp]
exact (Set.range_comp_subset_range _ _).trans (by simpa using hU₀))) (by
rw [← cancel_mono (Scheme.Opens.ι _)]
simp [pullback.condition_assoc])
@[reassoc (attr := simp)]
private lemma glueDataT'Aux_fst (U V W U₀ : X.affineOpens) (hU₀ : U.1 ⊓ W ≤ U₀) :
I.glueDataT'Aux U V W U₀ hU₀ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ I.glueDataT U V ≫ pullback.fst _ _ := pullback.lift_fst _ _ _
@[reassoc (attr := simp)]
private lemma glueDataT'Aux_snd_ι (U V W U₀ : X.affineOpens) (hU₀ : U.1 ⊓ W ≤ U₀) :
I.glueDataT'Aux U V W U₀ hU₀ ≫ pullback.snd _ _ ≫ (V.1 ⊓ U₀.1).ι =
pullback.fst _ _ ≫ pullback.fst _ _ ≫ I.glueDataObjι U ≫ U.1.ι :=
(pullback.lift_snd_assoc _ _ _ _).trans (IsOpenImmersion.lift_fac _ _ _)
/-- (Implementation) The glue data for `𝒪ₓ/I`. -/
@[simps]
private noncomputable
def glueData : Scheme.GlueData where
J := X.affineOpens
U := I.glueDataObj
V ij := I.glueDataObjPullback ij.1 ij.2
f i j := pullback.fst _ _
f_id i :=
have : IsIso (X.homOfLE (inf_le_left (a := i.1) (b := i.1))) :=
⟨X.homOfLE (by simp), by simp, by simp⟩
inferInstance
t i j := I.glueDataT i j
t_id i := by
apply pullback.hom_ext
· rw [← cancel_mono (glueDataObjι _ _)]
simp [pullback.condition]
· simp
t' i j k := pullback.lift
(I.glueDataT'Aux _ _ _ _ inf_le_right) (I.glueDataT'Aux _ _ _ _ inf_le_left) (by simp)
t_fac i j k := by
apply pullback.hom_ext
· rw [← cancel_mono (glueDataObjι _ _)]
simp
· rw [← cancel_mono (Scheme.Opens.ι _)]
simp [pullback.condition_assoc]
cocycle i j k := by
dsimp only
apply pullback.hom_ext
· apply pullback.hom_ext
· rw [← cancel_mono (glueDataObjι _ _), ← cancel_mono (Scheme.Opens.ι _)]
simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
glueDataT'Aux_fst, limit.lift_π_assoc, cospan_left, glueDataT_fst, Scheme.homOfLE_ι,
glueDataT'Aux_snd_ι, glueDataT'Aux_fst_assoc, glueDataT_fst_assoc, Category.id_comp]
rw [pullback.condition_assoc (f := I.glueDataObjι i)]
simp
· rw [← cancel_mono (Scheme.Opens.ι _)]
simp [pullback.condition_assoc]
· apply pullback.hom_ext
· rw [← cancel_mono (glueDataObjι _ _), ← cancel_mono (Scheme.Opens.ι _)]
simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
glueDataT'Aux_fst, limit.lift_π_assoc, cospan_left, glueDataT_fst, Scheme.homOfLE_ι,
glueDataT'Aux_snd_ι, glueDataT'Aux_fst_assoc, glueDataT_fst_assoc, Category.id_comp]
rw [← pullback.condition_assoc, pullback.condition_assoc (f := I.glueDataObjι i),
X.homOfLE_ι]
· rw [← cancel_mono (Scheme.Opens.ι _)]
simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
glueDataT'Aux_snd_ι, limit.lift_π_assoc, cospan_left, glueDataT'Aux_fst_assoc,
glueDataT_fst_assoc, Scheme.homOfLE_ι, Category.id_comp]
rw [pullback.condition_assoc, pullback.condition_assoc, X.homOfLE_ι]
f_open i j := inferInstance
/-- (Implementation) The map from `Spec(𝒪ₓ/I)` to `X`. See `IdealSheafData.subschemeι` instead. -/
private noncomputable
def gluedTo : I.glueData.glued ⟶ X :=
Multicoequalizer.desc _ _ (fun i ↦ I.glueDataObjι i ≫ i.1.ι)
(by simp [GlueData.diagram, pullback.condition_assoc])
@[reassoc (attr := simp)]
private lemma ι_gluedTo (U : X.affineOpens) :
I.glueData.ι U ≫ I.gluedTo = I.glueDataObjι U ≫ U.1.ι :=
Multicoequalizer.π_desc _ _ _ _ _
@[reassoc (attr := simp)]
private lemma glueDataObjMap_ι (U V : X.affineOpens) (h : U ≤ V) :
I.glueDataObjMap h ≫ I.glueData.ι V = I.glueData.ι U := by
have : IsIso (X.homOfLE inf_le_left : (U.1 ⊓ V.1).toScheme ⟶ U) :=
⟨X.homOfLE (by simpa), by simp, by simp⟩
have H : inv (X.homOfLE inf_le_left : (U.1 ⊓ V.1).toScheme ⟶ U) = X.homOfLE (by simpa) := by
rw [eq_comm, ← hom_comp_eq_id]; simp
have := I.glueData.glue_condition U V
simp only [glueData_J, glueData_V, glueData_t, glueData_U, glueData_f] at this
rw [← IsIso.inv_comp_eq] at this
rw [← Category.id_comp (I.glueData.ι U), ← this]
simp_rw [← Category.assoc]
congr 1
rw [← cancel_mono (glueDataObjι _ _)]
simp [pullback_inv_fst_snd_of_right_isIso_assoc, H]
private lemma gluedTo_injective :
Function.Injective I.gluedTo := by
intro a b e
obtain ⟨ia, a : I.glueDataObj ia, rfl⟩ :=
I.glueData.toGlueData.ι_jointly_surjective forget a
obtain ⟨ib, b : I.glueDataObj ib, rfl⟩ :=
I.glueData.toGlueData.ι_jointly_surjective forget b
change I.glueData.ι ia a = I.glueData.ι ib b
have : (I.glueDataObjι ia a).1 = (I.glueDataObjι ib b).1 := by
have : (I.glueData.ι ia ≫ I.gluedTo) a = (I.glueData.ι ib ≫ I.gluedTo) b := e
rwa [ι_gluedTo, ι_gluedTo] at this
obtain ⟨f, g, hfg, H⟩ := exists_basicOpen_le_affine_inter ia.2 ib.2
(I.glueDataObjι ia a).1
⟨(I.glueDataObjι ia a).2, this ▸ (I.glueDataObjι ib b).2⟩
have hmem (W) (hW : W = X.affineBasicOpen g) :
b ∈ Set.range (I.glueDataObjMap (hW.trans_le (X.affineBasicOpen_le g))) := by
subst hW
refine (I.opensRange_glueDataObjMap g).ge ?_
change (I.glueDataObjι ib b).1 ∈ X.basicOpen g
rwa [← this, ← hfg]
obtain ⟨a, rfl⟩ := (I.opensRange_glueDataObjMap f).ge H
obtain ⟨b, rfl⟩ := hmem (X.affineBasicOpen f) (Subtype.ext hfg)
simp only [glueData_U, ← Scheme.Hom.comp_apply, glueDataObjMap_glueDataObjι] at this ⊢
simp only [Scheme.affineBasicOpen_coe, Scheme.Hom.comp_base, TopCat.comp_app,
Scheme.homOfLE_apply, SetLike.coe_eq_coe] at this
obtain rfl := (I.glueDataObjι (X.affineBasicOpen f)).isEmbedding.injective this
simp only [glueDataObjMap_ι]
lemma range_glueDataObjι_ι_eq_support_inter (U : X.affineOpens) :
Set.range (I.glueDataObjι U ≫ U.1.ι) = (I.support : Set X) ∩ U :=
(I.range_glueDataObjι_ι U).trans (I.coe_support_inter U).symm
private lemma range_gluedTo :
Set.range I.gluedTo = I.support := by
refine subset_antisymm (Set.range_subset_iff.mpr fun x ↦ ?_) ?_
· obtain ⟨ix, x : I.glueDataObj ix, rfl⟩ :=
I.glueData.toGlueData.ι_jointly_surjective forget x
change (I.glueData.ι _ ≫ I.gluedTo) x ∈ I.support
rw [ι_gluedTo]
exact ((I.range_glueDataObjι_ι_eq_support_inter ix).le ⟨_, rfl⟩).1
· intro x hx
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
obtain ⟨y, rfl⟩ := (I.range_glueDataObjι_ι_eq_support_inter ⟨U, hU⟩).ge ⟨hx, hxU⟩
rw [← ι_gluedTo]
exact ⟨_, rfl⟩
private lemma range_glueData_ι (U : X.affineOpens) :
Set.range (Scheme.Hom.toLRSHom' (X := I.glueDataObj U) <|
I.glueData.ι U).base = (I.gluedTo ⁻¹ᵁ U : Set I.glueData.glued) := by
simp only [TopologicalSpace.Opens.map_coe]
apply I.gluedTo_injective.image_injective
rw [← Set.range_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, ι_gluedTo,
range_glueDataObjι_ι, Set.image_preimage_eq_inter_range, range_gluedTo,
← coe_support_inter, Set.inter_comm]
/-- (Implementation) identifying `Spec(Γ(X, U)/I(U))` with its image in `Spec(𝒪ₓ/I)`. -/
private noncomputable
def glueDataObjIso (U : X.affineOpens) :
I.glueDataObj U ≅ I.gluedTo ⁻¹ᵁ U :=
IsOpenImmersion.isoOfRangeEq (I.glueData.ι U) (Scheme.Opens.ι _) (by
simp only [Scheme.Opens.range_ι, TopologicalSpace.Opens.map_coe, range_glueData_ι])
@[reassoc (attr := simp)]
private lemma glueDataObjIso_hom_ι (U : X.affineOpens) :
(I.glueDataObjIso U).hom ≫ (I.gluedTo ⁻¹ᵁ U).ι = I.glueData.ι U :=
IsOpenImmersion.isoOfRangeEq_hom_fac _ _ _
private lemma glueDataObjIso_hom_restrict (U : X.affineOpens) :
(I.glueDataObjIso U).hom ≫ I.gluedTo ∣_ ↑U = I.glueDataObjι U := by
rw [← cancel_mono U.1.ι]; simp
private instance : IsPreimmersion I.gluedTo := by
rw [IsZariskiLocalAtTarget.iff_of_iSup_eq_top (P := @IsPreimmersion)
_ (iSup_affineOpens_eq_top X)]
intro U
rw [← MorphismProperty.cancel_left_of_respectsIso @IsPreimmersion (I.glueDataObjIso U).hom,
glueDataObjIso_hom_restrict]
infer_instance
private instance : QuasiCompact I.gluedTo :=
⟨fun _ _ ↦ (Topology.IsClosedEmbedding.isProperMap
⟨I.gluedTo.isEmbedding, I.range_gluedTo ▸ I.support.isClosed⟩).isCompact_preimage⟩
/-- (Implementation) The underlying space of `Spec(𝒪ₓ/I)` is homeomorphic to the support of `I`. -/
private noncomputable
def gluedHomeo : I.glueData.glued ≃ₜ I.support :=
I.gluedTo.isEmbedding.toHomeomorph.trans (.setCongr I.range_gluedTo)
/-- The subscheme associated to an ideal sheaf. -/
noncomputable
def subscheme : Scheme :=
I.glueData.glued.restrict
(f := TopCat.ofHom (toContinuousMap I.gluedHomeo.symm))
I.gluedHomeo.symm.isOpenEmbedding
/-- (Implementation) The isomorphism between the subscheme and the glued scheme. -/
private noncomputable
def subschemeIso : I.subscheme ≅ I.glueData.glued :=
letI F := I.glueData.glued.ofRestrict (f := TopCat.ofHom (toContinuousMap I.gluedHomeo.symm))
I.gluedHomeo.symm.isOpenEmbedding
have : Epi F.base := ConcreteCategory.epi_of_surjective _ I.gluedHomeo.symm.surjective
letI := IsOpenImmersion.isIso F
asIso F
/-- The inclusion from the subscheme associated to an ideal sheaf. -/
noncomputable
def subschemeι : I.subscheme ⟶ X :=
(I.subschemeIso.hom ≫ I.gluedTo).copyBase Subtype.val <| by
ext x
change (I.gluedHomeo (I.gluedHomeo.symm x)).1 = x.1
rw [I.gluedHomeo.apply_symm_apply]
lemma subschemeι_apply (x : I.subscheme) : I.subschemeι x = x.1 := rfl
private lemma subschemeι_def : I.subschemeι = I.subschemeIso.hom ≫ I.gluedTo :=
Scheme.Hom.copyBase_eq _ _ _
/-- See `AlgebraicGeometry.Morphisms.ClosedImmersion` for the closed immersion version. -/
instance : IsPreimmersion I.subschemeι := by
rw [subschemeι_def]
infer_instance
instance : QuasiCompact I.subschemeι := by
rw [subschemeι_def]
infer_instance
@[simp]
lemma range_subschemeι : Set.range I.subschemeι = I.support := by
simp [← range_gluedTo, I.subschemeι_def, Set.range_comp]
private lemma opensRange_glueData_ι_subschemeIso_inv (U : X.affineOpens) :
(I.glueData.ι U ≫ I.subschemeIso.inv).opensRange = I.subschemeι ⁻¹ᵁ U := by
ext1
simp [Set.range_comp, I.range_glueData_ι, subschemeι_def, ← coe_homeoOfIso_symm,
← homeoOfIso_symm, ← Homeomorph.coe_symm_toEquiv, Equiv.image_symm_eq_preimage]
/-- The subscheme associated to an ideal sheaf `I` is covered by `Spec(Γ(X, U)/I(U))`. -/
noncomputable
def subschemeCover : I.subscheme.AffineOpenCover where
I₀ := X.affineOpens
X U := .of <| Γ(X, U) ⧸ I.ideal U
f U := I.glueData.ι U ≫ I.subschemeIso.inv
idx x := (X.openCoverOfIsOpenCover _ (iSup_affineOpens_eq_top X)).idx x.1
covers x := by
let U := (X.openCoverOfIsOpenCover _ (iSup_affineOpens_eq_top X)).idx x.1
obtain ⟨⟨y, hy : y ∈ U.1⟩, rfl : y = x.1⟩ :=
(X.openCoverOfIsOpenCover _ (iSup_affineOpens_eq_top X)).covers x.1
exact (I.opensRange_glueData_ι_subschemeIso_inv U).ge hy
@[simp]
lemma opensRange_subschemeCover_map (U : X.affineOpens) :
(I.subschemeCover.f U).opensRange = I.subschemeι ⁻¹ᵁ U :=
I.opensRange_glueData_ι_subschemeIso_inv U
@[simp]
lemma subschemeCover_map_subschemeι (U : X.affineOpens) :
I.subschemeCover.f U ≫ I.subschemeι = I.glueDataObjι U ≫ U.1.ι := by
simp [subschemeCover, subschemeι_def]
/-- `Γ(𝒪ₓ/I, U) ≅ 𝒪ₓ(U)/I(U)`. -/
noncomputable
def subschemeObjIso (U : X.affineOpens) :
Γ(I.subscheme, I.subschemeι ⁻¹ᵁ U) ≅ .of (Γ(X, U) ⧸ I.ideal U) :=
I.subscheme.presheaf.mapIso (eqToIso (by simp)).op ≪≫
(I.subschemeCover.f U).appIso _ ≪≫ Scheme.ΓSpecIso (.of (Γ(X, U) ⧸ I.ideal U))
lemma subschemeι_app (U : X.affineOpens) : I.subschemeι.app U =
CommRingCat.ofHom (Ideal.Quotient.mk (I.ideal U)) ≫
(I.subschemeObjIso U).inv := by
have := I.subschemeCover_map_subschemeι U
simp only [glueDataObjι, Category.assoc, IsAffineOpen.isoSpec_inv_ι] at this
replace this := Scheme.Hom.congr_app this U
simp only [Hom.comp_base, TopologicalSpace.Opens.map_comp_obj, Hom.comp_app,
IsAffineOpen.fromSpec_app_self, eqToHom_op, Category.assoc, Hom.naturality_assoc,
TopologicalSpace.Opens.map_top, ← ΓSpecIso_inv_naturality_assoc] at this
simp_rw [← Category.assoc, ← IsIso.comp_inv_eq] at this
simp only [← this, ← Functor.map_inv, inv_eqToHom, Category.assoc, eqToHom_unop,
← Functor.map_comp, IsIso.Iso.inv_inv, subschemeObjIso, Iso.trans_inv, Functor.mapIso_inv,
Iso.op_inv, eqToIso.inv, eqToHom_op, Iso.hom_inv_id_assoc, Hom.appIso_inv_naturality_assoc,
Functor.op_obj, Functor.op_map, unop_comp, unop_inv, Quiver.Hom.unop_op,
Hom.app_appIso_inv_assoc, TopologicalSpace.Opens.carrier_eq_coe, TopologicalSpace.Opens.map_coe,
homOfLE_leOfHom]
convert (Category.comp_id _).symm
exact CategoryTheory.Functor.map_id _ _
lemma subschemeι_app_surjective (U : X.affineOpens) :
Function.Surjective (I.subschemeι.app U) := by
rw [I.subschemeι_app U]
exact (I.subschemeObjIso U).commRingCatIsoToRingEquiv.symm.surjective.comp
Ideal.Quotient.mk_surjective
lemma ker_subschemeι_app (U : X.affineOpens) :
RingHom.ker (I.subschemeι.app U).hom = I.ideal U := by
rw [subschemeι_app]
let e : CommRingCat.of (Γ(X, U) ⧸ I.ideal U) ≅ Γ(I.subscheme, I.subschemeι ⁻¹ᵁ U) :=
(Scheme.ΓSpecIso _).symm ≪≫ ((I.subschemeCover.f U).appIso _).symm ≪≫
I.subscheme.presheaf.mapIso (eqToIso (by simp)).op
change RingHom.ker (e.commRingCatIsoToRingEquiv.toRingHom.comp
(Ideal.Quotient.mk (I.ideal U))) = _
rw [RingHom.ker_equiv_comp, Ideal.mk_ker]
@[simp]
lemma ker_subschemeι : I.subschemeι.ker = I := by
ext; simp [ker_subschemeι_app]
instance : IsEmpty (⊤ : X.IdealSheafData).subscheme := by
rw [← (subschemeι _).ker_eq_top_iff_isEmpty, ker_subschemeι]
/-- Given `I ≤ J`, this is the map `Spec(Γ(X, U)/J(U)) ⟶ Spec(Γ(X, U)/I(U))`. -/
noncomputable
def glueDataObjHom {I J : IdealSheafData X} (h : I ≤ J) (U) :
J.glueDataObj U ⟶ I.glueDataObj U :=
Spec.map (CommRingCat.ofHom (Ideal.Quotient.factor (h U)))
@[reassoc (attr := simp)]
lemma glueDataObjHom_ι {I J : IdealSheafData X} (h : I ≤ J) (U) :
glueDataObjHom h U ≫ I.glueDataObjι U = J.glueDataObjι U := by
rw [glueDataObjHom, glueDataObjι, glueDataObjι, ← Spec.map_comp_assoc, ← CommRingCat.ofHom_comp,
Ideal.Quotient.factor_comp_mk]
@[simp]
lemma glueDataObjHom_id {I : IdealSheafData X} (U) :
glueDataObjHom (le_refl I) U = 𝟙 _ := by
rw [← cancel_mono (I.glueDataObjι U)]
simp
@[reassoc (attr := simp)]
lemma glueDataObjHom_comp {I J K : IdealSheafData X} (hIJ : I ≤ J) (hJK : J ≤ K) (U) :
glueDataObjHom hJK U ≫ glueDataObjHom hIJ U = glueDataObjHom (hIJ.trans hJK) U := by
rw [← cancel_mono (I.glueDataObjι U)]
simp
/-- The inclusion of ideal sheaf induces an inclusion of subschemes -/
noncomputable
def inclusion {I J : IdealSheafData X} (h : I ≤ J) :
J.subscheme ⟶ I.subscheme :=
J.subschemeCover.openCover.glueMorphisms (fun U ↦ glueDataObjHom h U ≫ I.subschemeCover.f U)
(by
intro U V
simp only [← cancel_mono I.subschemeι, AffineOpenCover.openCover_X, glueDataObjHom_ι_assoc,
AffineOpenCover.openCover_f, Category.assoc, subschemeCover_map_subschemeι]
rw [← subschemeCover_map_subschemeι, pullback.condition_assoc, subschemeCover_map_subschemeι])
@[reassoc (attr := simp)]
lemma subSchemeCover_map_inclusion {I J : IdealSheafData X} (h : I ≤ J) (U) :
J.subschemeCover.f U ≫ inclusion h = glueDataObjHom h U ≫ I.subschemeCover.f U :=
J.subschemeCover.openCover.ι_glueMorphisms _ _ _
@[reassoc (attr := simp)]
lemma inclusion_subschemeι {I J : IdealSheafData X} (h : I ≤ J) :
inclusion h ≫ I.subschemeι = J.subschemeι :=
J.subschemeCover.openCover.hom_ext _ _ fun _ ↦ by simp
@[simp, reassoc]
lemma inclusion_id (I : IdealSheafData X) :
inclusion le_rfl = 𝟙 I.subscheme :=
I.subschemeCover.openCover.hom_ext _ _ fun _ ↦ by simp
@[reassoc (attr := simp)]
lemma inclusion_comp {I J K : IdealSheafData X} (h₁ : I ≤ J) (h₂ : J ≤ K) :
inclusion h₂ ≫ inclusion h₁ = inclusion (h₁.trans h₂) :=
K.subschemeCover.openCover.hom_ext _ _ fun _ ↦ by simp
/-- The functor taking an ideal sheaf to its associated subscheme. -/
@[simps]
noncomputable
def subschemeFunctor (Y : Scheme.{u}) : (IdealSheafData Y)ᵒᵖ ⥤ Over Y where
obj I := .mk I.unop.subschemeι
map {I J} h := Over.homMk (IdealSheafData.inclusion h.unop.le)
end IdealSheafData
noncomputable section image
open Limits
variable {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.affineOpens)
/-- The scheme-theoretic image of a morphism. -/
abbrev Hom.image : Scheme.{u} := f.ker.subscheme
/-- The embedding from the scheme-theoretic image to the codomain. -/
abbrev Hom.imageι : f.image ⟶ Y := f.ker.subschemeι
lemma ideal_ker_le_ker_ΓSpecIso_inv_comp :
f.ker.ideal U ≤ RingHom.ker ((ΓSpecIso Γ(Y, ↑U)).inv ≫
(pullback.snd f U.1.ι ≫ U.1.toSpecΓ).appTop).hom := by
let e : Γ(X, f ⁻¹ᵁ ↑U) ≅ Γ(Limits.pullback (C := Scheme) f U.1.ι, ⊤) :=
X.presheaf.mapIso (eqToIso (by simp [Scheme.Hom.opensRange_pullbackFst])).op
≪≫ (Limits.pullback.fst (C := Scheme) f U.1.ι).appIso ⊤
have he : f.app U ≫ e.hom =
(ΓSpecIso Γ(Y, ↑U)).inv ≫ (pullback.snd f U.1.ι ≫ U.1.toSpecΓ).appTop := by
rw [← (Iso.inv_comp_eq _).mpr U.2.isoSpec_inv_appTop, Category.assoc, Iso.eq_inv_comp]
simp only [Opens.topIso_hom, eqToHom_op, Hom.app_eq_appLE, Iso.trans_hom, Functor.mapIso_hom,
Iso.op_hom, eqToIso.hom, Hom.appIso_hom, Hom.appLE_map, Hom.map_appLE, Hom.appLE_comp_appLE,
Opens.map_top, e, pullback.condition, IsAffineOpen.toSpecΓ_isoSpec_inv, Category.assoc]
rw [Hom.comp_appLE, Opens.ι_app]
exact Hom.map_appLE _ _ (homOfLE le_top).op
rw [← he]
refine (IdealSheafData.ideal_ofIdeals_le _ _).trans_eq
(RingHom.ker_equiv_comp _ e.commRingCatIsoToRingEquiv).symm
private noncomputable
def Hom.toImageAux : X ⟶ f.image :=
Cover.glueMorphisms ((Y.openCoverOfIsOpenCover _ (iSup_affineOpens_eq_top Y)).pullback₁ f)
(fun U ↦ (pullback.snd f U.1.ι ≫ U.1.toSpecΓ).liftQuotient _
(by exact ideal_ker_le_ker_ΓSpecIso_inv_comp f U) ≫ f.ker.subschemeCover.f U) (by
intro U V
rw [← cancel_mono f.imageι]
simp [IdealSheafData.glueDataObjι, Scheme.Hom.liftQuotient_comp_assoc,
← pullback.condition, ← pullback.condition_assoc])
private lemma Hom.toImageAux_spec :
f.toImageAux ≫ f.imageι = f := by
apply Cover.hom_ext ((Y.openCoverOfIsOpenCover _ (iSup_affineOpens_eq_top Y)).pullback₁ f)
intro U
simp only [Hom.toImageAux, Cover.ι_glueMorphisms_assoc]
simp [IdealSheafData.glueDataObjι, Scheme.Hom.liftQuotient_comp_assoc, pullback.condition]
/-- The morphism from the domain to the scheme-theoretic image. -/
noncomputable
def Hom.toImage : X ⟶ f.image :=
f.toImageAux.copyBase (fun x ↦ ⟨f x, f.range_subset_ker_support ⟨x, rfl⟩⟩)
(funext fun x ↦ Subtype.ext congr($f.toImageAux_spec x))
@[reassoc (attr := simp)]
lemma Hom.toImage_imageι :
f.toImage ≫ f.imageι = f := by
convert f.toImageAux_spec using 2
exact Scheme.Hom.copyBase_eq _ _ _
instance [QuasiCompact f] : IsDominant f.toImage where
denseRange := by
rw [denseRange_iff_closure_range, f.imageι.isEmbedding.closure_eq_preimage_closure_image,
← Set.univ_subset_iff, ← Set.image_subset_iff, Set.image_univ,
IdealSheafData.range_subschemeι, Hom.support_ker, ← Set.range_comp,
← TopCat.coe_comp, ← Scheme.Hom.comp_base, f.toImage_imageι]
instance [QuasiCompact f] : QuasiCompact f.toImage :=
have : QuasiCompact (f.toImage ≫ f.imageι) := by simpa
.of_comp _ f.imageι
instance : IsIso (IdealSheafData.subschemeι ⊥ : _ ⟶ X) :=
⟨Scheme.Hom.toImage (𝟙 X) ≫ IdealSheafData.inclusion bot_le,
by simp [← cancel_mono (IdealSheafData.subschemeι _)], by simp⟩
lemma Hom.toImage_app :
f.toImage.app (f.imageι ⁻¹ᵁ U) =
(f.ker.subschemeObjIso U).hom ≫ CommRingCat.ofHom
(Ideal.Quotient.lift _ (f.app U.1).hom (IdealSheafData.ideal_ofIdeals_le _ _)) := by
have := ConcreteCategory.epi_of_surjective _ (f.ker.subschemeι_app_surjective U)
rw [← cancel_epi (f.ker.subschemeι.app U), ← Scheme.Hom.comp_app,
Scheme.Hom.congr_app f.toImage_imageι, f.ker.subschemeι_app,
← IsIso.eq_comp_inv, ← Functor.map_inv]
simp only [Hom.comp_base, Opens.map_comp_obj, Category.assoc,
Iso.inv_hom_id_assoc, eqToHom_op, inv_eqToHom]
rw [← reassoc_of% CommRingCat.ofHom_comp, Ideal.Quotient.lift_comp_mk, CommRingCat.ofHom_hom,
eqToHom_refl, CategoryTheory.Functor.map_id]
exact (Category.comp_id _).symm
lemma Hom.toImage_app_injective [QuasiCompact f] :
Function.Injective (f.toImage.app (f.imageι ⁻¹ᵁ U)) := by
simp only [f.toImage_app U, CommRingCat.hom_comp, CommRingCat.hom_ofHom, RingHom.coe_comp]
exact (RingHom.lift_injective_of_ker_le_ideal _ _ (by simp)).comp
(f.ker.subschemeObjIso U).commRingCatIsoToRingEquiv.injective
lemma Hom.stalkFunctor_toImage_injective [QuasiCompact f] (x) :
Function.Injective ((TopCat.Presheaf.stalkFunctor _ x).map f.toImage.c) := by
apply TopCat.Presheaf.stalkFunctor_map_injective_of_isBasis
(hB := (Y.isBasis_affineOpens.of_isInducing f.imageι.isEmbedding.isInducing))
rintro _ ⟨U, hU, rfl⟩
exact f.toImage_app_injective ⟨U, hU⟩
open IdealSheafData in
/-- The adjunction between `Y.IdealSheafData` and `(Over Y)ᵒᵖ` given by taking kernels. -/
@[simps]
noncomputable
def kerAdjunction (Y : Scheme.{u}) : (subschemeFunctor Y).rightOp ⊣ Y.kerFunctor where
unit.app I := eqToHom (by simp)
counit.app f := (Over.homMk f.unop.hom.toImage f.unop.hom.toImage_imageι).op
counit.naturality _ _ _ := Quiver.Hom.unop_inj (by ext1; simp [← cancel_mono (subschemeι _)])
left_triangle_components I := Quiver.Hom.unop_inj (by ext1; simp [← cancel_mono (subschemeι _)])
instance : (IdealSheafData.subschemeFunctor Y).Full :=
have : IsIso Y.kerAdjunction.rightOp.counit := by
simp [NatTrans.isIso_iff_isIso_app, CategoryTheory.instIsIsoEqToHom]
Y.kerAdjunction.rightOp.fullyFaithfulROfIsIsoCounit.full
end image
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean | import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact
import Mathlib.AlgebraicGeometry.Properties
/-!
# Ideal sheaves on schemes
We define ideal sheaves of schemes and provide various constructors for it.
## Main definition
* `AlgebraicGeometry.Scheme.IdealSheafData`: A structure that contains the data to uniquely define
an ideal sheaf, consisting of
1. an ideal `I(U) ≤ Γ(X, U)` for every affine open `U`
2. a proof that `I(D(f)) = I(U)_f` for every affine open `U` and every section `f : Γ(X, U)`.
* `AlgebraicGeometry.Scheme.IdealSheafData.ofIdeals`:
The largest ideal sheaf contained in a family of ideals.
* `AlgebraicGeometry.Scheme.IdealSheafData.equivOfIsAffine`:
Over affine schemes, ideal sheaves are in bijection with ideals of the global sections.
* `AlgebraicGeometry.Scheme.IdealSheafData.support`: The support of an ideal sheaf.
* `AlgebraicGeometry.Scheme.IdealSheafData.vanishingIdeal`: The vanishing ideal of a set.
* `AlgebraicGeometry.Scheme.Hom.ker`: The kernel of a morphism.
## Main results
* `AlgebraicGeometry.Scheme.IdealSheafData.gc`:
`support` and `vanishingIdeal` forms a Galois connection.
* `AlgebraicGeometry.Scheme.Hom.support_ker`: The support of a kernel of a quasi-compact morphism
is the closure of the range.
## Implementation detail
Ideal sheaves are not yet defined in this file as actual subsheaves of `𝒪ₓ`.
Instead, for the ease of development and application,
we define the structure `IdealSheafData` containing all necessary data to uniquely define an
ideal sheaf. This should be refactored as a constructor for ideal sheaves once they are introduced
into mathlib.
-/
open CategoryTheory TopologicalSpace
universe u
namespace AlgebraicGeometry.Scheme
variable {X : Scheme.{u}}
/--
A structure that contains the data to uniquely define an ideal sheaf, consisting of
1. an ideal `I(U) ≤ Γ(X, U)` for every affine open `U`
2. a proof that `I(D(f)) = I(U)_f` for every affine open `U` and every section `f : Γ(X, U)`
3. a subset of `X` equal to the support.
Also see `Scheme.IdealSheafData.mkOfMemSupportIff` for a constructor with the condition on the
support being (usually) easier to prove.
-/
structure IdealSheafData (X : Scheme.{u}) : Type u where
/-- The component of an ideal sheaf at an affine open. -/
ideal : ∀ U : X.affineOpens, Ideal Γ(X, U)
/-- Also see `AlgebraicGeometry.Scheme.IdealSheafData.map_ideal` -/
map_ideal_basicOpen : ∀ (U : X.affineOpens) (f : Γ(X, U)),
(ideal U).map (X.presheaf.map (homOfLE <| X.basicOpen_le f).op).hom =
ideal (X.affineBasicOpen f)
/-- The support of an ideal sheaf. Use `IdealSheafData.support` instead for most occasions. -/
supportSet : Set X := ⋂ U, X.zeroLocus (U := U.1) (ideal U)
supportSet_eq_iInter_zeroLocus : supportSet = ⋂ U, X.zeroLocus (U := U.1) (ideal U) := by rfl
namespace IdealSheafData
@[ext]
protected lemma ext {I J : X.IdealSheafData} (h : I.ideal = J.ideal) : I = J := by
obtain ⟨i, _, s, hs⟩ := I
obtain ⟨j, _, t, ht⟩ := J
subst h
congr
rw [hs, ht]
section Order
instance : PartialOrder (IdealSheafData X) := PartialOrder.lift ideal fun _ _ ↦ IdealSheafData.ext
lemma le_def {I J : IdealSheafData X} : I ≤ J ↔ ∀ U, I.ideal U ≤ J.ideal U := .rfl
instance : CompleteSemilatticeSup (IdealSheafData X) where
sSup s :=
{ ideal := sSup (ideal '' s),
map_ideal_basicOpen := by
have : sSup (ideal '' s) = ⨆ i : s, ideal i.1 := by
conv_lhs => rw [← Subtype.range_val (s := s), ← Set.range_comp]
rfl
simp only [this, iSup_apply, Ideal.map_iSup, map_ideal_basicOpen, implies_true] }
le_sSup s x hxs := le_sSup (s := ideal '' s) ⟨_, hxs, rfl⟩
sSup_le s i hi := sSup_le (s := ideal '' s) (Set.forall_mem_image.mpr hi)
/-- The largest ideal sheaf contained in a family of ideals. -/
def ofIdeals (I : ∀ U : X.affineOpens, Ideal Γ(X, U)) : IdealSheafData X :=
sSup { J : IdealSheafData X | J.ideal ≤ I }
lemma ideal_ofIdeals_le (I : ∀ U : X.affineOpens, Ideal Γ(X, U)) :
(ofIdeals I).ideal ≤ I :=
sSup_le (Set.forall_mem_image.mpr fun _ ↦ id)
/-- The Galois coinsertion between ideal sheaves and arbitrary families of ideals. -/
protected def gci : GaloisCoinsertion ideal (ofIdeals (X := X)) where
choice I hI :=
{ ideal := I
map_ideal_basicOpen U f :=
(ideal_ofIdeals_le I).antisymm hI ▸ (ofIdeals I).map_ideal_basicOpen U f }
gc _ _ := ⟨(le_sSup ·), (le_trans · (ideal_ofIdeals_le _))⟩
u_l_le _ := sSup_le fun _ ↦ id
choice_eq I hI := IdealSheafData.ext (hI.antisymm (ideal_ofIdeals_le I))
lemma strictMono_ideal : StrictMono (ideal (X := X)) := IdealSheafData.gci.strictMono_l
lemma ideal_mono : Monotone (ideal (X := X)) := strictMono_ideal.monotone
lemma ofIdeals_mono : Monotone (ofIdeals (X := X)) := IdealSheafData.gci.gc.monotone_u
lemma ofIdeals_ideal (I : IdealSheafData X) : ofIdeals I.ideal = I := IdealSheafData.gci.u_l_eq _
lemma le_ofIdeals_iff {I : IdealSheafData X} {J} : I ≤ ofIdeals J ↔ I.ideal ≤ J :=
IdealSheafData.gci.gc.le_iff_le.symm
instance : OrderTop (IdealSheafData X) where
top.ideal := ⊤
top.map_ideal_basicOpen := by simp [Ideal.map_top]
top.supportSet := ⊥
top.supportSet_eq_iInter_zeroLocus := by
ext x
simpa using X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
le_top I U := le_top
instance : OrderBot (IdealSheafData X) where
bot.ideal := ⊥
bot.map_ideal_basicOpen := by simp
bot.supportSet := ⊤
bot.supportSet_eq_iInter_zeroLocus := by ext; simp
bot_le I U := bot_le
instance : SemilatticeInf (IdealSheafData X) where
inf I J :=
{ ideal := I.ideal ⊓ J.ideal
map_ideal_basicOpen U f := by
dsimp
have : (X.presheaf.map (homOfLE (X.basicOpen_le f)).op).hom = algebraMap _ _ := rfl
have inst := U.2.isLocalization_basicOpen f
rw [← I.map_ideal_basicOpen U f, ← J.map_ideal_basicOpen U f, this]
ext x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq (.powers f) x
simp only [IsLocalization.mk'_mem_map_algebraMap_iff, Submonoid.mem_powers_iff, Ideal.mem_inf,
exists_exists_eq_and]
refine ⟨fun ⟨n, h₁, h₂⟩ ↦ ⟨⟨n, h₁⟩, ⟨n, h₂⟩⟩, ?_⟩
rintro ⟨⟨n₁, h₁⟩, ⟨n₂, h₂⟩⟩
refine ⟨n₁ + n₂, ?_, ?_⟩
· rw [add_comm, pow_add, mul_assoc]; exact Ideal.mul_mem_left _ _ h₁
· rw [pow_add, mul_assoc]; exact Ideal.mul_mem_left _ _ h₂ }
inf_le_left I J U := inf_le_left
inf_le_right I J U := inf_le_right
le_inf I J K hIJ hIK U := le_inf (hIJ U) (hIK U)
instance : CompleteLattice (IdealSheafData X) where
__ := inferInstanceAs (OrderTop (IdealSheafData X))
__ := inferInstanceAs (OrderBot (IdealSheafData X))
__ := inferInstanceAs (SemilatticeInf (IdealSheafData X))
__ := inferInstanceAs (CompleteSemilatticeSup (IdealSheafData X))
__ := IdealSheafData.gci.liftCompleteLattice
@[simp]
lemma ideal_top : ideal (X := X) ⊤ = ⊤ := rfl
@[simp]
lemma ideal_bot : ideal (X := X) ⊥ = ⊥ := rfl
@[simp]
lemma ideal_sup {I J : IdealSheafData X} : (I ⊔ J).ideal = I.ideal ⊔ J.ideal := rfl
@[simp]
lemma ideal_sSup {I : Set (IdealSheafData X)} : (sSup I).ideal = sSup (ideal '' I) := rfl
@[simp]
lemma ideal_iSup {ι : Type*} {I : ι → IdealSheafData X} : (iSup I).ideal = ⨆ i, (I i).ideal := by
rw [← sSup_range, ← sSup_range, ideal_sSup, ← Set.range_comp, Function.comp_def]
@[simp]
lemma ideal_inf {I J : IdealSheafData X} : (I ⊓ J).ideal = I.ideal ⊓ J.ideal := rfl
@[simp]
lemma ideal_biInf {ι : Type*} (I : ι → IdealSheafData X) {s : Set ι} (hs : s.Finite) :
(⨅ i ∈ s, I i).ideal = ⨅ i ∈ s, (I i).ideal := by
refine hs.induction_on _ (by simp) fun {i s} his hs e ↦ ?_
simp only [iInf_insert, e, ideal_inf]
@[simp]
lemma ideal_iInf {ι : Type*} (I : ι → IdealSheafData X) [Finite ι] :
(⨅ i, I i).ideal = ⨅ i, (I i).ideal := by
simpa using ideal_biInf I Set.finite_univ
end Order
variable (I : IdealSheafData X)
section map_ideal
/-- subsumed by `IdealSheafData.map_ideal` below. -/
private lemma map_ideal_basicOpen_of_eq
{U V : X.affineOpens} (f : Γ(X, U)) (hV : V = X.affineBasicOpen f) :
(I.ideal U).map (X.presheaf.map
(homOfLE (X := X.Opens) (hV.trans_le (X.affineBasicOpen_le f))).op).hom =
I.ideal V := by
subst hV; exact I.map_ideal_basicOpen _ _
lemma map_ideal {U V : X.affineOpens} (h : U ≤ V) :
(I.ideal V).map (X.presheaf.map (homOfLE h).op).hom = I.ideal U := by
rw [U.2.ideal_ext_iff]
intro x hxU
obtain ⟨f, g, hfg, hxf⟩ := exists_basicOpen_le_affine_inter U.2 V.2 x ⟨hxU, h hxU⟩
have := I.map_ideal_basicOpen_of_eq (V := X.affineBasicOpen g) f (Subtype.ext hfg.symm)
rw [← I.map_ideal_basicOpen] at this
apply_fun Ideal.map (X.presheaf.germ (X.basicOpen g) x (hfg ▸ hxf)).hom at this
simp only [Ideal.map_map, ← CommRingCat.hom_comp, affineBasicOpen_coe, X.presheaf.germ_res]
at this ⊢
simp only [homOfLE_leOfHom, TopCat.Presheaf.germ_res', this]
/-- A form of `map_ideal` that is easier to rewrite with. -/
lemma map_ideal' {U V : X.affineOpens} (h : Opposite.op V.1 ⟶ .op U.1) :
(I.ideal V).map (X.presheaf.map h).hom = I.ideal U :=
map_ideal _ _
lemma ideal_le_comap_ideal {U V : X.affineOpens} (h : U ≤ V) :
I.ideal V ≤ (I.ideal U).comap (X.presheaf.map (homOfLE h).op).hom := by
rw [← Ideal.map_le_iff_le_comap, ← I.map_ideal h]
end map_ideal
section support
lemma mem_supportSet_iff {I : IdealSheafData X} {x} :
x ∈ I.supportSet ↔ ∀ U, x ∈ X.zeroLocus (U := U.1) (I.ideal U) :=
(Set.ext_iff.mp I.supportSet_eq_iInter_zeroLocus _).trans Set.mem_iInter
lemma supportSet_subset_zeroLocus (I : IdealSheafData X) (U : X.affineOpens) :
I.supportSet ⊆ X.zeroLocus (U := U.1) (I.ideal U) :=
I.supportSet_eq_iInter_zeroLocus.trans_subset (Set.iInter_subset _ _)
lemma zeroLocus_inter_subset_supportSet (I : IdealSheafData X) (U : X.affineOpens) :
X.zeroLocus (U := U.1) (I.ideal U) ∩ U ⊆ I.supportSet := by
rw [I.supportSet_eq_iInter_zeroLocus]
refine Set.subset_iInter fun V ↦ ?_
apply (X.codisjoint_zeroLocus (U := V) (I.ideal V)).symm.left_le_of_le_inf_right
rintro x ⟨⟨hx, hxU⟩, hxV⟩
simp only [Scheme.mem_zeroLocus_iff, SetLike.mem_coe] at hx ⊢
intro s hfU hxs
obtain ⟨f, g, hfg, hxf⟩ := exists_basicOpen_le_affine_inter U.2 V.2 x ⟨hxU, hxV⟩
have inst := U.2.isLocalization_basicOpen f
have := (I.map_ideal (U := X.affineBasicOpen f) (hfg.trans_le (X.basicOpen_le g))).le
(Ideal.mem_map_of_mem _ hfU)
rw [← I.map_ideal_basicOpen] at this
obtain ⟨⟨s', ⟨_, n, rfl⟩⟩, hs'⟩ :=
(IsLocalization.mem_map_algebraMap_iff (.powers f) Γ(X, X.basicOpen f)).mp this
apply_fun (x ∈ X.basicOpen ·) at hs'
refine hx s' s'.2 ?_
cases n <;>
simpa [RingHom.algebraMap_toAlgebra, ← hfg, hxf, hxs, Scheme.basicOpen_pow] using hs'
lemma mem_supportSet_iff_of_mem {I : IdealSheafData X} {x} {U : X.affineOpens} (hxU : x ∈ U.1) :
x ∈ I.supportSet ↔ x ∈ X.zeroLocus (U := U.1) (I.ideal U) :=
⟨I.supportSet_eq_iInter_zeroLocus ▸ fun h ↦ Set.iInter_subset _ U h,
fun h ↦ I.zeroLocus_inter_subset_supportSet U ⟨h, hxU⟩⟩
lemma supportSet_inter (I : IdealSheafData X) (U : X.affineOpens) :
I.supportSet ∩ U = X.zeroLocus (U := U.1) (I.ideal U) ∩ U := by
ext x
by_cases hxU : x ∈ U.1
· simp [hxU, mem_supportSet_iff_of_mem hxU]
· simp [hxU]
lemma isClosed_supportSet (I : IdealSheafData X) : IsClosed I.supportSet := by
rw [TopologicalSpace.IsOpenCover.isClosed_iff_coe_preimage (iSup_affineOpens_eq_top X)]
intro U
refine ⟨(X.zeroLocus (U := U.1) (I.ideal U))ᶜ, (X.zeroLocus_isClosed _).isOpen_compl, ?_⟩
simp only [Set.preimage_compl, compl_inj_iff]
apply Subtype.val_injective.image_injective
simp [Set.image_preimage_eq_inter_range, I.supportSet_inter]
/-- The support of an ideal sheaf. Also see `IdealSheafData.mem_support_iff_of_mem`. -/
def support : Closeds X := ⟨I.supportSet, I.isClosed_supportSet⟩
lemma coe_support_eq_eq_iInter_zeroLocus :
(I.support : Set X) = ⋂ U, X.zeroLocus (U := U.1) (I.ideal U) :=
I.supportSet_eq_iInter_zeroLocus
lemma mem_support_iff {I : IdealSheafData X} {x} :
x ∈ I.support ↔ ∀ U, x ∈ X.zeroLocus (U := U.1) (I.ideal U) :=
(Set.ext_iff.mp I.supportSet_eq_iInter_zeroLocus _).trans Set.mem_iInter
lemma mem_support_iff_of_mem {I : IdealSheafData X} {x : X} {U : X.affineOpens} (h : x ∈ U.1) :
x ∈ I.support ↔ x ∈ X.zeroLocus (U := U.1) (I.ideal U) := by
simpa [-mem_zeroLocus_iff, h] using congr(x ∈ $(I.supportSet_inter U))
lemma coe_support_inter (I : IdealSheafData X) (U : X.affineOpens) :
(I.support : Set X) ∩ U = X.zeroLocus (U := U.1) (I.ideal U) ∩ U :=
I.supportSet_inter U
/-- Custom simps projection for `IdealSheafData`. -/
def Simps.coe_support : Set X := I.support
initialize_simps_projections IdealSheafData (supportSet → coe_support, as_prefix coe_support)
/-- A useful constructor of `IdealSheafData`
with the condition on `supportSet` being easier to check. -/
@[simps ideal coe_support]
def mkOfMemSupportIff
(ideal : ∀ U : X.affineOpens, Ideal Γ(X, U))
(map_ideal_basicOpen : ∀ (U : X.affineOpens) (f : Γ(X, U)),
(ideal U).map (X.presheaf.map (homOfLE <| X.basicOpen_le f).op).hom =
ideal (X.affineBasicOpen f))
(supportSet : Set X)
(supportSet_inter :
∀ U : X.affineOpens, ∀ x ∈ U.1, x ∈ supportSet ↔ x ∈ X.zeroLocus (U := U.1) (ideal U)) :
X.IdealSheafData where
ideal := ideal
map_ideal_basicOpen := map_ideal_basicOpen
supportSet := supportSet
supportSet_eq_iInter_zeroLocus := by
let I' : X.IdealSheafData := { ideal := ideal, map_ideal_basicOpen := map_ideal_basicOpen }
change supportSet = I'.supportSet
ext x
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
exact (supportSet_inter ⟨U, hU⟩ x hxU).trans
(I'.mem_support_iff_of_mem (U := ⟨U, hU⟩) hxU).symm
@[simp]
lemma support_top : support (X := X) ⊤ = ⊥ := rfl
@[simp]
lemma support_bot : support (X := X) ⊥ = ⊤ := rfl
lemma support_antitone : Antitone (support (X := X)) := by
intro I J h
rw [← SetLike.coe_subset_coe, I.coe_support_eq_eq_iInter_zeroLocus,
J.coe_support_eq_eq_iInter_zeroLocus]
exact Set.iInter_mono fun U ↦ X.zeroLocus_mono (h U)
@[simp]
lemma support_eq_bot_iff : support I = ⊥ ↔ I = ⊤ := by
refine ⟨fun H ↦ top_le_iff.mp fun U ↦ ?_, by simp +contextual⟩
have := (U.2.fromSpec_image_zeroLocus _).trans_subset
((zeroLocus_inter_subset_supportSet I U).trans H.le)
simp only [Set.subset_empty_iff, Set.image_eq_empty, Closeds.coe_bot] at this
simp [PrimeSpectrum.zeroLocus_empty_iff_eq_top.mp this]
end support
section IsAffine
/-- The ideal sheaf induced by an ideal of the global sections. -/
@[simps! ideal coe_support]
def ofIdealTop (I : Ideal Γ(X, ⊤)) : IdealSheafData X :=
mkOfMemSupportIff
(fun U ↦ I.map (X.presheaf.map (homOfLE le_top).op).hom)
(fun U f ↦ by rw [Ideal.map_map, ← CommRingCat.hom_comp, ← Functor.map_comp]; rfl)
(X.zeroLocus (U := ⊤) I)
(fun U x hxU ↦ by
simp only [Ideal.map, zeroLocus_span, zeroLocus_map, Set.mem_union, Set.mem_compl_iff,
SetLike.mem_coe, hxU, not_true_eq_false, iff_self_or, IsEmpty.forall_iff])
lemma le_of_isAffine [IsAffine X] {I J : IdealSheafData X}
(H : I.ideal ⟨⊤, isAffineOpen_top X⟩ ≤ J.ideal ⟨⊤, isAffineOpen_top X⟩) : I ≤ J := by
intro U
rw [← map_ideal (U := U) (V := ⟨⊤, isAffineOpen_top X⟩) I (le_top (a := U.1)),
← map_ideal (U := U) (V := ⟨⊤, isAffineOpen_top X⟩) J (le_top (a := U.1))]
exact Ideal.map_mono H
lemma ext_of_isAffine [IsAffine X] {I J : IdealSheafData X}
(H : I.ideal ⟨⊤, isAffineOpen_top X⟩ = J.ideal ⟨⊤, isAffineOpen_top X⟩) : I = J :=
(le_of_isAffine H.le).antisymm (le_of_isAffine H.ge)
/-- Over affine schemes, ideal sheaves are in bijection with ideals of the global sections. -/
@[simps]
def equivOfIsAffine [IsAffine X] : IdealSheafData X ≃o Ideal Γ(X, ⊤) where
toFun := (ideal · ⟨⊤, isAffineOpen_top X⟩)
invFun := ofIdealTop
left_inv I := ext_of_isAffine (by simp)
right_inv I := by simp
map_rel_iff' {I J} := ⟨le_of_isAffine, (· _)⟩
end IsAffine
section ofIsClosed
open _root_.PrimeSpectrum TopologicalSpace
@[deprecated (since := "2025-08-10")] alias Scheme.zeroLocus_radical :=
AlgebraicGeometry.Scheme.zeroLocus_radical
/-- The radical of a ideal sheaf. -/
@[simps! ideal]
def radical (I : IdealSheafData X) : IdealSheafData X :=
mkOfMemSupportIff
(fun U ↦ (I.ideal U).radical)
(fun U f ↦
letI : Algebra Γ(X, U) Γ(X, X.affineBasicOpen f) :=
(X.presheaf.map (homOfLE (X.basicOpen_le f)).op).hom.toAlgebra
have : IsLocalization.Away f Γ(X, X.basicOpen f) := U.2.isLocalization_of_eq_basicOpen _ _ rfl
(IsLocalization.map_radical (.powers f) Γ(X, X.basicOpen f) (I.ideal U)).trans
congr($(I.map_ideal_basicOpen U f).radical))
I.supportSet
(fun U x hx ↦ by
simp only [mem_supportSet_iff_of_mem hx, AlgebraicGeometry.Scheme.zeroLocus_radical])
@[simp]
lemma support_radical (I : IdealSheafData X) : I.radical.support = I.support := rfl
/-- The nilradical of a scheme. -/
def _root_.AlgebraicGeometry.Scheme.nilradical (X : Scheme.{u}) : IdealSheafData X :=
.radical ⊥
@[simp]
lemma _root_.AlgebraicGeometry.Scheme.support_nilradical (X : Scheme.{u}) :
X.nilradical.support = ⊤ := rfl
lemma le_radical : I ≤ I.radical := fun _ ↦ Ideal.le_radical
@[simp]
lemma radical_top : radical (X := X) ⊤ = ⊤ := top_le_iff.mp (le_radical _)
lemma radical_bot : radical ⊥ = nilradical X := rfl
lemma radical_sup {I J : IdealSheafData X} :
radical (I ⊔ J) = radical (radical I ⊔ radical J) := by
ext U : 2
exact (Ideal.radical_sup (I.ideal U) (J.ideal U))
@[simp]
lemma radical_inf {I J : IdealSheafData X} :
radical (I ⊓ J) = (radical I ⊓ radical J) := by
ext U : 2
simp only [radical_ideal, ideal_inf, Pi.inf_apply, Ideal.radical_inf]
/-- The vanishing ideal sheaf of a closed set,
which is the largest ideal sheaf whose support is equal to it.
The reduced induced scheme structure on the closed set is the quotient of this ideal. -/
@[simps! ideal coe_support]
nonrec def vanishingIdeal (Z : Closeds X) : IdealSheafData X :=
mkOfMemSupportIff
(fun U ↦ vanishingIdeal (U.2.fromSpec ⁻¹' Z))
(fun U f ↦ by
let F := X.presheaf.map (homOfLE (X.basicOpen_le f)).op
apply le_antisymm
· rw [Ideal.map_le_iff_le_comap]
intro x hx
suffices ∀ p, (X.affineBasicOpen f).2.fromSpec p ∈ Z → F.hom x ∈ p.asIdeal by
simpa [PrimeSpectrum.mem_vanishingIdeal] using this
intro x hxZ
refine (PrimeSpectrum.mem_vanishingIdeal _ _).mp hx
(Spec.map (X.presheaf.map (homOfLE _).op) x) ?_
rwa [Set.mem_preimage, ← Scheme.Hom.comp_apply,
IsAffineOpen.map_fromSpec _ (X.affineBasicOpen f).2]
· letI : Algebra Γ(X, U) Γ(X, X.affineBasicOpen f) := F.hom.toAlgebra
have : IsLocalization.Away f Γ(X, X.basicOpen f) :=
U.2.isLocalization_of_eq_basicOpen _ _ rfl
intro x hx
dsimp only at hx ⊢
have : Topology.IsOpenEmbedding (Spec.map F) :=
localization_away_isOpenEmbedding Γ(X, X.basicOpen f) f
rw [← U.2.map_fromSpec (X.affineBasicOpen f).2 (homOfLE (X.basicOpen_le f)).op,
Scheme.Hom.comp_base, TopCat.coe_comp, Set.preimage_comp] at hx
generalize U.2.fromSpec ⁻¹' Z = Z' at hx ⊢
replace hx : x ∈ vanishingIdeal (Spec.map F ⁻¹' Z') := hx
obtain ⟨I, hI, e⟩ :=
(isClosed_iff_zeroLocus_radical_ideal _).mp (isClosed_closure (s := Z'))
rw [← vanishingIdeal_closure,
← this.isOpenMap.preimage_closure_eq_closure_preimage this.continuous, e] at hx
rw [← vanishingIdeal_closure, e]
erw [preimage_comap_zeroLocus] at hx
rwa [← PrimeSpectrum.zeroLocus_span, ← Ideal.map, vanishingIdeal_zeroLocus_eq_radical,
← RingHom.algebraMap_toAlgebra (X.presheaf.map _).hom,
← IsLocalization.map_radical (.powers f), ← vanishingIdeal_zeroLocus_eq_radical] at hx)
Z
(fun U x hxU ↦ by
trans x ∈ X.zeroLocus (U := U.1) (vanishingIdeal (U.2.fromSpec ⁻¹' Z)) ∩ U.1
· rw [← U.2.fromSpec_image_zeroLocus, zeroLocus_vanishingIdeal_eq_closure,
← U.2.fromSpec.isOpenEmbedding.isOpenMap.preimage_closure_eq_closure_preimage
U.2.fromSpec.continuous,
Set.image_preimage_eq_inter_range, Z.isClosed.closure_eq, IsAffineOpen.range_fromSpec]
simp [hxU]
· simp [hxU])
lemma le_support_iff_le_vanishingIdeal {I : X.IdealSheafData} {Z : Closeds X} :
Z ≤ I.support ↔ I ≤ vanishingIdeal Z := by
simp only [le_def, vanishingIdeal_ideal, ← PrimeSpectrum.subset_zeroLocus_iff_le_vanishingIdeal]
trans ∀ U : X.affineOpens, (Z : Set X) ∩ U ⊆ I.support ∩ U
· refine ⟨fun H U x hx ↦ ⟨H hx.1, hx.2⟩, fun H x hx ↦ ?_⟩
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
exact (H ⟨U, hU⟩ ⟨hx, hxU⟩).1
refine forall_congr' fun U ↦ ?_
rw [coe_support_inter, ← Set.image_subset_image_iff U.2.fromSpec.isOpenEmbedding.injective,
Set.image_preimage_eq_inter_range, IsAffineOpen.fromSpec_image_zeroLocus,
IsAffineOpen.range_fromSpec]
@[deprecated (since := "2025-05-16")]
alias subset_support_iff_le_vanishingIdeal := le_support_iff_le_vanishingIdeal
/-- `support` and `vanishingIdeal` forms a Galois connection.
This is the global version of `PrimeSpectrum.gc`. -/
lemma gc : @GaloisConnection X.IdealSheafData (Closeds X)ᵒᵈ _ _ (support ·) (vanishingIdeal ·) :=
fun _ _ ↦ le_support_iff_le_vanishingIdeal
lemma vanishingIdeal_antimono {S T : Closeds X} (h : S ≤ T) : vanishingIdeal T ≤ vanishingIdeal S :=
gc.monotone_u h
lemma vanishingIdeal_support {I : IdealSheafData X} :
vanishingIdeal I.support = I.radical := by
ext U : 2
dsimp
rw [← vanishingIdeal_zeroLocus_eq_radical]
congr 1
apply U.2.fromSpec.isOpenEmbedding.injective.image_injective
rw [Set.image_preimage_eq_inter_range, IsAffineOpen.range_fromSpec,
IsAffineOpen.fromSpec_image_zeroLocus, coe_support_inter]
@[simp] lemma vanishingIdeal_bot : vanishingIdeal (X := X) ⊥ = ⊤ := gc.u_top
@[simp] lemma vanishingIdeal_top : vanishingIdeal (X := X) ⊤ = X.nilradical := by
rw [← support_bot, vanishingIdeal_support, nilradical]
@[simp] lemma vanishingIdeal_iSup {ι : Sort*} (Z : ι → Closeds X) :
vanishingIdeal (iSup Z) = ⨅ i, vanishingIdeal (Z i) := gc.u_iInf
@[simp] lemma vanishingIdeal_sSup (Z : Set (Closeds X)) :
vanishingIdeal (sSup Z) = ⨅ z ∈ Z, vanishingIdeal z := gc.u_sInf
@[simp] lemma vanishingIdeal_sup (Z Z' : TopologicalSpace.Closeds X) :
vanishingIdeal (Z ⊔ Z') = vanishingIdeal Z ⊓ vanishingIdeal Z' := gc.u_inf
@[simp] lemma support_sup (I J : X.IdealSheafData) :
(I ⊔ J).support = I.support ⊓ J.support := gc.l_sup
@[simp] lemma support_iSup {ι : Sort*} (I : ι → X.IdealSheafData) :
(iSup I).support = ⨅ i, (I i).support := gc.l_iSup
@[simp] lemma support_sSup (I : Set X.IdealSheafData) :
(sSup I).support = ⨅ i ∈ I, i.support := gc.l_sSup
end ofIsClosed
end IdealSheafData
section IsReduced
lemma nilradical_eq_bot [IsReduced X] : X.nilradical = ⊥ := by
ext; simp [nilradical, Ideal.radical_eq_iff.mpr (Ideal.isRadical_bot)]
lemma IdealSheafData.support_eq_top_iff [IsReduced X] {I : X.IdealSheafData} :
I.support = ⊤ ↔ I = ⊥ := by
rw [← top_le_iff, le_support_iff_le_vanishingIdeal,
vanishingIdeal_top, nilradical_eq_bot, le_bot_iff]
end IsReduced
section ker
open IdealSheafData
variable {Y Z : Scheme.{u}}
/-- The kernel of a morphism,
defined as the largest (quasi-coherent) ideal sheaf contained in the component-wise kernel.
This is usually only well-behaved when `f` is quasi-compact. -/
def Hom.ker (f : X.Hom Y) : IdealSheafData Y :=
ofIdeals fun U ↦ RingHom.ker (f.app U).hom
lemma Hom.ideal_ker_le (f : X.Hom Y) (U : Y.affineOpens) :
f.ker.ideal U ≤ RingHom.ker (f.app U).hom :=
ideal_ofIdeals_le _ _
@[simp]
lemma Hom.ker_apply (f : X.Hom Y) [QuasiCompact f] (U : Y.affineOpens) :
f.ker.ideal U = RingHom.ker (f.app U).hom := by
let I : IdealSheafData Y := ⟨fun U ↦ RingHom.ker (f.app U).hom, ?_, _, rfl⟩
· exact congr($(ofIdeals_ideal I).ideal U)
intro U s
apply le_antisymm
· refine Ideal.map_le_iff_le_comap.mpr fun x hx ↦ ?_
simp_rw [RingHom.comap_ker, ← CommRingCat.hom_comp, Scheme.affineBasicOpen_coe, f.naturality,
CommRingCat.hom_comp, ← RingHom.comap_ker]
exact Ideal.ker_le_comap _ hx
· intro x hx
have := U.2.isLocalization_basicOpen s
obtain ⟨x, ⟨_, n, rfl⟩, rfl⟩ := IsLocalization.exists_mk'_eq (.powers s) x
refine (IsLocalization.mk'_mem_map_algebraMap_iff _ _ _ _ _).mpr ?_
suffices ∃ (V : X.Opens) (hV : V = X.basicOpen ((f.app U).hom s)),
letI := hV.trans_le (X.basicOpen_le _); ((f.app U).hom x |_ V) = 0 by
obtain ⟨_, rfl, H⟩ := this
obtain ⟨n, hn⟩ := exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact
X (U := f ⁻¹ᵁ U) (QuasiCompact.isCompact_preimage (f := f) _ U.1.2 U.2.isCompact)
(f.app U x) (f.app U s) H
exact ⟨_, ⟨n, rfl⟩, by simpa using hn⟩
refine ⟨f ⁻¹ᵁ Y.basicOpen s, by simp, ?_⟩
replace hx : (Y.presheaf.map (homOfLE (Y.basicOpen_le s)).op ≫ f.app _).hom x = 0 := by
trans (f.app (Y.basicOpen s)).hom (algebraMap Γ(Y, U) _ x)
· simp [-NatTrans.naturality, RingHom.algebraMap_toAlgebra]
· simp only [Scheme.affineBasicOpen_coe, RingHom.mem_ker] at hx
rw [← IsLocalization.mk'_spec' (M := .powers s), map_mul, hx, mul_zero]
rwa [f.naturality] at hx
lemma Hom.le_ker_comp (f : X ⟶ Y) (g : Y.Hom Z) : g.ker ≤ (f ≫ g).ker := by
refine ofIdeals_mono fun U ↦ ?_
rw [Scheme.Hom.comp_app f g U, CommRingCat.hom_comp, ← RingHom.comap_ker]
exact Ideal.ker_le_comap _
lemma ker_eq_top_of_isEmpty (f : X.Hom Y) [IsEmpty X] : f.ker = ⊤ :=
top_le_iff.mp (le_ofIdeals_iff.mpr fun U x _ ↦ by simpa using Subsingleton.elim _ _)
@[simp]
lemma Hom.ker_eq_bot_of_isIso (f : X ⟶ Y) [IsIso f] : f.ker = ⊥ := by
ext U
simp [map_eq_zero_iff _ (ConcreteCategory.bijective_of_isIso (f.app U)).1]
lemma Hom.ker_comp_of_isIso (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] : (f ≫ g).ker = g.ker :=
(f.le_ker_comp g).antisymm' (((inv f).le_ker_comp _).trans (by simp))
lemma ker_of_isAffine {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] :
f.ker = ofIdealTop (RingHom.ker f.appTop.hom) := by
refine (le_of_isAffine ((f.ideal_ker_le _).trans (by simp))).antisymm
(le_ofIdeals_iff.mpr fun U ↦ ?_)
simp only [ofIdealTop_ideal, homOfLE_leOfHom, Ideal.map_le_iff_le_comap, RingHom.comap_ker,
← CommRingCat.hom_comp, f.naturality]
intro x
simp +contextual
lemma Hom.range_subset_ker_support (f : X ⟶ Y) :
Set.range f ⊆ f.ker.support := by
rintro _ ⟨x, rfl⟩
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ (f x)) isOpen_univ
refine ((coe_support_inter f.ker ⟨U, hU⟩).ge ⟨?_, hxU⟩).1
simp only [Scheme.mem_zeroLocus_iff, SetLike.mem_coe]
intro s hs hxs
have : x ∈ f ⁻¹ᵁ Y.basicOpen s := hxs
rwa [Scheme.preimage_basicOpen, RingHom.mem_ker.mp (f.ideal_ker_le _ hs),
Scheme.basicOpen_zero] at this
lemma Hom.ker_eq_top_iff_isEmpty (f : X.Hom Y) : f.ker = ⊤ ↔ IsEmpty X :=
⟨fun H ↦ by simpa [H] using f.range_subset_ker_support, fun _ ↦ ker_eq_top_of_isEmpty f⟩
lemma Hom.iInf_ker_openCover_map_comp_apply
(f : X.Hom Y) [QuasiCompact f] (𝒰 : X.OpenCover) (U : Y.affineOpens) :
⨅ i, (𝒰.f i ≫ f).ker.ideal U = f.ker.ideal U := by
refine le_antisymm ?_ (le_iInf fun i ↦ (𝒰.f i).le_ker_comp f U)
intro s hs
simp only [Hom.ker_apply, RingHom.mem_ker]
apply X.IsSheaf.section_ext
rintro x hxU
obtain ⟨i, x, rfl⟩ := 𝒰.exists_eq x
simp only [homOfLE_leOfHom, map_zero, exists_and_left]
refine ⟨𝒰.f i ''ᵁ 𝒰.f i ⁻¹ᵁ f ⁻¹ᵁ U.1, ⟨_, hxU, rfl⟩,
Set.image_preimage_subset (𝒰.f i) (f ⁻¹ᵁ U), ?_⟩
apply ((𝒰.f i).appIso _).commRingCatIsoToRingEquiv.injective
rw [map_zero, ← RingEquiv.coe_toRingHom, Iso.commRingCatIsoToRingEquiv_toRingHom,
Scheme.Hom.appIso_hom']
simp only [homOfLE_leOfHom, Scheme.Hom.app_eq_appLE, ← RingHom.comp_apply,
← CommRingCat.hom_comp, Scheme.Hom.appLE_map, Scheme.Hom.appLE_comp_appLE]
simpa [Scheme.Hom.appLE] using ideal_ker_le _ _ (Ideal.mem_iInf.mp hs i)
lemma Hom.iInf_ker_openCover_map_comp (f : X ⟶ Y) [QuasiCompact f] (𝒰 : X.OpenCover) :
⨅ i, (𝒰.f i ≫ f).ker = f.ker := by
refine le_antisymm ?_ (le_iInf fun i ↦ (𝒰.f i).le_ker_comp f)
refine iInf_le_iff.mpr fun I hI U ↦ ?_
rw [← f.iInf_ker_openCover_map_comp_apply 𝒰, le_iInf_iff]
exact fun i ↦ hI i U
lemma Hom.iUnion_support_ker_openCover_map_comp
(f : X.Hom Y) [QuasiCompact f] (𝒰 : X.OpenCover) [Finite 𝒰.I₀] :
⋃ i, ((𝒰.f i ≫ f).ker.support : Set Y) = f.ker.support := by
cases isEmpty_or_nonempty 𝒰.I₀
· have : IsEmpty X := Function.isEmpty 𝒰.idx
simp [ker_eq_top_of_isEmpty]
suffices ∀ U : Y.affineOpens,
(⋃ i, (𝒰.f i ≫ f).ker.support) ∩ U = (f.ker.support ∩ U : Set Y) by
ext x
obtain ⟨_, ⟨U, hU, rfl⟩, hxU, -⟩ :=
Y.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ x) isOpen_univ
simpa [hxU] using congr(x ∈ $(this ⟨U, hU⟩))
intro U
simp only [Set.iUnion_inter, coe_support_inter, ← f.iInf_ker_openCover_map_comp_apply 𝒰,
Scheme.zeroLocus_iInf_of_nonempty]
lemma ker_morphismRestrict_ideal (f : X.Hom Y) [QuasiCompact f]
(U : Y.Opens) (V : U.toScheme.affineOpens) :
(f ∣_ U).ker.ideal V = f.ker.ideal ⟨U.ι ''ᵁ V, V.2.image_of_isOpenImmersion _⟩ := by
have inst : QuasiCompact (f ∣_ U) := MorphismProperty.of_isPullback
(isPullback_morphismRestrict _ _).flip inferInstance
ext x
simpa [Scheme.Hom.appLE] using map_eq_zero_iff _
(ConcreteCategory.bijective_of_isIso
(X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op)).1
lemma ker_ideal_of_isPullback_of_isOpenImmersion {X Y U V : Scheme.{u}}
(f : X ⟶ Y) (f' : U ⟶ V) (iU : U ⟶ X) (iV : V ⟶ Y) [IsOpenImmersion iV]
[QuasiCompact f] (H : IsPullback f' iU iV f) (W) :
f'.ker.ideal W =
(f.ker.ideal ⟨iV ''ᵁ W, W.2.image_of_isOpenImmersion _⟩).comap (iV.appIso W).inv.hom := by
have : QuasiCompact f' := MorphismProperty.of_isPullback H.flip inferInstance
have : IsOpenImmersion iU := MorphismProperty.of_isPullback H inferInstance
ext x
have : iU ''ᵁ f' ⁻¹ᵁ W = f ⁻¹ᵁ iV ''ᵁ W :=
IsOpenImmersion.image_preimage_eq_preimage_image_of_isPullback H W
let e : Γ(X, f ⁻¹ᵁ iV ''ᵁ W) ≅ Γ(U, f' ⁻¹ᵁ W) :=
X.presheaf.mapIso (eqToIso this).op ≪≫ iU.appIso _
have : (iV.appIso W).inv ≫ f.app _ = f'.app W ≫ e.inv := by
rw [Iso.inv_comp_eq, ← Category.assoc, Iso.eq_comp_inv]
simp only [Scheme.Hom.app_eq_appLE, Iso.trans_hom, Functor.mapIso_hom, Iso.op_hom, eqToIso.hom,
eqToHom_op, Scheme.Hom.appIso_hom', Scheme.Hom.map_appLE, e, Scheme.Hom.appLE_comp_appLE, H.w]
simp only [Scheme.Hom.ker_apply, RingHom.mem_ker, Ideal.mem_comap, ← RingHom.comp_apply,
← CommRingCat.hom_comp, this]
simpa using (map_eq_zero_iff _ (ConcreteCategory.bijective_of_isIso e.inv).1).symm
lemma Hom.support_ker (f : X ⟶ Y) [QuasiCompact f] :
f.ker.support = closure (Set.range f) := by
apply subset_antisymm
· wlog hY : ∃ S, Y = Spec S
· intro x hx
let 𝒰 := Y.affineCover
obtain ⟨i, x, rfl⟩ := 𝒰.exists_eq x
have inst : QuasiCompact (𝒰.pullbackHom f i) :=
MorphismProperty.pullback_snd _ _ inferInstance
have := this (𝒰.pullbackHom f i) ⟨_, rfl⟩
((coe_support_inter _ ⟨⊤, isAffineOpen_top _⟩).ge ⟨?_, Set.mem_univ x⟩).1
· have := image_closure_subset_closure_image (f := 𝒰.f i)
(𝒰.f i).continuous (Set.mem_image_of_mem _ this)
rw [← Set.range_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, 𝒰.pullbackHom_map] at this
exact closure_mono (Set.range_comp_subset_range _ _) this
· rw [← (𝒰.f i).isOpenEmbedding.injective.mem_set_image, Scheme.image_zeroLocus,
ker_ideal_of_isPullback_of_isOpenImmersion f (𝒰.pullbackHom f i)
((𝒰.pullback₁ f).f i) (𝒰.f i),
Ideal.coe_comap, Set.image_preimage_eq]
· exact ⟨((coe_support_inter _ _).le ⟨hx, by simp⟩).1, ⟨_, rfl⟩⟩
· exact (ConcreteCategory.bijective_of_isIso ((𝒰.f i).appIso ⊤).inv).2
· exact (IsPullback.of_hasPullback _ _).flip
obtain ⟨S, rfl⟩ := hY
wlog hX : ∃ R, X = Spec R generalizing X S
· intro x hx
have inst : CompactSpace X := HasAffineProperty.iff_of_isAffine.mp ‹QuasiCompact f›
let 𝒰 := X.affineCover.finiteSubcover
obtain ⟨_, ⟨i, rfl⟩, hx⟩ := (f.iUnion_support_ker_openCover_map_comp 𝒰).ge hx
have inst : QuasiCompact (𝒰.f i ≫ f) := HasAffineProperty.iff_of_isAffine.mpr
(by change CompactSpace (Spec _); infer_instance)
exact closure_mono (Set.range_comp_subset_range _ _) (this S (𝒰.f i ≫ f) ⟨_, rfl⟩ hx)
obtain ⟨R, rfl⟩ := hX
obtain ⟨φ, rfl⟩ := Spec.map_surjective f
rw [ker_of_isAffine, coe_support_ofIdealTop, Spec_zeroLocus, ← Ideal.coe_comap,
RingHom.comap_ker, ← PrimeSpectrum.closure_range_comap, ← CommRingCat.hom_comp,
← Scheme.ΓSpecIso_inv_naturality]
simp only [CommRingCat.hom_comp, PrimeSpectrum.comap_comp, ContinuousMap.coe_comp]
exact closure_mono (Set.range_comp_subset_range _ (Spec.map φ))
· rw [(support _).isClosed.closure_subset_iff]
exact f.range_subset_ker_support
/-- The functor taking a morphism into `Y` to its kernel as an ideal sheaf on `Y`. -/
@[simps]
def kerFunctor (Y : Scheme.{u}) : (Over Y)ᵒᵖ ⥤ IdealSheafData Y where
obj f := f.unop.hom.ker
map {f g} hfg := homOfLE <| by simpa only [Functor.id_obj, Functor.const_obj_obj,
OrderDual.toDual_le_toDual, ← Over.w hfg.unop] using hfg.unop.left.le_ker_comp f.unop.hom
map_id _ := Subsingleton.elim _ _
map_comp _ _ := Subsingleton.elim _ _
variable (X) in
@[simp]
lemma ker_toSpecΓ [CompactSpace X] : X.toSpecΓ.ker = ⊥ := by
apply IdealSheafData.ext_of_isAffine
simpa using RingHom.ker_coe_equiv (ΓSpecIso Γ(X, ⊤)).commRingCatIsoToRingEquiv
end ker
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/IdealSheaf/Functorial.lean | import Mathlib.AlgebraicGeometry.Morphisms.ClosedImmersion
import Mathlib.AlgebraicGeometry.PullbackCarrier
/-!
# Functorial constructions of ideal sheaves
We define the pullback and pushforward of ideal sheaves in this file.
## Main definitions
- `AlgebraicGeometry.Scheme.IdealSheafData.comap`: The pullback of an ideal sheaf.
- `AlgebraicGeometry.Scheme.IdealSheafData.map`: The pushforward of an ideal sheaf.
- `AlgebraicGeometry.Scheme.IdealSheafData.map_gc`:
The Galois connection between pullback and pushforward.
-/
noncomputable section
universe u
open CategoryTheory Limits
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}}
namespace Scheme.IdealSheafData
/-- The pullback of an ideal sheaf. -/
def comap (I : Y.IdealSheafData) (f : X ⟶ Y) : X.IdealSheafData :=
(pullback.fst f I.subschemeι).ker
/-- The subscheme associated to the pullback ideal sheaf is isomorphic to the fibred product. -/
def comapIso (I : Y.IdealSheafData) (f : X ⟶ Y) :
(I.comap f).subscheme ≅ pullback f I.subschemeι :=
(asIso (pullback.fst f I.subschemeι).toImage).symm
@[reassoc (attr := simp)]
lemma comapIso_inv_subschemeι (I : Y.IdealSheafData) (f : X ⟶ Y) :
(I.comapIso f).inv ≫ (I.comap f).subschemeι = pullback.fst _ _ :=
(pullback.fst f I.subschemeι).toImage_imageι
@[reassoc (attr := simp)]
lemma comapIso_hom_fst (I : Y.IdealSheafData) (f : X ⟶ Y) :
(I.comapIso f).hom ≫ pullback.fst _ _ = (I.comap f).subschemeι := by
rw [← comapIso_inv_subschemeι, Iso.hom_inv_id_assoc]
@[simp]
lemma comap_comp (I : Z.IdealSheafData) (f : X ⟶ Y) (g : Y ⟶ Z) :
I.comap (f ≫ g) = (I.comap g).comap f := by
let e : pullback f (I.comap g).subschemeι ≅ pullback (f ≫ g) I.subschemeι :=
asIso (pullback.map _ _ _ _ (𝟙 _) (I.comapIso g).hom (𝟙 _) (by simp) (by simp)) ≪≫
pullbackRightPullbackFstIso _ _ _
rw [comap, comap, ← Scheme.Hom.ker_comp_of_isIso e.hom]
simp [e]
@[simp]
lemma comap_id (I : Z.IdealSheafData) :
I.comap (𝟙 _) = I := by
rw [comap, ← Scheme.Hom.ker_comp_of_isIso (inv (pullback.snd _ _)),
pullback_inv_snd_fst_of_left_isIso, IsIso.inv_id, Category.comp_id, ker_subschemeι]
@[simp]
lemma support_comap (I : Y.IdealSheafData) (f : X ⟶ Y) :
(I.comap f).support = I.support.preimage f.continuous := by
ext1
rw [comap, Scheme.Hom.support_ker, Pullback.range_fst, range_subschemeι,
TopologicalSpace.Closeds.coe_preimage, (I.support.isClosed.preimage f.continuous).closure_eq]
lemma ker_fst_of_isClosedImmersion (i : Z ⟶ Y) (f : X ⟶ Y) [IsClosedImmersion i] :
(pullback.fst f i).ker = i.ker.comap f := by
delta IdealSheafData.comap
rw [← Hom.ker_comp_of_isIso (pullback.map f i f i.imageι (𝟙 _) (i.toImage) (𝟙 _)
(by simp) (by simp)), pullback.lift_fst, Category.comp_id]
/-- To show that the pullback of the closed immersion `iX` along `f` is the closed immersion
`iY`, it suffices to check that the preimage of `ker iY` under `f` is `ker iX`. -/
lemma _root_.AlgebraicGeometry.isPullback_of_isClosedImmersion
{ZX ZY X Y : Scheme} (iX : ZX ⟶ X) (iY : ZY ⟶ Y) (Zf : ZX ⟶ ZY) (f : X ⟶ Y)
[IsClosedImmersion iX] [IsClosedImmersion iY]
(h : iX ≫ f = Zf ≫ iY) (h' : iY.ker.comap f = iX.ker) : IsPullback iX Zf f iY := by
suffices IsIso (pullback.lift _ _ h) by
simpa using (IsPullback.of_vert_isIso (show CommSq iX (pullback.lift iX Zf h)
(𝟙 X) (pullback.fst _ _) from ⟨by simp⟩)).paste_vert (IsPullback.of_hasPullback f iY)
refine IsClosedImmersion.isIso_of_ker_eq iX (pullback.fst f iY) _ (by simp) ?_
rw [ker_fst_of_isClosedImmersion, h']
/-- The pushforward of an ideal sheaf. -/
def map (I : X.IdealSheafData) (f : X ⟶ Y) : Y.IdealSheafData :=
(I.subschemeι ≫ f).ker
lemma le_map_iff_comap_le {I : X.IdealSheafData} {f : X ⟶ Y} {J : Y.IdealSheafData} :
J ≤ I.map f ↔ J.comap f ≤ I := by
constructor
· intro H
rw [← I.ker_subschemeι, ← pullback.lift_fst (f := f) (g := J.subschemeι) I.subschemeι
((I.subschemeι ≫ f).toImage ≫ inclusion H) (by simp)]
exact Hom.le_ker_comp _ _
· intro H
have : (inclusion H ≫ (J.comapIso f).hom ≫ pullback.snd _ _) ≫ J.subschemeι =
I.subschemeι ≫ f := by simp [← pullback.condition]
rw [map, ← J.ker_subschemeι, ← this]
exact Hom.le_ker_comp _ _
section gc
variable (I I₁ I₂ : X.IdealSheafData) (J J₁ J₂ : Y.IdealSheafData) (f : X ⟶ Y)
/-- Pushforward and pullback of ideal sheaves forms a Galois connection. -/
lemma map_gc : GaloisConnection (comap · f) (map · f) := fun _ _ ↦ le_map_iff_comap_le.symm
set_option linter.style.commandStart false
lemma map_mono : Monotone (map · f) := (map_gc f).monotone_u
lemma comap_mono : Monotone (comap · f) := (map_gc f).monotone_l
lemma le_map_comap : J ≤ (J.comap f).map f := (map_gc f).le_u_l J
lemma comap_map_le : (I.map f).comap f ≤ I := (map_gc f).l_u_le I
@[simp] lemma map_top : map ⊤ f = ⊤ := (map_gc f).u_top
@[simp] lemma comap_bot : comap ⊥ f = ⊥ := (map_gc f).l_bot
@[simp] lemma map_inf : map (I₁ ⊓ I₂) f = map I₁ f ⊓ map I₂ f := (map_gc f).u_inf
@[simp] lemma comap_sup : comap (J₁ ⊔ J₂) f = comap J₁ f ⊔ comap J₂ f := (map_gc f).l_sup
set_option linter.style.commandStart true
end gc
@[simp]
lemma map_bot (f : X ⟶ Y) : map ⊥ f = f.ker := by
simp [map, Scheme.Hom.ker_comp_of_isIso]
@[simp]
lemma comap_top (f : X ⟶ Y) : comap ⊤ f = ⊤ := by
rw [comap, Hom.ker_eq_top_iff_isEmpty]
exact Function.isEmpty (pullback.snd f _)
@[simp]
lemma map_comp (I : X.IdealSheafData) (f : X ⟶ Y) (g : Y ⟶ Z) :
I.map (f ≫ g) = (I.map f).map g := by
apply le_antisymm
· rw [le_map_iff_comap_le, le_map_iff_comap_le, ← comap_comp]; exact comap_map_le _ _
· rw [le_map_iff_comap_le, comap_comp]
exact (comap_mono _ (comap_map_le _ _)).trans (comap_map_le _ _)
@[simp]
lemma map_id (I : Z.IdealSheafData) :
I.map (𝟙 _) = I := by
simp [map]
lemma map_ker (f : X ⟶ Y) (g : Y ⟶ Z) : f.ker.map g = (f ≫ g).ker := by
simp [← map_bot]
lemma _root_.AlgebraicGeometry.Scheme.Hom.ker_comp
(f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).ker = f.ker.map g := (map_ker f g).symm
lemma map_vanishingIdeal {X Y : Scheme} (f : X ⟶ Y) (Z : TopologicalSpace.Closeds X) :
(vanishingIdeal Z).map f = vanishingIdeal (.closure (f '' Z)) := by
apply le_antisymm
· rw [map, ← le_support_iff_le_vanishingIdeal, TopologicalSpace.Closeds.closure_le]
refine .trans ?_ (Hom.range_subset_ker_support _)
rw [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp,
range_subschemeι, coe_support_vanishingIdeal]
· simp [le_map_iff_comap_le, ← le_support_iff_le_vanishingIdeal, ← Set.image_subset_iff,
subset_closure, ← SetLike.coe_subset_coe]
@[simp]
lemma support_map (I : X.IdealSheafData) (f : X ⟶ Y) [QuasiCompact f] :
(I.map f).support = .closure (f '' I.support) := by
ext1
rw [map, Scheme.Hom.support_ker, Scheme.Hom.comp_base, TopCat.coe_comp,
Set.range_comp, range_subschemeι, TopologicalSpace.Closeds.coe_closure]
lemma ideal_map (I : X.IdealSheafData) (f : X ⟶ Y) [QuasiCompact f] (U : Y.affineOpens)
(H : IsAffineOpen (f ⁻¹ᵁ U)) :
(I.map f).ideal U = (I.ideal ⟨_, H⟩).comap (f.app U).hom := by
have : RingHom.ker (I.subschemeObjIso ⟨_, H⟩).inv.hom = ⊥ :=
RingHom.ker_coe_equiv (I.subschemeObjIso ⟨_, H⟩).symm.commRingCatIsoToRingEquiv
simp [map, ← RingHom.comap_ker, subschemeι_app _ ⟨_, H⟩,
this, ← RingHom.ker_eq_comap_bot]
lemma ideal_map_of_isAffineHom
(I : X.IdealSheafData) (f : X ⟶ Y) [IsAffineHom f] (U : Y.affineOpens) :
(I.map f).ideal U = (I.ideal ⟨_, U.2.preimage f⟩).comap (f.app U).hom :=
ideal_map I f U (U.2.preimage f)
lemma ideal_comap_of_isOpenImmersion
(I : Y.IdealSheafData) (f : X ⟶ Y) [IsOpenImmersion f] (U : X.affineOpens) :
(I.comap f).ideal U = (I.ideal ⟨f ''ᵁ U, U.2.image_of_isOpenImmersion f⟩).comap
(f.appIso U).inv.hom := by
refine (ker_ideal_of_isPullback_of_isOpenImmersion _ _ _ _
(IsPullback.of_hasPullback f I.subschemeι) U).trans ?_
simp
/-- If `J ≤ I.map f`, then `f` restricts to a map `I ⟶ J` between the closed subschemes. -/
def subschemeMap (I : X.IdealSheafData) (J : Y.IdealSheafData)
(f : X ⟶ Y) (H : J ≤ I.map f) : I.subscheme ⟶ J.subscheme :=
IsClosedImmersion.lift J.subschemeι (I.subschemeι ≫ f) (by simpa using H)
@[reassoc (attr := simp)]
lemma subschemeMap_subschemeι (I : X.IdealSheafData) (J : Y.IdealSheafData)
(f : X ⟶ Y) (H : J ≤ I.map f) : subschemeMap I J f H ≫ J.subschemeι = I.subschemeι ≫ f :=
IsClosedImmersion.lift_fac _ _ _
@[reassoc (attr := simp)]
lemma comapIso_hom_snd (I : Y.IdealSheafData) (f : X ⟶ Y) :
(I.comapIso f).hom ≫ pullback.snd _ _ = subschemeMap _ _ f (I.le_map_comap f) := by
rw [← cancel_mono I.subschemeι]
simp [← pullback.condition]
end Scheme.IdealSheafData
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/Representability.lean | import Mathlib.CategoryTheory.MorphismProperty.Representable
import Mathlib.AlgebraicGeometry.Sites.BigZariski
import Mathlib.AlgebraicGeometry.OpenImmersion
import Mathlib.AlgebraicGeometry.GluingOneHypercover
import Mathlib.CategoryTheory.Sites.LocallyBijective
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Iso
/-!
# Representability of schemes is a local property
In this file we prove that a sheaf of types `F` on `Sch` is representable if it is
locally representable.
## Main result
- `AlgebraicGeometry.Scheme.LocalRepresentability.isRepresentable`:
Suppose
* F is a `Type u`-valued sheaf on `Sch` with respect to the Zariski topology
* X : ι → Sch is a family of schemes
* f : Π i, yoneda.obj (X i) ⟶ F is a family of relatively representable open immersions
* f is jointly surjective
Then `F` is representable.
## References
* https://stacks.math.columbia.edu/tag/01JJ
-/
namespace AlgebraicGeometry
open CategoryTheory Category Limits Opposite
attribute [local instance] Types.instFunLike Types.instConcreteCategory
universe u
namespace Scheme
/-
Consider the following setup:
* F is `Type u`-valued a sheaf on `Sch` with respect to the Zariski topology
* X : ι → Sch is a family of schemes
* f : Π i, yoneda.obj (X i) ⟶ F is a family of relatively representable open immersions
Later, we will also assume:
* The family f is locally surjective with respect to the Zariski topology
-/
variable (F : Sheaf Scheme.zariskiTopology.{u} (Type u))
{ι : Type u} {X : ι → Scheme.{u}}
(f : (i : ι) → yoneda.obj (X i) ⟶ F.1) (hf : ∀ i, IsOpenImmersion.presheaf (f i))
namespace LocalRepresentability
variable {F f} (i j k : ι)
open Functor.relativelyRepresentable in
/-- We get a family of gluing data by taking `U i = X i` and `V i j = (hf i).rep.pullback (f j)`. -/
@[simps]
noncomputable def glueData : GlueData where
J := ι
U := X
V := fun (i, j) ↦ (hf i).rep.pullback (f j)
f i j := (hf i).rep.fst' (f j)
f_mono i j :=
have := (hf j).property _ _ _ ((hf i).1.isPullback' (f j)).flip
IsOpenImmersion.mono _
f_id i := IsOpenImmersion.isIso_fst'_self IsOpenImmersion.le_monomorphisms (hf i)
t i j := (hf i).rep.symmetry (hf j).rep
t_id i := by apply (hf i).rep.hom_ext' <;>
simp [IsOpenImmersion.fst'_self_eq_snd IsOpenImmersion.le_monomorphisms (hf i)]
t' i j k := lift₃ _ _ _ (pullback₃.p₂ _ _ _) (pullback₃.p₃ _ _ _) (pullback₃.p₁ _ _ _)
(by simp) (by simp)
t_fac i j k := (hf j).rep.hom_ext' (by simp) (by simp)
cocycle i j k := pullback₃.hom_ext (by simp) (by simp) (by simp)
f_open i j := (hf j).property _ _ _ ((hf i).1.isPullback' (f j)).flip
/-- The map from `X i` to the glued scheme `(glueData hf).glued` -/
noncomputable def toGlued (i : ι) : X i ⟶ (glueData hf).glued :=
(glueData hf).ι i
instance : IsOpenImmersion (toGlued hf i) :=
inferInstanceAs (IsOpenImmersion ((glueData hf).ι i))
/-- The map from the glued scheme `(glueData hf).glued`, treated as a sheaf, to `F`. -/
noncomputable def yonedaGluedToSheaf :
zariskiTopology.yoneda.obj (glueData hf).glued ⟶ F where
-- The map is obtained by finding an object of `F((glueData hf).glued)`.
val := yonedaEquiv.symm
-- This section is obtained from gluing the section corresponding to `f i : Hom(-, X i) ⟶ F`.
((glueData hf).sheafValGluedMk (fun i ↦ yonedaEquiv (f i)) (by
intro i j
apply yonedaEquiv.symm.injective
dsimp only [glueData_V, glueData_J, glueData_U, glueData_f, glueData_t]
rw [yonedaEquiv_naturality, Equiv.symm_apply_apply,
FunctorToTypes.map_comp_apply, yonedaEquiv_naturality, yonedaEquiv_naturality,
Equiv.symm_apply_apply, ← Functor.map_comp_assoc,
Functor.relativelyRepresentable.symmetry_fst, ((hf i).rep.isPullback' (f j)).w]))
@[reassoc (attr := simp)]
lemma yoneda_toGlued_yonedaGluedToSheaf (i : ι) :
yoneda.map (toGlued hf i) ≫ (yonedaGluedToSheaf hf).val = f i := by
apply yonedaEquiv.injective
rw [yonedaGluedToSheaf, yonedaEquiv_apply, yonedaEquiv_apply,
FunctorToTypes.comp, yoneda_map_app, id_comp, yonedaEquiv_symm_app_apply]
apply GlueData.sheafValGluedMk_val
@[simp]
lemma yonedaGluedToSheaf_app_toGlued {i : ι} :
(yonedaGluedToSheaf hf).val.app _ (toGlued hf i) = yonedaEquiv (f i) := by
rw [← yoneda_toGlued_yonedaGluedToSheaf hf i, yonedaEquiv_comp,
yonedaEquiv_yoneda_map]
@[simp]
lemma yonedaGluedToSheaf_app_comp {V U : Scheme.{u}} (γ : V ⟶ U) (α : U ⟶ (glueData hf).glued) :
(yonedaGluedToSheaf hf).val.app (op V) (γ ≫ α) =
F.val.map γ.op ((yonedaGluedToSheaf hf).val.app (op U) α) :=
congr_fun ((yonedaGluedToSheaf hf).val.naturality γ.op) α
instance [Presheaf.IsLocallySurjective Scheme.zariskiTopology (Sigma.desc f)] :
Sheaf.IsLocallySurjective (yonedaGluedToSheaf hf) :=
Presheaf.isLocallySurjective_of_isLocallySurjective_fac _
(show Sigma.desc (fun i ↦ yoneda.map (toGlued hf i)) ≫
(yonedaGluedToSheaf hf).val = Sigma.desc f by cat_disch)
lemma comp_toGlued_eq {U : Scheme} {i j : ι} (a : U ⟶ X i) (b : U ⟶ X j)
(h : yoneda.map a ≫ f i = yoneda.map b ≫ f j) :
a ≫ toGlued hf i = b ≫ toGlued hf j := by
rw [← (hf i).rep.lift'_fst a b h, assoc]
conv_rhs => rw [← (hf i).rep.lift'_snd a b h, assoc]
congr 1
exact ((glueData hf).glue_condition i j).symm.trans (by simp [toGlued])
@[simp]
lemma glueData_openCover_map : (glueData hf).openCover.f j = toGlued hf j := rfl
instance : Sheaf.IsLocallyInjective (yonedaGluedToSheaf hf) where
equalizerSieve_mem := by
rintro ⟨U⟩ (α β : U ⟶ _) h
replace h : (yonedaGluedToSheaf hf).val.app _ α = (yonedaGluedToSheaf hf).val.app _ β := h
have mem := (glueData hf).openCover.mem_grothendieckTopology
refine GrothendieckTopology.superset_covering _ ?_
(zariskiTopology.intersection_covering (zariskiTopology.pullback_stable α mem)
(zariskiTopology.pullback_stable β mem))
rintro V (γ : _ ⟶ U) ⟨⟨W₁, a, _, ⟨i⟩, fac₁⟩, ⟨W₂, b, _, ⟨j⟩, fac₂⟩⟩
change γ ≫ α = γ ≫ β
replace h : (yonedaGluedToSheaf hf).val.app _ (γ ≫ α) =
(yonedaGluedToSheaf hf).val.app _ (γ ≫ β) := by simp [h]
rw [← fac₁, ← fac₂] at h ⊢
apply comp_toGlued_eq
simpa [Scheme.GlueData.openCover_X, yonedaEquiv_naturality] using h
variable [Presheaf.IsLocallySurjective Scheme.zariskiTopology (Sigma.desc f)]
instance : IsIso (yonedaGluedToSheaf hf) := by
rw [← Sheaf.isLocallyBijective_iff_isIso (yonedaGluedToSheaf hf)]
constructor <;> infer_instance
/-- The isomorphism between `yoneda.obj (glueData hf).glued` and `F`.
This implies that `F` is representable. -/
noncomputable def yonedaIsoSheaf :
zariskiTopology.yoneda.obj (glueData hf).glued ≅ F :=
asIso (yonedaGluedToSheaf hf)
/--
Suppose
* F is a `Type u`-valued sheaf on `Sch` with respect to the Zariski topology
* X : ι → Sch is a family of schemes
* f : Π i, yoneda.obj (X i) ⟶ F is a family of relatively representable open immersions
* f is jointly surjective
Then `F` is representable, and the representing object is glued from the `X i`s
-/
noncomputable
def representableBy : F.1.RepresentableBy (glueData hf).glued :=
Functor.representableByEquiv.symm ((sheafToPresheaf _ _).mapIso (yonedaIsoSheaf hf))
include hf in
/--
Suppose
* F is a `Type u`-valued sheaf on `Sch` with respect to the Zariski topology
* X : ι → Sch is a family of schemes
* f : Π i, yoneda.obj (X i) ⟶ F is a family of relatively representable open immersions
* f is jointly surjective
Then `F` is representable.
-/
@[stacks 01JJ]
theorem isRepresentable : F.1.IsRepresentable :=
⟨_, ⟨representableBy hf⟩⟩
end LocalRepresentability
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/Pretopology.lean | import Mathlib.AlgebraicGeometry.Sites.MorphismProperty
import Mathlib.AlgebraicGeometry.PullbackCarrier
/-!
# Grothendieck topology defined by a morphism property
Given a multiplicative morphism property `P` that is stable under base change, we define the
associated (pre)topology on the category of schemes, where coverings are given
by jointly surjective families of morphisms satisfying `P`.
## Implementation details
The pretopology is obtained from the precoverage `AlgebraicGeometry.Scheme.precoverage` defined in
`Mathlib.AlgebraicGeometry.Sites.MorphismProperty`. The definition is postponed to this file,
because the former does not have `HasPullbacks Scheme`.
-/
universe v u
open CategoryTheory Limits
namespace AlgebraicGeometry.Scheme
/--
The pretopology on the category of schemes defined by covering families where the components
satisfy `P`.
-/
def pretopology (P : MorphismProperty Scheme.{u}) [P.IsStableUnderBaseChange]
[P.IsMultiplicative] : Pretopology Scheme.{u} :=
(precoverage P).toPretopology
/-- The Grothendieck topology on the category of schemes induced by the pretopology defined by
`P`-covers. -/
abbrev grothendieckTopology (P : MorphismProperty Scheme.{u}) [P.IsStableUnderBaseChange]
[P.IsMultiplicative] :
GrothendieckTopology Scheme.{u} :=
(pretopology P).toGrothendieck
instance : jointlySurjectivePrecoverage.IsStableUnderBaseChange :=
isStableUnderBaseChange_comap_jointlySurjectivePrecoverage _
fun f g _ ↦ pullbackComparison_forget_surjective f g
/-- The pretopology on the category of schemes defined by jointly surjective families. -/
def jointlySurjectivePretopology : Pretopology Scheme.{u} :=
jointlySurjectivePrecoverage.toPretopology
variable {P : MorphismProperty Scheme.{u}} [P.IsStableUnderBaseChange] [P.IsMultiplicative]
@[grind ←]
lemma Cover.mem_pretopology {X : Scheme.{u}} {𝒰 : X.Cover (precoverage P)} :
Presieve.ofArrows 𝒰.X 𝒰.f ∈ pretopology P X := by
rw [pretopology, Precoverage.toPretopology_toPrecoverage, ofArrows_mem_precoverage_iff]
exact ⟨fun x ↦ ⟨𝒰.idx x, 𝒰.covers x⟩, 𝒰.map_prop⟩
lemma mem_pretopology_iff {X : Scheme.{u}} {R : Presieve X} :
R ∈ pretopology P X ↔ ∃ (𝒰 : Cover.{u + 1} (precoverage P) X),
R = Presieve.ofArrows 𝒰.X 𝒰.f :=
Precoverage.mem_iff_exists_zeroHypercover
alias ⟨exists_cover_of_mem_pretopology, _⟩ := mem_pretopology_iff
lemma mem_grothendieckTopology_iff {X : Scheme.{u}} {S : Sieve X} :
S ∈ grothendieckTopology P X ↔
∃ (𝒰 : Cover.{u} (precoverage P) X), Presieve.ofArrows 𝒰.X 𝒰.f ≤ S := by
simp_rw [grothendieckTopology, Pretopology.mem_toGrothendieck]
refine ⟨fun ⟨R, hR, hle⟩ ↦ ?_, fun ⟨𝒰, hle⟩ ↦ ⟨.ofArrows 𝒰.X 𝒰.f, 𝒰.mem_pretopology, hle⟩⟩
rw [mem_pretopology_iff] at hR
obtain ⟨𝒰, rfl⟩ := hR
use 𝒰.ulift, le_trans (fun Y g ⟨i⟩ ↦ .mk _) hle
alias ⟨exists_cover_of_mem_grothendieckTopology, _⟩ := mem_grothendieckTopology_iff
@[grind ←]
lemma Cover.mem_grothendieckTopology {X : Scheme.{u}} {𝒰 : X.Cover (precoverage P)} :
Sieve.ofArrows 𝒰.X 𝒰.f ∈ grothendieckTopology P X := by
rw [Pretopology.mem_toGrothendieck]
use Presieve.ofArrows 𝒰.X 𝒰.f, 𝒰.mem_pretopology
exact Sieve.le_generate (Presieve.ofArrows 𝒰.X 𝒰.f)
@[deprecated (since := "2025-08-28")]
alias pretopology_cover := Cover.mem_pretopology
@[deprecated (since := "2025-08-28")]
alias grothendieckTopology_cover := Cover.mem_grothendieckTopology
section
@[deprecated (since := "2025-08-18")] alias surjectiveFamiliesPretopology :=
jointlySurjectivePretopology
/-- The jointly surjective topology on `Scheme` is defined by the same condition as the jointly
surjective pretopology. -/
def jointlySurjectiveTopology : GrothendieckTopology Scheme.{u} :=
jointlySurjectivePretopology.toGrothendieck.copy (fun X s ↦ jointlySurjectivePretopology X ↑s) <|
funext fun _ ↦ Set.ext fun s ↦
⟨fun ⟨_, hp, hps⟩ x ↦ let ⟨Y, u, hu, hmem⟩ := hp x;
⟨Y, u, Presieve.map_monotone hps _ hu, hmem⟩,
fun hs ↦ ⟨s, hs, le_rfl⟩⟩
theorem mem_jointlySurjectiveTopology_iff_jointlySurjectivePretopology
{X : Scheme.{u}} {s : Sieve X} :
s ∈ jointlySurjectiveTopology X ↔ jointlySurjectivePretopology X ↑s :=
Iff.rfl
lemma jointlySurjectiveTopology_eq_toGrothendieck_jointlySurjectivePretopology :
jointlySurjectiveTopology.{u} = jointlySurjectivePretopology.toGrothendieck :=
GrothendieckTopology.copy_eq
variable (P)
/--
The pretopology defined by `P`-covers agrees with the
the intersection of the pretopology of surjective families with the pretopology defined by `P`.
-/
lemma pretopology_eq_inf : pretopology P = jointlySurjectivePretopology ⊓ P.pretopology := rfl
@[deprecated (since := "2025-08-28")]
alias pretopology_le_inf := pretopology_eq_inf
/--
The Grothendieck topology defined by `P`-covers agrees with the Grothendieck
topology induced by the intersection of the pretopology of surjective families with
the pretopology defined by `P`.
-/
lemma grothendieckTopology_eq_inf :
grothendieckTopology P = (jointlySurjectivePretopology ⊓ P.pretopology).toGrothendieck := by
rw [grothendieckTopology, pretopology_eq_inf]
end
section
variable {Q : MorphismProperty Scheme.{u}} [Q.IsMultiplicative] [Q.IsStableUnderBaseChange]
lemma pretopology_monotone (hPQ : P ≤ Q) : pretopology P ≤ pretopology Q := by
rintro X R hR
obtain ⟨𝒰, rfl⟩ := exists_cover_of_mem_pretopology hR
rw [mem_pretopology_iff]
use 𝒰.changeProp (fun j ↦ hPQ _ (𝒰.map_prop j))
rfl
@[deprecated (since := "2025-09-22")]
alias pretopology_le_pretopology := pretopology_monotone
lemma grothendieckTopology_monotone (hPQ : P ≤ Q) :
grothendieckTopology P ≤ grothendieckTopology Q :=
(Pretopology.gi Scheme.{u}).gc.monotone_l (pretopology_monotone hPQ)
@[deprecated (since := "2025-09-22")]
alias grothendieckTopology_le_grothendieckTopology := grothendieckTopology_monotone
end
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/BigZariski.lean | import Mathlib.AlgebraicGeometry.Sites.Pretopology
import Mathlib.CategoryTheory.Sites.Canonical
/-!
# The big Zariski site of schemes
In this file, we define the Zariski topology, as a Grothendieck topology on the
category `Scheme.{u}`: this is `Scheme.zariskiTopology.{u}`. If `X : Scheme.{u}`,
the Zariski topology on `Over X` can be obtained as `Scheme.zariskiTopology.over X`
(see `CategoryTheory.Sites.Over`.).
TODO:
* If `Y : Scheme.{u}`, define a continuous functor from the category of opens of `Y`
to `Over Y`, and show that a presheaf on `Over Y` is a sheaf for the Zariski topology
iff its "restriction" to the topological space `Z` is a sheaf for all `Z : Over Y`.
* We should have good notions of (pre)sheaves of `Type (u + 1)` (e.g. associated
sheaf functor, pushforward, pullbacks) on `Scheme.{u}` for this topology. However,
some constructions in the `CategoryTheory.Sites` folder currently assume that
the site is a small category: this should be generalized. As a result,
this big Zariski site can considered as a test case of the Grothendieck topology API
for future applications to étale cohomology.
-/
universe v u
open CategoryTheory
namespace AlgebraicGeometry
namespace Scheme
/-- The Zariski pretopology on the category of schemes. -/
def zariskiPretopology : Pretopology Scheme.{u} :=
pretopology @IsOpenImmersion
/-- The Zariski topology on the category of schemes. -/
abbrev zariskiTopology : GrothendieckTopology Scheme.{u} :=
grothendieckTopology IsOpenImmersion
lemma zariskiTopology_eq : zariskiTopology.{u} = zariskiPretopology.toGrothendieck := rfl
instance subcanonical_zariskiTopology : zariskiTopology.Subcanonical := by
apply GrothendieckTopology.Subcanonical.of_isSheaf_yoneda_obj
intro X
rw [Presieve.isSheaf_pretopology]
rintro Y S hS x hx
obtain ⟨(𝓤 : OpenCover Y), rfl⟩ := exists_cover_of_mem_pretopology hS
let e : Y ⟶ X := 𝓤.glueMorphisms (fun j => x (𝓤.f _) (.mk _)) <| by
intro i j
apply hx
exact Limits.pullback.condition
refine ⟨e, ?_, ?_⟩
· rintro Z e ⟨j⟩
dsimp [e]
rw [𝓤.ι_glueMorphisms]
· intro e' h
apply 𝓤.hom_ext
intro j
rw [𝓤.ι_glueMorphisms]
exact h (𝓤.f j) (.mk j)
end Scheme
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/Etale.lean | import Mathlib.AlgebraicGeometry.Morphisms.Etale
import Mathlib.AlgebraicGeometry.PullbackCarrier
import Mathlib.AlgebraicGeometry.Sites.BigZariski
import Mathlib.AlgebraicGeometry.Sites.Small
/-!
# The étale site
In this file we define the big étale site, i.e. the étale topology as a Grothendieck topology
on the category of schemes.
-/
universe v u
open CategoryTheory MorphismProperty Limits
namespace AlgebraicGeometry.Scheme
/-- Big étale site: the étale pretopology on the category of schemes. -/
def etalePretopology : Pretopology Scheme.{u} :=
pretopology @IsEtale
/-- Big étale site: the étale topology on the category of schemes. -/
abbrev etaleTopology : GrothendieckTopology Scheme.{u} :=
etalePretopology.toGrothendieck
lemma zariskiTopology_le_etaleTopology : zariskiTopology ≤ etaleTopology := by
apply grothendieckTopology_monotone
intro X Y f hf
infer_instance
/-- The small étale site of a scheme is the Grothendieck topology on the
category of schemes étale over `X` induced from the étale topology on `Scheme.{u}`. -/
def smallEtaleTopology (X : Scheme.{u}) : GrothendieckTopology X.Etale :=
X.smallGrothendieckTopology (P := @IsEtale)
/-- The pretopology generating the small étale site. -/
def smallEtalePretopology (X : Scheme.{u}) : Pretopology X.Etale :=
X.smallPretopology (Q := @IsEtale) (P := @IsEtale)
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/Small.lean | import Mathlib.AlgebraicGeometry.Cover.Over
import Mathlib.AlgebraicGeometry.Sites.Pretopology
import Mathlib.CategoryTheory.Sites.DenseSubsite.InducedTopology
import Mathlib.CategoryTheory.Sites.Over
/-!
# Small sites
In this file we define the small sites associated to morphism properties and give
generating pretopologies.
## Main definitions
- `AlgebraicGeometry.Scheme.overGrothendieckTopology`: the Grothendieck topology on `Over S`
obtained by localizing the topology on `Scheme` induced by `P` at `S`.
- `AlgebraicGeometry.Scheme.overPretopology`: the pretopology on `Over S` defined by
`P`-coverings of `S`-schemes. The induced topology agrees with
`AlgebraicGeometry.Scheme.overGrothendieckTopology`.
- `AlgebraicGeometry.Scheme.smallGrothendieckTopology`: the by the inclusion
`P.Over ⊤ S ⥤ Over S` induced topology on `P.Over ⊤ S`.
- `AlgebraicGeometry.Scheme.smallPretopology`: the pretopology on `P.Over ⊤ S` defined by
`P`-coverings of `S`-schemes with `P`. The induced topology agrees
with `AlgebraicGeometry.Scheme.smallGrothendieckTopology`.
-/
universe v u
open CategoryTheory Limits
namespace AlgebraicGeometry.Scheme
variable {P Q : MorphismProperty Scheme.{u}} {S : Scheme.{u}}
[P.IsStableUnderBaseChange]
/-- The presieve defined by a `P`-cover of `S`-schemes. -/
def Cover.toPresieveOver {X : Over S} (𝒰 : Cover.{u} (precoverage P) X.left) [𝒰.Over S] :
Presieve X :=
Presieve.ofArrows (fun i ↦ (𝒰.X i).asOver S) (fun i ↦ (𝒰.f i).asOver S)
/-- The presieve defined by a `P`-cover of `S`-schemes with `Q`. -/
def Cover.toPresieveOverProp {X : Q.Over ⊤ S} (𝒰 : Cover.{u} (precoverage P) X.left) [𝒰.Over S]
(h : ∀ j, Q (𝒰.X j ↘ S)) : Presieve X :=
Presieve.ofArrows (fun i ↦ (𝒰.X i).asOverProp S (h i)) (fun i ↦ (𝒰.f i).asOverProp S)
lemma Cover.overEquiv_generate_toPresieveOver_eq_ofArrows {X : Over S}
(𝒰 : Cover.{u} (precoverage P) X.left)
[𝒰.Over S] : Sieve.overEquiv X (Sieve.generate 𝒰.toPresieveOver) =
Sieve.ofArrows 𝒰.X 𝒰.f := by
ext V f
simp only [Sieve.overEquiv_iff, Functor.const_obj_obj, Sieve.generate_apply]
constructor
· rintro ⟨U, h, g, ⟨k⟩, hcomp⟩
exact ⟨𝒰.X k, h.left, 𝒰.f k, ⟨k⟩, congrArg CommaMorphism.left hcomp⟩
· rintro ⟨U, h, g, ⟨k⟩, hcomp⟩
have : 𝒰.f k ≫ X.hom = 𝒰.X k ↘ S := comp_over (𝒰.f k) S
refine ⟨(𝒰.X k).asOver S, Over.homMk h (by simp [← hcomp, this]), (𝒰.f k).asOver S, ⟨k⟩, ?_⟩
ext : 1
simpa
lemma Cover.toPresieveOver_le_arrows_iff {X : Over S} (R : Sieve X)
(𝒰 : Cover.{u} (precoverage P) X.left) [𝒰.Over S] :
𝒰.toPresieveOver ≤ R.arrows ↔
Presieve.ofArrows 𝒰.X 𝒰.f ≤ (Sieve.overEquiv X R).arrows := by
simp_rw [← Sieve.giGenerate.gc.le_iff_le, ← Sieve.overEquiv_le_overEquiv_iff]
rw [overEquiv_generate_toPresieveOver_eq_ofArrows]
variable [P.IsMultiplicative] [P.RespectsIso]
variable (P Q S)
/-- The pretopology on `Over S` induced by `P` where coverings are given by `P`-covers
of `S`-schemes. -/
def overPretopology : Pretopology (Over S) where
coverings Y R := ∃ (𝒰 : Cover.{u} (precoverage P) Y.left) (_ : 𝒰.Over S), R = 𝒰.toPresieveOver
has_isos {X Y} f _ := ⟨coverOfIsIso f.left, inferInstance, (Presieve.ofArrows_pUnit _).symm⟩
pullbacks := by
rintro Y X f _ ⟨𝒰, h, rfl⟩
refine ⟨𝒰.pullbackCoverOver' S f.left, inferInstance, ?_⟩
simpa [Cover.toPresieveOver] using
(Presieve.ofArrows_pullback f (fun i ↦ (𝒰.X i).asOver S) (fun i ↦ (𝒰.f i).asOver S)).symm
transitive := by
rintro X _ T ⟨𝒰, h, rfl⟩ H
choose V h hV using H
refine ⟨𝒰.bind (fun j => V ((𝒰.f j).asOver S) ⟨j⟩), inferInstance, ?_⟩
convert Presieve.ofArrows_bind _ (fun j ↦ (𝒰.f j).asOver S) _
(fun Y f H j ↦ ((V f H).X j).asOver S) (fun Y f H j ↦ ((V f H).f j).asOver S)
apply hV
/-- The topology on `Over S` induced from the topology on `Scheme` defined by `P`.
This agrees with the topology induced by `S.overPretopology P`, see
`AlgebraicGeometry.Scheme.overGrothendieckTopology_eq_toGrothendieck_overPretopology`. -/
abbrev overGrothendieckTopology : GrothendieckTopology (Over S) :=
(Scheme.grothendieckTopology P).over S
lemma overGrothendieckTopology_eq_toGrothendieck_overPretopology :
S.overGrothendieckTopology P = (S.overPretopology P).toGrothendieck := by
ext X R
rw [GrothendieckTopology.mem_over_iff]
constructor
· intro hR
obtain ⟨𝒰, hle⟩ := exists_cover_of_mem_grothendieckTopology hR
rw [mem_grothendieckTopology_iff] at hR
letI (i : 𝒰.I₀) : (𝒰.X i).Over S := { hom := 𝒰.f i ≫ X.hom }
letI : 𝒰.Over S :=
{ over := inferInstance
isOver_map := fun i ↦ ⟨rfl⟩ }
use 𝒰.toPresieveOver, ⟨𝒰, inferInstance, rfl⟩
rwa [Cover.toPresieveOver_le_arrows_iff]
· rintro ⟨T, ⟨𝒰, h, rfl⟩, hT⟩
use Presieve.ofArrows 𝒰.X 𝒰.f, 𝒰.mem_pretopology
rwa [Cover.toPresieveOver_le_arrows_iff] at hT
variable {S}
lemma mem_overGrothendieckTopology (X : Over S) (R : Sieve X) :
R ∈ S.overGrothendieckTopology P X ↔
∃ (𝒰 : Cover.{u} (precoverage P) X.left) (_ : 𝒰.Over S), 𝒰.toPresieveOver ≤ R.arrows := by
rw [overGrothendieckTopology_eq_toGrothendieck_overPretopology]
constructor
· rintro ⟨T, ⟨𝒰, h, rfl⟩, hle⟩
use 𝒰, h
· rintro ⟨𝒰, h𝒰, hle⟩
exact ⟨𝒰.toPresieveOver, ⟨𝒰, h𝒰, rfl⟩, hle⟩
variable [Q.IsStableUnderComposition]
variable (S) {P Q} in
lemma locallyCoverDense_of_le (hPQ : P ≤ Q) :
(MorphismProperty.Over.forget Q ⊤ S).LocallyCoverDense (overGrothendieckTopology P S) where
functorPushforward_functorPullback_mem X := by
intro ⟨T, hT⟩
rw [mem_overGrothendieckTopology] at hT ⊢
obtain ⟨𝒰, h, hle⟩ := hT
use 𝒰, h
rintro - - ⟨i⟩
have p : Q (𝒰.X i ↘ S) := by
rw [← comp_over (𝒰.f i) S]
exact Q.comp_mem _ _ (hPQ _ <| 𝒰.map_prop i) X.prop
use (𝒰.X i).asOverProp S p, MorphismProperty.Over.homMk (𝒰.f i) (comp_over (𝒰.f i) S), 𝟙 _
exact ⟨hle _ ⟨i⟩, rfl⟩
instance : (MorphismProperty.Over.forget P ⊤ S).LocallyCoverDense (overGrothendieckTopology P S) :=
locallyCoverDense_of_le S le_rfl
variable (S) {P Q} in
/-- If `P` and `Q` are morphism properties with `P ≤ Q`, this is the Grothendieck topology
induced via the forgetful functor `Q.Over ⊤ S ⥤ Over S` by the topology defined by `P`. -/
abbrev smallGrothendieckTopologyOfLE (hPQ : P ≤ Q) : GrothendieckTopology (Q.Over ⊤ S) :=
letI : (MorphismProperty.Over.forget Q ⊤ S).LocallyCoverDense (overGrothendieckTopology P S) :=
locallyCoverDense_of_le S hPQ
(MorphismProperty.Over.forget Q ⊤ S).inducedTopology (S.overGrothendieckTopology P)
/-- The Grothendieck topology on the category of schemes over `S` with `P` induced by `P`, i.e.
coverings are simply surjective families. This is the induced topology by the topology on `S`
defined by `P` via the inclusion `P.Over ⊤ S ⥤ Over S`.
This is a special case of `smallGrothendieckTopologyOfLE` for the case `P = Q`. -/
abbrev smallGrothendieckTopology : GrothendieckTopology (P.Over ⊤ S) :=
(MorphismProperty.Over.forget P ⊤ S).inducedTopology (S.overGrothendieckTopology P)
variable [Q.IsStableUnderBaseChange] [Q.HasOfPostcompProperty Q]
/-- The pretopology defined on the subcategory of `S`-schemes satisfying `Q` where coverings
are given by `P`-coverings in `S`-schemes satisfying `Q`.
The most common case is `P = Q`. In this case, this is simply surjective families
in `S`-schemes with `P`. -/
def smallPretopology : Pretopology (Q.Over ⊤ S) where
coverings Y R :=
∃ (𝒰 : Cover.{u} (precoverage P) Y.left) (_ : 𝒰.Over S) (h : ∀ j : 𝒰.I₀, Q (𝒰.X j ↘ S)),
R = 𝒰.toPresieveOverProp h
has_isos {X Y} f := ⟨coverOfIsIso f.left, inferInstance, fun _ ↦ Y.prop,
(Presieve.ofArrows_pUnit _).symm⟩
pullbacks := by
rintro Y X f _ ⟨𝒰, h, p, rfl⟩
refine ⟨𝒰.pullbackCoverOverProp' S f.left (Q := Q) Y.prop X.prop p, inferInstance, ?_, ?_⟩
· intro j
apply MorphismProperty.Comma.prop
· exact (Presieve.ofArrows_pullback f (fun i ↦ ⟨(𝒰.X i).asOver S, p i⟩)
(fun i ↦ ⟨(𝒰.f i).asOver S, trivial, trivial⟩)).symm
transitive := by
rintro X _ T ⟨𝒰, h, p, rfl⟩ H
choose V h pV hV using H
let 𝒱j (j : 𝒰.I₀) : (Cover (precoverage P) ((𝒰.X j).asOverProp S (p j)).left) :=
V ((𝒰.f j).asOverProp S) ⟨j⟩
refine ⟨𝒰.bind (fun j ↦ 𝒱j j), inferInstance, fun j ↦ pV _ _ _, ?_⟩
convert Presieve.ofArrows_bind _ (fun j ↦ ((𝒰.f j).asOverProp S)) _
(fun Y f H j ↦ ((V f H).X j).asOverProp S (pV _ _ _))
(fun Y f H j ↦ ((V f H).f j).asOverProp S)
apply hV
variable (S) {P Q} in
lemma smallGrothendieckTopologyOfLE_eq_toGrothendieck_smallPretopology (hPQ : P ≤ Q) :
S.smallGrothendieckTopologyOfLE hPQ = (S.smallPretopology P Q).toGrothendieck := by
ext X R
simp only [Pretopology.mem_toGrothendieck, Functor.mem_inducedTopology_sieves_iff,
MorphismProperty.Comma.forget_obj, mem_overGrothendieckTopology]
constructor
· intro ⟨𝒰, h, le⟩
have hj (j : 𝒰.I₀) : Q (𝒰.X j ↘ S) := by
rw [← comp_over (𝒰.f j)]
exact Q.comp_mem _ _ (hPQ _ <| 𝒰.map_prop _) X.prop
refine ⟨𝒰.toPresieveOverProp hj, ?_, ?_⟩
· use 𝒰, h, hj
· rintro - - ⟨i⟩
let fi : (𝒰.X i).asOverProp S (hj i) ⟶ X := (𝒰.f i).asOverProp S
have : R.functorPushforward _ ((MorphismProperty.Over.forget Q ⊤ S).map fi) := le _ ⟨i⟩
rwa [Sieve.functorPushforward_apply,
Sieve.mem_functorPushforward_iff_of_full_of_faithful] at this
· rintro ⟨T, ⟨𝒰, h, p, rfl⟩, le⟩
use 𝒰, h
rintro - - ⟨i⟩
exact ⟨(𝒰.X i).asOverProp S (p i), (𝒰.f i).asOverProp S, 𝟙 _, le _ ⟨i⟩, rfl⟩
lemma smallGrothendieckTopology_eq_toGrothendieck_smallPretopology [P.HasOfPostcompProperty P] :
S.smallGrothendieckTopology P = (S.smallPretopology P P).toGrothendieck :=
S.smallGrothendieckTopologyOfLE_eq_toGrothendieck_smallPretopology le_rfl
variable {P Q}
lemma mem_toGrothendieck_smallPretopology (X : Q.Over ⊤ S) (R : Sieve X) :
R ∈ (S.smallPretopology P Q).toGrothendieck X ↔
∀ x : X.left, ∃ (Y : Q.Over ⊤ S) (f : Y ⟶ X) (y : Y.left),
R f ∧ P f.left ∧ f.left y = x := by
rw [Pretopology.mem_toGrothendieck]
refine ⟨?_, fun h ↦ ?_⟩
· rintro ⟨T, ⟨𝒰, h, p, rfl⟩, hle⟩
intro x
obtain ⟨y, hy⟩ := 𝒰.covers x
refine ⟨(𝒰.X (𝒰.idx x)).asOverProp S (p _), (𝒰.f (𝒰.idx x)).asOverProp S, y, hle _ ?_,
𝒰.map_prop _, hy⟩
use 𝒰.idx x
· choose Y f y hf hP hy using h
let 𝒰 : X.left.Cover (precoverage P) :=
{ I₀ := X.left,
X := fun i ↦ (Y i).left
f := fun i ↦ (f i).left
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun x ↦ ⟨x, y x, hy x⟩, hP⟩ }
letI : 𝒰.Over S :=
{ over := fun i ↦ inferInstance
isOver_map := fun i ↦ inferInstance }
refine ⟨𝒰.toPresieveOverProp fun i ↦ MorphismProperty.Comma.prop _, ?_, ?_⟩
· use 𝒰, inferInstance, fun i ↦ MorphismProperty.Comma.prop _
· rintro - - ⟨i⟩
exact hf i
lemma mem_smallGrothendieckTopology [P.HasOfPostcompProperty P] (X : P.Over ⊤ S) (R : Sieve X) :
R ∈ S.smallGrothendieckTopology P X ↔
∃ (𝒰 : Cover.{u} (precoverage P) X.left) (_ : 𝒰.Over S) (h : ∀ j, P (𝒰.X j ↘ S)),
𝒰.toPresieveOverProp h ≤ R.arrows := by
rw [smallGrothendieckTopology_eq_toGrothendieck_smallPretopology]
constructor
· rintro ⟨T, ⟨𝒰, h, p, rfl⟩, hle⟩
use 𝒰, h, p
· rintro ⟨𝒰, h𝒰, p, hle⟩
exact ⟨𝒰.toPresieveOverProp p, ⟨𝒰, h𝒰, p, rfl⟩, hle⟩
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/MorphismProperty.lean | import Mathlib.AlgebraicGeometry.OpenImmersion
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.CategoryTheory.Sites.JointlySurjective
import Mathlib.CategoryTheory.Sites.MorphismProperty
/-!
# Site defined by a morphism property
Given a multiplicative morphism property `P` that is stable under base change, we define the
associated precoverage on the category of schemes, where coverings are given
by jointly surjective families of morphisms satisfying `P`.
-/
universe v u
open CategoryTheory MorphismProperty Limits
namespace AlgebraicGeometry
namespace Scheme
/-- A morphism property of schemes is said to preserve joint surjectivity, if
for any pair of morphisms `f : X ⟶ S` and `g : Y ⟶ S` where `g` satisfies `P`,
any pair of points `x : X` and `y : Y` with `f x = g y` can be lifted to a point
of `X ×[S] Y`.
In later files, this will be automatic, since this holds for any morphism `g`
(see `AlgebraicGeometry.Scheme.isJointlySurjectivePreserving`). But at
this early stage in the import tree, we only know it for open immersions. -/
class IsJointlySurjectivePreserving (P : MorphismProperty Scheme.{u}) where
exists_preimage_fst_triplet_of_prop {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]
(hg : P g) (x : X) (y : Y) (h : f x = g y) :
∃ a : ↑(pullback f g), pullback.fst f g a = x
variable {P : MorphismProperty Scheme.{u}}
lemma IsJointlySurjectivePreserving.exists_preimage_snd_triplet_of_prop
[IsJointlySurjectivePreserving P] {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]
(hf : P f) (x : X) (y : Y) (h : f x = g y) :
∃ a : ↑(pullback f g), pullback.snd f g a = y := by
let iso := pullbackSymmetry f g
haveI : HasPullback g f := hasPullback_symmetry f g
obtain ⟨a, ha⟩ := exists_preimage_fst_triplet_of_prop hf y x h.symm
use (pullbackSymmetry f g).inv a
rwa [← Scheme.Hom.comp_apply, pullbackSymmetry_inv_comp_snd]
instance : IsJointlySurjectivePreserving @IsOpenImmersion where
exists_preimage_fst_triplet_of_prop {X Y S f g} _ hg x y h := by
rw [← show _ = (pullback.fst _ _ : pullback f g ⟶ _).base from
PreservesPullback.iso_hom_fst Scheme.forgetToTop f g]
have : x ∈ Set.range (pullback.fst f.base g.base) := by
rw [TopCat.pullback_fst_range f.base g.base]
use y
obtain ⟨a, ha⟩ := this
use (PreservesPullback.iso Scheme.forgetToTop f g).inv a
rwa [← TopCat.comp_app, Iso.inv_hom_id_assoc]
/-- The precoverage on `Scheme` of jointly surjective families. -/
abbrev jointlySurjectivePrecoverage : Precoverage Scheme.{u} :=
Types.jointlySurjectivePrecoverage.comap Scheme.forget
variable (P : MorphismProperty Scheme.{u})
/-- The precoverage on `Scheme` induced by `P` is given by jointly surjective families of
`P`-morphisms. -/
def precoverage : Precoverage Scheme.{u} :=
jointlySurjectivePrecoverage ⊓ P.precoverage
@[simp]
lemma ofArrows_mem_precoverage_iff {S : Scheme.{u}} {ι : Type*} {X : ι → Scheme.{u}}
{f : ∀ i, X i ⟶ S} :
.ofArrows X f ∈ precoverage P S ↔ (∀ x, ∃ i, x ∈ Set.range (f i)) ∧ ∀ i, P (f i) := by
simp_rw [← Scheme.forget_map, ← Scheme.forget_obj,
← Presieve.ofArrows_mem_comap_jointlySurjectivePrecoverage_iff]
exact ⟨fun hmem ↦ ⟨hmem.1, fun i ↦ hmem.2 ⟨i⟩⟩, fun h ↦ ⟨h.1, fun {Y} g ⟨i⟩ ↦ h.2 i⟩⟩
instance [P.IsStableUnderComposition] : (precoverage P).IsStableUnderComposition := by
dsimp only [precoverage]; infer_instance
instance [P.ContainsIdentities] [P.RespectsIso] : (precoverage P).HasIsos := by
dsimp only [precoverage]; infer_instance
instance [IsJointlySurjectivePreserving P] [P.IsStableUnderBaseChange] :
(precoverage P).IsStableUnderBaseChange where
mem_coverings_of_isPullback {ι} S X f hf Y g T p₁ p₂ H := by
rw [ofArrows_mem_precoverage_iff] at hf ⊢
refine ⟨fun x ↦ ?_, fun i ↦ P.of_isPullback (H i).flip (hf.2 i)⟩
obtain ⟨i, y, hy⟩ := hf.1 (g x)
have := (H i).hasPullback
obtain ⟨w, hw⟩ := IsJointlySurjectivePreserving.exists_preimage_fst_triplet_of_prop (hf.2 i)
(f := g) x y hy.symm
use i, (H i).isoPullback.inv w
simpa [← Scheme.Hom.comp_apply]
/-- The Zariski precoverage on the category of schemes is the precoverage defined by
jointly surjective families of open immersions. -/
abbrev zariskiPrecoverage : Precoverage Scheme.{u} := precoverage @IsOpenImmersion
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Sites/SmallAffineZariski.lean | import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.CategoryTheory.Sites.DenseSubsite.InducedTopology
/-!
# The small affine Zariski site
`X.AffineZariskiSite` is the small affine Zariski site of `X`, whose elements are affine open
sets of `X`, and whose arrows are basic open sets `D(f) ⟶ U` for any `f : Γ(X, U)`.
Every presieve on `U` is then given by a `Set Γ(X, U)` (`presieveOfSections_surjective`), and
we endow `X.AffineZariskiSite` with `grothendieckTopology X`, such that `s : Set Γ(X, U)` is
a cover if and only if `Ideal.span s = ⊤` (`generate_presieveOfSections_mem_grothendieckTopology`).
This is a dense subsite of `X.Opens` (with respect to `Opens.grothendieckTopology X`) via the
inclusion functor `toOpensFunctor X`,
which gives an equivalence of categories of sheaves (`sheafEquiv`).
Note that this differs from the definition on stacks project where the arrows in the small affine
Zariski site are arbitrary inclusions.
-/
universe u
open CategoryTheory
noncomputable section
namespace AlgebraicGeometry
variable {X : Scheme.{u}}
/--
`X.AffineZariskiSite` is the small affine Zariski site of `X`, whose elements are affine open
sets of `X`, and whose arrows are basic open sets `D(f) ⟶ U` for any `f : Γ(X, U)`.
Note that this differs from the definition on stacks project where the arrows in the small affine
Zariski site are arbitrary inclusions.
-/
def Scheme.AffineZariskiSite (X : Scheme.{u}) : Type u := { U : X.Opens // IsAffineOpen U }
namespace Scheme.AffineZariskiSite
/-- The inclusion from `X.AffineZariskiSite` to `X.Opens`. -/
abbrev toOpens (U : X.AffineZariskiSite) : X.Opens := U.1
instance : Preorder X.AffineZariskiSite where
le U V := ∃ f : Γ(X, V.toOpens), X.basicOpen f = U.toOpens
le_refl U := ⟨1, Scheme.basicOpen_of_isUnit _ isUnit_one⟩
le_trans := by
rintro ⟨U, hU⟩ ⟨V, hV⟩ ⟨W, hW⟩ ⟨f, rfl⟩ ⟨g, rfl⟩
exact hW.basicOpen_basicOpen_is_basicOpen g f
lemma toOpens_mono :
Monotone (toOpens (X := X)) := by
rintro ⟨U, hU⟩ ⟨V, hV⟩ ⟨f, rfl⟩
exact X.basicOpen_le _
lemma toOpens_injective : Function.Injective (toOpens (X := X)) := Subtype.val_injective
instance : PartialOrder X.AffineZariskiSite where
le_antisymm _ _ hUV hVU := Subtype.ext ((toOpens_mono hUV).antisymm (toOpens_mono hVU))
/-- The basic open set of a section, as an element of `AffineZariskiSite`. -/
def basicOpen (U : X.AffineZariskiSite) (f : Γ(X, U.toOpens)) : X.AffineZariskiSite :=
⟨X.basicOpen f, U.2.basicOpen f⟩
lemma basicOpen_le (U : X.AffineZariskiSite) (f : Γ(X, U.toOpens)) : U.basicOpen f ≤ U :=
⟨f, rfl⟩
variable (X) in
/-- The inclusion functor from `X.AffineZariskiSite` to `X.Opens`. -/
def toOpensFunctor : X.AffineZariskiSite ⥤ X.Opens := toOpens_mono.functor
instance : (toOpensFunctor X).Faithful where
instance : (toOpensFunctor X).IsLocallyFull (Opens.grothendieckTopology X) where
functorPushforward_imageSieve_mem := by
intro U V h x hx
obtain ⟨f, hfU, hxf⟩ := V.2.exists_basicOpen_le ⟨x, hx⟩ (h.le hx)
exact ⟨X.basicOpen f, homOfLE hfU, ⟨V.basicOpen f,
⟨_, (X.basicOpen_res f h.op).trans (inf_eq_right.mpr hfU)⟩, 𝟙 _,
⟨⟨f, rfl⟩, rfl⟩, rfl⟩, hxf⟩
instance : (toOpensFunctor X).IsCoverDense (Opens.grothendieckTopology X) where
is_cover := by
intro U x hx
obtain ⟨_, ⟨V, hV, rfl⟩, hxV, hVU⟩ := X.isBasis_affineOpens.exists_subset_of_mem_open hx U.2
exact ⟨V, homOfLE hVU, ⟨⟨V, hV⟩, 𝟙 _, homOfLE hVU, rfl⟩, hxV⟩
variable (X) in
/-- The Grothendieck topology on `X.AffineZariskiSite` induced from the topology on `X.Opens`.
Also see `mem_grothendieckTopology_iff_sectionsOfPresieve`. -/
def grothendieckTopology : GrothendieckTopology X.AffineZariskiSite :=
(toOpensFunctor X).inducedTopology (Opens.grothendieckTopology X)
lemma mem_grothendieckTopology {U : X.AffineZariskiSite} {S : Sieve U} :
S ∈ grothendieckTopology X U ↔
∀ x ∈ U.toOpens, ∃ (V : _) (f : V ⟶ U), S.arrows f ∧ x ∈ V.toOpens := by
apply forall₂_congr fun x hxU ↦ ⟨?_, ?_⟩
· rintro ⟨V, f, ⟨W, g, h, hg, rfl⟩, hxV⟩
exact ⟨W, g, hg, h.le hxV⟩
· rintro ⟨W, g, hg, hxW⟩
exact ⟨W.toOpens, homOfLE (toOpens_mono g.le), ⟨W, g, 𝟙 _, hg, rfl⟩, hxW⟩
instance : (toOpensFunctor X).IsDenseSubsite
(grothendieckTopology X) (Opens.grothendieckTopology X) where
functorPushforward_mem_iff := Iff.rfl
/-- The presieve associated to a set of sections.
This is a surjection, see `presieveOfSections_surjective`. -/
def presieveOfSections (U : X.AffineZariskiSite) (s : Set Γ(X, U.toOpens)) : Presieve U :=
fun V _ ↦ ∃ f ∈ s, X.basicOpen f = V.toOpens
/-- The set of sections associated to a presieve. -/
def sectionsOfPresieve {U : X.AffineZariskiSite} (P : Presieve U) : Set Γ(X, U.toOpens) :=
{ f | P (homOfLE (U.basicOpen_le f)) }
lemma presieveOfSections_sectionsOfPresieve {U : X.AffineZariskiSite} (P : Presieve U) :
presieveOfSections U (sectionsOfPresieve P) = P := by
refine funext₂ fun ⟨V, hV⟩ ⟨f, hf⟩ ↦ eq_iff_iff.mpr ⟨?_, ?_⟩
· rintro ⟨_, H, rfl⟩
exact H
· intro H
obtain rfl : _ = V := hf
exact ⟨_, H, rfl⟩
lemma presieveOfSections_surjective {U : X.AffineZariskiSite} :
Function.Surjective (presieveOfSections U) :=
fun _ ↦ ⟨_, presieveOfSections_sectionsOfPresieve _⟩
lemma presieveOfSections_eq_ofArrows (U : X.AffineZariskiSite) (s : Set Γ(X, U.toOpens)) :
presieveOfSections U s = .ofArrows _ (fun i : s ↦ homOfLE (U.basicOpen_le i.1)) := by
refine funext₂ fun ⟨V, hV⟩ ⟨f, hf⟩ ↦ eq_iff_iff.mpr ⟨?_, ?_⟩
· rintro ⟨f, hfs, rfl⟩
exact .mk (ι := s) ⟨f, hfs⟩
· rintro ⟨⟨f, hfs⟩⟩
exact ⟨f, hfs, rfl⟩
lemma generate_presieveOfSections
{U V : X.AffineZariskiSite} {s : Set Γ(X, U.toOpens)} {f : V ⟶ U} :
Sieve.generate (presieveOfSections U s) f ↔ ∃ f ∈ s, ∃ g, X.basicOpen (f * g) = V.toOpens := by
obtain ⟨V, hV⟩ := V
constructor
· rintro ⟨⟨W, hW⟩, ⟨f₁, hf₁⟩, -, ⟨f₂, hf₂s, rfl⟩, rfl⟩
subst hf₁
obtain ⟨f₃, hf₃⟩ := U.2.basicOpen_basicOpen_is_basicOpen f₂ f₁
refine ⟨f₂, hf₂s, f₃, ?_⟩
rw [X.basicOpen_mul, hf₃, inf_eq_right]
exact X.basicOpen_le _
· rintro ⟨f₁, hf₁s, f₂, rfl⟩
refine ⟨U.basicOpen f₁, ⟨f₂ |_ _, ?_⟩, ⟨f₁, rfl⟩, ⟨f₁, hf₁s, rfl⟩, rfl⟩
exact (X.basicOpen_res _ _).trans (X.basicOpen_mul _ _).symm
lemma generate_presieveOfSections_mem_grothendieckTopology
{U : X.AffineZariskiSite} {s : Set Γ(X, U.toOpens)} :
Sieve.generate (presieveOfSections U s) ∈ grothendieckTopology X U ↔ Ideal.span s = ⊤ := by
rw [← U.2.self_le_iSup_basicOpen_iff, mem_grothendieckTopology, SetLike.le_def]
refine forall₂_congr fun x hx ↦ ?_
simp only [exists_and_left, TopologicalSpace.Opens.iSup_mk,
TopologicalSpace.Opens.carrier_eq_coe, Set.iUnion_coe_set, TopologicalSpace.Opens.mem_mk,
Set.mem_iUnion, SetLike.mem_coe, exists_prop, generate_presieveOfSections]
constructor
· simp only [basicOpen_mul]
rintro ⟨⟨V, hV⟩, ⟨f, hfs, g, rfl⟩, -, hxV⟩
exact ⟨f, hfs, hxV.1⟩
· rintro ⟨f, hfs, hxf⟩
refine ⟨U.basicOpen _, ⟨f, hfs, 1, rfl⟩, ⟨_, rfl⟩, by simpa using hxf⟩
lemma mem_grothendieckTopology_iff_sectionsOfPresieve
{U : X.AffineZariskiSite} {S : Sieve U} :
S ∈ grothendieckTopology X U ↔ Ideal.span (sectionsOfPresieve S.1) = ⊤ := by
rw [← generate_presieveOfSections_mem_grothendieckTopology, presieveOfSections_sectionsOfPresieve,
Sieve.generate_sieve]
variable {A} [Category A]
variable [∀ (U : X.Opensᵒᵖ), Limits.HasLimitsOfShape (StructuredArrow U (toOpensFunctor X).op) A]
/-- The category of sheaves on `X.AffineZariskiSite` is equivalent to the categories of sheaves
over `X`. -/
abbrev sheafEquiv : Sheaf (grothendieckTopology X) A ≌ TopCat.Sheaf A X :=
(toOpensFunctor X).sheafInducedTopologyEquivOfIsCoverDense _ _
end Scheme.AffineZariskiSite
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean | import Mathlib.RingTheory.GradedAlgebra.Homogeneous.Ideal
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Sets.Opens
import Mathlib.Data.Set.Subsingleton
/-!
# Projective spectrum of a graded ring
The projective spectrum of a graded commutative ring is the subtype of all homogeneous ideals that
are prime and do not contain the irrelevant ideal.
It is naturally endowed with a topology: the Zariski topology.
## Notation
- `A` is a commutative ring
- `σ` is a class of additive submonoids of `A`
- `𝒜 : ℕ → σ` is the grading of `A`;
## Main definitions
* `ProjectiveSpectrum 𝒜`: The projective spectrum of a graded ring `A`, or equivalently, the set of
all homogeneous ideals of `A` that is both prime and relevant i.e. not containing irrelevant
ideal. Henceforth, we call elements of projective spectrum *relevant homogeneous prime ideals*.
* `ProjectiveSpectrum.zeroLocus 𝒜 s`: The zero locus of a subset `s` of `A`
is the subset of `ProjectiveSpectrum 𝒜` consisting of all relevant homogeneous prime ideals that
contain `s`.
* `ProjectiveSpectrum.vanishingIdeal t`: The vanishing ideal of a subset `t` of
`ProjectiveSpectrum 𝒜` is the intersection of points in `t` (viewed as relevant homogeneous prime
ideals).
* `ProjectiveSpectrum.Top`: the topological space of `ProjectiveSpectrum 𝒜` endowed with the
Zariski topology.
-/
noncomputable section
open DirectSum Pointwise SetLike TopCat TopologicalSpace CategoryTheory Opposite
variable {A σ : Type*}
variable [CommRing A] [SetLike σ A] [AddSubmonoidClass σ A]
variable (𝒜 : ℕ → σ) [GradedRing 𝒜]
/-- The projective spectrum of a graded commutative ring is the subtype of all homogeneous ideals
that are prime and do not contain the irrelevant ideal. -/
@[ext]
structure ProjectiveSpectrum where
asHomogeneousIdeal : HomogeneousIdeal 𝒜
isPrime : asHomogeneousIdeal.toIdeal.IsPrime
not_irrelevant_le : ¬HomogeneousIdeal.irrelevant 𝒜 ≤ asHomogeneousIdeal
attribute [instance] ProjectiveSpectrum.isPrime
namespace ProjectiveSpectrum
instance (x : ProjectiveSpectrum 𝒜) : Ideal.IsPrime x.asHomogeneousIdeal.toIdeal := x.isPrime
/-- The zero locus of a set `s` of elements of a commutative ring `A` is the set of all relevant
homogeneous prime ideals of the ring that contain the set `s`.
An element `f` of `A` can be thought of as a dependent function on the projective spectrum of `𝒜`.
At a point `x` (a homogeneous prime ideal) the function (i.e., element) `f` takes values in the
quotient ring `A` modulo the prime ideal `x`. In this manner, `zeroLocus s` is exactly the subset
of `ProjectiveSpectrum 𝒜` where all "functions" in `s` vanish simultaneously. -/
def zeroLocus (s : Set A) : Set (ProjectiveSpectrum 𝒜) :=
{ x | s ⊆ x.asHomogeneousIdeal }
@[simp]
theorem mem_zeroLocus (x : ProjectiveSpectrum 𝒜) (s : Set A) :
x ∈ zeroLocus 𝒜 s ↔ s ⊆ x.asHomogeneousIdeal :=
Iff.rfl
@[simp]
theorem zeroLocus_span (s : Set A) : zeroLocus 𝒜 (Ideal.span s) = zeroLocus 𝒜 s := by
ext x
exact (Submodule.gi _ _).gc s x.asHomogeneousIdeal.toIdeal
variable {𝒜}
/-- The vanishing ideal of a set `t` of points of the projective spectrum of a commutative ring `R`
is the intersection of all the relevant homogeneous prime ideals in the set `t`.
An element `f` of `A` can be thought of as a dependent function on the projective spectrum of `𝒜`.
At a point `x` (a homogeneous prime ideal) the function (i.e., element) `f` takes values in the
quotient ring `A` modulo the prime ideal `x`. In this manner, `vanishingIdeal t` is exactly the
ideal of `A` consisting of all "functions" that vanish on all of `t`. -/
def vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) : HomogeneousIdeal 𝒜 :=
⨅ (x : ProjectiveSpectrum 𝒜) (_ : x ∈ t), x.asHomogeneousIdeal
theorem coe_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) :
(vanishingIdeal t : Set A) =
{ f | ∀ x : ProjectiveSpectrum 𝒜, x ∈ t → f ∈ x.asHomogeneousIdeal } := by
ext f
rw [vanishingIdeal, SetLike.mem_coe, ← HomogeneousIdeal.mem_iff, HomogeneousIdeal.toIdeal_iInf,
Submodule.mem_iInf]
refine forall_congr' fun x => ?_
rw [HomogeneousIdeal.toIdeal_iInf, Submodule.mem_iInf, HomogeneousIdeal.mem_iff]
theorem mem_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (f : A) :
f ∈ vanishingIdeal t ↔ ∀ x : ProjectiveSpectrum 𝒜, x ∈ t → f ∈ x.asHomogeneousIdeal := by
rw [← SetLike.mem_coe, coe_vanishingIdeal, Set.mem_setOf_eq]
@[simp]
theorem vanishingIdeal_singleton (x : ProjectiveSpectrum 𝒜) :
vanishingIdeal ({x} : Set (ProjectiveSpectrum 𝒜)) = x.asHomogeneousIdeal := by
simp [vanishingIdeal]
theorem subset_zeroLocus_iff_le_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (I : Ideal A) :
t ⊆ zeroLocus 𝒜 I ↔ I ≤ (vanishingIdeal t).toIdeal :=
⟨fun h _ k => (mem_vanishingIdeal _ _).mpr fun _ j => (mem_zeroLocus _ _ _).mpr (h j) k, fun h =>
fun x j =>
(mem_zeroLocus _ _ _).mpr (le_trans h fun _ h => ((mem_vanishingIdeal _ _).mp h) x j)⟩
variable (𝒜)
/-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/
theorem gc_ideal :
@GaloisConnection (Ideal A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun I => zeroLocus 𝒜 I) fun t => (vanishingIdeal t).toIdeal :=
fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I
/-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/
theorem gc_set :
@GaloisConnection (Set A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun s => zeroLocus 𝒜 s) fun t => vanishingIdeal t := by
have ideal_gc : GaloisConnection Ideal.span _ := (Submodule.gi A _).gc
simpa [zeroLocus_span, Function.comp_def] using GaloisConnection.compose ideal_gc (gc_ideal 𝒜)
theorem gc_homogeneousIdeal :
@GaloisConnection (HomogeneousIdeal 𝒜) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun I => zeroLocus 𝒜 I) fun t => vanishingIdeal t :=
fun I t => by
simpa [show I.toIdeal ≤ (vanishingIdeal t).toIdeal ↔ I ≤ vanishingIdeal t from Iff.rfl] using
subset_zeroLocus_iff_le_vanishingIdeal t I.toIdeal
theorem subset_zeroLocus_iff_subset_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (s : Set A) :
t ⊆ zeroLocus 𝒜 s ↔ s ⊆ vanishingIdeal t :=
(gc_set _) s t
theorem subset_vanishingIdeal_zeroLocus (s : Set A) : s ⊆ vanishingIdeal (zeroLocus 𝒜 s) :=
(gc_set _).le_u_l s
theorem ideal_le_vanishingIdeal_zeroLocus (I : Ideal A) :
I ≤ (vanishingIdeal (zeroLocus 𝒜 I)).toIdeal :=
(gc_ideal _).le_u_l I
theorem homogeneousIdeal_le_vanishingIdeal_zeroLocus (I : HomogeneousIdeal 𝒜) :
I ≤ vanishingIdeal (zeroLocus 𝒜 I) :=
(gc_homogeneousIdeal _).le_u_l I
theorem subset_zeroLocus_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) :
t ⊆ zeroLocus 𝒜 (vanishingIdeal t) :=
(gc_ideal _).l_u_le t
theorem zeroLocus_anti_mono {s t : Set A} (h : s ⊆ t) : zeroLocus 𝒜 t ⊆ zeroLocus 𝒜 s :=
(gc_set _).monotone_l h
theorem zeroLocus_anti_mono_ideal {s t : Ideal A} (h : s ≤ t) :
zeroLocus 𝒜 (t : Set A) ⊆ zeroLocus 𝒜 (s : Set A) :=
(gc_ideal _).monotone_l h
theorem zeroLocus_anti_mono_homogeneousIdeal {s t : HomogeneousIdeal 𝒜} (h : s ≤ t) :
zeroLocus 𝒜 (t : Set A) ⊆ zeroLocus 𝒜 (s : Set A) :=
(gc_homogeneousIdeal _).monotone_l h
theorem vanishingIdeal_anti_mono {s t : Set (ProjectiveSpectrum 𝒜)} (h : s ⊆ t) :
vanishingIdeal t ≤ vanishingIdeal s :=
(gc_ideal _).monotone_u h
theorem zeroLocus_bot : zeroLocus 𝒜 ((⊥ : Ideal A) : Set A) = Set.univ :=
(gc_ideal 𝒜).l_bot
@[simp]
theorem zeroLocus_singleton_zero : zeroLocus 𝒜 ({0} : Set A) = Set.univ :=
zeroLocus_bot _
@[simp]
theorem zeroLocus_empty : zeroLocus 𝒜 (∅ : Set A) = Set.univ :=
(gc_set 𝒜).l_bot
@[simp]
theorem vanishingIdeal_univ : vanishingIdeal (∅ : Set (ProjectiveSpectrum 𝒜)) = ⊤ := by
simpa using (gc_ideal _).u_top
theorem zeroLocus_empty_of_one_mem {s : Set A} (h : (1 : A) ∈ s) : zeroLocus 𝒜 s = ∅ :=
Set.eq_empty_iff_forall_notMem.mpr fun x hx =>
(inferInstance : x.asHomogeneousIdeal.toIdeal.IsPrime).ne_top <|
x.asHomogeneousIdeal.toIdeal.eq_top_iff_one.mpr <| hx h
@[simp]
theorem zeroLocus_singleton_one : zeroLocus 𝒜 ({1} : Set A) = ∅ :=
zeroLocus_empty_of_one_mem 𝒜 (Set.mem_singleton (1 : A))
@[simp]
theorem zeroLocus_univ : zeroLocus 𝒜 (Set.univ : Set A) = ∅ :=
zeroLocus_empty_of_one_mem _ (Set.mem_univ 1)
theorem zeroLocus_sup_ideal (I J : Ideal A) :
zeroLocus 𝒜 ((I ⊔ J : Ideal A) : Set A) = zeroLocus _ I ∩ zeroLocus _ J :=
(gc_ideal 𝒜).l_sup
theorem zeroLocus_sup_homogeneousIdeal (I J : HomogeneousIdeal 𝒜) :
zeroLocus 𝒜 ((I ⊔ J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus _ I ∩ zeroLocus _ J :=
(gc_homogeneousIdeal 𝒜).l_sup
theorem zeroLocus_union (s s' : Set A) : zeroLocus 𝒜 (s ∪ s') = zeroLocus _ s ∩ zeroLocus _ s' :=
(gc_set 𝒜).l_sup
theorem vanishingIdeal_union (t t' : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (t ∪ t') = vanishingIdeal t ⊓ vanishingIdeal t' := by
ext1; exact (gc_ideal 𝒜).u_inf
theorem zeroLocus_iSup_ideal {γ : Sort*} (I : γ → Ideal A) :
zeroLocus _ ((⨆ i, I i : Ideal A) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) :=
(gc_ideal 𝒜).l_iSup
theorem zeroLocus_iSup_homogeneousIdeal {γ : Sort*} (I : γ → HomogeneousIdeal 𝒜) :
zeroLocus _ ((⨆ i, I i : HomogeneousIdeal 𝒜) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) :=
(gc_homogeneousIdeal 𝒜).l_iSup
theorem zeroLocus_iUnion {γ : Sort*} (s : γ → Set A) :
zeroLocus 𝒜 (⋃ i, s i) = ⋂ i, zeroLocus 𝒜 (s i) :=
(gc_set 𝒜).l_iSup
theorem zeroLocus_bUnion (s : Set (Set A)) :
zeroLocus 𝒜 (⋃ s' ∈ s, s' : Set A) = ⋂ s' ∈ s, zeroLocus 𝒜 s' := by
simp only [zeroLocus_iUnion]
theorem vanishingIdeal_iUnion {γ : Sort*} (t : γ → Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) :=
HomogeneousIdeal.toIdeal_injective <| by
convert (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _
theorem zeroLocus_inf (I J : Ideal A) :
zeroLocus 𝒜 ((I ⊓ J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.inf_le
theorem union_zeroLocus (s s' : Set A) :
zeroLocus 𝒜 s ∪ zeroLocus 𝒜 s' = zeroLocus 𝒜 (Ideal.span s ⊓ Ideal.span s' : Ideal A) := by
rw [zeroLocus_inf]
simp
theorem zeroLocus_mul_ideal (I J : Ideal A) :
zeroLocus 𝒜 ((I * J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.mul_le
theorem zeroLocus_mul_homogeneousIdeal (I J : HomogeneousIdeal 𝒜) :
zeroLocus 𝒜 ((I * J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.mul_le
theorem zeroLocus_singleton_mul (f g : A) :
zeroLocus 𝒜 ({f * g} : Set A) = zeroLocus 𝒜 {f} ∪ zeroLocus 𝒜 {g} :=
Set.ext fun x => by simpa using x.isPrime.mul_mem_iff_mem_or_mem
@[simp]
theorem zeroLocus_singleton_pow (f : A) (n : ℕ) (hn : 0 < n) :
zeroLocus 𝒜 ({f ^ n} : Set A) = zeroLocus 𝒜 {f} :=
Set.ext fun x => by simpa using x.isPrime.pow_mem_iff_mem n hn
theorem sup_vanishingIdeal_le (t t' : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal t ⊔ vanishingIdeal t' ≤ vanishingIdeal (t ∩ t') := by
intro r
rw [← HomogeneousIdeal.mem_iff, HomogeneousIdeal.toIdeal_sup, mem_vanishingIdeal,
Submodule.mem_sup]
rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩
rw [HomogeneousIdeal.mem_iff, mem_vanishingIdeal] at hf hg
apply Submodule.add_mem <;> solve_by_elim
theorem mem_compl_zeroLocus_iff_notMem {f : A} {I : ProjectiveSpectrum 𝒜} :
I ∈ (zeroLocus 𝒜 {f} : Set (ProjectiveSpectrum 𝒜))ᶜ ↔ f ∉ I.asHomogeneousIdeal := by
rw [Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]; rfl
@[deprecated (since := "2025-05-23")]
alias mem_compl_zeroLocus_iff_not_mem := mem_compl_zeroLocus_iff_notMem
/-- The Zariski topology on the prime spectrum of a commutative ring is defined via the closed sets
of the topology: they are exactly those sets that are the zero locus of a subset of the ring. -/
instance zariskiTopology : TopologicalSpace (ProjectiveSpectrum 𝒜) :=
TopologicalSpace.ofClosed (Set.range (ProjectiveSpectrum.zeroLocus 𝒜)) ⟨Set.univ, by simp⟩
(by
intro Zs h
rw [Set.sInter_eq_iInter]
let f : Zs → Set _ := fun i => Classical.choose (h i.2)
have H : (Set.iInter fun i ↦ zeroLocus 𝒜 (f i)) ∈ Set.range (zeroLocus 𝒜) :=
⟨_, zeroLocus_iUnion 𝒜 _⟩
convert H using 2
funext i
exact (Classical.choose_spec (h i.2)).symm)
(by
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩
exact ⟨_, (union_zeroLocus 𝒜 s t).symm⟩)
/-- The underlying topology of `Proj` is the projective spectrum of graded ring `A`. -/
def top : TopCat :=
TopCat.of (ProjectiveSpectrum 𝒜)
theorem isOpen_iff (U : Set (ProjectiveSpectrum 𝒜)) : IsOpen U ↔ ∃ s, Uᶜ = zeroLocus 𝒜 s := by
simp only [@eq_comm _ Uᶜ]; rfl
theorem isClosed_iff_zeroLocus (Z : Set (ProjectiveSpectrum 𝒜)) :
IsClosed Z ↔ ∃ s, Z = zeroLocus 𝒜 s := by rw [← isOpen_compl_iff, isOpen_iff, compl_compl]
theorem isClosed_zeroLocus (s : Set A) : IsClosed (zeroLocus 𝒜 s) := by
rw [isClosed_iff_zeroLocus]
exact ⟨s, rfl⟩
theorem zeroLocus_vanishingIdeal_eq_closure (t : Set (ProjectiveSpectrum 𝒜)) :
zeroLocus 𝒜 (vanishingIdeal t : Set A) = closure t := by
apply Set.Subset.antisymm
· rintro x hx t' ⟨ht', ht⟩
obtain ⟨fs, rfl⟩ : ∃ s, t' = zeroLocus 𝒜 s := by rwa [isClosed_iff_zeroLocus] at ht'
rw [subset_zeroLocus_iff_subset_vanishingIdeal] at ht
exact Set.Subset.trans ht hx
· rw [(isClosed_zeroLocus _ _).closure_subset_iff]
exact subset_zeroLocus_vanishingIdeal 𝒜 t
theorem vanishingIdeal_closure (t : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (closure t) = vanishingIdeal t := by
have : (vanishingIdeal (zeroLocus 𝒜 (vanishingIdeal t))).toIdeal = _ := (gc_ideal 𝒜).u_l_u_eq_u t
ext1
rw [zeroLocus_vanishingIdeal_eq_closure 𝒜 t] at this
exact this
section BasicOpen
/-- `basicOpen r` is the open subset containing all prime ideals not containing `r`. -/
def basicOpen (r : A) : TopologicalSpace.Opens (ProjectiveSpectrum 𝒜) where
carrier := { x | r ∉ x.asHomogeneousIdeal }
is_open' := ⟨{r}, Set.ext fun _ => Set.singleton_subset_iff.trans <| Classical.not_not.symm⟩
@[simp]
theorem mem_basicOpen (f : A) (x : ProjectiveSpectrum 𝒜) :
x ∈ basicOpen 𝒜 f ↔ f ∉ x.asHomogeneousIdeal :=
Iff.rfl
theorem mem_coe_basicOpen (f : A) (x : ProjectiveSpectrum 𝒜) :
x ∈ (↑(basicOpen 𝒜 f) : Set (ProjectiveSpectrum 𝒜)) ↔ f ∉ x.asHomogeneousIdeal :=
Iff.rfl
theorem isOpen_basicOpen {a : A} : IsOpen (basicOpen 𝒜 a : Set (ProjectiveSpectrum 𝒜)) :=
(basicOpen 𝒜 a).isOpen
@[simp]
theorem basicOpen_eq_zeroLocus_compl (r : A) :
(basicOpen 𝒜 r : Set (ProjectiveSpectrum 𝒜)) = (zeroLocus 𝒜 {r})ᶜ :=
Set.ext fun x => by simp only [Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]; rfl
@[simp]
theorem basicOpen_one : basicOpen 𝒜 (1 : A) = ⊤ :=
TopologicalSpace.Opens.ext <| by simp
@[simp]
theorem basicOpen_zero : basicOpen 𝒜 (0 : A) = ⊥ :=
TopologicalSpace.Opens.ext <| by simp
theorem basicOpen_mul (f g : A) : basicOpen 𝒜 (f * g) = basicOpen 𝒜 f ⊓ basicOpen 𝒜 g :=
TopologicalSpace.Opens.ext <| by simp [zeroLocus_singleton_mul]
theorem basicOpen_mul_le_left (f g : A) : basicOpen 𝒜 (f * g) ≤ basicOpen 𝒜 f := by
rw [basicOpen_mul 𝒜 f g]
exact inf_le_left
theorem basicOpen_mul_le_right (f g : A) : basicOpen 𝒜 (f * g) ≤ basicOpen 𝒜 g := by
rw [basicOpen_mul 𝒜 f g]
exact inf_le_right
@[simp]
theorem basicOpen_pow (f : A) (n : ℕ) (hn : 0 < n) : basicOpen 𝒜 (f ^ n) = basicOpen 𝒜 f :=
TopologicalSpace.Opens.ext <| by simpa using zeroLocus_singleton_pow 𝒜 f n hn
theorem basicOpen_eq_union_of_projection (f : A) :
basicOpen 𝒜 f = ⨆ i : ℕ, basicOpen 𝒜 (GradedRing.proj 𝒜 i f) :=
TopologicalSpace.Opens.ext <|
Set.ext fun z => by
rw [mem_coe_basicOpen, mem_coe, iSup, TopologicalSpace.Opens.mem_sSup]
constructor <;> intro hz
· rcases show ∃ i, GradedRing.proj 𝒜 i f ∉ z.asHomogeneousIdeal by
contrapose! hz with H
classical
rw [← DirectSum.sum_support_decompose 𝒜 f]
apply Ideal.sum_mem _ fun i _ => H i with ⟨i, hi⟩
exact ⟨basicOpen 𝒜 (GradedRing.proj 𝒜 i f), ⟨i, rfl⟩, by rwa [mem_basicOpen]⟩
· obtain ⟨_, ⟨i, rfl⟩, hz⟩ := hz
exact fun rid => hz (z.1.2 i rid)
theorem isTopologicalBasis_basic_opens :
TopologicalSpace.IsTopologicalBasis
(Set.range fun r : A => (basicOpen 𝒜 r : Set (ProjectiveSpectrum 𝒜))) := by
apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
· rintro _ ⟨r, rfl⟩
exact isOpen_basicOpen 𝒜
· rintro p U hp ⟨s, hs⟩
rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
obtain ⟨f, hfs, hfp⟩ := hp
refine ⟨basicOpen 𝒜 f, ⟨f, rfl⟩, hfp, ?_⟩
rw [← Set.compl_subset_compl, ← hs, basicOpen_eq_zeroLocus_compl, compl_compl]
exact zeroLocus_anti_mono 𝒜 (Set.singleton_subset_iff.mpr hfs)
end BasicOpen
section Order
/-!
## The specialization order
We endow `ProjectiveSpectrum 𝒜` with a partial order,
where `x ≤ y` if and only if `y ∈ closure {x}`.
-/
instance : PartialOrder (ProjectiveSpectrum 𝒜) :=
PartialOrder.lift asHomogeneousIdeal fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self]
@[simp]
theorem as_ideal_le_as_ideal (x y : ProjectiveSpectrum 𝒜) :
x.asHomogeneousIdeal ≤ y.asHomogeneousIdeal ↔ x ≤ y :=
Iff.rfl
@[simp]
theorem as_ideal_lt_as_ideal (x y : ProjectiveSpectrum 𝒜) :
x.asHomogeneousIdeal < y.asHomogeneousIdeal ↔ x < y :=
Iff.rfl
theorem le_iff_mem_closure (x y : ProjectiveSpectrum 𝒜) :
x ≤ y ↔ y ∈ closure ({x} : Set (ProjectiveSpectrum 𝒜)) := by
rw [← as_ideal_le_as_ideal, ← zeroLocus_vanishingIdeal_eq_closure, mem_zeroLocus,
vanishingIdeal_singleton]
simp only [as_ideal_le_as_ideal, coe_subset_coe]
end Order
end ProjectiveSpectrum |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Basic.lean | import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Scheme
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Gluing
/-!
# Basic properties of the scheme `Proj A`
The scheme `Proj 𝒜` for a graded ring `𝒜` is constructed in
`AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean`.
In this file we provide basic properties of the scheme.
## Main results
- `AlgebraicGeometry.Proj.toSpecZero`: The structure map `Proj A ⟶ Spec (A 0)`.
- `AlgebraicGeometry.Proj.basicOpenIsoSpec`:
The canonical isomorphism `Proj A |_ D₊(f) ≅ Spec (A_f)₀`
when `f` is homogeneous of positive degree.
- `AlgebraicGeometry.Proj.awayι`: The open immersion `Spec (A_f)₀ ⟶ Proj A`.
- `AlgebraicGeometry.Proj.affineOpenCover`: The open cover of `Proj A` by `Spec (A_f)₀` for all
homogeneous `f` of positive degree.
- `AlgebraicGeometry.Proj.stalkIso`:
The stalk of `Proj A` at `x` is the degree `0` part of the localization of `A` at `x`.
- `AlgebraicGeometry.Proj.fromOfGlobalSections`:
Given a map `f : A →+* Γ(X, ⊤)` such that the image of the irrelevant ideal under `f`
generates the whole ring, we can construct a map `X ⟶ Proj 𝒜`.
-/
namespace AlgebraicGeometry.Proj
open HomogeneousLocalization CategoryTheory
universe u
variable {σ : Type*} {A : Type u}
variable [CommRing A] [SetLike σ A] [AddSubgroupClass σ A]
variable (𝒜 : ℕ → σ)
variable [GradedRing 𝒜]
section basicOpen
variable (f g : A)
/-- The basic open set `D₊(f)` associated to `f : A`. -/
def basicOpen : (Proj 𝒜).Opens :=
ProjectiveSpectrum.basicOpen 𝒜 f
@[simp]
theorem mem_basicOpen (x : Proj 𝒜) :
x ∈ basicOpen 𝒜 f ↔ f ∉ x.asHomogeneousIdeal :=
Iff.rfl
@[simp] theorem basicOpen_one : basicOpen 𝒜 1 = ⊤ := ProjectiveSpectrum.basicOpen_one ..
@[simp] theorem basicOpen_zero : basicOpen 𝒜 0 = ⊥ := ProjectiveSpectrum.basicOpen_zero ..
@[simp] theorem basicOpen_pow (n) (hn : 0 < n) : basicOpen 𝒜 (f ^ n) = basicOpen 𝒜 f :=
ProjectiveSpectrum.basicOpen_pow 𝒜 f n hn
theorem basicOpen_mul : basicOpen 𝒜 (f * g) = basicOpen 𝒜 f ⊓ basicOpen 𝒜 g :=
ProjectiveSpectrum.basicOpen_mul ..
theorem basicOpen_mono (hfg : f ∣ g) : basicOpen 𝒜 g ≤ basicOpen 𝒜 f :=
(hfg.choose_spec ▸ basicOpen_mul 𝒜 f _).trans_le inf_le_left
theorem basicOpen_eq_iSup_proj (f : A) :
basicOpen 𝒜 f = ⨆ i : ℕ, basicOpen 𝒜 (GradedRing.proj 𝒜 i f) :=
ProjectiveSpectrum.basicOpen_eq_union_of_projection ..
theorem isBasis_basicOpen :
TopologicalSpace.Opens.IsBasis (Set.range (basicOpen 𝒜)) := by
delta TopologicalSpace.Opens.IsBasis
convert ProjectiveSpectrum.isTopologicalBasis_basic_opens 𝒜
exact (Set.range_comp _ _).symm
/-- If `{ xᵢ }` spans the irrelevant ideal of `A`, then `D₊(xᵢ)` covers `Proj A`. -/
lemma iSup_basicOpen_eq_top {ι : Type*} (f : ι → A)
(hf : (HomogeneousIdeal.irrelevant 𝒜).toIdeal ≤ Ideal.span (Set.range f)) :
⨆ i, Proj.basicOpen 𝒜 (f i) = ⊤ := by
classical
refine top_le_iff.mp fun x hx ↦ TopologicalSpace.Opens.mem_iSup.mpr ?_
by_contra! H
simp only [mem_basicOpen, Decidable.not_not] at H
refine x.not_irrelevant_le (hf.trans ?_)
rwa [Ideal.span_le, Set.range_subset_iff]
/-- If `{ xᵢ }` are homogeneous and span `A` as an `A₀` algebra, then `D₊(xᵢ)` covers `Proj A`. -/
lemma iSup_basicOpen_eq_top' {ι : Type*} (f : ι → A)
(hfn : ∀ i, ∃ n, f i ∈ 𝒜 n)
(hf : Algebra.adjoin (𝒜 0) (Set.range f) = ⊤) :
⨆ i, Proj.basicOpen 𝒜 (f i) = ⊤ := by
classical
apply Proj.iSup_basicOpen_eq_top
intro x hx
convert_to x - GradedRing.projZeroRingHom 𝒜 x ∈ _
· rw [GradedRing.projZeroRingHom_apply, ← GradedRing.proj_apply,
(HomogeneousIdeal.mem_irrelevant_iff _ _).mp hx, sub_zero]
clear hx
have := (eq_iff_iff.mp congr(x ∈ $hf)).mpr trivial
induction this using Algebra.adjoin_induction with
| mem x hx =>
obtain ⟨i, rfl⟩ := hx
obtain ⟨n, hn⟩ := hfn i
rw [GradedRing.projZeroRingHom_apply]
by_cases hn' : n = 0
· rw [DirectSum.decompose_of_mem_same 𝒜 (hn' ▸ hn), sub_self]
exact zero_mem _
· rw [DirectSum.decompose_of_mem_ne 𝒜 hn hn', sub_zero]
exact Ideal.subset_span ⟨_, rfl⟩
| algebraMap r =>
convert zero_mem (Ideal.span _)
rw [sub_eq_zero]
exact (DirectSum.decompose_of_mem_same 𝒜 r.2).symm
| add x y hx hy _ _ =>
rw [map_add, add_sub_add_comm]
exact add_mem ‹_› ‹_›
| mul x y hx hy hx' hy' =>
convert add_mem (Ideal.mul_mem_left _ x hy')
(Ideal.mul_mem_right (GradedRing.projZeroRingHom 𝒜 y) _ hx') using 1
rw [map_mul]
ring
/-- The canonical map `(A_f)₀ ⟶ Γ(Proj A, D₊(f))`.
This is an isomorphism when `f` is homogeneous of positive degree. See `basicOpenIsoAway` below. -/
def awayToSection : CommRingCat.of (Away 𝒜 f) ⟶ Γ(Proj 𝒜, basicOpen 𝒜 f) :=
ProjectiveSpectrum.Proj.awayToSection ..
/-- The canonical map `Proj A |_ D₊(f) ⟶ Spec (A_f)₀`.
This is an isomorphism when `f` is homogeneous of positive degree. See `basicOpenIsoSpec` below. -/
noncomputable
def basicOpenToSpec : (basicOpen 𝒜 f).toScheme ⟶ Spec (.of <| Away 𝒜 f) :=
(basicOpen 𝒜 f).toSpecΓ ≫ Spec.map (awayToSection 𝒜 f)
lemma basicOpenToSpec_app_top :
(basicOpenToSpec 𝒜 f).app ⊤ = (Scheme.ΓSpecIso _).hom ≫ awayToSection 𝒜 f ≫
(basicOpen 𝒜 f).topIso.inv := by
rw [basicOpenToSpec]
simp only [Scheme.Hom.comp_base, TopologicalSpace.Opens.map_comp_obj,
TopologicalSpace.Opens.map_top, Scheme.Hom.comp_app, Scheme.Opens.topIso_inv, eqToHom_op]
erw [Scheme.Hom.comp_app]
simp
/-- The structure map `Proj A ⟶ Spec A₀`. -/
noncomputable
def toSpecZero : Proj 𝒜 ⟶ Spec (.of <| 𝒜 0) :=
(Scheme.topIso _).inv ≫ (Scheme.isoOfEq _ (basicOpen_one _)).inv ≫
basicOpenToSpec 𝒜 1 ≫ Spec.map (CommRingCat.ofHom (fromZeroRingHom 𝒜 _))
variable {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m)
/-- The canonical isomorphism `Proj A |_ D₊(f) ≅ Spec (A_f)₀`
when `f` is homogeneous of positive degree. -/
@[simps! -isSimp hom]
noncomputable
def basicOpenIsoSpec : (basicOpen 𝒜 f).toScheme ≅ Spec (.of <| Away 𝒜 f) :=
have : IsIso (basicOpenToSpec 𝒜 f) := by
apply (isIso_iff_of_reflects_iso _ Scheme.forgetToLocallyRingedSpace).mp ?_
convert ProjectiveSpectrum.Proj.isIso_toSpec 𝒜 f f_deg hm using 1
refine Eq.trans ?_ (ΓSpec.locallyRingedSpaceAdjunction.homEquiv_apply _ _ _).symm
dsimp [basicOpenToSpec, Scheme.Opens.toSpecΓ]
simp only [eqToHom_op, Category.assoc, ← Spec.map_comp]
rfl
asIso (basicOpenToSpec 𝒜 f)
/-- The canonical isomorphism `(A_f)₀ ≅ Γ(Proj A, D₊(f))`
when `f` is homogeneous of positive degree. -/
@[simps! -isSimp hom]
noncomputable
def basicOpenIsoAway : CommRingCat.of (Away 𝒜 f) ≅ Γ(Proj 𝒜, basicOpen 𝒜 f) :=
have : IsIso (awayToSection 𝒜 f) := by
have := basicOpenToSpec_app_top 𝒜 f
rw [← Iso.inv_comp_eq, Iso.eq_comp_inv] at this
rw [← this, ← basicOpenIsoSpec_hom 𝒜 f f_deg hm]
infer_instance
asIso (awayToSection 𝒜 f)
/-- The open immersion `Spec (A_f)₀ ⟶ Proj A`. -/
noncomputable
def awayι : Spec (.of <| Away 𝒜 f) ⟶ Proj 𝒜 :=
(basicOpenIsoSpec 𝒜 f f_deg hm).inv ≫ (Proj.basicOpen 𝒜 f).ι
@[reassoc]
lemma basicOpenIsoSpec_inv_ι :
(basicOpenIsoSpec 𝒜 f f_deg hm).inv ≫ (Proj.basicOpen 𝒜 f).ι = awayι 𝒜 f f_deg hm := rfl
instance : IsOpenImmersion (Proj.awayι 𝒜 f f_deg hm) :=
IsOpenImmersion.comp _ _
lemma opensRange_awayι :
(Proj.awayι 𝒜 f f_deg hm).opensRange = Proj.basicOpen 𝒜 f :=
(Scheme.Hom.opensRange_comp_of_isIso _ _).trans (basicOpen 𝒜 f).opensRange_ι
include f_deg hm in
lemma isAffineOpen_basicOpen : IsAffineOpen (basicOpen 𝒜 f) := by
rw [← opensRange_awayι 𝒜 f f_deg hm]
exact isAffineOpen_opensRange (awayι _ _ _ _)
@[reassoc]
lemma awayι_toSpecZero : awayι 𝒜 f f_deg hm ≫ toSpecZero 𝒜 =
Spec.map (CommRingCat.ofHom (fromZeroRingHom 𝒜 _)) := by
rw [toSpecZero, basicOpenToSpec, awayι]
simp only [Category.assoc, Iso.inv_comp_eq, basicOpenIsoSpec_hom]
have (U) (e : U = ⊤) : (basicOpen 𝒜 f).ι ≫ (Scheme.topIso _).inv ≫ (Scheme.isoOfEq _ e).inv =
Scheme.homOfLE _ (le_top.trans_eq e.symm) := by
simp only [← Category.assoc, Iso.comp_inv_eq]
simp only [Scheme.topIso_hom, Category.assoc, Scheme.isoOfEq_hom_ι, Scheme.homOfLE_ι]
rw [reassoc_of% this, ← Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_assoc, basicOpenToSpec,
Category.assoc, ← Spec.map_comp, ← Spec.map_comp, ← Spec.map_comp]
rfl
variable {f}
variable {m' : ℕ} {g : A} (g_deg : g ∈ 𝒜 m') (hm' : 0 < m') {x : A} (hx : x = f * g)
@[reassoc]
lemma awayMap_awayToSection :
CommRingCat.ofHom (awayMap 𝒜 g_deg hx) ≫ awayToSection 𝒜 x =
awayToSection 𝒜 f ≫ (Proj 𝒜).presheaf.map (homOfLE (basicOpen_mono _ _ _ ⟨_, hx⟩)).op := by
ext a
apply Subtype.ext
ext ⟨i, hi⟩
obtain ⟨⟨n, a, ⟨b, hb'⟩, i, rfl : _ = b⟩, rfl⟩ := mk_surjective a
simp only [homOfLE_leOfHom, CommRingCat.hom_comp, RingHom.coe_comp, Function.comp_apply]
erw [ProjectiveSpectrum.Proj.awayToSection_apply]
rw [CommRingCat.hom_ofHom, val_awayMap_mk, Localization.mk_eq_mk', IsLocalization.map_mk',
← Localization.mk_eq_mk']
refine Localization.mk_eq_mk_iff.mpr ?_
rw [Localization.r_iff_exists]
use 1
simp only [OneMemClass.coe_one, RingHom.id_apply, one_mul, hx]
ring
@[reassoc]
lemma basicOpenToSpec_SpecMap_awayMap :
basicOpenToSpec 𝒜 x ≫ Spec.map (CommRingCat.ofHom (awayMap 𝒜 g_deg hx)) =
(Proj 𝒜).homOfLE (basicOpen_mono _ _ _ ⟨_, hx⟩) ≫ basicOpenToSpec 𝒜 f := by
rw [basicOpenToSpec, Category.assoc, ← Spec.map_comp, awayMap_awayToSection,
Spec.map_comp, Scheme.Opens.toSpecΓ_SpecMap_presheaf_map_assoc]
rfl
@[reassoc]
lemma SpecMap_awayMap_awayι :
Spec.map (CommRingCat.ofHom (awayMap 𝒜 g_deg hx)) ≫ awayι 𝒜 f f_deg hm =
awayι 𝒜 x (hx ▸ SetLike.mul_mem_graded f_deg g_deg) (hm.trans_le (m.le_add_right m')) := by
rw [awayι, awayι, Iso.eq_inv_comp, basicOpenIsoSpec_hom, basicOpenToSpec_SpecMap_awayMap_assoc,
← basicOpenIsoSpec_hom _ _ f_deg hm, Iso.hom_inv_id_assoc, Scheme.homOfLE_ι]
/-- The isomorphism `D₊(f) ×[Proj 𝒜] D₊(g) ≅ D₊(fg)`. -/
noncomputable
def pullbackAwayιIso :
Limits.pullback (awayι 𝒜 f f_deg hm) (awayι 𝒜 g g_deg hm') ≅ Spec (.of <| Away 𝒜 x) :=
IsOpenImmersion.isoOfRangeEq (Limits.pullback.fst _ _ ≫ awayι 𝒜 f f_deg hm)
(awayι 𝒜 x (hx ▸ SetLike.mul_mem_graded f_deg g_deg) (hm.trans_le (m.le_add_right m'))) <| by
rw [IsOpenImmersion.range_pullback_to_base_of_left]
change ((awayι 𝒜 f _ _).opensRange ⊓ (awayι 𝒜 g _ _).opensRange).1 = (awayι 𝒜 _ _ _).opensRange.1
rw [opensRange_awayι, opensRange_awayι, opensRange_awayι, ← basicOpen_mul, hx]
@[reassoc (attr := simp)]
lemma pullbackAwayιIso_hom_awayι :
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' hx).hom ≫
awayι 𝒜 x (hx ▸ SetLike.mul_mem_graded f_deg g_deg) (hm.trans_le (m.le_add_right m')) =
Limits.pullback.fst _ _ ≫ awayι 𝒜 f f_deg hm :=
IsOpenImmersion.isoOfRangeEq_hom_fac ..
@[reassoc (attr := simp)]
lemma pullbackAwayιIso_hom_SpecMap_awayMap_left :
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' hx).hom ≫
Spec.map (CommRingCat.ofHom (awayMap 𝒜 g_deg hx)) = Limits.pullback.fst _ _ := by
rw [← cancel_mono (awayι 𝒜 f f_deg hm), ← pullbackAwayιIso_hom_awayι,
Category.assoc, SpecMap_awayMap_awayι]
@[reassoc (attr := simp)]
lemma pullbackAwayιIso_hom_SpecMap_awayMap_right :
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' hx).hom ≫
Spec.map (CommRingCat.ofHom (awayMap 𝒜 f_deg (hx.trans (mul_comm _ _)))) =
Limits.pullback.snd _ _ := by
rw [← cancel_mono (awayι 𝒜 g g_deg hm'), ← Limits.pullback.condition,
← pullbackAwayιIso_hom_awayι 𝒜 f_deg hm g_deg hm' hx,
Category.assoc, SpecMap_awayMap_awayι]
rfl
@[reassoc (attr := simp)]
lemma pullbackAwayιIso_inv_fst :
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' hx).inv ≫ Limits.pullback.fst _ _ =
Spec.map (CommRingCat.ofHom (awayMap 𝒜 g_deg hx)) := by
rw [← pullbackAwayιIso_hom_SpecMap_awayMap_left, Iso.inv_hom_id_assoc]
@[reassoc (attr := simp)]
lemma pullbackAwayιIso_inv_snd :
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' hx).inv ≫ Limits.pullback.snd _ _ =
Spec.map (CommRingCat.ofHom (awayMap 𝒜 f_deg (hx.trans (mul_comm _ _)))) := by
rw [← pullbackAwayιIso_hom_SpecMap_awayMap_right (hx := hx) .., Iso.inv_hom_id_assoc]
include hm' in
lemma awayι_preimage_basicOpen :
awayι 𝒜 f f_deg hm ⁻¹ᵁ basicOpen 𝒜 g =
PrimeSpectrum.basicOpen (Away.isLocalizationElem f_deg g_deg) := by
ext1
trans Set.range (Spec.map (CommRingCat.ofHom (awayMap 𝒜 g_deg rfl)))
· rw [← pullbackAwayιIso_inv_fst 𝒜 f_deg hm g_deg hm' rfl]
simp only [TopologicalSpace.Opens.map_coe, Scheme.Hom.comp_base,
TopCat.hom_comp, ContinuousMap.coe_comp, Set.range_comp]
rw [Set.range_eq_univ.mpr (by exact
(pullbackAwayιIso 𝒜 f_deg hm g_deg hm' rfl).inv.homeomorph.surjective),
← opensRange_awayι _ _ g_deg hm']
simp [IsOpenImmersion.range_pullbackFst]
· letI := (awayMap (f := f) 𝒜 g_deg rfl).toAlgebra
letI := HomogeneousLocalization.Away.isLocalization_mul f_deg g_deg rfl hm.ne'
exact PrimeSpectrum.localization_away_comap_range _ _
open TopologicalSpace.Opens in
/-- Given a family of homogeneous elements `f` of positive degree that spans the irrelevant ideal,
`Spec (A_f)₀ ⟶ Proj A` forms an affine open cover of `Proj A`. -/
noncomputable
def affineOpenCoverOfIrrelevantLESpan {ι : Type*} (f : ι → A) {m : ι → ℕ}
(f_deg : ∀ i, f i ∈ 𝒜 (m i)) (hm : ∀ i, 0 < m i)
(hf : (HomogeneousIdeal.irrelevant 𝒜).toIdeal ≤ Ideal.span (Set.range f)) :
(Proj 𝒜).AffineOpenCover where
I₀ := ι
X i := .of (Away 𝒜 (f i))
f i := awayι 𝒜 (f i) (f_deg i) (hm i)
idx x := (mem_iSup.mp ((iSup_basicOpen_eq_top 𝒜 f hf).ge (Set.mem_univ x))).choose
covers x := by
change x ∈ (awayι 𝒜 _ _ _).opensRange
rw [opensRange_awayι]
exact (mem_iSup.mp ((iSup_basicOpen_eq_top 𝒜 f hf).ge (Set.mem_univ x))).choose_spec
@[deprecated (since := "2025-10-07")]
noncomputable alias openCoverOfISupEqTop := affineOpenCoverOfIrrelevantLESpan
/-- `Proj A` is covered by `Spec (A_f)₀` for all homogeneous elements of positive degree. -/
noncomputable
def affineOpenCover : (Proj 𝒜).AffineOpenCover :=
affineOpenCoverOfIrrelevantLESpan 𝒜
(ι := Σ i : PNat, 𝒜 i) (m := fun i ↦ i.1) (fun i ↦ i.2) (fun i ↦ i.2.2) (fun i ↦ i.1.2) <| by
classical
intro z hz
rw [← DirectSum.sum_support_decompose 𝒜 z]
refine Ideal.sum_mem _ fun c hc ↦ if hc0 : c = 0 then ?_ else
Ideal.subset_span ⟨⟨⟨c, Nat.pos_iff_ne_zero.mpr hc0⟩, _⟩, rfl⟩
convert Ideal.zero_mem _
subst hc0
exact hz
end basicOpen
section stalk
/-- The stalk of `Proj A` at `x` is the degree `0` part of the localization of `A` at `x`. -/
noncomputable
def stalkIso (x : Proj 𝒜) :
(Proj 𝒜).presheaf.stalk x ≅ .of (AtPrime 𝒜 x.asHomogeneousIdeal.toIdeal) :=
(stalkIso' 𝒜 x).toCommRingCatIso
end stalk
noncomputable section ofGlobalSection
open Limits
variable {X : Scheme.{u}} (f : A →+* Γ(X, ⊤)) {x x' : Γ(X, ⊤)} {t t' : A} {d d' : ℕ}
/-- Given a graded ring `A` and a map `f : A →+* Γ(X, ⊤)`,
for each homogeneous `t` of positive degree, it induces a map from `D(f(t)) ⟶ D₊(t)`. -/
def toBasicOpenOfGlobalSections (H : f t = x) (h0d : 0 < d) (hd : t ∈ 𝒜 d) :
(X.basicOpen x).toScheme ⟶ basicOpen 𝒜 t := by
refine ?_ ≫ (basicOpenIsoSpec _ _ hd h0d).inv
refine (X.isoOfEq (X.toSpecΓ_preimage_basicOpen x)).inv ≫ X.toSpecΓ ∣_ _ ≫ ?_
refine (basicOpenIsoSpecAway _).hom ≫
Spec.map (CommRingCat.ofHom (RingHom.comp ?_ (algebraMap _ (Localization.Away t))))
refine IsLocalization.map (M := .powers t) (T := .powers x) _ f ?_
· rw [← Submonoid.map_le_iff_le_comap, Submonoid.map_powers]
simp [H]
@[reassoc]
lemma homOfLE_toBasicOpenOfGlobalSections_ι
{H : f t = x} {h0d : 0 < d} {hd : t ∈ 𝒜 d} {H' : f t' = x'} {h0d' : 0 < d'} {hd' : t' ∈ 𝒜 d'}
{s : A} (hts : t * s = t') {n : ℕ} (hn : d + n = d') (hs : s ∈ 𝒜 n) :
X.homOfLE (by aesop) ≫ toBasicOpenOfGlobalSections 𝒜 f H h0d hd ≫ (basicOpen 𝒜 t).ι =
toBasicOpenOfGlobalSections 𝒜 f H' h0d' hd' ≫ (basicOpen 𝒜 t').ι := by
simp only [toBasicOpenOfGlobalSections, Scheme.isoOfEq_inv,
← Scheme.Hom.resLE_eq_morphismRestrict, CommRingCat.ofHom_comp, Spec.map_comp,
Scheme.Hom.map_resLE_assoc, Category.assoc, basicOpenIsoSpec_inv_ι]
have hx'x : PrimeSpectrum.basicOpen x' ≤ PrimeSpectrum.basicOpen x := by
aesop (add simp PrimeSpectrum.basicOpen_mul)
rw [← Scheme.Hom.resLE_map_assoc _ (by simp [X.toSpecΓ_preimage_basicOpen]) hx'x]
congr 1
simp only [← Iso.inv_comp_eq]
subst hts hn
rw [← SpecMap_awayMap_awayι (𝒜 := 𝒜) hd h0d
hs rfl, basicOpenIsoSpecAway_inv_homOfLE_assoc (R := Γ(X, ⊤)) x (f s) x' (by simp [← H', H]),
Iso.inv_hom_id_assoc]
simp only [← Category.assoc, ← Spec.map_comp, ← CommRingCat.ofHom_comp]
congr 3
ext
simp only [RingHom.coe_comp, Function.comp_apply,
HomogeneousLocalization.algebraMap_apply, HomogeneousLocalization.val_awayMap]
simp only [← RingHom.comp_apply]
congr 1
apply IsLocalization.ringHom_ext (M := .powers t)
ext i
simp [IsLocalization.Away.awayToAwayRight_eq]
variable (f : A →+* Γ(X, ⊤)) (hf : (HomogeneousIdeal.irrelevant 𝒜).toIdeal.map f = ⊤)
/-- Given a graded ring `A` and a map `f : A →+* Γ(X, ⊤)` such that the image of the
irrelevant ideal under `f` generates the whole ring, the set of `D(f(r))` for homogeneous `r`
of positive degree forms an open cover on `X`. -/
def openCoverOfMapIrrelevantEqTop : X.OpenCover :=
X.openCoverOfIsOpenCover (fun ir : Σ' i r, 0 < i ∧ r ∈ 𝒜 i ↦
X.basicOpen (f ir.2.1)) (by
classical
have H : Ideal.span (Set.range fun x : Σ' i r, 0 < i ∧ r ∈ 𝒜 i ↦ x.2.1) =
(HomogeneousIdeal.irrelevant 𝒜).toIdeal := by
apply le_antisymm
· rw [Ideal.span_le, Set.range_subset_iff]
rintro ⟨i, r, hi0, hri⟩
simp [-ZeroMemClass.coe_eq_zero,
DirectSum.decompose_of_mem_ne 𝒜 hri hi0.ne']
· intro x hx
rw [← DirectSum.sum_support_decompose 𝒜 x]
refine Ideal.sum_mem _ fun c hc ↦ ?_
have : c ≠ 0 := by contrapose! hc; simpa [hc] using hx
exact Ideal.subset_span ⟨⟨c, _, this.bot_lt, by simp⟩, rfl⟩
ext1
apply compl_injective
simp only [TopologicalSpace.Opens.coe_iSup, Set.compl_iUnion, ← Scheme.zeroLocus_singleton,
← Scheme.zeroLocus_iUnion, Set.iUnion_singleton_eq_range, TopologicalSpace.Opens.coe_top,
Set.compl_univ]
rw [← Scheme.zeroLocus_span, Set.range_comp', ← Ideal.map_span, H, hf]
simp)
@[deprecated (since := "2025-08-22")] noncomputable alias openCoverOfMapIrreleventEqTop :=
openCoverOfMapIrrelevantEqTop
/-- Given a graded ring `A` and a map `f : A →+* Γ(X, ⊤)` such that the image of the
irrelevant ideal under `f` generates the whole ring, we can construct a map `X ⟶ Proj 𝒜`. -/
def fromOfGlobalSections : X ⟶ Proj 𝒜 := by
refine (openCoverOfMapIrrelevantEqTop 𝒜 f hf).glueMorphisms
(fun ri ↦ toBasicOpenOfGlobalSections 𝒜 f rfl ri.2.2.1 ri.2.2.2 ≫ Scheme.Opens.ι _) ?_
rintro x y
let e : pullback ((openCoverOfMapIrrelevantEqTop 𝒜 f hf).f x)
((openCoverOfMapIrrelevantEqTop 𝒜 f hf).f y) ≅ (X.basicOpen (f (x.snd.fst * y.snd.fst))) :=
(isPullback_opens_inf _ _).isoPullback.symm ≪≫ X.isoOfEq (by simp)
rw [← cancel_epi e.inv]
trans toBasicOpenOfGlobalSections 𝒜 f rfl (Nat.add_pos_left x.2.2.1 y.1)
(SetLike.mul_mem_graded x.2.2.2 y.2.2.2) ≫ (Scheme.Opens.ι _)
· simpa [e, openCoverOfMapIrrelevantEqTop, Scheme.isoOfEq_inv] using
homOfLE_toBasicOpenOfGlobalSections_ι _ _ rfl rfl y.2.2.2
· simpa [e, openCoverOfMapIrrelevantEqTop, Scheme.isoOfEq_inv] using
(homOfLE_toBasicOpenOfGlobalSections_ι _ _ (mul_comm _ _) (add_comm _ _) x.2.2.2).symm
lemma fromOfGlobalSections_preimage_basicOpen {r : A} {n : ℕ} (hn : 0 < n) (hr : r ∈ 𝒜 n) :
fromOfGlobalSections 𝒜 f hf ⁻¹ᵁ basicOpen 𝒜 r = X.basicOpen (f r) := by
apply le_antisymm
· intro x hx
obtain ⟨i, x, rfl⟩ := (openCoverOfMapIrrelevantEqTop 𝒜 f hf).exists_eq x
simp only [TopologicalSpace.Opens.map_coe, Set.mem_preimage, SetLike.mem_coe,
← Scheme.Hom.comp_apply, fromOfGlobalSections, Scheme.Cover.ι_glueMorphisms] at hx
simp only [openCoverOfMapIrrelevantEqTop, Scheme.openCoverOfIsOpenCover_X,
toBasicOpenOfGlobalSections, Scheme.isoOfEq_inv, Category.assoc, basicOpenIsoSpec_inv_ι] at hx
simp only [Scheme.Hom.comp_base, Scheme.homOfLE_base, homOfLE_leOfHom, TopCat.hom_comp,
ContinuousMap.comp_assoc, ContinuousMap.comp_apply, morphismRestrict_base,
TopologicalSpace.Opens.carrier_eq_coe] at hx
rw [← SetLike.mem_coe, ← Set.mem_preimage, ← TopologicalSpace.Opens.map_coe,
Proj.awayι_preimage_basicOpen (𝒜 := 𝒜) i.2.2.2 i.2.2.1 hr hn,
← Set.mem_preimage, ← TopologicalSpace.Opens.map_coe, ← Function.Injective.mem_set_image
(Spec.map (CommRingCat.ofHom (algebraMap Γ(X, ⊤) _))).isOpenEmbedding.injective,
← Scheme.Hom.comp_apply, basicOpenIsoSpecAway, IsOpenImmersion.isoOfRangeEq_hom_fac] at hx
rw [← Scheme.toSpecΓ_preimage_basicOpen, TopologicalSpace.Opens.map_coe, Set.mem_preimage]
refine Set.mem_of_subset_of_mem (Set.image_subset_iff.mpr ?_) hx
change PrimeSpectrum.basicOpen _ ≤ PrimeSpectrum.basicOpen _
simp only [CommRingCat.ofHom_comp, CommRingCat.hom_comp, CommRingCat.hom_ofHom,
RingHom.coe_comp, Function.comp_apply, HomogeneousLocalization.algebraMap_apply,
HomogeneousLocalization.Away.val_mk, Localization.mk_eq_mk', IsLocalization.map_mk', map_pow,
PrimeSpectrum.basicOpen_le_basicOpen_iff, IsLocalization.mk'_mem_iff]
exact Ideal.pow_mem_of_mem _ (Ideal.le_radical (Ideal.mem_span_singleton_self _)) _ i.2.2.1
· intro x hx
let I : (openCoverOfMapIrrelevantEqTop 𝒜 f hf).I₀ := ⟨n, r, hn, hr⟩
obtain ⟨x, rfl⟩ : x ∈ ((openCoverOfMapIrrelevantEqTop 𝒜 f hf).f I).opensRange := by
simpa [openCoverOfMapIrrelevantEqTop] using hx
simp only [TopologicalSpace.Opens.map_coe, Set.mem_preimage, SetLike.mem_coe,
← Scheme.Hom.comp_apply, fromOfGlobalSections, Scheme.Cover.ι_glueMorphisms]
simp
lemma fromOfGlobalSections_morphismRestrict {r : A} {n : ℕ} (hn : 0 < n) (hr : r ∈ 𝒜 n) :
(fromOfGlobalSections 𝒜 f hf) ∣_ (basicOpen 𝒜 r) =
(Scheme.isoOfEq _ (fromOfGlobalSections_preimage_basicOpen _ _ _ hn hr)).hom ≫
toBasicOpenOfGlobalSections 𝒜 f rfl hn hr := by
rw [← Iso.inv_comp_eq, ← cancel_mono (basicOpen 𝒜 r).ι]
simp only [Scheme.isoOfEq_inv, Category.assoc, morphismRestrict_ι, Scheme.homOfLE_ι_assoc,
fromOfGlobalSections]
exact (openCoverOfMapIrrelevantEqTop 𝒜 f hf).ι_glueMorphisms _ _ ⟨_, _, hn, hr⟩
lemma fromOfGlobalSections_resLE {r : A} {n : ℕ} (hn : 0 < n) (hr : r ∈ 𝒜 n) :
(fromOfGlobalSections 𝒜 f hf).resLE _ _
(fromOfGlobalSections_preimage_basicOpen _ _ _ hn hr).ge =
toBasicOpenOfGlobalSections 𝒜 f rfl hn hr := by
rw [← (Iso.inv_comp_eq _).mpr (fromOfGlobalSections_morphismRestrict 𝒜 f hf hn hr),
← Scheme.Hom.resLE_eq_morphismRestrict]
simp [Scheme.isoOfEq_inv]
@[reassoc]
lemma fromOfGlobalSections_toSpecZero
(f : A →+* Γ(X, ⊤)) (hf : (HomogeneousIdeal.irrelevant 𝒜).toIdeal.map f = ⊤) :
fromOfGlobalSections 𝒜 f hf ≫ toSpecZero 𝒜 =
X.toSpecΓ ≫ Spec.map (CommRingCat.ofHom (f.comp (algebraMap _ _))) := by
refine (openCoverOfMapIrrelevantEqTop 𝒜 f hf).hom_ext _ _ fun x ↦ ?_
simp only [fromOfGlobalSections, toBasicOpenOfGlobalSections, CommRingCat.ofHom_comp,
Category.assoc, Scheme.Cover.ι_glueMorphisms_assoc, basicOpenIsoSpec_inv_ι_assoc,
awayι_toSpecZero, Iso.inv_comp_eq]
simp only [openCoverOfMapIrrelevantEqTop, Scheme.openCoverOfIsOpenCover_X,
Scheme.openCoverOfIsOpenCover_f, Scheme.isoOfEq_hom_ι_assoc, ← morphismRestrict_ι_assoc]
congr 1
simp only [basicOpenIsoSpecAway, ← CommRingCat.ofHom_comp, ← Spec.map_comp, ← Iso.eq_inv_comp,
IsOpenImmersion.isoOfRangeEq_inv_fac_assoc, ← HomogeneousLocalization.algebraMap_eq]
congr 2
rw [RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, IsScalarTower.algebraMap_eq _ A,
← RingHom.comp_assoc, IsLocalization.map_comp, RingHom.comp_assoc]
end ofGlobalSection
end AlgebraicGeometry.Proj |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/StructureSheaf.lean | import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Topology
import Mathlib.Topology.Sheaves.LocalPredicate
import Mathlib.RingTheory.GradedAlgebra.HomogeneousLocalization
import Mathlib.Geometry.RingedSpace.LocallyRingedSpace
/-!
# The structure sheaf on `ProjectiveSpectrum 𝒜`.
In `Mathlib/AlgebraicGeometry/Topology.lean`, we have given a topology on `ProjectiveSpectrum 𝒜`; in
this file we will construct a sheaf on `ProjectiveSpectrum 𝒜`.
## Notation
- `A` is a commutative ring;
- `σ` is a class of additive subgroups of `A`;
- `𝒜 : ℕ → σ` is the grading of `A`;
- `U` is opposite object of some open subset of `ProjectiveSpectrum.top`.
## Main definitions and results
We define the structure sheaf as the subsheaf of all dependent function
`f : Π x : U, HomogeneousLocalization 𝒜 x` such that `f` is locally expressible as ratio of two
elements of the *same grading*, i.e. `∀ y ∈ U, ∃ (V ⊆ U) (i : ℕ) (a b ∈ 𝒜 i), ∀ z ∈ V, f z = a / b`.
* `AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf.isLocallyFraction`: the predicate that
a dependent function is locally expressible as a ratio of two elements of the same grading.
* `AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf.sectionsSubring`: the dependent functions
satisfying the above local property forms a subring of all dependent functions
`Π x : U, HomogeneousLocalization 𝒜 x`.
* `AlgebraicGeometry.Proj.StructureSheaf`: the sheaf with `U ↦ sectionsSubring U` and natural
restriction map.
Then we establish that `Proj 𝒜` is a `LocallyRingedSpace`:
* `AlgebraicGeometry.Proj.stalkIso'`: for any `x : ProjectiveSpectrum 𝒜`, the stalk of
`Proj.StructureSheaf` at `x` is isomorphic to `HomogeneousLocalization 𝒜 x`.
* `AlgebraicGeometry.Proj.toLocallyRingedSpace`: `Proj` as a locally ringed space.
## References
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
noncomputable section
namespace AlgebraicGeometry
open scoped DirectSum Pointwise
open DirectSum SetLike Localization TopCat TopologicalSpace CategoryTheory Opposite
variable {A σ : Type*}
variable [CommRing A] [SetLike σ A] [AddSubgroupClass σ A]
variable (𝒜 : ℕ → σ) [GradedRing 𝒜]
local notation3 "at " x =>
HomogeneousLocalization.AtPrime 𝒜
(HomogeneousIdeal.toIdeal (ProjectiveSpectrum.asHomogeneousIdeal x))
namespace ProjectiveSpectrum.StructureSheaf
variable {𝒜} in
/-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
`r / s` of *same grading* in each of the stalks (which are localizations at various prime ideals).
-/
def IsFraction {U : Opens (ProjectiveSpectrum.top 𝒜)} (f : ∀ x : U, at x.1) : Prop :=
∃ (i : ℕ) (r s : 𝒜 i) (s_nin : ∀ x : U, s.1 ∉ x.1.asHomogeneousIdeal),
∀ x : U, f x = .mk ⟨i, r, s, s_nin x⟩
/--
The predicate `IsFraction` is "prelocal", in the sense that if it holds on `U` it holds on any open
subset `V` of `U`.
-/
def isFractionPrelocal : PrelocalPredicate fun x : ProjectiveSpectrum.top 𝒜 => at x where
pred f := IsFraction f
res := by rintro V U i f ⟨j, r, s, h, w⟩; exact ⟨j, r, s, (h <| i ·), (w <| i ·)⟩
/-- We will define the structure sheaf as the subsheaf of all dependent functions in
`Π x : U, HomogeneousLocalization 𝒜 x` consisting of those functions which can locally be expressed
as a ratio of `A` of same grading. -/
def isLocallyFraction : LocalPredicate fun x : ProjectiveSpectrum.top 𝒜 => at x :=
(isFractionPrelocal 𝒜).sheafify
namespace SectionSubring
variable {𝒜}
open Submodule SetLike.GradedMonoid HomogeneousLocalization
theorem zero_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
(isLocallyFraction 𝒜).pred (0 : ∀ x : U.unop, at x.1) := fun x =>
⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨0, zero_mem _⟩, ⟨1, one_mem_graded _⟩, _, fun _ => rfl⟩⟩
theorem one_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
(isLocallyFraction 𝒜).pred (1 : ∀ x : U.unop, at x.1) := fun x =>
⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨1, one_mem_graded _⟩, ⟨1, one_mem_graded _⟩, _, fun _ => rfl⟩⟩
theorem add_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a b : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) (hb : (isLocallyFraction 𝒜).pred b) :
(isLocallyFraction 𝒜).pred (a + b) := fun x => by
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, hwa, wa⟩
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, hwb, wb⟩
refine
⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ja + jb,
⟨sb * ra + sa * rb,
add_mem (add_comm jb ja ▸ mul_mem_graded sb_mem ra_mem : sb * ra ∈ 𝒜 (ja + jb))
(mul_mem_graded sa_mem rb_mem)⟩,
⟨sa * sb, mul_mem_graded sa_mem sb_mem⟩, fun y ↦
y.1.asHomogeneousIdeal.toIdeal.primeCompl.mul_mem (hwa ⟨y.1, y.2.1⟩) (hwb ⟨y.1, y.2.2⟩), ?_⟩
rintro ⟨y, hy⟩
simp only [Subtype.forall, Opens.apply_mk] at wa wb
simp [wa y hy.1, wb y hy.2, ext_iff_val, add_mk, add_comm (sa * rb)]
theorem neg_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) : (isLocallyFraction 𝒜).pred (-a) := fun x => by
rcases ha x with ⟨V, m, i, j, ⟨r, r_mem⟩, ⟨s, s_mem⟩, nin, hy⟩
refine ⟨V, m, i, j, ⟨-r, neg_mem r_mem⟩, ⟨s, s_mem⟩, nin, fun y => ?_⟩
simp only [ext_iff_val, val_mk] at hy
simp only [Pi.neg_apply, ext_iff_val, val_neg, hy, val_mk, neg_mk]
theorem mul_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a b : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) (hb : (isLocallyFraction 𝒜).pred b) :
(isLocallyFraction 𝒜).pred (a * b) := fun x => by
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, hwa, wa⟩
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, hwb, wb⟩
refine
⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ja + jb,
⟨ra * rb, SetLike.mul_mem_graded ra_mem rb_mem⟩,
⟨sa * sb, SetLike.mul_mem_graded sa_mem sb_mem⟩, fun y =>
y.1.asHomogeneousIdeal.toIdeal.primeCompl.mul_mem (hwa ⟨y.1, y.2.1⟩) (hwb ⟨y.1, y.2.2⟩), ?_⟩
rintro ⟨y, hy⟩
simp only [Subtype.forall, Opens.apply_mk] at wa wb
simp [wa y hy.1, wb y hy.2, ext_iff_val, Localization.mk_mul]
end SectionSubring
section
open SectionSubring
variable {𝒜}
/-- The functions satisfying `isLocallyFraction` form a subring of all dependent functions
`Π x : U, HomogeneousLocalization 𝒜 x`. -/
def sectionsSubring (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
Subring (∀ x : U.unop, at x.1) where
carrier := {f | (isLocallyFraction 𝒜).pred f}
zero_mem' := zero_mem' U
one_mem' := one_mem' U
add_mem' := add_mem' U _ _
neg_mem' := neg_mem' U _
mul_mem' := mul_mem' U _ _
end
/-- The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of
functions satisfying `isLocallyFraction`. -/
def structureSheafInType : Sheaf (Type _) (ProjectiveSpectrum.top 𝒜) :=
subsheafToTypes (isLocallyFraction 𝒜)
instance commRingStructureSheafInTypeObj (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
CommRing ((structureSheafInType 𝒜).1.obj U) :=
(sectionsSubring U).toCommRing
/-- The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type`-valued
structure presheaf. -/
@[simps obj_carrier]
def structurePresheafInCommRing : Presheaf CommRingCat (ProjectiveSpectrum.top 𝒜) where
obj U := CommRingCat.of ((structureSheafInType 𝒜).1.obj U)
map i := CommRingCat.ofHom
{ toFun := (structureSheafInType 𝒜).1.map i
map_zero' := rfl
map_add' := fun _ _ => rfl
map_one' := rfl
map_mul' := fun _ _ => rfl }
/-- Some glue, verifying that the structure presheaf valued in `CommRing` agrees with the
`Type`-valued structure presheaf. -/
def structurePresheafCompForget :
structurePresheafInCommRing 𝒜 ⋙ forget CommRingCat ≅ (structureSheafInType 𝒜).1 :=
NatIso.ofComponents (fun _ => Iso.refl _) (by cat_disch)
end ProjectiveSpectrum.StructureSheaf
namespace ProjectiveSpectrum
open TopCat.Presheaf ProjectiveSpectrum.StructureSheaf Opens
/-- The structure sheaf on `Proj` 𝒜, valued in `CommRing`. -/
def Proj.structureSheaf : Sheaf CommRingCat (ProjectiveSpectrum.top 𝒜) :=
⟨structurePresheafInCommRing 𝒜,
(-- We check the sheaf condition under `forget CommRing`.
isSheaf_iff_isSheaf_comp
_ _).mpr
(isSheaf_of_iso (structurePresheafCompForget 𝒜).symm (structureSheafInType 𝒜).cond)⟩
end ProjectiveSpectrum
section
open ProjectiveSpectrum ProjectiveSpectrum.StructureSheaf Opens
section
variable {U V : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ} (i : V ⟶ U)
(s t : (Proj.structureSheaf 𝒜).1.obj V) (x : V.unop)
@[simp]
theorem Proj.res_apply (x) : ((Proj.structureSheaf 𝒜).1.map i s).1 x = s.1 (i.unop x) := rfl
@[ext] theorem Proj.ext (h : s.1 = t.1) : s = t := Subtype.ext h
@[simp] theorem Proj.add_apply : (s + t).1 x = s.1 x + t.1 x := rfl
@[simp] theorem Proj.mul_apply : (s * t).1 x = s.1 x * t.1 x := rfl
@[simp] theorem Proj.sub_apply : (s - t).1 x = s.1 x - t.1 x := rfl
@[simp] theorem Proj.pow_apply (n : ℕ) : (s ^ n).1 x = s.1 x ^ n := rfl
@[simp] theorem Proj.zero_apply : (0 : (Proj.structureSheaf 𝒜).1.obj V).1 x = 0 := rfl
@[simp] theorem Proj.one_apply : (1 : (Proj.structureSheaf 𝒜).1.obj V).1 x = 1 := rfl
end
/-- `Proj` of a graded ring as a `SheafedSpace` -/
def Proj.toSheafedSpace : SheafedSpace CommRingCat where
carrier := TopCat.of (ProjectiveSpectrum 𝒜)
presheaf := (Proj.structureSheaf 𝒜).1
IsSheaf := (Proj.structureSheaf 𝒜).2
/-- The ring homomorphism that takes a section of the structure sheaf of `Proj` on the open set `U`,
implemented as a subtype of dependent functions to localizations at homogeneous prime ideals, and
evaluates the section on the point corresponding to a given homogeneous prime ideal. -/
def openToLocalization (U : Opens (ProjectiveSpectrum.top 𝒜)) (x : ProjectiveSpectrum.top 𝒜)
(hx : x ∈ U) : (Proj.structureSheaf 𝒜).1.obj (op U) ⟶ CommRingCat.of (at x) :=
CommRingCat.ofHom
{ toFun s := (s.1 ⟨x, hx⟩ :)
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl }
/-- The ring homomorphism from the stalk of the structure sheaf of `Proj` at a point corresponding
to a homogeneous prime ideal `x` to the *homogeneous localization* at `x`,
formed by gluing the `openToLocalization` maps. -/
def stalkToFiberRingHom (x : ProjectiveSpectrum.top 𝒜) :
(Proj.structureSheaf 𝒜).presheaf.stalk x ⟶ CommRingCat.of (at x) :=
Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (Proj.structureSheaf 𝒜).1)
{ pt := _
ι :=
{ app := fun U =>
openToLocalization 𝒜 ((OpenNhds.inclusion _).obj U.unop) x U.unop.2 } }
@[simp]
theorem germ_comp_stalkToFiberRingHom
(U : Opens (ProjectiveSpectrum.top 𝒜)) (x : ProjectiveSpectrum.top 𝒜) (hx : x ∈ U) :
(Proj.structureSheaf 𝒜).presheaf.germ U x hx ≫ stalkToFiberRingHom 𝒜 x =
openToLocalization 𝒜 U x hx :=
Limits.colimit.ι_desc _ _
@[simp]
theorem stalkToFiberRingHom_germ (U : Opens (ProjectiveSpectrum.top 𝒜))
(x : ProjectiveSpectrum.top 𝒜) (hx : x ∈ U) (s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
stalkToFiberRingHom 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ _ x hx s) = s.1 ⟨x, hx⟩ :=
RingHom.ext_iff.1 (CommRingCat.hom_ext_iff.mp (germ_comp_stalkToFiberRingHom 𝒜 U x hx)) s
theorem mem_basicOpen_den (x : ProjectiveSpectrum.top 𝒜)
(f : HomogeneousLocalization.NumDenSameDeg 𝒜 x.asHomogeneousIdeal.toIdeal.primeCompl) :
x ∈ ProjectiveSpectrum.basicOpen 𝒜 f.den := by
rw [ProjectiveSpectrum.mem_basicOpen]
exact f.den_mem
/-- Given a point `x` corresponding to a homogeneous prime ideal, there is a (dependent) function
such that, for any `f` in the homogeneous localization at `x`, it returns the obvious section in the
basic open set `D(f.den)`. -/
def sectionInBasicOpen (x : ProjectiveSpectrum.top 𝒜) :
∀ f : HomogeneousLocalization.NumDenSameDeg 𝒜 x.asHomogeneousIdeal.toIdeal.primeCompl,
(Proj.structureSheaf 𝒜).1.obj (op (ProjectiveSpectrum.basicOpen 𝒜 f.den)) :=
fun f =>
⟨fun y => HomogeneousLocalization.mk ⟨f.deg, f.num, f.den, y.2⟩, fun y =>
⟨ProjectiveSpectrum.basicOpen 𝒜 f.den, y.2,
⟨𝟙 _, ⟨f.deg, ⟨f.num, f.den, _, fun _ => rfl⟩⟩⟩⟩⟩
open HomogeneousLocalization in
/-- Given any point `x` and `f` in the homogeneous localization at `x`, there is an element in the
stalk at `x` obtained by `sectionInBasicOpen`. This is the inverse of `stalkToFiberRingHom`.
-/
def homogeneousLocalizationToStalk (x : ProjectiveSpectrum.top 𝒜) (y : at x) :
(Proj.structureSheaf 𝒜).presheaf.stalk x := Quotient.liftOn' y (fun f =>
(Proj.structureSheaf 𝒜).presheaf.germ _ x (mem_basicOpen_den _ x f) (sectionInBasicOpen _ x f))
fun f g (e : f.embedding = g.embedding) ↦ by
simp only [HomogeneousLocalization.NumDenSameDeg.embedding, Localization.mk_eq_mk',
IsLocalization.mk'_eq_iff_eq,
IsLocalization.eq_iff_exists x.asHomogeneousIdeal.toIdeal.primeCompl] at e
obtain ⟨⟨c, hc⟩, hc'⟩ := e
apply (Proj.structureSheaf 𝒜).presheaf.germ_ext
(ProjectiveSpectrum.basicOpen 𝒜 f.den.1 ⊓
ProjectiveSpectrum.basicOpen 𝒜 g.den.1 ⊓ ProjectiveSpectrum.basicOpen 𝒜 c)
⟨⟨mem_basicOpen_den _ x f, mem_basicOpen_den _ x g⟩, hc⟩
(homOfLE inf_le_left ≫ homOfLE inf_le_left) (homOfLE inf_le_left ≫ homOfLE inf_le_right)
apply Subtype.ext
ext ⟨t, ⟨htf, htg⟩, ht'⟩
rw [Proj.res_apply, Proj.res_apply]
simp only [sectionInBasicOpen, HomogeneousLocalization.val_mk, Localization.mk_eq_mk',
IsLocalization.mk'_eq_iff_eq]
apply (IsLocalization.map_units (M := t.asHomogeneousIdeal.toIdeal.primeCompl)
(Localization t.asHomogeneousIdeal.toIdeal.primeCompl) ⟨c, ht'⟩).mul_left_cancel
rw [← map_mul, ← map_mul, hc']
lemma homogeneousLocalizationToStalk_stalkToFiberRingHom (x z) :
homogeneousLocalizationToStalk 𝒜 x (stalkToFiberRingHom 𝒜 x z) = z := by
obtain ⟨U, hxU, s, rfl⟩ := (Proj.structureSheaf 𝒜).presheaf.germ_exist x z
change homogeneousLocalizationToStalk 𝒜 x ((stalkToFiberRingHom 𝒜 x).hom
(((Proj.structureSheaf 𝒜).presheaf.germ U x hxU) s)) =
((Proj.structureSheaf 𝒜).presheaf.germ U x hxU) s
obtain ⟨V, hxV, i, n, a, b, h, e⟩ := s.2 ⟨x, hxU⟩
simp only [Subtype.forall, apply_mk] at e
rw [stalkToFiberRingHom_germ, homogeneousLocalizationToStalk, e x hxV, Quotient.liftOn'_mk'']
refine Presheaf.germ_ext (C := CommRingCat) _ V hxV (homOfLE <| fun _ h' ↦ h ⟨_, h'⟩) i ?_
change ((Proj.structureSheaf 𝒜).presheaf.map (homOfLE <| fun _ h' ↦ h ⟨_, h'⟩).op) _ =
((Proj.structureSheaf 𝒜).presheaf.map i.op) s
apply Subtype.ext
ext ⟨t, ht⟩
rw [Proj.res_apply, Proj.res_apply]
simp [sectionInBasicOpen, HomogeneousLocalization.val_mk, Localization.mk_eq_mk', e t ht]
lemma stalkToFiberRingHom_homogeneousLocalizationToStalk (x z) :
stalkToFiberRingHom 𝒜 x (homogeneousLocalizationToStalk 𝒜 x z) = z := by
obtain ⟨z, rfl⟩ := Quotient.mk''_surjective z
rw [homogeneousLocalizationToStalk, Quotient.liftOn'_mk'',
stalkToFiberRingHom_germ, sectionInBasicOpen]
/-- Using `homogeneousLocalizationToStalk`, we construct a ring isomorphism between stalk at `x`
and homogeneous localization at `x` for any point `x` in `Proj`. -/
def Proj.stalkIso' (x : ProjectiveSpectrum.top 𝒜) :
(Proj.structureSheaf 𝒜).presheaf.stalk x ≃+* at x where
__ := (stalkToFiberRingHom _ x).hom
invFun := homogeneousLocalizationToStalk 𝒜 x
left_inv := homogeneousLocalizationToStalk_stalkToFiberRingHom 𝒜 x
right_inv := stalkToFiberRingHom_homogeneousLocalizationToStalk 𝒜 x
@[simp]
theorem Proj.stalkIso'_germ (U : Opens (ProjectiveSpectrum.top 𝒜))
(x : ProjectiveSpectrum.top 𝒜) (hx : x ∈ U) (s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
Proj.stalkIso' 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ _ x hx s) = s.1 ⟨x, hx⟩ :=
stalkToFiberRingHom_germ 𝒜 U x hx s
@[simp]
theorem Proj.stalkIso'_symm_mk (x) (f) :
(Proj.stalkIso' 𝒜 x).symm (.mk f) = (Proj.structureSheaf 𝒜).presheaf.germ _
x (mem_basicOpen_den _ x f) (sectionInBasicOpen _ x f) := rfl
/-- `Proj` of a graded ring as a `LocallyRingedSpace` -/
def Proj.toLocallyRingedSpace : LocallyRingedSpace :=
{ Proj.toSheafedSpace 𝒜 with
isLocalRing := fun x =>
@RingEquiv.isLocalRing _ _ _ (show IsLocalRing (at x) from inferInstance) _
(Proj.stalkIso' 𝒜 x).symm }
end
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Proper.lean | import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Basic
import Mathlib.AlgebraicGeometry.ValuativeCriterion
/-!
# Properness of `Proj A`
We show that `Proj 𝒜` is proper over `Spec 𝒜₀`.
## Notes
This contribution was created as part of the Durham Computational Algebraic Geometry Workshop
-/
namespace AlgebraicGeometry.Proj
variable {σ A : Type*}
variable [CommRing A] [SetLike σ A] [AddSubgroupClass σ A]
variable (𝒜 : ℕ → σ)
variable [GradedRing 𝒜]
open Scheme CategoryTheory Limits pullback HomogeneousLocalization
section IsSeparated
lemma lift_awayMapₐ_awayMapₐ_surjective {d e : ℕ} {f : A} (hf : f ∈ 𝒜 d)
{g : A} (hg : g ∈ 𝒜 e) {x : A} (hx : x = f * g) (hd : 0 < d) :
Function.Surjective
(Algebra.TensorProduct.lift (awayMapₐ 𝒜 hg hx) (awayMapₐ 𝒜 hf (hx.trans (mul_comm _ _)))
(fun _ _ ↦ .all _ _)) := by
intro z
obtain ⟨⟨n, ⟨a, ha⟩, ⟨b, hb'⟩, ⟨j, (rfl : _ = b)⟩⟩, rfl⟩ := mk_surjective z
by_cases hfg : (f * g) ^ j = 0
· use 0
have := HomogeneousLocalization.subsingleton 𝒜 (x := Submonoid.powers x) ⟨j, hx ▸ hfg⟩
exact this.elim _ _
have : n = j * (d + e) := by
apply DirectSum.degree_eq_of_mem_mem 𝒜 hb'
· convert SetLike.pow_mem_graded _ _ using 2
· infer_instance
· exact hx ▸ SetLike.mul_mem_graded hf hg
· exact hx ▸ hfg
let x0 : NumDenSameDeg 𝒜 (.powers f) :=
{ deg := j * (d * (e + 1))
num := ⟨a * g ^ (j * (d - 1)), by
convert SetLike.mul_mem_graded ha (SetLike.pow_mem_graded _ hg) using 2
rw [this]
cases d
· contradiction
· simp; ring⟩
den := ⟨f ^ (j * (e + 1)), by convert SetLike.pow_mem_graded _ hf using 2; ring⟩
den_mem := ⟨_,rfl⟩ }
let y0 : NumDenSameDeg 𝒜 (.powers g) :=
{ deg := j * (d * e)
num := ⟨f ^ (j * e), by convert SetLike.pow_mem_graded _ hf using 2; ring⟩
den := ⟨g ^ (j * d), by convert SetLike.pow_mem_graded _ hg using 2; ring⟩
den_mem := ⟨_,rfl⟩ }
use mk x0 ⊗ₜ mk y0
ext
simp only [Algebra.TensorProduct.lift_tmul, awayMapₐ_apply, val_mul,
val_awayMap_mk, Localization.mk_mul, val_mk, x0, y0]
rw [Localization.mk_eq_mk_iff, Localization.r_iff_exists]
use 1
simp only [OneMemClass.coe_one, one_mul, Submonoid.mk_mul_mk]
cases d
· contradiction
· simp only [hx, add_tsub_cancel_right]
ring
open TensorProduct in
instance isSeparated : IsSeparated (toSpecZero 𝒜) := by
refine ⟨IsZariskiLocalAtTarget.of_openCover (Pullback.openCoverOfLeftRight
(affineOpenCover 𝒜).openCover (affineOpenCover 𝒜).openCover _ _) ?_⟩
intro ⟨i, j⟩
dsimp [Scheme, Cover.pullbackHom]
refine (MorphismProperty.cancel_left_of_respectsIso (P := @IsClosedImmersion)
(f := (pullbackDiagonalMapIdIso ..).inv) _).mp ?_
let e₁ : pullback ((affineOpenCover 𝒜).f i ≫ toSpecZero 𝒜)
((affineOpenCover 𝒜).f j ≫ toSpecZero 𝒜) ≅
Spec (.of <| TensorProduct (𝒜 0) (Away 𝒜 (i.2 : A)) (Away 𝒜 (j.2 : A))) := by
refine pullback.congrHom ?_ ?_ ≪≫ pullbackSpecIso (𝒜 0) (Away 𝒜 (i.2 : A)) (Away 𝒜 (j.2 : A))
· simp [affineOpenCover, affineOpenCoverOfIrrelevantLESpan, awayι_toSpecZero]; rfl
· simp [affineOpenCover, affineOpenCoverOfIrrelevantLESpan, awayι_toSpecZero]; rfl
let e₂ : pullback ((affineOpenCover 𝒜).f i) ((affineOpenCover 𝒜).f j) ≅
Spec (.of <| Away 𝒜 (i.2 * j.2 : A)) :=
pullbackAwayιIso 𝒜 _ _ _ _ rfl
rw [← MorphismProperty.cancel_right_of_respectsIso (P := @IsClosedImmersion) _ e₁.hom,
← MorphismProperty.cancel_left_of_respectsIso (P := @IsClosedImmersion) e₂.inv]
let F : Away 𝒜 i.2.1 ⊗[𝒜 0] Away 𝒜 j.2.1 →+* Away 𝒜 (i.2.1 * j.2.1) :=
(Algebra.TensorProduct.lift (awayMapₐ 𝒜 j.2.2 rfl) (awayMapₐ 𝒜 i.2.2 (mul_comm _ _))
(fun _ _ ↦ .all _ _)).toRingHom
have : Function.Surjective F := lift_awayMapₐ_awayMapₐ_surjective 𝒜 i.2.2 j.2.2 rfl i.1.2
convert IsClosedImmersion.spec_of_surjective
(CommRingCat.ofHom (R := Away 𝒜 i.2.1 ⊗[𝒜 0] Away 𝒜 j.2.1) F) this using 1
rw [← cancel_mono (pullbackSpecIso ..).inv]
apply pullback.hom_ext
· simp only [Iso.trans_hom, congrHom_hom, Category.assoc, Iso.hom_inv_id, Category.comp_id,
limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, e₂, e₁,
pullbackDiagonalMapIdIso_inv_snd_fst, pullbackSpecIso_inv_fst,
← Spec.map_comp]
erw [pullbackAwayιIso_inv_fst]
congr 1
ext x : 2
exact DFunLike.congr_fun (Algebra.TensorProduct.lift_comp_includeLeft
(awayMapₐ 𝒜 j.2.2 rfl) (awayMapₐ 𝒜 i.2.2 (mul_comm _ _)) (fun _ _ ↦ .all _ _)).symm x
· simp only [Iso.trans_hom, congrHom_hom, Category.assoc, Iso.hom_inv_id, Category.comp_id,
limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
pullbackDiagonalMapIdIso_inv_snd_snd, pullbackSpecIso_inv_snd, ←
Spec.map_comp, e₂, e₁]
erw [pullbackAwayιIso_inv_snd]
congr 1
ext x : 2
exact DFunLike.congr_fun (Algebra.TensorProduct.lift_comp_includeRight
(awayMapₐ 𝒜 j.2.2 rfl) (awayMapₐ 𝒜 i.2.2 (mul_comm _ _)) (fun _ _ ↦ .all _ _)).symm x
@[stacks 01MC]
instance : Scheme.IsSeparated (Proj 𝒜) :=
(HasAffineProperty.iff_of_isAffine (P := @IsSeparated)).mp (isSeparated 𝒜)
end IsSeparated
section LocallyOfFiniteType
instance [Algebra.FiniteType (𝒜 0) A] : LocallyOfFiniteType (Proj.toSpecZero 𝒜) := by
obtain ⟨x, hx, hx'⟩ := GradedAlgebra.exists_finset_adjoin_eq_top_and_homogeneous_ne_zero 𝒜
choose d hd hxd using hx'
rw [IsZariskiLocalAtSource.iff_of_iSup_eq_top (P := @LocallyOfFiniteType) _
(Proj.iSup_basicOpen_eq_top' 𝒜 (ι := x) (↑) (fun i ↦ ⟨_, hxd _ i.2⟩) (by simpa using hx))]
intro i
rw [← MorphismProperty.cancel_left_of_respectsIso (P := @LocallyOfFiniteType)
(Proj.basicOpenIsoSpec 𝒜 (i : A) (hxd _ i.2) (hd _ i.2).bot_lt).inv, ← Category.assoc,
← Proj.awayι, Proj.awayι_toSpecZero, HasRingHomProperty.Spec_iff (P := @LocallyOfFiniteType)]
exact HomogeneousLocalization.Away.finiteType _ _ (hxd _ i.2)
end LocallyOfFiniteType
section QuasiCompact
instance [Algebra.FiniteType (𝒜 0) A] : QuasiCompact (Proj.toSpecZero 𝒜) := by
rw [HasAffineProperty.iff_of_isAffine (P := @QuasiCompact)]
obtain ⟨x, hx, hx'⟩ := GradedAlgebra.exists_finset_adjoin_eq_top_and_homogeneous_ne_zero 𝒜
choose d hd hxd using hx'
have H (i : x) : IsCompact (Proj.basicOpen 𝒜 (i : A)).1 := by
rw [← Proj.opensRange_awayι _ _ (hxd _ i.2) (hd _ i.2).bot_lt]
exact isCompact_range (Proj.awayι _ _ (hxd _ i.2) (hd _ i.2).bot_lt).continuous
have := congr($(Proj.iSup_basicOpen_eq_top' 𝒜
(ι := x) (↑) (fun i ↦ ⟨_, hxd _ i.2⟩) (by simpa using hx)).1)
simp only [TopologicalSpace.Opens.iSup_mk, TopologicalSpace.Opens.carrier_eq_coe,
TopologicalSpace.Opens.coe_mk, TopologicalSpace.Opens.coe_top] at this
rw [← isCompact_univ_iff, ← this]
exact isCompact_iUnion H
end QuasiCompact
section UniversallyClosed
open ValuationRing in
/--
Let `𝒜` be a graded ring generated over `𝒜₀` by finitely many homogeneous elements.
Suppose we have the following diagram for some homogeneous `x`
with `O` a valuation ring and `K = Frac(O)`.
```
φ
K ←--- 𝒜_{(x)}
↑ ↑
| |
| |
O ←---- 𝒜₀
φ₀
```
Then there exists a lift `φₗ : 𝒜_{(x₀)} →+* O` for some `x₀`
such that these two diagrams exist and commute.
```
φ' φ'
K ←--- 𝒜_{(x x₀)} K ←--- 𝒜_{(x x₀)}
↑ ↑ ↖ ↑
| | φ ⟍ |
| | ⟍ |
O ←---- 𝒜_{(x₀)} 𝒜_{(x)}
φₗ
```
This is the underlying algebraic statement of the valuative criterion for `Proj 𝒜`.
-/
@[stacks 01MF "algebraic part"]
theorem valuativeCriterion_existence_aux
{O : Type*} [CommRing O] [IsDomain O] [ValuationRing O]
{K : Type*} [Field K] [Algebra O K] [IsFractionRing O K]
(φ₀ : (𝒜 0) →+* O)
(ι : Type*) [Finite ι] (x : ι → A) (h2 : Algebra.adjoin (𝒜 0) (Set.range x) = ⊤)
(j : ι) (φ : Away 𝒜 (x j) →+* K)
(hcomm : (algebraMap O K).comp φ₀ = φ.comp (fromZeroRingHom 𝒜 _))
(d : ι → ℕ) (hdi : ∀ i, 0 < d i) (hxdi : ∀ i, x i ∈ 𝒜 (d i)) :
∃ (j₀ : ι) (φ' : Away 𝒜 (x j * x j₀) →+* K), φ'.comp (awayMap 𝒜 (hxdi j₀) rfl) = φ ∧
(φ'.comp (awayMap 𝒜 (hxdi j) (mul_comm (x j) (x j₀)))).range ≤ (algebraMap O K).range := by
classical
cases nonempty_fintype ι
let ψ (i : ι) : ValueGroup O K :=
valuation O K ((φ (Away.isLocalizationElem (hxdi j) (hxdi i))) ^ ∏ k ∈ Finset.univ.erase i, d k)
have : Nonempty ι := ⟨j⟩
let Kmax := (Finset.univ.image ψ).max' (by simp)
have ⟨i₀, hi1⟩ : ∃ a, ψ a = Kmax := by simpa using Finset.max'_mem (Finset.univ.image ψ)
have hi₀ (j) : ψ j ≤ ψ i₀ := hi1 ▸ (Finset.univ.image ψ).le_max' (ψ j) (by simp)
have hKmax : 0 < Kmax := by
refine zero_lt_iff.mpr fun hKmax ↦ ?_
have (i : _) : ψ i = 0 := le_zero_iff.mp (hKmax ▸ Finset.le_max' _ _ (by simp))
simp only [ψ, map_pow, pow_eq_zero_iff', map_eq_zero, ne_eq] at this
have : φ 1 = 0 := by convert (this j).1; ext; simp
simp only [map_one, one_ne_zero] at this
letI := (awayMap 𝒜 (f := x j) (hxdi i₀) rfl).toAlgebra
have := Away.isLocalization_mul (hxdi j) (hxdi i₀) rfl (hdi _).ne'
have hunit : IsUnit (φ (Away.isLocalizationElem (hxdi j) (hxdi i₀))) := isUnit_iff_ne_zero.mpr
fun rid ↦ hKmax.ne' (.symm (by simpa [ψ, rid, Finset.prod_eq_zero_iff, (hdi _).ne'] using hi1))
let φ' := IsLocalization.Away.lift (S := Away 𝒜 (x j * x i₀)) _ hunit
have hφ'1 (s) : φ' (awayMap 𝒜 (hxdi i₀) rfl s) = φ s := IsLocalization.Away.lift_eq _ hunit s
use i₀, φ', IsLocalization.Away.lift_comp ..
rintro _ ⟨sx, rfl⟩
rw [RingHom.mem_range, ← ValuationRing.mem_integer_iff, Valuation.mem_integer_iff]
have := (Away.span_mk_prod_pow_eq_top (hxdi i₀) x h2 d hxdi).ge (Submodule.mem_top (x := sx))
induction this using Submodule.span_induction with
| zero => simp
| add x y hx hy hhx hhy =>
simp only [RingHom.coe_comp, Function.comp_apply, map_add, ge_iff_le]
exact ((valuation O K).map_add _ _).trans <| sup_le_iff.mpr ⟨hhx, hhy⟩
| smul a x₀ hx hx1 =>
simp only [Algebra.smul_def, RingHom.coe_comp, Function.comp_apply, map_mul, ge_iff_le]
refine mul_le_one' ?_ hx1
rw [RingHom.algebraMap_toAlgebra, awayMap_fromZeroRingHom 𝒜 (hxdi j) (mul_comm (x j) (x i₀)),
← awayMap_fromZeroRingHom 𝒜 (hxdi i₀) rfl a, hφ'1]
change valuation O K (φ.comp (fromZeroRingHom 𝒜 (.powers (x j))) a) ≤ 1
simp only [← hcomm, RingHom.coe_comp, Function.comp_apply, ← Valuation.mem_integer_iff,
IsFractionRing.coe_inj, exists_eq, mem_integer_iff]
| mem x1 h =>
obtain ⟨a, ai, hai, rfl⟩ := h
simp only [smul_eq_mul] at hai
have H : (∏ i, x i ^ ai i) * x i₀ ^ (a * (d j - 1)) ∈ 𝒜 ((a * d i₀) • d j) := by
convert SetLike.mul_mem_graded (SetLike.prod_pow_mem_graded 𝒜 d x ai fun _ _ ↦ hxdi _)
(SetLike.pow_mem_graded (a * (d j - 1)) (hxdi i₀)) using 2
simp only [smul_eq_mul, hai]
cases h : d j
· cases (hdi j).ne' h
· simp only [add_tsub_cancel_right]; ring
suffices valuation O K (φ (Away.mk 𝒜 (hxdi j) _ _ H) /
φ (Away.isLocalizationElem (hxdi j) (hxdi i₀)) ^ a) ≤ 1 by
convert this
rw [eq_div_iff (pow_ne_zero _ hunit.ne_zero), ← hφ'1, ← hφ'1, RingHom.comp_apply,
← map_pow, ← map_mul]
congr
ext
simp only [awayMap_mk, Away.val_mk, val_pow, Localization.mk_pow, Localization.mk_mul,
Localization.mk_eq_mk_iff, Localization.r_iff_exists, val_mul]
use 1
simp only [OneMemClass.coe_one, one_mul, Submonoid.coe_mul, SubmonoidClass.coe_pow]
cases h : d j
· cases (hdi j).ne' h
· rw [Nat.add_sub_cancel]; ring
rw [map_div₀, div_le_iff₀ ((pow_pos ((Valuation.pos_iff _).mpr hunit.ne_zero) _).trans_eq
(Valuation.map_pow _ _ _).symm), one_mul, ← pow_le_pow_iff_left₀ zero_le' zero_le'
(mul_pos (hdi j) (Finset.prod_pos fun i _ => hdi i)).ne.symm]
calc
_ = (∏ i, ψ i ^ (d i * ai i)) * ψ i₀ ^ (d i₀ * a * (d j - 1)) := by
simp only [ψ, ← map_pow, ← map_prod, ← map_mul]
congr 2
apply (show Function.Injective (algebraMap (Away 𝒜 (x j)) (Localization.Away (x j)))
from val_injective _)
simp only [map_pow, map_prod, map_mul]
simp only [HomogeneousLocalization.algebraMap_apply, Away.val_mk, Localization.mk_pow,
Localization.mk_prod, Localization.mk_mul]
rw [Localization.mk_eq_mk_iff, Localization.r_iff_exists]
use 1
simp only [OneMemClass.coe_one, ← pow_mul, Submonoid.coe_mul,
SubmonoidClass.coe_finset_prod, one_mul]
simp_rw [← mul_assoc, Finset.prod_erase_mul _ d (h := Finset.mem_univ _), mul_assoc,
← mul_assoc (Finset.prod ..), Finset.prod_erase_mul _ d (h := Finset.mem_univ _),
SubmonoidClass.coe_pow, ← pow_mul, Finset.prod_pow_eq_pow_sum,
← pow_add, mul_pow, ← Finset.prod_pow, ← pow_mul]
congr 3
· simp only [mul_comm _ (∏ i, d i), mul_assoc, mul_left_comm _ (∏ i, d i),
mul_comm (d _) (ai _), ← Finset.mul_sum, hai]
cases h : d j
· cases (hdi j).ne' h
· simp; ring
· ext i; congr 1; ring
· ring
_ ≤ (∏ i : ι, ψ i₀ ^ (d i * ai i)) * ψ i₀ ^ (d i₀ * a * (d j - 1)) := by
gcongr with i; exacts [fun i _ ↦ zero_le', zero_le', hi₀ i]
_ = ψ i₀ ^ (d i₀ * a * d j) := by
rw [Finset.prod_pow_eq_pow_sum, ← pow_add]
simp_rw [mul_comm (d _) (ai _), hai]
cases h : d j
· cases (hdi j).ne' h
· simp; ring_nf
_ = valuation O K ((φ _) ^ a) ^ (d j * ∏ i, d i) := by
· simp only [ψ, ← map_pow]
congr 2
rw [← pow_mul, ← pow_mul, ← mul_assoc, ← mul_assoc, ← mul_assoc,
Finset.univ.prod_erase_mul d (h := Finset.mem_univ _),
mul_comm _ a, mul_right_comm]
@[stacks 01MF]
lemma valuativeCriterion_existence [Algebra.FiniteType (𝒜 0) A] :
ValuativeCriterion.Existence (Proj.toSpecZero 𝒜) := by
rintro ⟨O, K, i₁, i₂, w⟩
obtain ⟨x, hx, hx'⟩ := GradedAlgebra.exists_finset_adjoin_eq_top_and_homogeneous_ne_zero 𝒜
choose d hd hxd using hx'
have : i₁ (IsLocalRing.closedPoint K) ∈ (⊤ : (Proj 𝒜).Opens) := trivial
rw [← Proj.iSup_basicOpen_eq_top' 𝒜 (ι := x) (↑) (fun i ↦ ⟨_, hxd _ i.2⟩) (by simpa using hx),
TopologicalSpace.Opens.mem_iSup] at this
obtain ⟨i, hi⟩ := this
have : Set.range i₁ ⊆ (Proj.awayι 𝒜 _ (hxd i i.2) (hd i i.2).bot_lt).opensRange := by
rw [Proj.opensRange_awayι]
rintro _ ⟨x, rfl⟩
obtain rfl := Subsingleton.elim x (IsLocalRing.closedPoint K)
exact hi
let φ : Spec (.of <| K) ⟶ _ := IsOpenImmersion.lift _ _ this
have H : Spec.preimage i₂ ≫ CommRingCat.ofHom (algebraMap O K) =
CommRingCat.ofHom (fromZeroRingHom 𝒜 _) ≫ Spec.preimage φ := by
apply Spec.map_injective
simp only [Spec.map_comp, Spec.map_preimage, ← w.w]
rw [← Proj.awayι_toSpecZero _ _ (hxd i i.2), IsOpenImmersion.lift_fac_assoc]
exact Nat.zero_lt_of_ne_zero (hd i i.2)
obtain ⟨i₀, φ', hφ, hφ'⟩ :=
valuativeCriterion_existence_aux 𝒜 (Spec.preimage i₂).hom x (↑) (by simpa using hx) i
(O := O) (K := K) (Spec.preimage φ).hom congr(($H).hom)
(fun i ↦ d _ i.2) (fun i ↦ (hd _ i.2).bot_lt) (fun i ↦ hxd _ i.2)
let e : O ≃+* (algebraMap O K).range :=
(AlgEquiv.ofInjective (Algebra.ofId O K) (IsFractionRing.injective _ _)).toRingEquiv
let φ'' := e.symm.toRingHom.comp ((Subring.inclusion hφ').comp (RingHom.rangeRestrict _))
have hφ'' : (algebraMap O K).comp φ'' = φ'.comp (awayMap 𝒜 (hxd _ i.2) (mul_comm _ _)) := by
ext x
exact congr_arg Subtype.val (e.apply_symm_apply _)
refine ⟨⟨Spec.map (CommRingCat.ofHom φ'') ≫ Proj.awayι 𝒜 _ (hxd _ i₀.2) (hd _ _).bot_lt, ?_, ?_⟩⟩
· rw [← Spec.map_comp_assoc]
convert IsOpenImmersion.lift_fac _ _ this using 1
change _ = φ ≫ _
rw [← Spec.map_preimage φ, ← CommRingCat.ofHom_hom (Spec.preimage φ), ← hφ,
← CommRingCat.ofHom_comp]
simp [hφ'', SpecMap_awayMap_awayι, add_comm]
· simp only [Category.assoc, Proj.awayι_toSpecZero, ← Spec.map_comp]
conv_rhs => rw [← Spec.map_preimage i₂]
congr 1
ext x
apply IsFractionRing.injective O K
refine (DFunLike.congr_fun hφ'' (fromZeroRingHom 𝒜 _ _)).trans ?_
simp only [RingHom.coe_comp, Function.comp_apply]
rw [awayMap_fromZeroRingHom, ← awayMap_fromZeroRingHom 𝒜 (hxd i₀ i₀.2) rfl,
← RingHom.comp_apply, hφ]
exact congr($(H.symm) x)
instance [Algebra.FiniteType (𝒜 0) A] : UniversallyClosed (Proj.toSpecZero 𝒜) := by
rw [UniversallyClosed.eq_valuativeCriterion]
exact ⟨valuativeCriterion_existence 𝒜, inferInstance⟩
end UniversallyClosed
instance [Algebra.FiniteType (𝒜 0) A] : IsProper (Proj.toSpecZero 𝒜) where
end AlgebraicGeometry.Proj |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean | import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf
import Mathlib.AlgebraicGeometry.GammaSpecAdjunction
import Mathlib.RingTheory.GradedAlgebra.Radical
/-!
# Proj as a scheme
This file is to prove that `Proj` is a scheme.
## Notation
* `Proj` : `Proj` as a locally ringed space
* `Proj.T` : the underlying topological space of `Proj`
* `Proj| U` : `Proj` restricted to some open set `U`
* `Proj.T| U` : the underlying topological space of `Proj` restricted to open set `U`
* `pbo f` : basic open set at `f` in `Proj`
* `Spec` : `Spec` as a locally ringed space
* `Spec.T` : the underlying topological space of `Spec`
* `sbo g` : basic open set at `g` in `Spec`
* `A⁰_x` : the degree zero part of localized ring `Aₓ`
## Implementation
In `AlgebraicGeometry/ProjectiveSpectrum/StructureSheaf.lean`, we have given `Proj` a
structure sheaf so that `Proj` is a locally ringed space. In this file we will prove that `Proj`
equipped with this structure sheaf is a scheme. We achieve this by using an affine cover by basic
open sets in `Proj`, more specifically:
1. We prove that `Proj` can be covered by basic open sets at homogeneous elements of positive
degree.
2. We prove that for any homogeneous element `f : A` of positive degree `m`, `Proj.T | (pbo f)` is
homeomorphic to `Spec.T A⁰_f`:
- forward direction `toSpec`:
for any `x : pbo f`, i.e. a relevant homogeneous prime ideal `x`, send it to
`A⁰_f ∩ span {g / 1 | g ∈ x}` (see `ProjIsoSpecTopComponent.ToSpec.carrier`). This ideal is
prime, the proof is in `ProjIsoSpecTopComponent.ToSpec.toFun`. The fact that this function
is continuous is found in `ProjIsoSpecTopComponent.toSpec`
- backward direction `fromSpec`:
for any `q : Spec A⁰_f`, we send it to `{a | ∀ i, aᵢᵐ/fⁱ ∈ q}`; we need this to be a
homogeneous prime ideal that is relevant.
* This is in fact an ideal, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal`;
* This ideal is also homogeneous, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal.homogeneous`;
* This ideal is relevant, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.relevant`;
* This ideal is prime, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal.prime`.
Hence we have a well-defined function `Spec.T A⁰_f → Proj.T | (pbo f)`, this function is called
`ProjIsoSpecTopComponent.FromSpec.toFun`. But to prove the continuity of this function, we need
to prove `fromSpec ∘ toSpec` and `toSpec ∘ fromSpec` are both identities; these are achieved in
`ProjIsoSpecTopComponent.fromSpec_toSpec` and `ProjIsoSpecTopComponent.toSpec_fromSpec`.
3. Then we construct a morphism of locally ringed spaces `α : Proj| (pbo f) ⟶ Spec.T A⁰_f` as the
following: by the Gamma-Spec adjunction, it is sufficient to construct a ring map
`A⁰_f → Γ(Proj, pbo f)` from the ring of homogeneous localization of `A` away from `f` to the
local sections of structure sheaf of projective spectrum on the basic open set around `f`.
The map `A⁰_f → Γ(Proj, pbo f)` is constructed in `awayToΓ` and is defined by sending
`s ∈ A⁰_f` to the section `x ↦ s` on `pbo f`.
## Main Definitions and Statements
For a homogeneous element `f` of degree `m`
* `ProjIsoSpecTopComponent.toSpec`: the continuous map between `Proj.T| pbo f` and `Spec.T A⁰_f`
defined by sending `x : Proj| (pbo f)` to `A⁰_f ∩ span {g / 1 | g ∈ x}`. We also denote this map
as `ψ`.
* `ProjIsoSpecTopComponent.ToSpec.preimage_eq`: for any `a: A`, if `a/f^m` has degree zero,
then the preimage of `sbo a/f^m` under `toSpec f` is `pbo f ∩ pbo a`.
If we further assume `m` is positive
* `ProjIsoSpecTopComponent.fromSpec`: the continuous map between `Spec.T A⁰_f` and `Proj.T| pbo f`
defined by sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}` where `aᵢ` is the `i`-th coordinate of `a`.
We also denote this map as `φ`
* `projIsoSpecTopComponent`: the homeomorphism `Proj.T| pbo f ≅ Spec.T A⁰_f` obtained by `φ` and
`ψ`.
* `ProjectiveSpectrum.Proj.toSpec`: the morphism of locally ringed spaces between `Proj| pbo f`
and `Spec A⁰_f` corresponding to the ring map `A⁰_f → Γ(Proj, pbo f)` under the Gamma-Spec
adjunction defined by sending `s` to the section `x ↦ s` on `pbo f`.
Finally,
* `AlgebraicGeometry.Proj`: for any `ℕ`-graded ring `A`, `Proj A` is locally affine, hence is a
scheme.
## Reference
* [Robin Hartshorne, *Algebraic Geometry*][Har77]: Chapter II.2 Proposition 2.5
-/
noncomputable section
namespace AlgebraicGeometry
open scoped DirectSum Pointwise
open DirectSum SetLike.GradedMonoid Localization
open Finset hiding mk_zero
variable {A σ : Type*}
variable [CommRing A] [SetLike σ A] [AddSubgroupClass σ A]
variable (𝒜 : ℕ → σ)
variable [GradedRing 𝒜]
open TopCat TopologicalSpace
open CategoryTheory Opposite
open ProjectiveSpectrum.StructureSheaf
-- Porting note: currently require lack of hygiene to use in variable declarations
-- maybe all make into notation3?
set_option hygiene false
/-- `Proj` as a locally ringed space -/
local notation3 "Proj" => Proj.toLocallyRingedSpace 𝒜
/-- The underlying topological space of `Proj` -/
local notation3 "Proj.T" => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace
<| LocallyRingedSpace.toSheafedSpace <| Proj.toLocallyRingedSpace 𝒜
/-- `Proj` restrict to some open set -/
macro "Proj| " U:term : term =>
`((Proj.toLocallyRingedSpace 𝒜).restrict
(Opens.isOpenEmbedding (X := Proj.T) ($U : Opens Proj.T)))
/-- the underlying topological space of `Proj` restricted to some open set -/
local notation "Proj.T| " U => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace
<| LocallyRingedSpace.toSheafedSpace
<| (LocallyRingedSpace.restrict Proj (Opens.isOpenEmbedding (X := Proj.T) (U : Opens Proj.T)))
/-- basic open sets in `Proj` -/
local notation "pbo " x => ProjectiveSpectrum.basicOpen 𝒜 x
/-- basic open sets in `Spec` -/
local notation "sbo " f => PrimeSpectrum.basicOpen f
/-- `Spec` as a locally ringed space -/
local notation3 "Spec " ring => Spec.locallyRingedSpaceObj (CommRingCat.of ring)
/-- the underlying topological space of `Spec` -/
local notation "Spec.T " ring =>
(Spec.locallyRingedSpaceObj (CommRingCat.of ring)).toSheafedSpace.toPresheafedSpace.1
local notation3 "A⁰_ " f => HomogeneousLocalization.Away 𝒜 f
namespace ProjIsoSpecTopComponent
/-
This section is to construct the homeomorphism between `Proj` restricted at basic open set at
a homogeneous element `x` and `Spec A⁰ₓ` where `A⁰ₓ` is the degree zero part of the localized
ring `Aₓ`.
-/
namespace ToSpec
open Ideal
-- This section is to construct the forward direction :
-- So for any `x` in `Proj| (pbo f)`, we need some point in `Spec A⁰_f`, i.e. a prime ideal,
-- and we need this correspondence to be continuous in their Zariski topology.
variable {𝒜}
variable {f : A} {m : ℕ} (x : Proj| (pbo f))
/--
For any `x` in `Proj| (pbo f)`, the corresponding ideal in `Spec A⁰_f`. This fact that this ideal
is prime is proven in `TopComponent.Forward.toFun`. -/
def carrier : Ideal (A⁰_ f) :=
Ideal.comap (algebraMap (A⁰_ f) (Away f))
(x.val.asHomogeneousIdeal.toIdeal.map (algebraMap A (Away f)))
@[simp]
theorem mk_mem_carrier (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
HomogeneousLocalization.mk z ∈ carrier x ↔ z.num.1 ∈ x.1.asHomogeneousIdeal := by
rw [carrier, Ideal.mem_comap, HomogeneousLocalization.algebraMap_apply,
HomogeneousLocalization.val_mk, Localization.mk_eq_mk', IsLocalization.mk'_eq_mul_mk'_one,
mul_comm, Ideal.unit_mul_mem_iff_mem, ← Ideal.mem_comap,
IsLocalization.comap_map_of_isPrime_disjoint (.powers f)]
· rfl
· infer_instance
· exact (disjoint_powers_iff_notMem _ (Ideal.IsPrime.isRadical inferInstance)).mpr x.2
· exact isUnit_of_invertible _
theorem isPrime_carrier : Ideal.IsPrime (carrier x) := by
refine Ideal.IsPrime.comap _ (hK := ?_)
exact IsLocalization.isPrime_of_isPrime_disjoint
(Submonoid.powers f) _ _ inferInstance
((disjoint_powers_iff_notMem _ (Ideal.IsPrime.isRadical inferInstance)).mpr x.2)
variable (f)
/-- The function between the basic open set `D(f)` in `Proj` to the corresponding basic open set in
`Spec A⁰_f`. This is bundled into a continuous map in `TopComponent.forward`.
-/
@[simps -isSimp]
def toFun (x : Proj.T| pbo f) : Spec.T A⁰_ f :=
⟨carrier x, isPrime_carrier x⟩
/-
The preimage of basic open set `D(a/f^n)` in `Spec A⁰_f` under the forward map from `Proj A` to
`Spec A⁰_f` is the basic open set `D(a) ∩ D(f)` in `Proj A`. This lemma is used to prove that the
forward map is continuous.
-/
theorem preimage_basicOpen (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
toFun f ⁻¹' (sbo (HomogeneousLocalization.mk z) : Set (PrimeSpectrum (A⁰_ f))) =
Subtype.val ⁻¹' (pbo z.num.1 : Set (ProjectiveSpectrum 𝒜)) :=
Set.ext fun y ↦ (mk_mem_carrier y z).not
end ToSpec
section
/-- The continuous function from the basic open set `D(f)` in `Proj`
to the corresponding basic open set in `Spec A⁰_f`. -/
@[simps! -isSimp hom_apply_asIdeal]
def toSpec (f : A) : (Proj.T| pbo f) ⟶ Spec.T A⁰_ f :=
TopCat.ofHom
{ toFun := ToSpec.toFun f
continuous_toFun := by
rw [PrimeSpectrum.isTopologicalBasis_basic_opens.continuous_iff]
rintro _ ⟨x, rfl⟩
obtain ⟨x, rfl⟩ := Quotient.mk''_surjective x
rw [ToSpec.preimage_basicOpen]
exact (pbo (x.num : A)).2.preimage continuous_subtype_val }
variable {𝒜} in
lemma toSpec_preimage_basicOpen {f} (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
toSpec 𝒜 f ⁻¹' (sbo (HomogeneousLocalization.mk z) : Set (PrimeSpectrum (A⁰_ f))) =
Subtype.val ⁻¹' (pbo z.num.1 : Set (ProjectiveSpectrum 𝒜)) :=
ToSpec.preimage_basicOpen f z
end
namespace FromSpec
open GradedRing SetLike
open Finset hiding mk_zero
open HomogeneousLocalization
variable {𝒜}
variable {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m)
open Lean Meta Elab Tactic
macro "mem_tac_aux" : tactic =>
`(tactic| first | exact pow_mem_graded _ (SetLike.coe_mem _) | exact natCast_mem_graded _ _ |
exact pow_mem_graded _ f_deg)
macro "mem_tac" : tactic =>
`(tactic| first | mem_tac_aux |
repeat (all_goals (apply SetLike.GradedMonoid.toGradedMul.mul_mem)); mem_tac_aux)
/-- The function from `Spec A⁰_f` to `Proj|D(f)` is defined by `q ↦ {a | aᵢᵐ/fⁱ ∈ q}`, i.e. sending
`q` a prime ideal in `A⁰_f` to the homogeneous prime relevant ideal containing only and all the
elements `a : A` such that for every `i`, the degree 0 element formed by dividing the `m`-th power
of the `i`-th projection of `a` by the `i`-th power of the degree-`m` homogeneous element `f`,
lies in `q`.
The set `{a | aᵢᵐ/fⁱ ∈ q}`
* is an ideal, as proved in `carrier.asIdeal`;
* is homogeneous, as proved in `carrier.asHomogeneousIdeal`;
* is prime, as proved in `carrier.asIdeal.prime`;
* is relevant, as proved in `carrier.relevant`.
-/
def carrier (f_deg : f ∈ 𝒜 m) (q : Spec.T A⁰_ f) : Set A :=
{a | ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by rw [← smul_eq_mul]; mem_tac⟩,
⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1}
theorem mem_carrier_iff (q : Spec.T A⁰_ f) (a : A) :
a ∈ carrier f_deg q ↔ ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by
rw [← smul_eq_mul]; mem_tac⟩,
⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1 :=
Iff.rfl
theorem mem_carrier_iff' (q : Spec.T A⁰_ f) (a : A) :
a ∈ carrier f_deg q ↔
∀ i, (Localization.mk (proj 𝒜 i a ^ m) ⟨f ^ i, ⟨i, rfl⟩⟩ : Localization.Away f) ∈
algebraMap (HomogeneousLocalization.Away 𝒜 f) (Localization.Away f) '' { s | s ∈ q.1 } :=
(mem_carrier_iff f_deg q a).trans
(by
constructor <;> intro h i <;> specialize h i
· rw [Set.mem_image]; refine ⟨_, h, rfl⟩
· rw [Set.mem_image] at h; rcases h with ⟨x, h, hx⟩
change x ∈ q.asIdeal at h
convert h
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk]
dsimp only [Subtype.coe_mk]; rw [← hx]; rfl)
theorem mem_carrier_iff_of_mem (hm : 0 < m) (q : Spec.T A⁰_ f) (a : A) {n} (hn : a ∈ 𝒜 n) :
a ∈ carrier f_deg q ↔
(HomogeneousLocalization.mk ⟨m * n, ⟨a ^ m, pow_mem_graded m hn⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal := by
trans (HomogeneousLocalization.mk ⟨m * n, ⟨proj 𝒜 n a ^ m, by rw [← smul_eq_mul]; mem_tac⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal
· refine ⟨fun h ↦ h n, fun h i ↦ if hi : i = n then hi ▸ h else ?_⟩
convert zero_mem q.asIdeal
apply HomogeneousLocalization.val_injective
simp only [proj_apply, decompose_of_mem_ne _ hn (Ne.symm hi), zero_pow hm.ne',
HomogeneousLocalization.val_mk, Localization.mk_zero, HomogeneousLocalization.val_zero]
· simp only [proj_apply, decompose_of_mem_same _ hn]
theorem mem_carrier_iff_of_mem_mul (hm : 0 < m)
(q : Spec.T A⁰_ f) (a : A) {n} (hn : a ∈ 𝒜 (n * m)) :
a ∈ carrier f_deg q ↔ (HomogeneousLocalization.mk ⟨m * n, ⟨a, mul_comm n m ▸ hn⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal := by
rw [mem_carrier_iff_of_mem f_deg hm q a hn, iff_iff_eq, eq_comm,
← Ideal.IsPrime.pow_mem_iff_mem (α := A⁰_ f) inferInstance m hm]
congr 1
apply HomogeneousLocalization.val_injective
simp only [HomogeneousLocalization.val_mk, HomogeneousLocalization.val_pow,
Localization.mk_pow, pow_mul]
rfl
theorem num_mem_carrier_iff (hm : 0 < m) (q : Spec.T A⁰_ f)
(z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
z.num.1 ∈ carrier f_deg q ↔ HomogeneousLocalization.mk z ∈ q.asIdeal := by
obtain ⟨n, hn : f ^ n = _⟩ := z.den_mem
have : f ^ n ≠ 0 := fun e ↦ by
have := HomogeneousLocalization.subsingleton 𝒜 (x := .powers f) ⟨n, e⟩
exact IsEmpty.elim (inferInstanceAs (IsEmpty (PrimeSpectrum (A⁰_ f)))) q
convert mem_carrier_iff_of_mem_mul f_deg hm q z.num.1 (n := n) ?_ using 2
· apply HomogeneousLocalization.val_injective; simp only [hn, HomogeneousLocalization.val_mk]
· have := degree_eq_of_mem_mem 𝒜 (SetLike.pow_mem_graded n f_deg) (hn.symm ▸ z.den.2) this
rw [← smul_eq_mul, this]; exact z.num.2
theorem carrier.add_mem (q : Spec.T A⁰_ f) {a b : A} (ha : a ∈ carrier f_deg q)
(hb : b ∈ carrier f_deg q) : a + b ∈ carrier f_deg q := by
refine fun i => (q.2.mem_or_mem ?_).elim id id
change (HomogeneousLocalization.mk ⟨_, _, _, _⟩ : A⁰_ f) ∈ q.1; dsimp only [Subtype.coe_mk]
simp_rw [← pow_add, map_add, add_pow, mul_comm, ← nsmul_eq_mul]
let g : ℕ → A⁰_ f := fun j => (m + m).choose j •
if h2 : m + m < j then (0 : A⁰_ f)
else
if h1 : j ≤ m then
(HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ j * proj 𝒜 i b ^ (m - j), ?_⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩ : A⁰_ f) *
(HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i b ^ m, by rw [← smul_eq_mul]; mem_tac⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩ : A⁰_ f)
else
(HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ m, by rw [← smul_eq_mul]; mem_tac⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩ : A⁰_ f) *
(HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ (j - m) * proj 𝒜 i b ^ (m + m - j), ?_⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩ : A⁰_ f)
rotate_left
· rw [(_ : m * i = _)]
apply GradedMonoid.toGradedMul.mul_mem <;> mem_tac_aux
rw [← add_smul, Nat.add_sub_of_le h1]; rfl
· rw [(_ : m * i = _)]
apply GradedMonoid.toGradedMul.mul_mem (i := (j-m) • i) (j := (m + m - j) • i) <;> mem_tac_aux
rw [← add_smul]; congr; cutsat
convert_to ∑ i ∈ range (m + m + 1), g i ∈ q.1; swap
· refine q.1.sum_mem fun j _ => nsmul_mem ?_ _; split_ifs
exacts [q.1.zero_mem, q.1.mul_mem_left _ (hb i), q.1.mul_mem_right _ (ha i)]
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk]
change _ = (algebraMap (HomogeneousLocalization.Away 𝒜 f) (Localization.Away f)) _
dsimp only [Subtype.coe_mk]; rw [map_sum, mk_sum]
apply Finset.sum_congr rfl fun j hj => _
intro j hj
change _ = HomogeneousLocalization.val _
rw [HomogeneousLocalization.val_smul]
split_ifs with h2 h1
· exact ((Finset.mem_range.1 hj).not_ge h2).elim
all_goals simp only [HomogeneousLocalization.val_mul,
HomogeneousLocalization.val_mk, Localization.mk_mul, ← smul_mk]; congr 2
· dsimp; rw [mul_assoc, ← pow_add, add_comm (m - j), Nat.add_sub_assoc h1]
· simp_rw [pow_add]; rfl
· dsimp; rw [← mul_assoc, ← pow_add, Nat.add_sub_of_le (le_of_not_ge h1)]
· simp_rw [pow_add]; rfl
variable (hm : 0 < m) (q : Spec.T A⁰_ f)
include hm
theorem carrier.zero_mem : (0 : A) ∈ carrier f_deg q := fun i => by
convert Submodule.zero_mem q.1 using 1
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_zero]; simp_rw [map_zero, zero_pow hm.ne']
convert Localization.mk_zero (S := Submonoid.powers f) _ using 1
theorem carrier.smul_mem (c x : A) (hx : x ∈ carrier f_deg q) : c • x ∈ carrier f_deg q := by
revert c
refine DirectSum.Decomposition.inductionOn 𝒜 ?_ ?_ ?_
· rw [zero_smul]; exact carrier.zero_mem f_deg hm _
· rintro n ⟨a, ha⟩ i
simp_rw [proj_apply, smul_eq_mul, coe_decompose_mul_of_left_mem 𝒜 i ha]
let product : A⁰_ f :=
(HomogeneousLocalization.mk
⟨_, ⟨a ^ m, pow_mem_graded m ha⟩, ⟨_, ?_⟩, ⟨n, rfl⟩⟩ : A⁰_ f) *
(HomogeneousLocalization.mk
⟨_, ⟨proj 𝒜 (i - n) x ^ m, by mem_tac⟩, ⟨_, ?_⟩, ⟨i - n, rfl⟩⟩ : A⁰_ f)
· split_ifs with h
· convert_to product ∈ q.1
· dsimp [product]
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mul, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mk]
· simp_rw [mul_pow]; rw [Localization.mk_mul]
· congr; rw [← pow_add, Nat.add_sub_of_le h]
· apply Ideal.mul_mem_left (α := A⁰_ f) _ _ (hx _)
rw [(_ : m • n = _)]
· mem_tac
· simp only [smul_eq_mul, mul_comm]
· simpa only [map_zero, zero_pow hm.ne'] using zero_mem f_deg hm q i
rw [(_ : m • (i - n) = _)]
· mem_tac
· simp only [smul_eq_mul, mul_comm]
· simp_rw [add_smul]; exact fun _ _ => carrier.add_mem f_deg q
/-- For a prime ideal `q` in `A⁰_f`, the set `{a | aᵢᵐ/fⁱ ∈ q}` as an ideal.
-/
def carrier.asIdeal : Ideal A where
carrier := carrier f_deg q
zero_mem' := carrier.zero_mem f_deg hm q
add_mem' := carrier.add_mem f_deg q
smul_mem' := carrier.smul_mem f_deg hm q
theorem carrier.asIdeal.homogeneous : (carrier.asIdeal f_deg hm q).IsHomogeneous 𝒜 :=
fun i a ha j =>
(em (i = j)).elim (fun h => h ▸ by simpa only [proj_apply, decompose_coe, of_eq_same] using ha _)
fun h => by
simpa only [proj_apply, decompose_of_mem_ne 𝒜 (SetLike.coe_mem (decompose 𝒜 a i)) h,
zero_pow hm.ne', map_zero] using carrier.zero_mem f_deg hm q j
/-- For a prime ideal `q` in `A⁰_f`, the set `{a | aᵢᵐ/fⁱ ∈ q}` as a homogeneous ideal.
-/
def carrier.asHomogeneousIdeal : HomogeneousIdeal 𝒜 :=
⟨carrier.asIdeal f_deg hm q, carrier.asIdeal.homogeneous f_deg hm q⟩
theorem carrier.denom_notMem : f ∉ carrier.asIdeal f_deg hm q := fun rid =>
q.isPrime.ne_top <|
(Ideal.eq_top_iff_one _).mpr
(by
convert rid m
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_one,
HomogeneousLocalization.val_mk]
dsimp
simp_rw [decompose_of_mem_same _ f_deg]
simp only [mk_eq_monoidOf_mk', Submonoid.LocalizationMap.mk'_self])
@[deprecated (since := "2025-05-23")] alias carrier.denom_not_mem := carrier.denom_notMem
theorem carrier.relevant : ¬HomogeneousIdeal.irrelevant 𝒜 ≤ carrier.asHomogeneousIdeal f_deg hm q :=
fun rid => carrier.denom_notMem f_deg hm q <| rid <| DirectSum.decompose_of_mem_ne 𝒜 f_deg hm.ne'
theorem carrier.asIdeal.ne_top : carrier.asIdeal f_deg hm q ≠ ⊤ := fun rid =>
carrier.denom_notMem f_deg hm q (rid.symm ▸ Submodule.mem_top)
theorem carrier.asIdeal.prime : (carrier.asIdeal f_deg hm q).IsPrime :=
(carrier.asIdeal.homogeneous f_deg hm q).isPrime_of_homogeneous_mem_or_mem
(carrier.asIdeal.ne_top f_deg hm q) fun {x y} ⟨nx, hnx⟩ ⟨ny, hny⟩ hxy =>
show (∀ _, _ ∈ _) ∨ ∀ _, _ ∈ _ by
rw [← and_forall_ne nx, and_iff_left, ← and_forall_ne ny, and_iff_left]
· apply q.2.mem_or_mem; convert hxy (nx + ny) using 1
dsimp
simp_rw [decompose_of_mem_same 𝒜 hnx, decompose_of_mem_same 𝒜 hny,
decompose_of_mem_same 𝒜 (SetLike.GradedMonoid.toGradedMul.mul_mem hnx hny),
mul_pow, pow_add]
simp only [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mul, Localization.mk_mul]
simp only [Submonoid.mk_mul_mk, mk_eq_monoidOf_mk']
all_goals
intro n hn; convert q.1.zero_mem using 1
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_zero]; simp_rw [proj_apply]
convert mk_zero (S := Submonoid.powers f) _
rw [decompose_of_mem_ne 𝒜 _ hn.symm, zero_pow hm.ne']
· first | exact hnx | exact hny
/-- The function `Spec A⁰_f → Proj|D(f)` sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}`. -/
def toFun : (Spec.T A⁰_ f) → Proj.T| pbo f := fun q =>
⟨⟨carrier.asHomogeneousIdeal f_deg hm q, carrier.asIdeal.prime f_deg hm q,
carrier.relevant f_deg hm q⟩,
(ProjectiveSpectrum.mem_basicOpen _ f _).mp <| carrier.denom_notMem f_deg hm q⟩
end FromSpec
section toSpecFromSpec
lemma toSpec_fromSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) (x : Spec.T (A⁰_ f)) :
toSpec 𝒜 f (FromSpec.toFun f_deg hm x) = x := by
apply PrimeSpectrum.ext
ext z
obtain ⟨z, rfl⟩ := HomogeneousLocalization.mk_surjective z
rw [← FromSpec.num_mem_carrier_iff f_deg hm x]
exact ToSpec.mk_mem_carrier _ z
end toSpecFromSpec
section fromSpecToSpec
lemma fromSpec_toSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) (x : Proj.T| pbo f) :
FromSpec.toFun f_deg hm (toSpec 𝒜 f x) = x := by
refine Subtype.ext <| ProjectiveSpectrum.ext <| HomogeneousIdeal.ext' ?_
intro i z hzi
refine (FromSpec.mem_carrier_iff_of_mem f_deg hm _ _ hzi).trans ?_
exact (ToSpec.mk_mem_carrier _ _).trans (x.1.2.pow_mem_iff_mem m hm)
lemma toSpec_injective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Injective (toSpec 𝒜 f) := by
intro x₁ x₂ h
have := congr_arg (FromSpec.toFun f_deg hm) h
rwa [fromSpec_toSpec, fromSpec_toSpec] at this
lemma toSpec_surjective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Surjective (toSpec 𝒜 f) :=
Function.surjective_iff_hasRightInverse |>.mpr
⟨FromSpec.toFun f_deg hm, toSpec_fromSpec 𝒜 f_deg hm⟩
lemma toSpec_bijective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Bijective (toSpec (𝒜 := 𝒜) (f := f)) :=
⟨toSpec_injective 𝒜 f_deg hm, toSpec_surjective 𝒜 f_deg hm⟩
end fromSpecToSpec
namespace toSpec
variable {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m)
include hm f_deg
variable {𝒜} in
lemma image_basicOpen_eq_basicOpen (a : A) (i : ℕ) :
toSpec 𝒜 f '' (Subtype.val ⁻¹' (pbo (decompose 𝒜 a i) : Set (ProjectiveSpectrum 𝒜))) =
(PrimeSpectrum.basicOpen (R := A⁰_ f) <|
HomogeneousLocalization.mk
⟨m * i, ⟨decompose 𝒜 a i ^ m,
smul_eq_mul m i ▸ SetLike.pow_mem_graded _ (SetLike.coe_mem _)⟩,
⟨f^i, by rw [mul_comm]; exact SetLike.pow_mem_graded _ f_deg⟩, ⟨i, rfl⟩⟩).1 :=
Set.preimage_injective.mpr (toSpec_surjective 𝒜 f_deg hm) <|
Set.preimage_image_eq _ (toSpec_injective 𝒜 f_deg hm) ▸ by
rw [Opens.carrier_eq_coe, toSpec_preimage_basicOpen, ProjectiveSpectrum.basicOpen_pow 𝒜 _ m hm]
end toSpec
variable {𝒜} in
/-- The continuous function `Spec A⁰_f → Proj|D(f)` sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}` where
`m` is the degree of `f` -/
def fromSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Spec.T (A⁰_ f)) ⟶ (Proj.T| (pbo f)) :=
TopCat.ofHom
{ toFun := FromSpec.toFun f_deg hm
continuous_toFun := by
rw [isTopologicalBasis_subtype (ProjectiveSpectrum.isTopologicalBasis_basic_opens 𝒜) (pbo f).1
|>.continuous_iff]
rintro s ⟨_, ⟨a, rfl⟩, rfl⟩
have h₁ : Subtype.val (p := (pbo f).1) ⁻¹' (pbo a) =
⋃ i : ℕ, Subtype.val (p := (pbo f).1) ⁻¹' (pbo (decompose 𝒜 a i)) := by
simp [ProjectiveSpectrum.basicOpen_eq_union_of_projection 𝒜 a]
let e : _ ≃ _ :=
⟨FromSpec.toFun f_deg hm, ToSpec.toFun f, toSpec_fromSpec _ _ _, fromSpec_toSpec _ _ _⟩
change IsOpen <| e ⁻¹' _
rw [← Equiv.image_symm_eq_preimage, h₁, Set.image_iUnion]
exact isOpen_iUnion fun i ↦ toSpec.image_basicOpen_eq_basicOpen f_deg hm a i ▸
PrimeSpectrum.isOpen_basicOpen }
end ProjIsoSpecTopComponent
variable {𝒜} in
/--
The homeomorphism `Proj|D(f) ≅ Spec A⁰_f` defined by
- `φ : Proj|D(f) ⟶ Spec A⁰_f` by sending `x` to `A⁰_f ∩ span {g / 1 | g ∈ x}`
- `ψ : Spec A⁰_f ⟶ Proj|D(f)` by sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}`.
-/
def projIsoSpecTopComponent {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Proj.T| (pbo f)) ≅ (Spec.T (A⁰_ f)) where
hom := ProjIsoSpecTopComponent.toSpec 𝒜 f
inv := ProjIsoSpecTopComponent.fromSpec f_deg hm
hom_inv_id := ConcreteCategory.hom_ext _ _
(ProjIsoSpecTopComponent.fromSpec_toSpec 𝒜 f_deg hm)
inv_hom_id := ConcreteCategory.hom_ext _ _
(ProjIsoSpecTopComponent.toSpec_fromSpec 𝒜 f_deg hm)
namespace ProjectiveSpectrum.Proj
/--
The ring map from `A⁰_ f` to the local sections of the structure sheaf of the projective spectrum of
`A` on the basic open set `D(f)` defined by sending `s ∈ A⁰_f` to the section `x ↦ s` on `D(f)`.
-/
def awayToSection (f) : CommRingCat.of (A⁰_ f) ⟶ (structureSheaf 𝒜).1.obj (op (pbo f)) :=
CommRingCat.ofHom
-- Have to hint `S`, otherwise it gets unfolded to `structureSheafInType`
-- causing `ext` to fail
(S := (structureSheaf 𝒜).1.obj (op (pbo f)))
{ toFun s :=
⟨fun x ↦ HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr x.2) s, fun x ↦ by
obtain ⟨s, rfl⟩ := HomogeneousLocalization.mk_surjective s
obtain ⟨n, hn : f ^ n = s.den.1⟩ := s.den_mem
exact ⟨_, x.2, 𝟙 _, s.1, s.2, s.3,
fun x hsx ↦ x.2 (Ideal.IsPrime.mem_of_pow_mem inferInstance n (hn ▸ hsx)), fun _ ↦ rfl⟩⟩
map_add' _ _ := by ext; simp only [map_add, HomogeneousLocalization.val_add, Proj.add_apply]
map_mul' _ _ := by ext; simp only [map_mul, HomogeneousLocalization.val_mul, Proj.mul_apply]
map_zero' := by ext; simp only [map_zero, HomogeneousLocalization.val_zero, Proj.zero_apply]
map_one' := by ext; simp only [map_one, HomogeneousLocalization.val_one, Proj.one_apply] }
lemma awayToSection_germ (f x hx) :
awayToSection 𝒜 f ≫ (structureSheaf 𝒜).presheaf.germ _ x hx =
CommRingCat.ofHom (HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr hx)) ≫
(Proj.stalkIso' 𝒜 x).toCommRingCatIso.inv := by
ext z
apply (Proj.stalkIso' 𝒜 x).eq_symm_apply.mpr
apply Proj.stalkIso'_germ
lemma awayToSection_apply (f : A) (x p) :
(((ProjectiveSpectrum.Proj.awayToSection 𝒜 f).1 x).val p).val =
IsLocalization.map (M := Submonoid.powers f) (T := p.1.1.toIdeal.primeCompl) _
(RingHom.id _) (Submonoid.powers_le.mpr p.2) x.val := by
obtain ⟨x, rfl⟩ := HomogeneousLocalization.mk_surjective x
change (HomogeneousLocalization.mapId 𝒜 _ _).val = _
dsimp [HomogeneousLocalization.mapId, HomogeneousLocalization.map]
rw [Localization.mk_eq_mk', Localization.mk_eq_mk', IsLocalization.map_mk']
rfl
/--
The ring map from `A⁰_ f` to the global sections of the structure sheaf of the projective spectrum
of `A` restricted to the basic open set `D(f)`.
Mathematically, the map is the same as `awayToSection`.
-/
def awayToΓ (f) : CommRingCat.of (A⁰_ f) ⟶ LocallyRingedSpace.Γ.obj (op <| Proj| pbo f) :=
awayToSection 𝒜 f ≫ (ProjectiveSpectrum.Proj.structureSheaf 𝒜).1.map
(homOfLE (Opens.isOpenEmbedding_obj_top _).le).op
lemma awayToΓ_ΓToStalk (f) (x) :
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x =
CommRingCat.ofHom (HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr x.2)) ≫
(Proj.stalkIso' 𝒜 x.1).toCommRingCatIso.inv ≫
((Proj.toLocallyRingedSpace 𝒜).restrictStalkIso (Opens.isOpenEmbedding _) x).inv := by
rw [awayToΓ, Category.assoc, ← Category.assoc _ (Iso.inv _),
Iso.eq_comp_inv, Category.assoc, Category.assoc, Presheaf.Γgerm]
rw [LocallyRingedSpace.restrictStalkIso_hom_eq_germ]
simp only [Proj.toLocallyRingedSpace, Proj.toSheafedSpace]
rw [Presheaf.germ_res, awayToSection_germ]
rfl
/--
The morphism of locally ringed space from `Proj|D(f)` to `Spec A⁰_f` induced by the ring map
`A⁰_ f → Γ(Proj, D(f))` under the gamma spec adjunction.
-/
def toSpec (f) : (Proj| pbo f) ⟶ Spec (A⁰_ f) :=
ΓSpec.locallyRingedSpaceAdjunction.homEquiv (Proj| pbo f) (op (CommRingCat.of <| A⁰_ f))
(awayToΓ 𝒜 f).op
open HomogeneousLocalization IsLocalRing
lemma toSpec_base_apply_eq_comap {f} (x : Proj| pbo f) :
(toSpec 𝒜 f).base x = PrimeSpectrum.comap (mapId 𝒜 (Submonoid.powers_le.mpr x.2))
(closedPoint (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)) := by
change PrimeSpectrum.comap (awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x).hom
(IsLocalRing.closedPoint ((Proj| pbo f).presheaf.stalk x)) = _
rw [awayToΓ_ΓToStalk, CommRingCat.hom_comp, PrimeSpectrum.comap_comp]
exact congr(PrimeSpectrum.comap _ $(@IsLocalRing.comap_closedPoint
(HomogeneousLocalization.AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) _ _
((Proj| pbo f).presheaf.stalk x) _ _ _ (isLocalHom_of_isIso _)))
lemma toSpec_base_apply_eq {f} (x : Proj| pbo f) :
(toSpec 𝒜 f).base x = ProjIsoSpecTopComponent.toSpec 𝒜 f x :=
toSpec_base_apply_eq_comap 𝒜 x |>.trans <| PrimeSpectrum.ext <| Ideal.ext fun z =>
show ¬ IsUnit _ ↔ z ∈ ProjIsoSpecTopComponent.ToSpec.carrier _ by
obtain ⟨z, rfl⟩ := z.mk_surjective
rw [← HomogeneousLocalization.isUnit_iff_isUnit_val,
ProjIsoSpecTopComponent.ToSpec.mk_mem_carrier, HomogeneousLocalization.map_mk,
HomogeneousLocalization.val_mk, Localization.mk_eq_mk',
IsLocalization.AtPrime.isUnit_mk'_iff]
exact not_not
lemma toSpec_base_isIso {f} {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
IsIso (toSpec 𝒜 f).base := by
convert (projIsoSpecTopComponent f_deg hm).isIso_hom
exact ConcreteCategory.hom_ext _ _ <| toSpec_base_apply_eq 𝒜
lemma mk_mem_toSpec_base_apply {f} (x : Proj| pbo f)
(z : NumDenSameDeg 𝒜 (.powers f)) :
HomogeneousLocalization.mk z ∈ ((toSpec 𝒜 f).base x).asIdeal ↔
z.num.1 ∈ x.1.asHomogeneousIdeal :=
(toSpec_base_apply_eq 𝒜 x).symm ▸ ProjIsoSpecTopComponent.ToSpec.mk_mem_carrier _ _
lemma toSpec_preimage_basicOpen {f}
(t : NumDenSameDeg 𝒜 (.powers f)) :
(Opens.map (toSpec 𝒜 f).base).obj (sbo (HomogeneousLocalization.mk t)) =
Opens.comap ⟨_, continuous_subtype_val⟩ (pbo t.num.1) :=
Opens.ext <| Opens.map_coe _ _ ▸ by
convert (ProjIsoSpecTopComponent.ToSpec.preimage_basicOpen f t)
exact funext fun _ => toSpec_base_apply_eq _ _
@[reassoc]
lemma toOpen_toSpec_val_c_app (f) (U) :
StructureSheaf.toOpen (A⁰_ f) U.unop ≫ (toSpec 𝒜 f).c.app U =
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.map (homOfLE le_top).op :=
Eq.trans (by congr) <| ΓSpec.toOpen_comp_locallyRingedSpaceAdjunction_homEquiv_app _ U
@[reassoc]
lemma toStalk_stalkMap_toSpec (f) (x) :
StructureSheaf.toStalk _ _ ≫ (toSpec 𝒜 f).stalkMap x =
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x := by
rw [StructureSheaf.toStalk, Category.assoc]
simp_rw [← Spec.locallyRingedSpaceObj_presheaf']
rw [LocallyRingedSpace.stalkMap_germ (toSpec 𝒜 f),
toOpen_toSpec_val_c_app_assoc, Presheaf.germ_res]
rfl
/--
If `x` is a point in the basic open set `D(f)` where `f` is a homogeneous element of positive
degree, then the homogeneously localized ring `A⁰ₓ` has the universal property of the localization
of `A⁰_f` at `φ(x)` where `φ : Proj|D(f) ⟶ Spec A⁰_f` is the morphism of locally ringed space
constructed as above.
-/
lemma isLocalization_atPrime (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
@IsLocalization (Away 𝒜 f) _ ((toSpec 𝒜 f).base x).asIdeal.primeCompl
(AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) _
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra := by
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
constructor
· rintro ⟨y, hy⟩
obtain ⟨y, rfl⟩ := HomogeneousLocalization.mk_surjective y
refine .of_mul_eq_one
(.mk ⟨y.deg, y.den, y.num, (mk_mem_toSpec_base_apply _ _ _).not.mp hy⟩) <| val_injective _ ?_
simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mul, val_mk, mk_eq_mk',
val_one, IsLocalization.mk'_mul_mk'_eq_one']
· intro z
obtain ⟨⟨i, a, ⟨b, hb⟩, (hb' : b ∉ x.1.1)⟩, rfl⟩ := z.mk_surjective
refine ⟨⟨HomogeneousLocalization.mk ⟨i * m, ⟨a * b ^ (m - 1), ?_⟩,
⟨f ^ i, SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
⟨HomogeneousLocalization.mk ⟨i * m, ⟨b ^ m, mul_comm m i ▸ SetLike.pow_mem_graded _ hb⟩,
⟨f ^ i, SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
(mk_mem_toSpec_base_apply _ _ _).not.mpr <| x.1.1.toIdeal.primeCompl.pow_mem hb' m⟩⟩,
val_injective _ ?_⟩
· convert SetLike.mul_mem_graded a.2 (SetLike.pow_mem_graded (m - 1) hb) using 2
rw [← succ_nsmul', tsub_add_cancel_of_le (by cutsat), mul_comm, smul_eq_mul]
· simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mul, val_mk,
mk_eq_mk', ← IsLocalization.mk'_mul, Submonoid.mk_mul_mk, IsLocalization.mk'_eq_iff_eq]
rw [mul_comm b, mul_mul_mul_comm, ← pow_succ', mul_assoc, tsub_add_cancel_of_le (by cutsat)]
· intro y z e
obtain ⟨y, rfl⟩ := HomogeneousLocalization.mk_surjective y
obtain ⟨z, rfl⟩ := HomogeneousLocalization.mk_surjective z
obtain ⟨i, c, hc, hc', e⟩ : ∃ i, ∃ c ∈ 𝒜 i, c ∉ x.1.asHomogeneousIdeal ∧
c * (z.den.1 * y.num.1) = c * (y.den.1 * z.num.1) := by
apply_fun HomogeneousLocalization.val at e
simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mk, mk_eq_mk',
IsLocalization.mk'_eq_iff_eq] at e
obtain ⟨⟨c, hcx⟩, hc⟩ := IsLocalization.exists_of_eq (M := x.1.1.toIdeal.primeCompl) e
obtain ⟨i, hi⟩ := not_forall.mp ((x.1.1.isHomogeneous.mem_iff _).not.mp hcx)
refine ⟨i, _, (decompose 𝒜 c i).2, hi, ?_⟩
apply_fun fun x ↦ (decompose 𝒜 x (i + z.deg + y.deg)).1 at hc
conv_rhs at hc => rw [add_right_comm]
rwa [← mul_assoc, coe_decompose_mul_add_of_right_mem, coe_decompose_mul_add_of_right_mem,
← mul_assoc, coe_decompose_mul_add_of_right_mem, coe_decompose_mul_add_of_right_mem,
mul_assoc, mul_assoc] at hc
exacts [y.den.2, z.num.2, z.den.2, y.num.2]
refine ⟨⟨HomogeneousLocalization.mk ⟨m * i, ⟨c ^ m, SetLike.pow_mem_graded _ hc⟩,
⟨f ^ i, mul_comm m i ▸ SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
(mk_mem_toSpec_base_apply _ _ _).not.mpr <| x.1.1.toIdeal.primeCompl.pow_mem hc' _⟩,
val_injective _ ?_⟩
simp only [val_mul, val_mk, mk_eq_mk', ← IsLocalization.mk'_mul, Submonoid.mk_mul_mk,
IsLocalization.mk'_eq_iff_eq, mul_assoc]
congr 2
rw [mul_left_comm, mul_left_comm y.den.1, ← tsub_add_cancel_of_le (show 1 ≤ m from hm),
pow_succ, mul_assoc, mul_assoc, e]
/--
For an element `f ∈ A` with positive degree and a homogeneous ideal in `D(f)`, we have that the
stalk of `Spec A⁰_ f` at `y` is isomorphic to `A⁰ₓ` where `y` is the point in `Proj` corresponding
to `x`.
-/
def specStalkEquiv (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).base x) ≅
CommRingCat.of (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
haveI := isLocalization_atPrime 𝒜 f x f_deg hm
(IsLocalization.algEquiv
(R := A⁰_ f)
(M := ((toSpec 𝒜 f).base x).asIdeal.primeCompl)
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).base x))
(Q := AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)).toRingEquiv.toCommRingCatIso
lemma toStalk_specStalkEquiv (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
StructureSheaf.toStalk (A⁰_ f) ((toSpec 𝒜 f).base x) ≫ (specStalkEquiv 𝒜 f x f_deg hm).hom =
CommRingCat.ofHom (mapId _ <| Submonoid.powers_le.mpr x.2) :=
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
letI := isLocalization_atPrime 𝒜 f x f_deg hm
CommRingCat.hom_ext (IsLocalization.algEquiv
(R := A⁰_ f)
(M := ((toSpec 𝒜 f).base x).asIdeal.primeCompl)
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).base x))
(Q := AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)).toAlgHom.comp_algebraMap
lemma stalkMap_toSpec (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(toSpec 𝒜 f).stalkMap x =
(specStalkEquiv 𝒜 f x f_deg hm).hom ≫ (Proj.stalkIso' 𝒜 x.1).toCommRingCatIso.inv ≫
((Proj.toLocallyRingedSpace 𝒜).restrictStalkIso (Opens.isOpenEmbedding _) x).inv :=
CommRingCat.hom_ext <|
IsLocalization.ringHom_ext (R := A⁰_ f) ((toSpec 𝒜 f).base x).asIdeal.primeCompl
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).base x)) <|
CommRingCat.hom_ext_iff.mp <|
(toStalk_stalkMap_toSpec _ _ _).trans <| by
rw [awayToΓ_ΓToStalk, ← toStalk_specStalkEquiv, Category.assoc]; rfl
lemma isIso_toSpec (f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
IsIso (toSpec 𝒜 f) := by
haveI : IsIso (toSpec 𝒜 f).base := toSpec_base_isIso 𝒜 f_deg hm
haveI _ (x) : IsIso ((toSpec 𝒜 f).stalkMap x) := by
rw [stalkMap_toSpec 𝒜 f x f_deg hm]; infer_instance
haveI : LocallyRingedSpace.IsOpenImmersion (toSpec 𝒜 f) :=
LocallyRingedSpace.IsOpenImmersion.of_stalk_iso (toSpec 𝒜 f)
(TopCat.homeoOfIso (asIso <| (toSpec 𝒜 f).base)).isOpenEmbedding
exact LocallyRingedSpace.IsOpenImmersion.to_iso _
end ProjectiveSpectrum.Proj
open ProjectiveSpectrum.Proj in
/--
If `f ∈ A` is a homogeneous element of positive degree, then the projective spectrum restricted to
`D(f)` as a locally ringed space is isomorphic to `Spec A⁰_f`.
-/
def projIsoSpec (f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Proj| pbo f) ≅ (Spec (A⁰_ f)) :=
@asIso _ _ _ _ (f := toSpec 𝒜 f) (isIso_toSpec 𝒜 f f_deg hm)
/--
This is the scheme `Proj(A)` for any `ℕ`-graded ring `A`.
-/
def «Proj» : Scheme where
__ := Proj.toLocallyRingedSpace 𝒜
local_affine (x : Proj.T) := by
classical
obtain ⟨f, m, f_deg, hm, hx⟩ : ∃ (f : A) (m : ℕ) (_ : f ∈ 𝒜 m) (_ : 0 < m), f ∉ x.1 := by
by_contra!
refine x.not_irrelevant_le fun z hz ↦ ?_
rw [← DirectSum.sum_support_decompose 𝒜 z]
exact x.1.toIdeal.sum_mem fun k hk ↦ this _ k (SetLike.coe_mem _) <| by_contra <| by aesop
exact ⟨⟨pbo f, hx⟩, .of (A⁰_ f), ⟨projIsoSpec 𝒜 f f_deg hm⟩⟩
end AlgebraicGeometry |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Modules/Presheaf.lean | import Mathlib.Algebra.Category.ModuleCat.Presheaf
import Mathlib.AlgebraicGeometry.Scheme
import Mathlib.CategoryTheory.Sites.Whiskering
/-!
# The category of presheaves of modules over a scheme
In this file, given a scheme `X`, we define the category of presheaves
of modules over `X`. As categories of presheaves of modules are
defined for presheaves of rings (and not presheaves of commutative rings),
we also introduce a definition `X.ringCatSheaf` for the underlying sheaf
of rings of `X`.
-/
universe u
open CategoryTheory
namespace AlgebraicGeometry.Scheme
variable (X : Scheme.{u})
/-- The underlying sheaf of rings of a scheme. -/
abbrev ringCatSheaf : TopCat.Sheaf RingCat.{u} X :=
(sheafCompose _ (forget₂ CommRingCat RingCat.{u})).obj X.sheaf
/-- The category of presheaves of modules over a scheme. -/
nonrec abbrev PresheafOfModules := PresheafOfModules.{u} X.ringCatSheaf.val
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Modules/Sheaf.lean | import Mathlib.Algebra.Category.ModuleCat.Sheaf.Abelian
import Mathlib.AlgebraicGeometry.Modules.Presheaf
/-!
# The category of sheaves of modules over a scheme
In this file, we define the abelian category of sheaves of modules
`X.Modules` over a scheme `X`.
-/
universe u
open CategoryTheory
namespace AlgebraicGeometry.Scheme
variable (X : Scheme.{u})
/-- The category of sheaves of modules over a scheme. -/
abbrev Modules := SheafOfModules.{u} X.ringCatSheaf
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
noncomputable instance : HasSheafify (Opens.grothendieckTopology X) AddCommGrpCat.{u} :=
inferInstance
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
noncomputable instance : Abelian X.Modules := inferInstance
end AlgebraicGeometry.Scheme |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Modules/Tilde.lean | import Mathlib.Algebra.Module.LocalizedModule.Basic
import Mathlib.AlgebraicGeometry.StructureSheaf
import Mathlib.AlgebraicGeometry.Modules.Sheaf
import Mathlib.Algebra.Category.ModuleCat.Sheaf
import Mathlib.Algebra.Category.ModuleCat.FilteredColimits
import Mathlib.CategoryTheory.Limits.ConcreteCategory.WithAlgebraicStructures
/-!
# Construction of M^~
Given any commutative ring `R` and `R`-module `M`, we construct the sheaf `M^~` of `𝒪_SpecR`-modules
such that `M^~(U)` is the set of dependent functions that are locally fractions.
## Main definitions
* `ModuleCat.tildeInType` : `M^~` as a sheaf of types groups.
* `ModuleCat.tilde` : `M^~` as a sheaf of `𝒪_{Spec R}`-modules.
* `ModuleCat.tilde.stalkIso`: The isomorphism of `R`-modules from the stalk of `M^~` at `x` to
the localization of `M` at the prime ideal corresponding to `x`.
## Technical note
To get the `R`-module structure on the stalks on `M^~`, we had to define
`ModuleCat.tildeInModuleCat`, which is `M^~` seen as sheaf of `R`-modules. We get it by
applying a forgetful functor to `ModuleCat.tilde M`.
-/
universe u
open TopCat AlgebraicGeometry TopologicalSpace CategoryTheory Opposite
variable {R : Type u} [CommRing R] (M : ModuleCat.{u} R)
namespace ModuleCat
namespace Tilde
/-- For an `R`-module `M` and a point `P` in `Spec R`, `Localizations P` is the localized module
`M` at the prime ideal `P`. -/
abbrev Localizations (P : PrimeSpectrum.Top R) :=
LocalizedModule P.asIdeal.primeCompl M
/-- For any open subset `U ⊆ Spec R`, `IsFraction` is the predicate expressing that a function
`f : ∏_{x ∈ U}, Mₓ` is such that for any `𝔭 ∈ U`, `f 𝔭 = m / s` for some `m : M` and `s ∉ 𝔭`.
In short `f` is a fraction on `U`. -/
def isFraction {U : Opens (PrimeSpectrum R)} (f : ∀ 𝔭 : U, Localizations M 𝔭.1) : Prop :=
∃ (m : M) (s : R),
∀ x : U, s ∉ x.1.asIdeal ∧ s • f x = LocalizedModule.mkLinearMap x.1.asIdeal.primeCompl M m
/--
The property of a function `f : ∏_{x ∈ U}, Mₓ` being a fraction is stable under restriction.
-/
def isFractionPrelocal : PrelocalPredicate (Localizations M) where
pred {_} f := isFraction M f
res := by rintro V U i f ⟨m, s, w⟩; exact ⟨m, s, fun x => w (i x)⟩
/--
For any open subset `U ⊆ Spec R`, `IsLocallyFraction` is the predicate expressing that a function
`f : ∏_{x ∈ U}, Mₓ` is such that for any `𝔭 ∈ U`, there exists an open neighbourhood `V ∋ 𝔭`, such
that for any `𝔮 ∈ V`, `f 𝔮 = m / s` for some `m : M` and `s ∉ 𝔮`.
In short `f` is locally a fraction on `U`.
-/
def isLocallyFraction : LocalPredicate (Localizations M) := (isFractionPrelocal M).sheafify
@[simp]
theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)}
(f : ∀ x : U, Localizations M x) :
(isLocallyFraction M).pred f =
∀ y : U,
∃ (V : _) (_ : y.1 ∈ V) (i : V ⟶ U),
∃ (m : M) (s: R), ∀ x : V, s ∉ x.1.asIdeal ∧ s • f (i x) =
LocalizedModule.mkLinearMap x.1.asIdeal.primeCompl M m :=
rfl
/- M_x is an O_SpecR(U)-module when x is in U -/
noncomputable instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) (x : U.unop) :
Module ((Spec.structureSheaf R).val.obj U) (Localizations M x):=
Module.compHom (R := (Localization.AtPrime x.1.asIdeal)) _
((StructureSheaf.openToLocalization R U.unop x x.2).hom)
@[simp]
lemma sections_smul_localizations_def {U : (Opens (PrimeSpectrum.Top R))ᵒᵖ} (x : U.unop)
(r : (Spec.structureSheaf R).val.obj U) (m : Localizations M ↑x) :
r • m = r.1 x • m := rfl
/--
For any `R`-module `M` and any open subset `U ⊆ Spec R`, `M^~(U)` is an `𝒪_{Spec R}(U)`-submodule
of `∏_{𝔭 ∈ U} M_𝔭`. -/
noncomputable def sectionsSubmodule (U : (Opens (PrimeSpectrum R))ᵒᵖ) :
Submodule ((Spec.structureSheaf R).1.obj U) (∀ x : U.unop, Localizations M x.1) where
carrier := { f | (isLocallyFraction M).pred f }
zero_mem' x := ⟨unop U, x.2, 𝟙 _, 0, 1, fun y =>
⟨Ideal.ne_top_iff_one _ |>.1 y.1.isPrime.1, by simp⟩⟩
add_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, sb • ra + sa • rb, sa * sb, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y : Va) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ y : Vb) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [LocalizedModule.mkLinearMap_apply, Opens.comp_apply, Pi.add_apply, smul_add,
map_add, map_smul] at wa wb ⊢
rw [← wa, ← wb, ← mul_smul, ← mul_smul]
congr 2
simp [mul_comm]
smul_mem' := by
intro r a ha x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases r.2 x with ⟨Vr, mr, ir, rr, sr, wr⟩
refine ⟨Va ⊓ Vr, ⟨ma, mr⟩, Opens.infLELeft _ _ ≫ ia, rr • ra, sr * sa, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y : Va) with ⟨nma, wa⟩
rcases wr (Opens.infLERight _ _ y) with ⟨nmr, wr⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [Pi.smul_apply, LinearMapClass.map_smul, Opens.apply_def] at wa wr ⊢
rw [mul_comm, ← Algebra.smul_def] at wr
rw [sections_smul_localizations_def, ← wa, ← mul_smul, ← smul_assoc, mul_comm sr, mul_smul,
wr, mul_comm rr, Algebra.smul_def, ← map_mul]
rfl
end Tilde
/--
For any `R`-module `M`, `TildeInType R M` is the sheaf of set on `Spec R` whose sections on `U` are
the dependent functions that are locally fractions. This is often denoted by `M^~`.
See also `Tilde.isLocallyFraction`.
-/
def tildeInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
subsheafToTypes (Tilde.isLocallyFraction M)
noncomputable instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
AddCommGroup (M.tildeInType.1.obj U) :=
inferInstanceAs <| AddCommGroup (Tilde.sectionsSubmodule M U)
noncomputable instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
Module ((Spec <| .of R).ringCatSheaf.1.obj U) (M.tildeInType.1.obj U) :=
inferInstanceAs <| Module _ (Tilde.sectionsSubmodule M U)
/--
`M^~` as a sheaf of `𝒪_{Spec R}`-modules
-/
noncomputable def tilde : (Spec <| .of R).Modules where
val :=
{ obj := fun U ↦ ModuleCat.of _ (M.tildeInType.val.obj U)
map := fun {U V} i ↦ ofHom
-- TODO: after https://github.com/leanprover-community/mathlib4/pull/19511 we need to hint `(Y := ...)`
-- This suggests `restrictScalars` needs to be redesigned.
(Y := (restrictScalars ((Spec <| .of R).ringCatSheaf.val.map i).hom).obj
(of ((Spec <| .of R).ringCatSheaf.val.obj V) (M.tildeInType.val.obj V)))
{ toFun := M.tildeInType.val.map i
map_smul' := by intros; rfl
map_add' := by intros; rfl } }
isSheaf := (TopCat.Presheaf.isSheaf_iff_isSheaf_comp (forget AddCommGrpCat) _ ).2
M.tildeInType.2
/--
This is `M^~` as a sheaf of `R`-modules.
-/
noncomputable def tildeInModuleCat :
TopCat.Presheaf (ModuleCat R) (PrimeSpectrum.Top R) :=
(PresheafOfModules.forgetToPresheafModuleCat (op ⊤) <|
Limits.initialOpOfTerminal Limits.isTerminalTop).obj (tilde M).1 ⋙
ModuleCat.restrictScalars (StructureSheaf.globalSectionsIso R).hom.hom
namespace Tilde
@[simp]
theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U)
(s : (tildeInModuleCat M).obj (op U)) (x : V) :
((tildeInModuleCat M).map i.op s).1 x = (s.1 (i x) :) :=
rfl
lemma smul_section_apply (r : R) (U : Opens (PrimeSpectrum.Top R))
(s : (tildeInModuleCat M).obj (op U)) (x : U) :
(r • s).1 x = r • (s.1 x) := rfl
lemma smul_stalk_no_nonzero_divisor {x : PrimeSpectrum R}
(r : x.asIdeal.primeCompl) (st : (tildeInModuleCat M).stalk x) (hst : r.1 • st = 0) :
st = 0 := by
refine Limits.Concrete.colimit_no_zero_smul_divisor
_ _ _ ⟨op ⟨PrimeSpectrum.basicOpen r.1, r.2⟩, fun U i s hs ↦ Subtype.eq <| funext fun pt ↦ ?_⟩
_ hst
apply LocalizedModule.eq_zero_of_smul_eq_zero _ (i.unop pt).2 _
(congr_fun (Subtype.ext_iff.1 hs) pt)
/--
If `U` is an open subset of `Spec R`, this is the morphism of `R`-modules from `M` to
`M^~(U)`.
-/
noncomputable def toOpen (U : Opens (PrimeSpectrum.Top R)) :
ModuleCat.of R M ⟶ (tildeInModuleCat M).obj (op U) :=
-- TODO: after https://github.com/leanprover-community/mathlib4/pull/19511 we need to hint `(Y := ...)`
-- This suggests `restrictScalars` needs to be redesigned.
ModuleCat.ofHom (Y := (tildeInModuleCat M).obj (op U))
{ toFun := fun f =>
⟨fun x ↦ LocalizedModule.mkLinearMap _ _ f, fun x ↦
⟨U, x.2, 𝟙 _, f, 1, fun y ↦ ⟨(Ideal.ne_top_iff_one _).1 y.1.2.1, by simp⟩⟩⟩
map_add' := fun f g => Subtype.eq <| funext fun x ↦ LinearMap.map_add _ _ _
map_smul' := fun r m => by
simp only [isLocallyFraction_pred, LocalizedModule.mkLinearMap_apply, LinearMapClass.map_smul,
RingHom.id_apply]
rfl }
@[simp]
theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) :
toOpen M U ≫ (tildeInModuleCat M).map i.op = toOpen M V :=
rfl
/--
If `x` is a point of `Spec R`, this is the morphism of `R`-modules from `M` to the stalk of
`M^~` at `x`.
-/
noncomputable def toStalk (x : PrimeSpectrum.Top R) :
ModuleCat.of R M ⟶ TopCat.Presheaf.stalk (tildeInModuleCat M) x :=
(toOpen M ⊤ ≫ TopCat.Presheaf.germ (tildeInModuleCat M) ⊤ x (by trivial))
open LocalizedModule TopCat.Presheaf in
lemma isUnit_toStalk (x : PrimeSpectrum.Top R) (r : x.asIdeal.primeCompl) :
IsUnit ((algebraMap R (Module.End R ((tildeInModuleCat M).stalk x))) r) := by
rw [Module.End.isUnit_iff]
refine ⟨LinearMap.ker_eq_bot.1 <| eq_bot_iff.2 fun st (h : r.1 • st = 0) ↦
smul_stalk_no_nonzero_divisor M r st h, fun st ↦ ?_⟩
obtain ⟨U, mem, s, rfl⟩ := germ_exist (F := M.tildeInModuleCat) x st
let O := U ⊓ (PrimeSpectrum.basicOpen r)
refine ⟨germ M.tildeInModuleCat O x ⟨mem, r.2⟩
⟨fun q ↦ (Localization.mk 1 ⟨r, q.2.2⟩ : Localization.AtPrime q.1.asIdeal) • s.1
⟨q.1, q.2.1⟩, fun q ↦ ?_⟩, by
simpa only [Module.algebraMap_end_apply, ← map_smul] using
germ_ext (C := ModuleCat R) (W := O) (hxW := ⟨mem, r.2⟩) (iWU := 𝟙 _)
(iWV := homOfLE inf_le_left) _ <|
Subtype.eq <| funext fun y ↦ smul_eq_iff_of_mem (S := y.1.1.primeCompl) r _ _ _ |>.2 rfl⟩
obtain ⟨V, mem_V, iV, num, den, hV⟩ := s.2 ⟨q.1, q.2.1⟩
refine ⟨V ⊓ O, ⟨mem_V, q.2⟩, homOfLE inf_le_right, num, r * den, fun y ↦ ?_⟩
obtain ⟨h1, h2⟩ := hV ⟨y, y.2.1⟩
refine ⟨y.1.asIdeal.primeCompl.mul_mem y.2.2.2 h1, ?_⟩
simp only [Opens.apply_def, isLocallyFraction_pred, mkLinearMap_apply,
smul_eq_iff_of_mem (S := y.1.1.primeCompl) (hr := h1), mk_smul_mk, one_smul, mul_one] at h2 ⊢
simpa only [h2, mk_smul_mk, one_smul, smul'_mk, mk_eq] using ⟨1, by simp only [one_smul]; rfl⟩
/--
The morphism of `R`-modules from the localization of `M` at the prime ideal corresponding to `x`
to the stalk of `M^~` at `x`.
-/
noncomputable def localizationToStalk (x : PrimeSpectrum.Top R) :
ModuleCat.of R (LocalizedModule x.asIdeal.primeCompl M) ⟶
(TopCat.Presheaf.stalk (tildeInModuleCat M) x) :=
ModuleCat.ofHom <| LocalizedModule.lift _ (toStalk M x).hom <| isUnit_toStalk M x
/-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,
implemented as a subtype of dependent functions to localizations at prime ideals, and evaluates
the section on the point corresponding to a given prime ideal. -/
noncomputable def openToLocalization
(U : Opens (PrimeSpectrum R)) (x : PrimeSpectrum R) (hx : x ∈ U) :
(tildeInModuleCat M).obj (op U) ⟶
ModuleCat.of R (LocalizedModule x.asIdeal.primeCompl M) :=
-- TODO: after https://github.com/leanprover-community/mathlib4/pull/19511 we need to hint `(X := ...)` and `(Y := ...)`
-- This suggests `restrictScalars` needs to be redesigned.
ModuleCat.ofHom
(X := (tildeInModuleCat M).obj (op U))
(Y := ModuleCat.of R (LocalizedModule x.asIdeal.primeCompl M))
{ toFun := fun s => (s.1 ⟨x, hx⟩ :)
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
/--
The morphism of `R`-modules from the stalk of `M^~` at `x` to the localization of `M` at the
prime ideal of `R` corresponding to `x`.
-/
noncomputable def stalkToFiberLinearMap (x : PrimeSpectrum.Top R) :
(tildeInModuleCat M).stalk x ⟶
ModuleCat.of R (LocalizedModule x.asIdeal.primeCompl M) :=
Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (tildeInModuleCat M))
{ pt := _
ι :=
{ app := fun U => openToLocalization M ((OpenNhds.inclusion _).obj U.unop) x U.unop.2 } }
@[simp]
theorem germ_comp_stalkToFiberLinearMap (U : Opens (PrimeSpectrum.Top R)) (x) (hx : x ∈ U) :
(tildeInModuleCat M).germ U x hx ≫ stalkToFiberLinearMap M x =
openToLocalization M U x hx :=
Limits.colimit.ι_desc _ _
@[simp]
theorem stalkToFiberLinearMap_germ (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) (s : (tildeInModuleCat M).obj (op U)) :
(stalkToFiberLinearMap M x).hom
(TopCat.Presheaf.germ (tildeInModuleCat M) U x hx s) = (s.1 ⟨x, hx⟩ :) :=
DFunLike.ext_iff.1 (ModuleCat.hom_ext_iff.mp (germ_comp_stalkToFiberLinearMap M U x hx)) s
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x) (hx : x ∈ U) :
toOpen M U ≫ M.tildeInModuleCat.germ U x hx = toStalk M x := by
rw [← toOpen_res M ⊤ U (homOfLE le_top : U ⟶ ⊤), Category.assoc, Presheaf.germ_res]; rfl
@[reassoc (attr := simp)]
theorem toStalk_comp_stalkToFiberLinearMap (x : PrimeSpectrum.Top R) :
toStalk M x ≫ stalkToFiberLinearMap M x =
ofHom (LocalizedModule.mkLinearMap x.asIdeal.primeCompl M) := by
rw [toStalk, Category.assoc, germ_comp_stalkToFiberLinearMap]; rfl
theorem stalkToFiberLinearMap_toStalk (x : PrimeSpectrum.Top R) (m : M) :
(stalkToFiberLinearMap M x).hom (toStalk M x m) =
LocalizedModule.mk m 1 :=
LinearMap.ext_iff.1 (ModuleCat.hom_ext_iff.mp (toStalk_comp_stalkToFiberLinearMap M x)) _
/--
If `U` is an open subset of `Spec R`, `m` is an element of `M` and `r` is an element of `R`
that is invertible on `U` (i.e. does not belong to any prime ideal corresponding to a point
in `U`), this is `m / r` seen as a section of `M^~` over `U`.
-/
def const (m : M) (r : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, r ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
(tildeInModuleCat M).obj (op U) :=
⟨fun x => LocalizedModule.mk m ⟨r, hu x x.2⟩, fun x =>
⟨U, x.2, 𝟙 _, m, r, fun y => ⟨hu _ y.2, by
simpa only [LocalizedModule.mkLinearMap_apply, LocalizedModule.smul'_mk,
LocalizedModule.mk_eq] using ⟨1, by simp⟩⟩⟩⟩
@[simp]
theorem const_apply (m : M) (r : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, r ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) :
(const M m r U hu).1 x = LocalizedModule.mk m ⟨r, hu x x.2⟩ :=
rfl
theorem exists_const (U) (s : (tildeInModuleCat M).obj (op U)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) :
∃ (V : Opens (PrimeSpectrum.Top R)) (_ : x ∈ V) (i : V ⟶ U) (f : M) (g : R) (hg : _),
const M f g V hg = (tildeInModuleCat M).map i.op s :=
let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩
⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1, Subtype.eq <| funext fun y => by
obtain ⟨h1, (h2 : g • s.1 ⟨y, _⟩ = LocalizedModule.mk f 1)⟩ := hfg y
exact show LocalizedModule.mk f ⟨g, by exact h1⟩ = s.1 (iVU y) by
set x := s.1 (iVU y); change g • x = _ at h2; clear_value x
induction x using LocalizedModule.induction_on with
| h a b =>
rw [LocalizedModule.smul'_mk, LocalizedModule.mk_eq] at h2
obtain ⟨c, hc⟩ := h2
exact LocalizedModule.mk_eq.mpr ⟨c, by simpa using hc.symm⟩⟩
@[simp]
theorem res_const (f : M) (g : R) (U hu V hv i) :
(tildeInModuleCat M).map i (const M f g U hu) = const M f g V hv :=
rfl
@[simp]
theorem localizationToStalk_mk (x : PrimeSpectrum.Top R) (f : M) (s : x.asIdeal.primeCompl) :
(localizationToStalk M x).hom (LocalizedModule.mk f s) =
(tildeInModuleCat M).germ (PrimeSpectrum.basicOpen (s : R)) x s.2
(const M f s (PrimeSpectrum.basicOpen s) fun _ => id) :=
(Module.End.isUnit_iff _ |>.1 (isUnit_toStalk M x s)).injective <| by
erw [← Module.End.mul_apply]
simp only [IsUnit.mul_val_inv, Module.End.one_apply, Module.algebraMap_end_apply]
change (M.tildeInModuleCat.germ ⊤ x ⟨⟩) ((toOpen M ⊤) f) = _
rw [← map_smul]
fapply TopCat.Presheaf.germ_ext (W := PrimeSpectrum.basicOpen s.1) (hxW := s.2)
(F := M.tildeInModuleCat)
· exact homOfLE le_top
· exact 𝟙 _
refine Subtype.eq <| funext fun y => show LocalizedModule.mk f 1 = _ from ?_
#adaptation_note /-- https://github.com/leanprover/lean4/pull/6024
added this refine hack to be able to add type hint in `change` -/
refine (?_ : @Eq ?ty _ _)
change LocalizedModule.mk f 1 = (s.1 • LocalizedModule.mk f _ : ?ty)
rw [LocalizedModule.smul'_mk, LocalizedModule.mk_eq]
exact ⟨1, by simp⟩
/--
The isomorphism of `R`-modules from the stalk of `M^~` at `x` to the localization of `M` at the
prime ideal corresponding to `x`.
-/
@[simps]
noncomputable def stalkIso (x : PrimeSpectrum.Top R) :
TopCat.Presheaf.stalk (tildeInModuleCat M) x ≅
ModuleCat.of R (LocalizedModule x.asIdeal.primeCompl M) where
hom := stalkToFiberLinearMap M x
inv := localizationToStalk M x
hom_inv_id := TopCat.Presheaf.stalk_hom_ext _ fun U hxU ↦ ModuleCat.hom_ext <|
LinearMap.ext fun s ↦ by
change localizationToStalk M x (stalkToFiberLinearMap M x (M.tildeInModuleCat.germ U x hxU s)) =
M.tildeInModuleCat.germ U x hxU s
rw [stalkToFiberLinearMap_germ]
obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
exists_const _ _ s x hxU
have := res_apply M U V iVU s ⟨x, hxV⟩
dsimp only [isLocallyFraction_pred, Opens.val_apply, LocalizedModule.mkLinearMap_apply,
Opens.apply_mk] at this
rw [← this, ← hs, const_apply, localizationToStalk_mk]
exact (tildeInModuleCat M).germ_ext V hxV (homOfLE hg) iVU <| hs ▸ rfl
inv_hom_id := by ext x; exact x.induction_on (fun _ _ => by
simp only [hom_comp, LinearMap.coe_comp, Function.comp_apply, hom_id, LinearMap.id_coe, id_eq]
rw [localizationToStalk_mk, stalkToFiberLinearMap_germ]
simp)
instance (x : PrimeSpectrum.Top R) :
IsLocalizedModule x.asIdeal.primeCompl (toStalk M x).hom := by
convert IsLocalizedModule.of_linearEquiv
(hf := localizedModuleIsLocalizedModule (M := M) x.asIdeal.primeCompl)
(e := (stalkIso M x).symm.toLinearEquiv)
ext
simp only [of_coe,
show (stalkIso M x).symm.toLinearEquiv.toLinearMap = (stalkIso M x).inv.hom by rfl]
erw [LocalizedModule.lift_comp]
end Tilde
end ModuleCat |
.lake/packages/mathlib/Mathlib/AlgebraicGeometry/Cover/Sigma.lean | import Mathlib.AlgebraicGeometry.Morphisms.Basic
/-!
# Collapsing covers
We define the endofunctor on `Scheme.Cover P` that collapses a cover to a single object cover.
-/
universe v u
open CategoryTheory Limits
namespace AlgebraicGeometry.Scheme.Cover
variable {P : MorphismProperty Scheme.{u}} {S : Scheme.{u}} [IsZariskiLocalAtSource P]
[UnivLE.{v, u}] [P.IsStableUnderBaseChange] [IsJointlySurjectivePreserving P]
/-- If `𝒰` is a cover of `S`, this is the single object cover where the covering
object is the disjoint union. -/
@[simps]
noncomputable def sigma (𝒰 : Cover.{v} (precoverage P) S) : S.Cover (precoverage P) where
I₀ := PUnit.{v + 1}
X _ := ∐ 𝒰.X
f _ := Sigma.desc 𝒰.f
mem₀ := by
rw [presieve₀_mem_precoverage_iff]
refine ⟨fun s ↦ ?_, fun _ ↦ IsZariskiLocalAtSource.sigmaDesc 𝒰.map_prop⟩
obtain ⟨i, y, rfl⟩ := 𝒰.exists_eq s
refine ⟨default, Sigma.ι 𝒰.X i y, by simp [← Scheme.Hom.comp_apply]⟩
variable [P.IsMultiplicative] {𝒰 𝒱 : Scheme.Cover.{v} (precoverage P) S}
variable (𝒰) in
instance : Unique 𝒰.sigma.I₀ := inferInstanceAs <| Unique PUnit.{v + 1}
/-- `𝒰` refines the single object cover defined by `𝒰`. -/
@[simps]
noncomputable def toSigma (𝒰 : Cover.{v} (precoverage P) S) : 𝒰 ⟶ 𝒰.sigma where
idx _ := default
app i := Sigma.ι _ i
app_prop _ := IsZariskiLocalAtSource.of_isOpenImmersion _
/-- A refinement of coverings induces a refinement on the single object coverings. -/
@[simps]
noncomputable def Hom.sigma (f : 𝒰 ⟶ 𝒱) : 𝒰.sigma ⟶ 𝒱.sigma where
idx _ := default
app _ := Sigma.desc fun j ↦ f.app j ≫ Sigma.ι _ (f.idx j)
w _ := Sigma.hom_ext _ _ (by simp)
app_prop _ := by
simp only [sigma_X, sigma_I₀, PUnit.default_eq_unit,
IsZariskiLocalAtSource.iff_of_openCover (Scheme.IsLocallyDirected.openCover _),
Discrete.functor_obj_eq_as, IsLocallyDirected.openCover_I₀, IsLocallyDirected.openCover_X,
IsLocallyDirected.openCover_f, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app]
intro i
exact P.comp_mem _ _ (f.app_prop i.1) (IsZariskiLocalAtSource.of_isOpenImmersion _)
/-- Collapsing a cover to a single object cover is functorial. -/
@[simps]
noncomputable def sigmaFunctor : S.Cover (precoverage P) ⥤ S.Cover (precoverage P) where
obj 𝒰 := 𝒰.sigma
map f := f.sigma
map_id 𝒰 := Scheme.Cover.Hom.ext rfl <| by
simp only [sigma_I₀, sigma_X, Hom.sigma_idx, PUnit.default_eq_unit, id_idx_apply, heq_eq_eq]
ext j : 1
exact Sigma.hom_ext _ _ (by simp)
map_comp f g := Scheme.Cover.Hom.ext rfl <| by
simp only [sigma_I₀, sigma_X, Hom.sigma_idx, PUnit.default_eq_unit, comp_idx_apply, heq_eq_eq]
ext j : 1
exact Sigma.hom_ext _ _ (by simp)
end AlgebraicGeometry.Scheme.Cover |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.