-- Lean 4 proof step from Mathlib.Geometry.RingedSpace.OpenImmersion (goal)
Goal:
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' :
  Subset (α := Set (↑(↑Z.toPresheafedSpace : TopCat) : Type u_1))
    (Set.range (ι := (↑(↑Y.toPresheafedSpace : TopCat) : Type u_1))
      (⇑(ConcreteCategory.hom (FC := fun (X Y : TopCat.{u_1}) ↦ C((↑X : Type u_1), (↑Y : Type u_1))) (CC :=
            TopCat.carrier) g.base) :
        (a : (↑(↑Y.toPresheafedSpace : TopCat) : Type u_1)) → (↑(↑Z.toPresheafedSpace : TopCat) : Type u_1)))
    (Set.range (ι := (↑(↑X.toPresheafedSpace : TopCat) : Type u_1))
      (⇑(ConcreteCategory.hom (FC := fun (X Y : TopCat.{u_1}) ↦ C((↑X : Type u_1), (↑Y : Type u_1))) (CC :=
            TopCat.carrier) f.base) :
        (a : (↑(↑X.toPresheafedSpace : TopCat) : Type u_1)) → (↑(↑Z.toPresheafedSpace : TopCat) : Type u_1)))
this_1 : IsIso (X := pullback f g) (pullback.snd f g)
this :
  Eq (α := (↑(pullback f g).toPresheafedSpace : TopCat) ⟶ (↑X.toPresheafedSpace : TopCat))
    (CategoryStruct.comp (Y :=
      pullback ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
        ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g))
      (Iso.hom (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g))
      (pullback.fst ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
        ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g)))
    (PresheafedSpace.Hom.base (Hom.toHom (pullback.fst f g)))
⊢ Function.Surjective (α := (↑(↑Y.toPresheafedSpace : TopCat) : Type u_1)) (β :=
    (↑(pullback ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g)) :
      Type u_1))
    (⇑(ConcreteCategory.hom (FC := fun (X Y : TopCat.{u_1}) ↦ C((↑X : Type u_1), (↑Y : Type u_1))) (CC :=
          TopCat.carrier) (Y :=
          pullback ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
            ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g))
          (CategoryStruct.comp (Y := (↑(pullback f g).toPresheafedSpace : TopCat))
            (PresheafedSpace.Hom.base (Hom.toHom (inv (pullback.snd f g))))
            (Iso.hom (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g)))) :
      (a : (↑(↑Y.toPresheafedSpace : TopCat) : Type u_1)) →
        (↑(pullback ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
              ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g)) :
          Type u_1))
have rw : Epi (Y :=
  pullback ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f)
    ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g))
  (CategoryStruct.comp (Y := (↑(pullback f g).toPresheafedSpace : TopCat))
    (inv ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map (pullback.snd f g)))
    (Iso.hom (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g)))
Tactic: rw [← TopCat.epi_iff_surjective, show (inv (pullback.snd f g)).base = _ from
        (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _).map_inv _]