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
    -- Porting note : originally the first variable does not need to be explicit
    (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf S).val) _ 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 (algebraMap R S) _* (structureSheaf S).1).germ_res_apply (homOfLE hrU)
          ⟨p, hpr⟩ _).trans e
  set s' := (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).map (homOfLE hrU).op s with h
  replace e : ((Spec.topMap (algebraMap R S) _* (structureSheaf S).val).germ ⟨p, hpr⟩) s' = y
  · 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,
    comp_apply, comp_apply]
  iterate 2
    erw [← (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).germ_res_apply (homOfLE le_top)
      ⟨p, hpr⟩]
  rw [← e]
  -- Porting note : without this `change`, Lean doesn't know how to rewrite `map_mul`
  let f := TopCat.Presheaf.germ (Spec.topMap (algebraMap R S) _* (structureSheaf S).val) ⟨p, hpr⟩
  change f _ * f _ = f _
  rw [← map_mul, mul_comm]
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.mk.mk.intro
R S : CommRingCat
f✝ : R ⟶ S
p : PrimeSpectrum ↑R
inst✝ : Algebra ↑R ↑S
y : ↑(TopCat.Presheaf.stalk (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val) p)
r : ↑R
hpr : p ∈ PrimeSpectrum.basicOpen r
s' :
  (forget CommRingCat).obj
    ((Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val).obj (op (PrimeSpectrum.basicOpen r)))
e :
  (TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val) { val := p, property := hpr }) s' =
    y
s : ↑S
n : ℕ
hsn :
  s' *
      (algebraMap ↑S ↑((structureSheaf ↑S).val.obj (op (PrimeSpectrum.basicOpen ((algebraMap ↑R ↑S) r)))))
        ↑(s,
              { 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) }).2 =
    (algebraMap ↑S ↑((structureSheaf ↑S).val.obj (op (PrimeSpectrum.basicOpen ((algebraMap ↑R ↑S) r)))))
      (s,
          { 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) }).1
f : (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val).obj (op (PrimeSpectrum.basicOpen r)) ⟶
  TopCat.Presheaf.stalk (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val) ↑{ val := p, property := hpr } :=
  TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val) { val := p, property := hpr }
⊢ f
      (s' *
        ((Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val).map
            (homOfLE (_ : PrimeSpectrum.basicOpen r ≤ ⊤)).op)
          ((toOpen ↑S ⊤) ((algebraMap ↑R ↑S) ↑(s, { val := r, property := hpr } ^ n).2))) =
    f
      (((Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val).map
          (homOfLE (_ : PrimeSpectrum.basicOpen r ≤ ⊤)).op)
        ((toOpen ↑S ⊤) (s, { val := r, property := hpr } ^ n).1))

Next tactic:
dsimp only [Subtype.coe_mk] at hsn