l3lab/ntp-mathlib huggingface dataset:
/-- 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} (f : R ⟶ S) (p : PrimeSpectrum S) :
    (stalkIso R (PrimeSpectrum.comap f p)).hom ≫
        @CategoryStruct.comp _ _
          (CommRingCat.of (Localization.AtPrime (PrimeSpectrum.comap f p).asIdeal))
          (CommRingCat.of (Localization.AtPrime p.asIdeal)) _
          (Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f rfl)
          (stalkIso S p).inv =
      PresheafedSpace.stalkMap (Spec.sheafedSpaceMap f) p :=
  (stalkIso R (PrimeSpectrum.comap f p)).eq_inv_comp.mp <|
    (stalkIso S p).comp_inv_eq.mpr <|
      Localization.localRingHom_unique _ _ _ _ fun x => by
        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
        rw [stalkIso_hom, stalkIso_inv]; erw [comp_apply, comp_apply]; rw [localizationToStalk_of]
        

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑S
x : ↑R
⊢ (stalkToFiberRingHom (↑S) p)
      ((PresheafedSpace.stalkMap (Spec.sheafedSpaceMap f) p) ((toStalk (↑R) ((PrimeSpectrum.comap f) p)) x)) =
    (algebraMap (↑S) (Localization.AtPrime p.asIdeal)) (f x)

Next tactic:
erw [stalkMap_toStalk_apply f p x, stalkToFiberRingHom_toStalk]
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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.
      

Proof state:
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha : IsUnit ((PresheafedSpace.stalkMap (sheafedSpaceMap f) p) a)
⊢ IsUnit a

Next tactic:
erw [← localRingHom_comp_stalkIso_apply] at ha
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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] at ha
      

Proof state:
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha :
  IsUnit
    ((localizationToStalk (↑S) p)
      ((Localization.localRingHom ((PrimeSpectrum.comap f) p).asIdeal p.asIdeal f
          (_ : ((PrimeSpectrum.comap f) p).asIdeal = ((PrimeSpectrum.comap f) p).asIdeal))
        ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a)))
⊢ IsUnit a

Next tactic:
replace ha := (stalkIso S p).hom.isUnit_map ha
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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] at ha
      replace ha := (stalkIso S p).hom.isUnit_map ha
      

Proof state:
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha :
  IsUnit
    ((stalkIso (↑S) p).hom
      ((localizationToStalk (↑S) p)
        ((Localization.localRingHom ((PrimeSpectrum.comap f) p).asIdeal p.asIdeal f
            (_ : ((PrimeSpectrum.comap f) p).asIdeal = ((PrimeSpectrum.comap f) p).asIdeal))
          ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a))))
⊢ IsUnit a

Next tactic:
rw [← comp_apply, show localizationToStalk S p = (stalkIso S p).inv from rfl,
        Iso.inv_hom_id, id_apply] at ha
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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] at ha
      replace ha := (stalkIso S p).hom.isUnit_map ha
      rw [← comp_apply, show localizationToStalk S p = (stalkIso S p).inv from rfl,
        Iso.inv_hom_id, id_apply] at ha
      -- Porting note : `f` had to be made explicit
      

Proof state:
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha :
  IsUnit
    ((Localization.localRingHom ((PrimeSpectrum.comap f) p).asIdeal p.asIdeal f
        (_ : ((PrimeSpectrum.comap f) p).asIdeal = ((PrimeSpectrum.comap f) p).asIdeal))
      ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a))
⊢ IsUnit a

Next tactic:
replace ha := IsLocalRingHom.map_nonunit
        (f := (Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f _)) _ ha
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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] at ha
      replace ha := (stalkIso S p).hom.isUnit_map ha
      rw [← comp_apply, show localizationToStalk S p = (stalkIso S p).inv from rfl,
        Iso.inv_hom_id, id_apply] at ha
      -- Porting note : `f` had to be made explicit
      replace ha := IsLocalRingHom.map_nonunit
        (f := (Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f _)) _ ha
      

Proof state:
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha : IsUnit ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a)
⊢ IsUnit a

Next tactic:
convert RingHom.isUnit_map (stalkIso R (PrimeSpectrum.comap f p)).inv ha
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat} (f : R ⟶ S) :
    Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
  LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
    IsLocalRingHom.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] at ha
      replace ha := (stalkIso S p).hom.isUnit_map ha
      rw [← comp_apply, show localizationToStalk S p = (stalkIso S p).inv from rfl,
        Iso.inv_hom_id, id_apply] at ha
      -- Porting note : `f` had to be made explicit
      replace ha := IsLocalRingHom.map_nonunit
        (f := (Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f _)) _ ha
      convert RingHom.isUnit_map (stalkIso R (PrimeSpectrum.comap f p)).inv ha
      

Proof state:
case h.e'_3.h
R S : CommRingCat
f : R ⟶ S
p : ↑↑(locallyRingedSpaceObj S).toSheafedSpace.toPresheafedSpace
a : ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p))
ha : IsUnit ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a)
e_1✝ :
  ↑(PresheafedSpace.stalk (locallyRingedSpaceObj R).toSheafedSpace.toPresheafedSpace ((sheafedSpaceMap f).base p)) =
    ↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑R)) ((PrimeSpectrum.comap f) p))
⊢ a = (stalkIso (↑R) ((PrimeSpectrum.comap f) p)).inv ((stalkToFiberRingHom (↑R) ((PrimeSpectrum.comap f) p)) a)

Next tactic:
erw [← comp_apply, show stalkToFiberRingHom R _ = (stalkIso _ _).hom from rfl,
        Iso.hom_inv_id, id_apply]
@[simp]
theorem Spec.locallyRingedSpaceMap_id (R : CommRingCat) :
    Spec.locallyRingedSpaceMap (𝟙 R) = 𝟙 (Spec.locallyRingedSpaceObj R) :=
  LocallyRingedSpace.Hom.ext _ _ <| by
    

Proof state:
R : CommRingCat
⊢ (locallyRingedSpaceMap (𝟙 R)).val = (𝟙 (locallyRingedSpaceObj R)).val

Next tactic:
rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_id]
@[simp]
theorem Spec.locallyRingedSpaceMap_id (R : CommRingCat) :
    Spec.locallyRingedSpaceMap (𝟙 R) = 𝟙 (Spec.locallyRingedSpaceObj R) :=
  LocallyRingedSpace.Hom.ext _ _ <| by
    rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_id]; 

Proof state:
R : CommRingCat
⊢ 𝟙 (sheafedSpaceObj R) = (𝟙 (locallyRingedSpaceObj R)).val

Next tactic:
rfl
theorem Spec.locallyRingedSpaceMap_comp {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) :
    Spec.locallyRingedSpaceMap (f ≫ g) =
      Spec.locallyRingedSpaceMap g ≫ Spec.locallyRingedSpaceMap f :=
  LocallyRingedSpace.Hom.ext _ _ <| by
    

Proof state:
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
⊢ (locallyRingedSpaceMap (f ≫ g)).val = (locallyRingedSpaceMap g ≫ locallyRingedSpaceMap f).val

Next tactic:
rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_comp]
theorem Spec.locallyRingedSpaceMap_comp {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) :
    Spec.locallyRingedSpaceMap (f ≫ g) =
      Spec.locallyRingedSpaceMap g ≫ Spec.locallyRingedSpaceMap f :=
  LocallyRingedSpace.Hom.ext _ _ <| by
    rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_comp]; 

Proof state:
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
⊢ sheafedSpaceMap g ≫ sheafedSpaceMap f = (locallyRingedSpaceMap g ≫ locallyRingedSpaceMap f).val

Next tactic:
rfl
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCatᵒᵖ ⥤ LocallyRingedSpace where
  obj R := Spec.locallyRingedSpaceObj (unop R)
  map f := Spec.locallyRingedSpaceMap f.unop
  map_id R := by 

Proof state:
R : CommRingCatᵒᵖ
⊢ { obj := fun R => locallyRingedSpaceObj R.unop, map := fun {X Y} f => locallyRingedSpaceMap f.unop }.map (𝟙 R) =
    𝟙 ({ obj := fun R => locallyRingedSpaceObj R.unop, map := fun {X Y} f => locallyRingedSpaceMap f.unop }.obj R)

Next tactic:
dsimp
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCatᵒᵖ ⥤ LocallyRingedSpace where
  obj R := Spec.locallyRingedSpaceObj (unop R)
  map f := Spec.locallyRingedSpaceMap f.unop
  map_id R := by dsimp; 

Proof state:
R : CommRingCatᵒᵖ
⊢ locallyRingedSpaceMap (𝟙 R.unop) = 𝟙 (locallyRingedSpaceObj R.unop)

Next tactic:
rw [Spec.locallyRingedSpaceMap_id]
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCatᵒᵖ ⥤ 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 

Proof state:
X✝ Y✝ Z✝ : CommRingCatᵒᵖ
f : X✝ ⟶ Y✝
g : Y✝ ⟶ Z✝
⊢ { obj := fun R => locallyRingedSpaceObj R.unop, map := fun {X Y} f => locallyRingedSpaceMap f.unop }.map (f ≫ g) =
    { obj := fun R => locallyRingedSpaceObj R.unop, map := fun {X Y} f => locallyRingedSpaceMap f.unop }.map f ≫
      { obj := fun R => locallyRingedSpaceObj R.unop, map := fun {X Y} f => locallyRingedSpaceMap f.unop }.map g

Next tactic:
dsimp
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCatᵒᵖ ⥤ 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; 

Proof state:
X✝ Y✝ Z✝ : CommRingCatᵒᵖ
f : X✝ ⟶ Y✝
g : Y✝ ⟶ Z✝
⊢ locallyRingedSpaceMap (g.unop ≫ f.unop) = locallyRingedSpaceMap f.unop ≫ locallyRingedSpaceMap g.unop

Next tactic:
rw [Spec.locallyRingedSpaceMap_comp]
instance isIso_toSpecΓ (R : CommRingCat) : IsIso (toSpecΓ R) := by
  

Proof state:
R : CommRingCat
⊢ IsIso (toSpecΓ R)

Next tactic:
cases R
instance isIso_toSpecΓ (R : CommRingCat) : IsIso (toSpecΓ R) := by
  cases R; 

Proof state:
case mk
α✝ : Type ?u.189447
str✝ : CommRing α✝
⊢ IsIso (toSpecΓ (Bundled.mk α✝))

Next tactic:
apply StructureSheaf.isIso_to_global
@[reassoc]
theorem Spec_Γ_naturality {R S : CommRingCat} (f : R ⟶ S) :
    f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op := by
  -- Porting note : `ext` failed to pick up one of the three lemmas
  

Proof state:
R S : CommRingCat
f : R ⟶ S
⊢ f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op

Next tactic:
refine RingHom.ext fun x => Subtype.ext <| funext fun x' => ?_
@[reassoc]
theorem Spec_Γ_naturality {R S : CommRingCat} (f : R ⟶ S) :
    f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op := by
  -- Porting note : `ext` failed to pick up one of the three lemmas
  refine RingHom.ext fun x => Subtype.ext <| funext fun x' => ?_; 

Proof state:
R S : CommRingCat
f : R ⟶ S
x : ↑R
x' : ↥(op ⊤).unop
⊢ ↑((f ≫ toSpecΓ S) x) x' = ↑((toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op) x) x'

Next tactic:
symm
@[reassoc]
theorem Spec_Γ_naturality {R S : CommRingCat} (f : R ⟶ S) :
    f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op := by
  -- Porting note : `ext` failed to pick up one of the three lemmas
  refine RingHom.ext fun x => Subtype.ext <| funext fun x' => ?_; symm;
  

Proof state:
R S : CommRingCat
f : R ⟶ S
x : ↑R
x' : ↥(op ⊤).unop
⊢ ↑((toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op) x) x' = ↑((f ≫ toSpecΓ S) x) x'

Next tactic:
apply Localization.localRingHom_to_map
/-- The counit (`SpecΓIdentity.inv.op`) of the adjunction `Γ ⊣ Spec` is an isomorphism. -/
@[simps! hom_app inv_app]
def SpecΓIdentity : Spec.toLocallyRingedSpace.rightOp ⋙ Γ ≅ 𝟭 _ :=
  Iso.symm <| NatIso.ofComponents (fun R =>
    -- Porting note : In Lean3, this `IsIso` is synthesized automatically
    letI : IsIso (toSpecΓ R) := StructureSheaf.isIso_to_global _
    asIso (toSpecΓ R)) fun {X Y} f => by 

Proof state:
X Y : CommRingCat
f : X ⟶ Y
⊢ (𝟭 CommRingCat).map f ≫ ((fun R => asIso (toSpecΓ R)) Y).hom =
    ((fun R => asIso (toSpecΓ R)) X).hom ≫ (Spec.toLocallyRingedSpace.rightOp ⋙ Γ).map f

Next tactic:
convert Spec_Γ_naturality (R := X) (S := Y) f
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat) (M : Submonoid R)
    (x : PrimeSpectrum (Localization M)) :
    IsIso
      (PresheafedSpace.stalkMap
        (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap R (Localization M))).op) x) := by
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
x : PrimeSpectrum (Localization M)
⊢ IsIso
    (PresheafedSpace.stalkMap (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op) x)

Next tactic:
erw [← localRingHom_comp_stalkIso]
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat) (M : Submonoid R)
    (x : PrimeSpectrum (Localization M)) :
    IsIso
      (PresheafedSpace.stalkMap
        (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap R (Localization M))).op) x) := by
  erw [← localRingHom_comp_stalkIso]
  -- Porting note: replaced `apply (config := { instances := false })`.
  -- See https://github.com/leanprover/lean4/issues/2273
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
x : PrimeSpectrum (Localization M)
⊢ IsIso
    ((stalkIso (↑(op (CommRingCat.of ↑R)).unop)
          ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x)).hom ≫
      Localization.localRingHom
          ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal x.asIdeal
          (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop
          (_ :
            ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal =
              ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal) ≫
        (stalkIso (↑(op (CommRingCat.of (Localization M))).unop) x).inv)

Next tactic:
refine @IsIso.comp_isIso _ _ _ _ _ _ _ _ (?_)
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat) (M : Submonoid R)
    (x : PrimeSpectrum (Localization M)) :
    IsIso
      (PresheafedSpace.stalkMap
        (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap R (Localization M))).op) x) := by
  erw [← localRingHom_comp_stalkIso]
  -- Porting note: replaced `apply (config := { instances := false })`.
  -- See https://github.com/leanprover/lean4/issues/2273
  refine @IsIso.comp_isIso _ _ _ _ _ _ _ _ (?_)
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
x : PrimeSpectrum (Localization M)
⊢ IsIso
    (Localization.localRingHom
        ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal x.asIdeal
        (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop
        (_ :
          ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal =
            ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal) ≫
      (stalkIso (↑(op (CommRingCat.of (Localization M))).unop) x).inv)

Next tactic:
refine @IsIso.comp_isIso _ _ _ _ _ _ _ (?_) _
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat) (M : Submonoid R)
    (x : PrimeSpectrum (Localization M)) :
    IsIso
      (PresheafedSpace.stalkMap
        (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap R (Localization M))).op) x) := by
  erw [← localRingHom_comp_stalkIso]
  -- Porting note: replaced `apply (config := { instances := false })`.
  -- See https://github.com/leanprover/lean4/issues/2273
  refine @IsIso.comp_isIso _ _ _ _ _ _ _ _ (?_)
  refine @IsIso.comp_isIso _ _ _ _ _ _ _ (?_) _
  /- I do not know why this is defeq to the goal, but I'm happy to accept that it is. -/
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
x : PrimeSpectrum (Localization M)
⊢ IsIso
    (Localization.localRingHom
      ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal x.asIdeal
      (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop
      (_ :
        ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal =
          ((PrimeSpectrum.comap (CommRingCat.ofHom (algebraMap (↑R) (Localization M))).op.unop) x).asIdeal))

Next tactic:
show
    IsIso (IsLocalization.localizationLocalizationAtPrimeIsoLocalization M
      x.asIdeal).toRingEquiv.toCommRingCatIso.hom
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat) (M : Submonoid R)
    (x : PrimeSpectrum (Localization M)) :
    IsIso
      (PresheafedSpace.stalkMap
        (Spec.toPresheafedSpace.map (CommRingCat.ofHom (algebraMap R (Localization M))).op) x) := by
  erw [← localRingHom_comp_stalkIso]
  -- Porting note: replaced `apply (config := { instances := false })`.
  -- See https://github.com/leanprover/lean4/issues/2273
  refine @IsIso.comp_isIso _ _ _ _ _ _ _ _ (?_)
  refine @IsIso.comp_isIso _ _ _ _ _ _ _ (?_) _
  /- I do not know why this is defeq to the goal, but I'm happy to accept that it is. -/
  show
    IsIso (IsLocalization.localizationLocalizationAtPrimeIsoLocalization M
      x.asIdeal).toRingEquiv.toCommRingCatIso.hom
  

Proof state:
R : CommRingCat
M : Submonoid ↑R
x : PrimeSpectrum (Localization M)
⊢ IsIso
    (RingEquiv.toCommRingCatIso
        (AlgEquiv.toRingEquiv (IsLocalization.localizationLocalizationAtPrimeIsoLocalization M x.asIdeal))).hom

Next tactic:
infer_instance
@[reassoc]
theorem toPushforwardStalk_comp :
    f ≫ StructureSheaf.toPushforwardStalk f p =
      StructureSheaf.toStalk R p ≫
        (TopCat.Presheaf.stalkFunctor _ _).map (Spec.sheafedSpaceMap f).c := by
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑R
⊢ f ≫ toPushforwardStalk f p =
    toStalk (↑R) p ≫ (TopCat.Presheaf.stalkFunctor CommRingCat p).map (Spec.sheafedSpaceMap f).c

Next tactic:
rw [StructureSheaf.toStalk]
@[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]
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑R
⊢ f ≫ toPushforwardStalk f p =
    (toOpen ↑R ⊤ ≫
        TopCat.Presheaf.germ (TopCat.Sheaf.presheaf (structureSheaf ↑R)) { val := p, property := True.intro }) ≫
      (TopCat.Presheaf.stalkFunctor CommRingCat p).map (Spec.sheafedSpaceMap f).c

Next tactic:
erw [Category.assoc]
@[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]
  erw [Category.assoc]
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑R
⊢ f ≫ toPushforwardStalk f p =
    toOpen ↑R ⊤ ≫
      TopCat.Presheaf.germ (TopCat.Sheaf.presheaf (structureSheaf ↑R)) { val := p, property := True.intro } ≫
        (TopCat.Presheaf.stalkFunctor CommRingCat p).map (Spec.sheafedSpaceMap f).c

Next tactic:
rw [TopCat.Presheaf.stalkFunctor_map_germ]
@[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]
  erw [Category.assoc]
  rw [TopCat.Presheaf.stalkFunctor_map_germ]
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑R
⊢ f ≫ toPushforwardStalk f p =
    toOpen ↑R ⊤ ≫
      (Spec.sheafedSpaceMap f).c.app (op ⊤) ≫
        TopCat.Presheaf.germ ((Spec.sheafedSpaceMap f).base _* (Spec.sheafedSpaceObj S).toPresheafedSpace.presheaf)
          { val := p, property := True.intro }

Next tactic:
exact Spec_Γ_naturality_assoc f _