theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    exact X.basicOpen_le f
  · -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
    -- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
    intro S hS U hU hSU f x
    -- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
    obtain ⟨n₁, y₁, hy₁⟩ :=
      hU (hSU.of_subset <| Set.subset_union_left _ _) (X.presheaf.map (homOfLE le_sup_left).op f)
        (X.presheaf.map (homOfLE _).op x)
    -- · rw [X.basicOpen_res]; exact inf_le_right
    -- We know that such `y₂, n₂` exists on `U` since `U` is affine.
    obtain ⟨n₂, y₂, hy₂⟩ :=
      exists_eq_pow_mul_of_isAffineOpen X _ U.2 (X.presheaf.map (homOfLE le_sup_right).op f)
        (X.presheaf.map (homOfLE _).op x)
    delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at hy₂
    -- swap; · rw [X.basicOpen_res]; exact inf_le_right
    -- Since `S ∪ U` is quasi-separated, `S ∩ U` can be covered by finite affine opens.
    obtain ⟨s, hs', hs⟩ :=
      (isCompact_open_iff_eq_finset_affine_union _).mp
        ⟨hSU _ _ (Set.subset_union_left _ _) S.2 hS (Set.subset_union_right _ _) U.1.2
            U.2.isCompact,
          (S ⊓ U.1).2⟩
    haveI := hs'.to_subtype
    cases nonempty_fintype s
    replace hs : S ⊓ U.1 = iSup fun i : s => (i : Opens X.carrier) := by ext1; simpa using hs
    have hs₁ : ∀ i : s, i.1.1 ≤ S := by
      intro i; change (i : Opens X.carrier) ≤ S
      refine' le_trans _ inf_le_left; swap; exact U.1; erw [hs]
      -- Porting note: have to add argument explicitly
      exact @le_iSup (Opens X) s _ (fun (i : s) => (i : Opens X)) i
    have hs₂ : ∀ i : s, i.1.1 ≤ U.1 := by
      intro i; change (i : Opens X.carrier) ≤ U
      refine' le_trans _ inf_le_right; swap; exact S; erw [hs]
      -- Porting note: have to add argument explicitly
      exact @le_iSup (Opens X) s _ (fun (i : s) => (i : Opens X)) i
    -- On each affine open in the intersection, we have `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
    -- for some `n` since `f ^ n₂ * y₁ = f ^ (n₁ + n₂) * x = f ^ n₁ * y₂` on `X_f`.
    have := fun i ↦ exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux
      X i.1 S U (hs₁ i) (hs₂ i) hy₁ hy₂
    choose n hn using this
    -- We can thus choose a big enough `n` such that `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
    -- on `S ∩ U`.
    

Proof state:
case h₂.intro.intro.intro.intro.intro.intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U✝ : Opens ↑↑X.toPresheafedSpace
hU✝ : IsCompact U✝.carrier
S : Opens ↑↑X.toPresheafedSpace
hS : IsCompact S.carrier
U : ↑(Scheme.affineOpens X)
hU :
  IsQuasiSeparated S.carrier →
    ∀ (f : ↑(X.presheaf.obj (op S))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) f ^ n * x
hSU : IsQuasiSeparated (S ⊔ ↑U).carrier
f : ↑(X.presheaf.obj (op (S ⊔ ↑U)))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
n₁ : ℕ
y₁ : ↑(X.presheaf.obj (op S))
hy₁ :
  (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op) y₁ =
    (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op)
          ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ^
        n₁ *
      (X.presheaf.map (homOfLE (_ : X.basicOpen (f |_ₕ homOfLE (_ : S ≤ S ⊔ ↑U)) ≤ X.basicOpen f)).op) x
n₂ : ℕ
y₂ : ↑(X.presheaf.obj (op ↑U))
hy₂ :
  (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f) ≤ ↑U)).op) y₂ =
    (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f) ≤ ↑U)).op)
          ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f) ^
        n₂ *
      (X.presheaf.map (homOfLE (_ : X.basicOpen (f |_ₕ homOfLE (_ : ↑U ≤ S ⊔ ↑U)) ≤ X.basicOpen f)).op) x
s : Set ↑(Scheme.affineOpens X)
hs' : Set.Finite s
this : Finite ↑s
val✝ : Fintype ↑s
hs : S ⊓ ↑U = ⨆ i, ↑↑i
hs₁ : ∀ (i : ↑s), ↑↑i ≤ S
hs₂ : ∀ (i : ↑s), ↑↑i ≤ ↑U
n : ↑s → ℕ
hn : ∀ (i : ↑s) (m : ℕ), n i ≤ m → ((f |_ S) ^ (m + n₂) * y₁) |_ ↑↑i = ((f |_ ↑U) ^ (m + n₁) * y₂) |_ ↑↑i
⊢ ∃ n y,
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) y =
      (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) f ^ n * x

Next tactic:
have :
      X.presheaf.map (homOfLE <| inf_le_left).op
          (X.presheaf.map (homOfLE le_sup_left).op f ^ (Finset.univ.sup n + n₂) * y₁) =
        X.presheaf.map (homOfLE <| inf_le_right).op
          (X.presheaf.map (homOfLE le_sup_right).op f ^ (Finset.univ.sup n + n₁) * y₂) := by
      fapply X.sheaf.eq_of_locally_eq' fun i : s => i.1.1
      · refine' fun i => homOfLE _; erw [hs];
        -- Porting note: have to add argument explicitly
        exact @le_iSup (Opens X) s _ (fun (i : s) => (i : Opens X)) i
      · exact le_of_eq hs
      · intro i
        delta Scheme.sheaf SheafedSpace.sheaf
        simp only [← comp_apply, ← Functor.map_comp, ← op_comp]
        apply hn
        exact Finset.le_sup (Finset.mem_univ _)