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 (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 (algebraMap R S) p).map_zero,
      toPushforwardStalk] at hx
    -- Porting note : this `change` is manually rewriting `comp_apply`
    change _ = (TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val)
      (⟨p, trivial⟩ : (⊤ : TopologicalSpace.Opens (PrimeSpectrum R))) (toOpen S ⊤ 0)) at hx
    rw [map_zero] at hx
    change (forget CommRingCat).map _ _ = (forget _).map _ _ at hx
    obtain ⟨U, hpU, i₁, i₂, e⟩ := TopCat.Presheaf.germ_eq _ _ _ _ _ _ hx
    obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ :=
      PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open (show p ∈ U.1 from hpU)
        U.2
    change PrimeSpectrum.basicOpen r ≤ U at hrU
    apply_fun (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).map (homOfLE hrU).op at e
    simp only [TopCat.Presheaf.pushforwardObj_map, Functor.op_map, map_zero, ← comp_apply,
      toOpen_res] 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]
    -- Porting note : manually rewrite `Submonoid.coe_pow`
    change (algebraMap R S) (r ^ n) * x = 0
    

Proof state:
case h₃.intro.intro.intro.intro.intro.intro.intro.intro.intro.mk.intro
R S : CommRingCat
f : R ⟶ S
p : PrimeSpectrum ↑R
inst✝ : Algebra ↑R ↑S
x : ↑S
hx :
  (forget CommRingCat).map
      (TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val)
        { val := p, property := trivial })
      ((toOpen ↑S ⊤) x) =
    (forget CommRingCat).map
      (TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val)
        { val := p, property := trivial })
      0
U : TopologicalSpace.Opens ↑(Spec.topObj R)
hpU : p ∈ U
i₁ : U ⟶ ⊤
i₂ : U ⟶ ⊤
r : ↑R
hpr : p ∈ (fun r => ↑(PrimeSpectrum.basicOpen r)) r
hrU : PrimeSpectrum.basicOpen r ≤ U
e✝ :
  ((structureSheaf ↑S).val.map
        ((TopologicalSpace.Opens.map (Spec.topMap (algebraMap ↑R ↑S))).map (homOfLE hrU).op.unop).op)
      (((structureSheaf ↑S).val.map ((TopologicalSpace.Opens.map (Spec.topMap (algebraMap ↑R ↑S))).map i₁.op.unop).op)
        ((toOpen ↑S ⊤) x)) =
    ((structureSheaf ↑S).val.map
        ((TopologicalSpace.Opens.map (Spec.topMap (algebraMap ↑R ↑S))).map (homOfLE hrU).op.unop).op)
      (((structureSheaf ↑S).val.map ((TopologicalSpace.Opens.map (Spec.topMap (algebraMap ↑R ↑S))).map i₂.op.unop).op)
        0)
this✝ : (toOpen (↑S) (PrimeSpectrum.basicOpen ((algebraMap ↑R ↑S) r))) x = 0
this : IsLocalization.mk' (↑((structureSheaf ↑S).val.obj (op (PrimeSpectrum.basicOpen ((algebraMap ↑R ↑S) r))))) x 1 = 0
n : ℕ
e :
  ↑{ val := (fun x => (algebraMap ↑R ↑S) r ^ x) n,
          property := (_ : ∃ y, (fun x => (algebraMap ↑R ↑S) r ^ x) y = (fun x => (algebraMap ↑R ↑S) r ^ x) n) } *
      x =
    0
⊢ (algebraMap ↑R ↑S) (r ^ n) * x = 0

Next tactic:
rw [map_pow]