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]
  

Proof state:
case mk.intro.intro.intro.intro.intro.mk.intro
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
f : R →+* S
U : Opens ↑(PrimeSpectrum.Top R)
V : Opens ↑(PrimeSpectrum.Top S)
hUV : V.carrier ⊆ ⇑(PrimeSpectrum.comap f) ⁻¹' U.carrier
s : (x : ↥U) → Localizations R ↑x
hs : PrelocalPredicate.pred (isLocallyFraction R).toPrelocalPredicate s
p : ↑(PrimeSpectrum.Top S)
hpV : p ∈ V
W : Opens ↑(PrimeSpectrum.Top R)
m : ↑{ val := (PrimeSpectrum.comap f) p, property := (_ : p ∈ ⇑(PrimeSpectrum.comap f) ⁻¹' U.carrier) } ∈ W
iWU : W ⟶ U
a b : R
q : ↑(PrimeSpectrum.Top S)
hqW : q ∈ ↑((Opens.comap (PrimeSpectrum.comap f)) W)
hqV : q ∈ ↑V
h_frac :
  b ∉ (↑{ val := (PrimeSpectrum.comap f) q, property := hqW }).asIdeal ∧
    (fun x => s ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
          { val := (PrimeSpectrum.comap f) q, property := hqW } *
        (algebraMap R (Localizations R ↑{ val := (PrimeSpectrum.comap f) q, property := hqW })) b =
      (algebraMap R (Localizations R ↑{ val := (PrimeSpectrum.comap f) q, property := hqW })) a
⊢ (Localization.localRingHom ((PrimeSpectrum.comap f) q).asIdeal q.asIdeal f
          (_ :
            ((PrimeSpectrum.comap f)
                  ↑{ val := q,
                      property :=
                        (_ :
                          ↑{ val := q, property := (_ : q ∈ ↑((Opens.comap (PrimeSpectrum.comap f)) W) ∧ q ∈ ↑V) } ∈
                            ↑V) }).asIdeal =
              ((PrimeSpectrum.comap f)
                  ↑{ val := q,
                      property :=
                        (_ :
                          ↑{ val := q, property := (_ : q ∈ ↑((Opens.comap (PrimeSpectrum.comap f)) W) ∧ q ∈ ↑V) } ∈
                            ↑V) }).asIdeal))
        (s
          { val := (PrimeSpectrum.comap f) q,
            property :=
              (_ :
                ↑{ val := q,
                      property :=
                        (_ :
                          ↑{ val := q, property := (_ : q ∈ ↑((Opens.comap (PrimeSpectrum.comap f)) W) ∧ q ∈ ↑V) } ∈
                            ↑V) } ∈
                  ⇑(PrimeSpectrum.comap f) ⁻¹' U.carrier) }) *
      (algebraMap S (Localizations S q)) (f b) =
    (algebraMap S (Localizations S q)) (f a)

Next tactic:
erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,
    h_frac.2, Localization.localRingHom_to_map]