l3lab/ntp-mathlib huggingface dataset:
theorem Spec.sheafedSpaceMap_comp {R S T : CommRingCat} (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, whiskerRight_app, eqToHom_refl]
    erw [(sheafedSpaceObj T).presheaf.map_id, Category.comp_id, comap_comp]
    

Proof state:
case w.w
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
U✝ : TopologicalSpace.Opens ↑↑(sheafedSpaceObj R).toPresheafedSpace
x✝ : (forget CommRingCat).obj ((sheafedSpaceObj R).toPresheafedSpace.presheaf.obj (op U✝))
⊢ (RingHom.comp (comap g ?w.w.V ((TopologicalSpace.Opens.map (topMap (f ≫ g))).obj (op U✝).unop) ?w.w.hVW)
        (comap f (op U✝).unop ?w.w.V ?w.w.hUV))
      x✝ =
    ((sheafedSpaceMap g ≫ sheafedSpaceMap f).c.app (op U✝)) x✝
case w.w.V
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
U✝ : TopologicalSpace.Opens ↑↑(sheafedSpaceObj R).toPresheafedSpace
x✝ : (forget CommRingCat).obj ((sheafedSpaceObj R).toPresheafedSpace.presheaf.obj (op U✝))
⊢ TopologicalSpace.Opens ↑(PrimeSpectrum.Top ↑S)
case w.w.hUV
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
U✝ : TopologicalSpace.Opens ↑↑(sheafedSpaceObj R).toPresheafedSpace
x✝ : (forget CommRingCat).obj ((sheafedSpaceObj R).toPresheafedSpace.presheaf.obj (op U✝))
⊢ ∀ p ∈ ?w.w.V, (PrimeSpectrum.comap f) p ∈ (op U✝).unop
case w.w.hVW
R S T : CommRingCat
f : R ⟶ S
g : S ⟶ T
U✝ : TopologicalSpace.Opens ↑↑(sheafedSpaceObj R).toPresheafedSpace
x✝ : (forget CommRingCat).obj ((sheafedSpaceObj R).toPresheafedSpace.presheaf.obj (op U✝))
⊢ ∀ p ∈ (TopologicalSpace.Opens.map (topMap (f ≫ g))).obj (op U✝).unop, (PrimeSpectrum.comap g) p ∈ ?w.w.V

Next tactic:
rfl
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCatᵒᵖ ⥤ SheafedSpace CommRingCat where
  obj R := Spec.sheafedSpaceObj (unop R)
  map f := Spec.sheafedSpaceMap f.unop
  map_id R := by 

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

Next tactic:
dsimp
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCatᵒᵖ ⥤ SheafedSpace CommRingCat where
  obj R := Spec.sheafedSpaceObj (unop R)
  map f := Spec.sheafedSpaceMap f.unop
  map_id R := by dsimp; 

Proof state:
R : CommRingCatᵒᵖ
⊢ sheafedSpaceMap (𝟙 R.unop) = 𝟙 (sheafedSpaceObj R.unop)

Next tactic:
rw [Spec.sheafedSpaceMap_id]
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCatᵒᵖ ⥤ SheafedSpace CommRingCat where
  obj R := Spec.sheafedSpaceObj (unop R)
  map f := Spec.sheafedSpaceMap f.unop
  map_id R := by dsimp; rw [Spec.sheafedSpaceMap_id]
  map_comp f g := by 

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

Next tactic:
dsimp
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCatᵒᵖ ⥤ SheafedSpace CommRingCat where
  obj R := Spec.sheafedSpaceObj (unop R)
  map f := Spec.sheafedSpaceMap f.unop
  map_id R := by dsimp; rw [Spec.sheafedSpaceMap_id]
  map_comp f g := by dsimp; 

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

Next tactic:
rw [Spec.sheafedSpaceMap_comp]
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 

Proof state:
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
r : ↑R
U : TopologicalSpace.Opens (PrimeSpectrum ↑R) := PrimeSpectrum.basicOpen r
⊢ (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U)

Next tactic:
rw [w]
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
  

Proof state:
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
⊢ α = β

Next tactic:
ext : 1
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
  · 

Proof state:
case w
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
⊢ α.base = β.base

Next tactic:
exact w
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
  · 

Proof state:
case h
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
⊢ α.c ≫
      whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
        X.presheaf =
    β.c

Next tactic:
apply
      ((TopCat.Sheaf.pushforward _ β.base).obj X.sheaf).hom_ext _ PrimeSpectrum.isBasis_basic_opens
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
    

Proof state:
case h
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
⊢ ∀ (i : ↑R),
    (α.c ≫
            whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
              X.presheaf).app
        (op (PrimeSpectrum.basicOpen i)) =
      β.c.app (op (PrimeSpectrum.basicOpen i))

Next tactic:
intro r
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
    

Proof state:
case h
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
r : ↑R
⊢ (α.c ≫
          whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
            X.presheaf).app
      (op (PrimeSpectrum.basicOpen r)) =
    β.c.app (op (PrimeSpectrum.basicOpen r))

Next tactic:
apply (StructureSheaf.to_basicOpen_epi R r).1
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
    -- Porting note : was a one-liner `simpa using h r`
    

Proof state:
case h.a
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
h :
  ∀ (r : ↑R),
    let U := PrimeSpectrum.basicOpen r;
    (toOpen (↑R) U ≫ α.c.app (op U)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
      toOpen (↑R) U ≫ β.c.app (op U)
r : ↑R
⊢ toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      (α.c ≫
            whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
              X.presheaf).app
        (op (PrimeSpectrum.basicOpen r)) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))

Next tactic:
specialize h r
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
    -- Porting note : was a one-liner `simpa using h r`
    specialize h r
    

Proof state:
case h.a
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
r : ↑R
h :
  let U := PrimeSpectrum.basicOpen r;
  (toOpen (↑R) U ≫ α.c.app (op U)) ≫
      X.presheaf.map
        (eqToHom
          (_ : (TopologicalSpace.Opens.map α.base).op.obj (op U) = (TopologicalSpace.Opens.map β.base).op.obj (op U))) =
    toOpen (↑R) U ≫ β.c.app (op U)
⊢ toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      (α.c ≫
            whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
              X.presheaf).app
        (op (PrimeSpectrum.basicOpen r)) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))

Next tactic:
simp only [sheafedSpaceObj_carrier, Functor.op_obj, unop_op, TopCat.Presheaf.pushforwardObj_obj,
      sheafedSpaceObj_presheaf, Category.assoc] at h
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
    -- Porting note : was a one-liner `simpa using h r`
    specialize h r
    simp only [sheafedSpaceObj_carrier, Functor.op_obj, unop_op, TopCat.Presheaf.pushforwardObj_obj,
      sheafedSpaceObj_presheaf, Category.assoc] at h
    

Proof state:
case h.a
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
r : ↑R
h :
  toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      α.c.app (op (PrimeSpectrum.basicOpen r)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op (PrimeSpectrum.basicOpen r)) =
                (TopologicalSpace.Opens.map β.base).op.obj (op (PrimeSpectrum.basicOpen r)))) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))
⊢ toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      (α.c ≫
            whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
              X.presheaf).app
        (op (PrimeSpectrum.basicOpen r)) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))

Next tactic:
rw [NatTrans.comp_app, ← h]
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
    -- Porting note : was a one-liner `simpa using h r`
    specialize h r
    simp only [sheafedSpaceObj_carrier, Functor.op_obj, unop_op, TopCat.Presheaf.pushforwardObj_obj,
      sheafedSpaceObj_presheaf, Category.assoc] at h
    rw [NatTrans.comp_app, ← h]
    

Proof state:
case h.a
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
r : ↑R
h :
  toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      α.c.app (op (PrimeSpectrum.basicOpen r)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op (PrimeSpectrum.basicOpen r)) =
                (TopologicalSpace.Opens.map β.base).op.obj (op (PrimeSpectrum.basicOpen r)))) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))
⊢ toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      α.c.app (op (PrimeSpectrum.basicOpen r)) ≫
        (whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
              X.presheaf).app
          (op (PrimeSpectrum.basicOpen r)) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      α.c.app (op (PrimeSpectrum.basicOpen r)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op (PrimeSpectrum.basicOpen r)) =
                (TopologicalSpace.Opens.map β.base).op.obj (op (PrimeSpectrum.basicOpen r))))

Next tactic:
congr
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
    -- Porting note : was a one-liner `simpa using h r`
    specialize h r
    simp only [sheafedSpaceObj_carrier, Functor.op_obj, unop_op, TopCat.Presheaf.pushforwardObj_obj,
      sheafedSpaceObj_presheaf, Category.assoc] at h
    rw [NatTrans.comp_app, ← h]
    congr
    

Proof state:
case h.a.e_a.e_a
X : RingedSpace
R : CommRingCat
α β : X ⟶ sheafedSpaceObj R
w : α.base = β.base
r : ↑R
h :
  toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫
      α.c.app (op (PrimeSpectrum.basicOpen r)) ≫
        X.presheaf.map
          (eqToHom
            (_ :
              (TopologicalSpace.Opens.map α.base).op.obj (op (PrimeSpectrum.basicOpen r)) =
                (TopologicalSpace.Opens.map β.base).op.obj (op (PrimeSpectrum.basicOpen r)))) =
    toOpen (↑R) (PrimeSpectrum.basicOpen r) ≫ β.c.app (op (PrimeSpectrum.basicOpen r))
⊢ (whiskerRight (eqToHom (_ : (TopologicalSpace.Opens.map α.base).op = (TopologicalSpace.Opens.map β.base).op))
          X.presheaf).app
      (op (PrimeSpectrum.basicOpen r)) =
    X.presheaf.map
      (eqToHom
        (_ :
          (TopologicalSpace.Opens.map α.base).op.obj (op (PrimeSpectrum.basicOpen r)) =
            (TopologicalSpace.Opens.map β.base).op.obj (op (PrimeSpectrum.basicOpen r))))

Next tactic:
simp
@[elementwise]
theorem stalkMap_toStalk {R S : CommRingCat} (f : R ⟶ S) (p : PrimeSpectrum S) :
    toStalk R (PrimeSpectrum.comap f p) ≫ PresheafedSpace.stalkMap (Spec.sheafedSpaceMap f) p =
      f ≫ toStalk S p := by
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑S
⊢ toStalk (↑R) ((PrimeSpectrum.comap f) p) ≫ PresheafedSpace.stalkMap (Spec.sheafedSpaceMap f) p = f ≫ toStalk (↑S) p

Next tactic:
erw [← toOpen_germ S ⊤ ⟨p, trivial⟩, ← toOpen_germ R ⊤ ⟨PrimeSpectrum.comap f p, trivial⟩,
    Category.assoc, PresheafedSpace.stalkMap_germ (Spec.sheafedSpaceMap f) ⊤ ⟨p, trivial⟩,
    Spec.sheafedSpaceMap_c_app, toOpen_comp_comap_assoc]
@[elementwise]
theorem stalkMap_toStalk {R S : CommRingCat} (f : R ⟶ S) (p : PrimeSpectrum S) :
    toStalk R (PrimeSpectrum.comap f p) ≫ PresheafedSpace.stalkMap (Spec.sheafedSpaceMap f) p =
      f ≫ toStalk S p := by
  erw [← toOpen_germ S ⊤ ⟨p, trivial⟩, ← toOpen_germ R ⊤ ⟨PrimeSpectrum.comap f p, trivial⟩,
    Category.assoc, PresheafedSpace.stalkMap_germ (Spec.sheafedSpaceMap f) ⊤ ⟨p, trivial⟩,
    Spec.sheafedSpaceMap_c_app, toOpen_comp_comap_assoc]
  

Proof state:
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑S
⊢ CommRingCat.ofHom f ≫
      toOpen (↑S) ((TopologicalSpace.Opens.comap (PrimeSpectrum.comap f)) ⊤) ≫
        TopCat.Presheaf.germ (Spec.sheafedSpaceObj S).toPresheafedSpace.presheaf { val := p, property := trivial } =
    f ≫ toOpen ↑S ⊤ ≫ TopCat.Presheaf.germ (TopCat.Sheaf.presheaf (structureSheaf ↑S)) { val := p, property := trivial }

Next tactic:
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} (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
        

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

Next tactic:
rw [stalkIso_hom, stalkIso_inv]
/-- 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]; 

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

Next tactic:
erw [comp_apply, comp_apply]
/-- 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]; 

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

Next tactic:
rw [localizationToStalk_of]