l3lab/ntp-mathlib huggingface dataset:
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
n : ↑s → ℕ
this✝ : Finite ↑s
val✝ : Fintype ↑s
hU : IsCompact (⨆ i, ↑↑i).carrier
x f : ↑(X.presheaf.obj (op (⨆ i, ↑↑i)))
H : x |_ X.basicOpen f = 0
h₁ : ∀ (i : ↑s), ↑↑i ≤ ⨆ i, ↑↑i
hn :
  ∀ (i : ↑s),
    (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) x =
      0
this : ∀ (i : ↑s), (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) (f ^ Finset.sup Finset.univ n * x) = 0
i : ↑s
⊢ ((Scheme.sheaf X).val.map (Opens.leSupr (fun i => ↑↑i) i).op) (f ^ Finset.sup Finset.univ n * x) =
    ((Scheme.sheaf X).val.map (Opens.leSupr (fun i => ↑↑i) i).op) 0

Next tactic:
rw [map_zero]
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
n : ↑s → ℕ
this✝ : Finite ↑s
val✝ : Fintype ↑s
hU : IsCompact (⨆ i, ↑↑i).carrier
x f : ↑(X.presheaf.obj (op (⨆ i, ↑↑i)))
H : x |_ X.basicOpen f = 0
h₁ : ∀ (i : ↑s), ↑↑i ≤ ⨆ i, ↑↑i
hn :
  ∀ (i : ↑s),
    (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) x =
      0
this : ∀ (i : ↑s), (X.presheaf.map (homOfLE (_ : ↑↑i ≤ ⨆ i, ↑↑i)).op) (f ^ Finset.sup Finset.univ n * x) = 0
i : ↑s
⊢ ((Scheme.sheaf X).val.map (Opens.leSupr (fun i => ↑↑i) i).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
apply this
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
hn : ∀ (i : ↑s), (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) x = 0
this : Finite ↑s
val✝ : Fintype ↑s
⊢ ∀ (i : ↑s), (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
intro i
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  intro i
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
hn : ∀ (i : ↑s), (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) x = 0
this : Finite ↑s
val✝ : Fintype ↑s
i : ↑s
⊢ (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
replace hn :=
    congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
      (hn i)
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  intro i
  replace hn :=
    congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
      (hn i)
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
this : Finite ↑s
val✝ : Fintype ↑s
i : ↑s
hn :
  (fun x => (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i)) * x)
      ((X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) x) =
    (fun x => (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i)) * x) 0
⊢ (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
dsimp at hn
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  intro i
  replace hn :=
    congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
      (hn i)
  dsimp at hn
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
this : Finite ↑s
val✝ : Fintype ↑s
i : ↑s
hn :
  (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i)) *
      ((X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) f ^ n i * (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) x) =
    (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i)) * 0
⊢ (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
simp only [← map_mul, ← map_pow] at hn
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  intro i
  replace hn :=
    congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
      (hn i)
  dsimp at hn
  simp only [← map_mul, ← map_pow] at hn
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
this : Finite ↑s
val✝ : Fintype ↑s
i : ↑s
hn :
  (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i) * (f ^ n i * x)) =
    (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i)) * 0
⊢ (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ Finset.sup Finset.univ n * x) = 0

Next tactic:
rwa [mul_zero, ← mul_assoc, ← pow_add, tsub_add_cancel_of_le] at hn
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
    {U : Opens X.carrier} (hU : IsCompact U.1) (x f : X.presheaf.obj (op U))
    (H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
  replace e : U = iSup fun i : s => (i : Opens X.carrier)
  · ext1; simpa using e
  have h₁ : ∀ i : s, i.1.1 ≤ U := by
    intro i
    change (i : Opens X.carrier) ≤ U
    rw [e]
    -- porting note: `exact le_iSup _ _` no longer works
    exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
  have H' := fun i : s =>
    exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
      (X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
  swap
  · delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
    convert congr_arg (X.presheaf.map (homOfLE _).op) H
    · simp only [← comp_apply, ← Functor.map_comp]
      rfl
    · rw [map_zero]
      simp only [Scheme.basicOpen_res, ge_iff_le, inf_le_right]
  choose n hn using H'
  haveI := hs.to_subtype
  cases nonempty_fintype s
  use Finset.univ.sup n
  suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
    subst e
    apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : Opens X.carrier)
    intro i
    rw [map_zero]
    apply this
  intro i
  replace hn :=
    congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
      (hn i)
  dsimp at hn
  simp only [← map_mul, ← map_pow] at hn
  rwa [mul_zero, ← mul_assoc, ← pow_add, tsub_add_cancel_of_le] at hn
  

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
Z X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
x f : ↑(X.presheaf.obj (op U))
H : x |_ X.basicOpen f = 0
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : U = ⨆ i, ↑↑i
h₁ : ∀ (i : ↑s), ↑↑i ≤ U
n : ↑s → ℕ
this : Finite ↑s
val✝ : Fintype ↑s
i : ↑s
hn : (X.presheaf.map (homOfLE (_ : ↑↑i ≤ U)).op) (f ^ (Finset.sup Finset.univ n - n i + n i) * x) = 0
⊢ n i ≤ Finset.sup Finset.univ n

Next tactic:
apply Finset.le_sup (Finset.mem_univ i)
/-- If `R` and `A` have a bijective `algebraMap R A` and act identically on `M`,
then a basis for `M` as `R`-module is also a basis for `M` as `R'`-module. -/
@[simps! repr_apply_support_val repr_apply_toFun]
noncomputable def Basis.algebraMapCoeffs : Basis ι A M :=
  b.mapCoeffs (RingEquiv.ofBijective _ h) fun c x => by 

Proof state:
R : Type u
S : Type v
A : Type w
B : Type u₁
ι : Type u_1
M : Type u_2
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : AddCommMonoid M
inst✝³ : Algebra R A
inst✝² : Module A M
inst✝¹ : Module R M
inst✝ : IsScalarTower R A M
b : Basis ι R M
h : Function.Bijective ⇑(algebraMap R A)
c : R
x : M
⊢ (RingEquiv.ofBijective (algebraMap R A) h) c • x = c • x

Next tactic:
simp
theorem linearIndependent_smul {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A}
    (hb : LinearIndependent R b) (hc : LinearIndependent S c) :
    LinearIndependent R fun p : ι × ι' => b p.1 • c p.2 := by
  

Proof state:
R : Type u
S : Type v
A : Type w
B : Type u₁
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring S
inst✝⁴ : AddCommMonoid A
inst✝³ : Algebra R S
inst✝² : Module S A
inst✝¹ : Module R A
inst✝ : IsScalarTower R S A
ι : Type v₁
b : ι → S
ι' : Type w₁
c : ι' → A
hb : LinearIndependent R b
hc : LinearIndependent S c
⊢ LinearIndependent R fun p => b p.1 • c p.2

Next tactic:
rw [linearIndependent_iff'] at hb hc
theorem linearIndependent_smul {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A}
    (hb : LinearIndependent R b) (hc : LinearIndependent S c) :
    LinearIndependent R fun p : ι × ι' => b p.1 • c p.2 := by
  rw [linearIndependent_iff'] at hb hc; 

Proof state:
R : Type u
S : Type v
A : Type w
B : Type u₁
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring S
inst✝⁴ : AddCommMonoid A
inst✝³ : Algebra R S
inst✝² : Module S A
inst✝¹ : Module R A
inst✝ : IsScalarTower R S A
ι : Type v₁
b : ι → S
ι' : Type w₁
c : ι' → A
hb : ∀ (s : Finset ι) (g : ι → R), ∑ i in s, g i • b i = 0 → ∀ i ∈ s, g i = 0
hc : ∀ (s : Finset ι') (g : ι' → S), ∑ i in s, g i • c i = 0 → ∀ i ∈ s, g i = 0
⊢ LinearIndependent R fun p => b p.1 • c p.2

Next tactic:
rw [linearIndependent_iff'']
theorem linearIndependent_smul {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A}
    (hb : LinearIndependent R b) (hc : LinearIndependent S c) :
    LinearIndependent R fun p : ι × ι' => b p.1 • c p.2 := by
  rw [linearIndependent_iff'] at hb hc; rw [linearIndependent_iff'']; 

Proof state:
R : Type u
S : Type v
A : Type w
B : Type u₁
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring S
inst✝⁴ : AddCommMonoid A
inst✝³ : Algebra R S
inst✝² : Module S A
inst✝¹ : Module R A
inst✝ : IsScalarTower R S A
ι : Type v₁
b : ι → S
ι' : Type w₁
c : ι' → A
hb : ∀ (s : Finset ι) (g : ι → R), ∑ i in s, g i • b i = 0 → ∀ i ∈ s, g i = 0
hc : ∀ (s : Finset ι') (g : ι' → S), ∑ i in s, g i • c i = 0 → ∀ i ∈ s, g i = 0
⊢ ∀ (s : Finset (ι × ι')) (g : ι × ι' → R),
    (∀ i ∉ s, g i = 0) → ∑ i in s, g i • b i.1 • c i.2 = 0 → ∀ (i : ι × ι'), g i = 0

Next tactic:
rintro s g hg hsg ⟨i, k⟩
theorem linearIndependent_smul {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A}
    (hb : LinearIndependent R b) (hc : LinearIndependent S c) :
    LinearIndependent R fun p : ι × ι' => b p.1 • c p.2 := by
  rw [linearIndependent_iff'] at hb hc; rw [linearIndependent_iff'']; rintro s g hg hsg ⟨i, k⟩
  

Proof state:
case mk
R : Type u
S : Type v
A : Type w
B : Type u₁
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring S
inst✝⁴ : AddCommMonoid A
inst✝³ : Algebra R S
inst✝² : Module S A
inst✝¹ : Module R A
inst✝ : IsScalarTower R S A
ι : Type v₁
b : ι → S
ι' : Type w₁
c : ι' → A
hb : ∀ (s : Finset ι) (g : ι → R), ∑ i in s, g i • b i = 0 → ∀ i ∈ s, g i = 0
hc : ∀ (s : Finset ι') (g : ι' → S), ∑ i in s, g i • c i = 0 → ∀ i ∈ s, g i = 0
s : Finset (ι × ι')
g : ι × ι' → R
hg : ∀ i ∉ s, g i = 0
hsg : ∑ i in s, g i • b i.1 • c i.2 = 0
i : ι
k : ι'
⊢ g (i, k) = 0

Next tactic:
by_cases hik : (i, k) ∈ s
theorem linearIndependent_smul {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A}
    (hb : LinearIndependent R b) (hc : LinearIndependent S c) :
    LinearIndependent R fun p : ι × ι' => b p.1 • c p.2 := by
  rw [linearIndependent_iff'] at hb hc; rw [linearIndependent_iff'']; rintro s g hg hsg ⟨i, k⟩
  by_cases hik : (i, k) ∈ s
  · 

Proof state:
case pos
R : Type u
S : Type v
A : Type w
B : Type u₁
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring S
inst✝⁴ : AddCommMonoid A
inst✝³ : Algebra R S
inst✝² : Module S A
inst✝¹ : Module R A
inst✝ : IsScalarTower R S A
ι : Type v₁
b : ι → S
ι' : Type w₁
c : ι' → A
hb : ∀ (s : Finset ι) (g : ι → R), ∑ i in s, g i • b i = 0 → ∀ i ∈ s, g i = 0
hc : ∀ (s : Finset ι') (g : ι' → S), ∑ i in s, g i • c i = 0 → ∀ i ∈ s, g i = 0
s : Finset (ι × ι')
g : ι × ι' → R
hg : ∀ i ∉ s, g i = 0
hsg : ∑ i in s, g i • b i.1 • c i.2 = 0
i : ι
k : ι'
hik : (i, k) ∈ s
⊢ g (i, k) = 0

Next tactic:
have h1 : ∑ i in s.image Prod.fst ×ˢ s.image Prod.snd, g i • b i.1 • c i.2 = 0 := by
      rw [← hsg]
      exact
        (Finset.sum_subset Finset.subset_product fun p _ hp =>
            show g p • b p.1 • c p.2 = 0 by rw [hg p hp, zero_smul]).symm