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 

Proof state:
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 ?m.404197).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 ?m.405056).op) x
s : Set ↑(Scheme.affineOpens X)
hs' : Set.Finite s
hs : ↑S ∩ ↑↑U = ⋃ i ∈ s, ↑↑i
this : Finite ↑s
val✝ : Fintype ↑s
⊢ S ⊓ ↑U = ⨆ i, ↑↑i

Next tactic:
ext1